02-11-2008 03:50 PM
{
/* start of main */string card_name = "PXI-6552";
bool id_query_status = false;
bool reset_instrument_status = false;
string output_channels = "0,1,2,3,10,11,12";
string input_channels = "13";
uint misc_counter=0;
uint write_data=0x00000000;
uint mask_value=0XFFFFFFFF;
niHSDIO sig_gen = niHSDIO.InitGenerationSession(card_name,id_query_status,reset_instrument_status,"");
/* create a generation session to the Digital IO card */
sig_gen.AssignStaticChannels(output_channels);
sig_gen.ConfigureDataVoltageLogicFamily(output_channels,InstrumentDriverInterop.Ivi.niHSDIOConstants._33vLogic);
misc_counter = 0;
while(misc_counter <= 10000)
{
sig_gen.WriteStaticU32(0x00000000,mask_value);
sig_gen.WriteStaticU32(0xFFFFFFFF,mask_value);
Console.Write(misc_counter+"\n");
misc_counter++;
}
} /* end of main */
How do I close the generation session?
Regards,
Kaspar
02-12-2008 07:02 PM
02-15-2008 12:08 PM
Kaspar,
I have some more information that might help explain how (and why) the Dispose() method works. If you look at the definition of Dispose() you see that it calls a private method, Dispose(bool). This wrapper function contains a direct call to the Close() function imported from niHSDIO.dll. Thus you are calling the Close() method that you are probably used to seeing in the C version it has just been updated to work in C#. Hope this is helpful!
public void Dispose(){
this.Dispose(true);
System.GC.SuppressFinalize(this);
}
private void Dispose(bool disposing){
if ((this._disposed == false)){
PInvoke.close(this._handle);
this._handle = System.IntPtr.Zero;
}
this._disposed = true;
}