示例#1
1
        private void eXX_DO_Write(string IPAddr, UInt16 Port, UInt32 Timeout, byte Channel, uint Value, int ModuleType)
        {
            Int32[] hConnection = new Int32[16];
            string  Password    = "";
            int     ret         = 0;

            try
            {
                this.myLog.LogAlert(AlertType.System, this.id.ToString(), this.GetType().ToString(), "e1K_DO_Write()", "IPAddr = " + IPAddr.ToString(), "system");
                int init = MXIO_CS.MXEIO_Init();

                if ((MXIO_ModuleType)ModuleType == MXIO_ModuleType.E1212)
                {
                    ret = MXIO_CS.MXEIO_E1K_Connect(System.Text.Encoding.UTF8.GetBytes(IPAddr), Port, Timeout, hConnection, System.Text.Encoding.UTF8.GetBytes(Password));
                    ret = MXIO_CS.E1K_DO_Writes(hConnection[0], Channel, 1, Value);
                    MXIO_CS.MXEIO_Disconnect(hConnection[0]);
                }
                else if ((MXIO_ModuleType)ModuleType == MXIO_ModuleType.E2210)
                {
                    byte bytSlot = 0;
                    ret = MXIO_CS.MXEIO_Connect(System.Text.Encoding.UTF8.GetBytes(IPAddr), Port, Timeout, hConnection);
                    ret = MXIO_CS.DO_Writes(hConnection[0], bytSlot, Channel, 1, Value);
                    MXIO_CS.MXEIO_Disconnect(hConnection[0]);
                }

                MXIO_CS.MXEIO_Exit();

                if (ret != 0)
                {
                    this.myLog.LogAlert(AlertType.Error, this.id.ToString(), this.GetType().ToString(), "e1K_DO_Write()",
                                        "Error code, ret = " + ret.ToString(), "system");
                }
            }
            catch (Exception ex)
            {
                this.myLog.LogAlert(AlertType.Error, this.id.ToString(), this.GetType().ToString(), "e1K_DO_Write()",
                                    ex.ToString(), "system");
            }
        }