flowcontroller.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 flowcontrollerH
15 #define flowcontrollerH
16 //---------------------------------------------------------------------------
17 #include "primarydriverwiththread.h"
18 #include "xnodeconnector.h"
19 
20 class XScalarEntry;
21 class QMainWindow;
22 class Ui_FrmFlowController;
24 
25 //! Base class for mass flow monitors/controllers.
26 class DECLSPEC_SHARED XFlowControllerDriver : public XPrimaryDriverWithThread {
27 public:
28  XFlowControllerDriver(const char *name, bool runtime,
29  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
30  //! usually nothing to do
32  //! Shows all forms belonging to driver
33  virtual void showForms();
34 protected:
35  //! This function will be called when raw data are written.
36  //! Implement this function to convert the raw data to the record (Payload).
37  //! \sa analyze()
38  virtual void analyzeRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
39  //! This function is called after committing XPrimaryDriver::analyzeRaw() or XSecondaryDriver::analyze().
40  //! This might be called even if the record is invalid (time() == false).
41  virtual void visualize(const Snapshot &shot);
42 
43 public:
44  //! driver specific part below
45  const shared_ptr<XScalarEntry> &flow() const {return m_flow;} //!< [Given Unit]
46 
47  const shared_ptr<XDoubleNode> &target() const {return m_target;} //!< [Given Unit]
48  const shared_ptr<XDoubleNode> &valve() const {return m_valve;} //!< [V]
49  const shared_ptr<XDoubleNode> &rampTime() const {return m_rampTime;} //!< [ms]
50  const shared_ptr<XTouchableNode> &openValve() const {return m_openValve;}
51  const shared_ptr<XTouchableNode> &closeValve() const {return m_closeValve;}
52  const shared_ptr<XBoolNode> &warning() const {return m_warning;}
53  const shared_ptr<XBoolNode> &alarm() const {return m_alarm;}
54  const shared_ptr<XBoolNode> &control() const {return m_control;}
55 
56  struct DECLSPEC_SHARED Payload : public XPrimaryDriver::Payload {
57  double fullScale() const {return m_fullScale;}
58  XString m_unit;
59  double m_fullScale;
60  };
61 protected:
62  virtual bool isController() = 0; //! distinguishes monitors and controllers.
63  virtual bool isUnitInSLM() = 0; //! false for SCCM.
64  virtual double getFullScale() = 0;
65 
66  virtual void getStatus(double &flow_in_slm, double &valve_v, bool &alarm, bool &warning) = 0;
67  virtual void setValveState(bool open) = 0;
68  virtual void changeControl(bool ctrl) = 0;
69  virtual void changeSetPoint(double target) = 0;
70  virtual void setRampTime(double time) = 0;
71 private:
72  const shared_ptr<XScalarEntry> m_flow;
73 
74  const shared_ptr<XDoubleNode> m_target;
75  const shared_ptr<XDoubleNode> m_valve;
76  const shared_ptr<XDoubleNode> m_rampTime;
77  const shared_ptr<XTouchableNode> m_openValve;
78  const shared_ptr<XTouchableNode> m_closeValve;
79  const shared_ptr<XBoolNode> m_warning;
80  const shared_ptr<XBoolNode> m_alarm;
81  const shared_ptr<XBoolNode> m_control;
82 
83  shared_ptr<XListener> m_lsnTarget, m_lsnOpenValve, m_lsnCloseValve, m_lsnControl, m_lsnRampTime;
84  xqcon_ptr m_conFlow, m_conAlarm, m_conWarning, m_conTarget,
85  m_conRampTime, m_conValve, m_conControl, m_conOpenValve, m_conCloseValve;
86 
87  const qshared_ptr<FrmFlowController> m_form;
88 
89  void onTargetChanged(const Snapshot &shot, XValueNodeBase *);
90  void onRampTimeChanged(const Snapshot &shot, XValueNodeBase *);
91  void onControlChanged(const Snapshot &shot, XValueNodeBase *);
92  void onOpenValveTouched(const Snapshot &shot, XTouchableNode *);
93  void onCloseValveTouched(const Snapshot &shot, XTouchableNode *);
94 
95  void *execute(const atomic<bool> &);
96 
97 };
98 
99 
100 #endif

Generated for KAME4 by  doxygen 1.8.3