Instrument Neutral Distributed Interface INDI  1.9.5
ClientAPIForAlignmentDatabase.cpp
Go to the documentation of this file.
1 
10 
11 #include "indicom.h"
12 
13 namespace INDI
14 {
15 namespace AlignmentSubsystem
16 {
18 {
19  pthread_cond_init(&DriverActionCompleteCondition, nullptr);
20  pthread_mutex_init(&DriverActionCompleteMutex, nullptr);
21 }
22 
24 {
25  pthread_cond_destroy(&DriverActionCompleteCondition);
26  pthread_mutex_destroy(&DriverActionCompleteMutex);
27 }
28 
30 {
31  // Wait for driver to initialise if neccessary
32  WaitForDriverCompletion();
33 
34  ISwitchVectorProperty *pAction = Action->getSwitch();
35  ISwitchVectorProperty *pCommit = Commit->getSwitch();
36 
37  if (APPEND != IUFindOnSwitchIndex(pAction))
38  {
39  // Request Append mode
40  IUResetSwitch(pAction);
41  pAction->sp[APPEND].s = ISS_ON;
42  SetDriverBusy();
43  BaseClient->sendNewSwitch(pAction);
44  WaitForDriverCompletion();
45  if (IPS_OK != pAction->s)
46  {
47  IDLog("AppendSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
48  return false;
49  }
50  }
51 
52  if (!SendEntryData(CurrentValues))
53  return false;
54 
55  // Commit the entry to the database
56  IUResetSwitch(pCommit);
57  pCommit->sp[0].s = ISS_ON;
58  SetDriverBusy();
59  BaseClient->sendNewSwitch(pCommit);
60  WaitForDriverCompletion();
61  if (IPS_OK != pCommit->s)
62  {
63  IDLog("AppendSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s));
64  return false;
65  }
66 
67  return true;
68 }
69 
71 {
72  // Wait for driver to initialise if neccessary
73  WaitForDriverCompletion();
74 
75  ISwitchVectorProperty *pAction = Action->getSwitch();
76  ISwitchVectorProperty *pCommit = Commit->getSwitch();
77 
78  // Select the required action
79  if (CLEAR != IUFindOnSwitchIndex(pAction))
80  {
81  // Request Clear mode
82  IUResetSwitch(pAction);
83  pAction->sp[CLEAR].s = ISS_ON;
84  SetDriverBusy();
85  BaseClient->sendNewSwitch(pAction);
86  WaitForDriverCompletion();
87  if (IPS_OK != pAction->s)
88  {
89  IDLog("ClearSyncPoints - Bad Action switch state %s\n", pstateStr(pAction->s));
90  return false;
91  }
92  }
93 
94  IUResetSwitch(pCommit);
95  pCommit->sp[0].s = ISS_ON;
96  SetDriverBusy();
97  BaseClient->sendNewSwitch(pCommit);
98  WaitForDriverCompletion();
99  if (IPS_OK != pCommit->s)
100  {
101  IDLog("ClearSyncPoints - Bad Commit switch state %s\n", pstateStr(pCommit->s));
102  return false;
103  }
104 
105  return true;
106 }
107 
109 {
110  // Wait for driver to initialise if neccessary
111  WaitForDriverCompletion();
112 
113  ISwitchVectorProperty *pAction = Action->getSwitch();
114  INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber();
115  ISwitchVectorProperty *pCommit = Commit->getSwitch();
116 
117  // Select the required action
118  if (DELETE != IUFindOnSwitchIndex(pAction))
119  {
120  // Request Delete mode
121  IUResetSwitch(pAction);
122  pAction->sp[DELETE].s = ISS_ON;
123  SetDriverBusy();
124  BaseClient->sendNewSwitch(pAction);
125  WaitForDriverCompletion();
126  if (IPS_OK != pAction->s)
127  {
128  IDLog("DeleteSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
129  return false;
130  }
131  }
132 
133  // Send the offset
134  pCurrentEntry->np[0].value = Offset;
135  SetDriverBusy();
136  BaseClient->sendNewNumber(pCurrentEntry);
137  WaitForDriverCompletion();
138  if (IPS_OK != pCurrentEntry->s)
139  {
140  IDLog("DeleteSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s));
141  return false;
142  }
143 
144  // Commit the entry to the database
145  IUResetSwitch(pCommit);
146  pCommit->sp[0].s = ISS_ON;
147  SetDriverBusy();
148  BaseClient->sendNewSwitch(pCommit);
149  WaitForDriverCompletion();
150  if (IPS_OK != pCommit->s)
151  {
152  IDLog("DeleteSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s));
153  return false;
154  }
155 
156  return true;
157 }
158 
159 bool ClientAPIForAlignmentDatabase::EditSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
160 {
161  // Wait for driver to initialise if neccessary
162  WaitForDriverCompletion();
163 
164  ISwitchVectorProperty *pAction = Action->getSwitch();
165  INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber();
166  ISwitchVectorProperty *pCommit = Commit->getSwitch();
167 
168  // Select the required action
169  if (EDIT != IUFindOnSwitchIndex(pAction))
170  {
171  // Request Edit mode
172  IUResetSwitch(pAction);
173  pAction->sp[EDIT].s = ISS_ON;
174  SetDriverBusy();
175  BaseClient->sendNewSwitch(pAction);
176  WaitForDriverCompletion();
177  if (IPS_OK != pAction->s)
178  {
179  IDLog("EditSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
180  return false;
181  }
182  }
183 
184  // Send the offset
185  pCurrentEntry->np[0].value = Offset;
186  SetDriverBusy();
187  BaseClient->sendNewNumber(pCurrentEntry);
188  WaitForDriverCompletion();
189  if (IPS_OK != pCurrentEntry->s)
190  {
191  IDLog("EditSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s));
192  return false;
193  }
194 
195  if (!SendEntryData(CurrentValues))
196  return false;
197 
198  // Commit the entry to the database
199  IUResetSwitch(pCommit);
200  pCommit->sp[0].s = ISS_ON;
201  SetDriverBusy();
202  BaseClient->sendNewSwitch(pCommit);
203  WaitForDriverCompletion();
204  if (IPS_OK != pCommit->s)
205  {
206  IDLog("EditSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s));
207  return false;
208  }
209 
210  return true;
211 }
212 
214 {
215  return 0;
216 }
217 
219 {
220  ClientAPIForAlignmentDatabase::BaseClient = BaseClient;
221 }
222 
223 bool ClientAPIForAlignmentDatabase::InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
224 {
225  // Wait for driver to initialise if neccessary
226  WaitForDriverCompletion();
227 
228  ISwitchVectorProperty *pAction = Action->getSwitch();
229  INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber();
230  ISwitchVectorProperty *pCommit = Commit->getSwitch();
231 
232  // Select the required action
233  if (INSERT != IUFindOnSwitchIndex(pAction))
234  {
235  // Request Insert mode
236  IUResetSwitch(pAction);
237  pAction->sp[INSERT].s = ISS_ON;
238  SetDriverBusy();
239  BaseClient->sendNewSwitch(pAction);
240  WaitForDriverCompletion();
241  if (IPS_OK != pAction->s)
242  {
243  IDLog("InsertSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
244  return false;
245  }
246  }
247 
248  // Send the offset
249  pCurrentEntry->np[0].value = Offset;
250  SetDriverBusy();
251  BaseClient->sendNewNumber(pCurrentEntry);
252  WaitForDriverCompletion();
253  if (IPS_OK != pCurrentEntry->s)
254  {
255  IDLog("InsertSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s));
256  return false;
257  }
258 
259  if (!SendEntryData(CurrentValues))
260  return false;
261 
262  // Commit the entry to the database
263  IUResetSwitch(pCommit);
264  pCommit->sp[0].s = ISS_ON;
265  SetDriverBusy();
266  BaseClient->sendNewSwitch(pCommit);
267  WaitForDriverCompletion();
268  if (IPS_OK != pCommit->s)
269  {
270  IDLog("InsertSyncPoint - Bad Commit switch state %s\n", pstateStr(pCommit->s));
271  return false;
272  }
273 
274  return true;
275 }
276 
278 {
279  // Wait for driver to initialise if neccessary
280  WaitForDriverCompletion();
281 
282  ISwitchVectorProperty *pAction = Action->getSwitch();
283  ISwitchVectorProperty *pCommit = Commit->getSwitch();
284 
285  // Select the required action
286  if (LOAD_DATABASE != IUFindOnSwitchIndex(pAction))
287  {
288  // Request Load Database mode
289  IUResetSwitch(pAction);
290  pAction->sp[LOAD_DATABASE].s = ISS_ON;
291  SetDriverBusy();
292  BaseClient->sendNewSwitch(pAction);
293  WaitForDriverCompletion();
294  if (IPS_OK != pAction->s)
295  {
296  IDLog("LoadDatabase - Bad Action switch state %s\n", pstateStr(pAction->s));
297  return false;
298  }
299  }
300 
301  // Commit the Load Database
302  IUResetSwitch(pCommit);
303  pCommit->sp[0].s = ISS_ON;
304  SetDriverBusy();
305  BaseClient->sendNewSwitch(pCommit);
306  WaitForDriverCompletion();
307  if (IPS_OK != pCommit->s)
308  {
309  IDLog("LoadDatabase - Bad Commit state %s\n", pstateStr(pCommit->s));
310  return false;
311  }
312 
313  return true;
314 }
315 
317 {
318  if (strcmp(BLOBPointer->bvp->name, "ALIGNMENT_POINT_OPTIONAL_BINARY_BLOB") == 0)
319  {
320  if (IPS_BUSY != BLOBPointer->bvp->s)
321  {
322  ISwitchVectorProperty *pAction = Action->getSwitch();
323  int Index = IUFindOnSwitchIndex(pAction);
324  if ((READ != Index) && (READ_INCREMENT != Index))
325  SignalDriverCompletion();
326  }
327  }
328 }
329 
331 {
332  Device = DevicePointer;
333 }
334 
336 {
337  if (strcmp(NumberVectorProperty->name, "ALIGNMENT_POINT_MANDATORY_NUMBERS") == 0)
338  {
339  if (IPS_BUSY != NumberVectorProperty->s)
340  {
341  ISwitchVectorProperty *pAction = Action->getSwitch();
342  int Index = IUFindOnSwitchIndex(pAction);
343  if ((READ != Index) && (READ_INCREMENT != Index))
344  SignalDriverCompletion();
345  }
346  }
347  else if (strcmp(NumberVectorProperty->name, "ALIGNMENT_POINTSET_CURRENT_ENTRY") == 0)
348  {
349  if (IPS_BUSY != NumberVectorProperty->s)
350  {
351  ISwitchVectorProperty *pAction = Action->getSwitch();
352  int Index = IUFindOnSwitchIndex(pAction);
353  if (READ_INCREMENT != Index)
354  SignalDriverCompletion();
355  }
356  }
357 }
358 
360 {
361  bool GotOneOfMine = true;
362 
363  if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINT_MANDATORY_NUMBERS") == 0)
364  MandatoryNumbers = PropertyPointer;
365  else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINT_OPTIONAL_BINARY_BLOB") == 0)
366  {
367  OptionalBinaryBlob = PropertyPointer;
368  // Make sure the format string is set up
369  strncpy(OptionalBinaryBlob->getBLOB()->bp->format, "alignmentPrivateData", MAXINDIBLOBFMT);
370  }
371  else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINTSET_SIZE") == 0)
372  PointsetSize = PropertyPointer;
373  else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINTSET_CURRENT_ENTRY") == 0)
374  CurrentEntry = PropertyPointer;
375  else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINTSET_ACTION") == 0)
376  Action = PropertyPointer;
377  else if (strcmp(PropertyPointer->getName(), "ALIGNMENT_POINTSET_COMMIT") == 0)
378  Commit = PropertyPointer;
379  else
380  GotOneOfMine = false;
381 
382  // Tell the client when all the database proeprties have been set up
383  if (GotOneOfMine && (nullptr != MandatoryNumbers) && (nullptr != OptionalBinaryBlob) && (nullptr != PointsetSize) &&
384  (nullptr != CurrentEntry) && (nullptr != Action) && (nullptr != Commit))
385  {
386  // The DriverActionComplete state variable is initialised to false
387  // So I need to call this to set it to true and signal anyone
388  // waiting for the driver to initialise etc.
389  SignalDriverCompletion();
390  }
391 }
392 
394 {
395  if (strcmp(SwitchVectorProperty->name, "ALIGNMENT_POINTSET_ACTION") == 0)
396  {
397  if (IPS_BUSY != SwitchVectorProperty->s)
398  SignalDriverCompletion();
399  }
400  else if (strcmp(SwitchVectorProperty->name, "ALIGNMENT_POINTSET_COMMIT") == 0)
401  {
402  if (IPS_BUSY != SwitchVectorProperty->s)
403  SignalDriverCompletion();
404  }
405 }
406 
408 {
409  // Wait for driver to initialise if neccessary
410  WaitForDriverCompletion();
411 
412  ISwitchVectorProperty *pAction = Action->getSwitch();
413  INumberVectorProperty *pMandatoryNumbers = MandatoryNumbers->getNumber();
414  IBLOBVectorProperty *pBLOB = OptionalBinaryBlob->getBLOB();
415  INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber();
416  ISwitchVectorProperty *pCommit = Commit->getSwitch();
417 
418  // Select the required action
419  if (READ_INCREMENT != IUFindOnSwitchIndex(pAction))
420  {
421  // Request Read Increment mode
422  IUResetSwitch(pAction);
423  pAction->sp[READ_INCREMENT].s = ISS_ON;
424  SetDriverBusy();
425  BaseClient->sendNewSwitch(pAction);
426  WaitForDriverCompletion();
427  if (IPS_OK != pAction->s)
428  {
429  IDLog("ReadIncrementSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
430  return false;
431  }
432  }
433 
434  // Commit the read increment
435  IUResetSwitch(pCommit);
436  pCommit->sp[0].s = ISS_ON;
437  SetDriverBusy();
438  BaseClient->sendNewSwitch(pCommit);
439  WaitForDriverCompletion();
440  if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s) ||
441  (IPS_OK != pCurrentEntry->s))
442  {
443  IDLog("ReadIncrementSyncPoint - Bad Commit/Mandatory numbers/Blob/Current entry state %s %s %s %s\n",
444  pstateStr(pCommit->s), pstateStr(pMandatoryNumbers->s), pstateStr(pBLOB->s), pstateStr(pCurrentEntry->s));
445  return false;
446  }
447 
448  // Read the entry data
449  CurrentValues.ObservationJulianDate = pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value;
450  CurrentValues.RightAscension = pMandatoryNumbers->np[ENTRY_RA].value;
451  CurrentValues.Declination = pMandatoryNumbers->np[ENTRY_DEC].value;
452  CurrentValues.TelescopeDirection.x = pMandatoryNumbers->np[ENTRY_VECTOR_X].value;
453  CurrentValues.TelescopeDirection.y = pMandatoryNumbers->np[ENTRY_VECTOR_Y].value;
454  CurrentValues.TelescopeDirection.z = pMandatoryNumbers->np[ENTRY_VECTOR_Z].value;
455 
456  return true;
457 }
458 
460 {
461  // Wait for driver to initialise if neccessary
462  WaitForDriverCompletion();
463 
464  ISwitchVectorProperty *pAction = Action->getSwitch();
465  INumberVectorProperty *pMandatoryNumbers = MandatoryNumbers->getNumber();
466  IBLOBVectorProperty *pBLOB = OptionalBinaryBlob->getBLOB();
467  INumberVectorProperty *pCurrentEntry = CurrentEntry->getNumber();
468  ISwitchVectorProperty *pCommit = Commit->getSwitch();
469 
470  // Select the required action
471  if (READ != IUFindOnSwitchIndex(pAction))
472  {
473  // Request Read mode
474  IUResetSwitch(pAction);
475  pAction->sp[READ].s = ISS_ON;
476  SetDriverBusy();
477  BaseClient->sendNewSwitch(pAction);
478  WaitForDriverCompletion();
479  if (IPS_OK != pAction->s)
480  {
481  IDLog("ReadSyncPoint - Bad Action switch state %s\n", pstateStr(pAction->s));
482  return false;
483  }
484  }
485 
486  // Send the offset
487  pCurrentEntry->np[0].value = Offset;
488  SetDriverBusy();
489  BaseClient->sendNewNumber(pCurrentEntry);
490  WaitForDriverCompletion();
491  if (IPS_OK != pCurrentEntry->s)
492  {
493  IDLog("ReadSyncPoint - Bad Current Entry state %s\n", pstateStr(pCurrentEntry->s));
494  return false;
495  }
496 
497  // Commit the read
498  IUResetSwitch(pCommit);
499  pCommit->sp[0].s = ISS_ON;
500  SetDriverBusy();
501  BaseClient->sendNewSwitch(pCommit);
502  WaitForDriverCompletion();
503  if ((IPS_OK != pCommit->s) || (IPS_OK != pMandatoryNumbers->s) || (IPS_OK != pBLOB->s))
504  {
505  IDLog("ReadSyncPoint - Bad Commit/Mandatory numbers/Blob state %s %s %s\n", pstateStr(pCommit->s),
506  pstateStr(pMandatoryNumbers->s), pstateStr(pBLOB->s));
507  return false;
508  }
509 
510  // Read the entry data
511  CurrentValues.ObservationJulianDate = pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value;
512  CurrentValues.RightAscension = pMandatoryNumbers->np[ENTRY_RA].value;
513  CurrentValues.Declination = pMandatoryNumbers->np[ENTRY_DEC].value;
514  CurrentValues.TelescopeDirection.x = pMandatoryNumbers->np[ENTRY_VECTOR_X].value;
515  CurrentValues.TelescopeDirection.y = pMandatoryNumbers->np[ENTRY_VECTOR_Y].value;
516  CurrentValues.TelescopeDirection.z = pMandatoryNumbers->np[ENTRY_VECTOR_Z].value;
517 
518  return true;
519 }
520 
522 {
523  // Wait for driver to initialise if neccessary
524  WaitForDriverCompletion();
525 
526  ISwitchVectorProperty *pAction = Action->getSwitch();
527  ISwitchVectorProperty *pCommit = Commit->getSwitch();
528 
529  // Select the required action
530  if (SAVE_DATABASE != IUFindOnSwitchIndex(pAction))
531  {
532  // Request Load Database mode
533  IUResetSwitch(pAction);
534  pAction->sp[SAVE_DATABASE].s = ISS_ON;
535  SetDriverBusy();
536  BaseClient->sendNewSwitch(pAction);
537  WaitForDriverCompletion();
538  if (IPS_OK != pAction->s)
539  {
540  IDLog("SaveDatabase - Bad Action switch state %s\n", pstateStr(pAction->s));
541  return false;
542  }
543  }
544 
545  // Commit the Save Database
546  IUResetSwitch(pCommit);
547  pCommit->sp[0].s = ISS_ON;
548  SetDriverBusy();
549  BaseClient->sendNewSwitch(pCommit);
550  WaitForDriverCompletion();
551  if (IPS_OK != pCommit->s)
552  {
553  IDLog("Save Database - Bad Commit state %s\n", pstateStr(pCommit->s));
554  return false;
555  }
556 
557  return true;
558 }
559 
560 // Private methods
561 
562 bool ClientAPIForAlignmentDatabase::SendEntryData(const AlignmentDatabaseEntry &CurrentValues)
563 {
564  INumberVectorProperty *pMandatoryNumbers = MandatoryNumbers->getNumber();
565  IBLOBVectorProperty *pBLOB = OptionalBinaryBlob->getBLOB();
566  // Send the entry data
567  pMandatoryNumbers->np[ENTRY_OBSERVATION_JULIAN_DATE].value = CurrentValues.ObservationJulianDate;
568  pMandatoryNumbers->np[ENTRY_RA].value = CurrentValues.RightAscension;
569  pMandatoryNumbers->np[ENTRY_DEC].value = CurrentValues.Declination;
570  pMandatoryNumbers->np[ENTRY_VECTOR_X].value = CurrentValues.TelescopeDirection.x;
571  pMandatoryNumbers->np[ENTRY_VECTOR_Y].value = CurrentValues.TelescopeDirection.y;
572  pMandatoryNumbers->np[ENTRY_VECTOR_Z].value = CurrentValues.TelescopeDirection.z;
573  SetDriverBusy();
574  BaseClient->sendNewNumber(pMandatoryNumbers);
575  WaitForDriverCompletion();
576  if (IPS_OK != pMandatoryNumbers->s)
577  {
578  IDLog("SendEntryData - Bad mandatory numbers state %s\n", pstateStr(pMandatoryNumbers->s));
579  return false;
580  }
581 
582  if ((0 != CurrentValues.PrivateDataSize) && (nullptr != CurrentValues.PrivateData.get()))
583  {
584  // I have a BLOB to send
585  SetDriverBusy();
586  BaseClient->startBlob(Device->getDeviceName(), pBLOB->name, timestamp());
587  BaseClient->sendOneBlob(pBLOB->bp->name, CurrentValues.PrivateDataSize, pBLOB->bp->format,
588  CurrentValues.PrivateData.get());
590  WaitForDriverCompletion();
591  if (IPS_OK != pBLOB->s)
592  {
593  IDLog("SendEntryData - Bad BLOB state %s\n", pstateStr(pBLOB->s));
594  return false;
595  }
596  }
597  return true;
598 }
599 
600 bool ClientAPIForAlignmentDatabase::SetDriverBusy()
601 {
602  int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
603 
604  if (ReturnCode != 0)
605  return false;
606  DriverActionComplete = false;
607  IDLog("SetDriverBusy\n");
608  ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
609  return ReturnCode == 0;
610 }
611 
612 bool ClientAPIForAlignmentDatabase::SignalDriverCompletion()
613 {
614  int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
615 
616  if (ReturnCode != 0)
617  return false;
618  DriverActionComplete = true;
619  ReturnCode = pthread_cond_signal(&DriverActionCompleteCondition);
620  if (ReturnCode != 0)
621  {
622  ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
623  return false;
624  }
625  IDLog("SignalDriverCompletion\n");
626  ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
627  return ReturnCode == 0;
628 }
629 
630 bool ClientAPIForAlignmentDatabase::WaitForDriverCompletion()
631 {
632  int ReturnCode = pthread_mutex_lock(&DriverActionCompleteMutex);
633 
634  while (!DriverActionComplete)
635  {
636  IDLog("WaitForDriverCompletion - Waiting\n");
637  ReturnCode = pthread_cond_wait(&DriverActionCompleteCondition, &DriverActionCompleteMutex);
638  IDLog("WaitForDriverCompletion - Back from wait ReturnCode = %d\n", ReturnCode);
639  if (ReturnCode != 0)
640  {
641  ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
642  return false;
643  }
644  }
645  IDLog("WaitForDriverCompletion - Finished waiting\n");
646  ReturnCode = pthread_mutex_unlock(&DriverActionCompleteMutex);
647  return ReturnCode == 0;
648 }
649 
650 } // namespace AlignmentSubsystem
651 } // namespace INDI
INDI::AlignmentSubsystem::ENTRY_VECTOR_Z
@ ENTRY_VECTOR_Z
Definition: Common.h:57
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::TelescopeDirection
TelescopeDirectionVector TelescopeDirection
Normalised vector giving telescope pointing direction. This is referred to elsewhere as the "apparent...
Definition: Common.h:191
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ReadIncrementSyncPoint
bool ReadIncrementSyncPoint(AlignmentDatabaseEntry &CurrentValues)
Increment the current offset then read a sync point from the database.
Definition: ClientAPIForAlignmentDatabase.cpp:407
INDI::BaseClient::sendOneBlob
void sendOneBlob(IBLOB *bp)
Send ONE blob content to server. The BLOB data in raw binary format and will be converted to base64 a...
Definition: baseclient.cpp:1035
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::Initialise
void Initialise(INDI::BaseClient *BaseClient)
Initialise the API.
Definition: ClientAPIForAlignmentDatabase.cpp:218
_IBLOBVectorProperty::s
IPState s
Definition: indiapi.h:484
INDI::AlignmentSubsystem::AlignmentDatabaseEntry
Entry in the in memory alignment database.
Definition: Common.h:145
INDI::AlignmentSubsystem::INSERT
@ INSERT
Definition: Common.h:37
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ProcessNewProperty
void ProcessNewProperty(INDI::Property *PropertyPointer)
Process new property message from driver. This routine should be called from within the newProperty h...
Definition: ClientAPIForAlignmentDatabase.cpp:359
INDI::Property::getName
const char * getName() const
Definition: indiproperty.cpp:289
INDI::AlignmentSubsystem::LOAD_DATABASE
@ LOAD_DATABASE
Definition: Common.h:43
IPS_OK
@ IPS_OK
Definition: indiapi.h:161
_INumberVectorProperty::s
IPState s
Definition: indiapi.h:332
indicom.h
Implementations for common driver routines.
_IBLOBVectorProperty
BLOB (Binary Large Object) vector property descriptor.
Definition: indiapi.h:469
INDI::AlignmentSubsystem::READ_INCREMENT
@ READ_INCREMENT
Definition: Common.h:42
INDI::BaseClient::finishBlob
void finishBlob()
Send closing tag for BLOB command to server.
Definition: baseclient.cpp:1054
INDI::AlignmentSubsystem::ENTRY_RA
@ ENTRY_RA
Definition: Common.h:53
timestamp
const char * timestamp()
Create an ISO 8601 formatted time stamp. The format is YYYY-MM-DDTHH:MM:SS.
Definition: indicom.c:340
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateDataSize
int PrivateDataSize
This size in bytes of any private data.
Definition: Common.h:197
INDI::AlignmentSubsystem::ENTRY_DEC
@ ENTRY_DEC
Definition: Common.h:54
MAXINDIBLOBFMT
#define MAXINDIBLOBFMT
Definition: indiapi.h:195
INDI::BaseDevice::getDeviceName
const char * getDeviceName() const
Definition: basedevice.cpp:799
INDI::Property::getNumber
INDI::PropertyView< INumber > * getNumber() const
Definition: indiproperty.cpp:384
INDI::AlignmentSubsystem::ENTRY_VECTOR_X
@ ENTRY_VECTOR_X
Definition: Common.h:55
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::SaveDatabase
bool SaveDatabase()
Save the database to persistent storage.
Definition: ClientAPIForAlignmentDatabase.cpp:521
_IBLOBVectorProperty::bp
IBLOB * bp
Definition: indiapi.h:486
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::LoadDatabase
bool LoadDatabase()
Load the database from persistent storage.
Definition: ClientAPIForAlignmentDatabase.cpp:277
INDI::AlignmentSubsystem::EDIT
@ EDIT
Definition: Common.h:38
INDI::AlignmentSubsystem::APPEND
@ APPEND
Definition: Common.h:36
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ReadSyncPoint
bool ReadSyncPoint(unsigned int Offset, AlignmentDatabaseEntry &CurrentValues)
Read a sync point from the database.
Definition: ClientAPIForAlignmentDatabase.cpp:459
INDI::AlignmentSubsystem::ENTRY_VECTOR_Y
@ ENTRY_VECTOR_Y
Definition: Common.h:56
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ClientAPIForAlignmentDatabase
ClientAPIForAlignmentDatabase()
Default constructor.
Definition: ClientAPIForAlignmentDatabase.cpp:17
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ProcessNewBLOB
void ProcessNewBLOB(IBLOB *BLOBPointer)
Process new BLOB message from driver. This routine should be called from within the newBLOB handler i...
Definition: ClientAPIForAlignmentDatabase.cpp:316
IUResetSwitch
void IUResetSwitch(ISwitchVectorProperty *svp)
Reset all switches in a switch vector property to OFF.
Definition: indicom.c:1442
IDLog
void void void void void IDLog(const char *msg,...) ATTRIBUTE_FORMAT_PRINTF(1
Function Drivers call to log a message locally.
INDI::Property
Provides generic container for INDI properties.
Definition: indiproperty.h:43
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::DeleteSyncPoint
bool DeleteSyncPoint(unsigned int Offset)
Delete a sync point from the database.
Definition: ClientAPIForAlignmentDatabase.cpp:108
INDI::BaseClient::sendNewNumber
void sendNewNumber(INumberVectorProperty *pp)
Send new Number command to server.
Definition: baseclient.cpp:970
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
INDI::AlignmentSubsystem::CLEAR
@ CLEAR
Definition: Common.h:40
INDI::Property::getBLOB
INDI::PropertyView< IBLOB > * getBLOB() const
Definition: indiproperty.cpp:420
pstateStr
const char * pstateStr(IPState s)
Definition: indicom.c:1215
INDI::AlignmentSubsystem::DELETE
@ DELETE
Definition: Common.h:39
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ProcessNewSwitch
void ProcessNewSwitch(ISwitchVectorProperty *SwitchVectorProperty)
Process new switch message from driver. This routine should be called from within the newSwitch handl...
Definition: ClientAPIForAlignmentDatabase.cpp:393
IPS_BUSY
@ IPS_BUSY
Definition: indiapi.h:162
_INumberVectorProperty::np
INumber * np
Definition: indiapi.h:334
INDI::AlignmentSubsystem::TelescopeDirectionVector::z
double z
Definition: Common.h:78
_INumberVectorProperty::name
char name[MAXINDINAME]
Definition: indiapi.h:322
INDI::AlignmentSubsystem::READ
@ READ
Definition: Common.h:41
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::PrivateData
std::unique_ptr< unsigned char > PrivateData
Private data associated with this sync point.
Definition: Common.h:194
ClientAPIForAlignmentDatabase.h
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ProcessNewDevice
void ProcessNewDevice(INDI::BaseDevice *DevicePointer)
Process new device message from driver. This routine should be called from within the newDevice handl...
Definition: ClientAPIForAlignmentDatabase.cpp:330
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ClearSyncPoints
bool ClearSyncPoints()
Delete all sync points from the database.
Definition: ClientAPIForAlignmentDatabase.cpp:70
INDI::AlignmentSubsystem::TelescopeDirectionVector::y
double y
Definition: Common.h:77
INDI::AlignmentSubsystem::ENTRY_OBSERVATION_JULIAN_DATE
@ ENTRY_OBSERVATION_JULIAN_DATE
Definition: Common.h:52
INDI::BaseClient
Class to provide basic client functionality.
Definition: baseclient.h:54
INDI::BaseClient::sendNewSwitch
void sendNewSwitch(ISwitchVectorProperty *pp)
Send new Switch command to server.
Definition: baseclient.cpp:1000
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::GetDatabaseSize
int GetDatabaseSize()
Return the number of entries in the database.
Definition: ClientAPIForAlignmentDatabase.cpp:213
_ISwitchVectorProperty::s
IPState s
Definition: indiapi.h:382
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::InsertSyncPoint
bool InsertSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Insert a sync point in the database.
Definition: ClientAPIForAlignmentDatabase.cpp:223
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::~ClientAPIForAlignmentDatabase
virtual ~ClientAPIForAlignmentDatabase()
Virtual destructor.
Definition: ClientAPIForAlignmentDatabase.cpp:23
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::ProcessNewNumber
void ProcessNewNumber(INumberVectorProperty *NumberVectorProperty)
Process new number message from driver. This routine should be called from within the newNumber handl...
Definition: ClientAPIForAlignmentDatabase.cpp:335
INDI
Namespace to encapsulate INDI client, drivers, and mediator classes.
Definition: AlignmentSubsystemForClients.cpp:11
_IBLOBVectorProperty::name
char name[MAXINDINAME]
Definition: indiapi.h:474
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::Declination
double Declination
Declination in decimal degrees.
Definition: Common.h:187
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::EditSyncPoint
bool EditSyncPoint(unsigned int Offset, const AlignmentDatabaseEntry &CurrentValues)
Edit a sync point in the database.
Definition: ClientAPIForAlignmentDatabase.cpp:159
INDI::BaseClient::startBlob
void startBlob(const char *devName, const char *propName, const char *timestamp)
Send opening tag for BLOB command to server.
Definition: baseclient.cpp:1029
INDI::AlignmentSubsystem::SAVE_DATABASE
@ SAVE_DATABASE
Definition: Common.h:44
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::RightAscension
double RightAscension
Right ascension in decimal hours. N.B. libnova works in decimal degrees so conversion is always neede...
Definition: Common.h:184
IUFindOnSwitchIndex
int IUFindOnSwitchIndex(const ISwitchVectorProperty *sp)
Returns the index of first ON switch it finds in the vector switch property.
Definition: indicom.c:1424
_ISwitchVectorProperty::sp
ISwitch * sp
Definition: indiapi.h:384
INDI::AlignmentSubsystem::AlignmentDatabaseEntry::ObservationJulianDate
double ObservationJulianDate
Definition: Common.h:180
INDI::AlignmentSubsystem::ClientAPIForAlignmentDatabase::AppendSyncPoint
bool AppendSyncPoint(const AlignmentDatabaseEntry &CurrentValues)
Append a sync point to the database.
Definition: ClientAPIForAlignmentDatabase.cpp:29
INDI::BaseDevice
Class to provide basic INDI device functionality.
Definition: basedevice.h:45
INDI::AlignmentSubsystem::TelescopeDirectionVector::x
double x
Definition: Common.h:76
INDI::Property::getSwitch
INDI::PropertyView< ISwitch > * getSwitch() const
Definition: indiproperty.cpp:411
IBLOB
One Blob (Binary Large Object) descriptor.
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365
_ISwitchVectorProperty::name
char name[MAXINDINAME]
Definition: indiapi.h:370
ISS_ON
@ ISS_ON
Definition: indiapi.h:151