FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
types.ts
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
3
4import { z } from 'zod';
5import {
6 GlobalParametersSchema,
7 WaveformSchema,
8 TimingSchema,
9 AntennaSchema,
10 PlatformSchema,
11 ScenarioDataSchema,
12 NoiseEntrySchema,
13 PositionWaypointSchema,
14 RotationWaypointSchema,
15 PlatformComponentSchema,
16 FixedRotationSchema,
17 RotationPathSchema,
18 MotionPathSchema,
19 SchedulePeriodSchema,
20} from '../scenarioSchema';
21
22// --- Zod Inferred Types ---
23export type GlobalParameters = z.infer<typeof GlobalParametersSchema>;
24export type Waveform = z.infer<typeof WaveformSchema>;
25export type NoiseEntry = z.infer<typeof NoiseEntrySchema>;
26export type Timing = z.infer<typeof TimingSchema>;
27export type Antenna = z.infer<typeof AntennaSchema>;
28export type PositionWaypoint = z.infer<typeof PositionWaypointSchema>;
29export type MotionPath = z.infer<typeof MotionPathSchema>;
30export type FixedRotation = z.infer<typeof FixedRotationSchema>;
31export type RotationWaypoint = z.infer<typeof RotationWaypointSchema>;
32export type RotationPath = z.infer<typeof RotationPathSchema>;
33export type PlatformComponent = z.infer<typeof PlatformComponentSchema>;
34export type SchedulePeriod = z.infer<typeof SchedulePeriodSchema>;
35export type Platform = z.infer<typeof PlatformSchema> & {
36 pathPoints?: {
37 x: number;
38 y: number;
39 z: number;
40 vx: number;
41 vy: number;
42 vz: number;
43 }[];
44 rotationPathPoints?: { azimuth: number; elevation: number }[];
45};
46
47// --- Visibility Type Definitions ---
48export type VisualizationLayers = {
49 showAxes: boolean;
50 showPatterns: boolean;
51 showBoresights: boolean;
52 showLinks: boolean;
53 showLinkLabels: boolean;
54 showLinkMonostatic: boolean;
55 showLinkIlluminator: boolean;
56 showLinkScattered: boolean;
57 showLinkDirect: boolean;
58 showVelocities: boolean;
59 showPlatforms: boolean;
60 showPlatformLabels: boolean;
61 showMotionPaths: boolean;
62};
63
64// --- Component Type Definitions ---
65export type MonostaticComponent = Extract<
66 PlatformComponent,
67 { type: 'monostatic' }
68>;
69export type TransmitterComponent = Extract<
70 PlatformComponent,
71 { type: 'transmitter' }
72>;
73export type ReceiverComponent = Extract<
74 PlatformComponent,
75 { type: 'receiver' }
76>;
77export type TargetComponent = Extract<PlatformComponent, { type: 'target' }>;
78
79export type ScenarioData = Omit<
80 z.infer<typeof ScenarioDataSchema>,
81 'platforms'
82> & {
83 platforms: Platform[];
84};
85
86export type ScenarioItem =
87 | GlobalParameters
88 | Waveform
89 | Timing
90 | Antenna
91 | Platform;
92
93// --- Store Shape ---
94export type ViewControlAction = {
95 type: 'frame' | 'focus' | 'follow' | null;
96 targetId?: string;
97 timestamp: number;
98};
99
100export type ScenarioState = ScenarioData & {
101 selectedItemId: string | null;
102 isDirty: boolean;
103 isPlaying: boolean;
104 currentTime: number;
105 targetPlaybackDuration: number | null;
106 isSimulating: boolean;
107 isBackendSyncing: boolean;
108 backendVersion: number;
109 errorSnackbar: {
110 open: boolean;
111 message: string;
112 };
113 viewControlAction: ViewControlAction;
114 visibility: VisualizationLayers;
115};
116
117// --- Action Slice Types ---
118export type AssetActions = {
119 addWaveform: () => void;
120 addTiming: () => void;
121 addAntenna: () => void;
122 addNoiseEntry: (timingId: string) => void;
123 removeNoiseEntry: (timingId: string, entryId: string) => void;
124 setAntennaPattern: (
125 antennaId: string,
126 newPattern: Antenna['pattern']
127 ) => void;
128};
129
130export type PlatformActions = {
131 addPlatform: () => void;
132 addPositionWaypoint: (platformId: string) => void;
133 removePositionWaypoint: (platformId: string, waypointId: string) => void;
134 addRotationWaypoint: (platformId: string) => void;
135 removeRotationWaypoint: (platformId: string, waypointId: string) => void;
136 addPlatformComponent: (
137 platformId: string,
138 componentType: PlatformComponent['type']
139 ) => void;
140 removePlatformComponent: (platformId: string, componentId: string) => void;
141 setPlatformRcsModel: (
142 platformId: string,
143 componentId: string,
144 newModel: TargetComponent['rcs_model']
145 ) => void;
146 fetchPlatformPath: (platformId: string) => Promise<void>;
147};
148
149export type ScenarioActions = {
150 selectItem: (itemId: string | null) => void;
151 updateItem: (itemId: string, propertyPath: string, value: unknown) => void;
152 removeItem: (itemId: string) => void;
153 loadScenario: (backendData: unknown) => void;
154 resetScenario: () => void;
155};
156
157export type BackendActions = {
158 syncBackend: () => Promise<void>;
159 fetchFromBackend: () => Promise<void>;
160};
161
162export type PlaybackActions = {
163 togglePlayPause: () => void;
164 setCurrentTime: (time: number | ((prevTime: number) => number)) => void;
165 setTargetPlaybackDuration: (duration: number | null) => void;
166 setIsSimulating: (isSimulating: boolean) => void;
167};
168
169export type ErrorActions = {
170 showError: (message: string) => void;
171 hideError: () => void;
172};
173
174export type ViewControlActions = {
175 frameScene: () => void;
176 focusOnItem: (itemId: string) => void;
177 toggleFollowItem: (itemId: string) => void;
178 clearViewControlAction: () => void;
179 toggleLayer: (layer: keyof VisualizationLayers) => void;
180};
181
182// --- Full Store Type ---
183export type FullScenarioActions = AssetActions &
184 PlatformActions &
185 ScenarioActions &
186 BackendActions &
187 PlaybackActions &
188 ErrorActions &
189 ViewControlActions;
190
191export type ScenarioStore = ScenarioState & FullScenarioActions;