1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
4import { z } from 'zod';
6 GlobalParametersSchema,
13 PositionWaypointSchema,
14 RotationWaypointSchema,
15 PlatformComponentSchema,
20} from '../scenarioSchema';
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> & {
44 rotationPathPoints?: { azimuth: number; elevation: number }[];
47// --- Visibility Type Definitions ---
48export type VisualizationLayers = {
50 showPatterns: boolean;
51 showBoresights: 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;
64// --- Component Type Definitions ---
65export type MonostaticComponent = Extract<
67 { type: 'monostatic' }
69export type TransmitterComponent = Extract<
71 { type: 'transmitter' }
73export type ReceiverComponent = Extract<
77export type TargetComponent = Extract<PlatformComponent, { type: 'target' }>;
79export type ScenarioData = Omit<
80 z.infer<typeof ScenarioDataSchema>,
83 platforms: Platform[];
86export type ScenarioItem =
94export type ViewControlAction = {
95 type: 'frame' | 'focus' | 'follow' | null;
100export type ScenarioState = ScenarioData & {
101 selectedItemId: string | null;
105 targetPlaybackDuration: number | null;
106 isSimulating: boolean;
107 isBackendSyncing: boolean;
108 backendVersion: number;
113 viewControlAction: ViewControlAction;
114 visibility: VisualizationLayers;
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;
126 newPattern: Antenna['pattern']
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: (
138 componentType: PlatformComponent['type']
140 removePlatformComponent: (platformId: string, componentId: string) => void;
141 setPlatformRcsModel: (
144 newModel: TargetComponent['rcs_model']
146 fetchPlatformPath: (platformId: string) => Promise<void>;
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;
157export type BackendActions = {
158 syncBackend: () => Promise<void>;
159 fetchFromBackend: () => Promise<void>;
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;
169export type ErrorActions = {
170 showError: (message: string) => void;
171 hideError: () => void;
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;
182// --- Full Store Type ---
183export type FullScenarioActions = AssetActions &
191export type ScenarioStore = ScenarioState & FullScenarioActions;