コード例 #1
0
ファイル: GUIFacade.cs プロジェクト: harunoni/IoTUsingModbus
        private void checkMultipleAI(analogIO aStart, analogIO aEnd)
        {
            int    num          = 2;
            byte   unit         = 1;
            ushort startAddress = aStart.InputRegister;

            comHandler.send(4, getID(), unit, startAddress, (byte)num);
        }
コード例 #2
0
ファイル: GUIFacade.cs プロジェクト: harunoni/IoTUsingModbus
 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
ファイル: GUIFacade.cs プロジェクト: harunoni/IoTUsingModbus
        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);
        }