userfuncsynth.cpp
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 #include "userfuncsynth.h"
15 #include "charinterface.h"
16 #include "analyzer.h"
17 
18 REGISTER_TYPE(XDriverList, WAVEFACTORY, "NF WAVE-FACTORY pulse generator");
19 
20 XWAVEFACTORY::XWAVEFACTORY(const char *name, bool runtime,
21  Transaction &tr_meas, const shared_ptr<XMeasure> &meas) :
22  XCharDeviceDriver<XFuncSynth>(name, runtime, ref(tr_meas), meas) {
23 
24  iterate_commit([=](Transaction &tr){
25  tr[ *function()].add("SINUSOID");
26  tr[ *function()].add("TRIANGLE");
27  tr[ *function()].add("SQUARE");
28  tr[ *function()].add("PRAMP");
29  tr[ *function()].add("NRAMP");
30  tr[ *function()].add("USER");
31  tr[ *function()].add("VSQUARE");
32  tr[ *mode()].add("NORMAL");
33  tr[ *mode()].add("BURST");
34  tr[ *mode()].add("SWEEP");
35  tr[ *mode()].add("MODULATION");
36  tr[ *mode()].add("NOISE");
37  tr[ *mode()].add("DC");
38  });
39 }
40 /*
41  double
42  XWAVEFACTORY::Read(void)
43  {
44  string buf;
45  Query("?PHS", &buf);
46  double x = 0;
47  sscanf(buf.c_str(), "%*s %lf", &x);
48  return x;
49  }
50 */
51 void
52 XWAVEFACTORY::onOutputChanged(const Snapshot &shot, XValueNodeBase *) {
53  interface()->sendf("SIG %d", shot[ *output()] ? 1 : 0);
54 }
55 
56 void
57 XWAVEFACTORY::onTrigTouched(const Snapshot &shot, XTouchableNode *) {
58  interface()->send("TRG 1");
59 }
60 
61 void
62 XWAVEFACTORY::onModeChanged(const Snapshot &shot, XValueNodeBase *) {
63  interface()->sendf("OMO %d", (int)shot[ *mode()]);
64 }
65 
66 void
67 XWAVEFACTORY::onFunctionChanged(const Snapshot &shot, XValueNodeBase *) {
68  interface()->sendf("FNC %d", (int)shot[ *function()] + 1);
69 }
70 
71 void
72 XWAVEFACTORY::onFreqChanged(const Snapshot &shot, XValueNodeBase *) {
73  interface()->sendf("FRQ %e" , (double)shot[ *freq()]);
74 }
75 
76 void
77 XWAVEFACTORY::onAmpChanged(const Snapshot &shot, XValueNodeBase *) {
78  interface()->sendf("AMV %e" , (double)shot[ *amp()]);
79 }
80 
81 void
82 XWAVEFACTORY::onPhaseChanged(const Snapshot &shot, XValueNodeBase *) {
83  interface()->sendf("PHS %e" , (double)shot[ *phase()]);
84 }
85 
86 void
87 XWAVEFACTORY::onOffsetChanged(const Snapshot &shot, XValueNodeBase *) {
88  interface()->sendf("OFS %e" , (double)shot[ *offset()]);
89 }

Generated for KAME4 by  doxygen 1.8.3