Esempio n. 1
0
        public void ControlOil(string gpsCode, EnumOilCommandType commandType, GPSType type, Guid sequnceNo)
        {
            ControlOilCircuit control = new ControlOilCircuit();
            control.Data.GpsType = GPSType.YouWei;
            control.BreakOilCircuitTime = DateTime.Now;
            control.GPSCode = gpsCode;
            control.SerialNumber = sequnceNo.ToString();
            control.Data.GpsType = type;
            control.Data.IsGpsAckMsg = true;
            bool flag = false;

            if (commandType == EnumOilCommandType.BreakOil)
            {
                flag = CommandService.GetInstance().BreakOilCircuitBySmart(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "智能断电.");
            }
            if (commandType == EnumOilCommandType.Support)
            {
                flag = CommandService.GetInstance().SupplyOilCircuit(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "供电供油.");
            }
        }
Esempio n. 2
0
        private byte[] ControlOilBreak(int index)
        {

            CmdData cmdData = new CmdData();
            ControlOilCircuit data = new ControlOilCircuit();
            data.BreakOilCircuitTime = DateTime.Now;

            if (index == 1)
            {
                cmdData.Data.Cmd = ControlCmdType.BreakOilCircuitByForce;
                data.Data.operateMode = ControlOilMode.Force;
                data.Data.operateType = ContorlOilType.CutOil;
            }
            else if (index == 2)
            {
                cmdData.Data.Cmd = ControlCmdType.SupplyOilCircuit;
                data.Data.operateMode = ControlOilMode.Smart;
                data.Data.operateType = ContorlOilType.RestoreOil;
            }
            data.GPSCode = txtGpsCode.Text.Trim();
            if (data.GPSCode.StartsWith("0019"))
                data.Data.GpsType = GPSType.YaXun;
            else if (data.GPSCode.StartsWith("0013"))
                data.Data.GpsType = GPSType.BoShiJie;
            else if (data.GPSCode.StartsWith("0023"))
                data.Data.GpsType = GPSType.KangKaiSi;
            else if (data.GPSCode.StartsWith("0033"))
                data.Data.GpsType = GPSType.LianHuaYingKe;
            data.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(data.GPSCode).Length;
            data.SerialNumber = Guid.NewGuid().ToString();
            data.Data.SerialNumberLen = (byte)Encoding.Default.GetBytes(data.SerialNumber).Length;

            byte[] buffer = new byte[data.GetLength()];
            data.WriteBuffer(0, buffer);

            ControlOilCircuit dest = new ControlOilCircuit();
            dest.ReadBuffer(0, buffer);

            cmdData.DataBuffer = buffer;
            cmdData.Data.DataLen = (ushort)data.GetLength();

            byte[] sendBuffer = new byte[cmdData.GetLenth()];
            cmdData.WriteBuffer(0, sendBuffer);

            return sendBuffer;

        }
Esempio n. 3
0
        private void ReceiveDataEvent(EndPoint remotePoint, byte[] receivedBuffer)
        {
            //读取命令
            CmdData cmdData = new CmdData();

            //读入数据
            cmdData.ReadBuffer(0, receivedBuffer);

            ReceiveCount++;
            Logger.Info("收到指令反馈次数:" + ReceiveCount);
            switch (cmdData.Data.Cmd)
            {
                ////调度命令
                //case ControlCmdType.DispatchControl:

                //    DispatchControl dispatchControl = new DispatchControl();
                //    //读入数据
                //    dispatchControl.ReadBuffer(0, cmdData.DataBuffer);
                //    Log.Info(string.Format("收到调度指令回复。次数:{0},结果:{1},硬件反馈:{2}", ReceiveCount, dispatchControl.Data.Result, dispatchControl.Data.IsGpsAckMsg));

                //    IDispatchManager dispatchManager = new DispatchManager();
                //    PES.GPS.Entity.Dispatch.EnumSendState dispatchState = dispatchControl.Data.Result ? PES.GPS.Entity.Dispatch.EnumSendState.SendSuccess : PES.GPS.Entity.Dispatch.EnumSendState.SendFailed;
                //    if (!dispatchControl.Data.IsGpsAckMsg)
                //        dispatchManager.UpdateState(new Guid(dispatchControl.SerialNumber), dispatchState);
                //    break;

                ////监听喊话
                //case ControlCmdType.ListenCall:
                //    ListenCallControl CallControl = new ListenCallControl();

                //    //读入数据
                //    CallControl.ReadBuffer(0, cmdData.DataBuffer);
                //    Log.Info(string.Format("收到监听指令回复。次数:{0}", ReceiveCount));
                //    break;

                ////下发广告或LED其它命令
                //case ControlCmdType.SendAdvertisement:
                //    LEDControl advertiseControl = new LEDControl();
                //    //读入数据
                //    advertiseControl.ReadBuffer(0, cmdData.DataBuffer);

                //    IHistoryAdvertInfoManager db = new HistoryAdvertInfoManager();
                //    if (!advertiseControl.Data.IsGpsAckMsg)//网关反馈
                //    {
                //        if (advertiseControl.Data.Result)
                //        {
                //            db.Update<EAdvertSendHistory>(advertiseControl.GPSCode, EnumSendState.Sended);
                //            Log.Info(string.Format("收到[{1}]发送广告指令回复。结果:{0}", advertiseControl.Data.Result, advertiseControl.GPSCode));
                //        }
                //        else
                //        {
                //            db.Update<EAdvertSendHistory>(advertiseControl.GPSCode, EnumSendState.SendFailed);
                //            Log.Info(string.Format("收到[{1}]发送广告指令回复。结果:{0}", advertiseControl.Data.Result, advertiseControl.GPSCode));
                //        }
                //    }
                //    Log.Info(string.Format("收到发送广告指令回复。次数:{0}", ReceiveCount));
                //    break;

                ////简单控制命令
                //case ControlCmdType.SimpleInstruction:
                //    SimpleInstructionControl simpleControl = new SimpleInstructionControl();
                //    simpleControl.ReadBuffer(0, cmdData.DataBuffer);

                //    Log.Info(string.Format("收到简单控制指令回复。次数:{0},结果:{1},硬件反馈:{2}", ReceiveCount, simpleControl.Data.Result, simpleControl.Data.IsGpsAckMsg));
                //    break;
                ////下发拍照动作
                //case ControlCmdType.SendTakePicture:
                //    SimpleInstructionControl takePicture = new SimpleInstructionControl();
                //    takePicture.ReadBuffer(0, cmdData.DataBuffer);

                //    Log.Info(string.Format("收到拍照指令回复。次数:{0},结果:{1},硬件反馈:{2}", ReceiveCount, takePicture.Data.Result, takePicture.Data.IsGpsAckMsg));
                //    break;

                //控制油路通断
                case ControlCmdType.BreakOilCircuitByForce:
                case ControlCmdType.BreakOilCircuitBySmart:
                case ControlCmdType.SupplyOilCircuit:
                    ControlOilCircuit ControlOil = new ControlOilCircuit();
                    ControlOil.ReadBuffer(0, cmdData.DataBuffer);
                    Logger.Info(string.Format("收到油路指令回复。次数:{0},结果:{1},硬件反馈:{2}", ReceiveCount, ControlOil.Data.Result, ControlOil.Data.IsGpsAckMsg));
                    EnumOilCommandState breakOilState = EnumOilCommandState.All;
                    //有为油路通断控制
                    if (!ControlOil.Data.IsGpsAckMsg)
                    {
                        breakOilState = ControlOil.Data.Result ? EnumOilCommandState.SendSuccess : EnumOilCommandState.SendFail;
                        //IBreakOilHistoryManager breakOil = new BreakOilHistoryManager();
                        DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(new Guid(ControlOil.SerialNumber), breakOilState);
                    }
                    break;
                case ControlCmdType.DeviceCircuitresAndOil:
                    ControlOilCircuit ControlOil2 = new ControlOilCircuit();
                    ControlOil2.ReadBuffer(0, cmdData.DataBuffer);
                    EnumOilCommandState breakOilState2 = ControlOil2.Data.Result ? EnumOilCommandState.RunSuccess : EnumOilCommandState.RunFail;
                    //IBreakOilHistoryManager breakOil2 = new BreakOilHistoryManager();
                    DACFacade.Gps.BreakOilHistoryRecordDAC.UpdateState(ControlOil2.GPSCode, breakOilState2);
                    break;
                case ControlCmdType.OpenGPS:
                    KKSSimpleControl openGPSControl = new KKSSimpleControl();
                    openGPSControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(openGPSControl.GPSCode,1,openGPSControl.SendContent);
                    break;
                case ControlCmdType.SetFriendNumber:
                    KKSSimpleControl setfriendnumberControl = new KKSSimpleControl();
                    setfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(setfriendnumberControl.GPSCode, 2, setfriendnumberControl.SendContent);
                    break;
                case ControlCmdType.GetFriendNumber:
                    KKSSimpleControl getfriendnumberControl = new KKSSimpleControl();
                    getfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(getfriendnumberControl.GPSCode, 3, getfriendnumberControl.SendContent);
                    break;
                default:
                    break;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 选择应用层下发的任务
        /// </summary>
        /// <param name="receivedBuffer">接收缓冲区数据</param>
        /// <param name="remotePoint">客户端端点</param>
        public void SwitchEvent(EndPoint remotePoint, byte[] receivedBuffer)
        {
            try
            {
                //GPSCode
                string gpsCode = string.Empty;

                //读取命令
                CmdData cmdData = new CmdData();

                //读入数据
                cmdData.ReadBuffer(0, receivedBuffer);
                Logger.Trace("收到应用层下发指令,指令类型:" + cmdData.Data.Cmd.ToString());

                byte[] sendBuffer = null;

                switch (cmdData.Data.Cmd)
                {
                    //调度命令
                    case ControlCmdType.DispatchControl:

                        DispatchControl DispatchControl = new DispatchControl();

                        //读入数据
                        DispatchControl.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + DispatchControl.GPSCode);

                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(DispatchControl.GPSCode, remotePoint);

                        //下发调度命令
                        HandleDispatchControlInfo(DispatchControl);

                        break;

                    //监听喊话
                    case ControlCmdType.ListenCall:

                        ListenCallControl CallControl = new ListenCallControl();

                        //读入数据
                        CallControl.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + CallControl.GPSCode);

                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(CallControl.GPSCode, remotePoint);

                        //下发调度命令
                        HandleListenCallInfo(CallControl);

                        break;

                    //简单控制命令
                    //case ControlCmdType.SimpleInstruction:
                    //下发广告或LED其它命令
                    case ControlCmdType.LEDControl:

                        SimpleInstructionControl SimpleControl = new SimpleInstructionControl();
                        SimpleControl.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + SimpleControl.GPSCode);

                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(SimpleControl.GPSCode, remotePoint);

                        HandleSimpleInstructionControl(SimpleControl);

                        break;

                    //下发拍照的动作
                    case ControlCmdType.SendTakePicture:

                        TakePictureControl takePicture = new TakePictureControl();
                        takePicture.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + takePicture.GPSCode);

                        //将连接加入哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(takePicture.GPSCode, remotePoint);

                        HandleShootInstructionControl(takePicture);

                        break;

                    //下发拍照的动作(多摄像头)
                    case ControlCmdType.SendTakePictureMultiCamera:

                        TakePictureControlMultiCamera takePictureMultiCamera = new TakePictureControlMultiCamera();
                        takePictureMultiCamera.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + takePictureMultiCamera.GPSCode);

                        //将连接加入哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(takePictureMultiCamera.GPSCode, remotePoint);

                        HandleShootInstructionControl(takePictureMultiCamera);

                        break;

                    case ControlCmdType.SupplyOilCircuit:
                    //强制断油断电
                    case ControlCmdType.BreakOilCircuitByForce:
                    //智能断油断电
                    case ControlCmdType.BreakOilCircuitBySmart:

                        ControlOilCircuit ControlOil = new ControlOilCircuit();

                        ControlOil.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + ControlOil.GPSCode);

                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(ControlOil.GPSCode, remotePoint);

                        //油路通断控制
                        HandleBreakOilCircuit(ControlOil);

                        break;

                    //北京视展LED控制
                    case ControlCmdType.BJSZLedControl:
                    case ControlCmdType.SendAdvertisement:

                        LEDControl ledControl = new LEDControl();
                        ledControl.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + ledControl.GPSCode);
                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(ledControl.GPSCode, remotePoint);
                        HandleBJSZLEDContentInfo(ledControl);
                        break;

                    //解除报警
                    case ControlCmdType.DischargeAlarm:

                        DischangeAlarmControl dischangeAlarm = new DischangeAlarmControl();
                        dischangeAlarm.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + dischangeAlarm.GPSCode);
                        //将连接加入连接哈希表
                        GpsDataParser.OnPostAppLayerAddressEvent(dischangeAlarm.GPSCode, remotePoint);
                        DischargeAlarm(dischangeAlarm);

                        break;

                    //超速报警
                    case ControlCmdType.OverSpeedAlarm:

                        OverSpeedAlarmControl overSpeedAlarm = new OverSpeedAlarmControl();
                        overSpeedAlarm.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + overSpeedAlarm.GPSCode);
                        GpsDataParser.OnPostAppLayerAddressEvent(overSpeedAlarm.GPSCode, remotePoint);
                        HandleOverSpeed(overSpeedAlarm);

                        break;

                    //获取网关活动信息
                    case ControlCmdType.GetGatewayActiveInfo:

                        GatewayActiveInfo activeInfo = new GatewayActiveInfo();
                        activeInfo.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + activeInfo.GPSCode);
                        GpsDataParser.OnPostAppLayerAddressEvent(activeInfo.GPSCode, remotePoint);
                        SendGatewayActiveInfo(activeInfo, remotePoint);
                        break;
                    //更新GPS总里程值
                    case ControlCmdType.updatemileage:

                        UpdateMileage UpMileage = new UpdateMileage();
                        UpMileage.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + UpMileage.GPSCode);
                        GpsDataParser.OnPostAppLayerAddressEvent(UpMileage.GPSCode, remotePoint);
                        SendUpdateMileage(UpMileage);
                        break;
                    //设置GPS上传周期
                    case ControlCmdType.SendGPSPosUploadInterval:

                        GPSPosUploadInterval posUploadInterval = new GPSPosUploadInterval();
                        posUploadInterval.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + posUploadInterval.GPSCode);
                        GpsDataParser.OnPostAppLayerAddressEvent(posUploadInterval.GPSCode, remotePoint);
                        HandleGPSPosUploadInterval(posUploadInterval);
                        break;

                    //设置移动台初始经参数
                    case ControlCmdType.SetMobileInitPara:

                        SetMobileInitPara setMobileInitPara = new SetMobileInitPara();
                        setMobileInitPara.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + setMobileInitPara.GPSCode);
                        SetMobileInitPara(setMobileInitPara);

                        break;

                    //雅迅设备,配置报警器
                    case ControlCmdType.AllocateAnnounciator:

                        SetAnnounciator setAnnounciator = new SetAnnounciator();
                        setAnnounciator.ReadBuffer(0, cmdData.DataBuffer);

                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + setAnnounciator.GPSCode);

                        gpsCode = setAnnounciator.GPSCode;

                        sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.AllocateAnnounciator, setAnnounciator);

                        break;
                    case ControlCmdType.SetCircleRegion:
                    case ControlCmdType.SetRectangleRegion:
                    case ControlCmdType.SetPloygon:
                    case ControlCmdType.SetFixedLine:
                    case ControlCmdType.RemoveCircleRegion:
                    case ControlCmdType.RemoveRectangleRegion:
                    case ControlCmdType.RemovePloygon:
                    case ControlCmdType.RemoveFixedLine:
                    case ControlCmdType.TMLControl:
                    case ControlCmdType.SendTxtToTML:
                    case ControlCmdType.PhoneCallback:
                    case ControlCmdType.CameraShootImmediately:
                    case ControlCmdType.PositionQueryReq:
                    case ControlCmdType.SetStopCarAlarm:
                    case ControlCmdType.SetOverFatigueAlarm:
                    case ControlCmdType.SetOverSpeedAlarm:
                    case ControlCmdType.GetRravelRecord:

                        BuBiaoCommonControl BBControl = new BuBiaoCommonControl();
                        BBControl.ReadBuffer(0, cmdData.DataBuffer);

                        GpsDataParser.OnPostAppLayerAddressEvent(BBControl.GPSCode, remotePoint);
                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + BBControl.GPSCode);

                        HandleBuBiaoMessage(BBControl, cmdData.Data.Cmd);
                        break;
                    //部标解除报警
                    case ControlCmdType.ReleaseAlarm:
                        BuBiaoCommonControl ReleaseControl = new BuBiaoCommonControl();
                        ReleaseControl.ReadBuffer(0, cmdData.DataBuffer);

                        GpsDataParser.ReleaseAlarm(ReleaseControl);
                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + ReleaseControl.GPSCode);
                        break;
                    case ControlCmdType.OpenGPS:
                        KKSSimpleControl openGPSControl = new KKSSimpleControl();
                        openGPSControl.ReadBuffer(0, cmdData.DataBuffer);
                        GpsDataParser.OnPostAppLayerAddressEvent(openGPSControl.GPSCode, remotePoint);
                        HandleKKSSimpleControlInfo(ControlCmdType.OpenGPS, openGPSControl);
                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + openGPSControl.GPSCode);
                        break;
                    case ControlCmdType.SetFriendNumber:
                        KKSSimpleControl setfriendnumberControl = new KKSSimpleControl();
                        setfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                        GpsDataParser.OnPostAppLayerAddressEvent(setfriendnumberControl.GPSCode, remotePoint);
                        HandleKKSSimpleControlInfo(ControlCmdType.SetFriendNumber,setfriendnumberControl);
                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + setfriendnumberControl.GPSCode);
                        break;
                    case ControlCmdType.GetFriendNumber:
                        KKSSimpleControl getfriendnumberControl = new KKSSimpleControl();
                        getfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                        GpsDataParser.OnPostAppLayerAddressEvent(getfriendnumberControl.GPSCode, remotePoint);
                        HandleKKSSimpleControlInfo(ControlCmdType.GetFriendNumber,getfriendnumberControl);
                        Logger.Trace("应用层下发指令类型:" + cmdData.Data.Cmd.ToString() + ";GPSCode:" + getfriendnumberControl.GPSCode);
                        break;

                    default:


                        break;
                }
                //GpsDataParser.OnPostSendHandlerEvent(gpsCode, string.Empty, sendBuffer);
            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
            }
        }
Esempio n. 5
0
        /// <summary> 发送应答信息给应用
        /// 发送应答信息给应用
        /// </summary>
        /// <param name="serialNumber">流水号</param>
        /// <param name="isGpsAckMsg">是否是GPS应答消息</param>
        /// <param name="gpscode"></param>
        /// <param name="cmdType">下发的命令类型</param>
        /// <param name="result">GPS终端对命令的执行结果:成功或失败</param>
        //private void SendAnswerToWeb(string serialNumber, bool isGpsAckMsg, string gpscode, ControlCmdType cmdType, bool result, params SimpleCmdType[] simplecmd)
        //{
        //    //获取WEB列表
        //    EndPoint adress = (EndPoint)WebTable[gpscode];

        //    if (adress != null)
        //    {
        //        byte[] answerBytes = SetAnswerByte(serialNumber, isGpsAckMsg, gpscode, cmdType, result, simplecmd);

        //        CmdServer.SendTo((IPEndPoint)adress, answerBytes);
        //    }
        //}

        /// <summary> 构造应答数据
        /// 构造应答数据
        /// </summary>
        /// <param name="serialNumber">流水号</param>
        /// <param name="isGpsAckMsg">是否是GPS应答信息</param>
        /// <param name="gpsCode">GPSG带前缀编码</param>
        /// <param name="cmd">下发的命令类型</param>
        /// <param name="result">GPS终端对命令的执行结果:成功或失败</param>
        /// <param name="simpleCmd">简单控制命令类型</param>
        /// <returns></returns>
        private byte[] SetAnswerByte(string serialNumber,bool isGpsAckMsg, string gpsCode, ControlCmdType cmd, bool result, params SimpleCmdType[] simpleCmd)
        {
            try
            {
                byte[] sendBuffer = null;

                byte[] dataBuffer = null;

                CmdData cmddata = new CmdData();
                cmddata.Data.Cmd = cmd;

                byte gpsCodeLen = (byte)Encoding.Default.GetBytes(gpsCode).Length;

                byte serialLen = (byte)Encoding.Default.GetBytes(serialNumber).Length;

                switch (cmd)
                {
                    case ControlCmdType.DeviceCircuitresAndOil://控制油路应答

                        ControlOilCircuit structOil = new ControlOilCircuit();

                        structOil.Data.IsGpsAckMsg = isGpsAckMsg;
                        structOil.GPSCode = gpsCode;
                        structOil.Data.Result = result;
                        structOil.Data.GPSCodeLen = gpsCodeLen;
                        structOil.SerialNumber = serialNumber;
                        structOil.Data.SerialNumberLen = serialLen;
                        byte[] bytsOil = new byte[structOil.GetLength()];
                        structOil.WriteBuffer(0, bytsOil);
                        cmddata.DataBuffer = bytsOil;
                        cmddata.Data.DataLen = (ushort)bytsOil.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;

                    //解除报警应答
                    case ControlCmdType.DischargeAlarm:

                        DischangeAlarmControl structAlarm = new DischangeAlarmControl();

                        structAlarm.GPSCode = gpsCode;
                        structAlarm.Data.Result = result;
                        structAlarm.Data.GPSCodeLen = gpsCodeLen;
                        structAlarm.SerialNumber = serialNumber;
                        structAlarm.Data.SerialNumberLen = serialLen;

                        byte[] bytsAlarm = new byte[structAlarm.GetLength()];
                        structAlarm.WriteBuffer(0, bytsAlarm);
                        cmddata.DataBuffer = bytsAlarm;
                        cmddata.Data.DataLen = (ushort)bytsAlarm.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;

                    //调度控制(下发文本)
                    case ControlCmdType.DispatchControl:

                        DispatchControl structDispatch = new DispatchControl();
                        structDispatch.Data.IsGpsAckMsg = isGpsAckMsg;
                        structDispatch.GPSCode = gpsCode;
                        structDispatch.Data.Result = result;
                        structDispatch.Data.GPSCodeLen = gpsCodeLen;
                        structDispatch.SerialNumber = serialNumber;
                        byte[] bytsDispatch = new byte[structDispatch.GetLength()];
                        structDispatch.WriteBuffer(0, bytsDispatch);
                        cmddata.DataBuffer = bytsDispatch;
                        cmddata.Data.DataLen = (ushort)bytsDispatch.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;

                    //监听喊话
                    case ControlCmdType.ListenCall:

                        ListenCallControl structListenCall = new ListenCallControl();
                        structListenCall.Data.IsGpsAckMsg = isGpsAckMsg;
                        structListenCall.GPSCode = gpsCode;
                        structListenCall.Data.GPSCodeLen = gpsCodeLen;
                        structListenCall.Data.Result = result;
                        structListenCall.Data.SerialNumberLen = serialLen;
                        structListenCall.SerialNumber = serialNumber;
                        byte[] bytsListenCall = new byte[structListenCall.GetLength()];
                        structListenCall.WriteBuffer(0, bytsListenCall);
                        cmddata.DataBuffer = bytsListenCall;
                        cmddata.Data.DataLen = (ushort)bytsListenCall.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;

                    case ControlCmdType.BJSZLedControl://透传数据应答(BJSZ  LED)

                        BJSZLEDContentControl structBJSZLED = new BJSZLEDContentControl();
                        structBJSZLED.Data.IsGpsAckMsg = isGpsAckMsg;
                        structBJSZLED.GPSCode = gpsCode;
                        structBJSZLED.Data.Result = result;
                        structBJSZLED.Data.SerialNumberLen = serialLen;
                        structBJSZLED.SerialNumber = serialNumber;
                        structBJSZLED.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(gpsCode).Length;
                        byte[] bytsBJSZLED = new byte[structBJSZLED.GetLength()];
                        structBJSZLED.WriteBuffer(0, bytsBJSZLED);
                        cmddata.DataBuffer = bytsBJSZLED;
                        cmddata.Data.DataLen = (ushort)bytsBJSZLED.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);
                        break;

                    case ControlCmdType.LongHanAnswered://龙汗数据应答                    
                        break;

                    case ControlCmdType.SimpleInstruction://简单控制命令

                        SimpleInstructionControl structSimple = new SimpleInstructionControl();
                        structSimple.Data.InstructionType = simpleCmd[0];
                        structSimple.Data.IsGpsAckMsg = isGpsAckMsg;
                        structSimple.GPSCode = gpsCode;
                        structSimple.Data.Result = result;
                        structSimple.Data.SerialNumberLen = serialLen;
                        structSimple.SerialNumber = serialNumber;
                        structSimple.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(gpsCode).Length;
                        byte[] bytsSimple = new byte[structSimple.GetLength()];
                        structSimple.WriteBuffer(0, bytsSimple);
                        cmddata.DataBuffer = bytsSimple;
                        cmddata.Data.DataLen = (ushort)bytsSimple.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);
                        break;

                    case ControlCmdType.SendTakePicture://拍照应答

                        TakePictureControl structPicture = new TakePictureControl();
                        structPicture.Data.IsGpsAckMsg = isGpsAckMsg;
                        structPicture.GPSCode = gpsCode;
                        structPicture.Data.Result = result;
                        structPicture.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(gpsCode).Length;
                        structPicture.SerialNumber = serialNumber;
                        structPicture.Data.SerialNumberLen = (byte)Encoding.Default.GetBytes(serialNumber).Length;
                        byte[] bytsPicture = new byte[structPicture.GetLength()];
                        structPicture.WriteBuffer(0, bytsPicture);
                        cmddata.DataBuffer = bytsPicture;
                        cmddata.Data.DataLen = (ushort)bytsPicture.Length;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);
                        break;

                    //对下发广告的回复
                    case ControlCmdType.SendAdvertisement:

                        LEDControl ledControl = new LEDControl();
                        ledControl.GPSCode = gpsCode;
                        ledControl.SerialNumber = serialNumber;
                        ledControl.Data.SerialNumberLen = serialLen;
                        ledControl.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(gpsCode).Length;
                        ledControl.Data.IsGpsAckMsg = false;
                        ledControl.Data.Result = result;
                        dataBuffer = new byte[ledControl.GetLength()];
                        ledControl.WriteBuffer(0, dataBuffer);
                        cmddata.DataBuffer = dataBuffer;
                        cmddata.Data.DataLen = (ushort)dataBuffer.Length;
                        cmddata.Data.Cmd = ControlCmdType.SendAdvertisement;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;

                    //超速报警
                    case ControlCmdType.OverSpeedAlarm:

                        OverSpeedAlarmControl overSpeedCrl = new OverSpeedAlarmControl();
                        overSpeedCrl.GPSCode = gpsCode;
                        overSpeedCrl.Data.GPSCodeLen = gpsCodeLen;
                        overSpeedCrl.SerialNumber = serialNumber;
                        overSpeedCrl.Data.SerialNumberLen = serialLen;
                        overSpeedCrl.Data.IsGpsAckMsg = isGpsAckMsg;
                        overSpeedCrl.Data.Result = result;
                        dataBuffer = new byte[overSpeedCrl.GetLength()];
                        overSpeedCrl.WriteBuffer(0, dataBuffer);
                        cmddata.DataBuffer = dataBuffer;
                        cmddata.Data.DataLen = (ushort)dataBuffer.Length;
                        cmddata.Data.Cmd = ControlCmdType.OverSpeedAlarm;
                        sendBuffer = new byte[cmddata.GetLenth()];
                        cmddata.WriteBuffer(0, sendBuffer);

                        break;
                }
                return sendBuffer;
            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
                return new byte[0];
            }
        }
Esempio n. 6
0
        /// <summary> 
        /// 有为断油断电,(增加一张断油历史表,以及ACC,油路状态等字段)
        /// </summary>
        /// <param name="ControlOil"></param>
        /// <param name="type"></param>
        public void HandleBreakOilCircuit(ControlOilCircuit ControlOil)
        {
            string gpsCode = "";

            ControlCmdType cmdtype = ControlCmdType.BreakOilCircuitByForce;

            byte[] sendBuffer = null;

            try
            {        
                Socket socket=null;
                string remortpoint = string.Empty;

                gpsCode = ControlOil.GPSCode;
                
                if (GpsDataParser.TransfersType == TransfersType.IsTcp)
                {
                    socket = TCPConnList.Instance().GetTCPConnection(ControlOil.GPSCode);
                    if (socket == null)
                    {
                        //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        Logger.Trace("油路控制时,套接字不在列表中", null);
                        return;
                    }
                    if (socket.Connected == false)
                    {
                        //TCPConnList.Instance().RemoveTCPConnection(gpsCode);

                        //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        Logger.Trace("油路控制时,套接字已关闭", null);

                        return;
                    }

                    TimeSpan ControlTimeSpan = DateTime.Now - ControlOil.BreakOilCircuitTime;
                    if (ControlTimeSpan.TotalMinutes > 15)
                    {
                        //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        Logger.Trace("油路控制时,指令超时(15m)", null);
                    }
                }
                else
                {
                    remortpoint = UDPConnList.Instance().GetUDPConnection(ControlOil.GPSCode);
                    if (string.IsNullOrEmpty(remortpoint))
                    {
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        Logger.Trace("油路控制时,套接字不在UDP列表中", null);
                        return;
                    }                    
                }

                int send = 0;//下发指令返回字节数

                switch (ControlOil.Data.GpsType)
                {
                    case GPSType.YouWei:
                        BreakOilCircuitControlEntity entity = new BreakOilCircuitControlEntity();
                        entity.SetTimeBreakOilByUser = DateTime.Now;

                        if (ControlOil.Data.operateType == ContorlOilType.CutOil)//断油断电
                        {
                            if (entity.CmdType == ControlOilMode.Force)
                            {
                                //强制
                                cmdtype = ControlCmdType.BreakOilCircuitByForce;
                                sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.BreakOilCircuitByForce, entity);
                            }
                            else
                            {
                                //智能,停车断油            
                                cmdtype = ControlCmdType.BreakOilCircuitBySmart;
                                sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.BreakOilCircuitBySmart, entity);
                            }
                        }
                        else//供油
                        {
                            cmdtype = ControlCmdType.SupplyOilCircuit;
                            sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.SupplyOilCircuit, gpsCode);

                        }
                        break;
                    case GPSType.BuBiao:


                        //断油断电
                        if (ControlOil.Data.operateType == ContorlOilType.CutOil)
                        {
                            cmdtype = ControlCmdType.BreakOilCircuitByForce;
                            sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.BreakOilCircuitByForce, gpsCode);
                        }
                        else
                        {
                            cmdtype = ControlCmdType.SupplyOilCircuit;
                            sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.SupplyOilCircuit, gpsCode);
                        }
                        break;

                    case GPSType.LongHan:
                    case GPSType.DiBiao:
                    case GPSType.KaiYan:
                    case GPSType.XinAn:
                    case GPSType.BoShiJie:
                    case GPSType.YaXun:
                    case GPSType.KangKaiSi:
                    case GPSType.YongHua:

                        //断油断电
                        if (ControlOil.Data.operateType == ContorlOilType.CutOil)
                        {
                            cmdtype = ControlCmdType.BreakOilCircuitByForce;
                            sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.BreakOilCircuitByForce, gpsCode);
                           
                        }
                        else
                        {
                            cmdtype = ControlCmdType.SupplyOilCircuit;
                            sendBuffer = GpsDataParser.ParseControlInstruction(ControlCmdType.SupplyOilCircuit, gpsCode);
                        }
                        break;
                }
                if (sendBuffer == null)
                {
                    //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                    OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                    Logger.Trace("油路控制时,解析控制指令失败", null);

                    return;
                }

                if (GpsDataParser.TransfersType == TransfersType.IsTcp)
                {

                    send = socket.Send(sendBuffer);
                    if (send > 0)
                    {
                        //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, true);//通知应用层指令下发成功
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, true);//通知应用层指令下发成功
                        Logger.Trace("发送油路控制指令成功。GPSType:" + ControlOil.Data.GpsType.ToString(), null);

                        StringBuilder sbBinaryData = new StringBuilder();
                        sbBinaryData.Append("(" + gpsCode + ")-");
                        for (int i = 0; i < sendBuffer.Length; i++)
                        {
                            sbBinaryData.Append(sendBuffer[i].ToString("X2"));
                            sbBinaryData.Append(" ");
                        }
                        //System.Diagnostics.Debug.WriteLine(sbBinaryData.ToString());
                        socket.Send(sendBuffer);
                    }
                    else
                    {
                        //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                        Logger.Trace("发送油路控制指令失败。GPSType:" + ControlOil.Data.GpsType.ToString(), null);
                    }
                }
                else//UDP
                {
                    string[] endpoint = remortpoint.Split(':');
                    IPEndPoint e = new IPEndPoint(IPAddress.Parse(endpoint[0]), int.Parse(endpoint[1]));
                    //if(GpsDataParser.CodePrefix=="0001") 
                        
                    OnSendDataEvent((EndPoint)e, sendBuffer);
                }
            }
            catch (SocketException ex)
            {
                //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                Logger.Trace("油路控制时,套接字异常");
            }
            catch (Exception ex)
            {
                //SendAnswerToWeb(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                OnSendAnswerToWebEvent(ControlOil.SerialNumber, false, ControlOil.GPSCode, cmdtype, false);
                Logger.Error("油路控制时,异常:" + ex.Message);
            }
            finally
            {
                sendBuffer = null;
            }
        }
Esempio n. 7
0
        public string GetGpsCodeFromBuffer(byte[] receivedBuffer)
        {
            string gpsCode = string.Empty;

            try
            {
                CmdData cmdData = new CmdData();
                cmdData.ReadBuffer(0, receivedBuffer);
                switch (cmdData.Data.Cmd)
                {
                    //调度命令
                    case ControlCmdType.DispatchControl:
                        DispatchControl DispatchControl = new DispatchControl();
                        DispatchControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = DispatchControl.GPSCode;

                        break;

                    //监听喊话
                    case ControlCmdType.ListenCall:
                        ListenCallControl CallControl = new ListenCallControl();
                        CallControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = CallControl.GPSCode;
                        break;

                    case ControlCmdType.LEDControl:
                        SimpleInstructionControl SimpleControl = new SimpleInstructionControl();
                        SimpleControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = SimpleControl.GPSCode;

                        break;

                    //下发拍照的动作
                    case ControlCmdType.SendTakePicture:
                        TakePictureControl takePicture = new TakePictureControl();
                        takePicture.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = takePicture.GPSCode;

                        break;

                    //下发拍照的动作(多摄像头)
                    case ControlCmdType.SendTakePictureMultiCamera:
                        TakePictureControlMultiCamera takePictureMultiCamera = new TakePictureControlMultiCamera();
                        takePictureMultiCamera.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = takePictureMultiCamera.GPSCode;
                        break;

                    case ControlCmdType.SupplyOilCircuit:
                    //强制断油断电
                    case ControlCmdType.BreakOilCircuitByForce:
                    //智能断油断电
                    case ControlCmdType.BreakOilCircuitBySmart:
                        ControlOilCircuit ControlOil = new ControlOilCircuit();
                        ControlOil.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = ControlOil.GPSCode;
                        break;

                    //北京视展LED控制
                    case ControlCmdType.BJSZLedControl:
                    case ControlCmdType.SendAdvertisement:
                        LEDControl ledControl = new LEDControl();
                        ledControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = ledControl.GPSCode;

                        break;
                    //解除报警
                    case ControlCmdType.DischargeAlarm:
                        DischangeAlarmControl dischangeAlarm = new DischangeAlarmControl();
                        dischangeAlarm.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = dischangeAlarm.GPSCode;

                        break;

                    //超速报警
                    case ControlCmdType.OverSpeedAlarm:
                        OverSpeedAlarmControl overSpeedAlarm = new OverSpeedAlarmControl();
                        overSpeedAlarm.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = overSpeedAlarm.GPSCode;
                        break;

                    //获取网关活动信息
                    case ControlCmdType.GetGatewayActiveInfo:
                        GatewayActiveInfo activeInfo = new GatewayActiveInfo();
                        activeInfo.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = activeInfo.GPSCode;
                        break;
                    //更新GPS总里程值
                    case ControlCmdType.updatemileage:
                        UpdateMileage UpMileage = new UpdateMileage();
                        UpMileage.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = UpMileage.GPSCode;
                        break;
                    //设置GPS上传周期
                    case ControlCmdType.SendGPSPosUploadInterval:
                        GPSPosUploadInterval posUploadInterval = new GPSPosUploadInterval();
                        posUploadInterval.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = posUploadInterval.GPSCode;
                        break;

                    //设置移动台初始经参数
                    case ControlCmdType.SetMobileInitPara:
                        SetMobileInitPara setMobileInitPara = new SetMobileInitPara();
                        setMobileInitPara.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = setMobileInitPara.GPSCode;
                        break;

                    //雅迅设备,配置报警器
                    case ControlCmdType.AllocateAnnounciator:
                        SetAnnounciator setAnnounciator = new SetAnnounciator();
                        setAnnounciator.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = setAnnounciator.GPSCode;
                        break;
                    case ControlCmdType.SetCircleRegion:
                    case ControlCmdType.SetRectangleRegion:
                    case ControlCmdType.SetPloygon:
                    case ControlCmdType.SetFixedLine:
                    case ControlCmdType.RemoveCircleRegion:
                    case ControlCmdType.RemoveRectangleRegion:
                    case ControlCmdType.RemovePloygon:
                    case ControlCmdType.RemoveFixedLine:
                    case ControlCmdType.TMLControl:
                    case ControlCmdType.SendTxtToTML:
                    case ControlCmdType.PhoneCallback:
                    case ControlCmdType.CameraShootImmediately:
                    case ControlCmdType.PositionQueryReq:
                    case ControlCmdType.SetStopCarAlarm:
                    case ControlCmdType.SetOverFatigueAlarm:
                    case ControlCmdType.SetOverSpeedAlarm:
                    case ControlCmdType.GetRravelRecord:
                    //case ControlCmdType.MediaInfoSetting:
                    //case ControlCmdType.MediaInfoService:
                    //case ControlCmdType.EventSetting:
                    //case ControlCmdType.PublishQuestion:
                    //case ControlCmdType.TempLocationTrace:
                    //case ControlCmdType.VehicleControl:

                        BuBiaoCommonControl BBControl = new BuBiaoCommonControl();
                        BBControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = BBControl.GPSCode;
                        break;
                    //部标解除报警
                    case ControlCmdType.ReleaseAlarm:
                        BuBiaoCommonControl ReleaseControl = new BuBiaoCommonControl();
                        ReleaseControl.ReadBuffer(0, cmdData.DataBuffer);
                        gpsCode = ReleaseControl.GPSCode;
                        break;

                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
            }

            return gpsCode;
        }
Esempio n. 8
0
        private void ReceiveDataEvent(EndPoint remotePoint, byte[] receivedBuffer)
        {
            //读取命令
            CmdData cmdData = new CmdData();

            //读入数据
            cmdData.ReadBuffer(0, receivedBuffer);

            ReceiveCount++;
            Logger.Info("收到指令反馈次数:" + ReceiveCount);
            switch (cmdData.Data.Cmd)
            {
                

                //控制油路通断
                case ControlCmdType.BreakOilCircuitByForce:
                case ControlCmdType.BreakOilCircuitBySmart:
                case ControlCmdType.SupplyOilCircuit:
                    ControlOilCircuit ControlOil = new ControlOilCircuit();
                    ControlOil.ReadBuffer(0, cmdData.DataBuffer);
                    Logger.Info(string.Format("收到油路指令回复。次数:{0},结果:{1},硬件反馈:{2}", ReceiveCount, ControlOil.Data.Result, ControlOil.Data.IsGpsAckMsg));
                    EnumOilCommandState breakOilState = EnumOilCommandState.All;
                    //有为油路通断控制
                    if (!ControlOil.Data.IsGpsAckMsg)
                    {
                        breakOilState = ControlOil.Data.Result ? EnumOilCommandState.SendSuccess : EnumOilCommandState.SendFail;
                      
                        DACFacade.Gps.BreakOilHistoryDAC.UpdateState(new Guid(ControlOil.SerialNumber), breakOilState);
                    }
                    break;
                case ControlCmdType.DeviceCircuitresAndOil:
                    ControlOilCircuit ControlOil2 = new ControlOilCircuit();
                    ControlOil2.ReadBuffer(0, cmdData.DataBuffer);
                    EnumOilCommandState breakOilState2 = ControlOil2.Data.Result ? EnumOilCommandState.RunSuccess : EnumOilCommandState.RunFail;

                    DACFacade.Gps.BreakOilHistoryDAC.UpdateState(ControlOil2.GPSCode, breakOilState2);
                    break;
                case ControlCmdType.OpenGPS:
                    KKSSimpleControl openGPSControl = new KKSSimpleControl();
                    openGPSControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(openGPSControl.GPSCode, 1, openGPSControl.SendContent);
                    break;
                case ControlCmdType.SetFriendNumber:
                    KKSSimpleControl setfriendnumberControl = new KKSSimpleControl();
                    setfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(setfriendnumberControl.GPSCode, 2, setfriendnumberControl.SendContent);
                    break;
                case ControlCmdType.GetFriendNumber:
                    KKSSimpleControl getfriendnumberControl = new KKSSimpleControl();
                    getfriendnumberControl.ReadBuffer(0, cmdData.DataBuffer);
                    UpdateOpenGPSInfo(getfriendnumberControl.GPSCode, 3, getfriendnumberControl.SendContent);
                    break;
                default:
                    break;
            }
        }