示例#1
0
        private void checkMultipleDI(digitalIO dStart, digitalIO dEnd)
        {
            int    num          = 4;
            byte   unit         = 1;
            ushort startAddress = dStart.InputRegister;

            comHandler.send(2, getID(), unit, startAddress, (byte)num);
        }
示例#2
0
 private IO[] createIOArray(int nAnalog, int nDigital)
 {
     IO[] _ioObj = new IO[nAnalog + nDigital];
     if (nAnalog != 0 && nDigital != 0)
     {
         for (int i = 0; i < nAnalog; i++)
         {
             _ioObj[i] = new analogIO((byte)i, (byte)i);
         }
         for (int i = nAnalog; i < nAnalog + nDigital; i++)
         {
             _ioObj[i] = new digitalIO((byte)i, (byte)i);
         }
     }
     return(_ioObj);
 }
示例#3
0
        public GUIFacade(string _sName, int _sNumber)
        {
            gui = new GUI(this);
            gui.OnConnectClick    += new GUI.ConnectData(gui_onConnect);
            gui.OnReportClick     += new GUI.ReportData(gui_onReport);
            gui.OnWriteSend       += new GUI.WriteData(gui_onWriteSend);
            gui.OnReadSend        += new GUI.ReadData(gui_onReadData);
            gui.OnInputChange     += new GUI.InputData(gui_onInputChange);
            gui.OnTabChange       += new GUI.TabData(gui_OnTabCHange);
            gui.OnCheckChanged    += new GUI.CheckboxData(gui_OnCheckChange);
            gui.OnDisconnectClick += new GUI.DisconnectData(gui_OnDisconnectClick);


            if (comHandler == null)
            {
                comHandler = new ComHandler(_sName, _sNumber);
                comHandler.OnResponseData += new IoTModbus.ComHandler.ResponseData(comHandler_OnResponseData);
                comHandler.OnException    += new IoTModbus.ComHandler.ExceptionData(comHandler_OnException);
                comHandler.OnOutData      += new ComHandler.OutData(comHandler_OnOutData);
                comHandler.OnError        += new IoTModbus.ComHandler.ErrorData(comHandler_OnError);
            }

            int nAnalog  = 2;
            int nDigital = 4;

            ioObj = createIOArray(nAnalog, nDigital);

            d1 = new digitalIO(0, 0);
            d2 = new digitalIO(1, 1);
            d3 = new digitalIO(2, 2);
            d4 = new digitalIO(3, 3);

            a1 = new analogIO(0, 0);
            a2 = new analogIO(1, 1);

            tmr.Interval = 500;
            tmr.Tick    += Tmr_Tick;

            tmrKeepAlive.Interval = 1000;
            tmrKeepAlive.Tick    += TmrKeepAlive_Tick;

            Application.Run(gui);
        }