-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathElectronicEmissionsPdu.js
More file actions
135 lines (107 loc) · 5.27 KB
/
Copy pathElectronicEmissionsPdu.js
File metadata and controls
135 lines (107 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* Section 5.3.7.1. Information about active electronic warfare (EW) emissions and active EW countermeasures shall be communicated using an Electromagnetic Emission PDU. NOT COMPLETE
*
* Copyright (c) 2008-2015, MOVES Institute, Naval Postgraduate School. All rights reserved.
* This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html
*
* @author DMcG
*/
// On the client side, support for a namespace.
if (typeof dis === "undefined")
dis = {};
// Support for node.js style modules. Ignored if used in a client context.
// See http://howtonode.org/creating-custom-modules
if (typeof exports === "undefined")
exports = {};
dis.ElectronicEmissionsPdu = function()
{
/** The version of the protocol. 5=DIS-1995, 6=DIS-1998, 7=DIS-2009. */
this.protocolVersion = 7;
/** Exercise ID */
this.exerciseID = 0;
/** Type of pdu, unique for each PDU class */
this.pduType = 23;
/** value that refers to the protocol family, eg SimulationManagement, et */
this.protocolFamily = 6;
/** Timestamp value */
this.timestamp = 0;
/** Length, in bytes, of the PDU */
this.length = 0;
/** PDU Status Record. Described in 6.2.67. This field is not present in earlier DIS versions */
this.pduStatus = 0;
/** zero-filled array of padding */
this.padding = 0;
/** ID of the entity emitting */
this.emittingEntityID = new dis.EntityID();
/** ID of event */
this.eventID = new dis.EventIdentifier();
/** This field shall be used to indicate if the data in the PDU represents a state update or just data that has changed since issuance of the last Electromagnetic Emission PDU [relative to the identified entity and emission system(s)]. */
this.stateUpdateIndicator = 0;
/** This field shall specify the number of emission systems being described in the current PDU. */
this.numberOfSystems = 0;
/** padding */
this.paddingForEmissionsPdu = 0;
/** this field shall specify the length of this emitter system's data in 32-bit words. */
this.systemDataLength = 0;
/** the number of beams being described in the current PDU for the emitter system being described. */
this.numberOfBeams = 0;
/** information about a particular emitter system and shall be represented by an Emitter System record (see 6.2.23). */
this.emitterSystem = new dis.EmitterSystem();
/** the location of the antenna beam source with respect to the emitting entity's coordinate system. This location shall be the origin of the emitter coordinate system that shall have the same orientation as the entity coordinate system. This field shall be represented by an Entity Coordinate Vector record see 6.2.95 */
this.location = new dis.Vector3Float();
/** Electronic emmissions systems THIS IS WRONG. It has the WRONG class type and will cause problems in any marshalling. */
this.systems = new Array();
dis.ElectronicEmissionsPdu.prototype.initFromBinary = function(inputStream)
{
this.protocolVersion = inputStream.readUByte();
this.exerciseID = inputStream.readUByte();
this.pduType = inputStream.readUByte();
this.protocolFamily = inputStream.readUByte();
this.timestamp = inputStream.readUInt();
this.length = inputStream.readUShort();
this.pduStatus = inputStream.readUByte();
this.padding = inputStream.readUByte();
this.emittingEntityID.initFromBinary(inputStream);
this.eventID.initFromBinary(inputStream);
this.stateUpdateIndicator = inputStream.readUByte();
this.numberOfSystems = inputStream.readUByte();
this.paddingForEmissionsPdu = inputStream.readUShort();
this.systemDataLength = inputStream.readUByte();
this.numberOfBeams = inputStream.readUByte();
this.emitterSystem.initFromBinary(inputStream);
this.location.initFromBinary(inputStream);
for(var idx = 0; idx < this.numberOfSystems; idx++)
{
var anX = new dis.Vector3Float();
anX.initFromBinary(inputStream);
this.systems.push(anX);
}
};
dis.ElectronicEmissionsPdu.prototype.encodeToBinary = function(outputStream)
{
outputStream.writeUByte(this.protocolVersion);
outputStream.writeUByte(this.exerciseID);
outputStream.writeUByte(this.pduType);
outputStream.writeUByte(this.protocolFamily);
outputStream.writeUInt(this.timestamp);
outputStream.writeUShort(this.length);
outputStream.writeUByte(this.pduStatus);
outputStream.writeUByte(this.padding);
this.emittingEntityID.encodeToBinary(outputStream);
this.eventID.encodeToBinary(outputStream);
outputStream.writeUByte(this.stateUpdateIndicator);
outputStream.writeUByte(this.numberOfSystems);
outputStream.writeUShort(this.paddingForEmissionsPdu);
outputStream.writeUByte(this.systemDataLength);
outputStream.writeUByte(this.numberOfBeams);
this.emitterSystem.encodeToBinary(outputStream);
this.location.encodeToBinary(outputStream);
for(var idx = 0; idx < this.systems.length; idx++)
{
this.systems[idx].encodeToBinary(outputStream);
}
};
}; // end of class
// node.js module support
exports.ElectronicEmissionsPdu = dis.ElectronicEmissionsPdu;
// End of ElectronicEmissionsPdu class