LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CNVSetVariableAttribute and CNVVariablePrototypeAttribute

Solved!
Go to solution

I am using LabWindows/CVI 2009 and attempting to create Network variables within my c source. I am able to create the variable and set 'Single Writer' and 'Buffer Max Items' attributes but when attempting to set the prototype to boolean, no value parameter appears to work. Could anyone please advise what parameter I should use to prevent all my variables being of variant data type.

CNVNewVariable(process, name);
CNVSetVariableAttribute(process, nameCNVVariableSingleWriterAttribute, 0);
CNVSetVariableAttribute(process, name, CNVVariableServerBufferMaxItemsAttribute, 64);
CNVSetVariableAttribute(process, name, CNVVariablePrototypeAttribute, NotSureWhatToPutHere);

Regards

 

0 Kudos
Message 1 of 5
(3,203 Views)
What about using CNVCreateScalarDataValue or CNVCreateArrayDataValue? The second parameter of this function permits you to choose the data type.
0 Kudos
Message 2 of 5
(3,199 Views)
Using either of them calls adds data in the variant storage area but does not change the actual data type when reviewed from within the Distributed System Manager 2009. It is still a Variant. I would like this to show a boolean allowing me to edit the value manually from within the Manager.
0 Kudos
Message 3 of 5
(3,190 Views)
Solution
Accepted by Wildmind

Hi Atroyd,

 

I'm afraid I don't have CVI 2009 installed right now so I can't test this, but a previous Service Request mentions the following works in CVI 2009 (will not work in 9.0 which is what I have installed currently, CVI 2009 is not the same as 9.0):

 

CNVData myData; 

CNVNewVariable ("shared", "MyVariable"); 
CNVCreateScalarDataValue (&myData, CNVDouble, 20.0); 
CNVSetVariableAttribute ("shared", "MyVariable", CNVVariablePrototypeAttribute, myData);  

The code above creates a new variable called "MyVariable" in a process called "shared" that I already have on my computer. The next line creates a network variable pointer called "myData" and gives it a type of double and a value of 20 (myData must be initialized just as it is in the first line). The final line takes MyVariable and gives it the attributes of myData (mainly the data type double and the value of 20).

 

Please let me know if that works for you. 

Regards,


Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants

0 Kudos
Message 4 of 5
(3,168 Views)

Thank you for the reply. It has caused a partial success. The datatype is now as required but the default value is not recorded. Distributed System Manager reports a value of 'No Known Value'. Setting the default value after the supplied code corrects for this situation.

 

Regards

Atroyd

 

0 Kudos
Message 5 of 5
(3,150 Views)