VR-Engage  2.2
Loading...
Searching...
No Matches
radarWarningReceiverPSR.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file radarWarningReceiverPSR.h
7//! \ingroup vreVrfobjcore
8//! \brief Radar warning receiver process state repository for VREngage
9//!
10//! This file defines the DtRadarWarningReceiverPSR class, which provides a process state repository
11//! for radar warning receiver (RWR) components in VREngage. It tracks radar emissions detected
12//! by the entity and stores information about emitter contacts and detection parameters.
13
14#pragma once
15
17#include <vrfobjcore/vrfProcessStateRepository.h>
18#include <readerWriter/rwReal.h>
19#include <readerWriter/rwBoolean.h>
20#include <vlutil/vlTime.h>
21#include <vrfutil/rwEntityTypeList.h>
22
23//! Forward declarations for classes used in this file
24
26class DtEntityIdentifier;
27class DtUUID;
28
29namespace makVre
30{
31//! \brief Contact information list for the radar warning receiver
33
34//! \brief Type identifier string for the VREngage radar warning receiver PSR
35const char DtVreRadarWarningReceiverPSRType[] = "vre-radar-warning-receiver-psr";
36
37//! \brief Process state repository for radar warning receiver components
38//!
39//! This class provides storage and management for radar warning receiver (RWR) state data.
40//! An RWR is a passive sensor that detects radar emissions and provides information about
41//! potential threats to the entity. This PSR tracks detected radar contacts, their
42//! properties, and the operational parameters of the RWR system.
43class VREVRFOBJCORE_DLL DtRadarWarningReceiverPSR : public DtVrfProcessStateRepository
44{
45public:
46 //! \brief Constructor with VRF object and optional name
47 //! \param vrfObject Pointer to the local object this PSR is associated with
48 //! \param rwName Optional reader/writer name
49 //! \param parentRegistry Optional parent registry for reader/writer functionality
50 //!
51 //! Creates a new radar warning receiver PSR for the specified VRF object.
52 DtRadarWarningReceiverPSR(DtLocalObject* vrfObject, const DtString& rwName = DtString::nullString(),
53 DtReaderWriterRegistry* parentRegistry = 0);
54
55 //! \brief Copy constructor
56 //! \param orig The source PSR to copy from
57 //! \param rwName Optional reader/writer name
58 //! \param parentRegistry Optional parent registry for reader/writer functionality
59 //!
60 //! Creates a new radar warning receiver PSR as a copy of the provided original.
61 DtRadarWarningReceiverPSR(const DtRadarWarningReceiverPSR& orig, const DtString& rwName = DtString::nullString(),
62 DtReaderWriterRegistry* parentRegistry = 0);
63
64 //! \brief Virtual destructor
65 //!
66 //! Cleans up resources used by the PSR.
67 virtual ~DtRadarWarningReceiverPSR() override;
68
69 //! \brief Assignment operator (not implemented)
70 //! \param orig The source PSR to copy from
71 //! \return Reference to this PSR after assignment
72 //!
73 //! Assignment operator is declared but not implemented to prevent assignment.
75
76 //! \brief Creates a clone of this PSR
77 //! \param rwName Optional reader/writer name for the clone
78 //! \param parentRegistry Optional parent registry for reader/writer functionality
79 //! \return Pointer to a new PSR that is a clone of this one
80 //!
81 //! Creates a new radar warning receiver PSR as a deep copy of this one.
82 virtual DtVrfProcessStateRepository* clone(const DtString& rwName = DtString::nullString(),
83 DtReaderWriterRegistry* parentRegistry = 0) const override;
84
85 //! \brief Gets the type identifier for this PSR
86 //! \return String identifying this PSR type
87 //!
88 //! Returns a unique type identifier string for this PSR type.
89 //! Will return DtVreRadarWarningReceiverPSRType.
90 virtual DtString type() const override;
91
92 //! \brief Initializes the PSR after creation
93 //! \return True if initialization was successful, false otherwise
94 //!
95 //! Called after creation to initialize the PSR. This method sets up
96 //! myContactInfoList using createRwrContactInfoList().
97 virtual bool init() override;
98
99 //! \brief Gets the list of radar contact information objects (non-const version)
100 //! \return Pointer to the contact information list
101 //!
102 //! Returns the list of DtRwRwrContactInfo (or derivative) objects representing
103 //! detected radar emitters. Will call mapContactNamesToIds() if the flag is set.
104 //! For this reason, avoid holding a pointer to this list outside of this class.
106
107 //! \brief Gets the list of radar contact information objects (const version)
108 //! \return Const pointer to the contact information list
109 //!
110 //! Returns the const list of DtRwRwrContactInfo (or derivative) objects representing
111 //! detected radar emitters. Will call mapContactNamesToIds() if the flag is set
112 //! (casting away constness to do so). For this reason, avoid holding a pointer
113 //! to this list outside of this class.
114 virtual const DtRwrContactInfoList* contactInfoList() const;
115
116 //! \brief Looks up contact information by entity ID
117 //! \param id The UUID of the entity to find contact information for
118 //! \return Pointer to the contact information, or nullptr if not found
119 //!
120 //! Returns the contact information for the radar contact with the
121 //! specified entity ID, or nullptr if not found in the contact list.
122 virtual DtRwRwrContactInfo* lookupContactById(const DtUUID& id) const;
123
124 //! \brief Clears all radar contacts
125 //!
126 //! Empties the contact information list, removing all currently tracked radar contacts.
127 virtual void clearContactInfoList();
128
129 //! \brief Creates a new radar contact information object
130 //! \return Pointer to the newly created contact information object, or nullptr if creation failed
131 //!
132 //! Returns a new DtRwRwrContactInfo (or derivative) object by calling
133 //! myContactInfoList->createRwrContactInfo(). This returns the type being used in
134 //! the contactInfoList. All items added to the contactInfoList should be created
135 //! by calling this method. Returns nullptr if myContactInfoList is not set.
137
138 //! \brief Gets the task-specific entity types to detect
139 //! \return Const reference to the list of entity types
140 //!
141 //! Returns the list of entity types to detect that were set specifically for a task.
142 //! This type list is used along with the list in the descriptor and the list on the
143 //! types-to-detect input port to make a combined list for processing detections.
144 //! This task list is expected to be changed dynamically during a scenario by tasks.
145 virtual const DtRwEntityTypeList& typesToDetectForTask() const;
146
147 //! \brief Sets the task-specific entity types to detect
148 //! \param objectTypes The list of entity types to detect
149 //!
150 //! Sets the task-specific list of entity types that the RWR should detect.
151 //! This allows tasks to dynamically change detection parameters during a scenario.
152 virtual void setTypesToDetectForTask(const DtRwEntityTypeList& objectTypes);
153
154 //! \brief Clears the task-specific entity types to detect
155 //!
156 //! Clears the task-specific list of entity types that the RWR should detect,
157 //! returning to using only the default types from the descriptor.
159
160 //! \brief Sets the simulation time for the next detection attempt
161 //! \param time The simulation time (in seconds) for the next detection
162 //!
163 //! Sets the simulation time at which the RWR should make its next detection attempt.
164 //! This is used to control the detection update rate of the RWR.
165 virtual void setNextDetectAttempt(DtTime time);
166
167 //! \brief Gets the simulation time for the next detection attempt
168 //! \return The simulation time (in seconds) for the next detection
169 //!
170 //! Returns the simulation time at which the RWR will make its next detection attempt.
171 virtual DtTime nextDetectAttempt() const;
172
173 //! \brief Sets whether the RWR is enabled
174 //! \param enabled True to enable the RWR, false to disable it
175 //!
176 //! Enables or disables the radar warning receiver. When disabled, the RWR
177 //! will not detect any new radar emissions.
178 virtual void setRwrEnabled(bool enabled);
179
180 //! \brief Checks if the RWR is enabled
181 //! \return True if the RWR is enabled, false otherwise
182 //!
183 //! Returns whether the radar warning receiver is currently enabled.
184 virtual bool rwrEnabled() const;
185
186 //! \brief Writes this PSR to a file
187 //! \param fp The file path string to write to
188 //! \param indentLevel The indentation level to use
189 //! \param writeUnspecified Whether to write unspecified values
190 //! \param path The base path for resolving relative paths
191 //!
192 //! Overrides the base class method to perform additional processing before writing
193 //! the PSR to a file. Maps target IDs to target names before calling the base class
194 //! version to ensure that previously detected targets are preserved in checkpoint saves.
195 virtual void putSelf(std::string& fp,
196 int indentLevel = 0,
197 bool writeUnspecified = false,
198 const DtFilename& path = DtReaderWriter::appPath()) override;
199
200 //! \brief Reads this PSR from a stream
201 //! \param args The input stream to read from
202 //! \param searchPaths Search paths for resolving references
203 //! \param variableBindings Variable bindings for resolving references
204 //!
205 //! Overrides the base class method to perform additional processing after reading
206 //! the PSR from a stream. Sets a flag indicating that target names should be mapped
207 //! to target identifiers the next time lookupPreviousTarget() is called.
208 virtual void getSelf(DtlObjPtr args,
209 const DtReaderWriter::SearchPaths& searchPaths,
210 const DtVariableBindingsList& variableBindings) override;
211
212protected:
213 //! \brief Creates a new contact information list
214 //! \param name The name to assign to the new list
215 //! \return Pointer to the newly created contact information list
216 //!
217 //! Factory method that returns a new DtRwrContactInfoList. If you are adding custom
218 //! data to the RWR contact info, create a new derivative of DtRwrContactInfoList
219 //! and override this method to create your new subclass here.
220 virtual DtRwrContactInfoList* createRwrContactInfoList(const DtString& name);
221
222public:
223 //! \brief Factory function to create a new instance of this PSR
224 //! \param rwName The reader/writer name for the new instance
225 //! \param vrfObject Pointer to the local object this PSR will be associated with
226 //! \param parentRegistry Parent registry for reader/writer functionality
227 //! \return Pointer to a newly created PSR instance
228 //!
229 //! Static factory function used by the PSR creation system to instantiate
230 //! new instances of this PSR type.
231 static DtVrfProcessStateRepository* creator(
232 const DtString& rwName, DtLocalObject* vrfObject, DtReaderWriterRegistry* parentRegistry);
233
234protected:
235 //! \brief Maps contact IDs to contact names
236 //!
237 //! Looks up each object in myContactInfoList by the entity ID
238 //! in the contact information and sets the name of the contact
239 //! in the contact info to the name of the object found.
240 //! Objects that are not found are left as they were.
241 // virtual void mapContactIdsToContactNames();
242
243 //! \brief Maps contact names to contact IDs
244 //!
245 //! Looks up each object in myContactInfoList by name,
246 //! and sets the entity ID in the contact information
247 //! to the one found in the vrf object.
248 // virtual void mapContactNamesToContactIds();
249
250protected:
251 //! \brief List of radar contact information
252 //!
253 //! The list of radar contacts detected by the RWR. This is created by the init() method
254 //! using the createRwrContactInfoList() factory method.
256
257 //! \brief Flag for contact name to ID mapping
258 //!
259 //! Flag used to indicate that we should initialize contact names to entity identifiers.
260 //! This is used during deserialization to ensure contact information is properly restored.
262
263 //! \brief Task-specific entity types to detect
264 //!
265 //! Types of objects to detect for a particular task. This can be set with a function call
266 //! or an setAttribute call in Lua. Default value is empty.
267 DtRwEntityTypeList myTaskDetectionTypes;
268
269 //! \brief Next detection time
270 //!
271 //! Simulation time of the next detection attempt (in seconds).
273
274 //! \brief RWR enabled state
275 //!
276 //! Whether the radar warning receiver is enabled or disabled.
277 DtRwBoolean myRwrEnabled;
278};
279} // namespace makVre
Radar Warning Receiver (RWR) contact information class.
Definition rwRwrContactInfo.h:34
virtual DtRwrContactInfoList * contactInfoList()
Gets the list of radar contact information objects (non-const version)
DtRwBoolean myRwrEnabled
RWR enabled state.
Definition radarWarningReceiverPSR.h:277
virtual bool rwrEnabled() const
Checks if the RWR is enabled.
virtual DtTime nextDetectAttempt() const
Gets the simulation time for the next detection attempt.
virtual void setTypesToDetectForTask(const DtRwEntityTypeList &objectTypes)
Sets the task-specific entity types to detect.
virtual DtRwRwrContactInfo * createRwrContactInfo() const
Creates a new radar contact information object.
virtual DtString type() const override
Gets the type identifier for this PSR.
static DtVrfProcessStateRepository * creator(const DtString &rwName, DtLocalObject *vrfObject, DtReaderWriterRegistry *parentRegistry)
Factory function to create a new instance of this PSR.
virtual void clearTypesToDetectForTask()
Clears the task-specific entity types to detect.
DtRwReal myNextDetectAttempt
Next detection time.
Definition radarWarningReceiverPSR.h:272
virtual DtRwRwrContactInfo * lookupContactById(const DtUUID &id) const
Looks up contact information by entity ID.
virtual DtRwrContactInfoList * createRwrContactInfoList(const DtString &name)
Creates a new contact information list.
virtual ~DtRadarWarningReceiverPSR() override
Virtual destructor.
virtual void clearContactInfoList()
Clears all radar contacts.
DtRwEntityTypeList myTaskDetectionTypes
Task-specific entity types to detect.
Definition radarWarningReceiverPSR.h:267
virtual const DtRwEntityTypeList & typesToDetectForTask() const
Gets the task-specific entity types to detect.
DtRadarWarningReceiverPSR(DtLocalObject *vrfObject, const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
Constructor with VRF object and optional name.
virtual DtVrfProcessStateRepository * clone(const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0) const override
Creates a clone of this PSR.
DtRadarWarningReceiverPSR(const DtRadarWarningReceiverPSR &orig, const DtString &rwName=DtString::nullString(), DtReaderWriterRegistry *parentRegistry=0)
Copy constructor.
virtual const DtRwrContactInfoList * contactInfoList() const
Gets the list of radar contact information objects (const version)
virtual void setNextDetectAttempt(DtTime time)
Sets the simulation time for the next detection attempt.
bool myMutableMapContactNamesToContactIds
Flag for contact name to ID mapping.
Definition radarWarningReceiverPSR.h:261
DtRadarWarningReceiverPSR & operator=(const DtRadarWarningReceiverPSR &orig)
Assignment operator (not implemented)
virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings) override
Reads this PSR from a stream.
virtual bool init() override
Initializes the PSR after creation.
virtual void putSelf(std::string &fp, int indentLevel=0, bool writeUnspecified=false, const DtFilename &path=DtReaderWriter::appPath()) override
Writes this PSR to a file.
DtRwrContactInfoList * myContactInfoList
Maps contact IDs to contact names.
Definition radarWarningReceiverPSR.h:255
virtual void setRwrEnabled(bool enabled)
Sets whether the RWR is enabled.
A reader-writer list of RWR contact information elements.
Definition rwrContactInfoList.h:43
Export macros for the VREngage Object Core library.
#define VREVRFOBJCORE_DLL
Platform-specific DLL export/import declaration.
Definition export.h:27
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtVreRadarWarningReceiverPSRType[]
Type identifier string for the VREngage radar warning receiver PSR.
Definition radarWarningReceiverPSR.h:35