analyzer.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 //---------------------------------------------------------------------------
15 
16 #ifndef analyzerH
17 #define analyzerH
18 
19 #include "xnode.h"
20 #include "xitemnode.h"
21 #include "xlistnode.h"
22 #include "support.h"
23 #include "xnodeconnector.h"
24 
25 //Retain 'small' analyzed data capable to be handled by graphs, charts,...
26 class XJournal;
27 class XDriver;
28 
29 class DECLSPEC_KAME XScalarEntry : public XNode {
30 public:
31  XScalarEntry(const char *name, bool runtime, const shared_ptr<XDriver> &driver,
32  const char *format = 0L);
33  virtual ~XScalarEntry() = default;
34 
35  //A condition for determining a trigger of storing.
36  //0: never
37  //negative: allways
38  //positive: when the difference from old value exceeds 'Delta'.
39  const shared_ptr<XDoubleNode> &delta() const {return m_delta;}
40  //if false, one line should not include this.
41  const shared_ptr<XBoolNode> &store() const {return m_store;}
42 
43  const shared_ptr<XDoubleNode> &value() const {return m_value;}
44  const shared_ptr<XDoubleNode> &storedValue() const {return m_storedValue;}
45 
46  void storeValue(Transaction &tr);
47 
48  shared_ptr<XDriver> driver() const {return m_driver.lock();}
49 
50  virtual XString getLabel() const;
51 
52  void value(Transaction &tr, double val);
53 
54  struct Payload : public XNode::Payload {
55  Payload() : m_bTriggered(false) {}
56  bool isTriggered() const {return m_bTriggered;}
57  private:
58  friend class XScalarEntry;
59  bool m_bTriggered;
60  };
61 protected:
62 private:
63  const weak_ptr<XDriver> m_driver;
64 
65  const shared_ptr<XDoubleNode> m_delta;
66  const shared_ptr<XBoolNode> m_store;
67 
68  const shared_ptr<XDoubleNode> m_value;
69  const shared_ptr<XDoubleNode> m_storedValue;
70 };
71 
72 class XDriverList;
73 
74 class DECLSPEC_KAME XScalarEntryList : public XAliasListNode<XScalarEntry> {
75 public:
76  XScalarEntryList(const char *name, bool runtime) : XAliasListNode<XScalarEntry>(name, runtime) {}
77 };
78 
79 class Ui_FrmGraph;
80 class QMainWindow;
82 class XGraph;
83 class XXYPlot;
84 
85 class XValChart : public XNode {
86 public:
87  XValChart(const char *name, bool runtime, const shared_ptr<XScalarEntry> &entry);
88  virtual ~XValChart() = default;
89  void showChart();
90  const shared_ptr<XScalarEntry> &entry() const {return m_entry;}
91 private:
92  shared_ptr<XListener> m_lsnOnRecord;
93  //callback from Driver
94  void onRecord(const Snapshot &shot, XDriver *driver);
95 
96  const shared_ptr<XScalarEntry> m_entry;
97  shared_ptr<XGraph> m_graph;
98  qshared_ptr<FrmGraph> m_graphForm;
99  shared_ptr<XXYPlot> m_chart;
100 };
101 
102 class XChartList : public XAliasListNode<XValChart> {
103 public:
104  XChartList(const char *name, bool runtime, const shared_ptr<XScalarEntryList> &entries);
105  virtual ~XChartList() = default;
106 private:
107  shared_ptr<XListener> m_lsnOnCatchEntry;
108  shared_ptr<XListener> m_lsnOnReleaseEntry;
109  void onCatchEntry(const Snapshot &shot, const XListNodeBase::Payload::CatchEvent &e);
110  void onReleaseEntry(const Snapshot &shot, const XListNodeBase::Payload::ReleaseEvent &e);
111 
112  const shared_ptr<XScalarEntryList> m_entries;
113 };
114 
115 class XValGraph : public XNode {
116 public:
117  XValGraph(const char *name, bool runtime,
118  Transaction &tr_entries, const shared_ptr<XScalarEntryList> &entries);
119  virtual ~XValGraph() = default;
120 
121  void showGraph();
122  void clearAllPoints();
123 
125 
126  const shared_ptr<tAxis> &axisX() const {return m_axisX;}
127  const shared_ptr<tAxis> &axisY1() const {return m_axisY1;}
128  const shared_ptr<tAxis> &axisZ() const {return m_axisZ;}
129 
130  struct Payload : public XNode::Payload {
131  private:
132  friend class XValGraph;
133  shared_ptr<XGraph> m_graph;
134  shared_ptr<XXYPlot> m_livePlot, m_storePlot;
135  };
136 protected:
137 private:
138  qshared_ptr<FrmGraph> m_graphForm;
139 
140  shared_ptr<tAxis> m_axisX, m_axisY1, m_axisZ;
141  shared_ptr<XListener> m_lsnAxisChanged;
142  void onAxisChanged(const Snapshot &shot, XValueNodeBase *node);
143 
144  shared_ptr<XListener> m_lsnLiveChanged;
145  shared_ptr<XListener> m_lsnStoreChanged;
146  void onLiveChanged(const Snapshot &shot, XValueNodeBase *node);
147  void onStoreChanged(const Snapshot &shot, XValueNodeBase *node);
148 
149  weak_ptr<XScalarEntryList> m_entries;
150 };
151 
152 class XGraphList : public XCustomTypeListNode<XValGraph> {
153 public:
154  XGraphList(const char *name, bool runtime, const shared_ptr<XScalarEntryList> &entries);
155  virtual ~XGraphList() = default;
156 
157  virtual shared_ptr<XNode> createByTypename(const XString &, const XString& name);
158  const shared_ptr<XScalarEntryList> &entries() const {return m_entries;}
159 private:
160  const shared_ptr<XScalarEntryList> m_entries;
161 };
162 //---------------------------------------------------------------------------
163 #endif
164 

Generated for KAME4 by  doxygen 1.8.3