10-29-2013 06:05 AM - edited 10-29-2013 06:09 AM
Hello,
Configuration: VeriStand 2011SP1, VisualStudio 2010
I need to deal with the VeriStand calibaration API. I have developped a Windows Form and the folowing code is called upon a button click:
private /*List<Calibration>*/ void GetAllCalibrations()
{
toolStripProgressBar1.Value = 0;
toolStripStatusLabel1.Text = "";
//var cals = new List<Calibration>();
var w = new Factory().GetIWorkspace2();
NodeInfo[] channels;
var vserror = w.GetSystemNodeChannelList("", out channels);
if (vserror.IsError) throw new VeriStandException(vserror);
ScaleType scaleType;
double[] ais;
ThermocoupleType thermocoupleType;
TemperatureUnits temperatureUnits;
CJCType cjcType;
string cjcChannel;
double offset;
double scale;
int i = 0;
var ical = new Factory().GetICalibration("localhost");
foreach (var c in channels)
{
toolStripStatusLabel1.Text = c.Name;
toolStripProgressBar1.Value = (int)(100.0 * i / channels.Count());
i++;
double value;
w.GetSingleChannelValue(c.FullPath, out value);
System.Diagnostics.Debug.WriteLine(c.Name + "=" + value);
if (c.IsScalable)
{
ical.GetCalibration(c.FullPath, out scaleType, out ais, out thermocoupleType, out temperatureUnits, out cjcType, out cjcChannel, out offset, out scale);
}
//if (c.IsScalable)
//{
// var cal = new Calibration(ical, c.FullPath);
// if (cal.IsCalibrated)
// {
// cals.Add(cal);
// }
//}
}
toolStripProgressBar1.Value = 0;
toolStripStatusLabel1.Text = "";
return cals;
}
The VeriStand project, I connect to has a large number of channels (and a lot of them are scalable). When running this code, randomly (somtimes after 1000 calls, sometimes after 10000 ...), it gets definitively blocked into the "GetCalibration" method of the API. The only way to unblock is to kill the process.
The project can run on the local Windows PC or remotely to the RT target, the issue is the same.
Remark: To reproduce the issue more easily, enclose the foreach loop into an other for loop
How can I bypass that issue ? Thanks for your replies.
Best Regards
Solved! Go to Solution.
10-29-2013 08:11 AM - edited 10-29-2013 08:12 AM
Some more info: I'm trying to execute the code from a background thread and it seems to work better. Maybe there is a conflict with the UI thread ?
10-31-2013 01:51 PM
Hello,
What do you mean when you say 1000 or 10000. Is it the number of channels or the calls of GetAllCalibrations()?
Paolo_P
Certified TestStand Architect
Certified LabVIEW Architect
National Instruments France
11-04-2013 01:45 AM
Hi,
No its the number of calls to the API. Actually the blocking can arise in any API call (not only the GetCalibration).
I have modified my code so any API call is now issued from a "BackgroundWorker" thread and it seems to fix the problem. It would just be nice to know why there is a stall when it's called from the UI thread.
Regards
12-17-2013 10:29 AM
The solution is to not use UI Threads, but I don't know why, or if there is a better solution than using background threads.