示例#1
0
 private void CheckFota(ulong msgid)
 {
     if (LastSent.GetId() == msgid)
     {
         Fota.Dequeue(this, null);
     }
 }
示例#2
0
文件: Parser.cs 项目: jesumarquez/lt
 private void CheckFota(int msgId)
 {
     if (Lastsentmessageid == (ulong)msgId)
     {
         Fota.Dequeue(this, null);
     }
 }
示例#3
0
文件: Parser.cs 项目: jesumarquez/lt
 private void CheckFota(ulong mid)
 {
     STrace.Trace(GetType().FullName, Id, String.Format("CheckFota: LastSent.GetId()={0} mid={1}", LastSent.GetId(), mid));
     if (mid != 10000)
     //if (LastSent.GetId() == mid)
     {
         Fota.Dequeue(this, null);
     }
 }
示例#4
0
        private void CheckLastSentAndDequeueIt(BaseDeviceCommand dc)
        {
            string LastCmd = LastSent.GetText(String.Empty);

            if (LastSent != null)
            {
                if (LastSent.IsExpired())
                {
                    LastSent = null;
                }
                else
                {
                    var lastDC = BaseDeviceCommand.createFrom(LastCmd, this, null);
                    var result = lastDC.isExpectedResponse(dc);
                    if (result == DeviceCommandResponseStatus.Valid)
                    {
                        Fota.Dequeue(this, lastDC.MessageId);
                    }
                }
            }
        }
示例#5
0
        private bool CheckLastSentAndDequeueIt(String buffer, ulong msgId, ref IMessage salida)
        {
            var    result  = true;
            string LastCmd = LastSent.GetText(String.Empty);
            ulong  LastId  = LastSent.GetId();

            if (buffer.StartsWith(Reporte.SdLocked))
            {
                _sdSession = false;
                STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd BORRANDO_POR_LOCKED");
            }
            else if (buffer.StartsWith(Reporte.SdPassword))
            {
                //Debug.Assert(LastSent.IsOnTheFly() == true);
                if (LastCmd.StartsWith(Reporte.StartGgWriteSession) && (LastId == msgId))
                {
                    LastSent   = null;
                    _sdSession = true;
                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd ABIERTA");
                }
                else if (_sdSession)
                {
                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd NO_MANEJADO");
                }
                else if (LastId == msgId)
                {
                    ulong mid = NextSequence;


                    LastSent = new INodeMessage(mid,
                                                Mensaje.Factory(mid, this,
                                                                String.Format("{0}{1}",
                                                                              Reporte.StartGgWriteSession.TrimStart('>'),
                                                                              buffer.Substring(8, 8))),

                                                DateTime.MinValue)
                    {
                        IsOnTheFly = true
                    };

                    salida.AddStringToSend(LastSent.Text);

                    STrace.Debug(typeof(Parser).FullName, Id, "Sesion de escritura en sd ABRIENDO");
                }
                else
                {
                    STrace.Debug(typeof(Parser).FullName, Id,
                                 String.Format("Sesion de escritura en sd NADA (LastSent.GetId()={0} msgId={1})",
                                               LastSent.GetId(), msgId));
                }
            }
            else

            if (LastSent != null)
            {
                if (LastSent.IsExpired())
                {
                    LastSent = null;
                }
                else
                {
                    var lastDC     = BaseDeviceCommand.createFrom(LastCmd, this, null);
                    var respStatus = lastDC.isExpectedResponse(BaseDeviceCommand.createFrom(buffer, this, null));
                    switch (respStatus)
                    {
                    case DeviceCommandResponseStatus.Valid:
                        result = true;
                        Fota.Dequeue(this, lastDC.MessageId ?? null);
                        break;

                    case DeviceCommandResponseStatus.Invalid:
                        result = false;
                        break;

                    case DeviceCommandResponseStatus.Exception:
                        Fota.RollbackLastTransaction(this, lastDC.MessageId ?? null);
                        result = false;
                        break;
                    }
                }
            }
            return(result);
        }
示例#6
0
文件: Parser.cs 项目: jesumarquez/lt
        private IMessage Decode2(ulong mid, String[] s, DateTime dtsent, out String peeked)
        {
            peeked = null;
            var ss = s[0].Replace("+BUFF", "+RESP");

            switch (ss)
            {
            case Report.Fixed: return(ParsePositions(Id, mid, s));

            case Report.CrossBorderEvent: return(ParseEventWithPosition(Id, mid, s, s[5] == "1" ? MessageIdentifier.InsideGeoRefference : MessageIdentifier.OutsideGeoRefference, dtsent, 7, null));

            case Report.SpeedAlarm: return(ParsePosition(Id, mid, s));

            case Report.SosEvent: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.PanicButtonOn, dtsent, 7, null));

            case Report.RtoRtl: return(ParsePosition(Id, mid, s));

            case Report.DevicePowerUpFirstPosition: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.GpsSignalOn, dtsent, 7, null));

            case Report.NonMovementEvent:
            {
                var ev =
                    (s[5] == "0") ?  MessageIdentifier.StoppedEvent :
                    ((s[5] == "1") ? MessageIdentifier.StartMovementEvent :
                     /*s[5] == "2"*/ MessageIdentifier.Freefall);
                return(ParseEventWithPosition(Id, mid, s, ev, dtsent, 7, null));
            }

            case Report.LocationByCall:
            {
                var res = (Event)ParseEventWithPosition(Id, mid, s, MessageIdentifier.BlackcallIncoming, dtsent, 5, null);
                res.SensorsDataString = s[4];
                return(res);
            }

            case Report.LocationAsCentreOfGeofence: return(ParsePosition(Id, mid, s));

            case Report.DeviceInformation: return(new UserMessage(Id, mid));

            case Report.GpsRequest: return(new UserMessage(Id, mid));

            case Report.GetAllConfiguration: return(new UserMessage(Id, mid));

            case Report.RealTimeOperationCid: return(new UserMessage(Id, mid));

            case Report.RealTimeOperationCsq: return(new UserMessage(Id, mid));

            case Report.RealTimeOperationVer: return(new UserMessage(Id, mid));

            case Report.RealTimeOperationBat: return(FactoryEventWithoutPosition(Id, mid, MessageIdentifier.BateryInfo, String.Format("BatteryPercentage:{0},BatteryVoltage:{1},ExternalPowerSupply:{2},Charging:{3},LedOn:{4}", s[6], s[7], s[4], s[8], s[9])));

            case Report.RealTimeOperationTmz: return(new UserMessage(Id, mid));

            case Report.PowerOn: return(FactoryEventWithoutPosition(Id, mid, MessageIdentifier.DeviceTurnedOn, null));

            case Report.PowerOff: return(FactoryEventWithoutPosition(Id, mid, MessageIdentifier.DeviceShutdown, null));

            case Report.ConnectingExternalPowerSupply: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.PowerReconnected, dtsent, 4, null));

            case Report.DisconnectingExternalPowerSupply: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.PowerDisconnected, dtsent, 4, null));

            case Report.BatteryLow: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.BateryLow, dtsent, 5, String.Format("BatteryVoltage:{0}", s[4])));

            case Report.StartCharging: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.BatteryChargingStart, dtsent, 4, null));

            case Report.StopCharging: return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.BatteryChargingStop, dtsent, 5, null));

            case Report.DeviceMotionStateIndication: return(new UserMessage(Id, mid));

            case Report.GpsAntennaStatusIndication: return(new UserMessage(Id, mid));

            case Report.SwitchOnOffGeofence0ViaFunctionKey: return(new UserMessage(Id, mid));

            case Report.Heartbeat: return(ParseHeartbeat(Id, mid, s));

            default:
                if (s[0].StartsWith("+ACK:"))
                {
                    var midR = Convert.ToUInt64(s[s.Length - 3], 16);
                    peeked = Fota.Peek(this);
                    var midF = Convert.ToUInt64(peeked.Split(',').Last().TrimEnd('$'), 16);
                    if (midR == midF)
                    {
                        Fota.Dequeue(this, null);
                    }
                }
                return(null);
            }
        }
示例#7
0
        private IMessage Decode3(ulong mid, String[] s, DateTime dtsent)
        {
            switch (s[0])
            {
            case Report.NonMovementEvent:
                return(ParsePosition(Id, mid, s));

            case Report.MovementEvent:
                return(ParsePosition(Id, mid, s));

            case Report.GpsRequest:
                return(ParsePosition(Id, mid, s));

            case Report.Fixed:
                return(ParsePositionsFixed(Id, mid, s));

            case Report.GpsHistoryFixRecords:
                return(ParseGpsHistoryFixRecords(Id, mid, s));

            case Report.DevicePowerDown:
                return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.DeviceShutdown, dtsent));

            case Report.CrossBorderEvent:
                return(ParseEventWithPosition(Id, mid, s, s[5] == "1" ? MessageIdentifier.InsideGeoRefference : MessageIdentifier.OutsideGeoRefference, dtsent));

            case Report.SpeedAlarm:
                return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.SpeedingTicketEnd, dtsent));

            case Report.PowerKeyShortPressEvent:
                return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.PowerKeyShortPress, dtsent));

            case Report.FreefallEvent:
                return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.Freefall, dtsent));

            case Report.DeviceInformation:
                return(ParseEventWithoutPosition(Id, mid, MessageIdentifier.DeviceOnLine));

            case Report.BlackCallIncoming:
            {
                var res = (Event)ParseEventWithoutPosition(Id, mid, MessageIdentifier.BlackcallIncoming);
                res.SensorsDataString = s[4];
                return(res);
            }

            case Report.SosEvent:
                return(ParseEventWithPosition(Id, mid, s, MessageIdentifier.PanicButtonOn, dtsent).AddStringToSend(String.Format("AT+GTRTO={1},C,,,,,,,{0:X4}$", NextSequence, DataProvider.GetDetalleDispositivo(Id, "Password").As(Password))));

            case Report.Heartbeat:
                return(ParseHeartbeat(Id, mid, s));

            case Report.BatteryTimer:
                return(ParseBatteryTimer(Id, mid, s));

            default:
                if (s[0].StartsWith("+ACK"))
                {
                    var mid2 = GetMessageId2(s, Id);
                    if ((Lastsentmessageid == mid2))
                    {
                        Fota.Dequeue(this, null);
                    }
                }
                return(new UserMessage(Id, mid));
            }
        }