Exemplo n.º 1
3
        public void connect(string ipAddress, int rack, int slot)
        {
            MyClient = new S7Client();
            this.ipAddress = ipAddress;
            this.rack = rack;
            this.slot = slot;
            int result = MyClient.ConnectTo(this.ipAddress, this.rack, this.slot);

            if (result == 0)
            {
                Console.WriteLine("Connected to CPU at IP Address " + ipAddress);
                S7Client.S7OrderCode oc = new S7Client.S7OrderCode();
                result = MyClient.GetOrderCode(ref oc);

                if (result == 0)
                {
                    Console.WriteLine("CPU Order Code:\t" + this.orderCode);
                    S7Client.S7BlocksList bl = new S7Client.S7BlocksList();
                    result = MyClient.ListBlocks(ref bl);

                    if (result == 0)
                    {
                        Console.WriteLine("OB Count:\t" + bl.OBCount);
                        Console.WriteLine("FC Count:\t" + bl.FCCount);
                        Console.WriteLine("FB Count:\t" + bl.FBCount);
                        Console.WriteLine("DB Count:\t" + bl.DBCount);
                        Console.WriteLine("SFC Count:\t" + bl.SFCCount);
                        Console.WriteLine("SFB Count:\t" + bl.SFBCount);
                        Console.WriteLine("SDB Count:\t" + bl.SDBCount);
                    }
                    else //Failed to List Blocks
                    {
                        string error = "Failed to list blocks";
                        throw new wPlcException(error, result);
                    }
                }
                else //Failed to get Order Code
                {
                    string error = "Failed to get Order Code";
                    throw new wPlcException(error, result);
                }
            }
            else //Failed to connect to CPU
            {
                string error = "Failed to connect to CPU";
                throw new wPlcException(error, result);
            }
        }
Exemplo n.º 2
0
 public test()
 {
     InitializeComponent();
     plc = Plc.Instance;
     Worker workerObject = new Worker(plc,this);
     Thread workerThread = new Thread(workerObject.DoWork);
     // Start the worker thread.
     workerThread.Start();
 }
Exemplo n.º 3
0
 public Form1()
 {
     InitializeComponent();
     Client = new S7Client();
     if (IntPtr.Size == 4)
         this.Text = this.Text + " - Running 32 bit Code";
     else
         this.Text = this.Text + " - Running 64 bit Code";
 }
Exemplo n.º 4
0
        public MainForm()
        {
            InitializeComponent();
            Client = new S7Client();
            if (IntPtr.Size == 4)
                this.Text = this.Text + " - Running 32 bit Code";
            else
                this.Text = this.Text + " - Running 64 bit Code";

            CBType.SelectedIndex = 0;
        }
Exemplo n.º 5
0
 public INT1(S7Client plc,MainWindow mainWindow)
 {
     InitializeComponent();
     this.mainWindow = mainWindow;
     SetShowTagnamesVisibility();
     this.plc = plc;
     //
     // Check screen type for zooming settings
     //
     if (MainWindow.stat_bMultitouchS1) //Multitouch is enabled
     {
         uiScaleSlider.Visibility = Visibility.Hidden;
     }
     else
     {
     uiScaleSlider.Visibility = Visibility.Visible;
     ScaleTransform st = new ScaleTransform(uiScaleSlider.Value, uiScaleSlider.Value);
     grid1.LayoutTransform = st;
     }
 }
Exemplo n.º 6
0
    //-------------------------------------------------------------------------
    // 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();
    }
Exemplo n.º 7
0
 public void setCpuInfo(S7Client.S7CpuInfo ci)
 {
     this.moduleTypeName = cleanString(ci.ModuleTypeName);
     this.serialNumber = cleanString(ci.SerialNumber);
     this.ASName = cleanString(ci.ASName);
     this.copyright = cleanString(ci.Copyright);
     this.moduleName = cleanString(ci.ModuleName);
 }
Exemplo n.º 8
0
 public void addCpuBlock(S7Client.S7BlockInfo block, byte[] data)
 {
     this.blocks.Add(new wCpuBlock(block, data));
 }
Exemplo n.º 9
0
 public void setOrderCode(S7Client.S7OrderCode oc)
 {
     this.orderCode = cleanString(oc.Code);
     this.V1 = oc.V1;
     this.V2 = oc.V2;
     this.V3 = oc.V3;
 }
 public Worker(S7Client tmp, Concentrator_MTCB parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 11
0
 public Worker(S7Client tmp, Destoner_MTSD parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public Worker(S7Client tmp, SievingMachine_MKZF parent)
 {
     plc = tmp;
     this.parent = parent;
 }
        public byte[] write(S7Client aClient)
        {
            mNeedWrite      = false;
            byte[] lBuffer  = getValueForPLC();

            int lResult = aClient.WriteArea((int)mMemoryType, mDB, mStart, mLength, (int)mDataType, lBuffer);
            if (lResult != 0)
            {
                mConnection.reportError(Description + " " + aClient.ErrorText(lResult));
                return null;
            }
            else
            {
                return lBuffer;
            }
        }
 public Worker(S7Client tmp, Conveyor_Chain_AHKA_S parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 15
0
 public Worker(S7Client tmp, Filter_MVRT parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 16
0
 public Worker(S7Client tmp,test parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 17
0
 public Worker(S7Client tmp, Aspirator_MVSI parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public Worker(S7Client tmp, Conveyor_NFAS_M parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 19
0
 public Worker(S7Client tmp, Fan_Normal parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 20
0
 public Worker(S7Client tmp, Monitor_Stroke parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public Worker(S7Client tmp, Conveyor_Chain_MNKA50_DH parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public Worker(S7Client tmp, Conveyor_OverflowFlap parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 23
0
 public Worker(S7Client tmp, Valve_MAUB parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 24
0
 public Worker(S7Client tmp, Flowbalancer parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public void read(S7Client aClient)
 {
     if (mNeedWrite != true)
     {
         byte[] lBuff = new byte[mBufferLength];
         int lResult = aClient.ReadArea((int)mMemoryType, mDB, mStart, mLength, (int)mDataType, lBuff);
         if (lResult == 0)
         {
             setValueFromPLC(lBuff);
         }
         else
         {
             mConnection.reportError(Description + " " + aClient.ErrorText(lResult));
         }
     }
 }
Exemplo n.º 26
0
 public Worker(S7Client tmp, Level_High_Bin parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 27
0
 public Worker(S7Client tmp, Separator_MTRC parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 28
0
 public Worker(S7Client tmp, MYFC parent)
 {
     plc = tmp;
     this.parent = parent;
 }
 public Worker(S7Client tmp, RollerStand_Engage parent)
 {
     plc = tmp;
     this.parent = parent;
 }
Exemplo n.º 30
0
 public Worker(S7Client tmp, Elevator_L parent)
 {
     plc = tmp;
     this.parent = parent;
 }