Click or drag to resize

12.8 Auto-Changing between Lists

The legacy SP-ICE-1 Card implemented "On Demand" Auto-Change in which the change from one list to the other occurs after issuing the Aut_Change() control-command.

The SP-ICE-3 Card provides flow-control capabilities far exceeding those of the legacy card, but still allows simple emulation of On Demand style Auto-Change.

How to implement "On Demand" Auto-Change with the SP-ICE-3 Card

There are different approaches possible to achieve Auto-Change between two lists using the SP-ICE-3 Card. One would be using a third list that takes care of the switching between two lists by using conditional branches and BooleanVariables.

  1. Create two BooleanVariables, to indicate if the two lists are ready or not.

  2. Create a control list that takes care of the switching between the two lists by using conditional branches.

  3. Create List 1, and set one of the flags to false at the begining of the list using BooleanVariable.

  4. Create List 2, and set the other flag to false at the begining of the list.

  5. Now set both flags to true and start executing the control list.

  6. Wait for one of the lists to be idle, replace the list that is idle and indicate that the list is ready again by changing the boolean variable of the list to true using BooleanVariableAPISetValue.

    Continue this step as long as you want.

The following code example shows a possible implementation of the solution described above.

C#
using ( ClientAPI client = new ClientAPI() )
{
    client.Connect( myCardIP );
    client.System.ResetToDefaults();

    ScannerConfig sc = client.Scanner.GetConfig();
    sc.FieldSize = new Point3D( 65000, 65000, 1 );
    client.Scanner.SetConfig( sc );

    ProcessVariables pv = client.Process.GetVariables();
    pv.EvaluationLeadTime = 10000;
    pv.JumpSpeed = 2;
    pv.MarkSpeed = 0.1;
    client.Process.SetVariables( pv );

    client.Variables.BooleanVariable.Create( "ListReady0", false );
    client.Variables.BooleanVariable.Create( "ListReady1", false );

    const int controlListID = 100;
    CommandList controlList = new CommandList();
    controlList.AppendBranchList( 0, "ListReady0" );
    controlList.AppendBranchList( 1, "ListReady1" );
    controlList.AppendBranchAbs( 0, "ListReady0" );
    controlList.AppendBranchAbs( 1, "ListReady1" );

    CommandList[] list = new CommandList[2];
    list[0] = new CommandList();
    list[0].AppendBooleanSet( "ListReady0", false );
    list[0].AppendJumpAbs( 0, 0 );
    list[0].AppendMarkRel( 0, 20000 );
    list[0].AppendMarkRel( 20000, 0 );
    list[0].AppendMarkRel( 0, -20000 );
    list[0].AppendMarkRel( -20000, 0 );

    list[1] = new CommandList();
    list[1].AppendBooleanSet( "ListReady1", false );
    list[1].AppendJumpAbs( 0, 0 );
    list[1].AppendMarkRel( -20000, 0 );
    list[1].AppendMarkRel( 0, -20000 );
    list[1].AppendMarkRel( 20000, 0 );
    list[1].AppendMarkRel( 0, 20000 );

    client.List.Set( controlListID, controlList );
    client.List.Set( 0, list[0] );
    client.List.Set( 1, list[1] );

    client.Variables.BooleanVariable.SetValue( "ListReady0", true );
    client.Variables.BooleanVariable.SetValue( "ListReady1", true );
    client.List.Execute( controlListID );

    int? idleId = null;
    const int iterations = 10;
    for ( int iteration = 0; iteration < iterations; iteration++ )
    {
        client.List.WaitForListIdle( out idleId );
        Console.WriteLine( "List {0} idle.", idleId );
        if ( idleId != controlListID )
        {
            Console.WriteLine( "Replacing list {0}", idleId );
            client.List.Set( idleId.Value, list[idleId.Value] );
            client.Process.SetValue( listReady[idleId.Value], true );
        }
        else
        {
            Console.WriteLine( "List was not replaced in time. Restarting!" );
            client.List.Execute( controlListID );
        }
    }

    do
    {
        client.List.WaitForListIdle( out idleId );
        Console.WriteLine( "List {0} idle.", idleId );
    } while ( idleId.HasValue && idleId.Value != controlListID );

    int? doneId;
    client.List.WaitForListDone( out doneId );

    client.Disconnect();
}