02-25-2008 01:42 PM
02-25-2008 03:16 PM
02-26-2008 08:00 AM
I have a fully developed C# program with many classes. It uses several threads. I have created a new class to hold TestStand compliant functions depending upon type (Action, NumLimit, etc.). My main program uses many double arrays in the test class to store data. I haven't been able to hook up TestStand to this class. I created StationGlobal variables of the ref type and can set them to my test arrays on start. When I run a sequence however the StationGlobal references become null. I ended up putting a custom container class in TestStand to hold test arrays.
The second problem is hooking up my hardware class that references DAQmx libraries from CSharp. Will references to these functions cause a problem when run from within TestStand? Can I use the existing reference to my hardware class or do I need to create a separate instance in TestStand by using my class constructor. My board will only allow one reference at a time.
This is just a exploratory program to see how involved it will be to incorporate TestStand into our existing programs.
02-26-2008 08:48 AM
Hi,
In this there is an access to TestStand arrays.
http://forums.ni.com/ni/board/message?board.id=330&message.id=17787&query.id=56418#M17787
By the way i know thats not what your are looking for. You are searching the other way round.
Makeing the arrays accessible to Teststand.
Can you please post a small example of your code. Constructor and maybe 2 public Members with dummy stuff in enough
(source code in VS8 would be great). So I can and ohter members here can take a look into it.
For your second problem: Reference Storage can be done. Take a look in upper exsample.
Greetings
juergen
02-26-2008 12:02 PM
Some code snippets
//This is in the main csharp code (_Load)
//set StationGlobals for TestStand
TS.API.PropertyObject obj3 = axApplicationMgr.GetEngine().Globals;
//These are all StationGlobal 'ref' types
//TF is an instance of a class in my program
//MainForm is the CSharp form class
obj3.SetValVariant("TF", 0, CTF);
obj3.SetValVariant("ApplicationManager", 0, this.axApplicationMgr);
obj3.SetValVariant("MainForm", 0, MainForm1);
//at this point I can access all members of these instances like this
TestFunctions TF = (TestFunctions) obj3.GetValVariant("TF", 0);
MainForm MF = (MainForm) obj3.GetValVariant("MainForm", 0);
//the sequence file is loaded in the main module
Sequence += TestSuite.Substring(0, TestSuite.Length - 4) + ".seq";
//load test stand sequence
TS.API.SequenceFile sf = axApplicationMgr.OpenSequenceFile(Sequence);
//reload limits
TS.API.Step step = axSequenceFileViewMgr.Sequence.GetStep(2, TS.API.StepGroups.StepGroup_Main);
//MessageBox.Show(step.StepType.Name);
TS.API.PropertyObject obj = step.AsPropertyObject();
obj.SetValNumber("Limits.Low", 0, 0);
limit += 1.0;
obj.SetValNumber("Limits.High", 0, 2000);
//at this point I can still access all members of these instances like this
TestFunctions TF = (TestFunctions) obj3.GetValVariant("TF", 0);
MainForm MF = (MainForm) obj3.GetValVariant("MainForm", 0);
//code the sequence calls defined by Specify Module - Action step
//this code is in a separate class
public void CollectSimulatedData(SequenceContext seqContext, out String reportText, out bool errorOccurred, out int errorCode, out String errorMsg)
{
reportText = "CollectSimulatedData";
errorOccurred = false;
errorCode = 0;
errorMsg = String.Empty;
try
{
//connect to the current TestStand app
TS.API.PropertyObject obj3 = seqContext.StationGlobals;
axApplicationMgr = (NationalInstruments.TestStand.Interop.UI.Ax.AxApplicationMgr) obj3.GetValVariant("ApplicationManager", 0);
//create objects from station references
TestFunctions TF = (TestFunctions) obj3.GetValVariant("TF", 0);
MainForm frm = (MainForm) obj3.GetValVariant("MainForm", 0);
//this results in a null value for TF
}
catch
{
}
}
It appears that user defined classes need to be defined in TestStand as CustomContainers.
We can discuss hardware later.
02-27-2008 12:58 AM
Hi ,
I have rewritten my Example LocalLoader and and played with Excel Application reference.
Now there are 2 classes.
Class LocalLoader creates an Excel Application and stores the reference in a "Locals.hExcel" all this is done in the constructor
There is only one public member it gets the Excel reference and creates a xls on disk.
Class LocalLoaderExtern only gets only the SequenceContext ( in LocalLoader,too) in constructor.
The member get the Excel Handle from Variable and read the xls file.
In your code i saw you are using StationGlobals. I do not recommend this because the variables are stored on disk.
But when TS is running they are on File and on Memory, too and when Execution is over they do strange thinks. At the moment have not used to them for "dynamic" data.
I used them only for Machine initialisation stuff like path reading.
There are lot of good answers out in this forum, escpecially from Ray Farmer.
http://forums.ni.com/ni/board/message?board.id=330&thread.id=18389
So let's hope that Ray Farmer will read this thread and give us some advice
Greetings
juergen
02-29-2008 02:51 PM
08-08-2022 03:50 AM
Hello,
I'am the new about the c# developing using NI daq.
I'm trying to get the data using several daq.
However, there are errors when I connect several daq...
How can I get multi data using c#?
Can I get a sample code?
Thanks