Beispiel #1
0
        private static GPSFix ConstructGPSFix(Packet gpsPacket)
        {
            if (gpsPacket.GetField(STIRConsts.FieldName_User).value != STIRConsts.NID_XUser_STIR)
            {
                return(null);//Packet not intended for us
            }
            GPSFix theFix = new GPSFix();

            //Co-ordinates are D M'mm.mmm'
            theFix.LatDegrees         = (UInt16)gpsPacket.GetField(STIRConsts.FieldName_LatDegrees).value;
            theFix.LatMinutes         = (UInt16)gpsPacket.GetField(STIRConsts.FieldName_LatMinutes).value;
            theFix.LatDecimal         = (byte)gpsPacket.GetField(STIRConsts.FieldName_LatDecimal).value;
            theFix.LatMinutesFraction = gpsPacket.GetField(STIRConsts.FieldName_LatFraction).value;
            theFix.LatHemishpere      = (char)gpsPacket.GetField(STIRConsts.FieldName_LatHemisphere).value;
            theFix.LonDegrees         = (UInt16)gpsPacket.GetField(STIRConsts.FieldName_LonDegrees).value;
            theFix.LonMinutes         = (UInt16)gpsPacket.GetField(STIRConsts.FieldName_LonMinutes).value;
            theFix.LonDecimal         = (byte)gpsPacket.GetField(STIRConsts.FieldName_LonDecimal).value;
            theFix.LonMinutesFraction = gpsPacket.GetField(STIRConsts.FieldName_LonFraction).value;
            //Speed in knots
            theFix.SpeedKnotsInteger  = gpsPacket.GetField(STIRConsts.FieldName_SPEED_KNOTS_INTEGER).value;
            theFix.SpeedKnotsDecimal  = (byte)gpsPacket.GetField(STIRConsts.FieldName_SPEED_DECIMAL_POINT).value;
            theFix.SpeedKnotsFraction = (byte)gpsPacket.GetField(STIRConsts.FieldName_SPEED_KNOTS_FRACTION).value;
            //Fix time
            theFix.Hours            = (ushort)gpsPacket.GetField(STIRConsts.FieldName_Hours).value;
            theFix.Minutes          = (ushort)gpsPacket.GetField(STIRConsts.FieldName_Minutes).value;
            theFix.Seconds          = (ushort)gpsPacket.GetField(STIRConsts.FieldName_Seconds).value;
            theFix.Decimal_Point    = (byte)gpsPacket.GetField(STIRConsts.FieldName_Hours).value;
            theFix.Seconds_Fraction = (ushort)gpsPacket.GetField(STIRConsts.FieldName_Seconds_Fraction).value;
            //other
            theFix.FixType = (byte)gpsPacket.GetField(STIRConsts.FieldName_FIXTYPE).value;
            theFix.Offset  = (byte)gpsPacket.GetField(STIRConsts.FieldName_Offset).value;

            return(theFix);
        }
Beispiel #2
0
        private CompletePossitionReport ProcessTrainPosMessage(PCBridgeDataTransferMessage dataMessage)
        {
            CompletePossitionReport complete = new CompletePossitionReport();
            Packet gpsPacket  = dataMessage.GetPacket(STIRConsts.Packet_OtherData);      //packet 44
            GPSFix gpsDetails = ConstructGPSFix(gpsPacket);
            Packet posPacket  = dataMessage.GetPacket(STIRConsts.Packet_PositionReport); //packet 0

            if (posPacket != null)
            {
                complete.Basic = ConstructReport(posPacket);
            }
            if (gpsDetails != null)
            {
                complete.GPSDetails = gpsDetails;
            }
            Field Q_CABROLE = dataMessage.GetMessageField(STIRConsts.FieldName_Q_CABROLE);

            if (Q_CABROLE != null)
            {
                complete.FrontCabNotBack = Q_CABROLE.value == 0;
            }

            Field Q_STIRSTATUS = dataMessage.GetMessageField(STIRConsts.FieldName_Q_CABROLE);

            if (Q_STIRSTATUS != null)
            {
                complete.Stir_Status = (StirStatusEnum)(byte)Q_STIRSTATUS.value;
            }

            complete.NID_Engine = dataMessage.GetMessageField(STIRConsts.FieldName_NID_ENGINE).value;
            complete.TSAP       = dataMessage.TSAP;
            return(complete);
        }