Пример #1
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Location location)
        {
            bool reslt = false;
              location = new DataBlock_Location();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            location.blockType = stream.GetUint(offset, BlockTypeLen);
            location.BlockType = (ICDBlockType)location.blockType;
            offset += BlockTypeLen;

            location.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            location.BlockLengthBytes = stream.GetUint(offset, BlockLengthBytesLen);
            offset += BlockLengthBytesLen;

            location.LatitudeHemisphere = stream.GetUint(offset, LatitudeHemisphereLen);
            offset += LatitudeHemisphereLen;

            location.LatitudeDegrees = stream.GetUint(offset, LatitudeDegreesLen);
            offset += LatitudeDegreesLen;

            location.LatitudeMinutes = stream.GetUint(offset, LatitudeMinutesLen);
            offset += LatitudeMinutesLen;

            location.LatitudeMinutesDecimal = stream.GetUint(offset, LatitudeMinutesDecimalLen);
            offset += LatitudeMinutesDecimalLen;

            //seteamos la latitud
            if (location.LatitudeHemisphere == 0)
              location.position.Latitude.setValue((int)location.LatitudeDegrees, (location.LatitudeMinutes + (double)location.LatitudeMinutesDecimal / 1000), "N");
            else
              location.position.Latitude.setValue((int)location.LatitudeDegrees, (location.LatitudeMinutes + (double)location.LatitudeMinutesDecimal / 1000), "S");
            //completar

            location.LongitudeHemisphere = stream.GetUint(offset, LongitudeHemisphereLen);
            offset += LongitudeHemisphereLen;

            location.LongitudeDegrees = stream.GetUint(offset, LongitudeDegreesLen);
            offset += LongitudeDegreesLen;

            location.LongitudeMinutes = stream.GetUint(offset, LongitudeMinutesLen);
            offset += LatitudeMinutesLen;

            location.LongitudeMinutesDecimal = stream.GetUint(offset, LongitudeMinutesDecimalLen);
            offset += LongitudeMinutesDecimalLen;

            //seteamos la longitud
            if (location.LongitudeHemisphere == 0)
              location.position.Longitude.setValue((int)location.LongitudeDegrees, (location.LongitudeMinutes + (double)location.LongitudeMinutesDecimal / 1000), "E");
            else
              location.position.Longitude.setValue((int)location.LongitudeDegrees, (location.LongitudeMinutes + (double)location.LongitudeMinutesDecimal / 1000), "W");

            location.SpeedOverGround = stream.GetUint(offset, SpeedOverGroundLen);
            offset += SpeedOverGroundLen;

            location.VelocityDirection = stream.GetUint(offset, VelocityDirectionLen);
            offset += VelocityDirectionLen;

            location.CourseOverGround = stream.GetUint(offset, CourseOverGroundLen);
            offset += CourseOverGroundLen;

            location.AltitudeSign = stream.GetUint(offset, AltitudeSignLen);
            offset += AltitudeSignLen;

            location.Altitude = stream.GetUint(offset, AltitudeLen);
            offset += AltitudeLen;

            location.Source = stream.GetUint(offset, SourceLen);
            offset += SourceLen;

            location.LatitudeAccuracyMeasurement = stream.GetUint(offset, LatitudeAccuracyMeasurementLen);
            offset += LatitudeAccuracyMeasurementLen;

            location.LatitudeAccuracy = stream.GetUint(offset, LatitudeAccuracyLen);
            offset += LatitudeAccuracyLen;

            location.LongitudeAccuracyMeasurement = stream.GetUint(offset, LongitudeAccuracyMeasurementLen);
            offset += LongitudeAccuracyMeasurementLen;

            location.LongitudeAccuracy = stream.GetUint(offset, LongitudeAccuracyLen);
            offset += LongitudeAccuracyLen;

            location.AltitudeAccuracyMeasurement = stream.GetUint(offset, AltitudeAccuracyMeasurementLen);
            offset += AltitudeAccuracyMeasurementLen;

            location.AltitudeAccuracy = stream.GetUint(offset, AltitudeAccuracyLen);
            offset += AltitudeAccuracyLen;

            location.IsValid = stream.GetUint(offset, IsValidLen);
            offset += IsValidLen;

            location.GPSTimestampUTCYear = stream.GetUint(offset, GPSTimestampUTCYearLen);
            offset += GPSTimestampUTCYearLen;

            location.GPSTimestampUTCMonth = stream.GetUint(offset, GPSTimestampUTCMonthLen);
            offset += GPSTimestampUTCMonthLen;

            location.GPSTimestampUTCDay = stream.GetUint(offset, GPSTimestampUTCDayLen);
            offset += GPSTimestampUTCDayLen;

            location.GPSTimestampUTCHours = stream.GetUint(offset, GPSTimestampUTCHoursLen);
            offset += GPSTimestampUTCHoursLen;

            location.GPSTimestampUTCMinutes = stream.GetUint(offset, GPSTimestampUTCMinutesLen);
            offset += GPSTimestampUTCMinutesLen;

            location.GPSTimestampUTCSeconds = stream.GetUint(offset, GPSTimestampUTCSecondsLen);
            offset += GPSTimestampUTCSecondsLen;

            location.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #2
0
        public static bool TryParse(byte[] buff, int baseoffset, out _FreeText freeText)
        {
            freeText = new _FreeText();
              bool resp = false;
              try
              {
            int offset = baseoffset;
            BitStream stream = new BitStream(buff);

            freeText.FreeTextLengthIndicator = stream.GetUint(offset, freeText.FreeTextLengthIndicatorLen);
            offset += freeText.FreeTextLengthIndicatorLen;

            //la longitud es 7 bits
            if (freeText.FreeTextLengthIndicator == 0)
              freeText.FreeTextLengthLen = 7;
            else
              freeText.FreeTextLengthLen = 15;

            freeText.FreeTextLength = stream.GetUint(offset, freeText.FreeTextLengthLen);
            offset += freeText.FreeTextLengthLen;

            //repetir
            freeText.DecodeTextIndicator = stream.GetUint(offset, freeText.FreeTextLengthIndicatorLen);
            offset += freeText.FreeTextLengthIndicatorLen;

            int rest = 1;
            if (freeText.DecodeTextIndicator == 0)
              freeText.DecodeTextLengthLen = 7;
            else
            {
              freeText.DecodeTextLengthLen = 15;
              rest = 2;
            }
            freeText.DecodeTextLength = stream.GetUint(offset, (int)freeText.DecodeTextLengthLen);
            offset += freeText.FreeTextLengthLen;
            //

            offset = ((int)offset / 8);
            freeText.BytesText = new byte[freeText.FreeTextLength - rest];
            for (int i = 0; i < freeText.FreeTextLength; i++, offset++)
            {
              if (offset < buff.Length)
              {
            freeText.BytesText[i] = buff[offset];
              }
            }

            resp = true;
              }
              catch (Exception ex) { resp = false; }
              return resp;
        }
Пример #3
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_DeviceIdentifier deviceIdentifier)
        {
            bool reslt = false;
              deviceIdentifier = new DataBlock_DeviceIdentifier();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            deviceIdentifier.blockType = stream.GetUint(offset, BlockTypeLen);

            deviceIdentifier.BlockType = (ICDBlockType)deviceIdentifier.blockType;
            offset += BlockTypeLen;

            deviceIdentifier.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (deviceIdentifier.BlockLengthIndicator == 0)
            {
              deviceIdentifier.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              deviceIdentifier.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }

            reslt = _FreeText.TryParse(buff, offset, out deviceIdentifier.FreeText);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #4
0
        public static bool TryParse(byte[] buff, int offset, ICDMTPacket packet1, out ICDMTPacket packet)
        {
            bool reslt = false;
              packet = packet1;
              packet.body = new ICDMTMessageBody();
              ICDMTMessageType type = ICDMTMessageType.Unknown;
              type = packet.header.MessageType;
              int boffset = offset;

              BitStream stream = new BitStream(buff);
              uint blockType = 0;
              if (boffset == 0)
              {
            boffset = ICDMTMessageStandardHeader.HeaderLen;
              }
              blockType = stream.GetUint(boffset, ICDDataBlock.BlockTypeLen);

              switch (type)
              {
            case ICDMTMessageType.EmergencyAcknowledge:
            case ICDMTMessageType.EmergencyCancelRequest:
            case ICDMTMessageType.LocationPingRequest:
            case ICDMTMessageType.SystemTestResponseEndToEnd:
            case ICDMTMessageType.DiagnosticRequest:
            case ICDMTMessageType.ConfirmedCheckIn:
            case ICDMTMessageType.GeofenceCancel:
            case ICDMTMessageType.RequestDeviceIdentifier:
              break;
            case ICDMTMessageType.FreeText:
              while (boffset < buff.Length * 8)
              {
            blockType = stream.GetUint(boffset, ICDDataBlock.BlockTypeLen);
            switch (blockType)
            {
              case 0x01:
                DataBlock_FreeText freeText;
                if (DataBlock_FreeText.TryParse(buff, boffset, out freeText))
                {
                  packet.body.datablocks.Add(freeText);
                  boffset += (int)freeText.FreeTextLenBytes * 8;
                }
                break;
              case 0x06:
                {
                  DataBlock_Sender sender;
                  if (DataBlock_Sender.TryParse(buff, boffset, out sender))
                  {
                    packet.body.datablocks.Add(sender);
                    boffset += (int)sender.SenderLenBytes * 8;
                  }
                }
                break;
            }
              }
              break;
            case ICDMTMessageType.GeofenceActivate:
              while (boffset < buff.Length * 8)
              {
            blockType = stream.GetUint(boffset, ICDDataBlock.BlockTypeLen);
            switch (blockType)
            {
              case 0x08:
                DataBlock_Polygon polygon;
                if (DataBlock_Polygon.TryParse(buff, boffset, out polygon))
                {
                  packet.body.datablocks.Add(polygon);
                  boffset += (int)polygon.BlockLengthBytes * 8;
                }
                break;
              case 0x07:
                DataBlock_Circle circle;
                if (DataBlock_Circle.TryParse(buff, boffset, out circle))
                {
                  packet.body.datablocks.Add(circle);
                  boffset += (int)circle.BlockLengthBytes * 8;
                }
                break;
            }
              }
              break;
            case ICDMTMessageType.SynchroniseDataToDevice:
              while (boffset < buff.Length * 8)
              {
            DataBlock_Synchronisation synchronisation;
            if (DataBlock_Synchronisation.TryParse(buff, boffset, out synchronisation))
            {
              packet.body.datablocks.Add(synchronisation);
              boffset += synchronisation.SynchronisationLenBytes * 8;
            }
              }
              break;
            case ICDMTMessageType.PortalStatusMessage:

              while (boffset < buff.Length * 8)
              {
            blockType = stream.GetUint(boffset, ICDDataBlock.BlockTypeLen);
            switch (blockType)
            {
              case 0x09:
                DataBlock_PortalStatus portalStatus;
                if (DataBlock_PortalStatus.TryParse(buff, boffset, out portalStatus))
                {
                  packet.body.datablocks.Add(portalStatus);
                  boffset += portalStatus.PortalStatusLenBytes * 8;
                }
                break;
              case 0x0d:
                DataBlock_PortalProviderInformation portalProviderInformation;
                if (DataBlock_PortalProviderInformation.TryParse(buff, boffset, out portalProviderInformation))
                {
                  packet.body.datablocks.Add(portalProviderInformation);
                  boffset += portalProviderInformation.PortalProviderInformationLenBytes * 8;
                }
                break;
            }
              }
              break;

            case ICDMTMessageType.Reserved://borrar?
              break;
            case ICDMTMessageType.UserExtensions: // borrar?
              break;
              }
              return reslt;
        }
Пример #5
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_CannedMessagesHash cannedMessageHash)
        {
            bool reslt = false;
              cannedMessageHash = new DataBlock_CannedMessagesHash();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            cannedMessageHash.blockType = stream.GetUint(offset, BlockTypeLen);

            cannedMessageHash.BlockType = (ICDBlockType)cannedMessageHash.blockType;
            offset += BlockTypeLen;

            cannedMessageHash.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            cannedMessageHash.BlockLengthBytes = stream.GetUint(offset, BlockLengthBytesLen);
            offset += BlockLengthBytesLen;
            //
            uint tempUint = 0;
            byte[] tempBytes = new byte[0];
            for (int j = 0; j < 4; j++)
            {
              tempUint = stream.GetUint(offset, 4 * 8); //un uint son 4 bytes o sea 32 bits
              offset += 4 * 8;
              tempBytes = DataBlock_CannedMessagesHash.GetBytes(tempUint);
              for (int i = 0; i < tempBytes.Length; i++)
            cannedMessageHash.Hash[(j * 4) + i] = tempBytes[i];
            }
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #6
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationReportingFrequencyRate reportingFrequency)
        {
            bool reslt = false;
              reportingFrequency = new DataBlock_SynchronisationReportingFrequencyRate();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            reportingFrequency.blockType = stream.GetUint(offset, BlockTypeLen);

            reportingFrequency.BlockType = (ICDBlockType)reportingFrequency.blockType;
            offset += BlockTypeLen;

            reportingFrequency.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (reportingFrequency.BlockLengthIndicator == 0)
            {
              reportingFrequency.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              reportingFrequency.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            reportingFrequency.dataType = stream.GetUint(offset, DataTypeLen);
            reportingFrequency.DataType = (SynchronisationDataType)reportingFrequency.dataType;
            offset += DataTypeLen;

            reslt = DataBlock_ReportingFrequencyRate.TryParse(buff, offset, out reportingFrequency.data);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #7
0
        public static bool TryParse(byte[] buff, int baseoffset, out ICDMOMessageReduceHeader rheader)
        {
            rheader = new ICDMOMessageReduceHeader();
              bool reslt = false;
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);
            rheader.protocolType = stream.GetUint(offset, ProtocolTypeLen);
            if (rheader.protocolType == 102)
              rheader.ProtocolType = ICDProtocolType.p102;

            offset += ProtocolTypeLen;
            rheader.ProtocolVersionNumber = stream.GetUint(offset, ProtocolVersionNumberLen);

            offset += ProtocolVersionNumberLen;
            rheader.MOMessageType = stream.GetUint(offset, MOMessageTypeLen);
            rheader.MessageType = (ICDMOMessageType)rheader.MOMessageType;
            // continuar ...
            offset += MOMessageTypeLen;
            rheader.Timestamp = stream.GetUint(offset, TimestampLen);

            offset += TimestampLen;
            rheader.EmergencyFlag = stream.GetUint(offset, EmergencyFlagLen);

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #8
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_ProtocolType dataBlockProtocolType)
        {
            bool reslt = false;
              dataBlockProtocolType = new DataBlock_ProtocolType();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            dataBlockProtocolType.ProtocolType = stream.GetUint(offset, ProtocolTypeLen);
            offset += ProtocolTypeLen;

            dataBlockProtocolType.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            reslt = true;

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #9
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_ReducedLocation rlocation, int isReduced)
        {
            bool reslt = false;
              rlocation = new DataBlock_ReducedLocation();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);
            if (isReduced == 0)
            {
              rlocation.IsReduced = false;
              rlocation.blockType = stream.GetUint(offset, BlockTypeLen);
              rlocation.BlockType = (ICDBlockType)rlocation.blockType;
              offset += BlockTypeLen;

              rlocation.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
              offset += BlockLengthIndicatorLen;

              rlocation.BlockLengthBytes = stream.GetUint(offset, BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              rlocation.IsReduced = true;
              rlocation.BlockType = ICDBlockType.ReducedSizeLocation;
              rlocation.blockType = (uint)rlocation.BlockType;
            }
            rlocation.LatitudeHemisphere = stream.GetUint(offset, LatitudeHemisphereLen);
            offset += LatitudeHemisphereLen;

            rlocation.LatitudeDegrees = stream.GetUint(offset, LatitudeDegreesLen);
            offset += LatitudeDegreesLen;

            rlocation.LatitudeMinutes = stream.GetUint(offset, LatitudeMinutesLen);
            offset += LatitudeMinutesLen;

            rlocation.LatitudeMinutesDecimal = stream.GetUint(offset, LatitudeMinutesDecimalLen);
            offset += LatitudeMinutesDecimalLen;

            //seteamos la latitud
            if (rlocation.LatitudeHemisphere == 0)
              rlocation.position.Latitude.setValue((int)rlocation.LatitudeDegrees, (rlocation.LatitudeMinutes + (double)rlocation.LatitudeMinutesDecimal / 1000), "N");
            else
              rlocation.position.Latitude.setValue((int)rlocation.LatitudeDegrees, (rlocation.LatitudeMinutes + (double)rlocation.LatitudeMinutesDecimal / 1000), "S");
            //completar

            rlocation.LongitudeHemisphere = stream.GetUint(offset, LongitudeHemisphereLen);
            offset += LongitudeHemisphereLen;

            rlocation.LongitudeDegrees = stream.GetUint(offset, LongitudeDegreesLen);
            offset += LongitudeDegreesLen;

            rlocation.LongitudeMinutes = stream.GetUint(offset, LongitudeMinutesLen);
            offset += LatitudeMinutesLen;

            rlocation.LongitudeMinutesDecimal = stream.GetUint(offset, LongitudeMinutesDecimalLen);
            offset += LongitudeMinutesDecimalLen;

            //seteamos la longitud
            if (rlocation.LongitudeHemisphere == 0)
              rlocation.position.Longitude.setValue((int)rlocation.LongitudeDegrees, (rlocation.LongitudeMinutes + (double)rlocation.LongitudeMinutesDecimal / 1000), "E");
            else
              rlocation.position.Longitude.setValue((int)rlocation.LongitudeDegrees, (rlocation.LongitudeMinutes + (double)rlocation.LongitudeMinutesDecimal / 1000), "W");

            rlocation.IsValid = stream.GetUint(offset, IsValidLen);
            offset += IsValidLen;

            rlocation.SourceOfFix = stream.GetUint(offset, SourceOfFixLen);
            offset += SourceOfFixLen;

            rlocation.AgeOfGPSFix = stream.GetUint(offset, AgeOfGPSFixLen);
            offset += AgeOfGPSFixLen;

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #10
0
        //const int CannedMessageDataLengthBytes = 28;
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_CannedMessageData cannedMessageData)
        {
            bool reslt = false;
              cannedMessageData = new DataBlock_CannedMessageData();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            cannedMessageData.LanguageIdentifierFirstLetter = stream.GetUint(offset, LanguageIdentifierFirstLetterLen);
            offset += LanguageIdentifierFirstLetterLen;

            cannedMessageData.LanguageIdentifierSecondLetter = stream.GetUint(offset, LanguageIdentifierSecondLetterLen);

            byte[] bytes = Encoding.ASCII.GetBytes("a");
            bytes[0] += (byte)(cannedMessageData.LanguageIdentifierFirstLetter - 1);
            cannedMessageData.LanguageIdentifier = new string(Encoding.ASCII.GetChars(bytes));
            bytes = Encoding.ASCII.GetBytes("a");
            bytes[0] += (byte)(cannedMessageData.LanguageIdentifierSecondLetter - 1);
            cannedMessageData.LanguageIdentifier = string.Format("{0}{1}", cannedMessageData.LanguageIdentifier, new string(Encoding.ASCII.GetChars(bytes)));

            offset += LanguageIdentifierSecondLetterLen;

            cannedMessageData.CannedMessageNumber = stream.GetUint(offset, CannedMessageNumberLen);
            offset += CannedMessageNumberLen;

            cannedMessageData.IncludeLocation = stream.GetUint(offset, IncludeLocationLen);
            offset += IncludeLocationLen;

            cannedMessageData.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            cannedMessageData.CannedMessageLength = stream.GetUint(offset, CannedMessageLengthLen);
            offset += CannedMessageLengthLen;
            int boffset = (offset / 8);

            byte[] bit7buff = new byte[cannedMessageData.CannedMessageLength - 3];
            for (int i = 0; i < cannedMessageData.CannedMessageLength - 3; i++)
              bit7buff[i] = buff[i + boffset];
            cannedMessageData.CannedMessage = GsmUtils.FromGSM7BitPacked(bit7buff);
            reslt = true;

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #11
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_PortalStatus portalStatus)
        {
            bool reslt = false;
              portalStatus = new DataBlock_PortalStatus();
              try
              {
            int longitudMensajeBytes = 0;
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            portalStatus.blockType = stream.GetUint(offset, BlockTypeLen);

            portalStatus.BlockType = (ICDBlockType)portalStatus.blockType;
            offset += BlockTypeLen;

            portalStatus.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (portalStatus.BlockLengthIndicator == 0)
            {
              portalStatus.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              longitudMensajeBytes = (int)stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              portalStatus.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }

            portalStatus.Status = stream.GetUint(offset, StatusLen);
            offset += StatusLen;

            portalStatus.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            portalStatus.FreeTextLengthAndFreeText = stream.GetUint(offset, FreeTextLengthAndFreeTextLen);
            offset += FreeTextLengthAndFreeTextLen;
            int boffset = (offset / 8);

            //el EmergencyCallRecipient se saca del stream, la cantidad esta dada en el primer byte
            byte[] bit7buff = new byte[longitudMensajeBytes - 1];//[portalStatus.FreeTextLengthAndFreeText];
            for (int i = 0; i < longitudMensajeBytes - 1; i++)//portalStatus.FreeTextLengthAndFreeText
              bit7buff[i] = buff[i + boffset];
            portalStatus.FreeText = GsmUtils.FromGSM7BitPacked(bit7buff);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #12
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Polygon dataBlockPolygon)
        {
            bool reslt = false;
              dataBlockPolygon = new DataBlock_Polygon();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            dataBlockPolygon.blockType = stream.GetUint(offset, BlockTypeLen);

            dataBlockPolygon.BlockType = (ICDBlockType)dataBlockPolygon.blockType;
            offset += BlockTypeLen;

            dataBlockPolygon.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            dataBlockPolygon.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
            offset += BlockLengthBytesLen;

            dataBlockPolygon.AlertWhenCrossed = stream.GetUint(offset, AlertWhenCrossedLen);
            offset += AlertWhenCrossedLen;

            dataBlockPolygon.FenceHysteresisUnits = stream.GetUint(offset, FenceHysteresisUnitsLen);
            offset += FenceHysteresisUnitsLen;

            dataBlockPolygon.FenceHysteresis = stream.GetUint(offset, FenceHysteresisLen);
            offset += FenceHysteresisLen;

            dataBlockPolygon.FenceProximityUnits = stream.GetUint(offset, FenceProximityUnitsLen);
            offset += FenceProximityUnitsLen;

            dataBlockPolygon.FenceProximity = stream.GetUint(offset, FenceProximityLen);
            offset += FenceProximityLen;

            dataBlockPolygon.RefreshRateInMinutes = stream.GetUint(offset, RefreshRateInMinutesLen);
            offset += RefreshRateInMinutesLen;

            reslt = Point.TryParse(buff, offset, dataBlockPolygon.BlockLengthBytes, out dataBlockPolygon.listPoints);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #13
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_PhoneSettings phonesettings)
        {
            bool reslt = false;
              phonesettings = new DataBlock_PhoneSettings();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            phonesettings.blockType = stream.GetUint(offset, BlockTypeLen);

            phonesettings.BlockType = (ICDBlockType)phonesettings.blockType;
            offset += BlockTypeLen;

            phonesettings.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (phonesettings.BlockLengthIndicator == 0)
            {
              phonesettings.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              phonesettings.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }
            phonesettings.ReportingFrecuencyRate = stream.GetUint(offset, ReportingFrecuencyRateLen);
            offset += ReportingFrecuencyRateLen;

            phonesettings.ReportingFrecuencyRateUnits = stream.GetUint(offset, ReportingFrecuencyRateUnitsLen);
            offset += ReportingFrecuencyRateUnitsLen;

            phonesettings.EmergencyDestination = stream.GetUint(offset, EmergencyDestinationLen);
            offset += EmergencyDestinationLen;

            phonesettings.MessageEncoding = stream.GetUint(offset, MessageEncodingLen);
            offset += MessageEncodingLen;

            phonesettings.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            phonesettings.EmergencyCallRecipientLength = stream.GetUint(offset, EmergencyCallRecipientLengthLen);
            offset += EmergencyCallRecipientLengthLen;
            int boffset = (offset / 8);

            //el EmergencyCallRecipient se saca del stream, la cantidad esta dada en el primer byte
            byte[] bit7buff = new byte[phonesettings.EmergencyCallRecipientLength];
            for (int i = 0; i < phonesettings.EmergencyCallRecipientLength; i++)
              bit7buff[i] = buff[i + boffset];
            phonesettings.EmergencyCallRecipient = GsmUtils.FromGSM7BitPacked(bit7buff);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #14
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_MessageIdentifier messageIdentifier)
        {
            bool reslt = false;
              messageIdentifier = new DataBlock_MessageIdentifier();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            messageIdentifier.blockType = stream.GetUint(offset, BlockTypeLen);

            messageIdentifier.BlockType = (ICDBlockType)messageIdentifier.blockType;
            offset += BlockTypeLen;

            messageIdentifier.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            messageIdentifier.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
            offset += BlockLengthBytesLen;

            messageIdentifier.MessageIdentifier = stream.GetUint(offset, MessageIdentifierLen);
            offset += MessageIdentifierLen;

            reslt = true;

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #15
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_CannedMessageIdentifier cannedMessageIdentifier)
        {
            bool reslt = false;
              cannedMessageIdentifier = new DataBlock_CannedMessageIdentifier();

              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            cannedMessageIdentifier.blockType = stream.GetUint(offset, BlockTypeLen);

            cannedMessageIdentifier.BlockType = (ICDBlockType)cannedMessageIdentifier.blockType;
            offset += BlockTypeLen;

            cannedMessageIdentifier.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (cannedMessageIdentifier.BlockLengthIndicator == 0)
            {
              cannedMessageIdentifier.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              cannedMessageIdentifier.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }
            cannedMessageIdentifier.CannedMessageNumber = stream.GetUint(offset, CannedMessageNumberLen);
            offset += CannedMessageNumberLen;

            cannedMessageIdentifier.cannedMessageCRC = stream.GetUint(offset, CannedMessageCRCLen);
            offset += CannedMessageCRCLen;

            try
            {
              Encoding unicode = Encoding.Unicode;
              Encoding utf8 = Encoding.UTF8;
              string s = "I have achieved my objective";
              //string s = "123456789";
              //var barray = GsmUtils.ToGSM7BitPacked(s);
             // byte[] array = HexAscii.ConvertToBytes(barray);

              byte[] array = HexAscii.ConvertToBytes("1C49103A6C2F83C26374BA6C2F9341ED3CE82D5697C7F4B4BD0C");
              //byte[] barray = GetBytes(s);

              //1C49103A6C2F83C26374BA6C2F9341ED3CE82D5697C7F4B4BD0C
              crc_32c crc32 = new crc_32c();
              uint crcVar = 0;
              /*ASCII*/
              //array = Encoding.Convert(unicode, utf8, array);
              crcVar = crc32.crc_32c_init();
              crcVar = crc32.crc_32c_update(array, array.Length, crcVar);
              crcVar = crc32.crc_32c_finalize(crcVar);
              /*UTF-16*/
              //array = Encoding.Convert(unicode, utf8, array);
              //crcVar = crc32.crc_32c_init();
              //crcVar = crc32.crc_32c_update_UTF_16(array, array.Length, crcVar);
              //crcVar = crc32.crc_32c_finalize(crcVar);

              //CRC (ASCII): 0xe3069283
              //CRC (UTF-16): 0x9d7b210c
              string imei = "300015010444890";
              byte[] imeib = GetBytes(imei);
              imeib = Encoding.Convert(unicode, utf8, imeib);

              crc_32c hash = new crc_32c();
              uint hashvar = hash.toHash2(imeib, imeib.Length);
            }
            catch (Exception e) { }

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }

              return reslt;
        }
Пример #16
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_ReportingFrequencyRate reportingFrequencyRate)
        {
            bool reslt = false;
              reportingFrequencyRate = new DataBlock_ReportingFrequencyRate();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            reportingFrequencyRate.ReportingFrecuencyRate = stream.GetUint(offset, ReportingFrecuencyRateLen);
            offset += ReportingFrecuencyRateLen;

            reportingFrequencyRate.ReportingFrecuencyRateUnits = stream.GetUint(offset, ReportingFrecuencyRateUnitsLen);
            offset += ReportingFrecuencyRateUnitsLen;

            reportingFrequencyRate.Units = (RateUnits)reportingFrequencyRate.ReportingFrecuencyRateUnits;

            reslt = true;

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #17
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationProtocolType protocolType)
        {
            bool reslt = false;
              protocolType = new DataBlock_SynchronisationProtocolType();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            protocolType.blockType = stream.GetUint(offset, BlockTypeLen);

            protocolType.BlockType = (ICDBlockType)protocolType.blockType;
            offset += BlockTypeLen;

            protocolType.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (protocolType.BlockLengthIndicator == 0)
            {
              protocolType.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              protocolType.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            protocolType.dataType = stream.GetUint(offset, DataTypeLen);
            protocolType.DataType = (SynchronisationDataType)protocolType.dataType;
            offset += DataTypeLen;

            reslt = DataBlock_ProtocolType.TryParse(buff, offset, out protocolType.data);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #18
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Sender sender)
        {
            bool reslt = false;
              sender = new DataBlock_Sender();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            sender.blockType = stream.GetUint(offset, BlockTypeLen);

            sender.BlockType = (ICDBlockType)sender.blockType;
            offset += BlockTypeLen;

            sender.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (sender.BlockLengthIndicator == 0)
            {
              sender.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              sender.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }
            sender.SenderLengthAndSender = stream.GetUint(offset, SenderLengthAndSenderLen);
            offset += SenderLengthAndSenderLen;
            int boffset = (offset / 8);

            //el EmergencyCallRecipient se saca del stream, la cantidad esta dada en el primer byte
            byte[] bit7buff = new byte[sender.SenderLengthAndSender];
            for (int i = 0; i < sender.SenderLengthAndSender; i++)
              bit7buff[i] = buff[i + boffset];
            sender.Sender = GsmUtils.FromGSM7BitPacked(bit7buff);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #19
0
        //The message body for a Mobile Originated message consists of zero or more Data Blocks. Some message types have mandatory Data Blocks. Optionally, additional data blocks may be included for any message type.
        public static bool TryParse(byte[] buff, int offset, ICDMOPacket packet1, out ICDMOPacket packet)
        {
            bool flag = false;
              bool reslt = false;
              packet = packet1;
              packet.body = new ICDMOMessageBody();
              ICDMOMessageType type = ICDMOMessageType.Unknown;
              if (packet.header != null)
            type = packet.header.MessageType;
              else if (packet.rheader != null)
            type = packet.rheader.MessageType;

              int boffset = offset;
              net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);
              uint blockType = 0;
              if (packet.header != null)
              {
            // blockType = stream.GetUint(ICDMessageStandardHeader.HeaderLen, DataBlock_Location.BlockTypeLen);
            boffset = ICDMOMessageStandardHeader.HeaderLen;
              }
              else if (packet.rheader != null)
              {
            // blockType = stream.GetUint(ICDMessageReduceHeader.HeaderLen, DataBlock_ReducedLocation.BlockTypeLen);
            boffset = ICDMOMessageReduceHeader.HeaderLen;
              }
              while (boffset < buff.Length * 8 && flag == false)
              {
            blockType = stream.GetUint(boffset, ICDDataBlock.BlockTypeLen);

            switch (blockType)
            {
              case 0:
                DataBlock_Location location;
                if (DataBlock_Location.TryParse(buff, boffset, out location))
                {
                  packet.body.datablocks.Add(location);
                  boffset += DataBlock_Location.LocationLenBytes * 8;
                }
                break;
              case 0x01:
                DataBlock_FreeText freetext;
                if (DataBlock_FreeText.TryParse(buff, boffset, out freetext))
                {
                  packet.body.datablocks.Add(freetext);
                  boffset += DataBlock_FreeText.BlockTypeLen * 8;
                }
                break;
              case 0x0E:
                int isReduced = 0;
                DataBlock_ReducedLocation rlocation;
                if (DataBlock_ReducedLocation.TryParse(buff, boffset, out rlocation, isReduced))
                {
                  //DataBlock_ReducedLocation.ToBytes(isReduced, rlocation);
                  packet.body.datablocks.Add(rlocation);
                  boffset += DataBlock_ReducedLocation.ReducedLocationLenBytes * 8;
                }
                break;
              case 0x34:
                isReduced = 1;
                DataBlock_ReducedLocation rminlocation;
                if (DataBlock_ReducedLocation.TryParse(buff, ICDMOMessageReduceHeader.HeaderLen, out rminlocation, isReduced))
                {
                  packet.body.datablocks.Add(rminlocation);
                  boffset += DataBlock_ReducedLocation.ReducedLocationLenBytes * 8;
                }
                break;
              case 0x0a:
                //int isReduced = 0;
                DataBlock_PhoneSettings phonesettings;
                if (DataBlock_PhoneSettings.TryParse(buff, boffset, out phonesettings))
                {
                  //DataBlock_ReducedLocation.ToBytes(isReduced, rlocation);
                  packet.body.datablocks.Add(phonesettings);
                  boffset += phonesettings.PhoneSettingsLenBytes * 8;
                }
                break;
              case 0x0c:
                //int isReduced = 0;
                DataBlock_CannedMessagesHash cannedMessageHash;
                if (DataBlock_CannedMessagesHash.TryParse(buff, boffset, out cannedMessageHash))
                {
                  //DataBlock_ReducedLocation.ToBytes(isReduced, rlocation);
                  packet.body.datablocks.Add(cannedMessageHash);
                  boffset += DataBlock_CannedMessagesHash.CannedMessagesHashLenBytes * 8;
                }
                break;
              case 0x10:
                //int isReduced = 0;
                DataBlock_DistributionListHash distributionListHash;
                if (DataBlock_DistributionListHash.TryParse(buff, boffset, out distributionListHash))
                {
                  //DataBlock_ReducedLocation.ToBytes(isReduced, rlocation);
                  packet.body.datablocks.Add(distributionListHash);
                  boffset += DataBlock_DistributionListHash.DistributionListHashLenBytes * 8;
                }
                break;
              case 0x12:
                //int isReduced = 0;
                DataBlock_HandsetFwHwVersion handsetFirmwareHardwareVersion;
                if (DataBlock_HandsetFwHwVersion.TryParse(buff, boffset, out handsetFirmwareHardwareVersion))
                {
                  //DataBlock_ReducedLocation.ToBytes(isReduced, rlocation);
                  packet.body.datablocks.Add(handsetFirmwareHardwareVersion);
                  boffset += handsetFirmwareHardwareVersion.HandsetFwHwVersionLenBytes * 8;
                }
                break;
              case 0x03:
                while (boffset < buff.Length * 8)
                {
                  DataBlock_Synchronisation synchronisation;
                  if (DataBlock_Synchronisation.TryParse(buff, boffset, out synchronisation))
                  {
                    packet.body.datablocks.Add(synchronisation);
                    boffset += synchronisation.SynchronisationLenBytes * 8;
                  }
                }
                break;
              case 0x09:
                DataBlock_PortalStatus portalStatus;
                if (DataBlock_PortalStatus.TryParse(buff, boffset, out portalStatus))
                {
                  packet.body.datablocks.Add(portalStatus);
                  boffset += portalStatus.PortalStatusLenBytes * 8;
                }
                break;
              case 0x0d:
                DataBlock_PortalProviderInformation portalProviderInformation;
                if (DataBlock_PortalProviderInformation.TryParse(buff, boffset, out portalProviderInformation))
                {
                  packet.body.datablocks.Add(portalProviderInformation);
                  boffset += portalProviderInformation.PortalProviderInformationLenBytes * 8;
                }
                break;
              case 0x02:
                DataBlock_Recipient recipient;
                if (DataBlock_Recipient.TryParse(buff, boffset, out recipient))
                {
                  packet.body.datablocks.Add(recipient);
                  boffset += recipient.RecipientLenBytes * 8;
                }
                break;
              case 0x04:
                DataBlock_DeviceIdentifier deviceIdentifier;
                if (DataBlock_DeviceIdentifier.TryParse(buff, boffset, out deviceIdentifier))
                {
                  packet.body.datablocks.Add(deviceIdentifier);
                  boffset += deviceIdentifier.DeviceIdentifierLenBytes * 8;
                }
                break;
              case 0x05:
                DataBlock_Diagnostics diagnostics;
                if (DataBlock_Diagnostics.TryParse(buff, boffset, out diagnostics))
                {
                  packet.body.datablocks.Add(diagnostics);
                  boffset += diagnostics.DiagnosticsLenBytes * 8;
                }
                break;
              case 0x06:
                DataBlock_Sender sender;
                if (DataBlock_Sender.TryParse(buff, boffset, out sender))
                {
                  packet.body.datablocks.Add(sender);
                  boffset += sender.SenderLenBytes * 8;
                }
                break;
              case 0x07:
                DataBlock_Circle circle;
                if (DataBlock_Circle.TryParse(buff, boffset, out circle))
                {
                  packet.body.datablocks.Add(circle);
                  boffset += (int)circle.BlockLengthBytes * 8;
                }
                break;

              //POLYGON//
              case 0x08:
                DataBlock_Polygon polygon;
                if (DataBlock_Polygon.TryParse(buff, boffset, out polygon))
                {
                  packet.body.datablocks.Add(polygon);
                  boffset += (int)polygon.BlockLengthBytes * 8;
                }
                break;

              case 0x11:
                DataBlock_GeofenceStatus geofenceStatus;
                if (DataBlock_GeofenceStatus.TryParse(buff, boffset, out geofenceStatus))
                {
                  packet.body.datablocks.Add(geofenceStatus);
                  boffset += (int)geofenceStatus.BlockLengthBytes * 8;
                }
                break;
              case 0x0F:
                DataBlock_CannedMessageIdentifier cannedmessage;
                if (DataBlock_CannedMessageIdentifier.TryParse(buff, boffset, out cannedmessage))
                {
                  packet.body.datablocks.Add(cannedmessage);
                  boffset += (int)cannedmessage.BlockLengthBytes * 8;
                }
                break;
              case 0x17:
                DataBlock_MessageIdentifier messageIdentifier;
                if (DataBlock_MessageIdentifier.TryParse(buff, boffset, out messageIdentifier))
                {
                  packet.body.datablocks.Add(messageIdentifier);
                  boffset += (int)messageIdentifier.BlockLengthBytes * 8;
                }
                break;
              default:
                flag = true;
                break;
            }
              }

            /*
              case ICDMOMessageType.UserExtensions:
            break;
              case ICDMOMessageType.Reserved:
            break;
             */
              //}
              reslt = true;
              return reslt;
        }
Пример #20
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Synchronisation synchronisation)
        {
            bool reslt = false;
              synchronisation = new DataBlock_Synchronisation();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            int boffset = offset;

            synchronisation.blockType = stream.GetUint(offset, BlockTypeLen);

            synchronisation.BlockType = (ICDBlockType)synchronisation.blockType;
            offset += BlockTypeLen;

            synchronisation.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (synchronisation.BlockLengthIndicator == 0)
            {
              synchronisation.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              synchronisation.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }
            synchronisation.dataType = stream.GetUint(offset, DataTypeLen);
            synchronisation.DataType = (SynchronisationDataType)synchronisation.dataType;

            switch (synchronisation.DataType)
            {
              case SynchronisationDataType.CannedMessage:
            DataBlock_SynchronisationCannedMessage temp = new DataBlock_SynchronisationCannedMessage();
            reslt = DataBlock_SynchronisationCannedMessage.TryParse(buff, baseoffset, out temp);
            synchronisation = temp;
            break;
              case SynchronisationDataType.DistributionlistClearAll:
              case SynchronisationDataType.DistributionListClear:
              case SynchronisationDataType.DistributionListAdd:
            DataBlock_SynchronisationDistributionList temp2 = new DataBlock_SynchronisationDistributionList();
            reslt = DataBlock_SynchronisationDistributionList.TryParse(buff, baseoffset, out temp2);
            synchronisation = temp2;
            break;
              case SynchronisationDataType.AddressBookEntry:
            DataBlock_SynchronisationAddressBook temp3 = new DataBlock_SynchronisationAddressBook();
            reslt = DataBlock_SynchronisationAddressBook.TryParse(buff, baseoffset, out temp3);
            synchronisation = temp3;
            break;
              case SynchronisationDataType.EmergencyDestination:
            DataBlock_SynchronisationEmergencyDestination temp4 = new DataBlock_SynchronisationEmergencyDestination();
            reslt = DataBlock_SynchronisationEmergencyDestination.TryParse(buff, baseoffset, out temp4);
            synchronisation = temp4;
            break;
              case SynchronisationDataType.EmergencyCallRecipient:
            DataBlock_SynchronisationEmergencyCallRecipient temp5 = new DataBlock_SynchronisationEmergencyCallRecipient();
            reslt = DataBlock_SynchronisationEmergencyCallRecipient.TryParse(buff, baseoffset, out temp5);
            synchronisation = temp5;
            break;
              case SynchronisationDataType.GPSFrequencyRate:
            DataBlock_SynchronisationReportingFrequencyRate temp6 = new DataBlock_SynchronisationReportingFrequencyRate();
            reslt = DataBlock_SynchronisationReportingFrequencyRate.TryParse(buff, baseoffset, out temp6);
            synchronisation = temp6;
            break;
              case SynchronisationDataType.ProtocolType:
            DataBlock_SynchronisationProtocolType temp7 = new DataBlock_SynchronisationProtocolType();
            reslt = DataBlock_SynchronisationProtocolType.TryParse(buff, baseoffset, out temp7);
            synchronisation = temp7;
            break;
              default:
            break;
            }

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #21
0
        public static bool TryParse(byte[] buff, int baseoffset, out ICDMOMessageStandardHeader header)
        {
            header = new ICDMOMessageStandardHeader();
              bool reslt = false;
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);
            header.protocolType = stream.GetUint(offset, ProtocolTypeLen);
            if (header.protocolType == 102)
              header.ProtocolType = ICDProtocolType.p102;

            offset += ProtocolTypeLen;
            header.ProtocolVersionNumber = stream.GetUint(offset, ProtocolVersionNumberLen);

            offset += ProtocolVersionNumberLen;
            header.LanguageIdentifierFirstLetter = stream.GetUint(offset, LanguageIdentifierFirstLetterLen);

            offset += LanguageIdentifierFirstLetterLen;
            header.LanguageIdentifierSecondLetter = stream.GetUint(offset, LanguageIdentifierSecondLetterLen);
            byte[] bytes = Encoding.ASCII.GetBytes("a");
            bytes[0] += (byte)(header.LanguageIdentifierFirstLetter - 1);
            header.LanguageIdentifier = new string(Encoding.ASCII.GetChars(bytes));
            bytes = Encoding.ASCII.GetBytes("a");
            bytes[0] += (byte)(header.LanguageIdentifierSecondLetter - 1);
            header.LanguageIdentifier = string.Format("{0}{1}", header.LanguageIdentifier, new string(Encoding.ASCII.GetChars(bytes)));

            offset += LanguageIdentifierSecondLetterLen;
            header.MOMessageType = stream.GetUint(offset, MOMessageTypeLen);
            header.MessageType = (ICDMOMessageType)header.MOMessageType;

            offset += MOMessageTypeLen;
            header.SequenceNumber = stream.GetUint(offset, SequenceNumberLen);

            offset += SequenceNumberLen;
            header.TimestampUTCYear = stream.GetUint(offset, TimestampUTCYearLen);

            offset += TimestampUTCYearLen;
            header.TimestampUTCMonth = stream.GetUint(offset, TimestampUTCMonthLen);

            offset += TimestampUTCMonthLen;
            header.TimestampUTCDay = stream.GetUint(offset, TimestampUTCDayLen);

            offset += TimestampUTCDayLen;
            header.TimestampUTCHours = stream.GetUint(offset, TimestampUTCHoursLen);

            offset += TimestampUTCHoursLen;
            header.TimestampUTCMinutes = stream.GetUint(offset, TimestampUTCMinutesLen);

            offset += TimestampUTCMinutesLen;
            header.TimestampUTCSeconds = stream.GetUint(offset, TimestampUTCSecondsLen);

            offset += TimestampUTCSecondsLen;
            header.EmergencyFlag = stream.GetUint(offset, EmergencyFlagLen);

            offset += EmergencyFlagLen;
            header.Spare = stream.GetUint(offset, SpareLen);

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #22
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationAddressBook addressBook)
        {
            bool reslt = false;
              addressBook = new DataBlock_SynchronisationAddressBook();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            addressBook.blockType = stream.GetUint(offset, BlockTypeLen);

            addressBook.BlockType = (ICDBlockType)addressBook.blockType;
            offset += BlockTypeLen;

            addressBook.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (addressBook.BlockLengthIndicator == 0)
            {
              addressBook.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              addressBook.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            addressBook.dataType = stream.GetUint(offset, DataTypeLen);
            addressBook.DataType = (SynchronisationDataType)addressBook.dataType;
            offset += DataTypeLen;

            reslt = DataBlock_AddressBook.TryParse(buff, offset, out addressBook.data);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #23
0
        public static bool TryParse(byte[] buff, int baseoffset, out ICDMTMessageStandardHeader header)
        {
            header = new ICDMTMessageStandardHeader();
              bool reslt = false;
              try
              {
            int offset = baseoffset;
            BitStream stream = new BitStream(buff);
            header.protocolType = stream.GetUint(offset, ProtocolTypeLen);
            offset += ProtocolTypeLen;

            header.ProtocolVersionNumber = stream.GetUint(offset, ProtocolVersionNumberLen);
            offset += ProtocolVersionNumberLen;

            header.messageType = stream.GetUint(offset, MTMessageTypeLen);
            header.MessageType = (ICDMTMessageType)header.messageType;
            offset += MTMessageTypeLen;

            header.MessageIdentifier = stream.GetUint(offset, MessageIdentifierLen);
            offset = MessageIdentifierLen;

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #24
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationCannedMessage canned)
        {
            bool reslt = false;
              canned = new DataBlock_SynchronisationCannedMessage();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            canned.blockType = stream.GetUint(offset, BlockTypeLen);

            canned.BlockType = (ICDBlockType)canned.blockType;
            offset += BlockTypeLen;

            canned.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (canned.BlockLengthIndicator == 0)
            {
              canned.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              canned.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            canned.dataType = stream.GetUint(offset, DataTypeLen);
            canned.DataType = (SynchronisationDataType)canned.dataType;
            offset += DataTypeLen;

            reslt = DataBlock_CannedMessageData.TryParse(buff, offset, out canned.data);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #25
0
        public static bool TryParse(byte[] buff, int baseoffset, uint BlockLengthBytes, out List<Point> listPoints)
        {
            bool reslt = false;
              listPoints = new List<Point>();
              int points = 0;
              try
              {
            int offset = baseoffset;
            int tempOffset = 0;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            switch ((int)BlockLengthBytes)
            {
              case 24:
            points = 3;
            break;
              case 30:
            points = 4;
            break;
              case 36:
            points = 5;
            break;
              case 42:
            points = 6;
            break;
              case 48:
            points = 7;
            break;
              case 54:
            points = 8;
            break;
            }

            for (int i = 0; i < points; i++)
            {
              Point point = new Point();
              if (tempOffset != 0)
              {
            offset = tempOffset;
              }
              point.LatitudeHemisphere = stream.GetUint(offset, LatitudeHemisphereLen);
              offset += LatitudeHemisphereLen;

              point.LatitudeDegrees = stream.GetUint(offset, LatitudeDegreesLen);
              offset += LatitudeDegreesLen;

              point.LatitudeMinutes = stream.GetUint(offset, LatitudeMinutesLen);
              offset += LatitudeMinutesLen;

              point.LatitudeMinutesDecimal = stream.GetUint(offset, LatitudeMinutesDecimalLen);
              offset += LatitudeMinutesDecimalLen;

              if (point.LatitudeHemisphere == 0)
            point.position.Latitude.setValue((int)point.LatitudeDegrees, (point.LatitudeMinutes + (double)point.LatitudeMinutesDecimal / 1000), "N");
              else
            point.position.Latitude.setValue((int)point.LatitudeDegrees, (point.LatitudeMinutes + (double)point.LatitudeMinutesDecimal / 1000), "N");

              point.LongitudeHemisphere = stream.GetUint(offset, LongitudeHemisphereLen);
              offset += LongitudeHemisphereLen;

              point.LongitudeDegrees = stream.GetUint(offset, LongitudeDegreesLen);
              offset += LongitudeDegreesLen;

              point.LongitudeMinutesDecimal = stream.GetUint(offset, LongitudeMinutesDecimalLen);
              offset += LongitudeMinutesDecimalLen;

              if (point.LongitudeHemisphere == 0)
            point.position.Longitude.setValue((int)point.LongitudeDegrees, (point.LongitudeMinutes + (double)point.LongitudeMinutesDecimal / 1000), "E");
              else
            point.position.Longitude.setValue((int)point.LongitudeDegrees, (point.LongitudeMinutes + (double)point.LongitudeMinutesDecimal / 1000), "W");

              tempOffset = offset;
              listPoints.Add(point);
            }

            reslt = true;

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #26
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationDistributionList distributionList)
        {
            bool reslt = false;
              distributionList = new DataBlock_SynchronisationDistributionList();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            distributionList.blockType = stream.GetUint(offset, BlockTypeLen);

            distributionList.BlockType = (ICDBlockType)distributionList.blockType;
            offset += BlockTypeLen;

            distributionList.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (distributionList.BlockLengthIndicator == 0)
            {
              distributionList.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              distributionList.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            distributionList.dataType = stream.GetUint(offset, DataTypeLen);
            distributionList.DataType = (SynchronisationDataType)distributionList.dataType;
            offset += DataTypeLen;
            if ((SynchronisationDataType)distributionList.dataType == SynchronisationDataType.DistributionlistClearAll)
            {
              reslt = true;
            }
            else
            {
              reslt = DataBlock_DistributionList.TryParse(buff, offset, out distributionList.data);
            }
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #27
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Circle dataBlockCircle)
        {
            bool reslt = false;
              dataBlockCircle = new DataBlock_Circle();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            dataBlockCircle.blockType = stream.GetUint(offset, BlockTypeLen);

            dataBlockCircle.BlockType = (ICDBlockType)dataBlockCircle.blockType;
            offset += BlockTypeLen;

            dataBlockCircle.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            dataBlockCircle.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
            offset += BlockLengthBytesLen;

            dataBlockCircle.AlertWhenCrossed = stream.GetUint(offset, AlertWhenCrossedLen);
            offset += AlertWhenCrossedLen;

            dataBlockCircle.FenceHysteresisUnits = stream.GetUint(offset, FenceHysteresisUnitsLen);
            offset += FenceHysteresisUnitsLen;

            dataBlockCircle.FenceHysteresis = stream.GetUint(offset, FenceHysteresisLen);
            offset += FenceHysteresisLen;

            dataBlockCircle.FenceProximityUnits = stream.GetUint(offset, FenceProximityUnitsLen);
            offset += FenceProximityUnitsLen;

            dataBlockCircle.FenceProximity = stream.GetUint(offset, FenceProximityLen);
            offset += FenceProximityLen;

            dataBlockCircle.RefreshRateInMinutes = stream.GetUint(offset, RefreshRateInMinutesLen);
            offset += RefreshRateInMinutesLen;

            dataBlockCircle.LatitudeHemisphere = stream.GetUint(offset, LatitudeHemisphereLen);
            offset += LatitudeHemisphereLen;

            dataBlockCircle.LatitudeDegrees = stream.GetUint(offset, LatitudeDegreesLen);
            offset += LatitudeDegreesLen;

            dataBlockCircle.LatitudeMinutes = stream.GetUint(offset, LatitudeMinutesLen);
            offset += LatitudeMinutesLen;

            dataBlockCircle.LatitudeMinutesDecimal = stream.GetUint(offset, LatitudeMinutesDecimalLen);
            offset += LatitudeMinutesDecimalLen;

            if (dataBlockCircle.LatitudeHemisphere == 0)
              dataBlockCircle.position.Latitude.setValue((int)dataBlockCircle.LatitudeDegrees, (dataBlockCircle.LatitudeMinutes + (double)dataBlockCircle.LatitudeMinutesDecimal / 1000), "N");
            else
              dataBlockCircle.position.Latitude.setValue((int)dataBlockCircle.LatitudeDegrees, (dataBlockCircle.LatitudeMinutes + (double)dataBlockCircle.LatitudeMinutesDecimal / 1000), "N");

            dataBlockCircle.LongitudeHemisphere = stream.GetUint(offset, LongitudeHemisphereLen);
            offset += LongitudeHemisphereLen;

            dataBlockCircle.LongitudeDegrees = stream.GetUint(offset, LongitudeDegreesLen);
            offset += LongitudeDegreesLen;

            dataBlockCircle.RefreshRateInMinutes = stream.GetUint(offset, RefreshRateInMinutesLen);
            offset += RefreshRateInMinutesLen;

            dataBlockCircle.LongitudeMinutesDecimal = stream.GetUint(offset, LongitudeMinutesDecimalLen);
            offset += LongitudeMinutesDecimalLen;

            if (dataBlockCircle.LongitudeHemisphere == 0)
              dataBlockCircle.position.Longitude.setValue((int)dataBlockCircle.LongitudeDegrees, (dataBlockCircle.LongitudeMinutes + (double)dataBlockCircle.LongitudeMinutesDecimal / 1000), "E");
            else
              dataBlockCircle.position.Longitude.setValue((int)dataBlockCircle.LongitudeDegrees, (dataBlockCircle.LongitudeMinutes + (double)dataBlockCircle.LongitudeMinutesDecimal / 1000), "W");

            dataBlockCircle.RadiusMeasurement = stream.GetUint(offset, RadiusMeasurementLen);
            offset += RadiusMeasurementLen;

            dataBlockCircle.RadiusLength = stream.GetUint(offset, RadiusLengthLen);
            offset += RadiusLengthLen;

            dataBlockCircle.Spare = stream.GetUint(offset, SpareLen);
            offset += SpareLen;

            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #28
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_SynchronisationEmergencyDestination emergencyDestination)
        {
            bool reslt = false;
              emergencyDestination = new DataBlock_SynchronisationEmergencyDestination();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            emergencyDestination.blockType = stream.GetUint(offset, BlockTypeLen);

            emergencyDestination.BlockType = (ICDBlockType)emergencyDestination.blockType;
            offset += BlockTypeLen;

            emergencyDestination.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (emergencyDestination.BlockLengthIndicator == 0)
            {
              emergencyDestination.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              emergencyDestination.BlockLengthBytes = stream.GetUint(offset, DataBlock_Synchronisation.BlockLengthExtendedBytesLen);
              offset += DataBlock_Synchronisation.BlockLengthExtendedBytesLen;
            }

            emergencyDestination.dataType = stream.GetUint(offset, DataTypeLen);
            emergencyDestination.DataType = (SynchronisationDataType)emergencyDestination.dataType;
            offset += DataTypeLen;

            reslt = DataBlock_EmergencyDestination.TryParse(buff, offset, out emergencyDestination.data);

              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #29
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_Diagnostics diagnostics)
        {
            bool reslt = false;
              diagnostics = new DataBlock_Diagnostics();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            diagnostics.blockType = stream.GetUint(offset, BlockTypeLen);

            diagnostics.BlockType = (ICDBlockType)diagnostics.blockType;
            offset += BlockTypeLen;

            diagnostics.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            if (diagnostics.BlockLengthIndicator == 0)
            {
              diagnostics.BlockLengthBytes = stream.GetUint(offset, ICDDataBlock.BlockLengthBytesLen);
              offset += BlockLengthBytesLen;
            }
            else
            {
              diagnostics.BlockLengthBytes = stream.GetUint(offset, BlockLengthExtendedBytesLen);
              offset += BlockLengthExtendedBytesLen;
            }

            diagnostics.BatteryVoltage = stream.GetUint(offset, BatteryVoltageLen);
            offset += BatteryVoltageLen;

            diagnostics.ChargerStatus = stream.GetUint(offset, ChargerStatusLen);
            offset += ChargerStatusLen;

            diagnostics.AccumulatorRange = stream.GetUint(offset, AccumulatorRangeLen);
            offset += AccumulatorRangeLen;

            diagnostics.VisibleGPSSatellites = stream.GetUint(offset, VisisbleGPSSatellitesLen);
            offset += AccumulatorRangeLen;

            reslt = _FreeText.TryParse(buff, offset, out diagnostics.FreeText);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }
Пример #30
0
        public static bool TryParse(byte[] buff, int baseoffset, out DataBlock_HandsetFwHwVersion handsetFwHwVersion)
        {
            bool reslt = false;
              handsetFwHwVersion = new DataBlock_HandsetFwHwVersion();
              try
              {
            int offset = baseoffset;
            net.Tesacom.GeneralUtilities.BitStream stream = new net.Tesacom.GeneralUtilities.BitStream(buff);

            handsetFwHwVersion.blockType = stream.GetUint(offset, BlockTypeLen);

            handsetFwHwVersion.BlockType = (ICDBlockType)handsetFwHwVersion.blockType;
            offset += BlockTypeLen;

            handsetFwHwVersion.BlockLengthIndicator = stream.GetUint(offset, BlockLengthIndicatorLen);
            offset += BlockLengthIndicatorLen;

            handsetFwHwVersion.BlockLengthBytes = stream.GetUint(offset, BlockLengthBytesLen);
            offset += BlockLengthBytesLen;

            reslt = _FreeText.TryParse(buff, offset, out handsetFwHwVersion.FreeText);
            reslt = true;
              }
              catch (Exception ex) { reslt = false; }
              return reslt;
        }