pulseanalyzer.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 PULSEANALYZER_H_
15 #define PULSEANALYZER_H_
16 
17 #include "networkanalyzer.h"
18 #include "pulserdriver.h"
19 #include "dso.h"
20 #include "signalgenerator.h"
21 #include "secondarydriverinterface.h"
22 
23 //! Built-in network analyzer using a directional coupler in coherent pulse NMR system.
24 class XNMRBuiltInNetworkAnalyzer : public XSecondaryDriverInterface<XNetworkAnalyzer> {
25 public:
26  XNMRBuiltInNetworkAnalyzer(const char *name, bool runtime,
27  Transaction &tr_meas, const shared_ptr<XMeasure> &meas);
28  virtual ~XNMRBuiltInNetworkAnalyzer() {}
29 
30  struct Payload : public XSecondaryDriverInterface<XNetworkAnalyzer>::Payload {
31  private:
32  friend class XNMRBuiltInNetworkAnalyzer;
33  std::vector<std::complex<double> > m_ftsum, m_raw_open, m_raw_short, m_raw_term, m_raw_thru;
34  std::vector<int> m_ftsum_weight;
35  int m_calMode;
36  std::pair<double, double> m_marker_min, m_marker_max;
37  double m_sweepStep;
38  double m_sweepStart;
39  double m_sweepStop;
40  int m_sweepPoints;
41  bool m_sweeping;
42  double m_lastCenterFreq;
43  };
45 
46  virtual void onStartFreqChanged(const Snapshot &shot, XValueNodeBase *);
47  virtual void onStopFreqChanged(const Snapshot &shot, XValueNodeBase *);
48  virtual void onAverageChanged(const Snapshot &shot, XValueNodeBase *);
49  virtual void onPointsChanged(const Snapshot &shot, XValueNodeBase *);
50  virtual void onCalOpenTouched(const Snapshot &shot, XTouchableNode *);
51  virtual void onCalShortTouched(const Snapshot &shot, XTouchableNode *);
52  virtual void onCalTermTouched(const Snapshot &shot, XTouchableNode *);
53  virtual void onCalThruTouched(const Snapshot &shot, XTouchableNode *);
54  virtual void getMarkerPos(unsigned int num, double &x, double &y);
55  virtual void oneSweep();
56  virtual void startContSweep();
57  virtual void acquireTrace(shared_ptr<RawData> &, unsigned int ch);
58  //! Converts raw to dispaly-able
59  virtual void convertRaw(RawDataReader &reader, Transaction &tr) throw (XRecordError&);
60 
61  //! Be called just after opening interface. Call start() inside this routine appropriately.
62  virtual void open() throw (XKameError &);
63  //! Be called for closing interfaces.
64  //! This function should not cause an exception.
65  virtual void closeInterface() {}
66 
67 protected:
68  //! This function is called when a connected driver emit a signal
69  virtual void analyze(Transaction &tr, const Snapshot &shot_emitter, const Snapshot &shot_others,
70  XDriver *emitter) throw (XRecordError&);
71  //! This function is called inside analyze() or analyzeRaw()
72  //! this must be reentrant unlike analyze()
73  virtual void visualize(const Snapshot &shot);
74  //! Checks if the connected drivers have valid time stamps.
75  //! \return true if dependency is resolved.
76  //! This function must be reentrant unlike analyze().
77  virtual bool checkDependency(const Snapshot &shot_this,
78  const Snapshot &shot_emitter, const Snapshot &shot_others,
79  XDriver *emitter) const;
80 
81 private:
82  const shared_ptr<XItemNode<XDriverList, XPulser> > m_pulser;
83  const shared_ptr<XItemNode<XDriverList, XDSO> > m_dso;
84  const shared_ptr<XItemNode<XDriverList, XSG> > m_sg;
85 
86  //for FFT.
87  shared_ptr<FFT> m_fft;
88  std::vector<std::complex<double> > m_fftin, m_fftout;
89 
90  void clear();
91  void restart(Transaction &tr, int calmode, bool clear = false);
92  bool restart(int calmode, bool clear = false);
93  enum {CAL_NONE = 0, CAL_OPEN = 1, CAL_SHORT = 2, CAL_TERM = 3, CAL_THRU = 4};
94 
95  void writeTraceAndMarkers(Transaction &tr);
96 };
97 
98 #endif /* PULSEANALYZER_H_ */

Generated for KAME4 by  doxygen 1.8.3