dcsource.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 dcsourceH
15 #define dcsourceH
16 
17 #include "primarydriver.h"
18 #include "xnodeconnector.h"
19 #include "analyzer.h"
20 
21 class QMainWindow;
22 class Ui_FrmDCSource;
24 
25 class DECLSPEC_SHARED XDCSource: public XPrimaryDriver {
26 public:
27  XDCSource(const char *name, bool runtime,
28  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
29  //! usually nothing to do
30  virtual ~XDCSource() {
31  }
32  //! show all forms belonging to driver
33  virtual void showForms();
34 
35  //! driver specific part below
36  virtual void changeFunction(int ch, int x) = 0;
37  virtual void changeOutput(int ch, bool x) = 0;
38  virtual void changeValue(int ch, double x, bool autorange) = 0;
39  virtual void changeRange(int ch, int x) = 0;
40  virtual void queryStatus(Transaction &tr, int ch) = 0;
41  virtual double max(int ch, bool autorange) const = 0;
42 
43  const shared_ptr<XComboNode> &function() const {
44  return m_function;
45  }
46  const shared_ptr<XBoolNode> &output() const {
47  return m_output;
48  }
49  const shared_ptr<XDoubleNode> &value() const {
50  return m_value;
51  }
52  const shared_ptr<XComboNode> &channel() const {
53  return m_channel;
54  }
55  const shared_ptr<XComboNode> &range() const {
56  return m_range;
57  }
58 protected:
59  //! Starts up your threads, connects GUI, and activates signals.
60  virtual void start();
61  //! Shuts down your threads, unconnects GUI, and deactivates signals
62  //! This function may be called even if driver has already stopped.
63  virtual void stop();
64 
65  //! This function will be called when raw data are written.
66  //! Implement this function to convert the raw data to the record (Payload).
67  //! \sa analyze()
68  virtual void analyzeRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
69  //! This function is called after committing XPrimaryDriver::analyzeRaw() or XSecondaryDriver::analyze().
70  //! This might be called even if the record is invalid (time() == false).
71  virtual void visualize(const Snapshot &shot);
72 
73  void updateStatus() {
74  Snapshot shot( *channel());
75  onChannelChanged(shot, channel().get());
76  }
77 
78 private:
79  const shared_ptr<XScalarEntry> m_entryValue;
80  xqcon_ptr m_conFunction, m_conOutput, m_conValue, m_conChannel, m_conRange;
81  const shared_ptr<XComboNode> m_function;
82  const shared_ptr<XBoolNode> m_output;
83  const shared_ptr<XDoubleNode> m_value;
84  const shared_ptr<XComboNode> m_channel;
85  const shared_ptr<XComboNode> m_range;
86  shared_ptr<XListener> m_lsnFunction, m_lsnOutput, m_lsnValue, m_lsnChannel,
87  m_lsnRange;
88 
89  virtual void onFunctionChanged(const Snapshot &shot, XValueNodeBase *);
90  virtual void onOutputChanged(const Snapshot &shot, XValueNodeBase *);
91  virtual void onValueChanged(const Snapshot &shot, XValueNodeBase *);
92  virtual void onChannelChanged(const Snapshot &shot, XValueNodeBase *);
93  virtual void onRangeChanged(const Snapshot &shot, XValueNodeBase *);
94 
95  const qshared_ptr<FrmDCSource> m_form;
96 
97  void finish(const XTime &time_awared);
98 };
99 
100 #endif
101 

Generated for KAME4 by  doxygen 1.8.3