28#include <vrfExtObjects/reflectedExtEntityList.h>
30#include <vrfmsgs/ifTakeOwnershipResponse.h>
32#include <vlpi/entityIdentifier.h>
33#include <vlpi/simulationAddress.h>
34#include <vrfutil/uuid.h>
41class DtExerciseConnInitializer;
46class DtVrlinkVrfRemoteController;
126 DtIfTakeOwnershipResponse::Status
status;
168 virtual void install(makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection,
169 makVrf::DtVrlinkVrfRemoteController* vrfRemoteController,
170 DtReflectedExtEntityList* reflectedExtEntityList);
182 virtual void tick(
double dt)
override;
250 const DtEntityIdentifier& entityId,
const DtSimulationAddress& targetVreSim, std::string& reason)
const;
255 virtual DtSimulationAddress
lastVrfSim(
const DtUUID& entityUuid)
const;
260 virtual DtSimulationAddress
lastVreSim(
const DtUUID& entityUuid)
const;
364 virtual bool entityOnBackend(
const DtEntityIdentifier& entityId,
const DtSimulationAddress& vreSim)
const;
375 const DtSimulationAddress& localVreSim)
const;
417 const std::string& msg = std::string())
const;
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 ¤tPrimaryUuid, const DtEntityIdentifier ¤tPrimaryId)
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