16 #include "interface.h"
19 XCounter::XCounter(
const char *name,
bool runtime,
20 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
26 for(
unsigned int ch = 0; ch < m_entries.size(); ch++) {
27 m_entries[ch]->value(tr, reader.pop<
double>());
35 const char **channel_names) {
36 shared_ptr<XScalarEntryList> entries(meas->scalarEntries());
38 for(
int i = 0; channel_names[i]; i++) {
39 shared_ptr<XScalarEntry> entry(create<XScalarEntry>(
40 channel_names[i],
false,
41 dynamic_pointer_cast<XDriver>(shared_from_this()),
"%.8g"));
42 m_entries.push_back(entry);
43 entries->insert(tr_meas, entry);
51 auto writer = std::make_shared<RawData>();
54 unsigned int num = m_entries.size();
55 for(
unsigned int ch = 0; ch < num; ch++)
56 writer->push((
double)getLevel(ch));
68 #include "charinterface.h"
71 REGISTER_TYPE(
XDriverList, MutohCounterNPS,
"Mutoh Digital Counter NPS");
75 XMutohCounterNPS::XMutohCounterNPS(
const char *name,
bool runtime,
76 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
78 const char *channels_create[] = {
"Ch0", 0L};
81 interface()->setSerialParity(XCharInterface::PARITY_EVEN);
82 interface()->setSerialBaudRate(19200);
83 interface()->setSerial7Bits(
true);
84 interface()->setEOS(
"\x03");
88 XMutohCounterNPS::getLevel(
unsigned int ch) {
90 interface()->query(STX
"00F102");
92 if(interface()->scanf(STX
"00F202%d", &fun2) != 1)
95 interface()->query(STX
"00F105");
97 if(interface()->scanf(STX
"00F205%d", &fun5) != 1)
100 interface()->query(STX
"00P1");
102 if(interface()->scanf(STX
"00P2%d", &x) != 1)
108 z = x / pow(10.0, fun2 % 10);
113 z = (x / 100) + ((x > 0) ? 1 : -1) * (abs(x) % 100) / 60.0;
119 z = (x / 10000) + ((x > 0) ? 1 : -1) * ((abs(x) % 10000) / 100 + (abs(x) % 100) / 60.0) / 60.0;