testdriver.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 //---------------------------------------------------------------------------
15 #include "testdriver.h"
16 #include "analyzer.h"
17 #include "xnodeconnector.h"
18 #include <QStatusBar>
19 #include "rand.h"
20 
21 REGISTER_TYPE(XDriverList, TestDriver, "Test driver: random number generation");
22 
23 XTestDriver::XTestDriver(const char *name, bool runtime,
24  Transaction &tr_meas, const shared_ptr<XMeasure> &meas) :
25  XDummyDriver<XPrimaryDriverWithThread>(name, runtime, ref(tr_meas), meas),
26  m_entryX(create<XScalarEntry>("X", false,
27  static_pointer_cast<XDriver>(shared_from_this()), "%.3g")),
28  m_entryY(create<XScalarEntry>("Y", false,
29  static_pointer_cast<XDriver>(shared_from_this()), "%+.4f[K]")) {
30 
31  meas->scalarEntries()->insert(tr_meas, m_entryX);
32  meas->scalarEntries()->insert(tr_meas, m_entryY);
33 }
34 
35 void
37 // impliment form->show() here
38 }
39 void
41  // Since raw buffer is FIFO, use the same sequence of push()es for pop()s
42  tr[ *this].m_x = reader.pop<double>();
43  tr[ *this].m_y = reader.pop<double>();
44  m_entryX->value(tr, tr[ *this].m_x);
45  m_entryY->value(tr, tr[ *this].m_y);
46 }
47 void
49 }
50 
51 void *
52 XTestDriver::execute(const atomic<bool> &terminated) {
53  while( !terminated) {
54  msecsleep(10);
55  double x = randMT19937() - 0.2;
56  double y = randMT19937()- 0.2;
57 
58  auto writer = std::make_shared<RawData>();
59  writer->push(x);
60  writer->push(y);
61  finishWritingRaw(writer, XTime::now(), XTime::now());
62  }
63  return NULL;
64 }
65 

Generated for KAME4 by  doxygen 1.8.3