public void Init(string COM)
        {
            string path = System.Environment.CurrentDirectory;

            path = path.Replace("\\", "\\\\");
            path = path.Insert(path.Length, "DMT.dll"); // obtain the relative path where the DMT.dll resides

            hDMTDll     = LoadLibrary(path);            // explicitly link to DMT.dll
            conn_num    = Convert.ToInt32(COM.Replace("COM", ""));
            CloseModbus = CloseSerial;
            status      = OpenModbusSerial(conn_num, 9600, 7, 'E', 1, 1);
            if (status == -1)
            {
                throw new Exception("Serial Connection Failed");
            }
        }
コード例 #2
0
        private void Init()
        {
            string path = System.Environment.CurrentDirectory;

            path = path.Replace("\\", "\\\\");
            path = path.Insert(path.Length, "DMT.dll"); // obtain the relative path where the DMT.dll resides

            hDMTDll     = LoadLibrary(path);            // explicitly link to DMT.dll
            CloseModbus = CloseSocket;
            IPAddress ipaddress = IPAddress.Parse(IP);

            ip     = BitConverter.ToInt32(ipaddress.GetAddressBytes(), 0);
            status = OpenModbusTCPSocket(conn_num, ip);
            if (status == -1)
            {
                throw new Exception("Socket Connection Failed");
            }
        }
コード例 #3
0
        public void Init(string ComOrIp, int mode)
        {
            string path = System.Environment.CurrentDirectory;

            path = path.Replace("\\", "\\\\");
            path = path.Insert(path.Length, "DMT.dll"); // obtain the relative path where the DMT.dll resides

            hDMTDll = LoadLibrary(path);                // explicitly link to DMT.dll

            //mode:0 串口
            //mode:1 网口
            switch (mode)
            {
            case 0:
                comm_type   = 0;
                strProduct  = "DVP";
                conn_num    = Convert.ToInt32(ComOrIp.Replace("COM", ""));
                CloseModbus = CloseSerial;
                status      = OpenModbusSerial(conn_num, 9600, 7, 'E', 1, 1);//波特率9600,数据位7,停止位1,偶校验,ASCII
                if (status == -1)
                {
                    throw new Exception("Serial Connection Failed");
                }
                break;

            case 1:
                comm_type   = 1;
                strProduct  = "AS";
                CloseModbus = CloseSocket;
                IPAddress ipaddress = IPAddress.Parse(ComOrIp);    //192.168.1.5
                int       ip        = BitConverter.ToInt32(ipaddress.GetAddressBytes(), 0);
                status = OpenModbusTCPSocket(conn_num, ip);
                if (status == -1)
                {
                    throw new Exception("Socket Connection Failed");
                }
                break;

            default:
                throw new Exception("illegal Mode");
                //break;
            }
        }
コード例 #4
0
        /// <summary>
        /// 最后清理.</summary>
        public void Cleanup()
        {
            _luaInit         = null;
            _luaRecycle      = null;
            _luaOpen         = null;
            _luaClose        = null;
            _luaUpdate       = null;
            _luaPause        = null;
            _luaResume       = null;
            _luaCover        = null;
            _luaReveal       = null;
            _luaRefocus      = null;
            _luaDepthChanged = null;

            _workerTable = null;

            if (_scriptEnv != null)
            {
                _scriptEnv.Dispose();
            }
            _scriptEnv = null;
        }
コード例 #5
0
ファイル: Imap4Client.cs プロジェクト: vipwan/CommunityServer
 public IAsyncResult BeginClose(AsyncCallback callback)
 {
     this._delegateClose = this.Close;
     return this._delegateClose.BeginInvoke(callback, this._delegateClose);
 }