VR-Engage  2.3
Loading...
Searching...
No Matches
ownershipTransferConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2026 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file ownershipTransferConnector.h
7//! \brief Defines the DtOwnershipTransferConnector class
8//!
9//! This connector is the sole decision-making authority for entity ownership
10//! acquisition and divestiture in the VR-Engage frontend. It is a
11//! DtSimEventConnector instantiated once per VRE frontend instance. It
12//! communicates with VRF and VRE backends directly through the VRF interface;
13//! the state machine communicates with it via the internal message bus.
14//! No ownership coordination logic resides in vrEngageSim.
15
16#pragma once
17
20
24
27
28#include <vrfExtObjects/reflectedExtEntityList.h>
29
30#include <vrfmsgs/ifTakeOwnershipResponse.h>
31
32#include <vlpi/entityIdentifier.h>
33#include <vlpi/simulationAddress.h>
34#include <vrfutil/uuid.h>
35
36#include <deque>
37#include <string>
38#include <vector>
39
40class DtSimMessage;
41class DtExerciseConnInitializer;
42
43namespace makVrf
44{
45//! \brief Forward declaration of the VRF remote controller
46class DtVrlinkVrfRemoteController;
47} // namespace makVrf
48
49namespace makVre
50{
52
53//! \brief Result of an entity transfer eligibility check
55{
56 Eligible, //!< Entity can be transferred
57 AlreadyOnBackend, //!< Entity is already simulated by the VRE backend
58 Ineligible //!< Entity cannot be transferred (missing data, capabilities, etc.)
59};
60
61//! \brief Type of ownership operation in the queue
62enum class OperationType
63{
64 Acquire, //!< Request to acquire ownership of an entity
65 Release //!< Request to release/divest ownership of an entity
66};
67
68//! \brief A single ownership operation in the FIFO queue
70{
72 unsigned long long requestId = 0;
73 DtEntityIdentifier entityId;
74 DtUUID entityUuid;
76 std::string requestingRoleName;
77 bool retainCurrentOwned = false; //!< Only meaningful for Acquire
78 bool allowRemoteVreOwnership = false; //!< Allow role engagement without local transfer when a remote VRE owns it.
79 bool idleInitiated = false; //!< True if triggered by idle timer (suppress response msg)
80 bool internalAutoDivest = false; //!< True if synthesized by connector (suppress response msg)
81 bool towingOwnershipTransfer = false; //!< True when a release belongs to a towing acquire.
82 unsigned int pairId = 0; //!< Links internal Release + its paired Acquire (0 = unpaired)
83 bool transferDisabled = false; //!< True when DisableOwnershipTransfer property prevented the transfer
84};
85
86//! \brief Phase of the currently active operation
88{
89 Idle, //!< No operation in progress; ready to dequeue next
90 Pending, //!< Just dequeued; tick will evaluate EESR and decide action
91 Sent, //!< TakeOwnership message dispatched; waiting for terminal response
92 Complete //!< Terminal response received; tick will finalize and go Idle
93};
94
95//! \brief Terminal outcome of an active ownership operation
97{
98 None, //!< Not yet determined
99 Success, //!< Transfer completed successfully
100 Skipped, //!< Transfer was intentionally bypassed
101 SkippedRemoteVreOwner, //!< Target remains remote; this station does not record ownership of it
102 Failure //!< Transfer refused or unsupported
103};
104
105//! \brief State of the currently executing operation
107{
110
111 //!< Release-specific: target backend candidates (ordered)
112 std::vector<DtSimulationAddress> divestCandidates;
113
114 //!< Deadline countdown (seconds remaining)
115 double deadline = 0.0;
116
117 //!< Terminal result (set when phase transitions to Complete)
119 std::string failureMessage;
120};
121
122//! \brief A VRF ownership response entry stored in the response queue
124{
126 DtIfTakeOwnershipResponse::Status status;
127 DtSimulationAddress sender;
128};
129
130//! \brief Coordinator connector for VRE entity ownership transfer
131//!
132//! DtOwnershipTransferConnector is the sole decision-making
133//! authority for all entity ownership acquire and divest operations in
134//! the VR-Engage frontend process. It lives as a base connector for the
135//! lifetime of the frontend session.
136//!
137//! On acquire, the coordinator sends \c DtIfTakeOwnership directly to the
138//! current VRE Sim backend via the VRF message interface. \c DtIfTakeOwnershipResponse
139//! callbacks drive non-terminal status publications and terminal response
140//! publications back to the state machine.
141//!
142//! On divest, the coordinator resolves the towing-specific LastVreSim target
143//! when present, otherwise falls back to LastVrfSim. If LastVrfSim is missing
144//! or unavailable, it uses the first available full-capabilities backend.
145//!
146//! \ingroup vrePlayerStationConnector
148{
149public:
150 //! \brief Default constructor
152
153 //! \brief Virtual destructor
154 virtual ~DtOwnershipTransferConnector() override = default;
155
156 //! \brief Installs the coordinator with shared infrastructure
157 //!
158 //! \param connection Non-owning pointer to the protocol-specific VR-Link connection.
159 //! \param vrfRemoteController Non-owning pointer to the shared VRF remote controller.
160 //! \param reflectedExtEntityList Non-owning pointer to the reflected entity list used
161 //! to look up entity sim engine addresses during eligibility checks
162 //!
163 //! Stores the non-owning infrastructure pointer, registers factory creators
164 //! for DtIfTakeOwnership and DtIfTakeOwnershipResponse, registers the static
165 //! takeOwnershipResponseCallback, and subscribes to OwnershipTransferRequestMessage
166 //! via DtVreMessageManager. Binds the ownership-transfer manager from the
167 //! global App attribute tree.
168 virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection,
169 makVrf::DtVrlinkVrfRemoteController* vrfRemoteController,
170 DtReflectedExtEntityList* reflectedExtEntityList);
171
172 //! \brief Shuts down the coordinator
173 //!
174 //! Cancels queued operations, removes the VRF response callback, unassigns
175 //! App attribute handles, and clears non-owning infrastructure references.
176 virtual void shutdown() override;
177
178 //! \brief Performs periodic processing for the ownership transfer coordinator.
179 //!
180 //! Checks whether an in-flight acquire has exceeded its deadline and, if so,
181 //! clears the pending transfer and publishes a terminal FAILURE response.
182 virtual void tick(double dt) override;
183
184 //! \brief Dispatches an incoming ownership transfer request by enqueuing it
185 //! \param message Pointer to the ownership transfer request message
186 //! \return HANDLED
188
189 //! \name Tick-Driven State Machine
190 //! @{
191
192 //! \brief Dequeues the next operation from the FIFO queue and moves to Pending phase.
193 //!
194 //! A no-op when the queue is empty (stays Idle).
195 virtual void startNextOperation();
196
197 //! \brief Evaluates EESR ground truth and sends TakeOwnership if needed.
198 //!
199 //! Dispatches to evaluateAcquire or evaluateRelease based on operation type.
200 virtual void evaluateAndSend();
201
202 //! \brief Evaluates and dispatches the active Acquire operation.
203 //! \param vreSim The current VRE backend address (already validated non-null).
204 virtual void evaluateAcquire(const DtSimulationAddress& vreSim);
205
206 //! \brief Evaluates and dispatches the active Release operation.
207 //! \param vreSim The current VRE backend address (already validated non-null).
208 virtual void evaluateRelease(const DtSimulationAddress& vreSim);
209
210 //! \brief Drains the response queue, applies response precedence, and advances state.
211 //!
212 //! Processes all queued VRF responses in order, applying terminal detection per the
213 //! response precedence table. After draining, checks timeout if no terminal was found.
214 //! \param dt Elapsed seconds since the previous tick.
215 virtual void processBackendResponses(double dt);
216
217 //! \brief Publishes results, updates ownership attrs, and returns to Idle phase.
218 //!
219 //! For failed internal auto-divest releases, cancels the paired Acquire in the queue
220 //! and publishes failure for the original request.
221 virtual void finalizeAndPublish();
222
223 //! \brief Detects backend address change or disconnect; clears all state if found.
224 //!
225 //! Checks the backend dirty flag set by the attribute callback. If the backend
226 //! has changed or gone null, publishes failures for all in-flight work, clears
227 //! queues and attrs, and returns true. The caller (tick) returns early.
228 //! \return true if backend changed and state was cleared; false otherwise
229 virtual bool detectBackendChange();
230
231 //! \brief Detects when an entity has been transferred to our VRE backend
232 //! by another station's divest, without an explicit acquire request.
233 //!
234 //! Only runs during maintenance (phase==Idle && queue empty). If we don't
235 //! currently own any entity but the local station is engaged on an entity
236 //! whose simEngineAddress matches our VRE backend, claim ownership.
238
239 //! @}
240
241 //! \name Eligibility and Resolution
242 //! @{
243
244 //! \brief Evaluates whether the entity can be transferred to the VRE sim backend
245 //! \param entityId The entity identifier to check
246 //! \param targetVreSim The simulation address of the VRE Sim backend
247 //! \param reason Populated with a human-readable explanation when ineligible
248 //! \return DtTransferEligibility indicating whether the transfer can proceed
250 const DtEntityIdentifier& entityId, const DtSimulationAddress& targetVreSim, std::string& reason) const;
251
252 //! \brief Reads the reflected LastVrfSim owner for an entity
253 //! \param entityUuid UUID of the entity
254 //! \return The simulation address, or DtSimulationAddress::nullId() when unavailable
255 virtual DtSimulationAddress lastVrfSim(const DtUUID& entityUuid) const;
256
257 //! \brief Reads the reflected LastVreSim owner for a towing-acquired entity
258 //! \param entityUuid UUID of the entity
259 //! \return The simulation address, or DtSimulationAddress::nullId() when unavailable
260 virtual DtSimulationAddress lastVreSim(const DtUUID& entityUuid) const;
261
262 //! @}
263
264 //! \name VRF Response
265 //! @{
266
267 //! \brief Static VRF message callback for DtIfTakeOwnershipResponse
268 //!
269 //! Extracts response data and pushes to myResponseQueue. Makes NO decisions.
270 //! \param msg Pointer to the simulation message
271 //! \param usr Pointer to the connector instance
272 static void takeOwnershipResponseCallback(DtSimMessage* msg, void* usr);
273
274 //! \brief Processes a change to the backend Enabled attribute.
275 //!
276 //! Sets myBackendDirtyFlag to true. All decision logic is deferred to
277 //! detectBackendChange() in the next tick.
278 //! \param enabled The new value of the Enabled attribute
279 virtual void onBackendEnabledChanged(bool enabled);
280
281 //! @}
282
283 //! \name Helpers
284 //! @{
285
286 //! \brief Sends DtIfTakeOwnership to the target backend
287 //! \param target The simulation address to send to
288 //! \param entityUuid The entity UUID to transfer
289 virtual void sendTransferOwnershipMessage(const DtSimulationAddress& target, const DtUUID& entityUuid) const;
290
291 //! \brief Publishes a VreOwnershipTransferStatusMessage to the frontend
292 //! \param statusCode The status code to report
294
295 //! @}
296
297 //! \brief Handles notification that an entity was removed from the simulation.
298 //!
299 //! If the removed entity matches the currently owned entity, clears all
300 //! ownership tracking state and resets the attribute store to the initial
301 //! values. This covers rewind and entity deletion scenarios.
302 //!
303 //! \param message Pointer to the EntityRemovedMessage.
304 //! \return HANDLED
306
307 //! \brief Handles OwnershipPlayerDisengagedMessage from chooseRoleState.
308 //!
309 //! Arms the idle-release timer.
310 //!
311 //! \param message Pointer to the OwnershipPlayerDisengagedMessage.
312 //! \return HANDLED
314
315 //! \brief Handles OwnershipPlayerEngagedMessage from chooseRoleState.
316 //!
317 //! Cancels an armed idle-release timer only when the message's entity
318 //! matches the entity awaiting release.
319 //!
320 //! \param message Pointer to the OwnershipPlayerEngagedMessage.
321 //! \return HANDLED
323
324 //! @}
325
326 //! \brief Looks up the extended entity state repository for a reflected entity.
327 //!
328 //! Searches myReflectedEntityList for the first entry whose ESR entity
329 //! identifier matches \p entityId and returns its extended ESR (EESR).
330 //!
331 //! \param entityId The entity identifier to search for.
332 //! \return A non-owning pointer to the matching DtExtEntityStateRepository,
333 //! or nullptr if no matching entity is found or if the matched entry
334 //! has no extended ESR. The caller must not delete the returned pointer.
335 virtual DtExtEntityStateRepository* reflectedEntityEESR(const DtEntityIdentifier& entityId) const;
336
337protected:
338 //! \brief Clears secondary owned entity attributes to null.
339 virtual void clearSecondaryOwned();
340
341 //! \brief Promotes the secondary owned entity to primary.
342 //!
343 //! Moves the secondary entity UUID and ID into the primary attributes,
344 //! then clears the secondary.
346
347 //! \brief Rolls back secondary entity to primary after an acquire failure.
348 //!
349 //! Called when a Vehicle acquire fails while the Human was moved to secondary
350 //! (retain path). Restores Human as primary since it's still owned by our backend.
352
353 //! \brief Clears primary and/or secondary attrs that match the given entity UUID.
354 //! \param uuid The entity UUID to clear from owned attrs.
355 virtual void clearAttrsForEntity(const DtUUID& uuid);
356
357 //! \brief Sets primary owned entity attrs (UUID and ID together).
358 virtual void setPrimaryOwned(const DtUUID& uuid, const DtEntityIdentifier& id);
359
360 //! \brief Clears primary owned entity attrs (UUID and ID together).
361 virtual void clearPrimaryOwned();
362
363 //! \brief Returns true if entity is reflected and currently on the given backend.
364 virtual bool entityOnBackend(const DtEntityIdentifier& entityId, const DtSimulationAddress& vreSim) const;
365
366 //! \brief Returns true if an address belongs to a remote VRE ownship backend.
367 //!
368 //! Uses the backend listener's limited-capability status first, then falls
369 //! back to a recent remote VRE station status record.
370 //!
371 //! \param backendAddress Simulation address to classify.
372 //! \param localVreSim This station's VRE backend address, which is never remote.
373 //! \return True when the address identifies a remote VRE ownship backend.
374 virtual bool isRemoteVreOwnshipBackend(const DtSimulationAddress& backendAddress,
375 const DtSimulationAddress& localVreSim) const;
376
377 //! \brief Returns true if the reflected entity was acquired through towing.
378 virtual bool needsTowingOwnershipTransfer(const DtUUID& entityUuid) const;
379 //! \brief Returns true when the entity's DisableOwnershipTransfer state property is True.
380 //! \param entityId The entity to check
381 virtual bool isOwnershipTransferDisabledForEntity(const DtEntityIdentifier& entityId) const;
382
383 //! \brief Reads a simulation-address-valued reflected state property.
384 virtual DtSimulationAddress statePropertySimAddress(const DtUUID& entityUuid, const std::string& propertyName) const;
385
386 //! \brief Resolves active candidate target backends for releasing an entity.
387 //!
388 //! Prefers LastVreSim for towing releases, then LastVrfSim. When LastVrfSim
389 //! is missing or unavailable, appends the first available backend that
390 //! advertises all scenario capabilities.
391 virtual std::vector<DtSimulationAddress> releaseTargetsForEntity(const DtUUID& entityUuid, bool towingRelease) const;
392
393 //! \brief Returns true when the backend listener currently lists an address.
394 //!
395 //! \param backendAddress Simulation address of the backend to find.
396 //! \return True when the address is non-null and belongs to a known backend.
397 virtual bool isBackendAvailable(const DtSimulationAddress& backendAddress) const;
398
399 //! \brief Returns whether ownership transfer may run in the current session.
400 //!
401 //! Returns false before the app-level manager is available and for
402 //! unhosted or self-hosted sessions.
404
405 //! \brief Clears the reflected towing transfer marker after release succeeds.
406 virtual void clearTowingOwnershipTransferMarker(const DtEntityIdentifier& entityId) const;
407
408 //! \brief Resets the active operation's deadline using settings (or default).
409 virtual void resetActiveDeadline();
410
411 //! \brief Publishes an OwnershipTransferResponseMessage for the given operation.
412 //! \param op The operation whose request id/entity is used to build the response.
413 //! \param status The response status code to publish.
414 //! \param msg Optional human-readable message.
415 virtual void publishResponse(const OwnershipOperation& op,
417 const std::string& msg = std::string()) const;
418
419 //! \brief Publishes a failure response for the operation only if it is externally visible
420 //! (not an internal auto-divest and not idle-initiated).
421 virtual void publishFailureIfExternal(const OwnershipOperation& op, const std::string& failureMsg) const;
422
423 //! \brief Transitions the active operation to Complete with the given outcome.
424 //! \param outcome Terminal outcome for the active operation.
425 //! \param failureMsg Optional failure message (cleared if not provided).
426 virtual void completeActiveOperation(TerminalOutcome outcome, std::string failureMsg = std::string());
427
428 //! \brief Inserts an auto-divest pair at the front of the queue: a Release of the
429 //! current primary followed by a re-queued copy of the active Acquire.
430 //! Resets phase to Idle so the next tick processes the new pair.
431 virtual void enqueueAutoDivestPair(const DtUUID& currentPrimaryUuid, const DtEntityIdentifier& currentPrimaryId);
432
433 //! \brief Cancels and removes the paired Acquire from the queue and publishes
434 //! failure if it was externally visible.
435 virtual void cancelPairedAcquire(unsigned int pairId, const std::string& failureMsg);
436
437 //! \brief Checks whether the secondary slot can be used. If occupied by a stale
438 //! entity, clears it. Returns false (with reason) if occupied by a live entity.
439 virtual bool prepareSecondarySlot(const DtSimulationAddress& vreSim, std::string& outFailReason);
440
441 //! \brief Decrements the idle-release deadline and enqueues automatic release
442 //! operations when it expires.
443 //!
444 //! Internally gated: only counts down when phase==Idle && queue empty.
445 //!
446 //! \param dt Elapsed seconds since the previous tick.
447 virtual void tickIdleRelease(double dt);
448
449 //! \brief Validates that the currently-owned entity still exists on our
450 //! backend, with a grace period before clearing stale ownership.
451 //! \param dt Elapsed seconds since the previous tick.
452 virtual void validateOwnshipEntity(double dt);
453
454 //! \brief Releases an entity immediately during shutdown using sendImmediately=true,
455 //! then clears local ownership attributes without waiting for backend response.
456 //! \param uuid The UUID of the entity to release.
457 //! \param entityId The entity identifier to release.
458 virtual void blockingRelease(const DtUUID& uuid, const DtEntityIdentifier& entityId);
459
460protected:
461 //! \brief Exercise connection initializer used to build protocol-specific connection parameters
462 //!
463 //! Non-owning pointer sourced from the VR-Link driver during install(). Lifetime is
464 //! guaranteed to outlive this connector.
465 const DtExerciseConnInitializer* myExerciseConnInitializer = nullptr;
466
467 //! \brief Non-owning pointer to the shared VRF remote controller
468 makVrf::DtVrlinkVrfRemoteController* myVrfRemoteController = nullptr;
469
470 //! \brief Attribute handle for the app-level ownership-transfer manager.
471 //!
472 //! Bound during install() to the non-owning manager pointer published by
473 //! DtPlayerStationApp.
474 //! \vreAttrKey{ownershipTransferManager}
476
477 //! \brief Non-owning pointer to the reflected entity list.
478 DtReflectedExtEntityList* myReflectedEntityList = nullptr;
479
480 //! \name Queue-Based State Machine
481 //! @{
482
483 //! \brief FIFO operation queue. Handlers only push; tick() pops.
484 std::deque<OwnershipOperation> myOperationQueue;
485
486 //! \brief The currently executing operation and its phase.
488
489 //! \brief VRF response queue. Callback pushes; tick() drains. Same thread — no mutex.
490 std::deque<OwnershipResponse> myResponseQueue;
491
492 //! \brief Monotonically increasing pair ID counter for linking auto-divest operations.
493 unsigned int myNextPairId = 1;
494
495 //! \brief Set to true by onBackendEnabledChanged(); read and cleared by detectBackendChange().
496 bool myBackendDirtyFlag = false;
497
498 //! @}
499
500 //! \name Attribute Handles
501 //! @{
502
503 //! \brief Current VRE Sim backend simulation address.
504 //! \vreAttrKey{vreBackendStatus.SimAddress}
506
507 //! \brief Owned entity UUID. Written on acquire success, cleared on release/shutdown.
508 //! \vreAttrKey{ownedEntityUuid}
510
511 //! \brief Owned entity identifier. Written alongside UUID.
512 //! \vreAttrKey{ownedEntityId}
514
515 //! \brief Secondary (embarked) entity UUID.
516 //! \vreAttrKey{secondaryOwnedEntityUuid}
518
519 //! \brief Secondary (embarked) entity identifier.
520 //! \vreAttrKey{secondaryOwnedEntityId}
522
523 //! \brief Local station's currently engaged entity.
524 //! \vreAttrKey{entityId}
526
527 //! \brief Recent remote VRE station statuses used to identify ownship backends.
528 //! \vreAttrKey{vreStatus.stations}
530
531 //! @}
532
533 //! \name Idle Release Timer
534 //! @{
535
536 //! \brief Seconds remaining before the idle-release timer fires.
537 //! Zero means no timer is armed.
539
540 //! \brief UUID of the entity the idle-release timer is armed for.
542
543 //! \brief Entity identifier the idle-release timer is armed for.
544 DtEntityIdentifier myIdleReleaseEntityId;
545
546 //! @}
547
548 //! \brief Previous VRE backend address, tracked to detect disconnects.
549 DtSimulationAddress myPreviousVreBackendAddr;
550
551 //! \brief Grace countdown for ownship entity validation (seconds).
552 double myValidationGrace = 0.0;
553};
554
555} // namespace makVre
Provides a callback mechanism for attribute changes in the VREngage system.
Provides handle classes for safe access to attributes.
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:53
Type-specific handle class for attributes.
Definition attributeHandle.h:229
virtual void clearPrimaryOwned()
Clears primary owned entity attrs (UUID and ID together).
virtual void clearAttrsForEntity(const DtUUID &uuid)
Clears primary and/or secondary attrs that match the given entity UUID.
DtAttributeHandleType< std::vector< std::string > > myVreStatusStationsAttr
Recent remote VRE station statuses used to identify ownship backends.
Definition ownershipTransferConnector.h:529
bool myBackendDirtyFlag
Set to true by onBackendEnabledChanged(); read and cleared by detectBackendChange().
Definition ownershipTransferConnector.h:496
virtual DtExtEntityStateRepository * reflectedEntityEESR(const DtEntityIdentifier &entityId) const
Looks up the extended entity state repository for a reflected entity.
virtual void sendStatusUpdate(VreOwnershipTransferStatusMessage::StatusCode statusCode) const
Publishes a VreOwnershipTransferStatusMessage to the frontend.
virtual DtSimulationAddress statePropertySimAddress(const DtUUID &entityUuid, const std::string &propertyName) const
Reads a simulation-address-valued reflected state property.
virtual void evaluateAndSend()
Evaluates EESR ground truth and sends TakeOwnership if needed.
ActiveOperation myActive
The currently executing operation and its phase.
Definition ownershipTransferConnector.h:487
virtual void setPrimaryOwned(const DtUUID &uuid, const DtEntityIdentifier &id)
Sets primary owned entity attrs (UUID and ID together).
virtual void promoteSecondaryToPrimary()
Promotes the secondary owned entity to primary.
virtual DtVreMessageResult handlePlayerEngaged(DtVreMessage *message)
Handles OwnershipPlayerEngagedMessage from chooseRoleState.
virtual void processBackendResponses(double dt)
Drains the response queue, applies response precedence, and advances state.
const DtExerciseConnInitializer * myExerciseConnInitializer
Exercise connection initializer used to build protocol-specific connection parameters.
Definition ownershipTransferConnector.h:465
virtual DtTransferEligibility entityTransferElegibility(const DtEntityIdentifier &entityId, const DtSimulationAddress &targetVreSim, std::string &reason) const
Evaluates whether the entity can be transferred to the VRE sim backend.
bool ownershipTransferAvailable() const
Returns whether ownership transfer may run in the current session.
DtAttributeHandleType< DtUUID > mySecondaryOwnedEntityUuidAttr
Secondary (embarked) entity UUID.
Definition ownershipTransferConnector.h:517
virtual void tickIdleRelease(double dt)
Decrements the idle-release deadline and enqueues automatic release operations when it expires.
virtual bool isBackendAvailable(const DtSimulationAddress &backendAddress) const
Returns true when the backend listener currently lists an address.
DtAttributeHandleType< DtEntityIdentifier > mySecondaryOwnedEntityIdAttr
Secondary (embarked) entity identifier.
Definition ownershipTransferConnector.h:521
virtual DtVreMessageResult handlePlayerDisengaged(DtVreMessage *message)
Handles OwnershipPlayerDisengagedMessage from chooseRoleState.
virtual bool entityOnBackend(const DtEntityIdentifier &entityId, const DtSimulationAddress &vreSim) const
Returns true if entity is reflected and currently on the given backend.
virtual void evaluateRelease(const DtSimulationAddress &vreSim)
Evaluates and dispatches the active Release operation.
virtual DtSimulationAddress lastVreSim(const DtUUID &entityUuid) const
Reads the reflected LastVreSim owner for a towing-acquired entity.
std::deque< OwnershipOperation > myOperationQueue
FIFO operation queue. Handlers only push; tick() pops.
Definition ownershipTransferConnector.h:484
virtual bool prepareSecondarySlot(const DtSimulationAddress &vreSim, std::string &outFailReason)
Checks whether the secondary slot can be used. If occupied by a stale entity, clears it....
virtual void publishResponse(const OwnershipOperation &op, OwnershipTransferResponseMessage::ResponseStatus status, const std::string &msg=std::string()) const
Publishes an OwnershipTransferResponseMessage for the given operation.
virtual void completeActiveOperation(TerminalOutcome outcome, std::string failureMsg=std::string())
Transitions the active operation to Complete with the given outcome.
virtual void resetActiveDeadline()
Resets the active operation's deadline using settings (or default).
std::deque< OwnershipResponse > myResponseQueue
VRF response queue. Callback pushes; tick() drains. Same thread — no mutex.
Definition ownershipTransferConnector.h:490
DtAttributeHandleType< DtUUID > myOwnedEntityUuidAttr
Owned entity UUID. Written on acquire success, cleared on release/shutdown.
Definition ownershipTransferConnector.h:509
virtual void tick(double dt) override
Performs periodic processing for the ownership transfer coordinator.
virtual void clearSecondaryOwned()
Clears secondary owned entity attributes to null.
makVrf::DtVrlinkVrfRemoteController * myVrfRemoteController
Non-owning pointer to the shared VRF remote controller.
Definition ownershipTransferConnector.h:468
DtOwnershipTransferConnector()=default
Default constructor.
virtual void rollbackSecondaryOnAcquireFailure()
Rolls back secondary entity to primary after an acquire failure.
virtual ~DtOwnershipTransferConnector() override=default
Virtual destructor.
DtAttributeHandleType< DtEntityIdentifier > myOwnedEntityIdAttr
Owned entity identifier. Written alongside UUID.
Definition ownershipTransferConnector.h:513
DtReflectedExtEntityList * myReflectedEntityList
Non-owning pointer to the reflected entity list.
Definition ownershipTransferConnector.h:478
virtual void publishFailureIfExternal(const OwnershipOperation &op, const std::string &failureMsg) const
Publishes a failure response for the operation only if it is externally visible (not an internal auto...
virtual void blockingRelease(const DtUUID &uuid, const DtEntityIdentifier &entityId)
Releases an entity immediately during shutdown using sendImmediately=true, then clears local ownershi...
virtual void enqueueAutoDivestPair(const DtUUID &currentPrimaryUuid, const DtEntityIdentifier &currentPrimaryId)
Inserts an auto-divest pair at the front of the queue: a Release of the current primary followed by a...
DtAttributeHandleType< DtOwnershipTransferManager * > myOwnershipTransferManagerAttr
Attribute handle for the app-level ownership-transfer manager.
Definition ownershipTransferConnector.h:475
DtSimulationAddress myPreviousVreBackendAddr
Previous VRE backend address, tracked to detect disconnects.
Definition ownershipTransferConnector.h:549
double myIdleReleaseDeadline
Seconds remaining before the idle-release timer fires. Zero means no timer is armed.
Definition ownershipTransferConnector.h:538
virtual void startNextOperation()
Dequeues the next operation from the FIFO queue and moves to Pending phase.
virtual bool needsTowingOwnershipTransfer(const DtUUID &entityUuid) const
Returns true if the reflected entity was acquired through towing.
virtual void validateOwnshipEntity(double dt)
Validates that the currently-owned entity still exists on our backend, with a grace period before cle...
virtual DtSimulationAddress lastVrfSim(const DtUUID &entityUuid) const
Reads the reflected LastVrfSim owner for an entity.
virtual DtVreMessageResult handleOwnershipTransferRequest(DtVreMessage *message)
Dispatches an incoming ownership transfer request by enqueuing it.
virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection, makVrf::DtVrlinkVrfRemoteController *vrfRemoteController, DtReflectedExtEntityList *reflectedExtEntityList)
Installs the coordinator with shared infrastructure.
DtAttributeHandleType< DtSimulationAddress > myVreBackendAttr
Current VRE Sim backend simulation address.
Definition ownershipTransferConnector.h:505
static void takeOwnershipResponseCallback(DtSimMessage *msg, void *usr)
Static VRF message callback for DtIfTakeOwnershipResponse.
virtual void sendTransferOwnershipMessage(const DtSimulationAddress &target, const DtUUID &entityUuid) const
Sends DtIfTakeOwnership to the target backend.
virtual void evaluateAcquire(const DtSimulationAddress &vreSim)
Evaluates and dispatches the active Acquire operation.
virtual void cancelPairedAcquire(unsigned int pairId, const std::string &failureMsg)
Cancels and removes the paired Acquire from the queue and publishes failure if it was externally visi...
virtual DtVreMessageResult handleEntityRemoved(DtVreMessage *message)
Handles notification that an entity was removed from the simulation.
double myValidationGrace
Grace countdown for ownship entity validation (seconds).
Definition ownershipTransferConnector.h:552
virtual std::vector< DtSimulationAddress > releaseTargetsForEntity(const DtUUID &entityUuid, bool towingRelease) const
Resolves active candidate target backends for releasing an entity.
virtual bool isRemoteVreOwnshipBackend(const DtSimulationAddress &backendAddress, const DtSimulationAddress &localVreSim) const
Returns true if an address belongs to a remote VRE ownship backend.
unsigned int myNextPairId
Monotonically increasing pair ID counter for linking auto-divest operations.
Definition ownershipTransferConnector.h:493
virtual void onBackendEnabledChanged(bool enabled)
Processes a change to the backend Enabled attribute.
DtAttributeHandleType< DtEntityIdentifier > myLocalEntityIdAttr
Local station's currently engaged entity.
Definition ownershipTransferConnector.h:525
DtEntityIdentifier myIdleReleaseEntityId
Entity identifier the idle-release timer is armed for.
Definition ownershipTransferConnector.h:544
virtual void finalizeAndPublish()
Publishes results, updates ownership attrs, and returns to Idle phase.
virtual bool detectBackendChange()
Detects backend address change or disconnect; clears all state if found.
virtual bool isOwnershipTransferDisabledForEntity(const DtEntityIdentifier &entityId) const
Returns true when the entity's DisableOwnershipTransfer state property is True.
virtual void clearTowingOwnershipTransferMarker(const DtEntityIdentifier &entityId) const
Clears the reflected towing transfer marker after release succeeds.
virtual void detectExternalOwnershipChanges()
Detects when an entity has been transferred to our VRE backend by another station's divest,...
DtUUID myIdleReleaseEntityUuid
UUID of the entity the idle-release timer is armed for.
Definition ownershipTransferConnector.h:541
virtual void shutdown() override
Shuts down the coordinator.
App-level runtime manager for the Ownership Transfer feature.
Definition ownershipTransferManager.h:52
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
ResponseStatus
ResponseStatus enumeration.
Definition ownershipTransferResponse.h:39
StatusCode
StatusCode enumeration.
Definition vreOwnershipTransferStatus.h:38
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
!
Definition glsVreMessageUtil.h:50
OperationType
Type of ownership operation in the queue.
Definition ownershipTransferConnector.h:63
@ Acquire
Request to acquire ownership of an entity.
Definition ownershipTransferConnector.h:64
@ Release
Request to release/divest ownership of an entity.
Definition ownershipTransferConnector.h:65
@ Pending
Component still needs work — finalizeInitTick() will be called again.
Definition playerComponent.h:82
TerminalOutcome
Terminal outcome of an active ownership operation.
Definition ownershipTransferConnector.h:97
@ Success
Transfer completed successfully.
Definition ownershipTransferConnector.h:99
@ None
Not yet determined.
Definition ownershipTransferConnector.h:98
@ SkippedRemoteVreOwner
Target remains remote; this station does not record ownership of it.
Definition ownershipTransferConnector.h:101
@ Skipped
Transfer was intentionally bypassed.
Definition ownershipTransferConnector.h:100
@ Failure
Transfer refused or unsupported.
Definition ownershipTransferConnector.h:102
@ Complete
Transition to ENGAGED_STATE.
Definition loadingPlayerState.h:51
ActiveOperationPhase
Phase of the currently active operation.
Definition ownershipTransferConnector.h:88
@ Sent
TakeOwnership message dispatched; waiting for terminal response.
Definition ownershipTransferConnector.h:91
@ Idle
No operation in progress; ready to dequeue next.
Definition ownershipTransferConnector.h:89
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
DtTransferEligibility
Result of an entity transfer eligibility check.
Definition ownershipTransferConnector.h:55
@ Eligible
Entity can be transferred.
Definition ownershipTransferConnector.h:56
@ AlreadyOnBackend
Entity is already simulated by the VRE backend.
Definition ownershipTransferConnector.h:57
@ Ineligible
Entity cannot be transferred (missing data, capabilities, etc.)
Definition ownershipTransferConnector.h:58
Definition connectorAccessory.h:38
Defines the base DtSimEventConnector class for VREngage simulation events.
State of the currently executing operation.
Definition ownershipTransferConnector.h:107
std::string failureMessage
Definition ownershipTransferConnector.h:119
TerminalOutcome outcome
Definition ownershipTransferConnector.h:118
OwnershipOperation operation
Release-specific: target backend candidates (ordered)
Definition ownershipTransferConnector.h:109
ActiveOperationPhase phase
Definition ownershipTransferConnector.h:108
double deadline
Terminal result (set when phase transitions to Complete)
Definition ownershipTransferConnector.h:115
std::vector< DtSimulationAddress > divestCandidates
Deadline countdown (seconds remaining)
Definition ownershipTransferConnector.h:112
A single ownership operation in the FIFO queue.
Definition ownershipTransferConnector.h:70
std::string requestingRoleName
Definition ownershipTransferConnector.h:76
OperationType type
Definition ownershipTransferConnector.h:71
bool retainCurrentOwned
Only meaningful for Acquire.
Definition ownershipTransferConnector.h:77
DtUUID entityUuid
Definition ownershipTransferConnector.h:74
DtEntityIdentifier entityId
Definition ownershipTransferConnector.h:73
unsigned long long requestId
Definition ownershipTransferConnector.h:72
std::string requestingStationId
Definition ownershipTransferConnector.h:75
bool transferDisabled
True when DisableOwnershipTransfer property prevented the transfer.
Definition ownershipTransferConnector.h:83
bool towingOwnershipTransfer
True when a release belongs to a towing acquire.
Definition ownershipTransferConnector.h:81
bool internalAutoDivest
True if synthesized by connector (suppress response msg)
Definition ownershipTransferConnector.h:80
bool allowRemoteVreOwnership
Allow role engagement without local transfer when a remote VRE owns it.
Definition ownershipTransferConnector.h:78
unsigned int pairId
Links internal Release + its paired Acquire (0 = unpaired)
Definition ownershipTransferConnector.h:82
bool idleInitiated
True if triggered by idle timer (suppress response msg)
Definition ownershipTransferConnector.h:79
A VRF ownership response entry stored in the response queue.
Definition ownershipTransferConnector.h:124
DtUUID entityUuid
Definition ownershipTransferConnector.h:125
DtSimulationAddress sender
Definition ownershipTransferConnector.h:127
DtIfTakeOwnershipResponse::Status status
Definition ownershipTransferConnector.h:126