Exemplo n.º 1
0
        private void SendToClient(int clientId, byte[] command)
        {
            short iCmdLen = Convert.ToInt16(command.Length);

            if (System.Configuration.ConfigurationSettings.AppSettings["TestMode"] == "1")
            {
                GW21API.AB_DCS_DspStrC(clientId, ref command, iCmdLen);
            }
            else
            {
                GW21API.AB_DCS_DspStrC(clientId, ref command[0], iCmdLen);
            }
        }
Exemplo n.º 2
0
        public void Close()
        {
            DSC19ClientStatus status = (DSC19ClientStatus)GW21API.AB_GW_Status(NodeID);

            if (status == DSC19ClientStatus.Connecting)
            {
                int iReturn;
                iReturn = GW21API.AB_GW_Close(NodeID);
                if (iReturn > 0)
                {
                    ClientStatus = DSC19ClientStatus.Closed;
                }
            }
        }
Exemplo n.º 3
0
        private byte[] ReceiveFromClient(ref int clientId)
        {
            short iSubCmd  = -1;
            short iCmdType = -1;
            short iCmdLen  = 512;

            byte[] data = new byte[iCmdLen];
            short  ret  = 0;

            if (System.Configuration.ConfigurationSettings.AppSettings["TestMode"] == "1")
            {
                ret = GW21API.AB_Tag_RcvMsg(ref clientId, ref iSubCmd, ref iCmdType, ref data, ref iCmdLen);
            }
            else
            {
                ret = GW21API.AB_Tag_RcvMsg(ref clientId, ref iSubCmd, ref iCmdType, ref data[0], ref iCmdLen);
            }
            if (ret <= 0)
            {
                return(new byte[0]);
            }
            if (iCmdLen > 1)
            {
                for (int i = 0; i < 2; i++)
                {
                    byte ch = data[iCmdLen - 1];
                    if (ch == 10 || ch == 13)
                    {
                        iCmdLen--;
                    }
                }
            }
            if (iCmdLen > 0)
            {
                //this.ClientID = clientId;
            }
            string strRetMsg = System.Text.UTF8Encoding.UTF8.GetString(data, 0, iCmdLen);

            byte[] revData = System.Text.UTF8Encoding.UTF8.GetBytes(strRetMsg);
            return(revData);
        }
Exemplo n.º 4
0
        public void Open()
        {
            try
            {
                DSC19ClientStatus status = (DSC19ClientStatus)GW21API.AB_GW_Status(NodeID);

                if (status != DSC19ClientStatus.Connecting)
                {
                    ClientStatus = (DSC19ClientStatus)GW21API.AB_GW_Open(NodeID);
                    System.Threading.Thread.Sleep(200);
                    status = (DSC19ClientStatus)GW21API.AB_GW_Status(NodeID);
                }
                ClientStatus = status;
            }
            catch (Exception ex)
            {
                if (OnError != null)
                {
                    OnError(this, new CommandEventArgs(ex.Message));
                }
            }
        }