Skip to content

Commit

Permalink
Fix for multiple trackJamRecords in Electromagnetic Emission Pdu
Browse files Browse the repository at this point in the history
For #14
  • Loading branch information
leif81 committed Dec 20, 2020
1 parent a1228c9 commit 20ab9a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions opendis/dis7.py
Original file line number Diff line number Diff line change
Expand Up @@ -5403,7 +5403,7 @@ def __init__(self):
self.numberOfTargetsInTrackJam = 0
self.highDensityTrackJam = 0
self.jammingModeSequence = 0
self.trackJamRecord = TrackJamData();
self.trackJamRecords = [];

def serialize(self, outputStream):
outputStream.write_unsigned_byte(self.systemDataLength);
Expand All @@ -5420,7 +5420,9 @@ def serialize(self, outputStream):
outputStream.read_unsigned_byte(self.highDensityTrackJam);
outputStream.read_unsigned_byte(0); # 8 bit padding
outputStream.read_unsigned_int(self.jammingModeSequence);
self.trackJamRecord.serialize(outputStream);

for anObj in self.trackJamRecords:
anObj.serialize(outputStream)

def parse(self, inputStream):
self.systemDataLength = inputStream.read_unsigned_byte();
Expand All @@ -5437,7 +5439,11 @@ def parse(self, inputStream):
self.highDensityTrackJam = inputStream.read_unsigned_byte();
inputStream.read_unsigned_byte(); # 8 bit padding
self.jammingModeSequence = inputStream.read_unsigned_int();
self.trackJamRecord.parse(inputStream);

for idx in range(0, self.numberOfTargetsInTrackJam):
element = TrackJamData()
element.parse(inputStream)
self.trackJamRecords.append(element)


class ResupplyOfferPdu( LogisticsFamilyPdu ):
Expand Down
10 changes: 5 additions & 5 deletions tests/testElectromageneticEmissionPdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ def test_parse(self):
self.assertEqual(0, pdu.systems[0].highDensityTrackJam)
self.assertEqual(0, pdu.systems[0].jammingModeSequence)

self.assertEqual(23, pdu.systems[0].trackJamRecord.entityID.siteID)
self.assertEqual(1, pdu.systems[0].trackJamRecord.entityID.applicationID)
self.assertEqual(1, pdu.systems[0].trackJamRecord.entityID.entityID)
self.assertEqual(0, pdu.systems[0].trackJamRecord.emitterNumber)
self.assertEqual(0, pdu.systems[0].trackJamRecord.beamNumber)
self.assertEqual(23, pdu.systems[0].trackJamRecords[0].entityID.siteID)
self.assertEqual(1, pdu.systems[0].trackJamRecords[0].entityID.applicationID)
self.assertEqual(1, pdu.systems[0].trackJamRecords[0].entityID.entityID)
self.assertEqual(0, pdu.systems[0].trackJamRecords[0].emitterNumber)
self.assertEqual(0, pdu.systems[0].trackJamRecords[0].beamNumber)


if __name__ == '__main__':
Expand Down

0 comments on commit 20ab9a3

Please sign in to comment.