Пример #1
0
        void ProcessData()
        {
            try
            {
                ILiveDebug.Instance.WriteLine(ILiveUtil.ToHexString(rdata.ToArray()));
                //55 屏幕ID 高位 低位 校验位 0D

                if (rdata.Count == 6 && rdata[0] == 0x55 && rdata[5] == 0x0D)
                {
                    byte iChanIdx = rdata[1];

                    int h = rdata[2];

                    int l = rdata[3];

                    // if (rdata[4] == 0x0D)//校验
                    {
                        if (this.PushTPCIEvent != null)
                        {
                            this.PushTPCIEvent(iChanIdx, (h * 256) + l);
                        }
                    }
                }

                rdata.Clear();
            }
            catch (Exception ex)
            {
                ILiveDebug.Instance.WriteLine(ex.Message);
            }
        }
Пример #2
0
 public void YelaProcess(byte[] yeladata)
 {
     ILiveDebug.Instance.WriteLine(ILiveUtil.ToHexString(yeladata));
     if (yeladata != null && yeladata.Length > 4)
     {
         if (yeladata[1] == 0x19)
         {
             if (yeladata[3] == 0x23 || yeladata[2] == 0x81)
             {
                 //门已经打开
             }
             else
             {
                 //门已经关闭
             }
             if (yeladata[2] == 0x81)
             {
                 this.YelaButtonPress(yeladata[4]);
                 //            honur=receivedBytes[4];
                 //            Admin[honur]=1;
                 //            delay(100);
                 //            Admin[honur]=0;
             }
         }
     }
     // yelaLock = null;
 }
Пример #3
0
        private void SendData(byte[] sendbytes)
        {
            ILiveDebug.Instance.WriteLine("I3ComSendData" + ILiveUtil.ToHexString(sendbytes));
            //  string cmd = Encoding.GetEncoding(28591).GetString(sendbytes, 0, sendbytes.Length);

            this.port.Send(sendbytes);
            Thread.Sleep(300);
        }
Пример #4
0
        private void SendCMD(int addr, int fun, int pa)
        {
            // ILiveDebug.Instance.WriteLine("Curtains:" + pa + ":" + addr);
            byte check = (byte)(pa + addr);

            byte[] data = { 0x55, 0xAA, (byte)fun, (byte)pa, 0x00, (byte)addr, check };
            this.port.Send(data);
            ILiveDebug.Instance.WriteLine("Curtains:" + ILiveUtil.ToHexString(data));
        }
Пример #5
0
        /// <summary>
        /// 设置第二路调光亮度
        /// </summary>
        /// <param name="p">亮度 0-255</param>
        public void SetDim2(int p)
        {
            byte[] sendBytes = this.BuildCMD((byte)addr, 0xA2, 0x02, 0x00, (byte)p);
            ILiveDebug.Instance.WriteLine("DIM2" + ILiveUtil.ToHexString(sendBytes));
            string cmd = Encoding.GetEncoding(28591).GetString(sendBytes, 0, sendBytes.Length);

            this.port.Send(cmd);
            this.Status.Dim2 = p;
            Thread.Sleep(500);
        }
Пример #6
0
        private void Send(params byte[] data)
        {
            byte[] sendBytes = this.GetCMDString(data);


            // byte[] sendBytes = Encoding.GetEncoding(28591).GetBytes(senddata);
            ILiveDebug.Instance.WriteLine("MusicData:" + ILiveUtil.ToHexString(sendBytes));

            this.port.Send(sendBytes);
        }
Пример #7
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="address"></param>
        /// <param name="data">每字节代表2路 如0x10 第一路断开 第二路闭合。继电器只识别0和1,其他数据不做任何动作,可以将该路赋值微其它值</param>
        private void SendData(int address, byte[] data)
        {
            if (data.Length != 8)
            {
                return;
            }
            byte[] checkarr1 = BitConverter.GetBytes(0x48 + 0x3a + address + 0x57 + data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7]);

            byte[] sendBytes = new byte[] { 0x48, 0x3a, (byte)address, 0x57, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], checkarr1[0], 0x45, 0x44 };

            ILiveDebug.Instance.WriteLine("Relay:" + ILiveUtil.ToHexString(sendBytes));
            string cmd = Encoding.GetEncoding(28591).GetString(sendBytes, 0, sendBytes.Length);

            this.port.Send(cmd);
            Thread.Sleep(500);
        }
Пример #8
0
 private void SendCMD(byte[] cmd)
 {
     ILiveDebug.Instance.WriteLine("Relay:" + ILiveUtil.ToHexString(cmd));
     this.port.Send(cmd);
     Thread.Sleep(500);
 }
Пример #9
0
 private void SendYork(params byte[] data)
 {
     byte[] senddata = this.GetCMDString(data);
     ILiveDebug.Instance.WriteLine("YORK:" + ILiveUtil.ToHexString(senddata));
     this.port.Send(senddata);
 }