Visual C#

It is an example program in Visual C#. The conversion data and error contents are displayed in output window.
Example program by using AioSingleAi

Example program by using AioMultiAi


Example program by using AioSingleAi

//---------------------------
// Variable declaration
//---------------------------

int Ret;            //Return values of functions
short Id;           //ID
string ErrorString; //Array for storing error string
int AiData;         //Conversion data

//---------------------------
// Initialize device
// Devicename : Aio000
//---------------------------

Ret = aio.Init( "Aio000" , out Id );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.Init : " + ErrorString );
    return;
}

//---------------------------
// Set analog input method
// Input method : Single-end input
//---------------------------

Ret = aio.SetAiInputMethod( Id , 0 );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.SetAiInputMethod : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}

//---------------------------
// Set analog input range
// Range : -10 to 10V
//---------------------------

Ret = aio.SetAiRangeAll( Id , (short)CaioConst.PM10 );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.SetAiRangeAll : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}

//---------------------------
// Analog input to the specified channel only once
// Input channel : 0
//---------------------------

Ret = aio.SingleAi( Id , 0 , out AiData );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.SingleAi : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}
System.Diagnostics.Trace.WriteLine( "Channel0F" + AiData.ToString() );

//---------------------------
// Device exit
//---------------------------

Ret = aio.Exit( Id );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.Exit : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}


Example program by using AioMultiAi

//---------------------------
// Variable declaration
//---------------------------

int Ret;                   //Return values of functions
short Id;                  //ID
string ErrorString;        //Array for storing error string
int[] AiData = new int[8]; //Conversion data
short i;

//---------------------------
// Initialize device
// Devicename : Aio000
//---------------------------

Ret = aio.Init( "Aio000" , out Id );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.Init : " + ErrorString );
    return;
}

//---------------------------
// Set analog input method
// Input method : Single-end input
//---------------------------

Ret = aio.SetAiInputMethod( Id , 0 );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.SetAiInputMethod : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}

//---------------------------
// Set analog input range
// Range : -10 to 10V
//---------------------------

Ret = aio.SetAiRangeAll( Id , (short)CaioConst.PM10 );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.SetAiRangeAll : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}

//---------------------------
// Analog input to multiple channels only once
// Number of input channels : 8
//---------------------------

Ret = aio.MultiAi( Id , 8 , out AiData );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.MultiAi : " + ErrorString );
    Ret = aio.Exit( Id );
    return;
}

for( i = 0 ; i < 8 ; i++ )
{
    System.Diagnostics.Trace.WriteLine( "Channel" + i.ToString() + ":" + AiData[i] );
}

//---------------------------
// Device exit
//---------------------------

Ret = aio.Exit( Id );
if( Ret != 0 )
{
    aio.GetErrorString( Ret , out ErrorString );
    System.Diagnostics.Trace.WriteLine( "aio.Exit : " + ErrorString );
    return;
}