1 /*! 2 * \file MapPropertiesToInMemoryDatabase.h 3 * 4 * \author Roger James 5 * \date 13th November 2013 6 * 7 */ 8 9 #pragma once 10 11 #include "InMemoryDatabase.h" 12 13 #include "inditelescope.h" 14 15 namespace INDI 16 { 17 namespace AlignmentSubsystem 18 { 19 /*! 20 * \class MapPropertiesToInMemoryDatabase 21 * \brief An entry in the sync point database is defined by the following INDI properties 22 * - ALIGNMENT_POINT_ENTRY_OBSERVATION_JULIAN_DATE\n 23 * The Julian date of the sync point observation (number) 24 * - ALIGNMENT_POINT_ENTRY_OBSERVATION_LOCAL_SIDEREAL_TIME\n 25 * The local sidereal time of the sync point observation (number) 26 * - ALIGNMENT_POINT_ENTRY_RA\n 27 * The right ascension of the sync point (number) 28 * - ALIGNMENT_POINT_ENTRY_DEC\n 29 * The declination of the sync point (number) 30 * - ALIGNMENT_POINT_ENTRY_VECTOR_X\n 31 * The x component of the telescope direction vector of the sync point (number) 32 * - ALIGNMENT_POINT_ENTRY_VECTOR_Y\n 33 * The y component of the telescope direction vector of the sync point (number) 34 * - ALIGNMENT_POINT_ENTRY_VECTOR_Z\n 35 * The z component of the telescope direction vector of the sync point (number) 36 * - ALIGNMENT_POINT_ENTRY_PRIVATE\n 37 * An optional binary blob for communication between the client and the math plugin 38 * . 39 * The database is accessed using the following properties 40 * - ALIGNMENT_POINTSET_SIZE\n 41 * The count of the number of sync points in the set (number) 42 * - ALIGNMENT_POINTSET_CURRENT_ENTRY\n 43 * A zero based number that sets/shows the current entry (number) 44 * Only valid if ALIGNMENT_POINTSET_SIZE is greater than zero 45 * - ALIGNMENT_POINTSET_ACTION\n 46 * Determines the action to take when the COMMIT property is written 47 * - APPEND\n 48 * Append a new entry to the set. 49 * - INSERT\n 50 * Insert a new entry at the pointer. 51 * - EDIT\n 52 * Overwrites the entry at the pointer. 53 * - DELETE\n 54 * Delete the entry at the pointer. 55 * - CLEAR\n 56 * Delete all entries. 57 * - READ\n 58 * Read the entry at the pointer. 59 * - READ INCREMENT\n 60 * Increment the pointer before reading the entry. 61 * - LOAD DATABASE\n 62 * Load the databse from local storage. 63 * - SAVE DATABASE\n 64 * Save the database to local storage. 65 * - ALIGNMENT_POINTSET_COMMIT\n 66 * When written take the action defined above. 67 * - COMMIT 68 * 69 */ 70 class MapPropertiesToInMemoryDatabase : public InMemoryDatabase 71 { 72 public: 73 /// \brief Virtual destructor ~MapPropertiesToInMemoryDatabase()74 virtual ~MapPropertiesToInMemoryDatabase() {} 75 76 // Public methods 77 78 /// \brief Initialize alignment database properties. It is recommended to call this function within initProperties() 79 /// of your primary device 80 /// \param[in] pTelescope Pointer to the child INDI::Telecope class 81 void InitProperties(Telescope *pTelescope); 82 83 /// \brief Call this function from within the ISNewBLOB processing path. The function will 84 /// handle any alignment database related properties. 85 /// \param[in] pTelescope Pointer to the child INDI::Telecope class 86 /// \param[in] name vector property name 87 /// \param[in] sizes 88 /// \param[in] blobsizes 89 /// \param[in] blobs 90 /// \param[in] formats 91 /// \param[in] names 92 /// \param[in] n 93 void ProcessBlobProperties(Telescope *pTelescope, const char *name, int sizes[], int blobsizes[], char *blobs[], 94 char *formats[], char *names[], int n); 95 96 /// \brief Call this function from within the ISNewNumber processing path. The function will 97 /// handle any alignment database related properties. 98 /// \param[in] pTelescope Pointer to the child INDI::Telecope class 99 /// \param[in] name vector property name 100 /// \param[in] values value as passed by the client 101 /// \param[in] names names as passed by the client 102 /// \param[in] n number of values and names pair to process. 103 void ProcessNumberProperties(Telescope *, const char *name, double values[], char *names[], int n); 104 105 /// \brief Call this function from within the ISNewSwitch processing path. The function will 106 /// handle any alignment database related properties. 107 /// \param[in] pTelescope Pointer to the child INDI::Telecope class 108 /// \param[in] name vector property name 109 /// \param[in] states states as passed by the client 110 /// \param[in] names names as passed by the client 111 /// \param[in] n number of values and names pair to process. 112 void ProcessSwitchProperties(Telescope *pTelescope, const char *name, ISState *states, char *names[], int n); 113 114 /// \brief Call this function from within the updateLocation processing path 115 /// \param[in] latitude Site latitude in degrees. 116 /// \param[in] longitude Site latitude in degrees increasing eastward from Greenwich (0 to 360). 117 /// \param[in] elevation Site elevation in meters. 118 void UpdateLocation(double latitude, double longitude, double elevation); 119 120 /// \brief Call this function when the number of entries in the database changes 121 void UpdateSize(); 122 123 private: 124 INumber AlignmentPointSetEntry[6]; 125 INumberVectorProperty AlignmentPointSetEntryV; 126 IBLOB AlignmentPointSetPrivateBinaryData; 127 IBLOBVectorProperty AlignmentPointSetPrivateBinaryDataV; 128 INumber AlignmentPointSetSize; 129 INumberVectorProperty AlignmentPointSetSizeV; 130 INumber AlignmentPointSetPointer; 131 INumberVectorProperty AlignmentPointSetPointerV; 132 ISwitch AlignmentPointSetAction[9]; 133 ISwitchVectorProperty AlignmentPointSetActionV; 134 ISwitch AlignmentPointSetCommit; 135 ISwitchVectorProperty AlignmentPointSetCommitV; 136 }; 137 138 } // namespace AlignmentSubsystem 139 } // namespace INDI 140