Instrument Neutral Distributed Interface INDI  2.0.2
MathPluginManagement.h
Go to the documentation of this file.
1 
9 #pragma once
10 
11 #include "BuiltInMathPlugin.h"
12 
13 #include "inditelescope.h"
14 
15 #include <memory>
16 
17 namespace INDI
18 {
19 namespace AlignmentSubsystem
20 {
34 class MathPluginManagement : private MathPlugin // Derive from MathPluign to force the function signatures to match
35 {
36  public:
41 
44 
46  virtual ~MathPluginManagement() {}
47 
51  void InitProperties(Telescope *pTelescope);
52 
61  void ProcessSwitchProperties(Telescope *pTelescope, const char *name, ISState *states, char *names[], int n);
62 
72  void ProcessTextProperties(Telescope *pTelescope, const char *name, char *texts[], char *names[], int n);
73 
78  void SaveConfigProperties(FILE *fp);
79 
90 
94  {
95  CurrentInMemoryDatabase = pDatabase;
96  }
97 
102  void SetAlignmentSubsystemActive(bool enable);
103 
107  {
108  return AlignmentSubsystemActive.s == ISS_ON ? true : false;
109  }
110 
111  // These must match the function signatures in MathPlugin
114  void SetApproximateMountAlignment(MountAlignment_t ApproximateAlignment);
115 
124  bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset,
125  TelescopeDirectionVector &ApparentTelescopeDirectionVector);
126 
134  bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector,
135  double &RightAscension, double &Declination);
136 
137  private:
138  void EnumeratePlugins();
139  void HandlePluginLoading(Telescope *pTelescope, int CurrentPlugin, int NewPlugin);
140  std::vector<std::string> MathPluginFiles;
141  std::vector<std::string> MathPluginDisplayNames;
142 
143  std::unique_ptr<ISwitch> AlignmentSubsystemMathPlugins;
144  ISwitchVectorProperty AlignmentSubsystemMathPluginsV;
145  ISwitch AlignmentSubsystemMathPluginInitialise;
146  ISwitchVectorProperty AlignmentSubsystemMathPluginInitialiseV;
147  ISwitch AlignmentSubsystemActive;
148  ISwitchVectorProperty AlignmentSubsystemActiveV;
149 
150  InMemoryDatabase *CurrentInMemoryDatabase;
151 
152  // The following property is used for configuration purposes only and is not propagated to the client
153  IText AlignmentSubsystemCurrentMathPlugin;
154  ITextVectorProperty AlignmentSubsystemCurrentMathPluginV;
155 
156  // The following hold links to the current loaded math plugin
157  // These must match the function signatures in MathPlugin
158  MountAlignment_t (MathPlugin::*pGetApproximateMountAlignment)();
159  bool (MathPlugin::*pInitialise)(InMemoryDatabase *pInMemoryDatabase);
160  void (MathPlugin::*pSetApproximateMountAlignment)(MountAlignment_t ApproximateAlignment);
161  bool (MathPlugin::*pTransformCelestialToTelescope)(const double RightAscension, const double Declination,
162  double JulianOffset,
164  bool (MathPlugin::*pTransformTelescopeToCelestial)(const TelescopeDirectionVector &TelescopeDirectionVector,
165  double &RightAscension, double &Declination);
166  MathPlugin *pLoadedMathPlugin;
167  void *LoadedMathPluginHandle;
168 
169  BuiltInMathPlugin BuiltInPlugin;
170 };
171 
172 } // namespace AlignmentSubsystem
173 } // namespace INDI
This class implements the default math plugin.
This class provides the driver side API to the in memory alignment database.
The following INDI properties are used to manage math plugins.
void ProcessSwitchProperties(Telescope *pTelescope, const char *name, ISState *states, char *names[], int n)
Call this function from within the ISNewSwitch processing path. The function will handle any math plu...
bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination)
TransformTelescopeToCelestial Transforms Mount Coords to Celestial (Sky) Coordinates.
void InitProperties(Telescope *pTelescope)
Initialize alignment math plugin properties. It is recommended to call this function within initPrope...
void SaveConfigProperties(FILE *fp)
Call this function to save persistent math plugin properties. This function should be called from wit...
bool IsAlignmentSubsystemActive() const
Return status of alignment subsystem.
void SetCurrentInMemoryDatabase(InMemoryDatabase *pDatabase)
Set the current in memory database.
void SetApproximateMountAlignment(MountAlignment_t ApproximateAlignment)
Set the approximate alognment of the mount.
void ProcessTextProperties(Telescope *pTelescope, const char *name, char *texts[], char *names[], int n)
Call this function from within the ISNewText processing path. The function will handle any math plugi...
bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset, TelescopeDirectionVector &ApparentTelescopeDirectionVector)
TransformCelestialToTelescope Transforms Celestial (Sky) Coords to Mount Coordinates.
bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
MountAlignment_t GetApproximateMountAlignment()
Get the approximate alognment of the mount.
MountType
Describes the basic type of the mount.
enum INDI::AlignmentSubsystem::MathPluginManagement::MountType MountType_t
void SetAlignmentSubsystemActive(bool enable)
SetAlignmentSubsystemActive Enable or Disable alignment subsystem.
void SetApproximateMountAlignmentFromMountType(MountType_t Type)
Call this function to set the ApproximateMountAlignment property of the current Math Plugin....
Provides alignment subsystem functions to INDI alignment math plugins.
Definition: MathPlugin.h:30
InMemoryDatabase * pInMemoryDatabase
Definition: MathPlugin.h:83
ISState
Switch state.
Definition: indiapi.h:150
@ ISS_ON
Definition: indiapi.h:152
enum INDI::AlignmentSubsystem::MountAlignment MountAlignment_t
Namespace to encapsulate INDI client, drivers, and mediator classes.
Holds a nomalised direction vector (direction cosines)
Definition: Common.h:69
One switch descriptor.
One text descriptor.
Holds the connection type.
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246