1 /******************************************************************************* 2 Copyright(c) 2019 Christian Liska. All rights reserved. 3 4 INDI Astromechanic Light Pollution Meter Driver 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License as published by the Free 8 Software Foundation; either version 2 of the License, or (at your option) 9 any later version. 10 11 This program is distributed in the hope that it will be useful, but WITHOUT 12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 more details. 15 16 You should have received a copy of the GNU Library General Public License 17 along with this library; see the file COPYING.LIB. If not, write to 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 21 The full GNU General Public License is included in this distribution in the 22 file called LICENSE. 23 *******************************************************************************/ 24 25 #pragma once 26 27 #include "defaultdevice.h" 28 29 class LPM : public INDI::DefaultDevice 30 { 31 public: 32 LPM(); 33 virtual ~LPM(); 34 35 virtual bool initProperties() override; 36 virtual bool updateProperties() override; 37 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; 38 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override; 39 40 /** 41 * @struct LpmConnection 42 * @brief Holds the connection mode of the device. 43 */ 44 enum 45 { 46 CONNECTION_NONE = 1 << 0, 47 CONNECTION_SERIAL = 1 << 1 48 } LpmConnection; 49 50 enum 51 { 52 SAVE_READINGS, 53 DISCARD_READINGS 54 }; 55 56 protected: 57 const char *getDefaultName() override; 58 void TimerHit() override; 59 60 private: 61 bool getReadings(); 62 bool getDeviceInfo(); 63 void openFilePtr(); 64 65 // Readings 66 INumberVectorProperty AverageReadingNP; 67 INumber AverageReadingN[5] {}; 68 69 // Record File Info 70 IText RecordFileT[2] {}; 71 ITextVectorProperty RecordFileTP; 72 73 ISwitch ResetB[1]; 74 ISwitchVectorProperty ResetBP; 75 76 ISwitch SaveB[2] {}; 77 ISwitchVectorProperty SaveBP; 78 79 // Device Information 80 INumberVectorProperty UnitInfoNP; 81 INumber UnitInfoN[1]; 82 83 Connection::Serial *serialConnection { nullptr }; 84 85 int PortFD { -1 }; 86 long count = 0; 87 float sumSQ = 0; 88 char filename[2048]; 89 90 uint8_t lpmConnection { CONNECTION_SERIAL }; 91 92 FILE * fp = nullptr; 93 }; 94