levelmeter.h
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #ifndef levelmeterH
15 #define levelmeterH
16 //---------------------------------------------------------------------------
17 #include "primarydriverwiththread.h"
18 #include "xnodeconnector.h"
19 
20 class XScalarEntry;
21 
22 class DECLSPEC_SHARED XLevelMeter : public XPrimaryDriverWithThread {
23 public:
24  XLevelMeter(const char *name, bool runtime,
25  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
26  //! usually nothing to do
27  virtual ~XLevelMeter() {}
28  //! Shows all forms belonging to driver
29  virtual void showForms();
30 
31  struct Payload : public XPrimaryDriver::Payload {
32  unsigned int channelNum() const {return m_levels.size();}
33  double level(unsigned int ch) const {return m_levels[ch];}
34  private:
35  friend class XLevelMeter;
36  std::vector<double> m_levels;
37  };
38 protected:
39  //! This function will be called when raw data are written.
40  //! Implement this function to convert the raw data to the record (Payload).
41  //! \sa analyze()
42  virtual void analyzeRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
43  //! This function is called after committing XPrimaryDriver::analyzeRaw() or XSecondaryDriver::analyze().
44  //! This might be called even if the record is invalid (time() == false).
45  virtual void visualize(const Snapshot &shot);
46 
47  //! driver specific part below
48 protected:
49  //! register channel names in your constructor
50  //! \param channel_names array of pointers to channel name. ends with null pointer.
51  void createChannels(Transaction &tr_meas, const shared_ptr<XMeasure> &meas,
52  const char **channel_names);
53 
54  virtual double getLevel(unsigned int ch) = 0;
55 private:
56  std::deque<shared_ptr<XScalarEntry> > m_entries;
57 
58  void *execute(const atomic<bool> &);
59 };
60 
61 #endif

Generated for KAME4 by  doxygen 1.8.3