public AisMessage CreateMessage(BitArray payload) { var type = payload.DecodeByte(0, 5); if (type != c_type) { throw new Exception(string.Format("Incorrect type, expected 19 but present:{0}", type)); } var timeStamp = DateTime.UtcNow.ToFileTimeUtc(); byte repeatIndicator = payload.DecodeByte(6, 7); uint mmsi = payload.DecodeUInt32(8, 37); float sog = (float)payload.DecodeUInt32(46, 55) / 10; bool posAccuracy = payload.DecodeBool(56); float longtitude = (float)payload.DecodeFloat(57, 84) / 600000; float latitude = (float)payload.DecodeFloat(85, 111) / 600000; float cog = (float)payload.DecodeUInt32(112, 123) / 10; ushort heading = payload.DecodeUShort(124, 132); byte utcSeconds = payload.DecodeByte(133, 138); string vesselName = payload.DecodeString(143, 262).Trim(); ShipType shipType = (ShipType)payload.DecodeByte(263, 270); uint bow = payload.DecodeUInt32(271, 279); uint stern = payload.DecodeUInt32(280, 288); byte port = payload.DecodeByte(289, 294); byte starboard = payload.DecodeByte(295, 300); EpfdFixType positionFixType = (EpfdFixType)payload.DecodeByte(301, 304); bool raim = payload.DecodeBool(305); bool dataTerminalReady = payload.DecodeBool(306); bool assigned = payload.DecodeBool(307); byte spare = payload.DecodeByte(308, 311); return(new ClassBExtendedPositionReportMessage( type, timeStamp, repeatIndicator, mmsi, sog, posAccuracy, longtitude, latitude, cog, heading, utcSeconds, vesselName, shipType, bow, stern, port, starboard, positionFixType, raim, dataTerminalReady, assigned, spare)); }
public AisMessage CreateMessage(BitArray payload) { var type = payload.DecodeByte(0, 5); if (type != c_type) { throw new Exception(string.Format("Incorrect type, expected 18 but present:{0}", type)); } var timeStamp = DateTime.UtcNow.ToFileTimeUtc(); byte repeatIndicator = payload.DecodeByte(6, 7); uint mmsi = payload.DecodeUInt32(8, 37); float sog = (float)payload.DecodeUInt32(46, 55) / 10; bool posAccuracy = payload.DecodeBool(56); float longtitude = (float)payload.DecodeFloat(57, 84) / 600000; float latitude = (float)payload.DecodeFloat(85, 111) / 600000; float cog = (float)payload.DecodeUInt32(112, 123) / 10; ushort heading = payload.DecodeUShort(124, 132); byte utcSeconds = payload.DecodeByte(133, 138); CsUnitType csUnit = payload.DecodeBool(141) ? CsUnitType.ClassBCarrierSense : CsUnitType.ClassBSotdma; bool display = payload.DecodeBool(142); bool dsc = payload.DecodeBool(143); bool band = payload.DecodeBool(144); bool message22 = payload.DecodeBool(145); bool assigned = payload.DecodeBool(146); bool raim = payload.DecodeBool(147); uint radioStatus = payload.DecodeUInt32(148, 167); return(new ClassBPositionReportMessage( type, timeStamp, repeatIndicator, mmsi, sog, posAccuracy, longtitude, latitude, cog, heading, utcSeconds, raim, radioStatus, csUnit, display, dsc, band, message22, assigned)); }
public AisMessage CreateMessage(BitArray payload) { var type = payload.DecodeByte(0, 5); if (type != c_type1 && type != c_type2 && type != c_type3) { throw new Exception(string.Format("Incorrect type, expected 1,2,3 but present:{0}", type)); } var timeStamp = DateTime.UtcNow.ToFileTimeUtc(); byte repeatIndicator = payload.DecodeByte(6, 7); uint mmsi = payload.DecodeUInt32(8, 37); NavigationStatus navStatus = (NavigationStatus)payload.DecodeByte(38, 41); int rot = payload.DecodeInt32(42, 49); float sog = (float)payload.DecodeUInt32(50, 59) / 10; bool posAccuracy = payload.DecodeBool(60); float longtitude = (float)payload.DecodeFloat(61, 88) / 600000; float latitude = (float)payload.DecodeFloat(89, 115) / 600000; float cog = (float)payload.DecodeUInt32(116, 127) / 10; ushort heading = payload.DecodeUShort(128, 136); byte utcSeconds = payload.DecodeByte(137, 142); ManeuverIndicator manuevrIndicator = (ManeuverIndicator)payload.DecodeByte(143, 144); byte spare = payload.DecodeByte(145, 147); bool raim = payload.DecodeBool(148); uint radioStatus = payload.DecodeUInt32(149, 167); return(new ClassAPositionReportMessage( type, timeStamp, repeatIndicator, mmsi, navStatus, rot, sog, posAccuracy, longtitude, latitude, cog, heading, utcSeconds, manuevrIndicator, spare, raim, radioStatus)); }