@hla4ts/spacefom 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.
@@ -0,0 +1,272 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <objectModel xsi:schemaLocation="http://standards.ieee.org/IEEE1516-2010 http://standards.ieee.org/downloads/1516/1516.2-2010/IEEE1516-DIF-2010.xsd" xmlns="http://standards.ieee.org/IEEE1516-2010" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <modelIdentification>
4
+ <name>SISO-STD-018-2020 - SISO Space Reference FOM Management</name>
5
+ <type>FOM</type>
6
+ <version>1.0</version>
7
+ <modificationDate>2019-10-25</modificationDate>
8
+ <securityClassification>unclassified</securityClassification>
9
+ <purpose>Define Space FOM compliant federation execution configuration.</purpose>
10
+ <applicationDomain></applicationDomain>
11
+ <description>Contains the base set of parameters parameters that define a Space Reference FOM compliant federation execution.</description>
12
+ <useLimitation></useLimitation>
13
+ <keyword>
14
+ <keywordValue>Space</keywordValue>
15
+ </keyword>
16
+ <keyword>
17
+ <keywordValue>FOM</keywordValue>
18
+ </keyword>
19
+ <keyword>
20
+ <keywordValue>Configuration</keywordValue>
21
+ </keyword>
22
+ <keyword>
23
+ <keywordValue>Execution</keywordValue>
24
+ </keyword>
25
+ <keyword>
26
+ <keywordValue>Federation</keywordValue>
27
+ </keyword>
28
+ <poc>
29
+ <pocType>Primary author</pocType>
30
+ <pocName>Edwin Z. Crues</pocName>
31
+ <pocOrg>NASA Johnson Space Center, Houston, TX</pocOrg>
32
+ <pocTelephone>+1-281-483-2902</pocTelephone>
33
+ <pocEmail>edwin.z.crues@nasa.gov</pocEmail>
34
+ </poc>
35
+ <poc>
36
+ <pocType>Contributor</pocType>
37
+ <pocName>Daniel E. Dexter</pocName>
38
+ <pocOrg>NASA Johnson Space Center, Houston, TX</pocOrg>
39
+ <pocTelephone>+1-281-483-1142</pocTelephone>
40
+ <pocEmail>daniel.e.dexter@nasa.gov</pocEmail>
41
+ </poc>
42
+ <poc>
43
+ <pocType>Contributor</pocType>
44
+ <pocName>Björn Möller</pocName>
45
+ <pocOrg>Pitch Technologies, Sweden</pocOrg>
46
+ <pocTelephone></pocTelephone>
47
+ <pocEmail>bjorn.moller@pitch.se</pocEmail>
48
+ </poc>
49
+ <poc>
50
+ <pocType>Contributor</pocType>
51
+ <pocName>Alfredo Garro</pocName>
52
+ <pocOrg>DIMES Department, University of Calabria, Italy</pocOrg>
53
+ <pocTelephone>+39-0984-49-4795</pocTelephone>
54
+ <pocEmail>alfredo.garro@unical.it</pocEmail>
55
+ </poc>
56
+ <other>Copyright © 2020 by the Simulation Interoperability Standards Organization, Inc.
57
+ P.O. Box 781238
58
+ Orlando, FL 32878-1238, USA
59
+ All rights reserved.
60
+
61
+ Schema and API: SISO hereby grants a general, royalty-free license to copy, distribute, display, and make derivative works from this material, for all purposes, provided that any use of the material contains the following attribution: “Reprinted with permission from SISO Inc.” Should a reader require additional information, contact the SISO Inc. Board of Directors.
62
+
63
+ Documentation: SISO hereby grants a general, royalty-free license to copy, distribute, display, and make derivative works from this material, for noncommercial purposes, provided that any use of the material contains the following attribution: “Reprinted with permission from SISO Inc.” The material may not be used for a commercial purpose without express written permission from the SISO Inc. Board of Directors.
64
+
65
+ SISO Inc. Board of Directors
66
+ P.O. Box 781238
67
+ Orlando, FL 32878-1238, USA
68
+ </other>
69
+ </modelIdentification>
70
+ <objects>
71
+ <objectClass>
72
+ <name>HLAobjectRoot</name>
73
+ <objectClass>
74
+ <name>ExecutionConfiguration</name>
75
+ <sharing>PublishSubscribe</sharing>
76
+ <semantics>This is the federation Execution Configuration Object (ExCO). This object defines the base set of parameters necessary to coordinate federation and federate execution time lines and execution mode transitions in a SISO Space Reference FOM compliant federation execution.</semantics>
77
+ <attribute>
78
+ <name>root_frame_name</name>
79
+ <dataType>HLAunicodeString</dataType>
80
+ <updateType>Static</updateType>
81
+ <updateCondition>At initialization</updateCondition>
82
+ <ownership>NoTransfer</ownership>
83
+ <sharing>PublishSubscribe</sharing>
84
+ <transportation>HLAreliable</transportation>
85
+ <order>TimeStamp</order>
86
+ <semantics>Specifies the name of the root coordinate frame in the federation execution's reference frame tree. This frame shall remain fixed throughout the federation execution.</semantics>
87
+ </attribute>
88
+ <attribute>
89
+ <name>scenario_time_epoch</name>
90
+ <dataType>Time</dataType>
91
+ <updateType>Static</updateType>
92
+ <updateCondition>At initialization</updateCondition>
93
+ <ownership>NoTransfer</ownership>
94
+ <sharing>PublishSubscribe</sharing>
95
+ <transportation>HLAreliable</transportation>
96
+ <order>TimeStamp</order>
97
+ <semantics>Federation execution scenario time epoch. This is the beginning epoch expressed in Terrestrial Time (TT), using as starting epoch that of the Truncated Julian Date (TJD)- 1968-05-24 00:00:00 UTC, that corresponds to HLA logical time 0. All joining federates shall use this time to coordinate the offset between their local simulation scenario times, their local simulation execution times and the HLA logical time.</semantics>
98
+ </attribute>
99
+ <attribute>
100
+ <name>current_execution_mode</name>
101
+ <dataType>ExecutionMode</dataType>
102
+ <updateType>Conditional</updateType>
103
+ <updateCondition>On change</updateCondition>
104
+ <ownership>NoTransfer</ownership>
105
+ <sharing>PublishSubscribe</sharing>
106
+ <transportation>HLAreliable</transportation>
107
+ <order>Receive</order>
108
+ <semantics>Defines the current running state of the federation execution in terms of a finite set of states expressed in the ExecutionMode enumeration.</semantics>
109
+ </attribute>
110
+ <attribute>
111
+ <name>next_execution_mode</name>
112
+ <dataType>ExecutionMode</dataType>
113
+ <updateType>Conditional</updateType>
114
+ <updateCondition>On change</updateCondition>
115
+ <ownership>NoTransfer</ownership>
116
+ <sharing>PublishSubscribe</sharing>
117
+ <transportation>HLAreliable</transportation>
118
+ <order>Receive</order>
119
+ <semantics>Defines the next running state of the federation execution in terms of a finite set of states expressed in the ExecutionMode enumeration. This is used in conjunction with the cte_mode_time, sim_mode_time and associated sync point mechanisms to coordinate federation execution mode transitions.</semantics>
120
+ </attribute>
121
+ <attribute>
122
+ <name>next_mode_scenario_time</name>
123
+ <dataType>Time</dataType>
124
+ <updateType>Conditional</updateType>
125
+ <updateCondition>On change</updateCondition>
126
+ <ownership>NoTransfer</ownership>
127
+ <sharing>PublishSubscribe</sharing>
128
+ <transportation>HLAreliable</transportation>
129
+ <order>Receive</order>
130
+ <semantics>The time for the next federation execution mode change expressed as a federation scenario time reference. Note: this value is only meaningful for going into freeze; exiting freeze is coordinated through a sync point mechanism.</semantics>
131
+ </attribute>
132
+ <attribute>
133
+ <name>next_mode_cte_time</name>
134
+ <dataType>Time</dataType>
135
+ <updateType>Conditional</updateType>
136
+ <updateCondition>On change</updateCondition>
137
+ <ownership>NoTransfer</ownership>
138
+ <sharing>PublishSubscribe</sharing>
139
+ <transportation>HLAreliable</transportation>
140
+ <order>Receive</order>
141
+ <semantics>The time for the next federation execution mode change expressed as a Central Timing Equipment (CTE) time reference. The standard for this reference shall be defined in the federation agreement when CTE is used.</semantics>
142
+ </attribute>
143
+ <attribute>
144
+ <name>least_common_time_step</name>
145
+ <dataType>HLAinteger64Time</dataType>
146
+ <updateType>Static</updateType>
147
+ <updateCondition>At initialization</updateCondition>
148
+ <ownership>NoTransfer</ownership>
149
+ <sharing>PublishSubscribe</sharing>
150
+ <transportation>HLAreliable</transportation>
151
+ <order>TimeStamp</order>
152
+ <semantics>A 64 bit integer time that represents microseconds for the least common value of all the time step values in the federation execution (LCTS). This value is set by the Master Federate and does not change during the federation execution. This is used in the computation to find the next HLA Logical Time Boundary (HLTB) available to all federates in the federation execution. The basic equation is HLTB = ( floor(GALT/LCTS) + 1 ) * LCTS, where GALT is the greatest available logical time. This is used to synchronize the federates in a federation execution to be on a common logical time boundary.</semantics>
153
+ </attribute>
154
+ </objectClass>
155
+ </objectClass>
156
+ </objects>
157
+ <interactions>
158
+ <interactionClass>
159
+ <name>HLAinteractionRoot</name>
160
+ <interactionClass>
161
+ <name>ModeTransitionRequest</name>
162
+ <sharing>PublishSubscribe</sharing>
163
+ <transportation>HLAreliable</transportation>
164
+ <order>Receive</order>
165
+ <semantics>The ModeTransitionRequest (MTR) interaction is used by participating federates, that are not the Master Federate, to request a federation execution mode transition. An MTR can be sent at anytime during initialization or execution but only certain MTR requests are valid at certain times.</semantics>
166
+ <parameter>
167
+ <name>execution_mode</name>
168
+ <dataType>MTRMode</dataType>
169
+ <semantics>The run mode requested. There are only 3 valid Mode Transition Request (MTR) mode values: MTR_GOTO_RUN, MTR_GOTO_FREEZE, MTR_GOTO_SHUTDOWN. Of these three valid mode requests, only 7 combinations of current execution mode and requested mode are valid:
170
+ 1. EXEC_MODE_UNINITIALIZED -&gt; EXEC_MODE_SHUTDOWN
171
+ 2. EXEC_MODE_INITIALIZED -&gt; EXEC_MODE_FREEZE
172
+ 3. EXEC_MODE_INITIALIZED -&gt; EXEC_MODE_SHUTDOWN
173
+ 4. EXEC_MODE_RUNNING -&gt; EXEC_MODE_FREEZE
174
+ 5. EXEC_MODE_RUNNING -&gt; EXEC_MODE_SHUTDOWN
175
+ 6. EXEC_MODE_FREEZE -&gt; EXEC_MODE_RUNNING
176
+ 7. EXEC_MODE_FREEZE -&gt; EXEC_MODE_SHUTDOWN</semantics>
177
+ </parameter>
178
+ </interactionClass>
179
+ </interactionClass>
180
+ </interactions>
181
+ <synchronizations>
182
+ <synchronizationPoint>
183
+ <label>initialization_started</label>
184
+ <dataType>NA</dataType>
185
+ <capability>RegisterAchieve</capability>
186
+ <semantics>Used to indicate that the initialization phase of a Space FOM compliant federation execution has been started. This synchronization point (sync-point) is not created until all federates required by the Master Federate have joined the federation execution. Once this occurs, the Master Federate announces this sync-point along with the "startup" sync-point for any federates that have already joined the federation execution. All federates in the sync-point group must achieve this sync-point prior to proceeding with federate and federation execution initialization.</semantics>
187
+ </synchronizationPoint>
188
+ <synchronizationPoint>
189
+ <label>initialization_completed</label>
190
+ <dataType>NA</dataType>
191
+ <capability>Register</capability>
192
+ <semantics>This synchronization point (sync-point) is registered by the federation execution Master Federate after all the early joining federates have achieved the "initialization_started" sync-point. This signals to any late joining federates that they can now proceed to the current run mode of the federation execution. This sync-point will never be achieved.</semantics>
193
+ </synchronizationPoint>
194
+ <synchronizationPoint>
195
+ <label>objects_discovered</label>
196
+ <dataType>NA</dataType>
197
+ <capability>RegisterAchieve</capability>
198
+ <semantics>This synchronization point (sync-point) is used to mark the point at which all required objects have been discovered by all the federates taking part in the initialization process. This sync-point is used to insure that all the necessary objects have been discovered prior to proceeding with the root reference frame discovery process and then multi-phase initialization.</semantics>
199
+ </synchronizationPoint>
200
+ <synchronizationPoint>
201
+ <label>mtr_run</label>
202
+ <dataType>NA</dataType>
203
+ <capability>RegisterAchieve</capability>
204
+ <semantics>This is used to synchronize the mode transition to EXEC_MODE_RUNNING. This synchronization point (sync-point) is registered by the federation execution Master Federate upon receipt of a valid MTR interaction after sending out the associated ExCO update. Upon receiving the ExCO for the mode transition and at the associated transition time, all federates must achieve this sync-point prior to going into mode EXEC_MODE_RUNNING.</semantics>
205
+ </synchronizationPoint>
206
+ <synchronizationPoint>
207
+ <label>mtr_freeze</label>
208
+ <dataType>NA</dataType>
209
+ <capability>RegisterAchieve</capability>
210
+ <semantics>This is used to synchronize the mode transition to EXEC_MODE_FREEZE. This synchronization point (sync-point) is registered by the federation execution Master Federate upon receipt of a valid MTR interaction after sending out the associated ExCO update. Upon receiving the ExCO for the mode transition and at the associated transition time, all federates must achieve this sync-point prior to going into mode EXEC_MODE_FREEZE.</semantics>
211
+ </synchronizationPoint>
212
+ <synchronizationPoint>
213
+ <label>mtr_shutdown</label>
214
+ <dataType>NA</dataType>
215
+ <capability>Register</capability>
216
+ <semantics>This synchronization point (sync-point) is used as a marker for the mode transition to EXEC_MODE_SHUTDOWN. This sync-point is registered by the federation execution’s Master Federate to “mark” the federation execution as shutting down. This marker sync-point is used in addition to the ExCO. This sync-point is never achieved and will remain for the life of the federation execution to inform any late joining federates of shutdown and that the federates should proceed directly to their shutdown processes.</semantics>
217
+ </synchronizationPoint>
218
+ <synchronizationPoint>
219
+ <label>root_frame_discovered</label>
220
+ <dataType>NA</dataType>
221
+ <capability>RegisterAchieve</capability>
222
+ <semantics>This synchronization point (sync-point) is used to mark the point at which the root reference frame for this federation execution has been discovered by the Master Federate and all other federates participating in the initialization process. This is necessary prior to moving into the multi-phase initialization process.</semantics>
223
+ </synchronizationPoint>
224
+ </synchronizations>
225
+ <dataTypes>
226
+ <enumeratedDataTypes>
227
+ <enumeratedData>
228
+ <name>ExecutionMode</name>
229
+ <representation>HLAinteger16LE</representation>
230
+ <semantics>Defines the mode for the running federation execution. This enumeration type is used for coordinating transitions between federation execution run states.</semantics>
231
+ <enumerator>
232
+ <name>EXEC_MODE_UNINITIALIZED</name>
233
+ <value>0</value>
234
+ </enumerator>
235
+ <enumerator>
236
+ <name>EXEC_MODE_INITIALIZING</name>
237
+ <value>1</value>
238
+ </enumerator>
239
+ <enumerator>
240
+ <name>EXEC_MODE_RUNNING</name>
241
+ <value>2</value>
242
+ </enumerator>
243
+ <enumerator>
244
+ <name>EXEC_MODE_FREEZE</name>
245
+ <value>3</value>
246
+ </enumerator>
247
+ <enumerator>
248
+ <name>EXEC_MODE_SHUTDOWN</name>
249
+ <value>4</value>
250
+ </enumerator>
251
+ </enumeratedData>
252
+ <enumeratedData>
253
+ <name>MTRMode</name>
254
+ <representation>HLAinteger16LE</representation>
255
+ <semantics>Mode Transition Request (MTR) transition values. This enumeration is used to request a specific mode transition. However, not all mode transition requests are accepted for any given Run Mode. See mode transition validation table in the Space Reference FOM documentation.</semantics>
256
+ <enumerator>
257
+ <name>MTR_GOTO_RUN</name>
258
+ <value>2</value>
259
+ </enumerator>
260
+ <enumerator>
261
+ <name>MTR_GOTO_FREEZE</name>
262
+ <value>3</value>
263
+ </enumerator>
264
+ <enumerator>
265
+ <name>MTR_GOTO_SHUTDOWN</name>
266
+ <value>4</value>
267
+ </enumerator>
268
+ </enumeratedData>
269
+ </enumeratedDataTypes>
270
+ </dataTypes>
271
+ <notes/>
272
+ </objectModel>
@@ -0,0 +1,67 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <objectModel xsi:schemaLocation="http://standards.ieee.org/IEEE1516-2010 http://standards.ieee.org/downloads/1516/1516.2-2010/IEEE1516-DIF-2010.xsd" xmlns="http://standards.ieee.org/IEEE1516-2010" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <modelIdentification>
4
+ <name>SISO-STD-018-2020 - SISO Space Reference FOM Switches</name>
5
+ <type>FOM</type>
6
+ <version>1.0</version>
7
+ <modificationDate>2019-10-25</modificationDate>
8
+ <securityClassification>Unclassified</securityClassification>
9
+ <purpose>SISO Space FOM Switches Table</purpose>
10
+ <applicationDomain></applicationDomain>
11
+ <description>Required HLA Switches table definitions.</description>
12
+ <useLimitation></useLimitation>
13
+ <poc>
14
+ <pocType>Primary author</pocType>
15
+ <pocName>Edwin Z. Crues</pocName>
16
+ <pocOrg>NASA Johnson Space Center</pocOrg>
17
+ <pocTelephone>1-281-483-2902</pocTelephone>
18
+ <pocEmail>edwin.z.crues@nasa.gov</pocEmail>
19
+ </poc>
20
+ <poc>
21
+ <pocType>Primary author</pocType>
22
+ <pocName>Dan Dexter</pocName>
23
+ <pocOrg>NASA Johnson Space Center</pocOrg>
24
+ <pocTelephone>1-281-483-1142</pocTelephone>
25
+ <pocEmail>dan.e.dexter@nasa.gov</pocEmail>
26
+ </poc>
27
+ <poc>
28
+ <pocType>Contributor</pocType>
29
+ <pocName>Björn Möller</pocName>
30
+ <pocOrg>Pitch Technologies, Sweden</pocOrg>
31
+ <pocEmail>bjorn.moller@pitch.se</pocEmail>
32
+ </poc>
33
+ <poc>
34
+ <pocType>Contributor</pocType>
35
+ <pocName>Alfredo Garro</pocName>
36
+ <pocOrg>DIMES Department, University of Calabria, Italy</pocOrg>
37
+ <pocTelephone>+39-0984-49-4795</pocTelephone>
38
+ <pocEmail>alfredo.garro@unical.it</pocEmail>
39
+ </poc>
40
+ <other>Copyright © 2020 by the Simulation Interoperability Standards Organization, Inc.
41
+ P.O. Box 781238
42
+ Orlando, FL 32878-1238, USA
43
+ All rights reserved.
44
+
45
+ Schema and API: SISO hereby grants a general, royalty-free license to copy, distribute, display, and make derivative works from this material, for all purposes, provided that any use of the material contains the following attribution: “Reprinted with permission from SISO Inc.” Should a reader require additional information, contact the SISO Inc. Board of Directors.
46
+
47
+ Documentation: SISO hereby grants a general, royalty-free license to copy, distribute, display, and make derivative works from this material, for noncommercial purposes, provided that any use of the material contains the following attribution: “Reprinted with permission from SISO Inc.” The material may not be used for a commercial purpose without express written permission from the SISO Inc. Board of Directors.
48
+
49
+ SISO Inc. Board of Directors
50
+ P.O. Box 781238
51
+ Orlando, FL 32878-1238, USA
52
+ </other>
53
+ </modelIdentification>
54
+ <switches>
55
+ <autoProvide isEnabled="false"/>
56
+ <conveyRegionDesignatorSets isEnabled="false"/>
57
+ <conveyProducingFederate isEnabled="false"/>
58
+ <attributeScopeAdvisory isEnabled="false"/>
59
+ <attributeRelevanceAdvisory isEnabled="false"/>
60
+ <objectClassRelevanceAdvisory isEnabled="false"/>
61
+ <interactionRelevanceAdvisory isEnabled="false"/>
62
+ <serviceReporting isEnabled="false"/>
63
+ <exceptionReporting isEnabled="false"/>
64
+ <delaySubscriptionEvaluation isEnabled="false"/>
65
+ <automaticResignAction resignAction="CancelThenDeleteThenDivest"/>
66
+ </switches>
67
+ </objectModel>
package/src/coders.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { decodeHLAunicodeString, encodeHLAunicodeString } from "./spacefom-encoding.ts";
2
+
3
+ export interface SpaceFomCoder<T> {
4
+ encode(value: T): Uint8Array;
5
+ decode?(data: Uint8Array): T;
6
+ }
7
+
8
+ export class HLAunicodeStringCoder implements SpaceFomCoder<string> {
9
+ encode(value: string): Uint8Array {
10
+ return encodeHLAunicodeString(value);
11
+ }
12
+
13
+ decode(data: Uint8Array): string {
14
+ return decodeHLAunicodeString(data);
15
+ }
16
+ }
@@ -0,0 +1,36 @@
1
+ export interface DashboardServeOptions {
2
+ [key: string]: unknown;
3
+ }
4
+
5
+ export interface DashboardServerHandle {
6
+ wsPort: number;
7
+ httpPort: number;
8
+ uiMode: "static" | "dev" | "off";
9
+ url?: string;
10
+ close: () => Promise<void>;
11
+ }
12
+
13
+ export async function serveDashboard(
14
+ options: DashboardServeOptions = {}
15
+ ): Promise<DashboardServerHandle> {
16
+ const loader = new Function(
17
+ "specifier",
18
+ "return import(specifier)"
19
+ ) as (specifier: string) => Promise<Record<string, unknown>>;
20
+
21
+ try {
22
+ const mod = await loader("@hla4ts/spacefomapp-dashboard");
23
+ const serve = mod["serveDashboard"] as
24
+ | ((opts?: DashboardServeOptions) => Promise<DashboardServerHandle>)
25
+ | undefined;
26
+ if (!serve) {
27
+ throw new Error("serveDashboard export not found.");
28
+ }
29
+ return await serve(options);
30
+ } catch (err) {
31
+ const message = err instanceof Error ? err.message : String(err);
32
+ throw new Error(
33
+ `Unable to load @hla4ts/spacefomapp-dashboard. Install it to use serveDashboard(). ${message}`
34
+ );
35
+ }
36
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @hla4ts/spacefom
3
+ *
4
+ * Raw SpaceFOM assets, encoders, constants, and optional tooling.
5
+ */
6
+
7
+ export { SpaceFomExecutionMode, SpaceFomMtrMode, SpaceFomSyncPointLabels } from "./spacefom-constants.ts";
8
+ export * from "./spacefom-encoding.ts";
9
+ export * from "./spacefom-presets.ts";
10
+ export * from "./coders.ts";
11
+ export * from "./dashboard.ts";
@@ -0,0 +1,26 @@
1
+ export enum SpaceFomExecutionMode {
2
+ Uninitialized = 0,
3
+ Initializing = 1,
4
+ Running = 2,
5
+ Freeze = 3,
6
+ Shutdown = 4,
7
+ }
8
+
9
+ export enum SpaceFomMtrMode {
10
+ GotoRun = 2,
11
+ GotoFreeze = 3,
12
+ GotoShutdown = 4,
13
+ }
14
+
15
+ export const SpaceFomSyncPointLabels = {
16
+ initializationStarted: "initialization_started",
17
+ initializationCompleted: "initialization_completed",
18
+ objectsDiscovered: "objects_discovered",
19
+ mtrRun: "mtr_run",
20
+ mtrFreeze: "mtr_freeze",
21
+ mtrShutdown: "mtr_shutdown",
22
+ rootFrameDiscovered: "root_frame_discovered",
23
+ } as const;
24
+
25
+ export type SpaceFomSyncPointLabel =
26
+ typeof SpaceFomSyncPointLabels[keyof typeof SpaceFomSyncPointLabels];
@@ -0,0 +1,45 @@
1
+ import { expect, test } from "bun:test";
2
+ import {
3
+ decodeHLAunicodeString,
4
+ decodeVector3,
5
+ decodeSpaceTimeCoordinateState,
6
+ encodeHLAunicodeString,
7
+ encodeVector3,
8
+ encodeSpaceTimeCoordinateState,
9
+ type SpaceTimeCoordinateState,
10
+ type Vector3,
11
+ } from "./spacefom-encoding.ts";
12
+
13
+ test("HLAunicodeString round-trip", () => {
14
+ const value = "Cafe\u00e9";
15
+ const encoded = encodeHLAunicodeString(value);
16
+ const decoded = decodeHLAunicodeString(encoded);
17
+ expect(decoded).toBe(value);
18
+ });
19
+
20
+ test("Vector3 round-trip", () => {
21
+ const vector: Vector3 = [1.5, -2.25, 3.75];
22
+ const encoded = encodeVector3(vector);
23
+ const decoded = decodeVector3(encoded);
24
+ expect(decoded).toEqual(vector);
25
+ });
26
+
27
+ test("SpaceTimeCoordinateState round-trip", () => {
28
+ const state: SpaceTimeCoordinateState = {
29
+ translation: {
30
+ position: [1, 2, 3],
31
+ velocity: [0.1, 0.2, 0.3],
32
+ },
33
+ rotation: {
34
+ attitude: {
35
+ scalar: 1,
36
+ vector: [0, 0, 0],
37
+ },
38
+ angularVelocity: [0.01, 0.02, 0.03],
39
+ },
40
+ time: 123.456,
41
+ };
42
+ const encoded = encodeSpaceTimeCoordinateState(state);
43
+ const decoded = decodeSpaceTimeCoordinateState(encoded);
44
+ expect(decoded).toEqual(state);
45
+ });