Ejemplo n.º 1
0
        public void Close()
        {
            byte[] sendBytes = null;
            byte[] receiveBytes = null;
            LEDReceivePackage rPck = null;
            //开屏
            LEDSendPackage spTemp = new LEDSendPackage(LEDCommandType.TempSetDisplayStatus);
            spTemp.TempSetDisplayStatusType = TempSetDisplayStatusType.Start;
            sendBytes = spTemp.GetPackage();
            writer.Write(sendBytes);
            writer.Flush();

            receiveBytes = reader.ReadBytes(52);
            rPck = new LEDReceivePackage(receiveBytes);
            if (rPck.Result != LEDReceiveResult.Sucess)
            {
                throw new Exception("发送失败");
            }
            if (reader != null)
            {
                reader.Close();
            }
            if (writer != null)
            {
                writer.Close();
            }
            if (tcpClient != null)
            {
                tcpClient.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 10ms延迟,GPRS 1分钟;串口 200ms
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="package"></param>
        public void SendMessage(LEDSendPackage package)
        {
            if (tcpClient.Connected)
            {
                byte[] sendBytes = null;
                byte[] receiveBytes = null;
                LEDReceivePackage rPck = null;
                //发送信息
                sendBytes = package.GetPackage();
                writer.Write(sendBytes);
                writer.Flush();

                receiveBytes = reader.ReadBytes(52);
                rPck = new LEDReceivePackage(receiveBytes);
                if (rPck.Result != LEDReceiveResult.Sucess)
                {
                    throw new Exception("发送失败");
                }

            }
        }
Ejemplo n.º 3
0
        public void Open(string ip)
        {
            ipAddr = IPAddress.Parse(ip);
            tcpClient = new TcpClient();
            if (!tcpClient.Connected)
                tcpClient.Connect(ipAddr, TCPPort);
            //if (tcpClient.Connected)

            netStream = tcpClient.GetStream();
            writer = new BinaryWriter(netStream);
            reader = new BinaryReader(netStream);
            byte[] sendBytes = null;
            byte[] receiveBytes = null;
            LEDReceivePackage rPck = null;
            //关屏
            LEDSendPackage spTemp = new LEDSendPackage(LEDCommandType.TempSetDisplayStatus);
            spTemp.TempSetDisplayStatusType = TempSetDisplayStatusType.Shutdown;
            sendBytes = spTemp.GetPackage();
            writer.Write(sendBytes);
            writer.Flush();

            receiveBytes = reader.ReadBytes(52);
            rPck = new LEDReceivePackage(receiveBytes);
            if (rPck.Result != LEDReceiveResult.Sucess)
            {
                throw new Exception("发送失败");
            }
        }