VR-Engage  2.2
Loading...
Searching...
No Matches
cigiTimePublisher.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies, Inc.
3** All rights reserved.
4*******************************************************************************/
5#pragma once
6
7//! \file cigiTimePublisher.h
8//! \brief Declares DtCigiTimePublisher, a CIGI host publisher for simulation time-of-day.
9
10// Delcare new CigiPublisher class for sending simulation date and time using the
11// DtCigiPubliher template.
12//
13// This is an unversioned base Publisher class, from which a CIGI version (4)
14// type will be derived. Currently only CIGI version 4 is supported by the
15// vreCigiHost, but this design allows for future support of other CIGI versions.
16//
17// The DtCigiPublisherTemplate is used to composes a CigiPublisherBase-derived
18// class, given a CIGI packet type, the new Publisher class name, and the parent
19// CigiPublisher type that the new Publisher should be derived from. In this case
20// DtCigiTimePublisher will derive directly from the DtCigiPublisherBase class,
21// and use a base CIGI packet type of CigiBaseEnvCtrl.
22//
23// The CIGI packet type used by the unversioned base Publisher class should
24// be a superclass for the CIGI packet class used by the versioned Publishers
25// that will be derived from this Publisher class.
26
28
29#include <CigiBaseEnvCtrl.h>
30
31namespace makVre
32{
33class DtCigiSession;
34
35//! \brief Unversioned CIGI time publisher used by the CIGI host extension example.
36//!
37//! This class demonstrates how to derive a publisher from DtCigiPublisherTemplate
38//! using the version-agnostic CigiBaseEnvCtrl packet type. It reads simulation time
39//! from the VR-Forces environmental state manager and drives celestial control
40//! packets for connected image generators.
41class DtCigiTimePublisher : public DtCigiPublisherTemplate<CigiBaseEnvCtrl, DtCigiTimePublisher, DtCigiPublisherBase>
42{
43public:
44 //! \brief Instantiates a new time publisher and adds it to a CIGI session.
45 //!
46 //! This helper is registered as a session-start callback by the example
47 //! plugin so that each new CIGI session automatically gets a time-of-day
48 //! publisher attached under the root publisher in the publisher tree.
50
51public:
53 : mySimTime(0.0)
54 , myTimeTolerance(1.0)
55 {
56 }
58
59 //! \brief Initializes the publisher and validates required VR-Forces services.
60 //!
61 //! This override checks that the CGF physical world and environmental state
62 //! manager are available, reads the optional timeDeviationTolerance value
63 //! from the session configuration, and then delegates to the base publisher
64 //! initialization.
65 //!
66 //! \return true if initialization succeeds and the publisher remains enabled.
67 bool init() override;
68
69 //! \brief Advances internal simulation time tracking and schedules updates.
70 //!
71 //! This method accumulates expected simulation time using the frame delta,
72 //! compares it against the authoritative time from the environmental state
73 //! manager, and marks the publisher dirty when the deviation exceeds the
74 //! configured tolerance before calling the base tick implementation.
75 //!
76 //! \param dt Delta time in seconds since the last tick.
77 void tick(double dt) override;
78
79protected:
80 //! \brief Initializes constant CIGI packet fields that do not change over time.
81 //!
82 //! Called once by the base publisher; sets up celestial body enable flags,
83 //! star intensity, and marks the date/time fields as valid.
84 void initCigi() override;
85
86 //! \brief Updates dynamic CIGI date/time and ephemeris fields before sending.
87 //!
88 //! When the publisher is dirty, this method updates the CIGI packet with
89 //! the current simulation UTC date and time and controls whether the image
90 //! generator advances time based on the simulation play/pause state.
91 void updateCigi() override;
92
93protected:
94 //! \brief Locally tracked simulation time in seconds based on accumulated dt.
95 double mySimTime;
96
97 //! \brief Maximum allowed deviation between tracked and actual sim time (seconds).
99};
100
101} // namespace makVre
virtual DtCigiSession & session() const
Definition cigiSession.h:38
virtual ~DtCigiTimePublisher()
Definition cigiTimePublisher.h:57
void tick(double dt) override
Advances internal simulation time tracking and schedules updates.
double mySimTime
Locally tracked simulation time in seconds based on accumulated dt.
Definition cigiTimePublisher.h:95
double myTimeTolerance
Maximum allowed deviation between tracked and actual sim time (seconds).
Definition cigiTimePublisher.h:98
DtCigiTimePublisher()
Definition cigiTimePublisher.h:52
static void addToSession(DtCigiSession &session)
Instantiates a new time publisher and adds it to a CIGI session.
bool init() override
Initializes the publisher and validates required VR-Forces services.
void updateCigi() override
Updates dynamic CIGI date/time and ephemeris fields before sending.
void initCigi() override
Initializes constant CIGI packet fields that do not change over time.
Include export definitions for this library.
Definition glsVreMessageUtil.h:49