Beispiel #1
0
        /// <summary>
        /// 解析有为LED信息
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override List<byte[]> ParseControlInstructionRetMultipleData(ControlCmdType instructionType, object entity)
        {
            List<byte[]> lstInstruction = new List<byte[]>();
            uint instructionLen = 0;
            byte[] instruction = null;
            byte[] pOutData = null;

            switch (instructionType)
            {
                //LED信息
                case ControlCmdType.LEDControl:

                    LEDBJSZContentInfoEntity ledBJSZControlInfo = entity as LEDBJSZContentInfoEntity;

                    List<byte[]> lstData = BeiJingShiZhanLEDCommander.BJSZ_LEDContentInfo(
                        ledBJSZControlInfo.LEDDisplayType,
                        ledBJSZControlInfo.LEDSpeed,
                        ledBJSZControlInfo.LEDTimeLen,
                        ledBJSZControlInfo.SendContent, true, ledBJSZControlInfo.ColorType, ledBJSZControlInfo.Width, ledBJSZControlInfo.Height);

                    if (lstData == null)
                    {
                        return null;
                    }

                    IEnumerator<byte[]> en = lstData.GetEnumerator();

                    while (en.MoveNext())
                    {
                        instruction = new byte[4096];
                        instructionLen = 0;
                        byte[] data = en.Current;

                        Change2TransparentData((uint)data.Length, data, ref instructionLen, ref instruction, ledBJSZControlInfo.GPSCode);

                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);
                        instruction = null;
                        lstInstruction.Add(pOutData);
                    }
                    break;
            }
            return lstInstruction;
        }
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            KKSSimpleControl simpleControl = new KKSSimpleControl();

            byte[] sendData = null;

            switch (cmdType)
            {
                //断油断电(智能)
                case ControlCmdType.BreakOilCircuitBySmart:
                //断油断电(强制)
                case ControlCmdType.BreakOilCircuitByForce:
                    sendData = GetOilPowerInstruction(true);
                    break;

                //恢复供油供电
                case ControlCmdType.SupplyOilCircuit:
                    sendData = GetOilPowerInstruction(false);
                    break;
            }

            return sendData;
        }
Beispiel #3
0
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            byte[] pOutData = null;
            string strGPSCode;
            GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame SendMsg;
            switch (cmdType)
            {
                case ControlCmdType.DispatchControl:
                    DispatchControl dc = (DispatchControl)entity;

                    SendTxtToTML obj = new SendTxtToTML();
                    obj.IsEmergency = 1;
                    obj.IsTMLLCDShow = 1;
                    obj.IsTMLTTSRead = 1;
                    obj.IsAdvertisingScreenShow = 1;
                    obj.TxtMassage = dc.SendContent;
                    obj.WriteBuffer();

                    GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SendTxtToTML, false, EncryptType.NoEncrypt
                        , (ushort)obj.getLength(), dc.GPSCode
                        , _SerialNumber, 0, 0, obj.dataBuffer);
                    pOutData = BuBiaoSendMsg.WriteBuffer();
                    SafeAddSequence();
                    break;
                case ControlCmdType.ListenCall:
                    YWListenCallInfoEntity callInfo = (YWListenCallInfoEntity)entity;
                    PhoneCallback objCallBack = new PhoneCallback();
                    if (callInfo.ListenCallType == 1)
                        objCallBack.flageByte = 1;
                    else
                        objCallBack.flageByte = 0;
                    objCallBack.PhoneNum = callInfo.Phone;
                    objCallBack.WriteBuffer();

                    GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame BuBiaoSendMsg1 = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.PhoneCallback, false, EncryptType.NoEncrypt
                       , (ushort)objCallBack.getLength(), callInfo.FullGPSCode
                       , _SerialNumber, 0, 0, objCallBack.dataBuffer);
                    pOutData = BuBiaoSendMsg1.WriteBuffer();
                    SafeAddSequence();
                    break;
                case ControlCmdType.BreakOilCircuitByForce:
                case ControlCmdType.BreakOilCircuitBySmart:
                    byte[] BreakOilByte = new byte[] { 0xf0 };
                    strGPSCode = entity.ToString();
                    SendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.TMLControl, false, EncryptType.NoEncrypt, (ushort)BreakOilByte.Length, strGPSCode, _SerialNumber, 0, 0, BreakOilByte);
                    pOutData = SendMsg.WriteBuffer();
                    Debug.WriteLine(Transfer.ConvertBytesToHexString(pOutData));
                    SafeAddSequence();

                    break;
                case ControlCmdType.SupplyOilCircuit:
                    byte[] SupplyOilByte = new byte[] { 0xf1 };
                    strGPSCode = entity.ToString();
                    SendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.TMLControl, false, EncryptType.NoEncrypt, (ushort)SupplyOilByte.Length, strGPSCode, _SerialNumber, 0, 0, SupplyOilByte);
                    pOutData = SendMsg.WriteBuffer();
                    SafeAddSequence();

                    break;
                case ControlCmdType.SimpleInstruction:

                    byte[] instruction = new byte[512];
                    uint instructionLen = 0;
                    SimpleInstructionControlEntity simpleInstructionControlEntity = entity as SimpleInstructionControlEntity;

                    ParseSimpleInstructionControl(simpleInstructionControlEntity, ref instructionLen, ref instruction);

                    pOutData = new byte[instructionLen];
                    Array.Copy(instruction, pOutData, instructionLen);
                    break;
            }
            return pOutData;
        }
Beispiel #4
0
        public void HandleBuBiaoMessage(BuBiaoCommonControl bbControl, ControlCmdType cmdType)
        {

            byte[] sendBuffer = null;
            byte[] BodyBuffer = GpsDataParser.ParseControlInstruction(cmdType, bbControl);
            GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame BuBiaoSendMsg;

            switch (cmdType)
            {
                case ControlCmdType.SetCircleRegion:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SetCircleRegion, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.RemoveCircleRegion:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.RemoveCircleRegion, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.TMLControl:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.TMLControl, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.SendTxtToTML:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SendTxtToTML, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.PhoneCallback:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.PhoneCallback, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.CameraShootImmediately:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.CameraShootImmediately, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.SetRectangleRegion:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SetRectangleRegion, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.SetPloygon:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SetPloygonRegion, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.SetFixedLine:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SetFixedLine, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.RemoveRectangleRegion:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.RemoveRectangleRegion, false, EncryptType.NoEncrypt
                       , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                       , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.RemovePloygon:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.RemovePloygonRegion, false, EncryptType.NoEncrypt
                       , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                       , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.RemoveFixedLine:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.RemoveFixedLine, false, EncryptType.NoEncrypt
                       , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                       , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.SetOverSpeedAlarm:
                case ControlCmdType.SetOverFatigueAlarm:
                case ControlCmdType.SetStopCarAlarm:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.SetTMLPara, false, EncryptType.NoEncrypt
                       , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                       , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.PositionQueryReq:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.QueryPosition, false, EncryptType.NoEncrypt
                       , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                       , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
                case ControlCmdType.GetRravelRecord:
                    BuBiaoSendMsg = new GPSGatewayServer.DataModel.BuBiaoData.GPRSFrame(BuBiaoMsgIdType.GetRravelRecord, false, EncryptType.NoEncrypt
                        , (ushort)bbControl.Data.CommandLen, bbControl.GPSCode
                        , bbControl.Data.SerialNumber, 0, 0, bbControl.Command);
                    sendBuffer = BuBiaoSendMsg.WriteBuffer();
                    break;
            }


            //解析页面下发数据
            if (sendBuffer == null || sendBuffer.Length <= 0)
            {
                Logger.Trace("指令为空, GPSCODE:" + bbControl.GPSCode);
                return;
            }

            try
            {
                //取得已建立的套接字
                Socket socket = TCPConnList.Instance().GetTCPConnection(bbControl.GPSCode);
                if (socket == null)
                {
                    return;
                }
                if (socket.Connected == false)
                {
                    //从集合移除
                    //TCPConnList.Instance().RemoveTCPConnection(bbControl.GPSCode);
                    return;
                }


                try
                {
                    int send = socket.Send(sendBuffer);

                    StringBuilder sbBinaryData = new StringBuilder();
                    for (int i = 0; i < sendBuffer.Length; i++)
                    {
                        sbBinaryData.Append(sendBuffer[i].ToString("X2"));
                        if (i < sendBuffer.Length - 1)
                            sbBinaryData.Append(",");
                    }
                    string ss = sbBinaryData.ToString();

                    GpsDataParser.OnDebugDataEvent(GpsDataParser.TransfersType.ToString(), bbControl.GPSCode, "[应用层下发指令]" + ss);

                    if (send > 0)
                    {
                        //发送回复表示执行成功                        
                        OnSendAnswerToWebEvent(bbControl.Data.SerialNumber.ToString(), false, bbControl.GPSCode, cmdType, true);
                        Logger.Trace("发送部标里程指令成功.GPSCODE:" + bbControl.GPSCode);
                    }
                    else
                    {
                        //发送回复表示执行失败                        
                        OnSendAnswerToWebEvent(bbControl.Data.SerialNumber.ToString(), false, bbControl.GPSCode, cmdType, false);
                        Logger.Trace("发送部标指令失败GPSCODE:" + bbControl.GPSCode);
                    }
                }
                catch (SocketException ex)
                {
                    //从列表移除此连接
                    //TCPConnList.Instance().RemoveTCPConnection(bbControl.GPSCode);
                    Logger.Trace(bbControl.GPSCode + "发送部标里程指令时异常" + ex.ToString(), null);
                }

            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
            }
            finally
            {
                sendBuffer = null;
            }
        }
Beispiel #5
0
        public void HandleKKSSimpleControlInfo(ControlCmdType controlType, KKSSimpleControl simpleControl)
        {
            //发送缓冲区
            byte[] sendBuffer = null;

            string gpsCode = simpleControl.GPSCode;

            try
            {
                Logger.Trace("下发指令到GPSCode:" + gpsCode);
                //取得已建立的套接字
                Socket socket = TCPConnList.Instance().GetTCPConnection(gpsCode);
                if (socket == null)
                {
                    Logger.Trace("下发指令到GPSCode:" + gpsCode + "失败,原因是socket=null");
                    return;
                }
                //已断开连接,将其从连接列表移除
                if (socket.Connected == false)
                {
                    Logger.Trace("下发指令到GPSCode:" + gpsCode + "失败,原因是socket.connected==null");
                    //TCPConnList.Instance().RemoveTCPConnection(gpsCode);
                    return;
                }

                //解析页面下发命令
                sendBuffer = GpsDataParser.ParseControlInstruction(controlType, simpleControl);

                if (sendBuffer == null || sendBuffer.Length <= 0)
                {
                    return;
                }

                try
                {
                    //向GPS发送控制命令
                    int send = socket.Send(sendBuffer);

                    if (send > 0)
                    {
                        //向应用层确认发送成功
                        //SendAnswerToWeb(dispatchControl.SerialNumber,false, gpsCode, ControlCmdType.DispatchControl, true);
                        OnSendAnswerToWebEvent(simpleControl.SerialNumber, false, gpsCode, ControlCmdType.DispatchControl, true);
                        Logger.Trace("GPSYouWei--Gps:" + gpsCode + " 发送命令成功", null);
                    }
                    else
                    {
                        //向应用层确认发送失败
                        //SendAnswerToWeb(dispatchControl.SerialNumber,false, gpsCode, ControlCmdType.DispatchControl, true);
                        OnSendAnswerToWebEvent(simpleControl.SerialNumber, false, gpsCode, ControlCmdType.DispatchControl, true);
                        Logger.Trace("GPSYouWei--Gps:" + gpsCode + " 发送命令失败", null);
                    }
                }
                catch (SocketException ex)
                {
                    //向应用层确认发送失败
                    //SendAnswerToWeb(dispatchControl.SerialNumber,false, gpsCode, ControlCmdType.DispatchControl, true);
                    OnSendAnswerToWebEvent(simpleControl.SerialNumber, false, gpsCode, ControlCmdType.DispatchControl, true);
                    Logger.Error("GPSYouWei--Gps:" + gpsCode + " 发送命令时异常--" + ex.Message, null);

                    //从列表移除此连接
                    //TCPConnList.Instance().RemoveTCPConnection(gpsCode);

                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
            }
            finally
            {
                sendBuffer = null;
            }
        }
Beispiel #6
0
 /// <summary>
 /// 解析有为LED信息
 /// </summary>
 /// <param name="instructionType"></param>
 /// <param name="entity"></param>
 /// <returns></returns>
 public virtual List<byte[]> ParseControlInstructionRetMultipleData(ControlCmdType instructionType, object entity) 
 {
     throw new NullReferenceException();
 }
Beispiel #7
0
        /// <summary> 收到应答后触发事件
        /// 
        /// </summary>
        /// <param name="head">数据共用头</param>
        /// <param name="cmd">控制命令类型</param>
        /// <param name="simpleCmd">命令字</param>
        private void OnPostAnswer(IDeviceNotifyHead head, ControlCmdType cmd, params SimpleCmdType []simpleCmd)
        {
            string gpscode = base.CodePrefix+Convert.ToString(head.dwDeviceNumber);

            bool bol = false;

            if (head.dwResult == YouWeiPublicDefine.EXESUCCEEDED)
            {
                bol = true;
            }
            OnSendAnswerToWebEvent(string.Empty, true, gpscode, cmd, bol, simpleCmd);
            //OnPostSendAnswerHandlerEvent(string.Empty,true, gpscode, cmd, bol, simpleCmd);            
        }
Beispiel #8
0
 /// <summary> 解析页面下发的命令
 /// 
 /// </summary>
 /// <param name="instructionType"></param>
 /// <param name="entity"></param>
 /// <returns></returns>
 public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
 {
     throw new NullReferenceException();
 }
Beispiel #9
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)
        {
            try
            {
                //获取WEB列表
                EndPoint adress = (EndPoint)WebTable[gpscode];

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

                    //硬编码30003为网站的监听端口
                    string[] remoteAddress = adress.ToString().Split(":".ToCharArray());
                    string remoteIP = remoteAddress[0];
                    IPAddress remoteIPAddress = IPAddress.Parse(remoteIP);
                    IPEndPoint remoteEndPoint = new IPEndPoint(remoteIPAddress, 30003);
                    CmdServer.SendTo(remoteEndPoint, answerBytes);
                    Logger.Trace("SendAnswerToWeb to " + remoteEndPoint.ToString());
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, null);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 解析页面下发的命令
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            //生在发送数据
            byte[] sendBuffer = null;

            //终端号
            string terminalNum = string.Empty;

            //选择命令
            switch (cmdType)
            {
                //监听喊话
                case ControlCmdType.ListenCall:
                    YWListenCallInfoEntity objParam = (YWListenCallInfoEntity)entity;
                    terminalNum = objParam.FullGPSCode.Substring(4);
                    bool isPhone = true;
                    //监听-1 喊话-2
                    if (objParam.ListenCallType == 1)
                        isPhone = false;
                    else if (objParam.ListenCallType == 2)
                        isPhone = true;
                    sendBuffer = CtrlListenPhone(terminalNum, isPhone, objParam.Phone);
                    break;

                //断油断电
                case ControlCmdType.BreakOilCircuitByForce:
                case ControlCmdType.BreakOilCircuitBySmart:

                    //去掉前缀
                    terminalNum = entity as string;
                    terminalNum = terminalNum.Substring(4);
                    sendBuffer = CtrlTelecontrollerReq(terminalNum, false, false);

                    break;

                //供油供电
                case ControlCmdType.SupplyOilCircuit:

                    terminalNum = entity as string;
                    terminalNum = terminalNum.Substring(4);
                    sendBuffer = CtrlTelecontrollerReq(terminalNum, false, true);

                    break;

                //配置报警器
                case ControlCmdType.AllocateAnnounciator:

                    SetAnnounciator setAnnounciator = (SetAnnounciator)entity;
                    SetAnnounciator.FixedData data = setAnnounciator.Data;

                    AnnounciatorState state = new AnnounciatorState();
                    state.AwayRoadAlarm = data.AwayRoadAlarm;
                    state.DoorUnClosed = data.DoorUnClosed;
                    state.InvalidOpenDoorAlarm = data.InvalidOpenDoorAlarm;
                    state.InvalidPower = data.InvalidPower;
                    state.OverBorderAlarm = data.OverBorderAlarm;
                    state.OverSpeeAlarm = data.OverSpeeAlarm;
                    state.PowerOffAlarm = data.PowerOffAlarm;
                    state.RobAlarm = data.RobAlarm;
                    state.ShakeAlarm = data.ShakeAlarm;
                    state.SpanCheck = data.SpanCheck;
                    state.UnderVolAlarm = data.UnderVolAlarm;
                    state.StopCheck = data.StopCheck;

                    sendBuffer = AllocateAnnounciator(setAnnounciator.GPSCode.Substring(4), state);

                    break;
            }

            return sendBuffer;
        }
Beispiel #11
0
        /// <summary> 解析页面下发的命令
        /// 解析页面下发的命令
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            string gpscode = entity.ToString();

            byte[] sendData = new byte[20];

            switch (cmdType)
            {
                //断油断电(智能)
                case ControlCmdType.BreakOilCircuitBySmart:
                //断油断电(强制)
                case ControlCmdType.BreakOilCircuitByForce:

                    sendData = GPSGatewayServer.DataParse.BoShiJieInstructionSet.BrokenCircuit(gpscode);

                    break;

                //恢复供油供电
                case ControlCmdType.SupplyOilCircuit:

                    sendData = GPSGatewayServer.DataParse.BoShiJieInstructionSet.ResumeCircuit(gpscode);

                    break;

                //解除报警
                case ControlCmdType.DischargeAlarm:

                    break;
            }
            return sendData;
        }
Beispiel #12
0
        /// <summary> 解析页面下发的命令
        /// 解析页面下发的命令
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            string gpscode = entity.ToString();

            byte[] sendData = new byte[20];

            switch (cmdType)
            {
                //断油断电(智能)
                case ControlCmdType.BreakOilCircuitBySmart:
                //断油断电(强制)
                case ControlCmdType.BreakOilCircuitByForce:

                    CreateBreakOilMessage(gpscode, ref sendData);

                    break;

                //恢复供油供电
                case ControlCmdType.SupplyOilCircuit:

                    CreateUpOilMessage(gpscode, ref sendData);

                    break;

                //解除报警
                case ControlCmdType.DischargeAlarm:

                    break;
            }
            return sendData;
        }
Beispiel #13
0
 /// <summary> 解析页面下发的命令
 /// 
 /// </summary>
 /// <param name="instructionType"></param>
 /// <param name="entity"></param>
 /// <returns></returns>
 public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
 {
     byte[] time = new byte[6];
     byte[] content = null;
     switch (cmdType)
     {
         case ControlCmdType.BreakOilCircuitBySmart:
         case ControlCmdType.BreakOilCircuitByForce:
             byte flage = (byte)1;
             time = SetTimeToBCD(DateTime.Now.AddSeconds(15));
             content = new byte[] { flage, time[0], time[1], time[2], time[3], time[4], time[5] };
             return SetDownDatagram("19", entity.ToString(), content);
         case ControlCmdType.SupplyOilCircuit://给油
             flage = (byte)0;
             time = SetTimeToBCD(DateTime.Now.AddMinutes(15));
             content = new byte[] { flage, time[0], time[1], time[2], time[3], time[4], time[5] };
             return SetDownDatagram("19", entity.ToString(), content);
         case ControlCmdType.OverSpeedAlarm://设置超速报警
             List<string> lis = entity as List<string>;
             string strgpscode = lis[0].ToString();//gpscode
             byte bytspeed = Convert.ToByte(int.Parse(lis[1].ToString()));//Speed km/h
             byte bytOsaTime = Convert.ToByte(int.Parse(lis[0].ToString()));//OsaTime s
             content = new byte[] { bytspeed, bytOsaTime };
             return SetDownDatagram("06", strgpscode, content);
     }
     return null;
 }
Beispiel #14
0
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            //string gpscode = entity.ToString();
            KKSSimpleControl simpleControl = new KKSSimpleControl();
            if (cmdType == ControlCmdType.OpenGPS || cmdType == ControlCmdType.GetFriendNumber || cmdType == ControlCmdType.SetFriendNumber)
            {
                simpleControl = (KKSSimpleControl)entity;
            }

            byte[] sendData = null;

            switch (cmdType)
            {
                //断油断电(智能)
                case ControlCmdType.BreakOilCircuitBySmart:
                //断油断电(强制)
                case ControlCmdType.BreakOilCircuitByForce:
                    sendData = GetOilPowerInstruction(true);
                    break;

                //恢复供油供电
                case ControlCmdType.SupplyOilCircuit:
                    sendData = GetOilPowerInstruction(false);
                    break;
                case ControlCmdType.OpenGPS:
                case ControlCmdType.GetFriendNumber:
                case ControlCmdType.SetFriendNumber:
                    sendData = GetSimpleControlInstruction(simpleControl);
                    break;
            }
            //if (simpleControl.Data.SimpleControlType == KKSSimpleControlType.SetFriendNumber)
            //{
            //    return GetResponseMsg(0x81, sendData);
            //}
            return GetResponseMsg(0x80, sendData);
        }
Beispiel #15
0
 public void OnSendAnswerToWebEvent(string serialNumber, bool isGpsAckMsg, string gpscode, ControlCmdType cmdType, bool result, params SimpleCmdType[] simplecmd)
 {
     if (SendAnswerToWebEvent != null)
     {
         SendAnswerToWebEvent(serialNumber, isGpsAckMsg, gpscode, cmdType, result, simplecmd);
     }
 }
Beispiel #16
0
 public void OnSendAnswerToWebEvent(string serialNumber, bool isGpsAckMsg, string gpscode, ControlCmdType cmdType, bool result, params SimpleCmdType[] simplecmd)
 {
     try
     {
         if (SendAnswerToWebEvent != null)
         {
             SendAnswerToWebEvent(serialNumber, isGpsAckMsg, gpscode, cmdType, result, simplecmd);
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex, null);
     }
 }
Beispiel #17
0
 /// <summary>
 /// 终端消息应答事件
 /// </summary>
 /// <param name="serialNumber">流水号</param>
 /// <param name="isGpsAckMsg">是否是GPS应答的消息</param>
 /// <param name="gpsCode">终端发送的GPSCode</param>
 /// <param name="cmd">消息命令字</param>
 /// <param name="bol">执行是否成功</param>
 public virtual void OnPostSendAnswerHandlerEvent(string serialNumber,bool isGpsAckMsg, string gpsCode, ControlCmdType cmd, bool bResult, params SimpleCmdType[] simplecmd)
 {
     if (PostSendHandlerAnswerEvent != null)
     {
         PostSendHandlerAnswerEvent(serialNumber,isGpsAckMsg, gpsCode, cmd, bResult, simplecmd);
     }
 }
Beispiel #18
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];
            }
        }
Beispiel #19
0
 /// <summary>
 /// 解析页面下发的命令
 /// </summary>
 /// <param name="cmdType">制命命令</param>
 /// <param name="entity"></param>
 /// <returns></returns>
 public virtual byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
 {
     return null;
 }
Beispiel #20
0
        /// <summary>
        /// 解析页面下发的命令
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            byte[] pOutData = null;
            try
            {
                uint instructionLen = 0;

                byte[] instruction = null;                

                string gpsCode;

                byte[] LEDData;

                switch (cmdType)
                {
                    //调度
                    case ControlCmdType.DispatchControl:

                        instruction = new byte[512];

                        YWDispatchControlEntity dispatch = entity as YWDispatchControlEntity;

                        //终端下发文本                        
                        SendDeviceTextMsg(dispatch, ref instructionLen, ref instruction);

                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);                        
                        break;

                    //监听、喊话
                    case ControlCmdType.ListenCall:

                        instruction = new byte[512];
                        YWListenCallInfoEntity listenCall = entity as YWListenCallInfoEntity;
                        StringBuilder listenPhone = new StringBuilder(listenCall.Phone);

                        YouWeiGPSInterface.EncodeConfDeviceListen(
                            (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                            YouWeiPublicDefine.PROTOCOLVER,
                            YouWeiPublicDefine.SEQUENCEID,
                            1,
                            (byte)listenCall.ListenCallType,
                            listenPhone,
                            ref instructionLen,
                            instruction);

                        pOutData = new byte[instructionLen];

                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

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

                        instruction = new byte[512];
                        SimpleInstructionControlEntity simpleInstructionControlEntity = entity as SimpleInstructionControlEntity;

                        ParseSimpleInstructionControl(simpleInstructionControlEntity, ref instructionLen, ref instruction);

                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //LED信息控制
                    case ControlCmdType.LEDControl:

                        instruction = new byte[4096];
                        YWLEDControlEntity ledControlInfo = entity as YWLEDControlEntity;

                        LEDData = YouWeiLEDCommander.GenerateMessageCommand(ledControlInfo.BoxNum.ToString("0000"), ledControlInfo.MessageType, ledControlInfo.Content);
                        SendTransparentData((uint)LEDData.Length, LEDData, ref instructionLen, ref instruction);

                        pOutData = new byte[instructionLen];

                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //LED属性
                    case ControlCmdType.LEDProperty:

                        instruction = new byte[4096];
                        YWLEDControlEntity ledProperty = entity as YWLEDControlEntity;
                        gpsCode = ledProperty.GPSCode.Substring(GPSCODEPRDFIXLEN, ledProperty.GPSCode.Length - GPSCODEPRDFIXLEN);

                        string dateFrom = Convert.ToDateTime(ledProperty.LEDSectime1).ToString("yyyyMMdd");
                        string dateTo = Convert.ToDateTime(ledProperty.LEDSectime2).ToString("yyyyMMdd");
                        string timeFrom = Convert.ToDateTime(ledProperty.LEDSectime1).ToString("HHmmss");
                        string timeTo = Convert.ToDateTime(ledProperty.LEDSectime2).ToString("HHmmss");

                        LEDData = YouWeiLEDCommander.GeneratePropertyCommand(
                            ledProperty.BoxNum.ToString("0000"),
                            8,
                            ledProperty.LEDDisplayType,
                            ledProperty.LEDFont,
                            ledProperty.LEDSpeed,
                            ledProperty.LEDInterval,
                            ledProperty.LEDTimes,
                            ledProperty.LEDTimeLen,
                            ledProperty.LEDBrightness,
                            dateFrom,
                            dateTo,
                            timeFrom,
                            timeTo);

                        SendTransparentData((uint)LEDData.Length, LEDData, ref instructionLen, ref instruction);

                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //断油断电(智能)
                    case ControlCmdType.BreakOilCircuitBySmart:


                        instruction = new byte[512];
                        YouWeiGPSInterface.EncodeContorlOilCircuit(
                                    (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                                    YouWeiPublicDefine.PROTOCOLVER,
                                    YouWeiPublicDefine.SEQUENCEID,
                                    (byte)ContorlOilType.CutOil,
                                    (byte)ControlOilMode.Smart,
                                    ref instructionLen,
                                    instruction);
                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //断油断电(强制)
                    case ControlCmdType.BreakOilCircuitByForce:

                        instruction = new byte[512];
                        YouWeiGPSInterface.EncodeContorlOilCircuit(
                                    (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                                    YouWeiPublicDefine.PROTOCOLVER,
                                    YouWeiPublicDefine.SEQUENCEID,
                                    (byte)ContorlOilType.CutOil,
                                    (byte)ControlOilMode.Force,
                                    ref instructionLen,
                                    instruction);
                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //恢复供油供电
                    case ControlCmdType.SupplyOilCircuit:

                        instruction = new byte[512];
                        YouWeiGPSInterface.EncodeContorlOilCircuit(
                                (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                                YouWeiPublicDefine.PROTOCOLVER,
                                YouWeiPublicDefine.SEQUENCEID,
                                (byte)ContorlOilType.RestoreOil,
                                (byte)ControlOilMode.Smart,
                                ref instructionLen,
                                instruction);
                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //解除报警
                    case ControlCmdType.DischargeAlarm:

                        instruction = new byte[512];
                        YouWeiGPSInterface.EncodeRelieveAlarm(
                            (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                            YouWeiPublicDefine.PROTOCOLVER,
                            YouWeiPublicDefine.SEQUENCEID,
                            0,
                            0,
                            ref instructionLen,
                            instruction);

                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //门锁
                    case ControlCmdType.LockSpeekerCircuit:

                        instruction = new byte[512];
                        List<string> lis = entity as List<string>;
                        YouWeiGPSInterface.EncodeContorlCircuit(
                            (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                            YouWeiPublicDefine.PROTOCOLVER,
                            YouWeiPublicDefine.SEQUENCEID,
                            Convert.ToByte(int.Parse(lis[0].ToString())),//type
                            Convert.ToByte(int.Parse(lis[1].ToString())),//operation
                            1,
                            ref instructionLen,
                            instruction
                            );
                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;

                    //超速报警
                    case ControlCmdType.OverSpeedAlarm:

                        instruction = new byte[512];
                        List<string> lis2 = entity as List<string>;
                        YouWeiGPSInterface.EncodeConfDeviceOSA(
                            (byte)GPSYouWeiProtocolType.GPRSORCDMA,
                            YouWeiPublicDefine.PROTOCOLVER,
                            YouWeiPublicDefine.SEQUENCEID,
                            Convert.ToByte(int.Parse(lis2[0].ToString())),//Speed
                            Convert.ToByte(int.Parse(lis2[1].ToString())),//OsaTime
                            ref instructionLen,
                            instruction
                            );
                        pOutData = new byte[instructionLen];
                        Array.Copy(instruction, pOutData, instructionLen);

                        break;
                }

                instruction = null;
                return pOutData;
            }
            catch (Exception ex)
            {
                Logger.Error(ex,null);
                return pOutData;
            }            
        }