Ejemplo 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;
            IBreakOilHistoryManager db = new BreakOilHistoryManager();
            if (commandType == EnumOilCommandType.BreakOil)
            {
                flag = CommandService.GetInstance().BreakOilCircuitBySmart(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                db.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "智能断电.");
            }
            if (commandType == EnumOilCommandType.Support)
            {
                flag = CommandService.GetInstance().SupplyOilCircuit(control);
                EnumOilCommandState state = flag == true ? EnumOilCommandState.Sended : EnumOilCommandState.SendFail;
                db.UpdateState(sequnceNo, state);
                WirteSendLog(flag, gpsCode, "供电供油.");
            }


        }
Ejemplo n.º 2
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();
                        breakOil.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();
                    breakOil2.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;
            }
        }