SafeDispatch/LibrarySDR/LIPDecoder.cs

4047 lines
181 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using LibrarySDR.Enums;
using LibrarySDR.Responses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibrarySDR
{
public class LIPDecoder
{
#region VARIABLES FOR SEND INITIALIZATION REQUEST RESPOND
public bool init_request = false;
public bool terminal_id = false;
public string pDUTypeBinaryValue;
public string pDUTypeExtensionBinaryValue;
public string timeTypeBinaryValue;
public string timeElapsedBinaryValue;
public string timePositionDayBinaryValue;
public string timePositionHourBinaryValue;
public string timePositionMinuteBinaryValue;
public string timePositionSecondBinaryValue;
public string locationShapeBinaryValue;
public string longitudeBinaryValue;
public string latitudeBinaryValue;
public string positionErrorBinaryValue;
public string horizontalPositionUncertaintyBinaryValue;
public string horizontalVelocityBinaryValue;
public string horizontalVelocityUncertaintyBinaryValue;
public string verticalVelocityUncertaintyBinaryValue;
public string verticalVelocitySignBinaryValue;
public string verticalVelocityBinaryValue;
public string halfOfMajorAxisBinaryValue;
public string halfOfMinorAxisBinaryValue;
public string angleBinaryValue;
public string locationAltitudeBinaryValue;
public string confidentLevelBinaryValue;
public string locationAltitudeAccuracyBinaryValue;
public string directionOfTravelBinaryValue;
public string typeOfAdditionalDataBinaryValue;
public string reasonForSendingBinaryValue;
public string innerRadiusBinaryValue;
public string outerRadiusBinaryValue;
public string startAngleBinaryValue;
public string stopAngleBinaryValue;
public string velocityTypeBinaryValue;
public string directionOfTravelExtendedBinaryValue;
public string directionOfTravelUncertaintyBinaryValue;
public string acknowledgementRequestBinaryValue;
public string extendedUserDefinedDataBinaryValue;
public string locationMessageReferenceBinaryValue;
public string resultCodeBinaryValue;
public string sDSType1ValueBinaryValue;
public string statusValueBinaryValue;
public string maximumInformationAgeBinaryValue;
public string maximumResponseTimeBinaryValue;
public string startTimeBinaryValue;
public string stopTimeBinaryValue;
public string startTimeDayBinaryValue;
public string startTimeHourBinaryValue;
public string startTimeMinuteBinaryValue;
public string startTimeSecondBinaryValue;
public string stopTimeDayBinaryValue;
public string stopTimeHourBinaryValue;
public string stopTimeMinuteBinaryValue;
public string stopTimeSecondBinaryValue;
public string requestPriorityBinaryValue;
public string directionOfTravelReturnValueBinaryValue;
public string directionOfTravelRequestedOrRequiredBinaryValue;
public string horizontalPositionReturnValueBinaryValue;
public string horizontalPositionRequestedOrRequiredBinaryValue;
public string horizontalVelocityReturnValueBinaryValue;
public string horizontalVelocityRequestedOrRequiredBinaryValue;
public string locationAltitudeReturnValueBinaryValue;
public string locationAltitudeRequestedOrRequiredBinaryValue;
public string verticalVelocityReturnValueBinaryValue;
public string verticalVelocityRequestedOrRequiredBinaryValue;
public string directionOfTravelAccuracyBinaryValue;
public string preferredShapeBinaryValue;
public string horizontalPositionAccuracyBinaryValue;
public string horizontalVelocityAccuracyBinaryValue;
public string locationAltitudeTypeBinaryValue;
public string verticalVelocityAccuracyBinaryValue;
public string triggerDefinitionBinaryValue;
public string oneshot_recurringBinaryValue;
public string locationReportingEnableFlagsBinaryValue;
public string reportingTypeBinaryValue;
public string minimumReportingIntervalBinaryValue;
public string type5ElementIdentifierBinaryValue;
public string type5ElementLengthBinaryValue;
public string type5DataBinaryValue;
public string type5ElementIdentifierBinaryValue1;
public string type5ElementLengthBinaryValue1;
public string type5DataBinaryValue1;
public string type5ElementIdentifierBinaryValue2;
public string type5ElementLengthBinaryValue2;
public string type5DataBinaryValue2;
public string type5ElementIdentifierBinaryValue3;
public string type5ElementLengthBinaryValue3;
public string type5DataBinaryValue3;
public string type5ElementIdentifierBinaryValue4;
public string type5ElementLengthBinaryValue4;
public string type5DataBinaryValue4;
public string type5ElementIdentifierBinaryValue5;
public string type5ElementLengthBinaryValue5;
public string type5DataBinaryValue5;
public string type5ElementIdentifierBinaryValue6;
public string type5ElementLengthBinaryValue6;
public string type5DataBinaryValue6;
public string pDUType;
public string pDUTypeExtension;
public string timeType;
public string timeElapsed;
public string timePositionDay;
public string timePositionHour;
public string timePositionMinute;
public string timePositionSecond;
public string locationShape;
public string longitude;
public string latitude;
public string positionError;
public string horizontalPositionUncertainty;
public string horizontalVelocity;
public string horizontalVelocityUncertainty;
public string verticalVelocityUncertainty;
public string verticalVelocitySign;
public string verticalVelocity;
public string halfOfMajorAxis;
public string halfOfMinorAxis;
public string angle;
public string locationAltitude;
public string confidentLevel;
public string locationAltitudeAccuracy;
public string directionOfTravel;
public string typeOfAdditionalData;
public string reasonForSending;
public string innerRadius;
public string outerRadius;
public string startAngle;
public string stopAngle;
public string velocityType;
public string directionOfTravelExtended;
public string directionOfTravelUncertainty;
public string acknowledgementRequest;
public string extendedUserDefinedData;
public string locationMessageReference;
public string resultCode;
public string sDSType1Value;
public string statusValue;
public string maximumInformationAge;
public string maximumResponseTime;
public string startTime;
public string stopTime;
public string startTimeDay;
public string startTimeHour;
public string startTimeMinute;
public string startTimeSecond;
public string stopTimeDay;
public string stopTimeHour;
public string stopTimeMinute;
public string stopTimeSecond;
public string requestPriority;
public string directionOfTravelReturnValue;
public string directionOfTravelRequestedOrRequired;
public string horizontalPositionReturnValue;
public string horizontalPositionRequestedOrRequired;
public string horizontalVelocityReturnValue;
public string horizontalVelocityRequestedOrRequired;
public string locationAltitudeReturnValue;
public string locationAltitudeRequestedOrRequired;
public string verticalVelocityReturnValue;
public string verticalVelocityRequestedOrRequired;
public string directionOfTravelAccuracy;
public string preferredShape;
public string horizontalPositionAccuracy;
public string horizontalVelocityAccuracy;
public string locationAltitudeType;
public string verticalVelocityAccuracy;
public string triggerDefinition;
public string oneshot_recurring;
public string type5ElementIdentifier;
public string type5ElementLength;
public string type5Data;
public string type5ElementIdentifier1;
public string type5ElementLength1;
public string type5Data1;
public string type5ElementIdentifier2;
public string type5ElementLength2;
public string type5Data2;
public string type5ElementIdentifier3;
public string type5ElementLength3;
public string type5Data3;
public string type5ElementIdentifier4;
public string type5ElementLength4;
public string type5Data4;
public string type5ElementIdentifier5;
public string type5ElementLength5;
public string type5Data5;
public string type5ElementIdentifier6;
public string type5ElementLength6;
public string type5Data6;
public string minimumReportingInterval;
public string reportingType;
public string locationReportingEnableFlags;
public string binary;
#endregion
//error message variable
public string errormessage;
private void resetValues()
{
pDUTypeBinaryValue = "";
pDUTypeExtensionBinaryValue = "";
timeTypeBinaryValue = "";
timeElapsedBinaryValue = "";
timePositionDayBinaryValue = "";
timePositionHourBinaryValue = "";
timePositionMinuteBinaryValue = "";
timePositionSecondBinaryValue = "";
locationShapeBinaryValue = "";
longitudeBinaryValue = "";
latitudeBinaryValue = "";
positionErrorBinaryValue = "";
horizontalPositionUncertaintyBinaryValue = "";
horizontalVelocityBinaryValue = "";
horizontalVelocityUncertaintyBinaryValue = "";
verticalVelocityUncertaintyBinaryValue = "";
verticalVelocitySignBinaryValue = "";
verticalVelocityBinaryValue = "";
halfOfMajorAxisBinaryValue = "";
halfOfMinorAxisBinaryValue = "";
angleBinaryValue = "";
locationAltitudeBinaryValue = "";
confidentLevelBinaryValue = "";
locationAltitudeAccuracyBinaryValue = "";
directionOfTravelBinaryValue = "";
typeOfAdditionalDataBinaryValue = "";
reasonForSendingBinaryValue = "";
innerRadiusBinaryValue = "";
outerRadiusBinaryValue = "";
startAngleBinaryValue = "";
stopAngleBinaryValue = "";
velocityTypeBinaryValue = "";
directionOfTravelExtendedBinaryValue = "";
directionOfTravelUncertaintyBinaryValue = "";
acknowledgementRequestBinaryValue = "";
extendedUserDefinedDataBinaryValue = "";
locationMessageReferenceBinaryValue = "";
resultCodeBinaryValue = "";
sDSType1ValueBinaryValue = "";
statusValueBinaryValue = "";
maximumInformationAgeBinaryValue = "";
maximumResponseTimeBinaryValue = "";
startTimeBinaryValue = "";
stopTimeBinaryValue = "";
startTimeDayBinaryValue = "";
startTimeHourBinaryValue = "";
startTimeMinuteBinaryValue = "";
startTimeSecondBinaryValue = "";
stopTimeDayBinaryValue = "";
stopTimeHourBinaryValue = "";
stopTimeMinuteBinaryValue = "";
stopTimeSecondBinaryValue = "";
requestPriorityBinaryValue = "";
directionOfTravelReturnValueBinaryValue = "";
directionOfTravelRequestedOrRequiredBinaryValue = "";
horizontalPositionReturnValueBinaryValue = "";
horizontalPositionRequestedOrRequiredBinaryValue = "";
horizontalVelocityReturnValueBinaryValue = "";
horizontalVelocityRequestedOrRequiredBinaryValue = "";
locationAltitudeReturnValueBinaryValue = "";
locationAltitudeRequestedOrRequiredBinaryValue = "";
verticalVelocityReturnValueBinaryValue = "";
verticalVelocityRequestedOrRequiredBinaryValue = "";
directionOfTravelAccuracyBinaryValue = "";
preferredShapeBinaryValue = "";
horizontalPositionAccuracyBinaryValue = "";
horizontalVelocityAccuracyBinaryValue = "";
locationAltitudeTypeBinaryValue = "";
verticalVelocityAccuracyBinaryValue = "";
triggerDefinitionBinaryValue = "";
oneshot_recurringBinaryValue = "";
type5ElementIdentifierBinaryValue = "";
type5ElementLengthBinaryValue = "";
type5DataBinaryValue = "";
type5ElementIdentifierBinaryValue1 = "";
type5ElementLengthBinaryValue1 = "";
type5DataBinaryValue1 = "";
type5ElementIdentifierBinaryValue2 = "";
type5ElementLengthBinaryValue2 = "";
type5DataBinaryValue2 = "";
type5ElementIdentifierBinaryValue3 = "";
type5ElementLengthBinaryValue3 = "";
type5DataBinaryValue3 = "";
type5ElementIdentifierBinaryValue4 = "";
type5ElementLengthBinaryValue4 = "";
type5DataBinaryValue4 = "";
type5ElementIdentifierBinaryValue5 = "";
type5ElementLengthBinaryValue5 = "";
type5DataBinaryValue5 = "";
type5ElementIdentifierBinaryValue6 = "";
type5ElementLengthBinaryValue6 = "";
type5DataBinaryValue6 = "";
pDUType = "";
pDUTypeExtension = "";
timeType = "";
timeElapsed = "";
timePositionDay = "";
timePositionHour = "";
timePositionMinute = "";
timePositionSecond = "";
locationShape = "";
longitude = "";
latitude = "";
positionError = "";
horizontalPositionUncertainty = "";
horizontalVelocity = "";
horizontalVelocityUncertainty = "";
verticalVelocityUncertainty = "";
verticalVelocitySign = "";
verticalVelocity = "";
halfOfMajorAxis = "";
halfOfMinorAxis = "";
angle = "";
locationAltitude = "";
confidentLevel = "";
locationAltitudeAccuracy = "";
directionOfTravel = "";
typeOfAdditionalData = "";
reasonForSending = "";
innerRadius = "";
outerRadius = "";
startAngle = "";
stopAngle = "";
velocityType = "";
directionOfTravelExtended = "";
directionOfTravelUncertainty = "";
acknowledgementRequest = "";
extendedUserDefinedData = "";
locationMessageReference = "";
resultCode = "";
sDSType1Value = "";
statusValue = "";
maximumInformationAge = "";
maximumResponseTime = "";
startTime = "";
stopTime = "";
startTimeDay = "";
startTimeHour = "";
startTimeMinute = "";
startTimeSecond = "";
stopTimeDay = "";
stopTimeHour = "";
stopTimeMinute = "";
stopTimeSecond = "";
requestPriority = "";
directionOfTravelReturnValue = "";
directionOfTravelRequestedOrRequired = "";
horizontalPositionReturnValue = "";
horizontalPositionRequestedOrRequired = "";
horizontalVelocityReturnValue = "";
horizontalVelocityRequestedOrRequired = "";
locationAltitudeReturnValue = "";
locationAltitudeRequestedOrRequired = "";
verticalVelocityReturnValue = "";
verticalVelocityRequestedOrRequired = "";
directionOfTravelAccuracy = "";
preferredShape = "";
horizontalPositionAccuracy = "";
horizontalVelocityAccuracy = "";
locationAltitudeType = "";
verticalVelocityAccuracy = "";
triggerDefinition = "";
oneshot_recurring = "";
type5ElementIdentifier = "";
type5ElementLength = "";
type5Data = "";
type5ElementIdentifier1 = "";
type5ElementLength1 = "";
type5Data1 = "";
type5ElementIdentifier2 = "";
type5ElementLength2 = "";
type5Data2 = "";
type5ElementIdentifier3 = "";
type5ElementLength3 = "";
type5Data3 = "";
type5ElementIdentifier4 = "";
type5ElementLength4 = "";
type5Data4 = "";
type5ElementIdentifier5 = "";
type5ElementLength5 = "";
type5Data5 = "";
type5ElementIdentifier6 = "";
type5ElementLength6 = "";
type5Data6 = "";
minimumReportingIntervalBinaryValue = "";
minimumReportingInterval = "";
reportingTypeBinaryValue = "";
reportingType = "";
resultCodeBinaryValue = "";
resultCode = "";
locationReportingEnableFlagsBinaryValue = "";
locationReportingEnableFlags = "";
// error message intialization
errormessage = "";
binary = "";
}
public void decoder(string list)
{
resetValues();
int start = 0;
try
{
if (list.Length > 11)
locationMessageReference = list[9] + "";
//remove sdts portion of code.
if ((list.Length > 32))
{
if (((list.Length > 32 & list.Substring(18, 2).CompareTo("0A") == 0 & list.Substring(30, 2).CompareTo("02") == 0) | (list.Length > 32 & list.Substring(18, 2).CompareTo("0a") == 0 & list.Substring(30, 2).CompareTo("02") == 0)))
{
start = 32;
}
}
int i = 0;
for (i = start; i <= Convert.ToInt32(list.ToString().Length - 1); i++)
{
binary = binary + HextoBits(list.ToString().Substring(i, 1));
}
//PDUtype = "00" is for Short location Report
// decode the lip message info
DecodeLipDataMessage(binary);
}
catch (System.ArgumentOutOfRangeException ex)
{
//temporary close the error
//pDUType = pDUType.ToString + "Error, invalid HEX value detected. If the problem still persist, kindly contact any of the DISC engineer. "
errormessage = ex.ToString() + " Error, invalid HEX value detected. If the problem still persist, kindly contact any of the DISC engineer. ";
}
}
public PDUType pduType;
public PDUTypeExtension pduTypeExtension;
public Object DecodeLipDataMessage(String hexLipLocation)
{
resetValues();
// skip the protocol identifier from the message
hexLipLocation = hexLipLocation.Substring(2);
String binary = "";
for (int i = 0; i < hexLipLocation.Length; i++)
{
binary = binary + HextoBits(hexLipLocation.Substring(i, 1));
}
#region SHORT LOCATION REPORT
if ((binary.Substring(0, 2).CompareTo("00") == 0))
{
pDUTypeBinaryValue = binary.Substring(0, 2);
pDUType = "Short Location Report";
pduType = PDUType.SHORT_LOCATION;
timeElapsedBinaryValue = binary.Substring(2, 2);
timeElapsed = TimeElapsedDefinition(timeElapsedBinaryValue);
longitudeBinaryValue = binary.Substring(4, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(29, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
positionErrorBinaryValue = binary.Substring(53, 3);
positionError = PositionErrorDefinition(positionErrorBinaryValue);
horizontalVelocityBinaryValue = binary.Substring(56, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
directionOfTravelBinaryValue = binary.Substring(63, 4);
directionOfTravel = DirectionOfTravelDefinition(directionOfTravelBinaryValue);
typeOfAdditionalDataBinaryValue = binary.Substring(67, 1);
typeOfAdditionalData = TypeOfAdditionalDataDefinition(typeOfAdditionalDataBinaryValue);
if (binary.Length >= 68 + 8)
{
reasonForSendingBinaryValue = binary.Substring(68, 8);
reasonForSending = ReasonForSendingDefinition(reasonForSendingBinaryValue);
}
/*
if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 32))
{
Utils.WriteLine("LOCATION WITH " + reasonForSending, ConsoleColor.Cyan);
}*/
//PDUtype = "01" is for Long location Message
}
#endregion
else if ((binary.Substring(0, 2).CompareTo("01") == 0))
{
pDUTypeBinaryValue = binary.Substring(0, 2);
pDUType = "Location protocol PDU with extension";
pduType = PDUType.LONG_LOCATION;
// "Long Location Message"
pDUTypeExtensionBinaryValue = binary.Substring(2, 4);
//reserved
if ((pDUTypeExtensionBinaryValue.CompareTo("0000") == 0))
{
pDUTypeExtension = "reserved";
pduTypeExtension = PDUTypeExtension.RESERVED0000;
// immediate location request
}
#region IMMEDIATE LOCATION REQUEST
else if ((pDUTypeExtensionBinaryValue.CompareTo("0001") == 0))
{
pDUTypeExtension = "Immediate location request";
pduTypeExtension = PDUTypeExtension.IMMEDIATE_LOCATION_REQ_REP;
reportingTypeBinaryValue = binary.Substring(6 + 1, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
int nextbits = 6 + 1 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5Data = type5DataBinaryValue;
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5Data1 = type5DataBinaryValue1;
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5Data2 = type5DataBinaryValue1;
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5Data3 = type5DataBinaryValue3;
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5Data4 = type5DataBinaryValue4;
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5Data5 = type5DataBinaryValue5;
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
if ((binary.Length > nextbits + 5 + 7 + 7))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5Data6 = type5DataBinaryValue6;
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
//nextbits = nextbits + 5 + 6 + Convert.ToInt32 (type5ElementLength6)
}
}
}
}
}
}
}
// reserved
}
#endregion
else if ((pDUTypeExtensionBinaryValue.CompareTo("0010") == 0))
{
pDUTypeExtension = "reserved";
pduTypeExtension = PDUTypeExtension.RESERVED0010;
// long location report
}
#region LONG LOCATION REPORT
else if ((pDUTypeExtensionBinaryValue.CompareTo("0011") == 0))
{
pDUTypeExtension = "Long Location Report";
pduTypeExtension = PDUTypeExtension.LONG_LOCATION_REPORT;
timeTypeBinaryValue = binary.Substring(6, 2);
int TDcont = TimeDecoder(timeTypeBinaryValue, binary, 6 + 2);
locationShapeBinaryValue = binary.Substring(TDcont, 4);
locationShape = LocationShapeDefinition(locationShapeBinaryValue);
int LDcont = LocationDecoder(locationShapeBinaryValue, binary, TDcont + 4);
velocityTypeBinaryValue = binary.Substring(LDcont, 3);
int VDcont = VelocityDecoder(velocityTypeBinaryValue, binary, LDcont + 3);
acknowledgementRequestBinaryValue = binary.Substring(VDcont, 1);
acknowledgementRequest = AcknowledgementRequestDefinition(acknowledgementRequestBinaryValue);
typeOfAdditionalDataBinaryValue = binary.Substring(VDcont + 1, 1);
typeOfAdditionalData = TypeOfAdditionalDataDefinition(typeOfAdditionalDataBinaryValue);
if ((typeOfAdditionalDataBinaryValue.CompareTo("0") == 0))
{
//"Reason for sending is included."
reasonForSendingBinaryValue = binary.Substring(VDcont + 1 + 1, 8);
reasonForSending = ReasonForSendingDefinition(reasonForSendingBinaryValue);
/*
if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 32))
{
Utils.WriteLine("LOCATION WITH " + reasonForSending, ConsoleColor.Cyan);
}*/
}
else
{
//"Reason for sending is not included."
//extendedUserDefinedDataBinaryValue = binary.Substring(VDcont + 1 + 1, 8)
//extendedUserDefinedData = extendedUserDefinedDataBinaryValue ' This is out of the scope of this application.
//Utils.WriteLine("LOCATION WITH " + "Reason for sending is not included.", ConsoleColor.Cyan);
}
if (reasonForSendingBinaryValue.Length > 0)
{
if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 4))
{
type5ElementIdentifierBinaryValue = binary.Substring(VDcont + 1 + 1 + 8, 5);
//type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = Convert.ToString(Convert.ToInt32(type5DataBinaryValue, 2));
if ((binary.Length >= (VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 8)))
{
locationMessageReferenceBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength), 8);
locationMessageReference = locationMessageReferenceBinaryValue;
// this is out of the scope of this sample application.
}
if ((binary.Length >= (VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 8 + 8)))
{
resultCodeBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 8, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
}
if ((binary.Length >= (VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16)))
{
sDSType1ValueBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 8 + 8, 16);
//for sDSType1Value please see EN 300 392-2[2], clause 14.8.49 User defined data-1
sDSType1Value = sDSType1ValueBinaryValue;
}
if ((binary.Length >= (VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16 + 16)))
{
statusValueBinaryValue = binary.Substring(VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16, 16);
//for statusValue please see EN 300 392-2[2], clause 14.8.34 precoded status
statusValue = statusValueBinaryValue;
}
if ((binary.Length > (VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16 + 16)))
{
type5ElementIdentifierBinaryValue1 = binary.Substring((VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16 + 16), 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring((VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16 + 16), 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring((VDcont + 1 + 1 + 8 + 5 + 6 + Convert.ToInt32(type5ElementLength) + 16 + 16 + 16) + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = Convert.ToString(Convert.ToInt32(type5DataBinaryValue1, 2));
}
}
}
//location report acknowledgement
}
#endregion
#region LOCATION REPORT ACK
else if ((pDUTypeExtensionBinaryValue.CompareTo("0100") == 0))
{
pDUTypeExtension = "location report acknowledgement";
pduTypeExtension = PDUTypeExtension.LONG_LOCATION_ACK;
resultCodeBinaryValue = binary.Substring(6, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
if ((binary.Length > 6 + 8 + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(6 + 8, 5);
//type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(6 + 8 + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(6 + 8 + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
//Convert.ToString (Convert.ToInt32 (type5DataBinaryValue1,2))
}
// basic location parameters request/response
}
#endregion
#region BASIC LOCATION PARAMETERS
else if ((pDUTypeExtensionBinaryValue.CompareTo("0101") == 0))
{
pduTypeExtension = PDUTypeExtension.BASIC_LOCATION_PARAM_REQ_REP;
int nextbits = 0;
#region BASIC LOCATION PARAMETERS RESPONSE
if ((binary.Substring(6, 1).CompareTo("1") == 0))
{
pDUTypeExtension = "Basic location parameters response";
resultCodeBinaryValue = binary.Substring(6 + 1, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
locationReportingEnableFlagsBinaryValue = binary.Substring(6 + 1 + 8, 8);
locationReportingEnableFlags = LocationReportingEnableFlagsDefinition(locationReportingEnableFlagsBinaryValue);
minimumReportingIntervalBinaryValue = binary.Substring(6 + 1 + 8 + 8, 7);
minimumReportingInterval = MinimumReportingIntervalDefinition(minimumReportingIntervalBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 8 + 8 + 7, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
nextbits = 6 + 1 + 8 + 8 + 7 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
type5Data2 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
type5Data3 = type5DataBinaryValue3;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
type5Data4 = type5DataBinaryValue4;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
type5Data5 = type5DataBinaryValue5;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
}
}
}
}
}
}
if (binary.Length > nextbits + 7 + 7 + 22 + 22)
{
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
startTimeBinaryValue = binary.Substring(nextbits + 7 + 7, 22);
StartTimeDefinition(startTimeBinaryValue);
stopTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 22, 22);
StopTimeDefinition(stopTimeBinaryValue);
}
if ((binary.Length > nextbits + 5 + 7 + 7 + 22 + 22))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
type5Data6 = type5DataBinaryValue6;
//nextbits = nextbits + 5 + 6 + Convert.ToInt32 (type5ElementLength6)
}
}
#endregion
#region BASIC LOCATION PARAMETERS REQUEST
else
{
pDUTypeExtension = "Basic location parameters request";
acknowledgementRequestBinaryValue = binary.Substring(6 + 1, 1);
acknowledgementRequest = AcknowledgementRequestDefinition(acknowledgementRequestBinaryValue);
minimumReportingIntervalBinaryValue = binary.Substring(6 + 1 + 1, 7);
minimumReportingInterval = MinimumReportingIntervalDefinition(minimumReportingIntervalBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 1 + 7, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
nextbits = 6 + 1 + 1 + 7 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
type5Data2 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
type5Data3 = type5DataBinaryValue3;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
type5Data4 = type5DataBinaryValue4;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
type5Data5 = type5DataBinaryValue5;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
}
}
}
}
}
}
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
startTimeBinaryValue = binary.Substring(nextbits + 7 + 7, 22);
StartTimeDefinition(startTimeBinaryValue);
stopTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 22, 22);
StopTimeDefinition(stopTimeBinaryValue);
if ((binary.Length > nextbits + 5 + 7 + 7 + 22 + 22))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
type5Data6 = type5DataBinaryValue6;
//nextbits = nextbits + 5 + 6 + Convert.ToInt32 (type5ElementLength6)
}
}
#endregion
//' add/modify trigger request / response
}
#endregion
else if ((pDUTypeExtensionBinaryValue.CompareTo("0110") == 0))
{
#region ADD/MODIFY TRIGGER REQUEST
if ((binary.Substring(6, 1).CompareTo("0") == 0))
{
pduTypeExtension = PDUTypeExtension.ADD_MODIFY_TRIGGER_REQ_REP;
pDUTypeExtension = "Add or Modify trigger Request";
acknowledgementRequestBinaryValue = binary.Substring(6 + 1, 1);
acknowledgementRequest = AcknowledgementRequestDefinition(acknowledgementRequestBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 1, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
int nextbits = 6 + 1 + 1 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
type5Data2 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
type5Data3 = type5DataBinaryValue3;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
type5Data4 = type5DataBinaryValue4;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
type5Data5 = type5DataBinaryValue5;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
}
}
}
}
}
}
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
requestPriorityBinaryValue = binary.Substring(nextbits + 7 + 7, 2);
requestPriority = RequestPriorityDefinition(requestPriorityBinaryValue);
startTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 2, 22);
StartTimeDefinition(startTimeBinaryValue);
stopTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 2 + 22, 22);
StopTimeDefinition(stopTimeBinaryValue);
if ((binary.Length > nextbits + 5 + 7 + 7 + 2 + 22 + 22))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
type5Data6 = type5DataBinaryValue6;
//nextbits = nextbits + 5 + 6 + Convert.ToInt32 (type5ElementLength6)
}
//If (binary.Length > nextbits + 5 + 7 + 7 + 22 + 22) Then
// type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22, 5)
// ' type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
// type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5, 6)
// type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2))
// type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6))
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6)
// type5Data6 = type5DataBinaryValue6
// 'nextbits = nextbits + 5 + 6 + Convert.ToInt32 (type5ElementLength6)
//End If
}
#endregion
#region ADD/MODIFY TRIGGER RESPONSE
else if ((binary.Substring(6, 1).CompareTo("1") == 0))
{
pduTypeExtension = PDUTypeExtension.ADD_MODIFY_TRIGGER_REQ_REP;
pDUTypeExtension = "Add or Modify trigger Response";
resultCodeBinaryValue = binary.Substring(6 + 1, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 8, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
return new AddModifyTriggerResponse(pduType, pduTypeExtension, (TriggerResultCode)(Convert.ToInt16(resultCodeBinaryValue, 2)),
(ReportType)(Convert.ToInt16(reportingTypeBinaryValue, 2)));
}
#endregion
//' report trigger request / response
}
#region REMOVE TRIGGER
else if ((pDUTypeExtensionBinaryValue.CompareTo("01111") == 0))
{
#region REMOVE TRIGGER REQUEST
if ((binary.Substring(6, 1).CompareTo("0") == 0))
{
pduTypeExtension = PDUTypeExtension.REMOVE_TRIGGER_REQ_REP;
pDUTypeExtension = "Remove trigger request";
acknowledgementRequestBinaryValue = binary.Substring(6 + 1, 1);
acknowledgementRequest = AcknowledgementRequestDefinition(acknowledgementRequestBinaryValue);
int nextbits = 6 + 1 + 1;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
}
}
}
#endregion
#region REMOVE TRIGGER RESPONSE
else if ((binary.Substring(6, 1).CompareTo("1") == 0))
{
pduTypeExtension = PDUTypeExtension.REMOVE_TRIGGER_REQ_REP;
pDUTypeExtension = "Remove trigger response";
resultCodeBinaryValue = binary.Substring(6 + 1, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
return new RemoveTriggerResponse(pduType, pduTypeExtension, (TriggerResultCode)(Convert.ToInt16(resultCodeBinaryValue, 2)));
}
#endregion
}
#endregion
#region REPORT TRIGGER
else if ((pDUTypeExtensionBinaryValue.CompareTo("1000") == 0))
{
#region REPORT TRIGGER REQUEST
if ((binary.Substring(6, 1).CompareTo("0") == 0))
{
pDUTypeExtension = "Report trigger request";
int nextbits = 6 + 1;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
}
}
#endregion
#region REPORT TRIGGER RESPONSE
else
{
pDUTypeExtension = "Report trigger response";
resultCodeBinaryValue = binary.Substring(6 + 1, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
locationReportingEnableFlagsBinaryValue = binary.Substring(6 + 1 + 8, 8);
locationReportingEnableFlags = LocationReportingEnableFlagsDefinition(locationReportingEnableFlagsBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 8 + 8, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
int nextbits = 6 + 1 + 8 + 8 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
type5Data2 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
type5Data3 = type5DataBinaryValue3;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
type5Data4 = type5DataBinaryValue4;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
type5Data5 = type5DataBinaryValue5;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
}
}
}
}
}
}
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
requestPriorityBinaryValue = binary.Substring(nextbits + 7 + 7, 2);
requestPriority = RequestPriorityDefinition(requestPriorityBinaryValue);
startTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 2, 22);
StartTimeDefinition(startTimeBinaryValue);
stopTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 2 + 22, 22);
StopTimeDefinition(stopTimeBinaryValue);
if ((binary.Length > nextbits + 5 + 7 + 7 + 2 + 22 + 22))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 2 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
type5Data6 = type5DataBinaryValue6;
}
}
#endregion
//' report basic location parameters request / response
}
#endregion
#region REPORT BASIC LOCATION PARAMETERS
else if ((pDUTypeExtensionBinaryValue.CompareTo("1001") == 0))
{
pDUTypeExtension = "report basic location parameters request / response";
#region REPORT BASIC LOCATION PARAMETERS REQUEST
if ((binary.Substring(6, 1).CompareTo("0") == 0))
{
pDUTypeExtension = "Report Basic location parameters request";
int nextbits = 6 + 1;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
}
}
#endregion
#region REPORT BASIC LOCATION PARAMETERS RESPONSE
else
{
pDUTypeExtension = "Report Basic location parameters response";
resultCodeBinaryValue = binary.Substring(6 + 1, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
locationReportingEnableFlagsBinaryValue = binary.Substring(6 + 1 + 8, 8);
locationReportingEnableFlags = LocationReportingEnableFlagsDefinition(locationReportingEnableFlagsBinaryValue);
minimumReportingIntervalBinaryValue = binary.Substring(6 + 1 + 8 + 8, 7);
minimumReportingInterval = MinimumReportingIntervalDefinition(minimumReportingIntervalBinaryValue);
reportingTypeBinaryValue = binary.Substring(6 + 1 + 8 + 8 + 7, 2);
reportingType = ReportTypeDefinition(reportingTypeBinaryValue);
int nextbits = 6 + 1 + 8 + 8 + 7 + 2;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue1 = binary.Substring(nextbits, 5);
// type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1)
type5ElementLengthBinaryValue1 = binary.Substring(nextbits + 5, 6);
type5ElementLength1 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue1, 2));
type5DataBinaryValue1 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength1));
type5ElementIdentifier1 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue1, type5DataBinaryValue1);
type5Data1 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength1);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue2 = binary.Substring(nextbits, 5);
// type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2)
type5ElementLengthBinaryValue2 = binary.Substring(nextbits + 5, 6);
type5ElementLength2 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue2, 2));
type5DataBinaryValue2 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength2));
type5ElementIdentifier2 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue2, type5DataBinaryValue2);
type5Data2 = type5DataBinaryValue1;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength2);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue3 = binary.Substring(nextbits, 5);
// type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3)
type5ElementLengthBinaryValue3 = binary.Substring(nextbits + 5, 6);
type5ElementLength3 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue3, 2));
type5DataBinaryValue3 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength3));
type5ElementIdentifier3 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue3, type5DataBinaryValue3);
type5Data3 = type5DataBinaryValue3;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength3);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue4 = binary.Substring(nextbits, 5);
// type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4)
type5ElementLengthBinaryValue4 = binary.Substring(nextbits + 5, 6);
type5ElementLength4 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue4, 2));
type5DataBinaryValue4 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength4));
type5ElementIdentifier4 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue4, type5DataBinaryValue4);
type5Data4 = type5DataBinaryValue4;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength4);
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue5 = binary.Substring(nextbits, 5);
// type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5)
type5ElementLengthBinaryValue5 = binary.Substring(nextbits + 5, 6);
type5ElementLength5 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue5, 2));
type5DataBinaryValue5 = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength5));
type5ElementIdentifier5 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue5, type5DataBinaryValue5);
type5Data5 = type5DataBinaryValue5;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength5);
}
}
}
}
}
}
maximumInformationAgeBinaryValue = binary.Substring(nextbits, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
maximumResponseTimeBinaryValue = binary.Substring(nextbits + 7, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
startTimeBinaryValue = binary.Substring(nextbits + 7 + 7, 22);
StartTimeDefinition(startTimeBinaryValue);
stopTimeBinaryValue = binary.Substring(nextbits + 7 + 7 + 22, 22);
StopTimeDefinition(stopTimeBinaryValue);
if ((binary.Length > nextbits + 5 + 7 + 7 + 22 + 22))
{
type5ElementIdentifierBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22, 5);
// type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6)
type5ElementLengthBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5, 6);
type5ElementLength6 = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue6, 2));
type5DataBinaryValue6 = binary.Substring(nextbits + 7 + 7 + 22 + 22 + 5 + 6, Convert.ToInt32(type5ElementLength6));
type5ElementIdentifier6 = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue6, type5DataBinaryValue6);
type5Data6 = type5DataBinaryValue6;
}
}
#endregion
//' location reporting enable /disable request/response
}
#endregion
#region LOCATION REPORTING ENABLE/DISABLE
else if ((pDUTypeExtensionBinaryValue.CompareTo("1010") == 0))
{
pduTypeExtension = PDUTypeExtension.LOCATION_REPORTING_ENABLE_DISABLE;
pDUTypeExtension = "location reporting enable/disable request/response";
#region LOCATION REPORTING ENABLE/DISABLE REQUEST
if ((binary.Substring(6, 1).CompareTo("0") == 0))
{
pDUTypeExtension = "Location reporting enable/disable request";
acknowledgementRequestBinaryValue = binary.Substring(6 + 1, 1);
acknowledgementRequest = AcknowledgementRequestDefinition(acknowledgementRequestBinaryValue);
locationReportingEnableFlagsBinaryValue = binary.Substring(6 + 1 + 1, 8);
locationReportingEnableFlags = LocationReportingEnableFlagsDefinition(locationReportingEnableFlagsBinaryValue);
int nextbits = 6 + 1 + 1 + 8;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
}
}
#endregion
#region LOCATION REPORTING ENABLE/DISABLE RESPONSE
else
{
pDUTypeExtension = "Location reporting enable/disable response";
locationReportingEnableFlagsBinaryValue = binary.Substring(6 + 1, 8);
locationReportingEnableFlags = LocationReportingEnableFlagsDefinition(locationReportingEnableFlagsBinaryValue);
int nextbits = 6 + 1 + 8;
if ((binary.Length > nextbits + 5))
{
type5ElementIdentifierBinaryValue = binary.Substring(nextbits, 5);
// type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue)
type5ElementLengthBinaryValue = binary.Substring(nextbits + 5, 6);
type5ElementLength = Convert.ToString(Convert.ToInt32(type5ElementLengthBinaryValue, 2));
type5DataBinaryValue = binary.Substring(nextbits + 5 + 6, Convert.ToInt32(type5ElementLength));
type5ElementIdentifier = Type5ElementIdentifierDefinition(type5ElementIdentifierBinaryValue, type5DataBinaryValue);
type5Data = type5DataBinaryValue;
nextbits = nextbits + 5 + 6 + Convert.ToInt32(type5ElementLength);
}
}
#endregion
// reserved
}
#endregion
else if ((pDUTypeExtensionBinaryValue.CompareTo("1011") == 0))
{
pDUTypeExtension = "reserved";
// reserved
}
else if ((pDUTypeExtensionBinaryValue.CompareTo("1100") == 0))
{
pDUTypeExtension = "reserved";
// reserved
}
else if ((pDUTypeExtensionBinaryValue.CompareTo("1101") == 0))
{
pDUTypeExtension = "reserved";
// reserved
}
else if ((pDUTypeExtensionBinaryValue.CompareTo("1110") == 0))
{
pDUTypeExtension = "reserved";
// reserved
}
else if ((pDUTypeExtensionBinaryValue.CompareTo("1111") == 0))
{
pDUTypeExtension = "reserved";
}
}
else if ((binary.Substring(0, 2).CompareTo("10") == 0))
{
pDUType = "PDUType as reserved";
}
else if ((binary.Substring(0, 2).CompareTo("11") == 0))
{
pDUType = "PDUType as reserved";
}
return null;
}
private string TimeElapsedDefinition(string timeElapsedBinaryValue)
{
string temp = "";
if ((timeElapsedBinaryValue.CompareTo("00") == 0))
{
temp = "less than 5 seconds";
}
else if ((timeElapsedBinaryValue.CompareTo("01") == 0))
{
temp = "less than 5 minutes";
}
else if ((timeElapsedBinaryValue.CompareTo("10") == 0))
{
temp = "less than 30 minutes";
}
else if ((timeElapsedBinaryValue.CompareTo("11") == 0))
{
temp = "time elapsed not known or not applicable";
}
return temp;
}
public string LongitudeDefinition(string binaryValue)
{
Boolean minus = false;
String tmpValue = binaryValue;
if (binaryValue[0] == '1')
{
minus = true;
tmpValue = tmpValue.Remove(0, 1);
}
Double calcLong = Convert.ToInt64(tmpValue, 2) * (360 / Math.Pow(2, 25));
if (minus) calcLong = calcLong - 180;
return Convert.ToString(calcLong);
//return (Convert.ToString(Convert.ToInt32(binaryValue, 2) * (360 / Math.Pow(2, 25))));
}
public string LatitudeDefinition(string binaryValue)
{
Boolean minus = false;
String tmpValue = binaryValue;
if (binaryValue[0] == '1')
{
minus = true;
tmpValue = tmpValue.Remove(0, 1);
}
Double calcLAT = Convert.ToInt32(tmpValue, 2) * (180 / Math.Pow(2, 24));
if (minus) calcLAT = calcLAT - 90;
return Convert.ToString(calcLAT);
//return Convert.ToString(Convert.ToInt32(binaryValue, 2) * (180 / Math.Pow(2, 24)));
}
private string PositionErrorDefinition(string positionErrorBinaryValue)
{
string temp = "";
if ((positionErrorBinaryValue.CompareTo("000") == 0))
{
temp = "less than 2 m";
}
else if ((positionErrorBinaryValue.CompareTo("001") == 0))
{
temp = "less than 20 m";
}
else if ((positionErrorBinaryValue.CompareTo("010") == 0))
{
temp = "less than 200 m";
}
else if ((positionErrorBinaryValue.CompareTo("011") == 0))
{
temp = "less than 2 km";
}
else if ((positionErrorBinaryValue.CompareTo("100") == 0))
{
temp = "less than 20 km";
}
else if ((positionErrorBinaryValue.CompareTo("101") == 0))
{
temp = "less than or equal to 200 km";
}
else if ((positionErrorBinaryValue.CompareTo("110") == 0))
{
temp = "more than 200 km";
}
else if ((positionErrorBinaryValue.CompareTo("111") == 0))
{
temp = "Position error not known";
}
return temp;
}
private string HextoBits(string ahex)
{
string bits = "";
if ((ahex.CompareTo("0") == 0))
{
bits = "0000";
}
else if ((ahex.CompareTo("1") == 0))
{
bits = "0001";
}
else if ((ahex.CompareTo("2") == 0))
{
bits = "0010";
}
else if ((ahex.CompareTo("3") == 0))
{
bits = "0011";
}
else if ((ahex.CompareTo("4") == 0))
{
bits = "0100";
}
else if ((ahex.CompareTo("5") == 0))
{
bits = "0101";
}
else if ((ahex.CompareTo("6") == 0))
{
bits = "0110";
}
else if ((ahex.CompareTo("7") == 0))
{
bits = "0111";
}
else if ((ahex.CompareTo("8") == 0))
{
bits = "1000";
}
else if ((ahex.CompareTo("9") == 0))
{
bits = "1001";
}
else if ((ahex.CompareTo("A") == 0 | ahex.CompareTo("a") == 0))
{
bits = "1010";
}
else if ((ahex.CompareTo("B") == 0 | ahex.CompareTo("b") == 0))
{
bits = "1011";
}
else if ((ahex.CompareTo("C") == 0 | ahex.CompareTo("c") == 0))
{
bits = "1100";
}
else if ((ahex.CompareTo("D") == 0 | ahex.CompareTo("d") == 0))
{
bits = "1101";
}
else if ((ahex.CompareTo("E") == 0 | ahex.CompareTo("e") == 0))
{
bits = "1110";
}
else if ((ahex.CompareTo("F") == 0 | ahex.CompareTo("f") == 0))
{
bits = "1111";
}
return bits;
}
private string HorizontalVelocityUncertaintyDefinition(string horizontalVelocityUncertaintyBinaryValue)
{
string temp = "";
if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("000") == 0))
{
temp = "Less than 1.5 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("001") == 0))
{
temp = "Less than 3 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("010") == 0))
{
temp = "Less than 6 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("011") == 0))
{
temp = "Less than 12 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("100") == 0))
{
temp = "Less than 24 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("101") == 0))
{
temp = "Less than 48 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("110") == 0))
{
temp = "Less than 96 km/h";
}
else if ((horizontalVelocityUncertaintyBinaryValue.CompareTo("111") == 0))
{
temp = "Reserved";
}
return temp;
}
private string DirectionOfTravelDefinition(string functiondirectionOfTravelBinaryValue)
{
string functionReturnValue = null;
if ((directionOfTravelBinaryValue.CompareTo("0000") == 0))
{
functionReturnValue = "North (N)";
}
else if ((directionOfTravelBinaryValue.CompareTo("0001") == 0))
{
functionReturnValue = "NNE";
}
else if ((directionOfTravelBinaryValue.CompareTo("0010") == 0))
{
functionReturnValue = "NE";
}
else if ((directionOfTravelBinaryValue.CompareTo("0011") == 0))
{
functionReturnValue = "ENE";
}
else if ((directionOfTravelBinaryValue.CompareTo("0100") == 0))
{
functionReturnValue = "East (E)";
}
else if ((directionOfTravelBinaryValue.CompareTo("0101") == 0))
{
functionReturnValue = "ESE";
}
else if ((directionOfTravelBinaryValue.CompareTo("0110") == 0))
{
functionReturnValue = "SE";
}
else if ((directionOfTravelBinaryValue.CompareTo("0111") == 0))
{
functionReturnValue = "SSE";
}
else if ((directionOfTravelBinaryValue.CompareTo("1000") == 0))
{
functionReturnValue = "South (S)";
}
else if ((directionOfTravelBinaryValue.CompareTo("1001") == 0))
{
functionReturnValue = "SSW";
}
else if ((directionOfTravelBinaryValue.CompareTo("1010") == 0))
{
functionReturnValue = "SW";
}
else if ((directionOfTravelBinaryValue.CompareTo("1011") == 0))
{
functionReturnValue = "WSW";
}
else if ((directionOfTravelBinaryValue.CompareTo("1100") == 0))
{
functionReturnValue = "West (W)";
}
else if ((directionOfTravelBinaryValue.CompareTo("1101") == 0))
{
functionReturnValue = "WNW";
}
else if ((directionOfTravelBinaryValue.CompareTo("1110") == 0))
{
functionReturnValue = "NW";
}
else if ((directionOfTravelBinaryValue.CompareTo("1111") == 0))
{
functionReturnValue = "NNW or direction of travel is not known.";
}
else
{
functionReturnValue = "Error";
}
return functionReturnValue;
}
private string HorizontalVelocityDefinition(string horizontalVelocityBinaryValue)
{
string temp = "";
if ((Convert.ToInt32(horizontalVelocityBinaryValue, 2) <= 28))
{
temp = Convert.ToString(Convert.ToInt32(horizontalVelocityBinaryValue, 2)) + "km/h";
}
else if ((Convert.ToInt32(horizontalVelocityBinaryValue, 2) > 28 & Convert.ToInt32(horizontalVelocityBinaryValue, 2) < 126))
{
temp = Convert.ToString(16 * Math.Pow(1.038, (Convert.ToInt32(horizontalVelocityBinaryValue, 2) - 13))) + "km/h";
}
else if ((Convert.ToInt32(horizontalVelocityBinaryValue, 2) == 126))
{
temp = "More than 1043km/h";
}
else if ((Convert.ToInt32(horizontalVelocityBinaryValue, 2) == 127))
{
temp = "Horizontal speed is not known";
}
return temp;
}
private string TypeOfAdditionalDataDefinition(string typeOfAdditionalDataBinaryValue)
{
string functionReturnValue = null;
if ((typeOfAdditionalDataBinaryValue.CompareTo("0") == 0))
{
functionReturnValue = "Reason for sending is included.";
}
else
{
functionReturnValue = "Reason for sending is not included.";
}
return functionReturnValue;
}
private string ReasonForSendingDefinition(string reasonForSendingBinaryValue)
{
string functionReturnValue = null;
if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 0))
{
functionReturnValue = "Subcriber unit is powered ON ";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 1))
{
functionReturnValue = "Subcriber unit is powered OFF ";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 2))
{
functionReturnValue = "Emergency condition is detected ";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 3))
{
functionReturnValue = "Push to talk condition is detected";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 4))
{
functionReturnValue = "Status";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 5))
{
functionReturnValue = "Transmit inhibit mode ON";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 6))
{
functionReturnValue = "Transmit inhibit mode OFF";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 7))
{
functionReturnValue = "System access (TMO ON)";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 8))
{
functionReturnValue = "DMO ON";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 9))
{
functionReturnValue = "Enter service (after being out of service)";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 10))
{
functionReturnValue = "Service lose";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 11))
{
functionReturnValue = "Cell reselection or change of serving cell.";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 12))
{
functionReturnValue = "Low battery";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 13))
{
functionReturnValue = "Subscriber unit is connected to a car kit";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 14))
{
functionReturnValue = "Subscriber unit is disconnected from a car kit";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 15))
{
functionReturnValue = "Subscriber unit asks for transfer initialization configuration";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 16))
{
functionReturnValue = "Arrival at destination";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 17))
{
functionReturnValue = "Arrival at defined location";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 18))
{
functionReturnValue = "Approaching a defined location";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 19))
{
functionReturnValue = "SDS type 1 entered";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 20))
{
functionReturnValue = "User application initiated";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 32))
{
functionReturnValue = "Response to an immediate location request";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 129))
{
functionReturnValue = "Maximum reporting interval exceeded since the last location information report";
}
else if ((Convert.ToInt32(reasonForSendingBinaryValue, 2) == 130))
{
functionReturnValue = "Maximum reporting distance limit travelled since last location information report";
}
else
{
functionReturnValue = "Reserved";
}
if (functionReturnValue == "Subscriber unit asks for transfer initialization configuration")
{
init_request = true;
}
return functionReturnValue;
}
private string ReportTypeDefinition(string reportTypeBinaryValue)
{
string temp = "";
if ((reportTypeBinaryValue.CompareTo("00") == 0))
{
temp = "Long location report preferred with no time information.";
}
else if ((reportTypeBinaryValue.CompareTo("01") == 0))
{
temp = "Long location report preferred with time type Time elapsed.";
}
else if ((reportTypeBinaryValue.CompareTo("10") == 0))
{
temp = "Long location report preferred with time type Time of position.";
}
else if ((reportTypeBinaryValue.CompareTo("11") == 0))
{
temp = "Short location report preferred, see note.";
}
return temp;
}
private string Type5ElementIdentifierDefinition(string type5ElementIdentifierBinaryValue, string type5DataBinaryValue)
{
string functionReturnValue = null;
// Direction of travel and direction of travel accuracy
if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 0))
{
if ((type5DataBinaryValue.Substring(0, 1).CompareTo("0") == 0))
{
directionOfTravelReturnValueBinaryValue = "0";
directionOfTravelReturnValue = "Direction of Travel Value Required";
}
else
{
directionOfTravelReturnValueBinaryValue = "1";
directionOfTravelReturnValue = "Direction of Travel and direction of travel uncertainty value required";
}
if ((type5DataBinaryValue.Substring(1, 2).CompareTo("00") == 0))
{
directionOfTravelRequestedOrRequiredBinaryValue = "0";
directionOfTravelRequestedOrRequired = "Use basic parameter value or default value, if basic parameter value is not defined";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("01") == 0))
{
directionOfTravelRequestedOrRequiredBinaryValue = "1";
directionOfTravelRequestedOrRequired = "Requested";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("10") == 0))
{
directionOfTravelRequestedOrRequiredBinaryValue = "1";
directionOfTravelRequestedOrRequired = "Required";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("11") == 0))
{
directionOfTravelRequestedOrRequiredBinaryValue = "1";
directionOfTravelRequestedOrRequired = "Requested and required";
}
directionOfTravelAccuracyBinaryValue = type5DataBinaryValue.Substring(1 + 2, 3);
directionOfTravelAccuracy = DirectionOfTravelUncertaintyDefinition(directionOfTravelAccuracyBinaryValue);
functionReturnValue = "Direction of travel and direction of travel accuracy.";
// Extended user defined data.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 1))
{
functionReturnValue = "Extended user defined data.";
// Horizontal position and horizontal position accuracy.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 2))
{
if ((type5DataBinaryValue.Substring(0, 1).CompareTo("0") == 0))
{
horizontalPositionReturnValueBinaryValue = "0";
horizontalPositionReturnValue = "Horizontal position value required.";
}
else
{
horizontalPositionReturnValueBinaryValue = "1";
horizontalPositionReturnValue = "Horizontal position and horizontal position uncertainty value required.";
}
if ((type5DataBinaryValue.Substring(1, 1).CompareTo("0") == 0))
{
preferredShapeBinaryValue = "0";
preferredShape = "Circle shapte preferred.";
}
else
{
preferredShapeBinaryValue = "1";
preferredShape = "Ellipse or another shape allowed.";
}
if ((type5DataBinaryValue.Substring(1 + 1, 2).CompareTo("00") == 0))
{
horizontalPositionRequestedOrRequiredBinaryValue = "0";
horizontalPositionRequestedOrRequired = "Use basic parameter value or default value, if basic parameter value is not defined";
}
else if ((type5DataBinaryValue.Substring(1 + 1, 2).CompareTo("01") == 0))
{
horizontalPositionRequestedOrRequiredBinaryValue = "1";
horizontalPositionRequestedOrRequired = "Requested";
}
else if ((type5DataBinaryValue.Substring(1 + 1, 2).CompareTo("10") == 0))
{
horizontalPositionRequestedOrRequiredBinaryValue = "1";
horizontalPositionRequestedOrRequired = "Required";
}
else if ((type5DataBinaryValue.Substring(1 + 1, 2).CompareTo("11") == 0))
{
horizontalPositionRequestedOrRequiredBinaryValue = "1";
horizontalPositionRequestedOrRequired = "Requested and required";
}
if (type5DataBinaryValue.Length > 4 + 6)
{
horizontalPositionAccuracyBinaryValue = type5DataBinaryValue.Substring(4, 6);
if ((Convert.ToInt32(horizontalPositionAccuracyBinaryValue, 2) == 63))
{
horizontalPositionAccuracy = "Best Effort";
}
else
{
horizontalPositionAccuracy = "Less than " + Convert.ToString(Math.Round(2 * Math.Pow(1.2, (Convert.ToInt32(horizontalPositionAccuracyBinaryValue, 2) + 5)) - 4)) + "m";
}
functionReturnValue = "Horizontal position and horizontal position accuracy.";
}
// Horizontal velocity and horizontal velocity accuracy.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 3))
{
if ((type5DataBinaryValue.Substring(0, 1).CompareTo("0") == 0))
{
horizontalVelocityReturnValueBinaryValue = "0";
horizontalVelocityReturnValue = "Horizontal velocity value required.";
}
else
{
horizontalVelocityReturnValueBinaryValue = "1";
horizontalVelocityReturnValue = "Horizontal velocity and horizontal velocity uncertainty values required.";
}
if ((type5DataBinaryValue.Substring(1, 2).CompareTo("00") == 0))
{
horizontalVelocityRequestedOrRequiredBinaryValue = "0";
horizontalVelocityRequestedOrRequired = "Use basic parameter value or default value, if basic parameter value is not defined";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("01") == 0))
{
horizontalVelocityRequestedOrRequiredBinaryValue = "1";
horizontalVelocityRequestedOrRequired = "Requested";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("10") == 0))
{
horizontalVelocityRequestedOrRequiredBinaryValue = "1";
horizontalVelocityRequestedOrRequired = "Required";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("11") == 0))
{
horizontalVelocityRequestedOrRequiredBinaryValue = "1";
horizontalVelocityRequestedOrRequired = "Requested and required";
}
horizontalVelocityAccuracyBinaryValue = type5DataBinaryValue.Substring(1 + 2, 3);
horizontalVelocityAccuracy = HorizontalVelocityUncertaintyDefinition(horizontalVelocityAccuracyBinaryValue);
functionReturnValue = "Horizontal velocity and horizontal velocity accuracy.";
// Location information destination.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 4))
{
functionReturnValue = "Location information destination.";
// Location altitude and location altitude accuracy
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 5))
{
if ((type5DataBinaryValue.Substring(0, 1).CompareTo("0") == 0))
{
locationAltitudeReturnValueBinaryValue = "0";
locationAltitudeReturnValue = "Altitude value required.";
}
else
{
locationAltitudeReturnValueBinaryValue = "1";
locationAltitudeReturnValue = "Altitude and altitude uncertainty values required.";
}
if ((type5DataBinaryValue.Substring(1, 1).CompareTo("0") == 0))
{
locationAltitudeTypeBinaryValue = "0";
locationAltitudeType = "WGS84";
}
else
{
locationAltitudeTypeBinaryValue = "1";
locationAltitudeType = "User Defined";
}
if ((type5DataBinaryValue.Substring(2, 2).CompareTo("00") == 0))
{
locationAltitudeRequestedOrRequiredBinaryValue = "0";
locationAltitudeRequestedOrRequired = "Use basic parameter value or default value, if basic parameter value is not defined";
}
else if ((type5DataBinaryValue.Substring(2, 2).CompareTo("01") == 0))
{
locationAltitudeRequestedOrRequiredBinaryValue = "1";
locationAltitudeRequestedOrRequired = "Requested";
}
else if ((type5DataBinaryValue.Substring(2, 2).CompareTo("10") == 0))
{
locationAltitudeRequestedOrRequiredBinaryValue = "1";
locationAltitudeRequestedOrRequired = "Required";
}
else if ((type5DataBinaryValue.Substring(2, 2).CompareTo("11") == 0))
{
locationAltitudeRequestedOrRequiredBinaryValue = "1";
locationAltitudeRequestedOrRequired = "Requested and required";
}
locationAltitudeAccuracyBinaryValue = type5DataBinaryValue.Substring(2 + 2, 3);
locationAltitudeAccuracy = locationAltitudeAccuracyDefinition(locationAltitudeAccuracyBinaryValue);
functionReturnValue = "Location altitude and location altitude accuracy";
// Location message reference.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 6))
{
functionReturnValue = "Location message reference.";
// Maximum information age
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 7))
{
maximumInformationAgeBinaryValue = type5DataBinaryValue.Substring(0, 7);
maximumInformationAge = MaximumInformationAgeDefinition(maximumInformationAgeBinaryValue);
functionReturnValue = "Maximum information age";
// Maximum response time
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 8))
{
maximumResponseTimeBinaryValue = type5DataBinaryValue.Substring(0, 7);
maximumResponseTime = MaximumResponseTimeDefinition(maximumResponseTimeBinaryValue);
functionReturnValue = "Maximum response time";
// Request priority
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 11))
{
requestPriorityBinaryValue = type5DataBinaryValue.Substring(0, 2);
requestPriority = RequestPriorityDefinition(requestPriorityBinaryValue);
functionReturnValue = "Request priority";
// Result code
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 12))
{
resultCodeBinaryValue = type5DataBinaryValue.Substring(0, 8);
resultCode = ResultCodeDefinition(resultCodeBinaryValue);
functionReturnValue = "Result code";
// SDS type-1 value
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 13))
{
functionReturnValue = "SDS type-1 value";
// Start Time
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 14))
{
startTimeBinaryValue = type5DataBinaryValue.Substring(0, 22);
StartTimeDefinition(startTimeBinaryValue);
functionReturnValue = "Start Time";
// Status Value
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 15))
{
functionReturnValue = "Status Value";
// Stop time
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 16))
{
stopTimeBinaryValue = type5DataBinaryValue.Substring(0, 22);
StopTimeDefinition(stopTimeBinaryValue);
functionReturnValue = "Stop time";
// Terminal or location identification
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 17))
{
functionReturnValue = "Terminal or location identification";
terminal_id = true;
// Trigger definition
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 19))
{
triggerDefinitionBinaryValue = type5DataBinaryValue.Substring(0, 8);
triggerDefinition = TriggerDefinitionDefinition(triggerDefinitionBinaryValue);
if ((type5DataBinaryValue.Substring(8, 1) == "0"))
{
oneshot_recurringBinaryValue = "0";
oneshot_recurring = "One Shot";
}
else
{
oneshot_recurringBinaryValue = "1";
oneshot_recurring = "Recurring";
}
functionReturnValue = "Trigger definition";
// Trigger removal
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 20))
{
if ((type5DataBinaryValue.Substring(0, 1) == "0"))
{
oneshot_recurringBinaryValue = "0";
oneshot_recurring = "Remove all triggers";
}
else
{
oneshot_recurringBinaryValue = "1";
oneshot_recurring = "Remove listed triggers";
}
triggerDefinitionBinaryValue = type5DataBinaryValue.Substring(1, 8);
triggerDefinition = TriggerDefinitionDefinition(triggerDefinitionBinaryValue);
functionReturnValue = "Trigger removal";
// Vertical velocity and vertical velocity accuracy
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 21))
{
if ((type5DataBinaryValue.Substring(0, 1).CompareTo("0") == 0))
{
verticalVelocityReturnValueBinaryValue = "0";
verticalVelocityReturnValue = "Vertical velocity value required.";
}
else
{
verticalVelocityReturnValueBinaryValue = "1";
verticalVelocityReturnValue = "Vertical velocity and Vertical velocity uncertainty values required.";
}
if ((type5DataBinaryValue.Substring(1, 2).CompareTo("00") == 0))
{
verticalVelocityRequestedOrRequiredBinaryValue = "0";
verticalVelocityRequestedOrRequired = "Use basic parameter value or default value, if basic parameter value is not defined";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("01") == 0))
{
verticalVelocityRequestedOrRequiredBinaryValue = "1";
verticalVelocityRequestedOrRequired = "Requested";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("10") == 0))
{
verticalVelocityRequestedOrRequiredBinaryValue = "1";
verticalVelocityRequestedOrRequired = "Required";
}
else if ((type5DataBinaryValue.Substring(1, 2).CompareTo("11") == 0))
{
verticalVelocityRequestedOrRequiredBinaryValue = "1";
verticalVelocityRequestedOrRequired = "Requested and required";
}
verticalVelocityAccuracyBinaryValue = type5DataBinaryValue.Substring(3, 3);
verticalVelocityAccuracy = HorizontalVelocityUncertaintyDefinition(verticalVelocityAccuracyBinaryValue);
functionReturnValue = "Vertical velocity and vertical velocity accuracy";
// Extended type 5 information element.
}
else if ((Convert.ToInt32(type5ElementIdentifierBinaryValue, 2) == 31))
{
functionReturnValue = "Extended type 5 information element.";
}
else
{
functionReturnValue = "Reserved";
}
return functionReturnValue;
}
private string locationAltitudeAccuracyDefinition(string locationAltitudeAccuracyBinaryValue)
{
string temp = "";
if ((locationAltitudeAccuracyBinaryValue.CompareTo("000") == 0))
{
temp = "less than 1 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("001") == 0))
{
temp = "less than 2 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("010") == 0))
{
temp = "less than 5 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("011") == 0))
{
temp = "less than 15 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("100") == 0))
{
temp = "less than 50 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("101") == 0))
{
temp = "less than 150 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("110") == 0))
{
temp = "less than 300 m";
}
else if ((locationAltitudeAccuracyBinaryValue.CompareTo("111") == 0))
{
temp = "Best effort or not supported";
}
return temp;
}
private string LocationAltitudeDefinition(string locationAltitudeBinaryValue)
{
int altitude = 0;
if ((locationAltitudeBinaryValue.Substring(0, 1) == "0"))
{
if ((Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) <= 1201))
{
altitude = Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) - 201;
}
else if ((Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) > 1201 & Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) <= 1926))
{
altitude = Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) - 1201;
altitude = altitude * 2;
altitude = altitude + 1000;
}
else if ((Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) >= 1927))
{
altitude = Convert.ToInt32(locationAltitudeBinaryValue.Substring(1, 11), 2) - 1201;
altitude = altitude - 725;
altitude = altitude * 75;
altitude = altitude + 1000 + 1450;
}
//user defined altitude
}
else
{
}
return Convert.ToString(altitude);
}
private int LocationDecoder(string locationShapeBinaryValue, string binary, int locationInTheBinary)
{
int functionReturnValue = 0;
//0
if ((locationShapeBinaryValue.CompareTo("0000") == 0))
{
//return "No shape"
functionReturnValue = locationInTheBinary + 0;
//1
}
else if ((locationShapeBinaryValue.CompareTo("0001") == 0))
{
//return "Location point"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
functionReturnValue = locationInTheBinary + 24 + 25;
//2
}
else if ((locationShapeBinaryValue.CompareTo("0010") == 0))
{
//return"Location circle"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
horizontalPositionUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
if ((Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) == 63))
{
horizontalPositionUncertainty = "Best Effort";
}
else
{
horizontalPositionUncertainty = "Less than " + Convert.ToString(Math.Round(2 * Math.Pow(1.2, (Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) + 5)) - 4)) + "m";
}
functionReturnValue = locationInTheBinary + 24 + 25 + 6;
//3
}
else if ((locationShapeBinaryValue.CompareTo("0011") == 0))
{
//return "Location ellipse"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
halfOfMajorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
halfOfMinorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6, 6);
if ((Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) == 63))
{
halfOfMajorAxis = "Best Effort";
}
else
{
halfOfMajorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
if ((Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) == 63))
{
halfOfMinorAxis = "Best Effort";
}
else
{
halfOfMinorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
angleBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6, 8);
angle = Convert.ToString(Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) * 360 / 256);
confidentLevelBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8, 3);
confidentLevel = ConfidentLevelDefinition(confidentLevelBinaryValue);
functionReturnValue = locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 3;
//4
}
else if ((locationShapeBinaryValue.CompareTo("0100") == 0))
{
//return "Location point with altitude"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
locationAltitudeBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 12);
locationAltitude = LocationAltitudeDefinition(locationAltitudeBinaryValue);
functionReturnValue = locationInTheBinary + 24 + 25 + 12;
//5
}
else if ((locationShapeBinaryValue.CompareTo("0101") == 0))
{
//return "Location circle with altitude"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
horizontalPositionUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
if ((Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) == 63))
{
horizontalPositionUncertainty = "Best Effort";
}
else
{
horizontalPositionUncertainty = "Less than " + Convert.ToString(Math.Round(2 * Math.Pow(1.2, (Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) + 5)) - 4)) + "m";
}
locationAltitudeBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6, 12);
locationAltitude = LocationAltitudeDefinition(locationAltitudeBinaryValue);
functionReturnValue = locationInTheBinary + 24 + 25 + 6 + 12;
//6
}
else if ((locationShapeBinaryValue.CompareTo("0110") == 0))
{
//return "Location ellipse with altitude"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
halfOfMajorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
halfOfMinorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6, 6);
if ((Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) == 63))
{
halfOfMajorAxis = "Best Effort";
}
else
{
halfOfMajorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
if ((Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) == 63))
{
halfOfMinorAxis = "Best Effort";
}
else
{
halfOfMinorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
angleBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6, 8);
angle = Convert.ToString(Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) * 360 / 256);
locationAltitudeBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8, 12);
locationAltitude = LocationAltitudeDefinition(locationAltitudeBinaryValue);
confidentLevelBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 12, 3);
confidentLevel = ConfidentLevelDefinition(confidentLevelBinaryValue);
functionReturnValue = locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 12 + 3;
//7
}
else if ((locationShapeBinaryValue.CompareTo("0111") == 0))
{
//return "Location circle with altitude and altitude uncertainty"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
horizontalPositionUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
if ((Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) == 63))
{
horizontalPositionUncertainty = "Best Effort";
}
else
{
horizontalPositionUncertainty = "Less than " + Convert.ToString(Math.Round(2 * Math.Pow(1.2, (Convert.ToInt32(horizontalPositionUncertaintyBinaryValue, 2) + 5)) - 4)) + "m";
}
locationAltitudeBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6, 12);
locationAltitude = LocationAltitudeDefinition(locationAltitudeBinaryValue);
locationAltitudeAccuracyBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 12, 3);
locationAltitudeAccuracy = locationAltitudeAccuracyDefinition(locationAltitudeAccuracyBinaryValue);
functionReturnValue = locationInTheBinary + 24 + 25 + 6 + 12 + 3;
//8
}
else if ((locationShapeBinaryValue.CompareTo("1000") == 0))
{
//return "Location ellipse with altitude and altitude uncertainty"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
halfOfMajorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 6);
halfOfMinorAxisBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6, 6);
if ((Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) == 63))
{
halfOfMajorAxis = "Best Effort";
}
else
{
halfOfMajorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMajorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
if ((Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) == 63))
{
halfOfMinorAxis = "Best Effort";
}
else
{
halfOfMinorAxis = Convert.ToString(2 * Math.Pow(1.2, (Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) + 5)) - 4) + "m";
}
angleBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6, 8);
angle = Convert.ToString(Convert.ToInt32(halfOfMinorAxisBinaryValue, 2) * 360 / 256);
locationAltitudeBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8, 12);
locationAltitude = LocationAltitudeDefinition(locationAltitudeBinaryValue);
locationAltitudeAccuracyBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 12, 3);
locationAltitudeAccuracy = locationAltitudeAccuracyDefinition(locationAltitudeAccuracyBinaryValue);
confidentLevelBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 12 + 3, 3);
confidentLevel = ConfidentLevelDefinition(confidentLevelBinaryValue);
functionReturnValue = locationInTheBinary + 25 + 24 + 6 + 6 + 8 + 12 + 3 + 3;
//9
}
else if ((locationShapeBinaryValue.CompareTo("1001") == 0))
{
//return "Location arc"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
innerRadiusBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 16);
innerRadius = Convert.ToString((Convert.ToInt32(innerRadiusBinaryValue, 2) * 2));
outerRadiusBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 16, 16);
outerRadius = Convert.ToString((Convert.ToInt32(outerRadiusBinaryValue, 2) * 2));
startAngleBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 16 + 16, 8);
startAngle = Convert.ToString(Convert.ToInt32(startAngleBinaryValue, 2) * 360 / 256);
stopAngleBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 16 + 16 + 8, 8);
stopAngle = Convert.ToString(Convert.ToInt32(stopAngleBinaryValue, 2) * 360 / 256);
confidentLevelBinaryValue = binary.Substring(locationInTheBinary + 25 + 24 + 16 + 16 + 8 + 8, 3);
confidentLevel = ConfidentLevelDefinition(confidentLevelBinaryValue);
functionReturnValue = locationInTheBinary + 25 + 24 + 16 + 16 + 8 + 8 + 3;
//10
}
else if ((locationShapeBinaryValue.CompareTo("1010") == 0))
{
//return "Location point and position error"
longitudeBinaryValue = binary.Substring(locationInTheBinary, 25);
longitude = LongitudeDefinition(longitudeBinaryValue);
latitudeBinaryValue = binary.Substring(locationInTheBinary + 25, 24);
latitude = LatitudeDefinition(latitudeBinaryValue);
positionErrorBinaryValue = binary.Substring(locationInTheBinary + 25 + 24, 3);
if ((positionErrorBinaryValue.CompareTo("000") == 0))
{
positionError = "less than 2 m";
}
else if ((positionErrorBinaryValue.CompareTo("001") == 0))
{
positionError = "less than 20 m";
}
else if ((positionErrorBinaryValue.CompareTo("010") == 0))
{
positionError = "less than 200 m";
}
else if ((positionErrorBinaryValue.CompareTo("011") == 0))
{
positionError = "less than 2 km";
}
else if ((positionErrorBinaryValue.CompareTo("100") == 0))
{
positionError = "less than 20 km";
}
else if ((positionErrorBinaryValue.CompareTo("101") == 0))
{
positionError = "less than or equal to 200 km";
}
else if ((positionErrorBinaryValue.CompareTo("110") == 0))
{
positionError = "more than 200 km";
}
else if ((positionErrorBinaryValue.CompareTo("111") == 0))
{
positionError = "Position error not known";
}
functionReturnValue = locationInTheBinary + 25 + 24 + 3;
//11
}
else if ((locationShapeBinaryValue.CompareTo("1011") == 0))
{
functionReturnValue = locationInTheBinary;
//12
}
else if ((locationShapeBinaryValue.CompareTo("1100") == 0))
{
functionReturnValue = locationInTheBinary;
//13
}
else if ((locationShapeBinaryValue.CompareTo("1101") == 0))
{
functionReturnValue = locationInTheBinary;
//14
}
else if ((locationShapeBinaryValue.CompareTo("1110") == 0))
{
functionReturnValue = locationInTheBinary;
//15
}
else if ((locationShapeBinaryValue.CompareTo("1111") == 0))
{
functionReturnValue = locationInTheBinary;
}
else
{
functionReturnValue = locationInTheBinary;
}
return functionReturnValue;
}
private int TimeDecoder(string timeTypeBinaryValue, string binary, int locationInTheBinary)
{
int nextstart = 0;
if ((timeTypeBinaryValue.CompareTo("00") == 0))
{
timeType = "None";
nextstart = locationInTheBinary;
}
else if ((timeTypeBinaryValue.CompareTo("01") == 0))
{
timeType = "Time elapsed";
timeElapsedBinaryValue = binary.Substring(locationInTheBinary, 2);
timeElapsed = TimeElapsedDefinition(timeElapsedBinaryValue);
nextstart = locationInTheBinary + 2;
}
else if ((timeTypeBinaryValue.CompareTo("10") == 0))
{
timeType = "Time of position";
timePositionDayBinaryValue = binary.Substring(locationInTheBinary, 5);
timePositionHourBinaryValue = binary.Substring(locationInTheBinary + 5, 5);
timePositionMinuteBinaryValue = binary.Substring(locationInTheBinary + 5 + 5, 6);
timePositionSecondBinaryValue = binary.Substring(locationInTheBinary + 5 + 5 + 6, 6);
timePositionDay = Convert.ToString(Convert.ToInt32(timePositionDayBinaryValue, 2));
timePositionHour = Convert.ToString(Convert.ToInt32(timePositionHourBinaryValue, 2));
timePositionMinute = Convert.ToString(Convert.ToInt32(timePositionMinuteBinaryValue, 2));
timePositionSecond = Convert.ToString(Convert.ToInt32(timePositionSecondBinaryValue, 2));
nextstart = locationInTheBinary + 5 + 5 + 6 + 6;
}
else if ((timeTypeBinaryValue.CompareTo("11") == 0))
{
timeType = "Reserved";
nextstart = locationInTheBinary;
}
return nextstart;
}
private int VelocityDecoder(string velocityTypeBinaryValue, string binary, int locationInTheBinary)
{
//Utils.WriteLine("Velocity decored : " + velocityTypeBinaryValue, ConsoleColor.DarkBlue);
int temp = 0;
if ((velocityTypeBinaryValue.CompareTo("000") == 0))
{
velocityType = "No velocity information.";
temp = locationInTheBinary;
}
else if ((velocityTypeBinaryValue.CompareTo("001") == 0))
{
velocityType = "Horizontal velocity";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
temp = locationInTheBinary + 7;
}
else if ((velocityTypeBinaryValue.CompareTo("010") == 0))
{
velocityType = "Horizontal velocity with uncertainty";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
horizontalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7, 3);
horizontalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(horizontalVelocityUncertaintyBinaryValue);
temp = locationInTheBinary + 7 + 3;
}
else if ((velocityTypeBinaryValue.CompareTo("011") == 0))
{
velocityType = "Horizontal velocity and vertical velocity";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
verticalVelocitySignBinaryValue = binary.Substring(locationInTheBinary + 7, 1);
verticalVelocitySign = VerticalVelocitySignDefinition(verticalVelocitySignBinaryValue);
verticalVelocityBinaryValue = binary.Substring(locationInTheBinary + 7 + 1, 7);
verticalVelocity = HorizontalVelocityDefinition(verticalVelocityBinaryValue);
temp = locationInTheBinary + 7 + 1 + 7;
}
else if ((velocityTypeBinaryValue.CompareTo("100") == 0))
{
velocityType = "Horizontal velocity and vertical velocity with uncertainty";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
horizontalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7, 3);
horizontalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(horizontalVelocityUncertaintyBinaryValue);
verticalVelocitySignBinaryValue = binary.Substring(locationInTheBinary + 7 + 3, 1);
verticalVelocitySign = VerticalVelocitySignDefinition(verticalVelocitySignBinaryValue);
verticalVelocityBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1, 7);
verticalVelocity = HorizontalVelocityDefinition(verticalVelocityBinaryValue);
verticalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1 + 7, 3);
verticalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(verticalVelocityUncertaintyBinaryValue);
temp = locationInTheBinary + 7 + 3 + 1 + 7 + 3;
}
else if ((velocityTypeBinaryValue.CompareTo("101") == 0))
{
velocityType = "Horizontal velocity and direction of travel extended";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
directionOfTravelExtendedBinaryValue = binary.Substring(locationInTheBinary + 7, 8);
directionOfTravelExtended = Convert.ToString(Convert.ToInt32(directionOfTravelExtendedBinaryValue, 2) * 360 / 256);
temp = locationInTheBinary + 7 + 8;
}
else if ((velocityTypeBinaryValue.CompareTo("110") == 0))
{
velocityType = "Horizontal velocity and direction of travel extended and uncertainty";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
horizontalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7, 3);
horizontalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(horizontalVelocityUncertaintyBinaryValue);
directionOfTravelExtendedBinaryValue = binary.Substring(locationInTheBinary + 7 + 3, 8);
directionOfTravelExtended = Convert.ToString(Convert.ToInt32(directionOfTravelExtendedBinaryValue, 2) * 360 / 256);
directionOfTravelUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 8, 3);
directionOfTravelUncertainty = DirectionOfTravelUncertaintyDefinition(directionOfTravelUncertaintyBinaryValue);
temp = locationInTheBinary + 7 + 3 + 8 + 3;
}
else if ((velocityTypeBinaryValue.CompareTo("111") == 0))
{
velocityType = "Horizontal velocity and vertical velocity with direction of travel extended and uncertainty";
horizontalVelocityBinaryValue = binary.Substring(locationInTheBinary, 7);
horizontalVelocity = HorizontalVelocityDefinition(horizontalVelocityBinaryValue);
horizontalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7, 3);
horizontalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(horizontalVelocityUncertaintyBinaryValue);
verticalVelocitySignBinaryValue = binary.Substring(locationInTheBinary + 7 + 3, 1);
verticalVelocitySign = VerticalVelocitySignDefinition(verticalVelocitySignBinaryValue);
verticalVelocityBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1, 7);
verticalVelocity = HorizontalVelocityDefinition(verticalVelocityBinaryValue);
verticalVelocityUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1 + 7, 3);
verticalVelocityUncertainty = HorizontalVelocityUncertaintyDefinition(verticalVelocityUncertaintyBinaryValue);
directionOfTravelExtendedBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1 + 7 + 3, 8);
directionOfTravelExtended = Convert.ToString(Convert.ToInt32(directionOfTravelExtendedBinaryValue, 2) * 360 / 256);
directionOfTravelUncertaintyBinaryValue = binary.Substring(locationInTheBinary + 7 + 3 + 1 + 7 + 3 + 8, 3);
directionOfTravelUncertainty = DirectionOfTravelUncertaintyDefinition(directionOfTravelUncertaintyBinaryValue);
temp = locationInTheBinary + 7 + 3 + 1 + 7 + 3 + 8 + 3;
}
return temp;
}
private string DirectionOfTravelUncertaintyDefinition(string directionOfTravelUncertaintyBinaryValue)
{
//previously known as DirectionOfTravelUncertainty
string temp = "";
if ((directionOfTravelUncertaintyBinaryValue.CompareTo("000") == 0))
{
temp = "less than 1.5 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("001") == 0))
{
temp = "less than 3 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("010") == 0))
{
temp = "less than 6 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("011") == 0))
{
temp = "less than 12 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("100") == 0))
{
temp = "less than 24 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("101") == 0))
{
temp = "less than 48 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("110") == 0))
{
temp = "less than 96 degree";
}
else if ((directionOfTravelUncertaintyBinaryValue.CompareTo("111") == 0))
{
temp = "Best effort or uncertainty not known";
}
return temp;
}
private string VerticalVelocitySignDefinition(string verticalVelocitySignBinaryValue)
{
if ((verticalVelocitySignBinaryValue == "0"))
{
return "Velocity upwards";
}
else
{
return "Velocity downwards";
}
}
private string ConfidentLevelDefinition(string confidentLevelBinaryValue)
{
//Utils.WriteLine("ConfidentLevelDefinition:" + confidentLevelBinaryValue, ConsoleColor.Magenta);
string temp = "";
if ((confidentLevelBinaryValue.CompareTo("000") == 0))
{
temp = "50%";
}
else if ((confidentLevelBinaryValue.CompareTo("001") == 0))
{
temp = "68%";
}
else if ((confidentLevelBinaryValue.CompareTo("010") == 0))
{
temp = "80%";
}
else if ((confidentLevelBinaryValue.CompareTo("011") == 0))
{
temp = "90%";
}
else if ((confidentLevelBinaryValue.CompareTo("100") == 0))
{
temp = "95%";
}
else if ((confidentLevelBinaryValue.CompareTo("101") == 0))
{
temp = "99%";
}
else if ((confidentLevelBinaryValue.CompareTo("110") == 0))
{
temp = "99.9%";
}
else if ((confidentLevelBinaryValue.CompareTo("111") == 0))
{
temp = "Confidence level not known";
}
return temp;
}
private string LocationShapeDefinition(string binaryValue)
{
//0
if ((binaryValue.CompareTo("0000") == 0))
{
return "No shape";
//1
}
else if ((binaryValue.CompareTo("0001") == 0))
{
return "Location point";
//2
}
else if ((binaryValue.CompareTo("0010") == 0))
{
return "Location circle";
//3
}
else if ((binaryValue.CompareTo("0011") == 0))
{
return "Location ellipse";
//4
}
else if ((binaryValue.CompareTo("0100") == 0))
{
return "Location point with altitude";
//5
}
else if ((binaryValue.CompareTo("0101") == 0))
{
return "Location circle with altitude";
//6
}
else if ((binaryValue.CompareTo("0110") == 0))
{
return "Location ellipse with altitude";
//7
}
else if ((binaryValue.CompareTo("0111") == 0))
{
return "Location circle with altitude and altitude uncertainty";
//8
}
else if ((binaryValue.CompareTo("1000") == 0))
{
return "Location ellipse with altitude and altitude uncertainty";
//9
}
else if ((binaryValue.CompareTo("1001") == 0))
{
return "Location arc";
//10
}
else if ((binaryValue.CompareTo("1010") == 0))
{
return "Location point and position error";
//11
}
else if ((binaryValue.CompareTo("1011") == 0))
{
return "Reserved";
//12
}
else if ((binaryValue.CompareTo("1100") == 0))
{
return "Reserved";
//13
}
else if ((binaryValue.CompareTo("1101") == 0))
{
return "Reserved";
//14
}
else if ((binaryValue.CompareTo("1110") == 0))
{
return "Reserved";
//15
}
else if ((binaryValue.CompareTo("1111") == 0))
{
return "Location Shape Extension.";
}
else
{
return "Error";
}
}
private string AcknowledgementRequestDefinition(string acknowledgementRequestBinaryValue)
{
if ((acknowledgementRequestBinaryValue.CompareTo("0") == 0))
{
return "No Acknowledgement requested";
}
else
{
return "Acknowledgement requested";
}
}
private string MinimumReportingIntervalDefinition(string minimumReportingIntervalBinaryValue)
{
if ((Convert.ToInt32(minimumReportingIntervalBinaryValue, 2) < 28))
{
int min = Convert.ToInt32(minimumReportingIntervalBinaryValue, 2) * 10;
return Convert.ToString(min) + "s";
}
else if ((Convert.ToInt32(minimumReportingIntervalBinaryValue, 2) < 58))
{
int min = 5;
int i = 0;
for (i = 29; i <= Convert.ToInt32(minimumReportingIntervalBinaryValue, 2) - 1; i++)
{
min = Convert.ToInt16(min + 0.5);
}
return Convert.ToString(min) + "min";
}
else
{
int min = 20;
int i = 0;
for (i = 59; i <= Convert.ToInt32(minimumReportingIntervalBinaryValue, 2) - 1; i++)
{
min = min + 1;
}
return Convert.ToString(min) + "min";
}
}
private string ResultCodeDefinition(string resultCodeBinaryValue)
{
if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 0))
{
return "Success";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 1))
{
return "System Failure";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 2))
{
return "Unspecified Error";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 3))
{
return "Unauthorized application";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 4))
{
return "Unknown subscriber";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 5))
{
return "Absent subscriber";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 6))
{
return "Congestion in provider";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 7))
{
return "Congestion in mobile network";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 8))
{
return "Unsupported version";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 9))
{
return "Insufficient resource";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 10))
{
return "Syntax error";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 11))
{
return "Protocol element not supported";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 12))
{
return "Service not supported";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 13))
{
return "Protocol element value not supported";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 14))
{
return "Type of information not currently available";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 15))
{
return "Required accuracy not achieved";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 16))
{
return "Reserved";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 17))
{
return "Reporting will stop";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 18))
{
return "Time Expired";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 19))
{
return "Disallowed by local regulation";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 20))
{
return "Reserved";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 21))
{
return "No Such Request";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 22))
{
return "User disabled location information report sending";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 23))
{
return "Parameter values modified";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 24))
{
return "Accepted";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 25))
{
return "Accepted, but some of the triggers or accuracies are modified or are not supported";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 26))
{
return "Triggers not supported";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 27))
{
return "Reserved";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 80))
{
return "Reserved";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 200))
{
return "Insufficient GPS satellites";
}
else if ((Convert.ToInt32(resultCodeBinaryValue, 2) == 201))
{
return "Bad GPS geometry";
}
else
{
return "Reserved";
}
}
private string LocationReportingEnableFlagsDefinition(string locationReportingEnableFlagsBinaryValue)
{
if ((locationReportingEnableFlagsBinaryValue.CompareTo("10000000") == 0))
{
return "Location reporting globally enabled.";
}
else if ((locationReportingEnableFlagsBinaryValue.CompareTo("00000000") == 0))
{
return "Location reporting globally disabled.";
}
else
{
return "Reserved";
}
}
private string MaximumInformationAgeDefinition(string maximumInformationAgeBinaryValue)
{
int k = Convert.ToInt32(maximumInformationAgeBinaryValue, 2);
if ((k < 29))
{
int min = k + 1;
return Convert.ToString(min) + "s";
}
else if ((k < 59))
{
int min = 30;
int i = 0;
for (i = 29; i <= k - 1; i++)
{
min = min + 5;
}
return Convert.ToString(min) + "s";
}
else if ((k < 73))
{
double min = 3;
int i = 0;
for (i = 59; i <= k - 1; i++)
{
min = min + 0.5;
}
return Convert.ToString(min) + "min";
}
else if ((k < 127))
{
double min = 10;
int i = 0;
for (i = 73; i <= k - 1; i++)
{
min = min + 1;
}
return Convert.ToString(min) + "min";
}
else
{
return "Best Effort";
}
}
private string MaximumResponseTimeDefinition(string maximumResponseTimeBinaryValue)
{
if ((Convert.ToInt32(maximumResponseTimeBinaryValue, 2) != 0))
{
return Convert.ToString((Convert.ToInt32(maximumResponseTimeBinaryValue, 2) * 2)) + "s";
}
else
{
return "Immediate";
}
}
private void StartTimeDefinition(string startTimeBinaryValue)
{
startTimeDayBinaryValue = startTimeBinaryValue.Substring(0, 5);
startTimeHourBinaryValue = startTimeBinaryValue.Substring(0 + 5, 5);
startTimeMinuteBinaryValue = startTimeBinaryValue.Substring(0 + 5 + 5, 6);
startTimeSecondBinaryValue = startTimeBinaryValue.Substring(0 + 5 + 5 + 6, 6);
startTimeDay = Convert.ToString(Convert.ToInt32(startTimeDayBinaryValue, 2));
startTimeHour = Convert.ToString(Convert.ToInt32(startTimeHourBinaryValue, 2));
startTimeMinute = Convert.ToString(Convert.ToInt32(startTimeMinuteBinaryValue, 2));
startTimeSecond = Convert.ToString(Convert.ToInt32(startTimeSecondBinaryValue, 2));
}
private void StopTimeDefinition(string stopTimeBinaryValue)
{
stopTimeDayBinaryValue = stopTimeBinaryValue.Substring(0, 5);
stopTimeHourBinaryValue = stopTimeBinaryValue.Substring(0 + 5, 5);
stopTimeMinuteBinaryValue = stopTimeBinaryValue.Substring(0 + 5 + 5, 6);
stopTimeSecondBinaryValue = stopTimeBinaryValue.Substring(0 + 5 + 5 + 6, 6);
stopTimeDay = Convert.ToString(Convert.ToInt32(stopTimeDayBinaryValue, 2));
stopTimeHour = Convert.ToString(Convert.ToInt32(stopTimeHourBinaryValue, 2));
stopTimeMinute = Convert.ToString(Convert.ToInt32(stopTimeMinuteBinaryValue, 2));
stopTimeSecond = Convert.ToString(Convert.ToInt32(stopTimeSecondBinaryValue, 2));
}
private string RequestPriorityDefinition(string requestPriorityBinaryValue)
{
if ((Convert.ToInt32(requestPriorityBinaryValue, 2) == 0))
{
return "Low Request Priority";
}
else if ((Convert.ToInt32(requestPriorityBinaryValue, 2) == 1))
{
return "Normal Request Priority";
}
else if ((Convert.ToInt32(requestPriorityBinaryValue, 2) == 2))
{
return "High Request Priority";
}
else
{
return "Highest Request Priority";
}
}
private string TriggerDefinitionDefinition(string triggerDefinitionBinaryValue)
{
//previously known as triggerDefinition
if ((Convert.ToInt32(triggerDefinitionBinaryValue, 2) == 0))
{
return "Subcriber unit is powered ON";
}
else if ((Convert.ToInt32(triggerDefinitionBinaryValue, 2) == 1))
{
return "Subcriber unit is powered OFF";
}
else if ((Convert.ToInt32(triggerDefinitionBinaryValue, 2) == 2))
{
return "Emergency condition is detected";
}
else if ((Convert.ToInt32(triggerDefinitionBinaryValue, 2) == 3))
{
return "Push to talk condition detected";
}
else
{
return "Please refer to Trigger Type PDU";
}
}
// ENCODED functions
public string encoder(int selectedindex, int binarylength)
{
string temp = null;
temp = Convert.ToString(selectedindex, 2);
int k = binarylength - temp.Length;
int i = 0;
for (i = 0; i <= k - 1; i++)
{
temp = "0" + temp;
}
return temp;
}
public string LongitudeEncoder(double input)
{
//longitude 25 bits
double longitudeconst = 360 / Math.Pow(2, 25);
int longitude = Convert.ToInt32(input / longitudeconst);
string longi = Convert.ToString(longitude, 2);
string temp = "";
int i = 0;
for (i = 0; i <= 25 - longi.Length - 1; i++)
{
temp = "0" + temp;
}
return temp + longi;
}
public string LatitudeEencoder(double input)
{
//latitude 24 bits
double latitudeconst = 180 / Math.Pow(2, 24);
int latitude = Convert.ToInt32(input / latitudeconst);
string lati = Convert.ToString(latitude, 2);
string temp = "";
int i = 0;
for (i = 0; i <= 24 - lati.Length - 1; i++)
{
temp = "0" + temp;
}
return temp + lati;
}
public string BinarytoHexCode(string BinaryEncoded)
{
string hexCode = "";
int modd = BinaryEncoded.Length % 4;
if ((modd == 1))
{
BinaryEncoded = BinaryEncoded + "000";
}
if ((modd == 2))
{
BinaryEncoded = BinaryEncoded + "00";
}
if ((modd == 3))
{
BinaryEncoded = BinaryEncoded + "0";
}
int i = 0;
for (i = 0; i <= (BinaryEncoded.Length / 4) - 1; i++)
{
string temp = "";
temp = Convert.ToString(Convert.ToInt32(BinaryEncoded.Substring(i * 4, 4), 2), 16);
hexCode = hexCode + temp;
}
int result = hexCode.Length % 2;
if (result != 0)
{
hexCode = hexCode + "0";
}
return hexCode;
}
public string BinarytoBinaryCode(string BinaryEncoded)
{
int modd = BinaryEncoded.Length % 4;
if ((modd == 1))
{
BinaryEncoded = BinaryEncoded + "000";
}
if ((modd == 2))
{
BinaryEncoded = BinaryEncoded + "00";
}
if ((modd == 3))
{
BinaryEncoded = BinaryEncoded + "0";
}
return BinaryEncoded;
}
public string Type5Encoder(int BinaryEncodedIdentifier, string BinaryEncoded)
{
string temp = "";
////identifier 5 bits
temp = encoder(BinaryEncodedIdentifier, 5);
////length 6 bits
temp = temp + encoder(BinaryEncoded.Length, 6);
////data
temp = temp + BinaryEncoded;
return temp;
}
}
}