string GetPacket(TrackerPacket point, int isResend) { decimal Alarm = 0; point.GetInput("ALARM", out Alarm); int timestamp, packettimestamp, servertimestamp; packettimestamp = point.m_Time; DateTime dt = CTime.GetTime(Convert.ToInt64(packettimestamp)); servertimestamp = Convert.ToInt32(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds); if (isResend > 0) { timestamp = servertimestamp; } else { timestamp = packettimestamp; } string str = "{\"deviceId\": \"" + m_Tracker.m_IMEI + "\", " + "\"latitude\": \"" + point.m_fLat + "\", " + "\"longitude\": \"" + point.m_fLng + "\", " + "\"timeStamp\": \"" + timestamp + "\", " + "\"speed\": \"" + CObject.Float2XML(point.m_Speed / 3.6) + "\", " + "\"sos\": \"" + ((Alarm != 0) ? "True": "False") + "\", " + "\"altitude\": \"" + point.m_Alt + "\", " + "\"vehicleNo\": \"" + m_Tracker.m_strName + "\", " + "\"isValid\": \"" + (point.IsFixed(false) ? "True" : "False") + "\", " + "\"packetTimeStamp\": \"" + packettimestamp + "\"," + "\"serverTimeStamp\": \"" + servertimestamp + "\"" + "}"; return(str); }
public override string ToString() { return("<tracker " + "ID=\"" + m_nID + "\" " + "UserID=\"" + m_nUserID + "\" " + "Name=\"" + String2XML(m_strName) + "\" " + "Comment=\"" + String2XML(m_strComment) + "\" " + "DeviceType=\"" + String2XML(m_strDeviceType) + "\" " + "IconID=\"" + m_nIconID + "\" " + "Color=\"" + String2XML(m_strColor) + "\" " + "Flags=\"" + String2XML(m_strFlags) + "\" " + "Phone=\"" + String2XML(m_strPhone) + "\" " + "SleepPeriod=\"" + m_Timeout + "\" " + "ParkRadius=\"" + m_ParkRadius + "\" " + "MinParkTime=\"" + m_MinParkTime + "\" " + "MinIdleTime=\"" + m_MinIdleTime + "\" " + "FuelExpense=\"" + CObject.Float2XML(m_fFuelExpensePerKm) + "\" " + "FuelExpensePerHr=\"" + CObject.Float2XML(m_fFuelExpensePerHr) + "\" " + "MinDrain=\"" + CObject.Float2XML(m_fMinDrain) + "\" " + "MinDrainSpeed=\"" + CObject.Float2XML(m_fMinDrainSpeed) + "\" " + "MaxSpeed=\"" + m_MaxSpeed + "\" " + "AlarmParkTime=\"" + m_AlarmParkTime + "\" " + "IMEI=\"" + m_IMEI + "\" " + "DaysToStore=\"" + m_nDaysToStore + "\" " + "CreateDate=\"" + m_dtCreateDate + "000\" " + //"InstallDate=\"" + m_dtInstallDate + "000\" " + "StateNumber=\"" + String2XML(m_strStateNumber) + "\" " + //"InstallerName=\"" + String2XML(m_strInstallerName) + "\" " + "/>"); }
string GetPacket(TrackerPacket point) { decimal key = 0; point.GetInput("EKEY", out key); DateTime dt = CTime.GetTime(point.m_Time); string str = dt.ToString("ddMMyy") + ";" + dt.ToString("HHmmss") + ";" + GetCoord(Math.Abs(point.m_fLat), true) + ";" + ((point.m_fLat > 0) ? "N" : "S") + ";" + GetCoord(Math.Abs(point.m_fLng), false) + ";" + ((point.m_fLng > 0) ? "E" : "W") + ";" + point.m_Speed + ";" + point.m_Direction + ";" + point.m_Alt + ";" + point.m_SatteliteCount + ";" + "0" + ";" + ";" + ";" + ";" + ((key > 0) ? ((long)key).ToString("X12") : "NA") + ";"; byte[] inputs = point.GetIOBuffer(); if (inputs != null) { int i = 0; while (i < inputs.Length) { ushort id = BitConverter.ToUInt16(inputs, i); bool b64bit = (id & (1 << (int)TrackerPacket.IOFlags.LENGTH8)) != 0; i += 2 + (b64bit ? 8 : 4); decimal fValue = 0; string name = IOChannelMgr.inst().GetIOChannel((ushort)(id & 0xFFF)); if (name != null && point.GetInput(name, out fValue)) { if ((id & (1 << (int)TrackerPacket.IOFlags.INTEGER)) != 0) { str += name + ":1:" + fValue + ","; } else { str += name + ":2:" + CObject.Float2XML(fValue) + ","; } } } } return(str.Trim(',')); }
string GetPacket(TrackerPacket point) { decimal Alarm = 0; point.GetInput("ALARM", out Alarm); string str = "{\"deviceId\": \"" + m_Tracker.m_IMEI + "\", " + "\"latitude\": \"" + point.m_fLat + "\", " + "\"longitude\": \"" + point.m_fLng + "\", " + "\"timeStamp\": \"" + point.m_Time + "\", " + "\"speed\": \"" + CObject.Float2XML(point.m_Speed / 3.6) + "\", " + "\"sos\": \"" + ((Alarm != 0) ? "True": "False") + "\", " + "\"altitude\": \"" + point.m_Alt + "\", " + "\"vehicleNo\": \"" + m_Tracker.m_strName + "\", " + "\"isValid\": \"" + (point.IsFixed(false) ? "True" : "False") + "\"}"; return(str); }
// У$DIMTS,null,null,null,357852031069696,DL1PC4716,31.12.2013,06:54:11,28.5271550,null,77.2807010,null,12.5,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null#Ф string GetPacket(TrackerPacket point) { DateTime dt = CTime.GetTime(point.m_Time); decimal odo = 0, pwr = 0, acc = 0; point.GetInput("ODO", out odo); point.GetInput("ACC", out acc); point.GetInput("PWR", out pwr); string res = "$DIMTS,null,null,null"; res += "," + m_Tracker.m_IMEI; res += "," + m_Tracker.m_strName; res += "," + dt.ToString("dd.MM.yyyy"); res += "," + dt.ToString("HH:mm:ss"); res += "," + CObject.Float2XML(Math.Abs(point.m_fLat)); res += "," + ((point.m_fLat >= 0) ? "N" : "S"); res += "," + CObject.Float2XML(Math.Abs(point.m_fLng)); res += "," + ((point.m_fLng >= 0) ? "E" : "W"); res += "," + point.m_Speed; res += "," + (point.IsFixed(false) ? "1" : "0"); res += "," + point.m_SatteliteCount; res += ",null";// + 1; //DOP res += "," + point.m_Direction; res += "," + point.m_Alt; res += ",null"; // + 0; res += "," + Math.Round(odo); //ODO res += ",null"; //IGN res += ",null"; // + CObject.Float2XML((double)acc / 1000.0); //Batt res += ",null"; // + CObject.Float2XML((double)pwr / 1000.0); //POWER res += ",null"; // + "00000000"; //Digitalinputvalues res += ",null"; //NetworkOperatorName res += ",null"; // + 15; //GSMStrength res += ",null"; // + 0; //CellID res += ",null"; // + 0; //LAC res += ",null"; // + 1; //SeqNo res += ",null"; // + 0; //AvgSpd res += ",null"; // + 0; //MinSpd res += "#"; m_Logger.Push(LogLevel.INFO, 0, res); return(res); }