public ResponseAppResult AppGetCarStatues(Dictionary <string, string> inparams) { ResponseAppResult Result = null; if (!inparams.Keys.Contains("cid") || inparams["cid"] == "") { Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null); return(Result); } try { string sysflag = inparams["sysflag"]; long cid = GetCarCIDBySimCode(sysflag, inparams["cid"]); monitor mon = new monitor(); WebGIS.RealtimeDataServer.CarRealData[] RealData = mon.CarRealDataByCids(WebProc.GetAppSysflagKey(sysflag), new long[] { cid }); if (RealData.Length > 0) { alarmcarstatuesalarm wd = new alarmcarstatuesalarm(); wd.cid = RealData[0].Carid.ToString(); wd.lat = RealData[0].Lati.ToString(); wd.longt = RealData[0].Long.ToString(); wd.onlinestatus = RealData[0].OnlineStatus.ToString(); wd.tdatetime = RealData[0].TDateTime.ToString("yyyy-MM-dd HH:mm:ss"); wd.tno = RealData[0].TNO.ToString(); if (RealData[0].sPositionAdditionalInfo != null) { wd = analyzeStatues(wd, RealData[0].sPositionAdditionalInfo); Result = new ResponseAppResult(ResState.Success, "操作成功", wd); } else { SendOrderHander.Send_CTS_TermSearchRequest(WebProc.GetAppSysflagKey(sysflag), "", cid, long.Parse(wd.tno)); Result = new ResponseAppResult(ResState.Success, "操作失败,无车辆状态数据!", null); } } else { Result = new ResponseAppResult(ResState.Success, "操作失败,车辆不在线!", null); } } catch (Exception ex) { LogHelper.WriteError("AppGetCarLastTrack调用异常", ex); Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null); } return(Result); }
private alarmcarstatuesalarm analyzeStatues(alarmcarstatuesalarm res, byte[] datas) { AlertorResolve alertorResolve = new AlertorResolve(); //MemoryStream msAdditionalInfo = new MemoryStream(datas); //COM_PositionAdditionalInfo AdditionalInfo = ProtoBuf.Serializer.Deserialize<COM_PositionAdditionalInfo>(msAdditionalInfo); Dictionary <int, byte[]> customdataparams = EB_Analyze.AnalyzePosAddlInfo(datas); //wd.rawdata = MyTools.byteToHexStr(AdditionalInfo.sCustomData); if (customdataparams.ContainsKey(1))//报警信息 { res.caralarms = dictcov(alertorResolve.analyzeAlertorInfo(customdataparams[1])); } if (customdataparams.ContainsKey(2))//状态信息 { res.carstatues = dictcov(alertorResolve.analyzeStatues(customdataparams[2])); } if (customdataparams.ContainsKey(3))//电压信息 { res.voltage = alertorResolve.analyzeEV(customdataparams[3][0]).ToString(); } return(res); }
public ResponseAppResult AppSendOBDDriver(Dictionary <string, string> inparams) { ResponseAppResult Result = null; if (!inparams.Keys.Contains("cid") || inparams["cid"] == "") { Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null); return(Result); } try { string sysflag = inparams["sysflag"]; monitor mon = new monitor(); long cid = GetCarCIDBySimCode(sysflag, inparams["cid"]); WebGIS.RealtimeDataServer.CarRealData[] RealData = mon.CarRealDataByCids(WebProc.GetAppSysflagKey(sysflag), new long[] { cid }); if (RealData.Length > 0) { if (RealData[0].OnlineStatus == 1 && RealData[0].sPositionAdditionalInfo != null && RealData[0].sPositionAdditionalInfo.Length > 0) { alarmcarstatuesalarm act = new alarmcarstatuesalarm(); act = analyzeStatues(act, RealData[0].sPositionAdditionalInfo); KeyValuePair <int, int> accstates = (KeyValuePair <int, int>)act.carstatues.GetValue(13); if (accstates.Value == 1) { long tno = GetCarTNO(WebProc.GetAppSysflagKey(sysflag), cid.ToString()); AlertorResolve ar = new AlertorResolve(); byte[] data = new byte[0]; bool w = SendOrderHander.Send_CTS_TransmissionProtocol(WebProc.GetAppSysflagKey(sysflag), "", cid, tno, 0x8fc8, data); if (w) { Result = new ResponseAppResult(ResState.Success, "操作成功", ""); } else { Result = new ResponseAppResult(ResState.OperationFailed, "操作失败,后台服务中断!", ""); } } else { Result = new ResponseAppResult(ResState.OperationFailed, "操作失败,请将钥匙置为ON档!", null); } } else { Result = new ResponseAppResult(ResState.OperationFailed, "车辆已经离线,无法发送指令!", null); return(Result); } } else { Result = new ResponseAppResult(ResState.OperationFailed, "车辆已经离线,无法发送指令!", null); return(Result); } } catch (Exception ex) { LogHelper.WriteError("AppSendOBDDriver调用异常", ex); Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null); } return(Result); }