public bool UnloadRoute(ulong messageId, Destination[] route, int routeId) { string cmd = null; var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: var config = new StringBuilder(); config.AppendFormat("{0}{1}", BaseDeviceCommand.createFrom(">SSG160<", this, null).ToString(false), Environment.NewLine); config.Append(GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteAllStopsOnTheClient).ToTraxFM(this, false)); foreach (var p in route) { config.Append(GarminFmi.EncodeDeleteTextmessage((UInt32)p.Code).ToTraxFM(this, false)); } config.Append(Environment.NewLine); config.Append(Fota.VirtualMessageFactory(MessageIdentifier.UnloadRouteSuccess, 0)); cmd = config.ToString(); break; case MessagingDevice.Mpx01: break; } SendMessages(cmd, messageId, md); return(true); }
public bool ReloadRoute(ulong messageId, Destination[] route, bool sort, int routeId) { string cmd = null; var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: var config = new StringBuilder(); config.AppendFormat("{0}{1}", BaseDeviceCommand.createFrom(">SSG161<", this, null).ToString(false), Environment.NewLine); //config.Append(GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteAllStopsOnTheClient).ToTraxFM(this, false)); foreach (var p in route) { var stopStr = GarminFmi.EncodeA603StopProtocol(p.Point, p.Code, p.Text).ToTraxFM(this, false); //STrace.Debug(typeof(GarminFmi).FullName, Id, "ReloadRoute: Stop ID=" + Convert.ToString(p.Code) + " - " + stopStr); config.Append(stopStr); } config.Append(Environment.NewLine); config.Append(Fota.VirtualMessageFactory(MessageIdentifier.ReloadRouteSuccess, NextSequence)); cmd = config.ToString(); break; case MessagingDevice.Mpx01: break; } SendMessages(cmd, messageId, md); return(true); }
public bool UnloadStop(ulong messageId, Destination[] route) { string cmd = null; var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: var config = new StringBuilder(); foreach (var p in route) { config.Append(GarminFmi.EncodeDeleteTextmessage((UInt32)p.Code).ToTraxFM(this, false)); var stopStr = GarminFmi.EncodeA603StopStatusProtocol(p.Code, StopStatusValue.DeleteStop).ToTraxFM(this, false); STrace.Debug(typeof(GarminFmi).FullName, Id, "UnloadStop: Stop ID=" + Convert.ToString(p.Code) + " - " + stopStr); config.Append(stopStr); } config.Append(Environment.NewLine); cmd = config.ToString(); break; case MessagingDevice.Mpx01: break; } SendMessages(cmd, messageId, md); return(true); }
public bool ResetFMIOnGarmin(ulong messageId) { var config = new StringBuilder(); config.Append(GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteFleetManagementInterfaceOnTheClient).ToTraxFM(this, false)); GarminSetup(ref config, this); GetMessages(ref config, false); SendMessages(config.ToString(), messageId, MessagingDevice.Garmin); return(true); }
private String GetCannedForGarmin(Logictracker.Types.BusinessObjects.Messages.Mensaje[] messagesParameters, UInt16 setFmiPacketId, UInt16 deleteFmiPacketId) { var config = new StringBuilder(); foreach (Logictracker.Types.BusinessObjects.Messages.Mensaje m in messagesParameters) { int cod = Convert.ToInt32(m.Codigo); config.Append(GarminFmi.EncodeSetCanned(cod, "code=" + cod + ";" + m.Texto, setFmiPacketId).ToTraxFM(this, false)); } return(config.ToString()); }
public bool SubmitTextMessage(ulong messageId, uint textMessageId, String textMessage, uint[] replies, int ackEvent) { STrace.Debug(typeof(Parser).FullName, Id, "SubmitTextMessage: messageId=" + messageId.ToString() + ",textMessageId=" + textMessageId.ToString() + ",textMessage=" + textMessage + ",replies=" + (replies == null?"null":String.Join(",", replies.Select(b => b.ToString()).ToArray()))); var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: { var cnf = new StringBuilder(); // cnf.Append(GarminFmi.EncodeDeleteTextmessage(textMessageId).ToTraxFM(this, false)); if (replies != null && replies.Length > 0) { cnf.Append(GarminFmi.EncodeCannedResponseList(textMessageId, replies).ToTraxFM(this, false)); } else { cnf.Append(GarminFmi.EncodeDeleteTextmessage(textMessageId).ToTraxFM(this, false)); } cnf.Append(GarminFmi.EncodeOpenTextMessage(textMessageId, textMessage, true).ToTraxFM(this, false)); if (ackEvent != -1) { cnf.Append(Fota.VirtualMessageFactory((MessageIdentifier)ackEvent, NextSequence)); } var cmd = cnf.ToString(); SendMessages(cmd, messageId, md); break; } case MessagingDevice.Mpx01: { var cmd = EncodeMpx01Msg(textMessage, messageId, this); SendMessages(cmd, messageId, md); break; } case MessagingDevice.Sms: { var cmd = EncodeSmsMsg(textMessage, messageId, this); SendMessages(cmd, messageId, md); break; } } return(true); }
public bool SetCannedResponse(ulong messageId, int codeResponseId, String response, int revision) { var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: var cmd = GarminFmi.EncodeSetCanned(codeResponseId, response, FmiPacketId.ScSetCannedResponse).ToTraxFM(this); SendMessages(new[] { cmd }, md); break; case MessagingDevice.Mpx01: break; } return(true); }
public bool DeleteCannedMessage(ulong messageId, int code, int revision) { var config = new StringBuilder(); var md = GetMessagingDevice(); var cmd = ""; if (code == 0) { var messagesParameters = DataProvider.GetCannedMessagesTable(Id, 0).OrderBy(m => m.Codigo); foreach (var mensaje in messagesParameters) { switch (md) { case MessagingDevice.Garmin: config.Append(GarminFmi.EncodeDeleteCanned(Convert.ToInt32(mensaje.Codigo), FmiPacketId.ScDeleteCannedMessage).ToTraxFM(this, false)); break; case MessagingDevice.Mpx01: break; } } config.Append(Environment.NewLine); // config.AppendFormat("{0}{1}", GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteAllCannedMessagesOnTheClient)); } else { switch (md) { case MessagingDevice.Garmin: config.Append(GarminFmi.EncodeDeleteCanned(code, FmiPacketId.ScDeleteCannedMessage).ToTraxFM(this, true)); break; case MessagingDevice.Mpx01: break; } } cmd = config.ToString(); SendMessages(cmd, messageId, md); return(true); }
public bool SubmitLongTextMessage(ulong messageId, uint textMessageId, String textMessage, int ackEvent) { STrace.Debug(typeof(Parser).FullName, Id, "SubmitLongTextMessage: messageId=" + messageId.ToString() + ",textMessageId=" + textMessageId.ToString() + ",textMessage=" + textMessage); var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: { var cnf = new StringBuilder(); cnf.Append(GarminFmi.EncodeDeleteTextmessage(textMessageId).ToTraxFM(this, false)); cnf.Append(GarminFmi.EncodeOpenLongTextMessage(textMessageId, textMessage, true).ToTraxFM(this, false)); if (ackEvent != -1) { cnf.Append(Fota.VirtualMessageFactory((MessageIdentifier)ackEvent, NextSequence)); } var cmd = cnf.ToString(); SendMessages(cmd, messageId, md); break; } case MessagingDevice.Mpx01: { var cmd = EncodeMpx01Msg(textMessage, messageId, this); SendMessages(cmd, messageId, md); break; } case MessagingDevice.Sms: { var cmd = EncodeSmsMsg(textMessage, messageId, this); SendMessages(cmd, messageId, md); break; } } return(true); }
public bool SubmitCannedMessage(ulong messageId, int codeMessageId, int[] replies) { //var messageM = daoFactory.MensajeDAO.GetCannedMessagesTable(DeviceId, 0).Where(m => m.Codigo == codeMessageId.ToString()).SingleOrDefault(); var messageM = DataProvider.GetCannedMessagesTable(Id, 0).SingleOrDefault(m => m.Codigo == codeMessageId.ToString(CultureInfo.InvariantCulture)); if (messageM == null) { STrace.Error(typeof(Parser).FullName, Id, String.Format("Se intento enviar un mensaje predefinido no existente con codigo={0}", codeMessageId)); return(false); } var message = messageM.Texto; var md = GetMessagingDevice(); switch (md) { case MessagingDevice.Garmin: { //envio sin id por que si el id se repite el envio da error y no hay canned messages hacia garmin, solo hacia server, que el usuario se encargue de borrar los mensajes /*(UInt32)codeMessageId*/ var cmd = GarminFmi.EncodeOpenTextMessage(0, message, true).ToTraxFM(this); SendMessages(new[] { cmd }, md); break; } case MessagingDevice.Mpx01: { var cmd = EncodeMpx01Msg(message, messageId, this); SendMessages(cmd, messageId, md); break; } case MessagingDevice.Sms: { var cmd = EncodeSmsMsg(message, messageId, this); SendMessages(cmd, messageId, md); } break; } return(true); }
private void GetMessages(ref StringBuilder config, bool deleteMessagesPreviously) { string md = DataProvider.GetDetalleDispositivo(Id, "GTE_MESSAGING_DEVICE").As(String.Empty); if (md == MessagingDevice.Garmin || md == MessagingDevice.Mpx01) { // cargar todos los posibles responses switch (md) { case MessagingDevice.Garmin: List <Logictracker.Types.BusinessObjects.Messages.Mensaje> resp = DataProvider.GetResponsesMessagesTable(Id, 0); if (deleteMessagesPreviously) { config.Append(GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteAllCannedRepliesOnTheClient).ToTraxFM(this, false)); } if (resp != null && resp.Any()) { var respArr = resp.OrderBy(m => m.Codigo).ToArray(); config.Append(GetCannedResponses4Garmin(respArr)); } break; default: break; } config.Append(Environment.NewLine); //cargar todos los canned messages List <Logictracker.Types.BusinessObjects.Messages.Mensaje> cmt = DataProvider.GetCannedMessagesTable(Id, 0); { if ((cmt != null) && (cmt.Any())) { Logictracker.Types.BusinessObjects.Messages.Mensaje[] messagesParameters = cmt.Where(m => !m.TipoMensaje.DeEstadoLogistico).OrderBy(m => m.Codigo).ToArray(); switch (md) { case MessagingDevice.Garmin: if (deleteMessagesPreviously) { config.Append(GarminFmi.EncodeDataDeletionFor(DataDeletionProtocolId.DeleteAllCannedMessagesOnTheClient).ToTraxFM(this, false)); } config.Append(GetCannedMessages4Garmin(messagesParameters)); break; case MessagingDevice.Mpx01: int count = 0; foreach (Logictracker.Types.BusinessObjects.Messages.Mensaje m in messagesParameters.Take(10)) { count++; string texto = m.Texto.ToUpper().PadRight(32); config.Replace(String.Format("$MENSAJE{0:D2}PARTE01", count), texto.Substring(0, 16)); config.Replace(String.Format("$MENSAJE{0:D2}PARTE02", count), texto.Substring(16, 16)); config.Replace(String.Format("$MENSAJE{0:D2}CODIGO", count), m.Codigo); } for (int i = count; i < 11; i++) { const String texto = " "; config.Replace(String.Format("$MENSAJE0{0:D1}PARTE01", i), texto); config.Replace(String.Format("$MENSAJE0{0:D1}PARTE02", i), texto); config.Replace(String.Format("$MENSAJE{0:D2}CODIGO", count), "00"); } break; } } } } if (!String.IsNullOrEmpty(config.ToString().Trim())) { config.AppendFormat("{0}{0}Envio de Mensajes Generado Exitosamente{0}", Environment.NewLine); config.Insert(0, Fota.VirtualMessageFactory(MessageIdentifier.MessagesStart, 0)); config.Append(Fota.VirtualMessageFactory(MessageIdentifier.MessagesSuccess, 0)); } else { config.AppendLine("No hay mensajes para Enviar"); } }