/// <summary> /// 解析GPS上传的数据----数据公用头 /// </summary> ///<param name="codePrefix">GPS分类前缀</param> /// <param name="notifyHead"></param> /// <param name="data"></param> public static void ParseGPSData_NotifyHead_ToEntity(IDeviceNotifyHead notifyHead, ref YouWeiGPSData data,string codePrefix) { data.BaseData.GPSCode = Convert.ToString(notifyHead.dwDeviceNumber); data.FullGpsCode = codePrefix + data.BaseData.GPSCode; //data.ProtocolType = (int)notifyHead.dwProtocolType; //data.ProtocolVer = (int)notifyHead.dwProtocolVer; //data.CarrierNumber = (int)notifyHead.dwCarrierNumber; //data.CommandExecuteResult = (int)notifyHead.dwResult; }
/// <summary> /// 获取当前油量(4011协议) /// </summary> /// <param name="status"></param> /// <param name="AccState"></param> /// <param name="data"></param> private static void GetOilBearling(IStatusEx status, int AccState, ref YouWeiGPSData data) { if (AccState == 1) { try { if (status.wOilValue < 500) { status.wOilValue = 500; } data.BaseData.OilBearing = (status.wOilValue - 500) / 10; } catch { data.BaseData.OilBearing = (decimal)0.00; } } else { data.BaseData.OilBearing = (decimal)0.00; } }
/// <summary> /// 获取当前油量(4012协议) /// </summary> /// <param name="position"></param> /// <param name="data"></param> private static void GetOilBearling(IPositionStatus position, ref YouWeiGPSData data) { if (position.Option.Length > 0) { uint uKind = (uint)position.Option[4]; if (uKind == YouWeiPublicDefine.POS_OPTION_KIND_OILVALUE) { IDevicePosOptionOIL deviceOil = (IDevicePosOptionOIL)Transfer.BytesToStuct(position.Option, typeof(IDevicePosOptionOIL)); if (data.BaseData.ACCState == 1) { try { if (deviceOil.dwValue < 500) { deviceOil.dwValue = 500; } data.BaseData.OilBearing = (deviceOil.dwValue - 500) / 10; } catch { data.BaseData.OilBearing = (decimal)0.00; } } else { data.BaseData.OilBearing = (decimal)0.00; } } //System.Diagnostics.Debug.WriteLine("----------" + data.BaseData.OilBearing.ToString() + "---------"); } }
/// <summary> /// 判断持续未定位状态时发送重启GPS指令 /// </summary> /// <param name="gpsData"></param> /// <param name="dicGPSLocated"></param> /// <param name="Time"></param> /// <returns></returns> public bool IsSendRestartMsg(YouWeiGPSData gpsData, Dictionary<string, DateTime> dicGPSLocated, double Time) { GPSDataEntity entity = gpsData.BaseData; if (string.IsNullOrEmpty(entity.GPSCode)) { return false; } lock (DicIsGPSLocated) { if (entity.IsLocatedData) { if (dicGPSLocated.ContainsKey(entity.GPSCode)) { dicGPSLocated[entity.GPSCode] = entity.ReceiveTime; } } else { if (!dicGPSLocated.ContainsKey(entity.GPSCode)) { dicGPSLocated.Add(entity.GPSCode, entity.ReceiveTime); } } if (dicGPSLocated.ContainsKey(entity.GPSCode)) { TimeSpan ts = entity.ReceiveTime - dicGPSLocated[entity.GPSCode]; if (ts.TotalMinutes > Time) { dicGPSLocated[entity.GPSCode] = entity.ReceiveTime; return true; } } } return false; }
/// <summary> /// 解析GPS上传的数据----终端向中心发送文本消息 /// </summary> /// <param name="OilConsumeAlarmParamRes"></param> /// <param name="data"></param> /// <param name="codePrefix">GPS分类前缀</param> public static void parseGPSData_DeviceSendTextMsg_ToEntity(IDeviceSendTextMsg DeviceSendTextMsg, ref YouWeiGPSData data,string codePrefix) { ParseGPSData_NotifyHead_ToEntity(DeviceSendTextMsg.NotifyHead, ref data,codePrefix); char[] content = null; switch(DeviceSendTextMsg.wTextCodingMode) { case (uint)GPSYouWei_TextCodingMode.English: content = Encoding.ASCII.GetChars(DeviceSendTextMsg.TextContent); break; case (uint)GPSYouWei_TextCodingMode.Unicode2: content = Encoding.Unicode.GetChars(DeviceSendTextMsg.TextContent); break; case (uint)GPSYouWei_TextCodingMode.GBK: content = Encoding.BigEndianUnicode.GetChars(DeviceSendTextMsg.TextContent); break; } for (int i = 0; i < content.Length; i++) { if (content[i] != '\0') { data.TextContent += content[i].ToString(); } else { break; } } }
/// <summary> /// 解析GPS上传的数据----拍照 /// </summary> /// <param name="TakePictureRes"></param> /// <param name="data"></param> public static void parseGPSData_TakePictureRes_ToEntity(IDeviceTakePictureRes TakePictureRes, ref YouWeiGPSData data, string codePrefix) { ParseGPSData_NotifyHead_ToEntity(TakePictureRes.NotifyHead, ref data,codePrefix); ParseGPSData_Position_ToEntity(TakePictureRes.position, ref data); ParseGPSData_StatusEx_ToEntity(TakePictureRes.statusEx, ref data); }
public static void ParseGPSData_PostionAndStatus_ToEntity2(IDevicePostionStatus positionAndStatus, ref YouWeiGPSData data, ref YouWeiGPSData[] dataEx, string codePrefix) { ParseGPSData_NotifyHead_ToEntity(positionAndStatus.NotifyHead, ref data, codePrefix); //ParseGPSData_StatusEx_ToEntity(positionAndStatus.statusEx, ref data); if (positionAndStatus.dwCount >= 1) { dataEx = new YouWeiGPSData[positionAndStatus.dwCount]; for (int i = 0; i < positionAndStatus.dwCount; i++) { if (i > 0 && positionAndStatus.position[i].dLatitude > 0 && positionAndStatus.position[i].dLongitude > 0) { if (dataEx[i] == null) { dataEx[i] = new YouWeiGPSData(); } ParseGPSData_NotifyHead_ToEntity(positionAndStatus.NotifyHead, ref dataEx[i], codePrefix); //ParseGPSData_StatusEx_ToEntity(positionAndStatus.statusEx, ref dataEx[i]); ParseGPSData_Position_ToEntity(positionAndStatus.position[i], ref dataEx[i]); } else if (i == 0) { ParseGPSData_Position_ToEntity(positionAndStatus.position[i], ref data); } } } }
/// <summary> /// 解析GPS上传的数据----终端注册 /// </summary> /// <param name="registered"></param> /// <param name="data"></param> /// <param name="codePrefix">GPS分类的前缀</param> public static void ParseGPSData_Registered_ToEntity(IDeviceRegistered registered, ref YouWeiGPSData data,string codePrefix) { ParseGPSData_NotifyHead_ToEntity(registered.NotifyHead, ref data,codePrefix); ParseGPSData_Position_ToEntity(registered.position, ref data); ParseGPSData_StatusEx_ToEntity(registered.statusEx, ref data); }
/// <summary> /// 应用层拍照确认方法 /// </summary> /// <param name="pictureData">拍照数据</param> /// <param name="isGpsAckMsg">是否是GPS终端的确认消息</param> /// <param name="bResult">执行结果:成功或失败</param> public void TakePictureAckMsg(ref YouWeiGPSData pictureData, bool isGpsAckMsg, bool bResult) { TakePictureControl takePicture = new TakePictureControl(); takePicture.FilePath = pictureData.BaseData.PhotoPath; takePicture.GPSCode = pictureData.FullGpsCode; takePicture.Data.FilePathLen = Encoding.Default.GetBytes(takePicture.FilePath).Length; takePicture.Data.GPSCodeLen = (byte)Encoding.Default.GetBytes(takePicture.GPSCode).Length; takePicture.Data.PictureType = (TakePictureType)pictureData.BaseData.RealTimePhotoType; takePicture.Data.Result = bResult; takePicture.Data.IsGpsAckMsg = isGpsAckMsg; byte[] dataBuffer = new byte[takePicture.GetLength()]; takePicture.WriteBuffer(0, dataBuffer); CmdData data = new CmdData(); data.Data.Cmd = ControlCmdType.SendTakePicture; data.DataBuffer = dataBuffer; data.Data.DataLen = (ushort)dataBuffer.Length; byte[] sendBuffer = new byte[data.GetLenth()]; data.WriteBuffer(0, sendBuffer); OnPostAckMsgHandlerEvent(takePicture.GPSCode, sendBuffer); }
/// <summary> /// 写照片文件到指定目录 /// </summary> private void SavePictureInfoToDB(string gpsCode, string httpFileName, BoShiJiePicture picture) { YouWeiGPSData picture_YouWeiData = new YouWeiGPSData(); //去掉前缀的GPSCode picture_YouWeiData.BaseData.GPSCode = gpsCode.Remove(0, base.CodePrefix.Length); picture_YouWeiData.BaseData.PhotoPath = httpFileName; picture_YouWeiData.BaseData.IsPhotoData = true; picture_YouWeiData.FullGpsCode = gpsCode; int photoType = 0; switch (picture.TakeKind) { case 2: case 3: //上车拍照或开门拍照 photoType = 3; break; default: //默认实时拍照 photoType = 2; if (PicTaskPool.ContainsKey(gpsCode) && PicTaskPool[gpsCode].Count > 0) { //取出队首的任务 TakePicTask task = PicTaskPool[gpsCode].Peek(); if (task.TaskType == SimpleCmdType.TimingShoot) { photoType = 1; } else if (task.TaskType == SimpleCmdType.TakePictureForDoorShot) { photoType = 3; } } break; } picture_YouWeiData.BaseData.ReportTime = DateTime.Now; picture_YouWeiData.BaseData.ReceiveTime = DateTime.Now; picture_YouWeiData.BaseData.DoorStatus = (picture.TakeKind == 0x02 || picture.TakeKind == 0x03) ? 1 : 0; picture_YouWeiData.BaseData.PlunderState = picture.TakeKind == 0x01 ? 0 : 1; picture_YouWeiData.BaseData.RealTimePhotoType = photoType; picture_YouWeiData.BaseData.CameraId = picture.CameraNo; //} //StorageService.Store(new List<GPSDataEntity>() { picture_YouWeiData.BaseData }, base.CodePrefix); StorageService.GetQueue().Enqueue(picture_YouWeiData.BaseData); //向应用层发送图片路径 TakePictureAckMsg(ref picture_YouWeiData, false, true); }
/// <summary> /// 解析GPS回传的命令 /// </summary> /// <param name="protocolType">协议类型</param> /// <param name="pInData">GPS回传的命令</param> /// <param name="receiveDataCondition"></param> /// <param name="gpsData">解析后的GPS数据</param> /// <param name="gpsDataEx"></param> /// <param name="pictureData"></param> /// <param name="responseList"></param> /// <returns></returns> private bool Decode( byte protocolType, byte[] pInData, ref YouWeiGPSReceiveDataCondition receiveDataCondition, ref YouWeiGPSData gpsData, ref YouWeiGPSData[] gpsDataEx, ref YouWeiGPSData pictureData, out List<byte[]> responseList) { bool Result = false; responseList = new List<byte[]>(); //解析上传数据 int nResult = ParseGPSCode(protocolType, pInData, ref receiveDataCondition); if (nResult < 0) { Logger.Error("GPSYouWei.YouWeiDataParser.Decode,ParseGPSCode方法返回值为负数,解析数据失败。" + CommonMethod.Transfer.ToHexString(pInData), null); return false; } // 128,下发到GPS的数据长度 uint sendDataLen = 0; //下发到GPS的数据 byte[] sendData = null; //解析后的输出数据 byte[] pOutData = null; try { //应答数据 if (receiveDataCondition.isNeedAnswer) { responseList.Add(receiveDataCondition.pAnswerData); } switch (receiveDataCondition.commandID) { //终端注册 case YouWeiPublicDefine.ICOMMAND_DEVICEREGISTERED: //解析出gpsData数据 IDeviceRegistered Reg = (IDeviceRegistered)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceRegistered)); YouWeiParseGPSDataToEntity.ParseGPSData_Registered_ToEntity(Reg, ref gpsData, base.CodePrefix); break; case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION2: case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION: //主动上传数据、设备定位信息 case YouWeiPublicDefine.ICOMMAND_DEVICECURRENTPOSRES: //获得当前位置(点名) case YouWeiPublicDefine.ICOMMAND_DEVICECURRSTATUSRES: //获得当前状态 if (receiveDataCondition.commandID == YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION2) { IDevicePostionStatus PosRes42 = (IDevicePostionStatus)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDevicePostionStatus)); YouWeiParseGPSDataToEntity.ParseGPSData_PostionAndStatus_ToEntity2(PosRes42, ref gpsData, ref gpsDataEx, base.CodePrefix); } else { IDevicePositionAndStatus PosRes = (IDevicePositionAndStatus)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDevicePositionAndStatus)); YouWeiParseGPSDataToEntity.ParseGPSData_PostionAndStatus_ToEntity(PosRes, ref gpsData, ref gpsDataEx, base.CodePrefix); } base.OnDebugDataEvent(this.TransfersType.ToString(), gpsData.FullGpsCode, "----------" + receiveDataCondition.commandID.ToString() + "(" + gpsData.BaseData.OilBearing.ToString() + ")------"); #region 测试命令 //#region 命令发送成功,并且终端有回应,但是这两条指令下发后,终端回应的数据一致 int i = 0; ////停止看守报警 //if (i == 19) //{ // YouWeiGPSInterface.EncodeWatchAlarm( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 0, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} ////进入看守报警 //if (i == 18) //{ // YouWeiGPSInterface.EncodeWatchAlarm( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 1, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} //#endregion ////唤醒睡眠 //if (i == 17) //{ // YouWeiGPSInterface.EncodeConfDeviceSleep( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 0, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} ////进入睡眠 //if (i == 16) //{ // YouWeiGPSInterface.EncodeConfDeviceSleep( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 1, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} ////查询/设置油耗检测参数 //if (i == 8) //{ // YouWeiGPSInterface.EncodeQueryDeviceOilCheck((byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} ////配置油耗检测参数 //if (i == 9) //{ // ushort[] ratio = new ushort[5] { 0, 25, 50, 75, 100 }; // ushort[] sample = new ushort[5] { 0, 16, 32, 64, 80 }; // YouWeiGPSInterface.EncodeConfDeviceOilCheck( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 5, // ratio, // sample, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} //配置短信接收号码 //if (i == 4) //{ // sendDataLen = 0; // sendData = new byte[512]; // StringBuilder phone = new StringBuilder("13554930639"); // YouWeiGPSInterface.EncodeSetCenterSMSRecvNumber( // (byte)GPSYouWeiProtocolType.GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // Convert.ToUInt32(gpsData.GPSCode), // (byte)GPSYouWei_Flag.Flag1, // 1, // phone, // ref sendDataLen, // sendData); //} ////设置油量异常(漏油、偷油) 报警检测参数 //if (i == 31) //{ // YouWeiGPSInterface.EncodeConfDeviceOilExceptionCheck( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // 1, // 100, // 1, // 100, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} ////查询油量异常(漏油、偷油)报警检测参数 //if (i == 30) //{ // YouWeiGPSInterface.EncodeQueryDeviceOilExceptionCheck( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // ref sendDataLen, // sendData); // blnShouldResponse = true; //} //if (i != 0) //{ // responseList.Add(sendData); //} #endregion break; //车辆报警事件 case YouWeiPublicDefine.ICOMMAND_DEVICEALARMEVENT: IDeviceAlarmEvent AlarmEvent = (IDeviceAlarmEvent)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceAlarmEvent)); YouWeiParseGPSDataToEntity.ParseGPSData_AlarmEvent_ToEntity(AlarmEvent, ref gpsData, base.CodePrefix); Logger.Trace("车辆主动报警。GPSCODE:" + gpsData.FullGpsCode + " 报警类型:" + gpsData.BaseData.PlunderState + " 经纬度--lat:" + gpsData.BaseData.Latitude + " log:" + gpsData.BaseData.Longitude); //不是私家车,立即解除。gxl 2010-3-5 if (!mIsPrivateCar) { //解除报警 3-11注释撤销报警 有为告知 报警不应解除 gxl //YouWeiGPSInterface.EncodeRelieveAlarm(protocolType, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, 0, 0, ref sendDataLen, sendData); //aResponseList.Add(sendData); //若是劫警,下发LED信息 if (gpsData.BaseData.PlunderState == 0) { //解除报警 3-11 非私家车,且是劫警,才解除 gxl sendDataLen = 0; sendData = new byte[512]; YouWeiGPSInterface.EncodeRelieveAlarm(protocolType, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, 0, 0, ref sendDataLen, sendData); pOutData = new byte[sendDataLen]; Array.Copy(sendData, pOutData, sendDataLen); sendData = null; Logger.Trace("非私家车,自动解除劫警。GPSCODE:" + gpsData.FullGpsCode + " 报警类型:" + gpsData.BaseData.PlunderState); responseList.Add(pOutData); Logger.Trace("GPSYouWei--Gps:" + gpsData.FullGpsCode + " is robbed", null); List<byte[]> PluderLedInstruction = GetLedInstructionWhenPlunder(gpsData.FullGpsCode); IEnumerator<byte[]> en = PluderLedInstruction.GetEnumerator(); while (en.MoveNext()) { byte[] data = en.Current; responseList.Add(data); } //当劫警发生时,终端自动会拍照并上报 } } break; //终端开始上传图片 case YouWeiPublicDefine.ICOMMAND_PICDATAUPLOADSTART: IDeviceUploadPictureStart UploadPictureStart = (IDeviceUploadPictureStart)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceUploadPictureStart)); YouWeiParseGPSDataToEntity.ParseGPSData_UploadPictureStart_ToEntity(UploadPictureStart, ref gpsData, base.CodePrefix); //加入拍照实体 KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.SetGPSCode, null); //每次开始开始上传照片时,先将报警状态清1 KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.PlunderState, 1); if (UploadPictureStart.dwEventNo == 1) //劫警照片 { //标记为劫警拍照 KeepPictureInfo(gpsData.FullGpsCode,TakePictureAction.PlunderState, 0); //正在上传劫警照片 Logger.Trace("GPSYouWei--Gps:" + gpsData.FullGpsCode + " 开始上传劫警照片", null); } else if (UploadPictureStart.dwEventNo == 4) //上车照片 { gpsData.BaseData.IsOnCar = true; KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.CustomerIn, TakePictureType.TakePictureForGetOn); //正在上传上车拍照照片 Logger.Trace("GPSYouWei--Gps:" + gpsData.FullGpsCode + " 开始上传上车照片", null); } else if (UploadPictureStart.dwEventNo == 9)//开门拍照车台自动触发的照片 { KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.RealTimeTakePicture, TakePictureType.TakePictureForOpenDoor); //开门拍照车台自动触发的照片 Logger.Trace("GPSYouWei--Gps:" + gpsData.FullGpsCode + " 开始上传开门照片", null); } else { if (PicTaskPool.ContainsKey(gpsData.FullGpsCode) && PicTaskPool[gpsData.FullGpsCode].Count > 0) { //取出队首的任务 TakePicTask task = PicTaskPool[gpsData.FullGpsCode].Peek(); if (task.TaskType == SimpleCmdType.TimingShoot) { KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.RealTimeTakePicture, TakePictureType.TakePictureForFixedTime); } else if (task.TaskType == SimpleCmdType.TakePictureForDoorShot) { KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.RealTimeTakePicture, TakePictureType.TakePictureForOpenDoor); } else if (task.TaskType == SimpleCmdType.RealTimeShoot || task.TaskType == SimpleCmdType.NormalSeriateShoot) { KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.RealTimeTakePicture, TakePictureType.TakePictureForRealTime); } } Logger.Trace("GPSYouWei--Gps:" + gpsData.FullGpsCode + " 开始上传照片", null); } KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.ReplyCameraID, UploadPictureStart.dwChannelID); KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.PictureCompress, UploadPictureStart.dwPictureCompress); YouWeiParseGPSDataToEntity.ParseGPSData_UploadPictureStart_ToEntity(UploadPictureStart, ref gpsData,CodePrefix); KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.PictureYouWeiGPSData, gpsData); break; case YouWeiPublicDefine.ICOMMAND_PICDATAUPLOAD://图片数据帧 IDeviceUploadPictureData UploadPictureData = (IDeviceUploadPictureData)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceUploadPictureData)); gpsData.FullGpsCode = CodePrefix + UploadPictureData.NotifyHead.dwDeviceNumber.ToString(); gpsData.BaseData.GPSCode = UploadPictureData.NotifyHead.dwDeviceNumber.ToString(); KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.SetPictureData, UploadPictureData.pPicData); Logger.Trace("图片数据接收,GPSCode:" + gpsData.FullGpsCode); //最后一桢数据 if (UploadPictureData.bIsLastFrame) { Logger.Trace("最后一帧图片数据接收,GPSCode:" + gpsData.FullGpsCode); KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.LastFrameNo, UploadPictureData.dwPicFrameNo); KeepPictureInfo(gpsData.FullGpsCode, TakePictureAction.LastFramePictureSeq, UploadPictureData.dwPictureSeq); sendDataLen = 0; sendData = new byte[512]; //下发图片数据确认命令到GPS终端 YouWeiGPSInterface.EncodeUploadPicDataConfirm( (byte)GPSYouWeiProtocolType.GPRSORCDMA, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, 0, (byte)dicTakePictureInfo[gpsData.FullGpsCode].LastFramePictureSeq, (ushort)dicTakePictureInfo[gpsData.FullGpsCode].LastFrameNo, ref sendDataLen, sendData); pOutData = new byte[sendDataLen]; Array.Copy(sendData, pOutData, sendDataLen); responseList.Add(pOutData); sendData = null; TakePictureType picType = dicTakePictureInfo[gpsData.FullGpsCode].PictureType; int PlunderState = dicTakePictureInfo[gpsData.FullGpsCode].PlunderState; //将图片数据写成图片文件存入指定位置 WritePicFile(gpsData.BaseData.GPSCode,gpsData.FullGpsCode, ref pictureData); //不是劫警照片,不是开门拍照硬件自动触发的照片,才触发任务对列中的后续照片 if ((PlunderState != 0 && picType != TakePictureType.TakePicutureForNull && picType != TakePictureType.TakePictureForOpenDoor && picType != TakePictureType.TakePictureForGetOn) || (PicTaskPool.ContainsKey(gpsData.FullGpsCode) && PicTaskPool[gpsData.FullGpsCode].Count > 0 && PicTaskPool[gpsData.FullGpsCode].Peek().TaskType == SimpleCmdType.TakePictureForDoorShot)) { //取出队首的任务 TakePicTask task = PicTaskPool[gpsData.FullGpsCode].Peek(); //将任务的状态改为“上一张图片已完成” task.Status = TakePicTaskStatus.LastPicFinished; //执行该任务 DoShoot(gpsData.FullGpsCode, false); } else { Logger.Trace(string.Format("没有触发下一张照片的原因,PlunderState:{0},picType:{1},gpscode:{2}", PlunderState, picType.ToString(), gpsData.FullGpsCode), null); if (PicTaskPool.ContainsKey(gpsData.FullGpsCode)) { if (PicTaskPool[gpsData.FullGpsCode].Count > 0) { Logger.Trace(string.Format("[{0}]队首任务的TaskType:{1}",gpsData.FullGpsCode, PicTaskPool[gpsData.FullGpsCode].Peek().TaskType.ToString()), null); } else { Logger.Trace(string.Format("[{0}]的任务队列任务数为0", gpsData.FullGpsCode), null); } } else { Logger.Trace(string.Format("[{0}]没有任务队列", gpsData.FullGpsCode), null); } } //zhoub@2010-03-30 //对于连拍的情况,触发下一张图片的拍摄,目前只针对有一个摄相头的情况 //分为正常连拍和劫警连拍两种情况 //------------------------------------------------------------------------------------------------------------------ sendDataLen = 0; sendData = new byte[512]; bool bNeedTakePicture = false; //是否需要劫警连拍 bNeedTakePicture = CheckIsNeedTakePictureRobShootTime(gpsData.FullGpsCode, ref sendDataLen, ref sendData); if (bNeedTakePicture == true) { pOutData = new byte[sendDataLen]; Array.Copy(sendData, pOutData, sendDataLen); responseList.Add(pOutData); sendData = null; } } break; //控制电路应答 case YouWeiPublicDefine.ICOMMAND_DEVICECONTROLCIRCUITRES: IDeviceControlCircuitRes ControlCircuitRes = (IDeviceControlCircuitRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceControlCircuitRes)); OnPostAnswer(ControlCircuitRes.NotifyHead, ControlCmdType.DeviceCircuitresAndOil); break; //设置查询短信中心应答 case YouWeiPublicDefine.ICOMMAND_DEVICESMSCENTERES: IGetSetSMSCenterRes SMSCenterRes = (IGetSetSMSCenterRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IGetSetSMSCenterRes)); break; //设置查询GPRS中心应答 case YouWeiPublicDefine.ICOMMAND_DEVICEGPRSCENTERES: IGetSetGPRSCenterRes GPRSCenterRes = (IGetSetGPRSCenterRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IGetSetGPRSCenterRes)); break; //终端心跳消息 case YouWeiPublicDefine.ICOMMAND_DEVICECHECKLINKER: IDeviceCheckLinker HeartBeat = (IDeviceCheckLinker)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceCheckLinker)); break; //终端故障 case YouWeiPublicDefine.ICOMMAND_DEVICETROUBLEEVENT: IDeviceTroubleEvent TroubleEvent = (IDeviceTroubleEvent)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceTroubleEvent)); break; //终端上报事件 case YouWeiPublicDefine.ICOMMAND_DEVICEADDONSEVENT: IDeviceAddOnsEvent AddOnsEvent = (IDeviceAddOnsEvent)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceAddOnsEvent)); break; //查询配置电话号码应答 case YouWeiPublicDefine.ICOMMAND_DEVICEPHONENUMBER: IDevicePhoneNumberRes PhoneNumberRes = (IDevicePhoneNumberRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDevicePhoneNumberRes)); break; //查询设置监控应答 case YouWeiPublicDefine.ICOMMAND_DEVICEMONITORSTATUSRES: IDeviceMonitorStatusRes MonitorStatusRes = (IDeviceMonitorStatusRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceMonitorStatusRes)); break; //设置看守报警应答 case YouWeiPublicDefine.ICOMMAND_DEVICEWATCHALARMRES: IDeviceWatchAlarmRes WatchAlarmRes = (IDeviceWatchAlarmRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceWatchAlarmRes)); break; //设置监听应答 case YouWeiPublicDefine.ICOMMAND_DEVICELISTENRES: IDeviceSetListenRes SetListenRes = (IDeviceSetListenRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceSetListenRes)); OnPostAnswer(SetListenRes.NotifyHead, ControlCmdType.ListenCall, new SimpleCmdType[] { SimpleCmdType .SetITimerTrack}); break; //复位操作应答 case YouWeiPublicDefine.ICOMMAND_DEVICERESETRES: IDeviceResetRes ResetRes = (IDeviceResetRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceResetRes)); OnPostAnswer(ResetRes.NotifyHead, ControlCmdType.SimpleInstruction, new SimpleCmdType[] { SimpleCmdType.ResetGPS}); break; //获取终端版本应答 case YouWeiPublicDefine.ICOMMAND_DEVICEVERSIONRES: IDeviceVersionRes VersionRes = (IDeviceVersionRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceVersionRes)); break; //中心向终端发送文本消息应答(调度) case YouWeiPublicDefine.ICOMMAND_DELIVERTEXTTODEVICE: IDeivceResDeliverTextMsg ResDeliverTextMsg = (IDeivceResDeliverTextMsg)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeivceResDeliverTextMsg)); OnPostAnswer(ResDeliverTextMsg.NotifyHead,ControlCmdType.DispatchControl); break; //终端向中心发送文本消息 case YouWeiPublicDefine.ICOMMAND_DEVICESENDTEXTMSG: IDeviceSendTextMsg SendTextMsg = (IDeviceSendTextMsg)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceSendTextMsg)); YouWeiParseGPSDataToEntity.parseGPSData_DeviceSendTextMsg_ToEntity(SendTextMsg, ref gpsData, base.CodePrefix); TransferGPSMsgAndSaveMsgToDB(SendTextMsg.NotifyHead.dwDeviceNumber.ToString(), SendTextMsg.wTextCodingMode, SendTextMsg.wTextLen, SendTextMsg.TextContent); break; //获取终端功能应答 case YouWeiPublicDefine.ICOMMAND_DEVICEFUNGETRES: IDeviceFunctionConfigRes FunctionConfigRes = (IDeviceFunctionConfigRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceFunctionConfigRes)); break; //查询/设置油量异常(漏油、偷油) 报警检测参数 case YouWeiPublicDefine.ICOMMAND_DEVICEOILEXCEPTIONPARAMRES: IDeviceOilConsumeAlarmParamRes OilConsumeAlarmParamRes = (IDeviceOilConsumeAlarmParamRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceOilConsumeAlarmParamRes)); YouWeiParseGPSDataToEntity.ParseGPSData_OilConsumeAlarmParamRes_ToEntity(OilConsumeAlarmParamRes, ref gpsData, base.CodePrefix); break; //查询/设置油耗检测参数 case YouWeiPublicDefine.ICOMMAND_DEVICEOILSAMPLINGPARAMRES: IDeviceOilSamplingParamRes OilSamplingParamRes = (IDeviceOilSamplingParamRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceOilSamplingParamRes)); break; //营运数据上传 case YouWeiPublicDefine.ICOMMAND_DEVICEUPLOADBUSINESSDATA: IDeviceUploadBusinessData UploadBusinessData = (IDeviceUploadBusinessData)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceUploadBusinessData)); break; //设置参数应答 case YouWeiPublicDefine.ICOMMAND_CONFDEVICEPARAMRES: IConfDeviceParamRes ConfDeviceParamRes = (IConfDeviceParamRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IConfDeviceParamRes)); break; //设置电子围栏应答 case YouWeiPublicDefine.ICOMMAND_DEVICELINEAREASETRES: IDeviceLineAreaRes LineAreaRes = (IDeviceLineAreaRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceLineAreaRes)); break; //设置轨迹参数应答 case YouWeiPublicDefine.ICOMMAND_CONFPOSSTOREPARAMRES: IConfDevicePosStoreParamRes PosStoreParamRes = (IConfDevicePosStoreParamRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IConfDevicePosStoreParamRes)); break; case YouWeiPublicDefine.ICOMMAND_GETHISPOSTIONRES://获取轨迹应答 case YouWeiPublicDefine.ICOMMAND_GETHISPICTIONRES://获取历史图片清单应答 IGetDeviceHisPosRes HisPosRes = (IGetDeviceHisPosRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IGetDeviceHisPosRes)); break; //设置图片参数应答 case YouWeiPublicDefine.ICOMMAND_CONFPICSTOREPARAMRES: IConfDevicePicStoreParamRes PicStoreParamRes = (IConfDevicePicStoreParamRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IConfDevicePicStoreParamRes)); break; //历史图片清单上传 case YouWeiPublicDefine.ICOMMAND_DEVICEUPLOADHISPICLIST: IDeviceUploadHisPicList UploadHisPicList = (IDeviceUploadHisPicList)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceUploadHisPicList)); break; //拍照应答 case YouWeiPublicDefine.ICOMMAND_TAKEPICTURERES: IDeviceTakePictureRes TakePictureRes = (IDeviceTakePictureRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceTakePictureRes)); YouWeiParseGPSDataToEntity.parseGPSData_TakePictureRes_ToEntity(TakePictureRes, ref gpsData, base.CodePrefix); OnPostAnswer(TakePictureRes.NotifyHead, ControlCmdType.SendTakePicture); break; //终端核实图片 case YouWeiPublicDefine.ICOMMAND_PICDATACONFIRM: IDevicePictureDataConfirm PictureDataConfirm = (IDevicePictureDataConfirm)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDevicePictureDataConfirm)); break; //终端应答中心下发透明数据 case YouWeiPublicDefine.ICOMMAND_DEVLIVERTRANSDATARES: IDeliverTransparentDataRes TransparentDataRes = (IDeliverTransparentDataRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeliverTransparentDataRes)); OnPostAnswer(TransparentDataRes.NotifyHead, ControlCmdType.SendAdvertisement); break; //终端上传透明数据 case YouWeiPublicDefine.ICOMMAND_SUBMITTRANSDATA: IDeviceSubmitTransparentDataReq SubmitTransparentDataReq = (IDeviceSubmitTransparentDataReq)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceSubmitTransparentDataReq)); break; //解除报警 case YouWeiPublicDefine.ICOMMAND_DEVICERELIEVEALARMRES: IDeviceRelieveAlarmRes RelieveAlarmRes = (IDeviceRelieveAlarmRes)Transfer.BytesToStuct(receiveDataCondition.pOutData, typeof(IDeviceRelieveAlarmRes)); OnPostAnswer(RelieveAlarmRes.NotifyHead,ControlCmdType.DischargeAlarm); break; } Result = true; } catch (Exception e) { Result = false; Logger.Error("GPSYouWei.YouWeiDataParser.Decode:" + e.ToString()); } return Result; }
/// <summary> /// 判断报警数据是否超时(10分钟) 是:true=补传数据 /// </summary> /// <param name="obj"></param> /// <param name="aPreviousValidGPSData"></param> /// <returns></returns> private bool CheckTimeOutAlarm(ref object obj, YouWeiGPSData aPreviousValidGPSData) { bool flag = false; YouWeiGPSData aGPSInfo = obj as YouWeiGPSData; if (DateTime.Compare(aGPSInfo.BaseData.ReportTime.AddMinutes(10), aPreviousValidGPSData.BaseData.ReportTime) <= 0) { return true; } else { aGPSInfo.BaseData.IsFetchData = false; } return flag; }
/// <summary> /// 检查异常漂移 /// </summary> ///<param name="gpsData">GPS信息</param> /// <param name="aPreviousValidGPSData">有效的上一点GPS数据</param> /// <param name="MaxSpeedMeterPerSecond">最大速度:米/秒</param> private bool ComputeMileAgeAndVerifyData(ref YouWeiGPSData gpsData, GPSDataEntity aPreviousValidGPSData, double MaxSpeedMeterPerSecond) { bool flag = false; if (!gpsData.BaseData.IsLocatedData) { Logger.Fatal("未定位,GpsCode=" + gpsData.FullGpsCode + " reporttime:" + gpsData.BaseData.ReportTime.ToString(strTimeFormat)); return true; } //是否是第一个点 bool blnIsFirstGPSData = false; if (aPreviousValidGPSData == null) { blnIsFirstGPSData = true; ////2010-7-28 判断第一点是否是异常数据,是,存放到无效数据表。 ////判断条件:reporttime 时间小于当前系统时间1天或者大于当前系统时间1小时 //if(gpsData.BaseData.ReportTime >= DateTime.Now.AddHours(1) || gpsData.BaseData.ReportTime <= DateTime.Now.AddDays(-1)) // gpsData.BaseData.IsOverflowGPSData=true; } TimeSpan dtSpan; double dclMileage = 0; bool blnIsGPSOverflow = false; //是否要记录里程 bool blnShoudBeStillness = false; //是否前条时间超过后一条时间 bool blnIsArrivalDelayed = false; if (!blnIsFirstGPSData) { if (DateTime.Compare(gpsData.BaseData.ReportTime, aPreviousValidGPSData.ReportTime) <= 0 || gpsData.BaseData.ReportTime >= DateTime.Now.AddHours(1)) { //当前时间小于上一点时间,为补传数据。2010-01-13 gxl 若当前数据时间大于服务器时间1小时,认为是异常数据,也标记为补传数据 gpsData.BaseData.IsFetchData = true; blnIsArrivalDelayed = true; flag = true; } double CurrentLatitude = Convert.ToDouble(gpsData.BaseData.Latitude); double CurrentLongitude = Convert.ToDouble(gpsData.BaseData.Longitude); double LastLatitude = Convert.ToDouble(aPreviousValidGPSData.Latitude); double LastLongitude = Convert.ToDouble(aPreviousValidGPSData.Longitude); if ((CurrentLatitude != LastLatitude) || (CurrentLongitude != LastLongitude)) { dclMileage = Transfer.GetDistance(LastLatitude, LastLongitude, CurrentLatitude, CurrentLongitude); } //计算当前点与其上一点之间的时间差 dtSpan = gpsData.BaseData.ReportTime - aPreviousValidGPSData.ReportTime; //两点之间最大比较里程 double dclMaxMileage = Math.Abs(Convert.ToDouble(MaxSpeedMeterPerSecond * dtSpan.TotalSeconds)); //最大比较速度:换算为公里/每小时 double maxSpeed = MaxSpeedMeterPerSecond * 3.6; //速度过大或里程过大,均认为是漂移数据 if (dclMileage > dclMaxMileage || gpsData.BaseData.Speed > (decimal)maxSpeed) { //异常:GPS漂移数据 blnIsGPSOverflow = true; gpsData.BaseData.IsOverflowGPSData = true; } //是否要记录里程 if ((gpsData.BaseData.Speed == 0) && (aPreviousValidGPSData.Speed == 0) && (dtSpan.TotalMinutes < 30)) { blnShoudBeStillness = true; } gpsData.BaseData.StarkMileage = aPreviousValidGPSData.StarkMileage; gpsData.BaseData.ControlTime = aPreviousValidGPSData.ControlTime; } else//上一点数据为NULL,表明是第一点数据 { if (gpsData.BaseData.ReportTime >= DateTime.Now.AddHours(1)) { gpsData.BaseData.IsOverflowGPSData = true; flag = true; Logger.Fatal("第一点位置数据时间大于服务器时间1小时,GpsCode=" + gpsData.BaseData.GPSCode + " reporttime:" + gpsData.BaseData.ReportTime.ToString(strTimeFormat)); } else if (gpsData.BaseData.ReportTime <= DateTime.Now.AddDays(-1)) { gpsData.BaseData.IsOverflowGPSData = true; flag = true; Logger.Fatal("第一点位置数据时间小于服务器时间1天,GpsCode=" + gpsData.BaseData.GPSCode + " reporttime:" + gpsData.BaseData.ReportTime.ToString(strTimeFormat)); } else if (gpsData.BaseData.Latitude < 1 || gpsData.BaseData.Longitude < 1 || gpsData.BaseData.Speed > 500) { gpsData.BaseData.IsOverflowGPSData = true; flag = true; Logger.Fatal("第一点位置数据经纬度或速度异常。GpsCode=" + gpsData.BaseData.GPSCode + " reporttime:" + gpsData.BaseData.ReportTime.ToString(strTimeFormat)); } } if (((!blnIsGPSOverflow) && (!blnIsFirstGPSData) && (!blnShoudBeStillness)) && (!blnIsArrivalDelayed)) { gpsData.BaseData.Mileage = (decimal)dclMileage; gpsData.BaseData.StarkMileage = gpsData.BaseData.StarkMileage + gpsData.BaseData.Mileage; } return flag; }
/// <summary> /// 写照片文件到指定目录 /// </summary> /// <param name="gpsCode"></param> /// <param name="httpFileName"></param> /// <param name="picture_YouWeiData"></param> private void SavePictureInfoToDB(string gpsCode, string httpFileName, ref YouWeiGPSData picture_YouWeiData) { //去掉前缀的GPSCode picture_YouWeiData.BaseData.GPSCode = gpsCode.Remove(0, base.CodePrefix.Length); picture_YouWeiData.BaseData.PhotoPath = httpFileName; picture_YouWeiData.BaseData.IsPhotoData = true; picture_YouWeiData.FullGpsCode = gpsCode; bool isExist; lock (dicTakePictureInfo) { isExist = dicTakePictureInfo.ContainsKey(gpsCode); } if ((dicTakePictureInfo != null) && (isExist)) { if ((dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.Longitude <= (decimal)0.001) || dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.Latitude <= (decimal)0.001) { } else { picture_YouWeiData.BaseData.Longitude = dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.Longitude; picture_YouWeiData.BaseData.Latitude = dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.Latitude; picture_YouWeiData.BaseData.ReportTime = dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.ReportTime; } picture_YouWeiData.BaseData.ReceiveTime = DateTime.Now; picture_YouWeiData.BaseData.DoorStatus = dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.DoorStatus; picture_YouWeiData.BaseData.PlunderState = dicTakePictureInfo[gpsCode].PlunderState; //入库前指定拍照类型 switch (dicTakePictureInfo[gpsCode].PictureType) { case TakePictureType.TakePictureForGetOn: case TakePictureType.TakePictureForOpenDoor: picture_YouWeiData.BaseData.RealTimePhotoType = 3; break; case TakePictureType.TakePictureForFixedTime: picture_YouWeiData.BaseData.RealTimePhotoType = 1; break; default: picture_YouWeiData.BaseData.RealTimePhotoType = 2; break; } //不知道是什么类型都改为实时抓拍 if (picture_YouWeiData.BaseData.RealTimePhotoType == 0) { picture_YouWeiData.BaseData.RealTimePhotoType = 2; } if (dicTakePictureInfo[gpsCode].ReplyCameraID > (int)GPSYouWei_CameraID.Camra0) { picture_YouWeiData.BaseData.CameraId = (int)dicTakePictureInfo[gpsCode].ReplyCameraID; } else { picture_YouWeiData.BaseData.CameraId = (int)dicTakePictureInfo[gpsCode].CameraID; } //完成一次拍照,将拍照类型置为空 dicTakePictureInfo[gpsCode].PictureType = TakePictureType.TakePicutureForNull; dicTakePictureInfo[gpsCode].PlunderState = 1; dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.DoorStatus = 0; Logger.Trace(string.Format("[{0}]的接受实体清零", gpsCode), null); } else { picture_YouWeiData.BaseData.ReportTime = DateTime.Now; picture_YouWeiData.BaseData.ReceiveTime = DateTime.Now; picture_YouWeiData.BaseData.DoorStatus = 0; picture_YouWeiData.BaseData.PlunderState = 1; picture_YouWeiData.BaseData.RealTimePhotoType = 0; picture_YouWeiData.BaseData.CameraId = 1; } //向应用层发送图片路径 TakePictureAckMsg(picture_YouWeiData, false, true); }
/// <summary> /// 将拍照数据写成图片文件 /// </summary> /// /// <param name="gpsCode">无前缀gpscode</param> /// <param name="prefixgpsCode">有前缀gpscode</param> /// <param name="picture_YouWeiData">拍照数据</param> private void WritePicFile(string gpsCode,string prefixgpsCode, ref YouWeiGPSData picture_YouWeiData) { bool gpsIsContained = false; lock (dicTakePictureInfo) { gpsIsContained = dicTakePictureInfo.ContainsKey(prefixgpsCode); } if (!gpsIsContained) { return; } //图片存放目录名 string folderName = DateTime.Now.ToString("yyyMMdd"); //图片存放文件名 string picFileName = DateTime.Now.ToString("yyyyMMddHHmmss"); //web端查询图片目录 string httpFileName = folderName; int nIndex = PhotoPath.IndexOf("|"); string folder = PhotoPath.Substring(0, nIndex) + "\\" + gpsCode + "\\" + folderName; FileStream stream = null; if (Directory.Exists(folder) == false) { Directory.CreateDirectory(folder); } try { string picFileExtension = ".jpg"; string DistFileName = ""; if (dicTakePictureInfo[prefixgpsCode].ReplyCameraID > (int)GPSYouWei_CameraID.Camra0) { DistFileName = folder + "\\" + picFileName + "_" + dicTakePictureInfo[prefixgpsCode].ReplyCameraID.ToString() + picFileExtension; stream = new FileStream(DistFileName, FileMode.Append); httpFileName += "/" + picFileName + "_" + dicTakePictureInfo[prefixgpsCode].ReplyCameraID.ToString() + picFileExtension; } else { DistFileName = folder + "\\" + picFileName + "_" + dicTakePictureInfo[prefixgpsCode].CameraID.ToString() + picFileExtension; stream = new FileStream(DistFileName, FileMode.Append); httpFileName += "/" + picFileName + "_" + dicTakePictureInfo[prefixgpsCode].CameraID.ToString() + picFileExtension; } List<byte[]> t; lock (dicTakePictureInfo) { t = dicTakePictureInfo[prefixgpsCode].PictureData; } IEnumerator en = t.GetEnumerator(); while (en.MoveNext()) { byte[] a = (byte[])en.Current; stream.Write(a, 0, a.Length); } stream.Close(); dicTakePictureInfo[prefixgpsCode].PictureData = null; try { Bitmap bmp = new Bitmap(DistFileName); } catch (Exception ex) { //完成一次拍照,将拍照类型置为空 dicTakePictureInfo[gpsCode].PictureType = TakePictureType.TakePicutureForNull; dicTakePictureInfo[gpsCode].PlunderState = 1; dicTakePictureInfo[gpsCode].PictureYouWeiGPSData.BaseData.DoorStatus = 0; Logger.Trace(string.Format("图片无法显示,不保存到数据库,[{0}]的接受实体清零", gpsCode)); return; } //将图片路径存入数据库 SavePictureInfoToDB(prefixgpsCode, httpFileName, ref picture_YouWeiData); Logger.Trace("GPSYouWei--Gps:" + gpsCode + " Saved picture", null); } catch (Exception ex) { Logger.Error("GPSYouWei.YouWeiDataParser.writePicFile:" + ex.ToString(), null); } }
/// <summary> /// 解析GPS上传的数据----定位信息 /// </summary> /// <param name="position"></param> /// <param name="data"></param> public static void ParseGPSData_Position_ToEntity(IPositionStatus position, ref YouWeiGPSData data) { try { string sDate = string.Empty; //默认为当前时间 DateTime aCurrentDateTime = DateTime.Now; byte[] byttime = position.szDatetime; try { string strtime = Encoding.ASCII.GetString(byttime); string stryear = strtime.Substring(0, 4); string strmonth = strtime.Substring(4, 2); string strday = strtime.Substring(6, 2); string strhour = strtime.Substring(8, 2); string strminute = strtime.Substring(10, 2); string strsecond = strtime.Substring(12, 2); //aCurrentDateTime = DateTime.Parse(strtime); sDate = stryear + "-" + strmonth + "-" + strday + " " + strhour + ":" + strminute + ":" + strsecond; try { aCurrentDateTime = Convert.ToDateTime(sDate); //GPS时间比正式时间晚8小时 aCurrentDateTime = aCurrentDateTime.AddHours(8); } catch { aCurrentDateTime = DateTime.Now; } } catch (Exception ex) { Logger.Error(ex, null); } data.BaseData.Latitude = (decimal)position.dLatitude; data.BaseData.Longitude = (decimal)position.dLongitude; //if (position.dwFlags == 1) //{ // data.BaseData.IsLocatedData = true; //} byte[] GpsFlag= BitConverter.GetBytes(position.dwGPSFlags); int bitStatus = Transfer.GetByteIndexValue(GpsFlag[0], 7); data.BaseData.IsLocatedData = bitStatus == 0 ? false : true; data.BaseData.Speed = (decimal)position.fSpeed; data.BaseData.Direction = (decimal)position.fDirect; data.BaseData.ReportTime = aCurrentDateTime; data.BaseData.ReceiveTime = DateTime.Now; ParseGPSData_StatusEx_ToEntity(position.byStatus, ref data); //added by lixun 2010/1/10 目前技术支持对808A油耗的接线不清楚,需要和厂家继续沟通,放入下一个版本 //GetOilBearling(position, ref data); } catch (Exception ex) { Logger.Error(ex, null); } }
/// <summary> /// 解析GPS上传的数据----定位状态信息 /// </summary> /// <param name="positionStatus"></param> /// <param name="data"></param> public static void ParseGPSData_PostionStatus_ToEntity(IPostionStatus positionStatus, ref YouWeiGPSData data) { data.BaseData.Latitude = (decimal)positionStatus.dLatitude; data.BaseData.Longitude = (decimal)positionStatus.dLongitude; //if (positionStatus.dLatitude <= 0 && positionStatus.dLongitude <= 0) //{ // data.IsGPSLocaated = false; //} if (positionStatus.dwFlags == 0) { data.BaseData.IsLocatedData = false; } data.BaseData.Speed = (decimal)positionStatus.fSpeed; data.BaseData.Direction = (decimal)positionStatus.fDirect; data.BaseData.GPSDeviceMileage = (decimal)positionStatus.dwOdometer; //data.ReportTime = aCurrentDateTime; //data.ReceiveTime = aCurrentDateTime; //data.Odometer = (int)positionStatus.dwOdometer; }
/// <summary> /// 构造函数 /// </summary> public YouWeiTakePictureStruct() { _gpsCode = ""; _takePictureStartDateTime = DateTime.Now; _takePictureEndDateTime = DateTime.Now; _isCompleteTakePicture = false; _cameraID = 1; _WaittingCameraIDList = new List<uint>(); _replyCameraID = 1; _pictureData = null; _lastFramePictureSeq = 0; _lastFrameNo = 0; _pictureCompress = 0; _pictureYouWeiGPSData = null; _plunderState = 1; }
/// <summary> /// 解析GPS上传的数据----车辆报警事件 /// </summary> /// <param name="alarmEvent"></param> /// <param name="data"></param> public static void ParseGPSData_AlarmEvent_ToEntity(IDeviceAlarmEvent alarmEvent, ref YouWeiGPSData data,string codePrefix) { ParseGPSData_NotifyHead_ToEntity(alarmEvent.NotifyHead, ref data,codePrefix); ParseGPSData_Position_ToEntity(alarmEvent.position, ref data); ParseGPSData_StatusEx_ToEntity(alarmEvent.statusEx, ref data); switch (alarmEvent.wAlarmEvent) { case YouWeiPublicDefine.ALARMEVENT_URGENCYCLICK://急按钮报警 data.BaseData.PlunderState = 0; //data.PlunderState = (int)EnumAlarmType.ALARMEVENT_URGENCYCLICK; break; case YouWeiPublicDefine.ALARMEVENT_LINEBREAKILLEGAL://非法断线或者故障 data.BaseData.AntennaState = 3; data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_LINEBERARKILLEGAL; break; case YouWeiPublicDefine.ALARMEVENT_GPSSHORT://GPS短路报警 data.BaseData.AntennaState = 1; data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_GPSSHORT; break; case YouWeiPublicDefine.ALARMEVENT_GPSOPEN://GPS开路报警 data.BaseData.AntennaState = 2; data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_GPSOPEN; break; case YouWeiPublicDefine.ALARMEVENT_LOWVOLTAGE://低电报警 data.BaseData.PowerState = 2; data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_LOWVOLTAGE; break; case YouWeiPublicDefine.ALARMEVENT_OUTAGECHECK://掉电检测 data.BaseData.PowerState = 1; data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_OUTAGECHECK; break; case YouWeiPublicDefine.ALARMEVENT_STARTILLEGAL: data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_STARTILLEGAL;//非法启动 break; case YouWeiPublicDefine.ALARMEVENT_OPENDOOR: data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_OPENDOOR;//开门报警 break; case YouWeiPublicDefine.ALARMEVENT_CARSTOLEN: data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_CARSTOLEN;//被盗报警 break; case YouWeiPublicDefine.ALARMEVENT_MOVEDILLEGAL://非法移动 data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_MOVEDILLEGAL;//非法移动 break; case YouWeiPublicDefine.ALARMEVENT_LOCKILLEGAL: data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_LOCKILLEGAL;//劫持报警 break; case YouWeiPublicDefine.ALARMEVENT_OVERSPEED: data.BaseData.PlunderState = (int)EnumAlarmType.ALARMEVENT_OVERSPEED;//超速报警 break; default: break; } data.AlarmCount = (int)alarmEvent.dwEventCount; data.AlarmEvent = (int)alarmEvent.wAlarmEvent; data.TimeFrom = (int)alarmEvent.wTimeFrom; if ((alarmEvent.wAlarmEvent == YouWeiPublicDefine.ALARMEVENT_INSCOPE) || (alarmEvent.wAlarmEvent == YouWeiPublicDefine.ALARMEVENT_SLOPOVER)) { //未完 } }
/// <summary> /// 将位置数据转换为YouWeiGPSData实体 /// </summary> /// <param name="position"></param> /// <param name="data"></param> public static void ParseGPSData_Position_ToEntity(IPostion position, ref YouWeiGPSData data) { try { //zhoub@2010-03-25 //此处传递的position数据有时有错误,是设备问题 string sDate = string.Empty; //默认为当前时间 DateTime aCurrentDateTime = DateTime.Now; try { sDate = position.wYear + "-" + position.wMonth + "-" + position.wDay + " " + position.wHour + ":" + position.wMinute + ":" + position.wSecond; if (position.wYear == 0) { aCurrentDateTime = DateTime.Now; } else { try { aCurrentDateTime = Convert.ToDateTime(sDate); //GPS时间比正式时间晚8小时 aCurrentDateTime = aCurrentDateTime.AddHours(8); } catch { aCurrentDateTime = DateTime.Now; } } } catch (Exception ex) { Logger.Error(ex, null); } data.BaseData.Latitude = (decimal)position.fLatitude; data.BaseData.Longitude = (decimal)position.fLongitude; if (position.dwFlags == 1) { data.BaseData.IsLocatedData = true; } data.BaseData.Speed = (decimal)position.fSpeed; data.BaseData.Direction = (decimal)position.fDirect; data.BaseData.ReportTime = aCurrentDateTime; data.BaseData.ReceiveTime = DateTime.Now; } catch (Exception ex) { Logger.Error(ex, null); } }
/// <summary> /// 解析GPS上传的数据----查询/设置油量异常(漏油、偷油) 报警检测参数 /// </summary> /// <param name="OilConsumeAlarmParamRes"></param> /// <param name="data"></param> public static void ParseGPSData_OilConsumeAlarmParamRes_ToEntity(IDeviceOilConsumeAlarmParamRes OilConsumeAlarmParamRes, ref YouWeiGPSData data,string codePrefix) { ParseGPSData_NotifyHead_ToEntity(OilConsumeAlarmParamRes.NotifyHead, ref data,codePrefix); }
/// <summary> /// 解析GPS上传的数据----车辆状态信息 /// </summary> /// <param name="status"></param> /// <param name="data"></param> public static void ParseGPSData_StatusEx_ToEntity(IStatusEx status, ref YouWeiGPSData data) { int bitStatus = (int)status.wCtrlStatus & (byte)GPSYouWei_Flag.Flag2; if (bitStatus > 0)//断油 { data.BaseData.OilState = 0; } else { data.BaseData.OilState = 1; } int accFlag = (int)status.wInputLevel & (byte)GPSYouWei_Flag.Flag4; if (accFlag > 0) { data.BaseData.ACCState = 1;//点火 } GetOilBearling(status, data.BaseData.ACCState, ref data); //int powerState = (int)status.wInputLevel & (byte)GPSYouWei_Flag.Flag3; //if (powerState > 0) //{ // data.PowerState = 1;//掉电 //} //else //{ // data.PowerState = 0; //} int antennaeState = (int)status.wInputLevel & 512; if (antennaeState > 0) { data.BaseData.AntennaState = 1; } else { data.BaseData.AntennaState = 0; } int powerState = (int)status.wAlarmStatus & (byte)GPSYouWei_Flag.Flag6; if (powerState > 0) { data.BaseData.PowerState = 1;//掉电 } else { data.BaseData.PowerState = 0; } //int doorFlag = (int)status.wStateFlags & (byte)GPSYouWei_Flag.Flag1; int doorFlag = (int)status.wCtrlStatus & (byte)GPSYouWei_Flag.Flag3; if (doorFlag <= 0) { //updated for lixun on 2012/12/16 调整过后默认为0--关门,当低电接负线后更改为1--开门 //data.BaseData.DoorStatus = 1;//门开 data.BaseData.DoorStatus = 0; data.BaseData.IsOnCar = false; } else { data.BaseData.DoorStatus = 1; data.BaseData.IsOnCar = true; } //data.OilOdometer = (int)status.dwOilOdometer; //data.Odometer = (int)status.dwOdometer; }
/// <summary> /// 解析GPS上传的数据----查询/设置油耗检测参数 /// </summary> /// <param name="OilSamplingParamRes"></param> /// <param name="data"></param> public static void ParseGPSData_OilSamplingParamRes_ToEntity(IDeviceOilSamplingParamRes OilSamplingParamRes, ref YouWeiGPSData data) { }
public static void ParseGPSData_StatusEx_ToEntity(byte[] status, ref YouWeiGPSData data) { int bitStatus = status[5] & (byte)GPSYouWei_Flag.Flag2; if (bitStatus > 0)//断油 { data.BaseData.OilState = 0; } else { data.BaseData.OilState = 1; } int accFlag = status[7] & (byte)GPSYouWei_Flag.Flag4; if (accFlag > 0)//点火 { data.BaseData.ACCState = 1; } else { data.BaseData.ACCState = 0; } int antennaeState = status[2] & (byte)GPSYouWei_Flag.Flag2; if (antennaeState > 0)//开路 { data.BaseData.AntennaState = 1; } else { data.BaseData.AntennaState = 0; } int powerState = status[0] & (byte)GPSYouWei_Flag.Flag6; if (powerState > 0) { data.BaseData.PowerState = 1;//掉电 } else { data.BaseData.PowerState = 0; } //空重 updated by lixun on 2010/11/23 #2269 有为网关4001,4002状态兼容, 新协议状态位分成空重车(上车)位和开门位 //空重车负 int negativeFlag = status[6] & (byte)GPSYouWei_Flag.Flag1; //空重车正 int positiveFlag = status[6] & (byte)GPSYouWei_Flag.Flag4; //updated by lixun on 2010/12/8 for solve Ticket #2702 if (positiveFlag > 0 || negativeFlag>0) { data.BaseData.IsOnCar = true; //updated for lixun on 2012/12/16 调整过后默认为0--关门,当低电接负线后更改为1--开门 //data.BaseData.DoorStatus = 0; data.BaseData.DoorStatus = 1; } else { data.BaseData.IsOnCar = false; data.BaseData.DoorStatus = 0; } //开门 //int doorFlag = status[6] & (byte)GPSYouWei_Flag.Flag8; //if (doorFlag > 0) // data.BaseData.DoorStatus = 0; //else // data.BaseData.DoorStatus = 1; }
/// <summary> /// 解析GPS上传的数据----终端开始上传图片 /// </summary> /// <param name="DeviceUploadPictureStart"></param> /// <param name="data"></param> public static void ParseGPSData_UploadPictureStart_ToEntity(IDeviceUploadPictureStart DeviceUploadPictureStart, ref YouWeiGPSData data,string codePrefix) { ParseGPSData_NotifyHead_ToEntity(DeviceUploadPictureStart.NotifyHead, ref data,codePrefix); ParseGPSData_Position_ToEntity(DeviceUploadPictureStart.position, ref data); //ParseGPSData_StatusEx_ToEntity(DeviceUploadPictureStart.statusEx, ref data); }
/// <summary> /// 分析GPS数据包 /// </summary> /// <param name="buffer">收到的原始数据</param> /// <param name="responseList">应答数据</param> /// <param name="fullGpsCode">解析后加前缀的GPSCode</param> /// <param name="sessionID">会话ID:IP地址+端口号</param> /// <returns></returns> public List<GPSDataEntity> Parse(byte[] buffer, out List<byte[]> responseList, out string fullGpsCode,string sessionID) { YouWeiGPSData result = null; responseList = null; List<GPSDataEntity> dataList = new List<GPSDataEntity>(); //DLL协议实体 YouWeiGPSReceiveDataCondition receiveDataCondition = new YouWeiGPSReceiveDataCondition(); YouWeiGPSData gpsData = new YouWeiGPSData(); YouWeiGPSData[] YouWeiDataEx = null; YouWeiGPSData pictureData = new YouWeiGPSData(); try { //LED报警显示也从Decode下发 bool returnValue = Decode( (byte)GPSYouWeiProtocolType.GPRSORCDMA, buffer, ref receiveDataCondition, ref gpsData, ref YouWeiDataEx, ref pictureData, out responseList); if (returnValue == false) { fullGpsCode = string.Empty; return null; } //FullGpsCode未赋值,重新赋值 if (string.IsNullOrEmpty(gpsData.FullGpsCode)) { fullGpsCode = CodePrefix + gpsData.BaseData.GPSCode; gpsData.FullGpsCode = fullGpsCode; } else { fullGpsCode = gpsData.FullGpsCode; } //将连接加入连接集合,如果是连接后的第一点数据,则同时会更新路由关系表 //注意UpdateFirstDataRela的先后关系 if (!String.IsNullOrEmpty(gpsData.FullGpsCode)) { OnAddConnectionEvent(gpsData.FullGpsCode, sessionID); } //更新上一次数据 if (TCPConnList.Instance().IsFirstDataOfConn(sessionID)) { if (string.IsNullOrEmpty(gpsData.FullGpsCode)) { Logger.Error("gpsData.FullGpsCode为空:" + gpsData.BaseData.GPSCode, null); } //更新上一点数据 //CacheUtility.UpdateLastGPSData(gpsData.FullGpsCode); //更改记录状态,标明以后的数据已不是第一点数据 TCPConnList.Instance().UpdateFirstDataRela(sessionID, 0); } //含有拍照数据 if (pictureData.BaseData.GPSCode.Length > 4) { result = pictureData; dataList.Add(pictureData.BaseData); } result = gpsData; //设备注册 if (receiveDataCondition.commandID == YouWeiPublicDefine.ICOMMAND_DEVICEREGISTERED) { lock (dicSendTrackEx) { if (dicSendTrackEx.ContainsKey(gpsData.FullGpsCode) == false) { //修改下发指令长度方法 2010-3-11 gxl uint instructionLen = 0; byte[] instruction = new byte[512]; byte[] pOutData = null; //ACC=1时的上报时间间隔 int TimeAccOn; //ACC=0时的上报时间间隔 int TimeAccOff; //GPSTraceIntervalGetTraceInterval(string gpsCode); if (dicGPSTraceInterval.ContainsKey(gpsData.FullGpsCode)) { GPSTraceInterval _GPSTraceInterval = dicGPSTraceInterval[gpsData.FullGpsCode]; TimeAccOn = _GPSTraceInterval.TimeAccOn; TimeAccOff = _GPSTraceInterval.TimeAccOff; } else { TimeAccOn = 15; TimeAccOff = 60; } //启动定时报警 YouWeiGPSInterface.EncodeStartTimerTrackEx( (byte)GPSYouWeiProtocolType.GPRSORCDMA, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, (ushort)TimeAccOn, (ushort)nTimeACCOffContinue, (ushort)TimeAccOff, ref instructionLen, instruction); pOutData = new byte[instructionLen]; Array.Copy(instruction, pOutData, instructionLen); responseList.Add(pOutData); if (!dicSendTrackEx.ContainsKey(gpsData.FullGpsCode)) { dicSendTrackEx.Add(gpsData.FullGpsCode, ""); } instruction = null; //非私家车,关闭解除报警 //if (this.mIsPrivateCar.ToLower() == "false") //{ // byte[] byt = new byte[4] { 255, 255, 255, 255 }; // instructionLen = 0; // instruction = new byte[512]; // pOutData = null; // YouWeiGPSInterface.EncodeConfDeviceAlarmFun( // (byte)GPSYouWei_ProtocolType.GPSYouWei_ProtocolType_GPRSORCDMA, // YouWeiPublicDefine.PROTOCOLVER, // YouWeiPublicDefine.SEQUENCEID, // byt, // ref instructionLen, // instruction); // pOutData = new byte[instructionLen]; // Array.Copy(instruction, pOutData, instructionLen); // instruction = null; // aResponseList.Add(pOutData); //} } } } //当前状态 if (gpsData.BaseData.GPSCode.Length > 4) { //主动上传数据、设备定位信息 //获得当前位置(点名)\ //获得当前状态 GPSDataEntity aLastData = null; bool AddedDataFlag = false; switch (receiveDataCondition.commandID) { //added by lixun on 2011/11/22 for solve ticket #2269 case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION2: case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION: case YouWeiPublicDefine.ICOMMAND_DEVICECURRENTPOSRES: case YouWeiPublicDefine.ICOMMAND_DEVICECURRSTATUSRES: dataList.Add(result.BaseData); break; case YouWeiPublicDefine.ICOMMAND_DEVICEALARMEVENT: if (gpsData.BaseData.PlunderState == 0 || gpsData.BaseData.PlunderState > 10) { dataList.Add(result.BaseData); } break; } } if (YouWeiDataEx != null && YouWeiDataEx.Length > 1) { for (int i = 1; i < YouWeiDataEx.Length; i++) { if (YouWeiDataEx[i] == null) continue; YouWeiDataEx[i].FullGpsCode = base.CodePrefix + YouWeiDataEx[i].BaseData.GPSCode; result = YouWeiDataEx[i]; if (YouWeiDataEx[i] == null) { continue; } if (YouWeiDataEx[i].BaseData.GPSCode.Length > 4) { switch (receiveDataCondition.commandID) { case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION2: case YouWeiPublicDefine.ICOMMAND_DEVICEPOSITION: case YouWeiPublicDefine.ICOMMAND_DEVICECURRENTPOSRES: case YouWeiPublicDefine.ICOMMAND_DEVICECURRSTATUSRES: dataList.Add(result.BaseData); break; } } if (receiveDataCondition.commandID == YouWeiPublicDefine.ICOMMAND_DEVICEALARMEVENT) { if (YouWeiDataEx[i].BaseData.PlunderState == 0 || gpsData.BaseData.PlunderState > 10) { dataList.Add(result.BaseData); } } } } //判断持续未定位状态时发送重启GPS指令 if (IsSendRestartMsg(gpsData, DicIsGPSLocated, RestartTimeByUnGPSLocated)) { //bShouldResponse = true; uint instructionLen = 0; byte[] instruction = new byte[512]; byte[] pOutData = null; if (responseList != null) { YouWeiGPSInterface.EncodeResetDevice( (byte)GPSYouWeiProtocolType.GPRSORCDMA, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, ref instructionLen, instruction); //instruction = ClearUselessDataFromInstruction((int)instructionLen, instruction); //aResponseList.Add(instruction); pOutData = new byte[instructionLen]; Array.Copy(instruction, pOutData, instructionLen); responseList.Add(pOutData); instruction = null; } else { responseList = new List<byte[]>(); //复位终端 YouWeiGPSInterface.EncodeResetDevice( (byte)GPSYouWeiProtocolType.GPRSORCDMA, YouWeiPublicDefine.PROTOCOLVER, YouWeiPublicDefine.SEQUENCEID, ref instructionLen, instruction); //instruction = ClearUselessDataFromInstruction((int)instructionLen, instruction); //aResponseList.Add(instruction); pOutData = new byte[instructionLen]; Array.Copy(instruction, pOutData, instructionLen); responseList.Add(pOutData); instruction = null; } Logger.Trace("UnGPSLocaatedRestart,GPSCode:" + gpsData.BaseData.GPSCode, null); } return dataList; } catch (Exception ex) { Logger.Error(ex, null); fullGpsCode = string.Empty; return null; } }