networkanalyzer.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 networkanalyzerH
17 #define networkanalyzerH
18 //---------------------------------------------------------------------------
19 #include "primarydriverwiththread.h"
20 #include "xnodeconnector.h"
21 #include <complex>
22 
23 class XScalarEntry;
24 class QMainWindow;
25 class Ui_FrmNetworkAnalyzer;
27 
28 class XGraph;
29 class XWaveNGraph;
30 class XXYPlot;
31 
32 //! Base class for digital storage oscilloscope.
33 class DECLSPEC_SHARED XNetworkAnalyzer : public XPrimaryDriverWithThread {
34 public:
35  XNetworkAnalyzer(const char *name, bool runtime,
36  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
37  //! usually nothing to do.
38  virtual ~XNetworkAnalyzer() {}
39  //! Shows all forms belonging to driver.
40  virtual void showForms();
41 
42  struct Payload : public XPrimaryDriver::Payload {
43  double startFreq() const {return m_startFreq;} //! [MHz]
44  double freqInterval() const {return m_freqInterval;} //! [MHz]
45  unsigned int length() const {return m_trace.size();}
46  const std::complex<double> *trace() const {return &m_trace.at(0);}
47 
48  std::vector<std::complex<double> > &trace_() {return m_trace;}
49  double m_startFreq;
50  double m_freqInterval;
51  private:
52  friend class XNetworkAnalyzer;
53  std::vector<std::complex<double> > m_trace;
54  std::deque<std::pair<double, double> > m_markers;
55  };
56 protected:
57  //! This function will be called when raw data are written.
58  //! Implement this function to convert the raw data to the record (Payload).
59  //! \sa analyze()
60  virtual void analyzeRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
61  //! This function is called after committing XPrimaryDriver::analyzeRaw() or XSecondaryDriver::analyze().
62  //! This might be called even if the record is invalid (time() == false).
63  virtual void visualize(const Snapshot &shot);
64 
65  //! driver specific part below
66  const shared_ptr<XScalarEntry> &marker1X() const {return m_marker1X;}
67  const shared_ptr<XScalarEntry> &marker1Y() const {return m_marker1Y;}
68  const shared_ptr<XScalarEntry> &marker2X() const {return m_marker2X;}
69  const shared_ptr<XScalarEntry> &marker2Y() const {return m_marker2Y;}
70  const shared_ptr<XDoubleNode> &startFreq() const {return m_startFreq;}
71  const shared_ptr<XDoubleNode> &stopFreq() const {return m_stopFreq;}
72  const shared_ptr<XComboNode> &points() const {return m_points;}
73  const shared_ptr<XUIntNode> &average() const {return m_average;}
74  const shared_ptr<XTouchableNode> &calOpen() const {return m_calOpen;}
75  const shared_ptr<XTouchableNode> &calShort() const {return m_calShort;}
76  const shared_ptr<XTouchableNode> &calTerm() const {return m_calTerm;}
77  const shared_ptr<XTouchableNode> &calThru() const {return m_calThru;}
78 protected:
79  virtual void onStartFreqChanged(const Snapshot &shot, XValueNodeBase *) = 0;
80  virtual void onStopFreqChanged(const Snapshot &shot, XValueNodeBase *) = 0;
81  virtual void onAverageChanged(const Snapshot &shot, XValueNodeBase *) = 0;
82  virtual void onPointsChanged(const Snapshot &shot, XValueNodeBase *) = 0;
83  virtual void onCalOpenTouched(const Snapshot &shot, XTouchableNode *) = 0;
84  virtual void onCalShortTouched(const Snapshot &shot, XTouchableNode *) = 0;
85  virtual void onCalTermTouched(const Snapshot &shot, XTouchableNode *) = 0;
86  virtual void onCalThruTouched(const Snapshot &shot, XTouchableNode *) = 0;
87  virtual void getMarkerPos(unsigned int num, double &x, double &y) = 0;
88  virtual void oneSweep() = 0;
89  virtual void startContSweep() = 0;
90  virtual void acquireTrace(shared_ptr<RawData> &, unsigned int ch) = 0;
91  //! Converts raw to dispaly-able
92  virtual void convertRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&) = 0;
93 private:
94  const shared_ptr<XWaveNGraph> &waveForm() const {return m_waveForm;}
95  const shared_ptr<XScalarEntry> m_marker1X;
96  const shared_ptr<XScalarEntry> m_marker1Y;
97  const shared_ptr<XScalarEntry> m_marker2X;
98  const shared_ptr<XScalarEntry> m_marker2Y;
99  const shared_ptr<XDoubleNode> m_startFreq;
100  const shared_ptr<XDoubleNode> m_stopFreq;
101  const shared_ptr<XComboNode> m_points;
102  const shared_ptr<XUIntNode> m_average;
103  const shared_ptr<XTouchableNode> m_calOpen, m_calShort, m_calTerm, m_calThru;
104 
105  const qshared_ptr<FrmNetworkAnalyzer> m_form;
106  const shared_ptr<XWaveNGraph> m_waveForm;
107 
108  shared_ptr<XListener> m_lsnOnStartFreqChanged;
109  shared_ptr<XListener> m_lsnOnStopFreqChanged;
110  shared_ptr<XListener> m_lsnOnPointsChanged;
111  shared_ptr<XListener> m_lsnOnAverageChanged;
112  shared_ptr<XListener> m_lsnCalOpen, m_lsnCalShort, m_lsnCalTerm, m_lsnCalThru;
113 
114  std::deque<xqcon_ptr> m_conUIs;
115 
116  shared_ptr<XGraph> m_graph;
117  shared_ptr<XXYPlot> m_markerPlot;
118 
119  void *execute(const atomic<bool> &);
120 };
121 
122 //---------------------------------------------------------------------------
123 
124 #endif

Generated for KAME4 by  doxygen 1.8.3