07-27-2012 08:25 PM
I am using CVI full feature OI. In CVI code it creates station globals.
1. If I run the deployed exe the station globals do not get created and a error -17306 variable not found is retuned.
2. If I run the code in debug mode and step through then the station globals are created. Moreover once the station globals are created (by running the code in debug mode) and then I run the exe it always creates the station globals (even if I delete the station globals from INI file)
Is there anything the CVI code does to registry? Attach is snippet of code where the station global is created.
TIA.
07-30-2012 05:12 PM
Hello lvrat,
I don't believe that the CVI code would make any changes to the registry; not sure how that would affect how these station global are created.
Could you reproduce a small sample program on your end that we can try to replicate over here at National Instruments? The version of both TestStand and LabWindows/CVI would be important to know as well as the OS.
07-31-2012 07:15 PM
You are correct, it has nothing to do with registry which I thought initially.
I am creating numeric, string and array globals from CVI. Numeric and strings get created but when the control reaches array variable it creates one array and stops.
In other words if I have 5 arrays to be created as globals I need to relaunch operator interface 5 times for all five array globals to be created.
Is this a bug with TS_PropertyNewSubProperty function? Using CVI 8.5.
Here is the code to create arrays:
//Check if the Station Global variable Temp[] already exists
tsErrChk(TS_PropertyExists(TS_Globals, &errorInfo, "Temp", 0, &propertyExists));
if (!propertyExists)
{
//Create the Station Global
tsErrChk(TS_PropertyNewSubProperty (TS_Globals, NULL, "Temp", TS_PropValType_Number, VTRUE, "", 0));
// Set the default value
tsErrChk(TS_PropertySetValNumber(TS_Globals, &errorInfo, "Temp", 0, 0));
}
08-01-2012 11:45 AM
It could be a bug, I will need to try and replicate it. Can you provide the TestStand version as well?
08-01-2012 12:46 PM
TestStand version is 4.1.
08-02-2012 06:28 PM
Thanks, I'm looking into it. I'll post here once I find something.
08-14-2012 06:26 PM
Hello Jacob,
Any findings on the post? Is there a workaround such that all globals are created at first launch of operator interface?
thanks!!
08-16-2012 05:27 PM
Hello lvrat,
Sorry, however I'm still working on it. I'll post back soon.
08-23-2012 03:34 PM
Hello lvrat,
Sorry for the delay. I have tested multiple different configurations and have not been able to replicate the error. In fact the code that you provided to create arrays does not run on my TestStand. It provides an error at TS_PropertySetValNumber, since you are trying to set a numeric value to a numeric array.
Here is the code that I used to create station global arrays and populate them; it worked in both an exe and the development enviroment.
//accessing TS StationGlobals
tsErrChk(TS_EngineGetGlobals (gMainWindow.engine, &errorInfo, &TS_Globals));
//Check if the Station Global variable MonitorStarted already exists
tsErrChk(TS_PropertyExists(TS_Globals, &errorInfo, "globalname", 0, &propertyExists));
if (!propertyExists)
{
//Create the Station Global
tsErrChk(TS_PropertyNewSubProperty (TS_Globals, NULL, "globalname", TS_PropValType_Number, VTRUE, "", 0));
// get a property object reference to the new global that was created
tsErrChk(TS_PropertyGetPropertyObject (TS_Globals, NULL, "globalname", 0, &MyGlobal));
// Set the size of the array
tsErrChk(TS_PropertySetNumElements (MyGlobal, NULL, 5, 0));
// set a value
tsErrChk(TS_PropertySetValNumber(TS_Globals, &errorInfo, "globalname[0]", 0, 2));
}
CA_DiscardObjHandle(MyGlobal);
CA_DiscardObjHandle(TS_Globals);
08-27-2012 09:55 PM
Hello Jacob,
In CVI I need to create a empty array, initialize the array to 0 but not define the size of array. Size of array gets populated in TestStand.
Therefore after TS_PropertyNewSubProperty function I used TS_PropertySetValNumber to intialize to zero.
So that gets rid of the two statements below as you provided in the code:
// get a property object reference to the new global that was created
tsErrChk(TS_PropertyGetPropertyObject (TS_Globals, NULL, "globalname", 0, &MyGlobal));
// Set the size of the array
tsErrChk(TS_PropertySetNumElements (MyGlobal, NULL, 5, 0));
Which brings it back to the code I have (replaced with your code) and it does not complete the creation of variables found after the array.
//Create the Station Global
tsErrChk(TS_PropertyNewSubProperty (TS_Globals, NULL, "globalname", TS_PropValType_Number, VTRUE, "", 0));
// set a default value
tsErrChk(TS_PropertySetValNumber(TS_Globals, &errorInfo, "globalname", 0, 0));
Is it that the arrays do not need to be initialized?
Thanks.