Instrument Neutral Distributed Interface INDI  1.9.5
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  bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset,
116  TelescopeDirectionVector &ApparentTelescopeDirectionVector);
117  bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector,
118  double &RightAscension, double &Declination);
119 
120  private:
121  void EnumeratePlugins();
122  void HandlePluginLoading(Telescope *pTelescope, int CurrentPlugin, int NewPlugin);
123  std::vector<std::string> MathPluginFiles;
124  std::vector<std::string> MathPluginDisplayNames;
125 
126  std::unique_ptr<ISwitch> AlignmentSubsystemMathPlugins;
127  ISwitchVectorProperty AlignmentSubsystemMathPluginsV;
128  ISwitch AlignmentSubsystemMathPluginInitialise;
129  ISwitchVectorProperty AlignmentSubsystemMathPluginInitialiseV;
130  ISwitch AlignmentSubsystemActive;
131  ISwitchVectorProperty AlignmentSubsystemActiveV;
132 
133  InMemoryDatabase *CurrentInMemoryDatabase;
134 
135  // The following property is used for configuration purposes only and is not propagated to the client
136  IText AlignmentSubsystemCurrentMathPlugin;
137  ITextVectorProperty AlignmentSubsystemCurrentMathPluginV;
138 
139  // The following hold links to the current loaded math plugin
140  // These must match the function signatures in MathPlugin
141  MountAlignment_t (MathPlugin::*pGetApproximateMountAlignment)();
142  bool (MathPlugin::*pInitialise)(InMemoryDatabase *pInMemoryDatabase);
143  void (MathPlugin::*pSetApproximateMountAlignment)(MountAlignment_t ApproximateAlignment);
144  bool (MathPlugin::*pTransformCelestialToTelescope)(const double RightAscension, const double Declination,
145  double JulianOffset,
147  bool (MathPlugin::*pTransformTelescopeToCelestial)(const TelescopeDirectionVector &TelescopeDirectionVector,
148  double &RightAscension, double &Declination);
149  MathPlugin *pLoadedMathPlugin;
150  void *LoadedMathPluginHandle;
151 
152  BuiltInMathPlugin BuiltInPlugin;
153 };
154 
155 } // namespace AlignmentSubsystem
156 } // namespace INDI
INDI::AlignmentSubsystem::MathPluginManagement::SaveConfigProperties
void SaveConfigProperties(FILE *fp)
Call this function to save persistent math plugin properties. This function should be called from wit...
Definition: MathPluginManagement.cpp:325
INDI::AlignmentSubsystem::MathPluginManagement::MathPluginManagement
MathPluginManagement()
Default constructor.
Definition: MathPluginManagement.cpp:19
INDI::AlignmentSubsystem::MathPluginManagement::SetApproximateMountAlignmentFromMountType
void SetApproximateMountAlignmentFromMountType(MountType_t Type)
Call this function to set the ApproximateMountAlignment property of the current Math Plugin....
Definition: MathPluginManagement.cpp:332
INDI::AlignmentSubsystem::MathPluginManagement::IsAlignmentSubsystemActive
bool IsAlignmentSubsystemActive() const
Return status of alignment subsystem.
Definition: MathPluginManagement.h:106
INDI::AlignmentSubsystem::MathPluginManagement::ProcessTextProperties
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...
Definition: MathPluginManagement.cpp:95
ISwitch
One switch descriptor.
INDI::AlignmentSubsystem::MathPluginManagement::InitProperties
void InitProperties(Telescope *pTelescope)
Initialize alignment math plugin properties. It is recommended to call this function within initPrope...
Definition: MathPluginManagement.cpp:30
INDI::AlignmentSubsystem::MathPluginManagement::SetAlignmentSubsystemActive
void SetAlignmentSubsystemActive(bool enable)
SetAlignmentSubsystemActive Enable or Disable alignment subsystem.
Definition: MathPluginManagement.cpp:318
INDI::AlignmentSubsystem::MathPluginManagement
The following INDI properties are used to manage math plugins.
Definition: MathPluginManagement.h:34
INDI::AlignmentSubsystem::MathPluginManagement::GetApproximateMountAlignment
MountAlignment_t GetApproximateMountAlignment()
Get the approximate alognment of the mount.
Definition: MathPluginManagement.cpp:354
INDI::AlignmentSubsystem::MathPluginManagement::TransformTelescopeToCelestial
bool TransformTelescopeToCelestial(const TelescopeDirectionVector &ApparentTelescopeDirectionVector, double &RightAscension, double &Declination)
Get the true celestial coordinates for the supplied telescope pointing direction.
Definition: MathPluginManagement.cpp:380
INDI::AlignmentSubsystem::MathPluginManagement::SetCurrentInMemoryDatabase
void SetCurrentInMemoryDatabase(InMemoryDatabase *pDatabase)
Set the current in memory database.
Definition: MathPluginManagement.h:93
INDI::AlignmentSubsystem::MathPluginManagement::ProcessSwitchProperties
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...
Definition: MathPluginManagement.cpp:214
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
IText
One text descriptor.
inditelescope.h
INDI::AlignmentSubsystem::MathPluginManagement::EQUATORIAL
@ EQUATORIAL
Definition: MathPluginManagement.h:40
INDI::AlignmentSubsystem::InMemoryDatabase
This class provides the driver side API to the in memory alignment database.
Definition: InMemoryDatabase.h:23
INDI::AlignmentSubsystem::MathPlugin::pInMemoryDatabase
InMemoryDatabase * pInMemoryDatabase
Definition: MathPlugin.h:80
INDI::Telescope
Definition: inditelescope.h:70
INDI::AlignmentSubsystem::MathPluginManagement::TransformCelestialToTelescope
bool TransformCelestialToTelescope(const double RightAscension, const double Declination, double JulianOffset, TelescopeDirectionVector &ApparentTelescopeDirectionVector)
Get the alignment corrected telescope pointing direction for the supplied celestial coordinates.
Definition: MathPluginManagement.cpp:369
INDI::AlignmentSubsystem::MathPlugin
Provides alignment subsystem functions to INDI alignment math plugins.
Definition: MathPlugin.h:29
INDI::AlignmentSubsystem::MathPluginManagement::MountType
MountType
Describes the basic type of the mount.
Definition: MathPluginManagement.h:40
Type
Holds the connection type.
name
const char * name
Definition: indiserver.c:116
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
INDI::AlignmentSubsystem::MathPluginManagement::ALTAZ
@ ALTAZ
Definition: MathPluginManagement.h:40
INDI::AlignmentSubsystem::MathPluginManagement::Initialise
bool Initialise(InMemoryDatabase *pInMemoryDatabase)
Initialise or re-initialise the math plugin. Re-reading the in memory database as necessary.
Definition: MathPluginManagement.cpp:359
INDI::AlignmentSubsystem::MathPluginManagement::~MathPluginManagement
virtual ~MathPluginManagement()
Virtual destructor.
Definition: MathPluginManagement.h:46
INDI::AlignmentSubsystem::MountAlignment_t
enum INDI::AlignmentSubsystem::MountAlignment MountAlignment_t
ISState
ISState
Switch state.
Definition: indiapi.h:148
INDI::AlignmentSubsystem::BuiltInMathPlugin
This class implements the default math plugin.
Definition: BuiltInMathPlugin.h:20
INDI::AlignmentSubsystem::MathPluginManagement::SetApproximateMountAlignment
void SetApproximateMountAlignment(MountAlignment_t ApproximateAlignment)
Set the approximate alognment of the mount.
Definition: MathPluginManagement.cpp:364
INDI::AlignmentSubsystem::TelescopeDirectionVector
Holds a nomalised direction vector (direction cosines)
Definition: Common.h:68
INDI::AlignmentSubsystem::MathPluginManagement::MountType_t
enum INDI::AlignmentSubsystem::MathPluginManagement::MountType MountType_t
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
ISS_ON
@ ISS_ON
Definition: indiapi.h:151
BuiltInMathPlugin.h