|
HLCC Documentation 2.2.0
|
#include <dataContext.hpp>
Public Types | |
| enum class | EstimatedState { UNDEFINED , STANDING_STILL , PRESETTING , TRACKING , MOVING } |
This class provide access to the application run-time data including the in-memory DB.
Enum for the position/motion state of the telescope, as determined by the DoEstimation activity while the state machine is in the Operational state.
TODO: Refine this enum. What if we do not have any telescope target at all? TODO: Always keep DataContext::EstimatedStateToString impl up to date.
| hlcc::eltpk::DataContext::DataContext | ( | std::shared_ptr< OldbInterface > | oldb_interface = nullptr | ) |
This constructor uses the application configuration to initialize the adapter object to the in-memory DB.
| [in] | oldb_interface | Can be passed explicitly to use a mock for testing. Otherwise it will be created. |
|
virtual |
Destructor
|
delete |
Normally methods of DataContext write to the OLDB, or also publish data on channels. This method allows controlling this behavior, e.g. for unit tests.
| enabled | true enables publishing, false disables it (or also when the MS LSV does the publishing instead???) |
| AmbientData & hlcc::eltpk::DataContext::GetAmbientData | ( | ) |
Gets ambient data that is relevant for astrometric transformations.
| HorizonPositionEsoTimestamped hlcc::eltpk::DataContext::GetCurrentAltAz | ( | ) | const |
Gets the current (actual) ALT/AZ position.
For its validity, check GetTargetAltAzValidity. The timestamp refers to the beginning of the time interval (TE_i) in which the value was simulated (i.e. the measurement was taken).
| DataContext::EstimatedState hlcc::eltpk::DataContext::GetEstimatedState | ( | ) | const |
Gets the state estimated by activity DoEstimation.
|
override |
| AgnosticPointingKernelPositions hlcc::eltpk::DataContext::GetPointingKernelPositions | ( | ) | const |
Gets the entity containing all pointing kernel positions
| std::shared_ptr< const::ccsinsif::PresetData > hlcc::eltpk::DataContext::GetPresetData | ( | ) |
Gets the PresetData
| PositionOnEarth hlcc::eltpk::DataContext::GetSitePosition | ( | ) | const |
Gets the configured position of the (ELT) telescope.
| std::optional< ptk::HorizonPositionEsoTimestamped > hlcc::eltpk::DataContext::GetTargetAltAz | ( | ::taiclock::TaiClock::time_point | time_tai = ::taiclock::TaiClock::time_point{} | ) | const |
Gets the ALT/AZ target that matches the given timestamp either exactly, or otherwise the closest match.
If this method gets called before SetTargetAltAz or UpdateDb has been called, it returns std::nullopt.
If no timestamp is given (parameter time_tai defaulting to time 0), then the data with the latest timestamp gets returned. It is up to the client to verify the timestamp of the target, and to dismiss it if needed.
For target validity, check GetTargetAltAzValidity.
The timestamp refers to the time when the target should be reached. When presetting/tracking, the control loop calculates and inserts (SetTargetAltAz) targets for 100 ms in the future. The control loop always consumes targets for the current loop time, which is either a static target in case of commanded move, or the dynamic target it calculated two loop iterations (100 ms) before.
| time_tai | The timestamp of the data to retrieve. |
| bool hlcc::eltpk::DataContext::GetTargetAltAzValidity | ( | ) | const |
Gets the validity flag for the ALT/AZ target.
See GetTargetAltAz.
| EquatorialPosition hlcc::eltpk::DataContext::GetTargetRaDec | ( | ) | const |
Gets the current RA/DEC target (ICRS coordinates).
This is a convenience access (with type conversion) to the data returned by GetPresetData.
For its validity, check GetTargetRaDecValidity.
| ptk::EquatorialPosition hlcc::eltpk::DataContext::GetTargetRaDecApparent | ( | ) | const |
Gets the apparent position that corresponds to GetTargetRaDec(), as set in SetTargetRaDecApparent().
| bool hlcc::eltpk::DataContext::GetTargetRaDecValidity | ( | ) | const |
Gets the validity flag for the current RA/DEC target.
See GetTargetRaDec.
| bool hlcc::eltpk::DataContext::IsPublishingEnabled | ( | ) | const |
| ptk::HorizonPositionEsoTimestamped hlcc::eltpk::DataContext::MergeTargetAltAz | ( | const AltAzOptional & | alt_az, |
| ElapsedTimeStats & | stats, | ||
| ::taiclock::TaiClock::time_point | time_tai = ptk::NextTimeEvent() ) |
DEPRECATED. We no longer move ALT and AZ separately. Use SetTargetAltAz instead. We only keep this method just in case the strategy may change again.
Merges the optional ALT or AZ components into the best matching one of the existing target positions, and also merges the timestamp time_tai to that target.
This is needed because the ICD allows to set ALT and AZ separately.
Of all timestamped ALT/AZ target positions, it selects the one closest to time_tai for merging. Newer entries (more recent timestamps than that of alt_az) in the map get deleted, so that there cannot be timestamp-based confusion about the target.
| alt_az | The new target position, with optional fields. |
| time_tai | The time (TAI) at which alt_az should be reached. Defaults to ptk::NextTimeEvent(). |
| stats | Reference to the ElapsedTimeStats |
|
delete |
Disable copy constructor.
Write an ops-log (a preformatted log for commands and state-changes) to the opslogger with the given name. The resulting log message will read " > name = value /".
| name | - name of ops-logger/series |
| value | - content for placeholder in the ops-log message |
|
override |
Reload the configuration from file.
Set current position for the axes.
The timestamp refers to the beginning of the time interval (TE_i) in which the value was simulated (i.e. the measurement was taken).
| void hlcc::eltpk::DataContext::SetEstimatedState | ( | EstimatedState | state | ) |
Sets the estimated state.
This method is called directly by activity DoEstimation, before it sends the internal NewEstimation event. When processing the NewEstimation event, the state machine's guard actions determine possible transitions, based on this state (and partly also on the current SM state).
Only after the SM transition, the new state gets written to OLDB by the SM callback in main().
| void hlcc::eltpk::DataContext::SetPointingKernelPositions | ( | const AgnosticPointingKernelPositions & | x, |
| ElapsedTimeStats & | stats ) |
Sets the entity containing all pointing kernel positions
| void hlcc::eltpk::DataContext::SetPresetArgs | ( | std::shared_ptr< const ::ccsinsif::PresetArgs > | preset_args | ) |
Sets the full description of the sidereal Preset. The embedded RA/DEC target can then be retrieved separately using GetTargetRaDec().
TODO: We still need this method to publish the preset args, but we no longer need to store them.
| void hlcc::eltpk::DataContext::SetSiteInfo | ( | ElapsedTimeStats & | stats | ) |
Writes the site info from configuration to the OLDB. It uses the defined periodicity for the writes. This means that it is not guaranteed that it will publish every time this method is called, but we should call the method frequently to ensure the period is constant.
TODO: Rename this method to "PublishSiteInfo" because it does not modify any data in DataContext. It is not 'const' only because it uses flags "m_site_info_published" and "m_site_info_first_iteration", which could also be changed to become static local variables inside SetSiteInfo impl.
| void hlcc::eltpk::DataContext::SetTargetAltAz | ( | const ptk::HorizonPositionEsoTimestamped & | alt_az, |
| ElapsedTimeStats & | stats ) |
Sets the target position with the corresponding timestamp, and publishes the data.
Called by the control loop to advance the position when presetting or tracking. The timestamp refers to the time (beginning of interval) when the target should be reached.
When commanding moves, the meaning is different: the telescope moves at fixed speed, so that the timestamp only means that the target is currently valid, but does not mean that it should be reached at that timestamp.
It is OK to insert data with a future timestamp. However, due to the internal cleanup mechanism, only data less than 1 s in the future should be inserted to not lose current data.
Newer entries (more recent timestamps than that of alt_az) in the map get deleted, so that there cannot be timestamp-based confusion about the target.
| alt_az | The target position. |
| stats | passed around to collect performance statistics. |
| void hlcc::eltpk::DataContext::SetTargetAltAzToCurrent | ( | ElapsedTimeStats & | stats | ) |
Sets the target position to the current value (as obtained by calling GetCurrentAltAz).
The new target position has the same timestamp as the current position. All other target positions, newer or older, get deleted.
Sets the validity flag for the current ALT/AZ target.
Note that calling SetTargetAltAz will set the validity to true, so that this method is mostly needed to set validity to false.
| void hlcc::eltpk::DataContext::SetTargetRaDec | ( | ptk::EquatorialPosition | pos | ) |
Sets the current RA/DEC target (ICRS coordinates).
We do not process sky offsets in eltpk, but get the resulting target RA/DEC values from LSV MS (trksim). Then we store them locally and to OLDB using this method.
| void hlcc::eltpk::DataContext::SetTargetRaDecApparent | ( | const ptk::EquatorialPosition & | pos_apparent | ) |
Sets the calculated apparent position of the commanded RA/DEC target.
Sets the validity flag for the current RA/DEC target.
See GetTargetRaDec, SetTargetRaDec.
|
override |
Try to connect to the DB and write the application configuration to the OLDB.
Initially called by rad::Application::Init. Later also called by, e.g., ActionsApp::SetConfig.
We initialize the telescope position with the value from OLDB, reflecting a previous run. The target pos also gets initialized to the current pos so that the telescope initially stands still.
rad::Application::Init calls only DataContext::UpdateDb, but no other, more suitable, init method of DataContext. Note that in the ctor of DataContext, Config is not yet initialized and thus we cannot use OldbInterface yet.