@its-c10/dis-codec 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/dist/binary/BinaryReader.d.ts +21 -0
- package/dist/binary/BinaryReader.js +92 -0
- package/dist/binary/BinaryWriter.d.ts +24 -0
- package/dist/binary/BinaryWriter.js +88 -0
- package/dist/binary.d.ts +36 -0
- package/dist/binary.js +144 -0
- package/dist/codecs/common/decodeEntityId.d.ts +3 -0
- package/dist/codecs/common/decodeEntityId.js +7 -0
- package/dist/codecs/common/encodeEntityId.d.ts +3 -0
- package/dist/codecs/common/encodeEntityId.js +5 -0
- package/dist/codecs/entityId.d.ts +10 -0
- package/dist/codecs/entityId.js +12 -0
- package/dist/core/entityId.d.ts +14 -0
- package/dist/core/entityId.js +14 -0
- package/dist/core/eventId.d.ts +12 -0
- package/dist/core/eventId.js +14 -0
- package/dist/dis/clockTime.d.ts +14 -0
- package/dist/dis/clockTime.js +10 -0
- package/dist/dis7/constants.d.ts +41 -0
- package/dist/dis7/constants.js +41 -0
- package/dist/dis7/createEntityPdu.d.ts +13 -0
- package/dist/dis7/createEntityPdu.js +17 -0
- package/dist/dis7/electromagneticEmissionPdu.d.ts +72 -0
- package/dist/dis7/electromagneticEmissionPdu.js +133 -0
- package/dist/dis7/entityStatePdu.d.ts +80 -0
- package/dist/dis7/entityStatePdu.js +149 -0
- package/dist/dis7/index.d.ts +12 -0
- package/dist/dis7/index.js +12 -0
- package/dist/dis7/pduHeader.d.ts +18 -0
- package/dist/dis7/pduHeader.js +22 -0
- package/dist/dis7/removeEntityPdu.d.ts +13 -0
- package/dist/dis7/removeEntityPdu.js +17 -0
- package/dist/dis7/startResumePdu.d.ts +16 -0
- package/dist/dis7/startResumePdu.js +22 -0
- package/dist/dis7/stopFreezePdu.d.ts +21 -0
- package/dist/dis7/stopFreezePdu.js +26 -0
- package/dist/dis7/transmitterPdu.d.ts +110 -0
- package/dist/dis7/transmitterPdu.js +200 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/types/EntityId.d.ts +6 -0
- package/dist/types/EntityId.js +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DIS protocol version 7 (IEEE 1278.1-2012 application protocols).
|
|
3
|
+
* Version is implied by module path; add `dis8/constants.ts` etc. for other editions.
|
|
4
|
+
*/
|
|
5
|
+
export const PROTOCOL_VERSION = 7;
|
|
6
|
+
/** Entity Information protocol family. */
|
|
7
|
+
export const PROTOCOL_FAMILY_ENTITY_INFORMATION = 1;
|
|
8
|
+
/** Simulation Management protocol family. */
|
|
9
|
+
export const PROTOCOL_FAMILY_SIMULATION_MANAGEMENT = 5;
|
|
10
|
+
/** PDU type: Entity State. */
|
|
11
|
+
export const PDU_TYPE_ENTITY_STATE = 1;
|
|
12
|
+
/** PDU type: Create Entity. */
|
|
13
|
+
export const PDU_TYPE_CREATE_ENTITY = 11;
|
|
14
|
+
/** PDU type: Remove Entity. */
|
|
15
|
+
export const PDU_TYPE_REMOVE_ENTITY = 12;
|
|
16
|
+
/** PDU type: Start/Resume. */
|
|
17
|
+
export const PDU_TYPE_START_RESUME = 13;
|
|
18
|
+
/** PDU type: Stop/Freeze. */
|
|
19
|
+
export const PDU_TYPE_STOP_FREEZE = 14;
|
|
20
|
+
/** PDU type: Electromagnetic Emission. */
|
|
21
|
+
export const PDU_TYPE_ELECTROMAGNETIC_EMISSION = 23;
|
|
22
|
+
/** PDU type: Transmitter. */
|
|
23
|
+
export const PDU_TYPE_TRANSMITTER = 25;
|
|
24
|
+
/** Electromagnetic Emission protocol family. */
|
|
25
|
+
export const PROTOCOL_FAMILY_ELECTROMAGNETIC_EMISSION = 6;
|
|
26
|
+
/** Radio Communications protocol family. */
|
|
27
|
+
export const PROTOCOL_FAMILY_RADIO_COMMUNICATIONS = 4;
|
|
28
|
+
/** Start/Resume PDU total length on wire (bytes). */
|
|
29
|
+
export const START_RESUME_PDU_LENGTH = 44;
|
|
30
|
+
/** Stop/Freeze PDU total length on wire (bytes). */
|
|
31
|
+
export const STOP_FREEZE_PDU_LENGTH = 40;
|
|
32
|
+
/** Create Entity PDU total length on wire (bytes). */
|
|
33
|
+
export const CREATE_ENTITY_PDU_LENGTH = 28;
|
|
34
|
+
/** Remove Entity PDU total length on wire (bytes). */
|
|
35
|
+
export const REMOVE_ENTITY_PDU_LENGTH = 28;
|
|
36
|
+
/** Entity State PDU fixed portion in bytes (144). Total = 144 + 16*N for N variable parameters. */
|
|
37
|
+
export const ENTITY_STATE_PDU_FIXED_LENGTH = 144;
|
|
38
|
+
/** Variable parameter record size in bytes. */
|
|
39
|
+
export const ENTITY_STATE_VARIABLE_PARAMETER_RECORD_LENGTH = 16;
|
|
40
|
+
/** Transmitter PDU fixed portion in bytes (104). Total = 104 + M + A + sum of variable record sizes. */
|
|
41
|
+
export const TRANSMITTER_PDU_FIXED_LENGTH = 104;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
5
|
+
/** Create Entity PDU (224 bits). Table 149. */
|
|
6
|
+
export interface CreateEntityPdu {
|
|
7
|
+
header: PduHeader;
|
|
8
|
+
originatingId: EntityId;
|
|
9
|
+
receivingId: EntityId;
|
|
10
|
+
requestId: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function decodeCreateEntityPdu(reader: BinaryReader): CreateEntityPdu;
|
|
13
|
+
export declare function encodeCreateEntityPdu(writer: BinaryWriter, pdu: CreateEntityPdu): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { decodeEntityId, encodeEntityId } from "../core/entityId.js";
|
|
2
|
+
import { decodePduHeader, encodePduHeader } from "./pduHeader.js";
|
|
3
|
+
export function decodeCreateEntityPdu(reader) {
|
|
4
|
+
return {
|
|
5
|
+
header: decodePduHeader(reader),
|
|
6
|
+
originatingId: decodeEntityId(reader),
|
|
7
|
+
receivingId: decodeEntityId(reader),
|
|
8
|
+
requestId: reader.readUint32(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function encodeCreateEntityPdu(writer, pdu) {
|
|
12
|
+
encodePduHeader(writer, pdu.header);
|
|
13
|
+
encodeEntityId(writer, pdu.originatingId);
|
|
14
|
+
encodeEntityId(writer, pdu.receivingId);
|
|
15
|
+
writer.writeUint32(pdu.requestId);
|
|
16
|
+
writer.patchUint16(8, writer.getOffset());
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { EventId } from "../core/eventId.js";
|
|
5
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
6
|
+
/** Fundamental parameter data for one beam (five float32s). */
|
|
7
|
+
export interface FundamentalParameterData {
|
|
8
|
+
frequency: number;
|
|
9
|
+
frequencyRange: number;
|
|
10
|
+
effectiveRadiatedPower: number;
|
|
11
|
+
pulseRepetitionFrequency: number;
|
|
12
|
+
pulseWidth: number;
|
|
13
|
+
}
|
|
14
|
+
/** Beam data group (azimuth/elevation center and sweep, sync). */
|
|
15
|
+
export interface BeamDataGroup {
|
|
16
|
+
beamAzimuthCenter: number;
|
|
17
|
+
beamAzimuthSweep: number;
|
|
18
|
+
beamElevationCenter: number;
|
|
19
|
+
beamElevationSweep: number;
|
|
20
|
+
beamSweepSync: number;
|
|
21
|
+
}
|
|
22
|
+
/** Beam data record (repeats M_i times per emitter system). */
|
|
23
|
+
export interface BeamData {
|
|
24
|
+
beamDataLength: number;
|
|
25
|
+
beamNumber: number;
|
|
26
|
+
beamParameterIndex: number;
|
|
27
|
+
fundamentalParameterData: FundamentalParameterData;
|
|
28
|
+
beamData: BeamDataGroup;
|
|
29
|
+
beamFunction: number;
|
|
30
|
+
numberOfTargets: number;
|
|
31
|
+
highDensityTrackJam: number;
|
|
32
|
+
beamStatus: number;
|
|
33
|
+
}
|
|
34
|
+
/** Emitter system (name, function, number) and location. */
|
|
35
|
+
export interface EmitterSystemRecord {
|
|
36
|
+
emitterName: number;
|
|
37
|
+
emitterFunction: number;
|
|
38
|
+
emitterNumber: number;
|
|
39
|
+
}
|
|
40
|
+
/** Location with respect to entity (x, y, z float32). */
|
|
41
|
+
export interface Location {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
z: number;
|
|
45
|
+
}
|
|
46
|
+
/** One emitter system: fixed fields plus M beams. */
|
|
47
|
+
export interface EmitterSystemData {
|
|
48
|
+
systemDataLength: number;
|
|
49
|
+
numberOfBeams: number;
|
|
50
|
+
padding: number;
|
|
51
|
+
emitterSystem: EmitterSystemRecord;
|
|
52
|
+
location: Location;
|
|
53
|
+
beams: BeamData[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Electromagnetic Emission (EE) PDU (Table 161).
|
|
57
|
+
* Header (96 bits), emitting entity ID, event ID, state/count, then N emitter system data blocks.
|
|
58
|
+
*/
|
|
59
|
+
export interface ElectromagneticEmissionPdu {
|
|
60
|
+
header: PduHeader;
|
|
61
|
+
emittingEntityId: EntityId;
|
|
62
|
+
eventId: EventId;
|
|
63
|
+
/** 8-bit enumeration. */
|
|
64
|
+
stateUpdateIndicator: number;
|
|
65
|
+
/** Number of emitter systems (N). */
|
|
66
|
+
numberOfSystems: number;
|
|
67
|
+
/** 16-bit padding. */
|
|
68
|
+
padding: number;
|
|
69
|
+
emitterSystems: EmitterSystemData[];
|
|
70
|
+
}
|
|
71
|
+
export declare function decodeElectromagneticEmissionPdu(reader: BinaryReader): ElectromagneticEmissionPdu;
|
|
72
|
+
export declare function encodeElectromagneticEmissionPdu(writer: BinaryWriter, pdu: ElectromagneticEmissionPdu): void;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { decodeEntityId, encodeEntityId } from "../core/entityId.js";
|
|
2
|
+
import { decodeEventId, encodeEventId } from "../core/eventId.js";
|
|
3
|
+
import { decodePduHeader, encodePduHeader } from "./pduHeader.js";
|
|
4
|
+
function decodeFundamentalParameterData(reader) {
|
|
5
|
+
return {
|
|
6
|
+
frequency: reader.readFloat32(),
|
|
7
|
+
frequencyRange: reader.readFloat32(),
|
|
8
|
+
effectiveRadiatedPower: reader.readFloat32(),
|
|
9
|
+
pulseRepetitionFrequency: reader.readFloat32(),
|
|
10
|
+
pulseWidth: reader.readFloat32(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function encodeFundamentalParameterData(writer, data) {
|
|
14
|
+
writer.writeFloat32(data.frequency);
|
|
15
|
+
writer.writeFloat32(data.frequencyRange);
|
|
16
|
+
writer.writeFloat32(data.effectiveRadiatedPower);
|
|
17
|
+
writer.writeFloat32(data.pulseRepetitionFrequency);
|
|
18
|
+
writer.writeFloat32(data.pulseWidth);
|
|
19
|
+
}
|
|
20
|
+
function decodeBeamDataGroup(reader) {
|
|
21
|
+
return {
|
|
22
|
+
beamAzimuthCenter: reader.readFloat32(),
|
|
23
|
+
beamAzimuthSweep: reader.readFloat32(),
|
|
24
|
+
beamElevationCenter: reader.readFloat32(),
|
|
25
|
+
beamElevationSweep: reader.readFloat32(),
|
|
26
|
+
beamSweepSync: reader.readFloat32(),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function encodeBeamDataGroup(writer, data) {
|
|
30
|
+
writer.writeFloat32(data.beamAzimuthCenter);
|
|
31
|
+
writer.writeFloat32(data.beamAzimuthSweep);
|
|
32
|
+
writer.writeFloat32(data.beamElevationCenter);
|
|
33
|
+
writer.writeFloat32(data.beamElevationSweep);
|
|
34
|
+
writer.writeFloat32(data.beamSweepSync);
|
|
35
|
+
}
|
|
36
|
+
function decodeBeamData(reader) {
|
|
37
|
+
return {
|
|
38
|
+
beamDataLength: reader.readUint8(),
|
|
39
|
+
beamNumber: reader.readUint8(),
|
|
40
|
+
beamParameterIndex: reader.readUint16(),
|
|
41
|
+
fundamentalParameterData: decodeFundamentalParameterData(reader),
|
|
42
|
+
beamData: decodeBeamDataGroup(reader),
|
|
43
|
+
beamFunction: reader.readUint8(),
|
|
44
|
+
numberOfTargets: reader.readUint8(),
|
|
45
|
+
highDensityTrackJam: reader.readUint8(),
|
|
46
|
+
beamStatus: reader.readUint8(),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function encodeBeamData(writer, beam) {
|
|
50
|
+
writer.writeUint8(beam.beamDataLength);
|
|
51
|
+
writer.writeUint8(beam.beamNumber);
|
|
52
|
+
writer.writeUint16(beam.beamParameterIndex);
|
|
53
|
+
encodeFundamentalParameterData(writer, beam.fundamentalParameterData);
|
|
54
|
+
encodeBeamDataGroup(writer, beam.beamData);
|
|
55
|
+
writer.writeUint8(beam.beamFunction);
|
|
56
|
+
writer.writeUint8(beam.numberOfTargets);
|
|
57
|
+
writer.writeUint8(beam.highDensityTrackJam);
|
|
58
|
+
writer.writeUint8(beam.beamStatus);
|
|
59
|
+
}
|
|
60
|
+
function decodeEmitterSystemData(reader) {
|
|
61
|
+
const systemDataLength = reader.readUint8();
|
|
62
|
+
const numberOfBeams = reader.readUint8();
|
|
63
|
+
const padding = reader.readUint16();
|
|
64
|
+
const emitterSystem = {
|
|
65
|
+
emitterName: reader.readUint16(),
|
|
66
|
+
emitterFunction: reader.readUint8(),
|
|
67
|
+
emitterNumber: reader.readUint8(),
|
|
68
|
+
};
|
|
69
|
+
const location = {
|
|
70
|
+
x: reader.readFloat32(),
|
|
71
|
+
y: reader.readFloat32(),
|
|
72
|
+
z: reader.readFloat32(),
|
|
73
|
+
};
|
|
74
|
+
const beams = [];
|
|
75
|
+
for (let j = 0; j < numberOfBeams; j++) {
|
|
76
|
+
beams.push(decodeBeamData(reader));
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
systemDataLength,
|
|
80
|
+
numberOfBeams,
|
|
81
|
+
padding,
|
|
82
|
+
emitterSystem,
|
|
83
|
+
location,
|
|
84
|
+
beams,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function encodeEmitterSystemData(writer, sys) {
|
|
88
|
+
writer.writeUint8(sys.systemDataLength);
|
|
89
|
+
writer.writeUint8(sys.numberOfBeams);
|
|
90
|
+
writer.writeUint16(sys.padding);
|
|
91
|
+
writer.writeUint16(sys.emitterSystem.emitterName);
|
|
92
|
+
writer.writeUint8(sys.emitterSystem.emitterFunction);
|
|
93
|
+
writer.writeUint8(sys.emitterSystem.emitterNumber);
|
|
94
|
+
writer.writeFloat32(sys.location.x);
|
|
95
|
+
writer.writeFloat32(sys.location.y);
|
|
96
|
+
writer.writeFloat32(sys.location.z);
|
|
97
|
+
for (const beam of sys.beams) {
|
|
98
|
+
encodeBeamData(writer, beam);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export function decodeElectromagneticEmissionPdu(reader) {
|
|
102
|
+
const header = decodePduHeader(reader);
|
|
103
|
+
const emittingEntityId = decodeEntityId(reader);
|
|
104
|
+
const eventId = decodeEventId(reader);
|
|
105
|
+
const stateUpdateIndicator = reader.readUint8();
|
|
106
|
+
const numberOfSystems = reader.readUint8();
|
|
107
|
+
const padding = reader.readUint16();
|
|
108
|
+
const emitterSystems = [];
|
|
109
|
+
for (let i = 0; i < numberOfSystems; i++) {
|
|
110
|
+
emitterSystems.push(decodeEmitterSystemData(reader));
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
header,
|
|
114
|
+
emittingEntityId,
|
|
115
|
+
eventId,
|
|
116
|
+
stateUpdateIndicator,
|
|
117
|
+
numberOfSystems,
|
|
118
|
+
padding,
|
|
119
|
+
emitterSystems,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function encodeElectromagneticEmissionPdu(writer, pdu) {
|
|
123
|
+
encodePduHeader(writer, pdu.header);
|
|
124
|
+
encodeEntityId(writer, pdu.emittingEntityId);
|
|
125
|
+
encodeEventId(writer, pdu.eventId);
|
|
126
|
+
writer.writeUint8(pdu.stateUpdateIndicator);
|
|
127
|
+
writer.writeUint8(pdu.numberOfSystems);
|
|
128
|
+
writer.writeUint16(pdu.padding);
|
|
129
|
+
for (const sys of pdu.emitterSystems) {
|
|
130
|
+
encodeEmitterSystemData(writer, sys);
|
|
131
|
+
}
|
|
132
|
+
writer.patchUint16(8, writer.getOffset());
|
|
133
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
5
|
+
/** Entity type (64 bits): kind, domain, country, category, subcategory, specific, extra. */
|
|
6
|
+
export interface EntityType {
|
|
7
|
+
kind: number;
|
|
8
|
+
domain: number;
|
|
9
|
+
country: number;
|
|
10
|
+
category: number;
|
|
11
|
+
subcategory: number;
|
|
12
|
+
specific: number;
|
|
13
|
+
extra: number;
|
|
14
|
+
}
|
|
15
|
+
/** Three-component vector (float32). */
|
|
16
|
+
export interface Vector3Float {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
z: number;
|
|
20
|
+
}
|
|
21
|
+
/** Three-component vector (float64). */
|
|
22
|
+
export interface Vector3Double {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
z: number;
|
|
26
|
+
}
|
|
27
|
+
/** Entity orientation: psi, theta, phi (radians, float32). */
|
|
28
|
+
export interface Orientation {
|
|
29
|
+
psi: number;
|
|
30
|
+
theta: number;
|
|
31
|
+
phi: number;
|
|
32
|
+
}
|
|
33
|
+
/** Dead reckoning parameters (320 bits). */
|
|
34
|
+
export interface DeadReckoningParameters {
|
|
35
|
+
/** 8-bit enumeration. */
|
|
36
|
+
deadReckoningAlgorithm: number;
|
|
37
|
+
/** Other parameters, 120 bits (15 bytes). */
|
|
38
|
+
otherParameters: Uint8Array;
|
|
39
|
+
entityLinearAcceleration: Vector3Float;
|
|
40
|
+
entityAngularVelocity: Vector3Float;
|
|
41
|
+
}
|
|
42
|
+
/** Entity marking: character set plus 11 characters (96 bits). */
|
|
43
|
+
export interface EntityMarking {
|
|
44
|
+
/** 8-bit enumeration. */
|
|
45
|
+
characterSet: number;
|
|
46
|
+
/** 11 bytes (88 bits). */
|
|
47
|
+
characters: Uint8Array;
|
|
48
|
+
}
|
|
49
|
+
/** Variable parameter record (128 bits). */
|
|
50
|
+
export interface VariableParameter {
|
|
51
|
+
/** 8-bit enumeration. */
|
|
52
|
+
recordType: number;
|
|
53
|
+
/** Record-specific fields, 120 bits (15 bytes). */
|
|
54
|
+
recordSpecific: Uint8Array;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Entity State PDU (Table 134).
|
|
58
|
+
* Fixed part 1152 bits (144 bytes), then N variable parameter records of 128 bits (16 bytes) each.
|
|
59
|
+
*/
|
|
60
|
+
export interface EntityStatePdu {
|
|
61
|
+
header: PduHeader;
|
|
62
|
+
entityId: EntityId;
|
|
63
|
+
/** 8-bit enumeration (e.g. Friendly, Opposing, Neutral). */
|
|
64
|
+
forceId: number;
|
|
65
|
+
numberOfVariableParameterRecords: number;
|
|
66
|
+
entityType: EntityType;
|
|
67
|
+
alternateEntityType: EntityType;
|
|
68
|
+
entityLinearVelocity: Vector3Float;
|
|
69
|
+
entityLocation: Vector3Double;
|
|
70
|
+
entityOrientation: Orientation;
|
|
71
|
+
/** 32-bit record. */
|
|
72
|
+
entityAppearance: number;
|
|
73
|
+
deadReckoningParameters: DeadReckoningParameters;
|
|
74
|
+
entityMarking: EntityMarking;
|
|
75
|
+
/** 32-bit record. */
|
|
76
|
+
capabilities: number;
|
|
77
|
+
variableParameters: VariableParameter[];
|
|
78
|
+
}
|
|
79
|
+
export declare function decodeEntityStatePdu(reader: BinaryReader): EntityStatePdu;
|
|
80
|
+
export declare function encodeEntityStatePdu(writer: BinaryWriter, pdu: EntityStatePdu): void;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { decodeEntityId, encodeEntityId } from "../core/entityId.js";
|
|
2
|
+
import { decodePduHeader, encodePduHeader } from "./pduHeader.js";
|
|
3
|
+
const DEAD_RECKONING_OTHER_BYTES = 15;
|
|
4
|
+
const ENTITY_MARKING_CHARACTERS_BYTES = 11;
|
|
5
|
+
const VARIABLE_PARAM_RECORD_SPECIFIC_BYTES = 15;
|
|
6
|
+
function decodeEntityType(reader) {
|
|
7
|
+
return {
|
|
8
|
+
kind: reader.readUint8(),
|
|
9
|
+
domain: reader.readUint8(),
|
|
10
|
+
country: reader.readUint16(),
|
|
11
|
+
category: reader.readUint8(),
|
|
12
|
+
subcategory: reader.readUint8(),
|
|
13
|
+
specific: reader.readUint8(),
|
|
14
|
+
extra: reader.readUint8(),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function encodeEntityType(writer, e) {
|
|
18
|
+
writer.writeUint8(e.kind);
|
|
19
|
+
writer.writeUint8(e.domain);
|
|
20
|
+
writer.writeUint16(e.country);
|
|
21
|
+
writer.writeUint8(e.category);
|
|
22
|
+
writer.writeUint8(e.subcategory);
|
|
23
|
+
writer.writeUint8(e.specific);
|
|
24
|
+
writer.writeUint8(e.extra);
|
|
25
|
+
}
|
|
26
|
+
function decodeVector3Float(reader) {
|
|
27
|
+
return {
|
|
28
|
+
x: reader.readFloat32(),
|
|
29
|
+
y: reader.readFloat32(),
|
|
30
|
+
z: reader.readFloat32(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function encodeVector3Float(writer, v) {
|
|
34
|
+
writer.writeFloat32(v.x);
|
|
35
|
+
writer.writeFloat32(v.y);
|
|
36
|
+
writer.writeFloat32(v.z);
|
|
37
|
+
}
|
|
38
|
+
function decodeVector3Double(reader) {
|
|
39
|
+
return {
|
|
40
|
+
x: reader.readFloat64(),
|
|
41
|
+
y: reader.readFloat64(),
|
|
42
|
+
z: reader.readFloat64(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function encodeVector3Double(writer, v) {
|
|
46
|
+
writer.writeFloat64(v.x);
|
|
47
|
+
writer.writeFloat64(v.y);
|
|
48
|
+
writer.writeFloat64(v.z);
|
|
49
|
+
}
|
|
50
|
+
function decodeOrientation(reader) {
|
|
51
|
+
return {
|
|
52
|
+
psi: reader.readFloat32(),
|
|
53
|
+
theta: reader.readFloat32(),
|
|
54
|
+
phi: reader.readFloat32(),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function encodeOrientation(writer, o) {
|
|
58
|
+
writer.writeFloat32(o.psi);
|
|
59
|
+
writer.writeFloat32(o.theta);
|
|
60
|
+
writer.writeFloat32(o.phi);
|
|
61
|
+
}
|
|
62
|
+
function decodeDeadReckoningParameters(reader) {
|
|
63
|
+
return {
|
|
64
|
+
deadReckoningAlgorithm: reader.readUint8(),
|
|
65
|
+
otherParameters: reader.readBytes(DEAD_RECKONING_OTHER_BYTES),
|
|
66
|
+
entityLinearAcceleration: decodeVector3Float(reader),
|
|
67
|
+
entityAngularVelocity: decodeVector3Float(reader),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function encodeDeadReckoningParameters(writer, d) {
|
|
71
|
+
writer.writeUint8(d.deadReckoningAlgorithm);
|
|
72
|
+
writer.writeBytes(d.otherParameters);
|
|
73
|
+
encodeVector3Float(writer, d.entityLinearAcceleration);
|
|
74
|
+
encodeVector3Float(writer, d.entityAngularVelocity);
|
|
75
|
+
}
|
|
76
|
+
function decodeEntityMarking(reader) {
|
|
77
|
+
return {
|
|
78
|
+
characterSet: reader.readUint8(),
|
|
79
|
+
characters: reader.readBytes(ENTITY_MARKING_CHARACTERS_BYTES),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function encodeEntityMarking(writer, m) {
|
|
83
|
+
writer.writeUint8(m.characterSet);
|
|
84
|
+
writer.writeBytes(m.characters);
|
|
85
|
+
}
|
|
86
|
+
function decodeVariableParameter(reader) {
|
|
87
|
+
return {
|
|
88
|
+
recordType: reader.readUint8(),
|
|
89
|
+
recordSpecific: reader.readBytes(VARIABLE_PARAM_RECORD_SPECIFIC_BYTES),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function encodeVariableParameter(writer, v) {
|
|
93
|
+
writer.writeUint8(v.recordType);
|
|
94
|
+
writer.writeBytes(v.recordSpecific);
|
|
95
|
+
}
|
|
96
|
+
export function decodeEntityStatePdu(reader) {
|
|
97
|
+
const header = decodePduHeader(reader);
|
|
98
|
+
const entityId = decodeEntityId(reader);
|
|
99
|
+
const forceId = reader.readUint8();
|
|
100
|
+
const numberOfVariableParameterRecords = reader.readUint8();
|
|
101
|
+
const entityType = decodeEntityType(reader);
|
|
102
|
+
const alternateEntityType = decodeEntityType(reader);
|
|
103
|
+
const entityLinearVelocity = decodeVector3Float(reader);
|
|
104
|
+
const entityLocation = decodeVector3Double(reader);
|
|
105
|
+
const entityOrientation = decodeOrientation(reader);
|
|
106
|
+
const entityAppearance = reader.readUint32();
|
|
107
|
+
const deadReckoningParameters = decodeDeadReckoningParameters(reader);
|
|
108
|
+
const entityMarking = decodeEntityMarking(reader);
|
|
109
|
+
const capabilities = reader.readUint32();
|
|
110
|
+
const variableParameters = [];
|
|
111
|
+
for (let i = 0; i < numberOfVariableParameterRecords; i++) {
|
|
112
|
+
variableParameters.push(decodeVariableParameter(reader));
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
header,
|
|
116
|
+
entityId,
|
|
117
|
+
forceId,
|
|
118
|
+
numberOfVariableParameterRecords,
|
|
119
|
+
entityType,
|
|
120
|
+
alternateEntityType,
|
|
121
|
+
entityLinearVelocity,
|
|
122
|
+
entityLocation,
|
|
123
|
+
entityOrientation,
|
|
124
|
+
entityAppearance,
|
|
125
|
+
deadReckoningParameters,
|
|
126
|
+
entityMarking,
|
|
127
|
+
capabilities,
|
|
128
|
+
variableParameters,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function encodeEntityStatePdu(writer, pdu) {
|
|
132
|
+
encodePduHeader(writer, pdu.header);
|
|
133
|
+
encodeEntityId(writer, pdu.entityId);
|
|
134
|
+
writer.writeUint8(pdu.forceId);
|
|
135
|
+
writer.writeUint8(pdu.numberOfVariableParameterRecords);
|
|
136
|
+
encodeEntityType(writer, pdu.entityType);
|
|
137
|
+
encodeEntityType(writer, pdu.alternateEntityType);
|
|
138
|
+
encodeVector3Float(writer, pdu.entityLinearVelocity);
|
|
139
|
+
encodeVector3Double(writer, pdu.entityLocation);
|
|
140
|
+
encodeOrientation(writer, pdu.entityOrientation);
|
|
141
|
+
writer.writeUint32(pdu.entityAppearance);
|
|
142
|
+
encodeDeadReckoningParameters(writer, pdu.deadReckoningParameters);
|
|
143
|
+
encodeEntityMarking(writer, pdu.entityMarking);
|
|
144
|
+
writer.writeUint32(pdu.capabilities);
|
|
145
|
+
for (const vp of pdu.variableParameters) {
|
|
146
|
+
encodeVariableParameter(writer, vp);
|
|
147
|
+
}
|
|
148
|
+
writer.patchUint16(8, writer.getOffset());
|
|
149
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DIS 7 codecs and constants. Version is in the path; names stay clean for dis8/ etc.
|
|
3
|
+
*/
|
|
4
|
+
export { PROTOCOL_VERSION, PROTOCOL_FAMILY_ENTITY_INFORMATION, PROTOCOL_FAMILY_SIMULATION_MANAGEMENT, PROTOCOL_FAMILY_ELECTROMAGNETIC_EMISSION, PDU_TYPE_ENTITY_STATE, PDU_TYPE_CREATE_ENTITY, PDU_TYPE_REMOVE_ENTITY, PDU_TYPE_START_RESUME, PDU_TYPE_STOP_FREEZE, PDU_TYPE_ELECTROMAGNETIC_EMISSION, PDU_TYPE_TRANSMITTER, PROTOCOL_FAMILY_RADIO_COMMUNICATIONS, START_RESUME_PDU_LENGTH, STOP_FREEZE_PDU_LENGTH, CREATE_ENTITY_PDU_LENGTH, REMOVE_ENTITY_PDU_LENGTH, ENTITY_STATE_PDU_FIXED_LENGTH, ENTITY_STATE_VARIABLE_PARAMETER_RECORD_LENGTH, TRANSMITTER_PDU_FIXED_LENGTH, } from "./constants.js";
|
|
5
|
+
export { type PduHeader, decodePduHeader, encodePduHeader, } from "./pduHeader.js";
|
|
6
|
+
export { type EntityStatePdu, type EntityType, type Vector3Float, type Vector3Double, type Orientation, type DeadReckoningParameters, type EntityMarking, type VariableParameter, decodeEntityStatePdu, encodeEntityStatePdu, } from "./entityStatePdu.js";
|
|
7
|
+
export { type CreateEntityPdu, decodeCreateEntityPdu, encodeCreateEntityPdu, } from "./createEntityPdu.js";
|
|
8
|
+
export { type RemoveEntityPdu, decodeRemoveEntityPdu, encodeRemoveEntityPdu, } from "./removeEntityPdu.js";
|
|
9
|
+
export { type StartResumePdu, decodeStartResumePdu, encodeStartResumePdu, } from "./startResumePdu.js";
|
|
10
|
+
export { type StopFreezePdu, decodeStopFreezePdu, encodeStopFreezePdu, } from "./stopFreezePdu.js";
|
|
11
|
+
export { type ElectromagneticEmissionPdu, type EmitterSystemData, type BeamData, type FundamentalParameterData, type BeamDataGroup, type EmitterSystemRecord, type Location, decodeElectromagneticEmissionPdu, encodeElectromagneticEmissionPdu, } from "./electromagneticEmissionPdu.js";
|
|
12
|
+
export { type TransmitterPdu, type RadioType, type ModulationType, type BeamAntennaPattern, type VariableTransmitterParameter, BEAM_ANTENNA_PATTERN_LENGTH, decodeTransmitterPdu, encodeTransmitterPdu, } from "./transmitterPdu.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DIS 7 codecs and constants. Version is in the path; names stay clean for dis8/ etc.
|
|
3
|
+
*/
|
|
4
|
+
export { PROTOCOL_VERSION, PROTOCOL_FAMILY_ENTITY_INFORMATION, PROTOCOL_FAMILY_SIMULATION_MANAGEMENT, PROTOCOL_FAMILY_ELECTROMAGNETIC_EMISSION, PDU_TYPE_ENTITY_STATE, PDU_TYPE_CREATE_ENTITY, PDU_TYPE_REMOVE_ENTITY, PDU_TYPE_START_RESUME, PDU_TYPE_STOP_FREEZE, PDU_TYPE_ELECTROMAGNETIC_EMISSION, PDU_TYPE_TRANSMITTER, PROTOCOL_FAMILY_RADIO_COMMUNICATIONS, START_RESUME_PDU_LENGTH, STOP_FREEZE_PDU_LENGTH, CREATE_ENTITY_PDU_LENGTH, REMOVE_ENTITY_PDU_LENGTH, ENTITY_STATE_PDU_FIXED_LENGTH, ENTITY_STATE_VARIABLE_PARAMETER_RECORD_LENGTH, TRANSMITTER_PDU_FIXED_LENGTH, } from "./constants.js";
|
|
5
|
+
export { decodePduHeader, encodePduHeader, } from "./pduHeader.js";
|
|
6
|
+
export { decodeEntityStatePdu, encodeEntityStatePdu, } from "./entityStatePdu.js";
|
|
7
|
+
export { decodeCreateEntityPdu, encodeCreateEntityPdu, } from "./createEntityPdu.js";
|
|
8
|
+
export { decodeRemoveEntityPdu, encodeRemoveEntityPdu, } from "./removeEntityPdu.js";
|
|
9
|
+
export { decodeStartResumePdu, encodeStartResumePdu, } from "./startResumePdu.js";
|
|
10
|
+
export { decodeStopFreezePdu, encodeStopFreezePdu, } from "./stopFreezePdu.js";
|
|
11
|
+
export { decodeElectromagneticEmissionPdu, encodeElectromagneticEmissionPdu, } from "./electromagneticEmissionPdu.js";
|
|
12
|
+
export { BEAM_ANTENNA_PATTERN_LENGTH, decodeTransmitterPdu, encodeTransmitterPdu, } from "./transmitterPdu.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
/**
|
|
4
|
+
* Standard PDU header (12 bytes). Layout is version-specific; this module is DIS 7.
|
|
5
|
+
*/
|
|
6
|
+
export interface PduHeader {
|
|
7
|
+
protocolVersion: number;
|
|
8
|
+
exerciseId: number;
|
|
9
|
+
pduType: number;
|
|
10
|
+
protocolFamily: number;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
/** Total PDU size in bytes, including this header. */
|
|
13
|
+
length: number;
|
|
14
|
+
pduStatus: number;
|
|
15
|
+
padding: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function decodePduHeader(reader: BinaryReader): PduHeader;
|
|
18
|
+
export declare function encodePduHeader(writer: BinaryWriter, header: PduHeader): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function decodePduHeader(reader) {
|
|
2
|
+
return {
|
|
3
|
+
protocolVersion: reader.readUint8(),
|
|
4
|
+
exerciseId: reader.readUint8(),
|
|
5
|
+
pduType: reader.readUint8(),
|
|
6
|
+
protocolFamily: reader.readUint8(),
|
|
7
|
+
timestamp: reader.readUint32(),
|
|
8
|
+
length: reader.readUint16(),
|
|
9
|
+
pduStatus: reader.readUint8(),
|
|
10
|
+
padding: reader.readUint8(),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function encodePduHeader(writer, header) {
|
|
14
|
+
writer.writeUint8(header.protocolVersion);
|
|
15
|
+
writer.writeUint8(header.exerciseId);
|
|
16
|
+
writer.writeUint8(header.pduType);
|
|
17
|
+
writer.writeUint8(header.protocolFamily);
|
|
18
|
+
writer.writeUint32(header.timestamp);
|
|
19
|
+
writer.writeUint16(header.length);
|
|
20
|
+
writer.writeUint8(header.pduStatus);
|
|
21
|
+
writer.writeUint8(header.padding);
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
5
|
+
/** Remove Entity PDU (224 bits). Table 150. */
|
|
6
|
+
export interface RemoveEntityPdu {
|
|
7
|
+
header: PduHeader;
|
|
8
|
+
originatingId: EntityId;
|
|
9
|
+
receivingId: EntityId;
|
|
10
|
+
requestId: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function decodeRemoveEntityPdu(reader: BinaryReader): RemoveEntityPdu;
|
|
13
|
+
export declare function encodeRemoveEntityPdu(writer: BinaryWriter, pdu: RemoveEntityPdu): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { decodeEntityId, encodeEntityId } from "../core/entityId.js";
|
|
2
|
+
import { decodePduHeader, encodePduHeader } from "./pduHeader.js";
|
|
3
|
+
export function decodeRemoveEntityPdu(reader) {
|
|
4
|
+
return {
|
|
5
|
+
header: decodePduHeader(reader),
|
|
6
|
+
originatingId: decodeEntityId(reader),
|
|
7
|
+
receivingId: decodeEntityId(reader),
|
|
8
|
+
requestId: reader.readUint32(),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function encodeRemoveEntityPdu(writer, pdu) {
|
|
12
|
+
encodePduHeader(writer, pdu.header);
|
|
13
|
+
encodeEntityId(writer, pdu.originatingId);
|
|
14
|
+
encodeEntityId(writer, pdu.receivingId);
|
|
15
|
+
writer.writeUint32(pdu.requestId);
|
|
16
|
+
writer.patchUint16(8, writer.getOffset());
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { ClockTime } from "../dis/clockTime.js";
|
|
5
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
6
|
+
/** Start/Resume PDU (352 bits). */
|
|
7
|
+
export interface StartResumePdu {
|
|
8
|
+
header: PduHeader;
|
|
9
|
+
originatingId: EntityId;
|
|
10
|
+
receivingId: EntityId;
|
|
11
|
+
realWorldTime: ClockTime;
|
|
12
|
+
simulationTime: ClockTime;
|
|
13
|
+
requestId: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function decodeStartResumePdu(reader: BinaryReader): StartResumePdu;
|
|
16
|
+
export declare function encodeStartResumePdu(writer: BinaryWriter, pdu: StartResumePdu): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { decodeEntityId, encodeEntityId } from "../core/entityId.js";
|
|
2
|
+
import { decodeClockTime, encodeClockTime } from "../dis/clockTime.js";
|
|
3
|
+
import { decodePduHeader, encodePduHeader } from "./pduHeader.js";
|
|
4
|
+
export function decodeStartResumePdu(reader) {
|
|
5
|
+
return {
|
|
6
|
+
header: decodePduHeader(reader),
|
|
7
|
+
originatingId: decodeEntityId(reader),
|
|
8
|
+
receivingId: decodeEntityId(reader),
|
|
9
|
+
realWorldTime: decodeClockTime(reader),
|
|
10
|
+
simulationTime: decodeClockTime(reader),
|
|
11
|
+
requestId: reader.readUint32(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function encodeStartResumePdu(writer, pdu) {
|
|
15
|
+
encodePduHeader(writer, pdu.header);
|
|
16
|
+
encodeEntityId(writer, pdu.originatingId);
|
|
17
|
+
encodeEntityId(writer, pdu.receivingId);
|
|
18
|
+
encodeClockTime(writer, pdu.realWorldTime);
|
|
19
|
+
encodeClockTime(writer, pdu.simulationTime);
|
|
20
|
+
writer.writeUint32(pdu.requestId);
|
|
21
|
+
writer.patchUint16(8, writer.getOffset());
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BinaryReader } from "../binary/BinaryReader.js";
|
|
2
|
+
import type { BinaryWriter } from "../binary/BinaryWriter.js";
|
|
3
|
+
import type { EntityId } from "../core/entityId.js";
|
|
4
|
+
import type { ClockTime } from "../dis/clockTime.js";
|
|
5
|
+
import type { PduHeader } from "./pduHeader.js";
|
|
6
|
+
/** Stop/Freeze PDU (320 bits). */
|
|
7
|
+
export interface StopFreezePdu {
|
|
8
|
+
header: PduHeader;
|
|
9
|
+
originatingId: EntityId;
|
|
10
|
+
receivingId: EntityId;
|
|
11
|
+
realWorldTime: ClockTime;
|
|
12
|
+
/** 8-bit enumeration: why the entity/exercise was stopped or frozen. */
|
|
13
|
+
reason: number;
|
|
14
|
+
/** 8-bit record: internal behavior and appearance while frozen. */
|
|
15
|
+
frozenBehavior: number;
|
|
16
|
+
/** 16-bit padding (unused on wire). */
|
|
17
|
+
padding: number;
|
|
18
|
+
requestId: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function decodeStopFreezePdu(reader: BinaryReader): StopFreezePdu;
|
|
21
|
+
export declare function encodeStopFreezePdu(writer: BinaryWriter, pdu: StopFreezePdu): void;
|