VR-Engage  2.2
Loading...
Searching...
No Matches
lightStateController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file lightStateController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for managing platform light states
9//!
10//! This file defines the DtLightStateController class which manages the state of
11//! platform lights such as headlights and brake lights based on input ports for
12//! throttle, braking, and explicit light state controls.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
17#include <vrfobjcore/controllerComponent.h>
18
19//! Platform facades provide an API specific to particular platform types
20//! Light state functionality is available for platforms but not for other entity types like tactical graphics
21#include <vrfobjcore/platformLocalObjectFacade.h>
22
23class DtBooleanInputPort;
24class DtStringInputPort;
25class DtAnalogInputPort;
26class DtInputPortGroup;
27
28namespace makVre
29{
30
31//! \brief Type identifier for the light state controller component
32const char DtLightStateControllerType[] = "light-state-controller";
33
34//! \brief Controller for managing platform light states
35//!
36//! DtLightStateController monitors inputs related to vehicle operation such as
37//! throttle and brake application, as well as explicit light control inputs,
38//! and uses these to manage the state of a platform's lights (headlights, brake
39//! lights, etc.). The controller provides a centralized way to control light
40//! states based on platform operation.
41class VREVRFMODEL_DLL DtLightStateController : public DtControllerComponent
42{
43public:
44 //! \brief Constructor
45 //! \param name The name of this component
46 //! \param owner The local object that owns this component
47 //! \param simManager The simulation services manager
48 //! \param desc Component descriptor with configuration parameters
49 //! \param parentRegistry Optional parent registry for reader/writer functionality
50 //!
51 //! Creates a new light state controller component with the specified parameters.
52 DtLightStateController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
53 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry = 0);
54
55 //! \brief Virtual destructor
56 //!
57 //! Cleans up resources used by the light state controller component.
58 virtual ~DtLightStateController() override;
59
60 //! \brief Gets the type identifier for this component
61 //! \return String identifying the component type (DtLightStateControllerType)
62 //!
63 //! Implements the DtSimComponent::type() method to return the
64 //! type identifier for this component.
65 virtual const char* type() const override;
66
67 //! \brief Creates port groups for this component
68 //! \return True if port groups were created successfully, false otherwise
69 //!
70 //! Creates and initializes the input port groups used by this controller
71 //! for light state control.
72 virtual bool createPortGroups() override;
73
74 //! \brief Creates input and output ports for this component
75 //! \return True if ports were created successfully, false otherwise
76 //!
77 //! Creates and initializes all input ports used by this controller
78 //! for light state control, including ports for headlights, throttle,
79 //! and brake inputs.
80 virtual bool createPorts() override;
81
82 //! \brief Factory method to create a new instance of this component
83 //! \param name The name for the new component
84 //! \param owner The local object that will own this component
85 //! \param simManager The simulation services manager
86 //! \param desc Optional component descriptor
87 //! \param parentRegistry Optional parent registry for reader/writer functionality
88 //! \return Pointer to the newly created component
89 //!
90 //! Static factory method used by the component creation system to instantiate
91 //! new instances of this component type.
92 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
93 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
94
95private:
96 //! \brief Default constructor (not implemented)
97 //!
98 //! Default constructor is private and not implemented to prevent
99 //! creation of instances without proper initialization.
101
102 //! \brief Copy constructor (not implemented)
103 //!
104 //! Copy constructor is private and not implemented to prevent
105 //! copy construction.
107
108 //! \brief Assignment operator (not implemented)
109 //! \return Reference to this object
110 //!
111 //! Assignment operator is private and not implemented to prevent assignment.
113
114protected:
115 //! \brief Updates the light state each simulation frame
116 //!
117 //! Processes light state control inputs and updates the platform's
118 //! light states based on current headlight switch, throttle, and brake inputs.
119 virtual void tick() override;
120
121 //! \brief Input port group for light state controls
122 //!
123 //! Contains all input ports related to light state control.
124 DtInputPortGroup* myStatePortGroup;
125
126 //! \brief Input port for headlight control
127 //!
128 //! When true, indicates that headlights should be turned on.
129 DtBooleanInputPort* myHeadlightPort;
130
131 //! \brief Input port for throttle state
132 //!
133 //! Analog input representing the current throttle position,
134 //! with 0.0 being idle and 1.0 being full throttle.
135 DtAnalogInputPort* myThrottlePort;
136
137 //! \brief Input port for brake state
138 //!
139 //! Analog input representing the current brake application,
140 //! with 0.0 being no braking and 1.0 being full braking.
141 DtAnalogInputPort* myBrakePort;
142
143 //! \brief Facade for platform local object access
144 //!
145 //! Provides simplified access to platform-specific functionality
146 //! of the local object, including light state control.
147 DtPlatformLocalObjectFacade myPlatformLocalObjectFacade;
148};
149
150} // namespace makVre
DtLightStateController(const DtLightStateController &orig)
Copy constructor (not implemented)
virtual const char * type() const override
Gets the type identifier for this component.
DtPlatformLocalObjectFacade myPlatformLocalObjectFacade
Facade for platform local object access.
Definition lightStateController.h:147
virtual ~DtLightStateController() override
Virtual destructor.
DtLightStateController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool createPorts() override
Creates input and output ports for this component.
virtual bool createPortGroups() override
Creates port groups for this component.
DtBooleanInputPort * myHeadlightPort
Input port for headlight control.
Definition lightStateController.h:129
DtInputPortGroup * myStatePortGroup
Input port group for light state controls.
Definition lightStateController.h:124
DtAnalogInputPort * myThrottlePort
Input port for throttle state.
Definition lightStateController.h:135
DtAnalogInputPort * myBrakePort
Input port for brake state.
Definition lightStateController.h:141
DtLightStateController & operator=(const DtLightStateController &orig)
Assignment operator (not implemented)
DtLightStateController()
Default constructor (not implemented)
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
virtual void tick() override
Updates the light state each simulation frame.
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtLightStateControllerType[]
Type identifier for the light state controller component.
Definition lightStateController.h:32