Exemple #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");
            }
        }
Exemple #2
0
 public bool DisConnect()
 {
     try
     {
         int num = MXIO_CS.MXEIO_Disconnect(this.hConnection[0]);
         MXIO_CS.MXEIO_Exit();
         return(num == 0);
     }
     catch (Exception exception)
     {
         CLog.WriteErrLogInTrace(string.Format("在设置IO端口状态时出错,{0}", exception.Message));
         return(false);
     }
 }
Exemple #3
0
        /// <summary>
        /// Closes the connection to this device.
        /// </summary>
        public void Close()
        {
            if (!Connected)
            {
                return;
            }

            MoxaStatus status = (MoxaStatus)MXIO_CS.MXEIO_Disconnect(_hConn[0]);

            if (status != MoxaStatus.Ok)
            {
                throw new IOException(this, String.Format("Failed to disconnect from Moxa ioLogic1200 device '{0}'.", Name));
            }

            Connected = false;
        }
Exemple #4
0
 public override void Close()
 {
     MXIO_CS.MXEIO_Disconnect(this.connection);
 }