Example #1
0
        public AnvizDevice(TcpClient socket)
        {
            DeviceStream = new AnvizStream(socket);
            DeviceStream.ReceivedPacket += (s, e) =>
            {
                switch (e.ResponseCode)
                {
                case 0x7F:
                    DevicePing?.Invoke(this, null);
                    break;

                case 0xDF:
                    ReceivedRecord?.Invoke(this, new Record(e.DATA, 0));
                    break;

                default:
                    ReceivedPacket?.Invoke(this, e);
                    break;
                }
            };
            DeviceStream.DeviceError += (s, e) =>
            {
                DeviceError?.Invoke(this, e);
            };
        }
Example #2
0
 public AnvizDevice(TcpClient socket)
 {
     DeviceStream = new AnvizStream(socket);
     DeviceStream.ReceivedPacket += (s, e) =>
     {
         if (e.ResponseCode == 0x7F)
         {
             DevicePing?.Invoke(this, null);
         }
         else
         {
             ReceivedPacket?.Invoke(this, e);
         }
     };
 }