public void Handle(AppSocketSession session, EInstruction instruction)
 {
     byte[] content = null;
     switch (instruction.InstructionType)
     {
         case EnumInstructionType.BreakOilOrPower:
             content = Encoding.ASCII.GetBytes("DYD,000000#");
             break;
         case EnumInstructionType.RecoveryBreakOilOrPower:
             content = Encoding.ASCII.GetBytes("HFYD,000000#");
             break;
     }
     if (content != null && content.Length > 0)
     {
         var cmd = KksCommon.CreateBytesPackage("80", session.GetSerialNumber(), (bw) =>
         {
             //指令长度
             bw.WriteInt(content.Length);
             //服务器标志位
             bw.WriteInt32(GetSerialNumber());
             //指令内容
             bw.Write(content);
             //语言
             bw.Write(new byte[] {0x00, 0x01});
         });
         session.SendAsync(cmd);
         _logger.WarnFormat("开始执行指令{0}-{1}-{2}", instruction.DeviceId, instruction.InstructionType.GetDisplayName(), ByteHelper.ConvertBytesToStringByHex(cmd));
     }
     else
     {
         _logger.WarnFormat("发送指令失败,无效指令!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
     }
 }
        /// <summary>
        /// 沃达孚断油断电指令 H1
        /// </summary>
        /// <param name="session"></param>
        /// <param name="instruction"></param>
        public void HandleH1(AppSocketSession session, EInstruction instruction)
        {
            var deviceGpsCodeNoPrefix = session["DeviceGpsCodeNoPrefix"] as string;
            if (deviceGpsCodeNoPrefix == null)
            {
                _logger.WarnFormat("发送指令失败!车辆不在线!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }

            List<byte> content = new List<byte>();
            switch (instruction.InstructionType)
            {
                case EnumInstructionType.BreakOilOrPower:
                    content.Add(0xf0);
                    break;
                case EnumInstructionType.RecoveryBreakOilOrPower:
                    content.Add(0xf1);
                    break;
            }
            if (content.Count > 0)
            {
                var cmd = T808Common.CreateBytesPackage("8105", deviceGpsCodeNoPrefix, GetSerialNumber(), (bw) =>
                {
                    bw.Write(content.ToArray());
                });
                session.SendAsync(cmd);
                _logger.WarnFormat("开始执行指令{0}-{1}-{2}", instruction.DeviceId, instruction.InstructionType.GetDisplayName(), ByteHelper.ConvertBytesToStringByHex(cmd));
            }
            else
            {
                _logger.WarnFormat("发送指令失败,无效指令!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }
        }
        public void Handle(AppSocketSession session, EInstruction instruction)
        {
            var deviceGpsCodeNoPrefix = session["DeviceGpsCodeNoPrefix"] as string;
            if (deviceGpsCodeNoPrefix == null)
            {
                _logger.WarnFormat("发送指令失败!车辆不在线!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }
            
            var cmd = new List<string>();
            switch (instruction.InstructionType)
            {
                case EnumInstructionType.BreakOilOrPower:
                    cmd.Add("#1:{0}:1:*".GetFormat(deviceGpsCodeNoPrefix));
                    cmd.Add(ByteHelper.ConvertUInt32ToHexString(GetSerialNumber()));
                    cmd.Add("CC");
                    cmd.Add(ByteHelper.ConvertDateToHexString(DateTime.Now));
                    cmd.Add(ByteHelper.ConvertTimeToHexString(DateTime.Now));
                    cmd.Add("Y1L1#");
                    session.SendAsync(Encoding.UTF8.GetBytes(string.Join(",", cmd)));
                    break;
                case EnumInstructionType.RecoveryBreakOilOrPower:
                    cmd.Add("#1:{0}:1:*".GetFormat(deviceGpsCodeNoPrefix));
                    cmd.Add(ByteHelper.ConvertUInt32ToHexString(GetSerialNumber()));
                    cmd.Add("CC");
                    cmd.Add(ByteHelper.ConvertDateToHexString(DateTime.Now));
                    cmd.Add(ByteHelper.ConvertTimeToHexString(DateTime.Now));
                    cmd.Add("Y2L2#");
                    
                    break;
            }

            if (cmd.Count > 0)
            {
                session.SendAsync(Encoding.UTF8.GetBytes(string.Join(",", cmd)));
                _logger.WarnFormat("开始执行指令{0}-{1}-{2}", instruction.DeviceId,instruction.InstructionType.GetDisplayName(), string.Join(",", cmd));
            }
            else
            {
                _logger.WarnFormat("发送指令失败,无效指令!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }

        }
        public void Handle(AppSocketSession session, EInstruction instruction)
        {
            //开油:*HQ,0000,S20,095517,1,0#
            //断油:*HQ,0000,S20,095517,1,1#"

            var deviceGpsCodeNoPrefix = session["DeviceGpsCodeNoPrefix"] as string;
            if (deviceGpsCodeNoPrefix == null)
            {
                _logger.WarnFormat("发送指令失败!车辆不在线!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }

            var cmd = $"*HQ,0000,S20,{DateTime.Now.ToString("HHmmss")},1,{(instruction.InstructionType==EnumInstructionType.BreakOilOrPower ? "1" : "0")}#";
            if (cmd.Length > 0)
            {
                session.SendAsync(Encoding.ASCII.GetBytes(string.Join(",", cmd)));
                _logger.WarnFormat("开始执行指令{0}-{1}-{2}", instruction.DeviceId, instruction.InstructionType.GetDisplayName(), string.Join(",", cmd));
            }
            else
            {
                _logger.WarnFormat("发送指令失败,无效指令!{0}-{1}", instruction.DeviceId, instruction.InstructionType.GetDisplayName());
            }

        }