15 namespace AlignmentSubsystem
22 WaitForDriverCompletion();
24 AvailableMathPlugins.clear();
28 for (
int i = 0; i < pPlugins->count(); i++)
29 AvailableMathPlugins.emplace_back(std::string(pPlugins->at(i)->getLabel()));
36 ClientAPIForMathPluginManagement::BaseClient =
BaseClient;
41 Device = DevicePointer;
46 bool GotOneOfMine =
true;
48 if (strcmp(PropertyPointer->
getName(),
"ALIGNMENT_SUBSYSTEM_MATH_PLUGINS") == 0)
49 MathPlugins = PropertyPointer;
50 else if (strcmp(PropertyPointer->
getName(),
"ALIGNMENT_SUBSYSTEM_MATH_PLUGIN_INITIALISE") == 0)
51 PluginInitialise = PropertyPointer;
56 if (GotOneOfMine && (
nullptr != MathPlugins) && (
nullptr != PluginInitialise))
61 SignalDriverCompletion();
67 if (strcmp(SwitchVectorProperty->
name,
"ALIGNMENT_SUBSYSTEM_MATH_PLUGINS") == 0)
70 SignalDriverCompletion();
72 else if (strcmp(SwitchVectorProperty->
name,
"ALIGNMENT_SUBSYSTEM_MATH_PLUGIN_INITIALISE") == 0)
75 SignalDriverCompletion();
82 WaitForDriverCompletion();
87 for (i = 0; i < pPlugins->count(); i++)
89 if (0 == strcmp(MathPluginName.c_str(), pPlugins->at(i)->getLabel()))
92 if (i >= pPlugins->count())
96 pPlugins->at(i)->setState(
ISS_ON);
99 WaitForDriverCompletion();
100 if (
IPS_OK != pPlugins->getState())
102 IDLog(
"SelectMathPlugin - Bad MathPlugins switch state %s\n", pPlugins->getStateAsString());
111 WaitForDriverCompletion();
113 auto pPluginInitialise = PluginInitialise->
getSwitch();
115 pPluginInitialise->
reset();
116 pPluginInitialise->at(0)->setState(
ISS_ON);
119 WaitForDriverCompletion();
120 if (
IPS_OK != pPluginInitialise->getState())
122 IDLog(
"ReInitialiseMathPlugin - Bad PluginInitialise switch state %s\n", pPluginInitialise->getStateAsString());
130 bool ClientAPIForMathPluginManagement::SetDriverBusy()
132 int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
136 DriverActionComplete =
false;
137 IDLog(
"SetDriverBusy\n");
138 ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
139 return ReturnCode == 0;
142 bool ClientAPIForMathPluginManagement::SignalDriverCompletion()
144 int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
148 DriverActionComplete =
true;
149 ReturnCode = pthread_cond_signal(&DriverActionCompleteCondition);
152 ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
155 IDLog(
"SignalDriverCompletion\n");
156 ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
157 return ReturnCode == 0;
160 bool ClientAPIForMathPluginManagement::WaitForDriverCompletion()
162 int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
164 while (!DriverActionComplete)
166 IDLog(
"WaitForDriverCompletion - Waiting\n");
167 ReturnCode = pthread_cond_wait(&DriverActionCompleteCondition, &DriverActionCompleteMutex);
168 IDLog(
"WaitForDriverCompletion - Back from wait ReturnCode = %d\n", ReturnCode);
171 ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
175 IDLog(
"WaitForDriverCompletion - Finished waiting\n");
176 ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
177 return ReturnCode == 0;
void sendNewSwitch(INDI::Property pp)
Send new Switch command to server.
Class to provide basic client functionality.
Class to provide basic INDI device functionality.
Provides generic container for INDI properties.
INDI::PropertyViewSwitch * getSwitch() const
const char * getName() const
void IDLog(const char *fmt,...)
Namespace to encapsulate INDI client, drivers, and mediator classes.
Switch vector property descriptor.