コード例 #1
0
ファイル: Client.cs プロジェクト: zfrgrbz/snap7
    //-------------------------------------------------------------------------
    // Main
    //-------------------------------------------------------------------------
    public static void Main(string[] args)
    {
        int Rack = 0, Slot = 2; // default for S7300

        // Uncomment next line if you are not able to see
        // the entire test text. (Note : Doesn't work in Mono 2.10)

        // Console.SetBufferSize(80, Int16.MaxValue-1);

        // Get Progran args
        if ((args.Length != 1) && (args.Length != 3))
        {
            Usage();
            return;
        }
        if (args.Length == 3) // only address without rack and slot
        {
            Rack = Convert.ToInt32(args[1]);
            Slot = Convert.ToInt32(args[2]);
        }
        // Client creation
        Client = new S7Client();
        // Set Async Completion Callback (without usrPtr, we don't need here).
        // You need this only if you use async functions and if you plan to
        // use a callback as done trigger.
        // In this demo we will use all 3 completion strategies.

        // Set the callbacks (using the static var to avoid the garbage collect)
        Completion = new S7Client.S7CliCompletion(CompletionProc);
        Client.SetAsCallBack(Completion, IntPtr.Zero);
        // Try Connection
        if (PlcConnect(args[0], Rack, Slot))
        {
            PerformTests();
            Client.Disconnect();
        }
        // Prints a short summary
        Summary();
        Console.ReadKey();
    }
コード例 #2
0
ファイル: Client.cs プロジェクト: jdugge/snap7
    //-------------------------------------------------------------------------  
    // Main                                  
    //-------------------------------------------------------------------------  
    public static void Main(string[] args)
    {
        int Rack = 0, Slot = 2; // default for S7300

        // Uncomment next line if you are not able to see
        // the entire test text. (Note : Doesn't work in Mono 2.10)

        // Console.SetBufferSize(80, Int16.MaxValue-1);

        // Get Progran args
        if ((args.Length != 1) && (args.Length != 3))
        {
            Usage();
            return;
        }
        if (args.Length == 3) // only address without rack and slot
        {
            Rack = Convert.ToInt32(args[1]);
            Slot = Convert.ToInt32(args[2]);
        }           
        // Client creation
        Client = new S7Client();
        // Set Async Completion Callback (without usrPtr, we don't need here).
        // You need this only if you use async functions and if you plan to 
        // use a callback as done trigger.
        // In this demo we will use all 3 completion strategies.
        
        // Set the callbacks (using the static var to avoid the garbage collect)
        Completion = new S7Client.S7CliCompletion(CompletionProc);
        Client.SetAsCallBack(Completion, IntPtr.Zero);
        // Try Connection
        if (PlcConnect(args[0], Rack, Slot))
        {
            PerformTests();
            Client.Disconnect();
        }
        // Prints a short summary
        Summary();
        Console.ReadKey();
    }