예제 #1
0
파일: Features.cs 프로젝트: jesumarquez/lt
        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);
        }
예제 #2
0
파일: Features.cs 프로젝트: jesumarquez/lt
        public bool LoadRoute(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, "LoadRoute: Stop ID=" + Convert.ToString(p.Code) + " - " + stopStr);
                    config.Append(stopStr);
                }
                config.Append(Environment.NewLine);
                config.Append(Fota.VirtualMessageFactory(MessageIdentifier.LoadRouteSuccess, NextSequence));
                cmd = config.ToString();
                break;

            case MessagingDevice.Mpx01:
                break;
            }
            SendMessages(cmd, messageId, md);
            return(true);
        }
예제 #3
0
파일: IFoteable.cs 프로젝트: jesumarquez/lt
        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);
        }
예제 #4
0
파일: IFoteable.cs 프로젝트: jesumarquez/lt
        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");
            }
        }