Instrument Neutral Distributed Interface INDI  2.0.2
lpm.h
Go to the documentation of this file.
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 
44  enum
45  {
46  CONNECTION_NONE = 1 << 0,
47  CONNECTION_SERIAL = 1 << 1
49 
50  enum
51  {
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 };
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: lpm.h:30
const char * getDefaultName() override
Definition: lpm.cpp:278
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: lpm.cpp:109
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: lpm.cpp:339
LPM()
Definition: lpm.cpp:42
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
Definition: lpm.cpp:133
@ DISCARD_READINGS
Definition: lpm.h:53
@ SAVE_READINGS
Definition: lpm.h:52
@ CONNECTION_NONE
Definition: lpm.h:46
@ CONNECTION_SERIAL
Definition: lpm.h:47
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: lpm.cpp:55
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: lpm.cpp:156
enum LPM::@6 LpmConnection
virtual ~LPM()
Definition: lpm.cpp:47
ISState
Switch state.
Definition: indiapi.h:150
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition: indiapi.h:319
Switch vector property descriptor.
Definition: indiapi.h:367
Text vector property descriptor.
Definition: indiapi.h:246