10-23-2008 09:18 AM
I'm not sure if I am doing something wrong, or if the Switch Front Panel isn't expected to reflect the results of my code. I have a virtual 1163 cart setup in MAX. I start the Switch Soft Front Panel and can see the state of the channels. I have auto refresh turned on.
My C++ code has a task generated by the .mxb file. The channel is configured this way:
void CDAQmxTask::Configure()
{
CNiDAQmxDOChannel ch = DOChannels.CreateChannel("SC1Mod6/port0/line2", "DigitalOut", DAQmxOneChannelForEachLine);
ch.InvertLines = false;
}
For simplicity sake, I create a gobal instance of this class at the top of the dlg class file:
CDAQmxTask task;
I have a single button that when pressed should turn on channel 2
void CFVT_TestAppDlg::OnBnClickedButton1()
{
task.Stop();
CNiDAQmxDigitalSingleChannelWriter* writer = new CNiDAQmxDigitalSingleChannelWriter(task.Stream);
writer->WriteSingleSampleSingleLine(TRUE, TRUE);
delete writer;
}
Should I expect to see teh results of this code in either the Schematic or Relays tab of SwitchSoft FP?
10-28-2008 10:32 AM
AiR_GuNNeR,
You will not see the NI-Switch Soft Front Panel (SSFP) update to reflect the results of your Visual Studio code. This is because NI-Switch is an IVI compliant driver, and IVI compliance for switches requires the driver to be able to open multiple driver sessions with one switch. As a result, your C++ program and the SSFP have each established a seperate, independant IVI driver session to the switch.
For example, if your C++ program instructs Relay 1 to close, the relay will close. Then, if the SSFP instructs Relay 1 to close, nothing will happen since the relay is already closed. The SSFP can also instruct Relay 1 to open, and it will, regardless of the fact that your C++ program gave no such command.
As a result, it is important that for switching applications, you be sure that you only have one session open to a given switch at a time, otherwise you may see unexpected behavior. This can even happen within an application.
You can lock a session within your application so that no other thread in your application can access that driver session. Do this using the niSwitch_LockSession function. You can find more information on this function in the NI-Switch shipping help.