09-14-2006 01:07 PM
LabVIEW.Application lv;
LabVIEW.VirtualInstrument vi;
lv = new LabVIEW.ApplicationClass(); //Set the path to the VI string vipath=@"C:\Demo\Monitor.VI";vi= lv.GetVIReference(vipath,
"",true);string
[] str1 = new String[2];str1[
0]="IntegerValue";str1[
1]="Read StringValue"; //The wrapper function expects to be passed a object type by reference. //We pass the string array to the object type here object param1 = (object)str1; //Define the variable that will pass the expression to be evaluated to //LabVIEW and typecast it to type object object[] str2 = new object[2]; str2[0] = 0;str2[
1] = ""; object param2= (object)str2;vi.Call2(
ref param1,ref param2,true,false,false,true);lv.Quit();
}
I am arraching project and Vi's run picture.
09-15-2006 02:08 PM
kkumud,
When you move your cursor over the red arrows, what text appears?
Chris C
05-17-2012 08:16 AM
Looks like the shared variable links are broken if they are red. Open the Distributed System Manager and check the names of your variables. You can also create and delete shared variables in the C# code at run time, like this:
// create network variables for LabView communication string processName = "COR"; if (ServerProcess.Exists(processName)) { ServerProcess.Delete(processName); } ServerProcessInfo procInfo = ServerProcess.Create(processName, true); ServerVariableInfo varInfo_K = procInfo.CreateVariable("K", false, 0); varInfo_K.VariableType = Type.GetType("System.Double"); ServerVariableInfo varInfo_R2 = procInfo.CreateVariable("R2", false, 0); varInfo_R2.VariableType = Type.GetType("System.Double"); ServerVariableInfo varInfo_T2 = procInfo.CreateVariable("T2", false, 0); varInfo_T2.VariableType = Type.GetType("System.Double"); ServerVariableInfo varInfo_timeArray = procInfo.CreateVariable("timeArray", false, 0); varInfo_timeArray.VariableType = Type.GetType("System.Double[]"); ServerVariableInfo varInfo_resistanceArray = procInfo.CreateVariable("resistanceArray", false, 0); varInfo_resistanceArray.VariableType = Type.GetType("System.Double[]");
Then, when you are ready to read/write the variables, define them as follows:
NetworkVariableWriter<double> writer_K = new NetworkVariableWriter<double>("\\\\localhost\\COR\\K"); NetworkVariableWriter<double[]> writer_time = new NetworkVariableWriter<double[]>("\\\\localhost\\COR\\timeArray"); NetworkVariableWriter<double[]> writer_resistance = new NetworkVariableWriter<double[]>("\\\\localhost\\COR\\resistanceArray"); NetworkVariableReader<double> reader_R2 = new NetworkVariableReader<double>("\\\\localhost\\COR\\R2"); NetworkVariableReader<double> reader_T2 = new NetworkVariableReader<double>("\\\\localhost\\COR\\T2");
There is a more robust way to get the URL for each variable, but I have had problems with them in the past because the format is a little different than the complier needs.
When you are ready to write or read from a variable, just use the WriteData() or ReadData() methods:
writer_K.Connect(); writer_K.WriteValue(k);
Hope this helps you out.
-Eric