14 #include "ui_dcsourceform.h"
16 #include "xnodeconnector.h"
18 #include <QPushButton>
21 XDCSource::XDCSource(
const char *name,
bool runtime,
22 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
25 dynamic_pointer_cast<
XDriver>(shared_from_this()),
"%.8f")),
26 m_function(create<
XComboNode>(
"Function", false)),
27 m_output(create<
XBoolNode>(
"Output", true)),
29 m_channel(create<
XComboNode>(
"Channel", false, true)),
30 m_range(create<
XComboNode>(
"Range", false, true)),
32 m_form->statusBar()->hide();
33 m_form->setWindowTitle(i18n(
"DC Source - ") +
getLabel() );
35 meas->scalarEntries()->
insert(tr_meas, m_entryValue);
37 m_output->setUIEnabled(
false);
38 m_function->setUIEnabled(
false);
39 m_value->setUIEnabled(
false);
40 m_channel->setUIEnabled(
false);
41 m_range->setUIEnabled(
false);
43 m_conFunction = xqcon_create<XQComboBoxConnector>(m_function, m_form->m_cmbFunction,
Snapshot( *m_function));
44 m_conOutput = xqcon_create<XQToggleButtonConnector>(m_output, m_form->m_ckbOutput);
45 m_conValue = xqcon_create<XQLineEditConnector>(m_value, m_form->m_edValue);
46 m_conChannel = xqcon_create<XQComboBoxConnector>(m_channel, m_form->m_cmbChannel,
Snapshot( *m_channel));
47 m_conRange = xqcon_create<XQComboBoxConnector>(m_range, m_form->m_cmbRange,
Snapshot( *m_range));
59 m_output->setUIEnabled(
true);
60 m_function->setUIEnabled(
true);
61 m_value->setUIEnabled(
true);
62 m_channel->setUIEnabled(
true);
63 m_range->setUIEnabled(
true);
66 m_lsnOutput = tr[ *output()].onValueChanged().connectWeakly(
67 shared_from_this(), &XDCSource::onOutputChanged);
68 m_lsnFunction = tr[ *
function()].onValueChanged().connectWeakly(
69 shared_from_this(), &XDCSource::onFunctionChanged);
70 m_lsnValue = tr[ *value()].onValueChanged().connectWeakly(
71 shared_from_this(), &XDCSource::onValueChanged);
72 m_lsnChannel = tr[ *channel()].onValueChanged().connectWeakly(
73 shared_from_this(), &XDCSource::onChannelChanged);
74 m_lsnRange = tr[ *range()].onValueChanged().connectWeakly(
75 shared_from_this(), &XDCSource::onRangeChanged);
83 m_lsnFunction.reset();
86 m_output->setUIEnabled(
false);
87 m_function->setUIEnabled(
false);
88 m_value->setUIEnabled(
false);
89 m_channel->setUIEnabled(
false);
90 m_range->setUIEnabled(
false);
97 m_entryValue->value(tr, tr[ *value()]);
104 XDCSource::finish(
const XTime &time_awared) {
105 auto writer = std::make_shared<RawData>();
113 XTime time_awared(XTime::now());
114 int ch = ***channel();
116 changeOutput(ch, shot[ *output()]);
119 e.print(
getLabel() + i18n(
": Error while changing output, "));
126 XTime time_awared(XTime::now());
127 int ch = ***channel();
132 e.print(
getLabel() + i18n(
": Error while changing function, "));
139 XTime time_awared(XTime::now());
140 int ch = ***channel();
142 changeValue(ch, shot[ *value()],
true);
145 e.print(
getLabel() + i18n(
": Error while changing value, "));
152 XTime time_awared(XTime::now());
153 int ch = ***channel();
155 changeRange(ch, shot[ *range()]);
158 e.print(
getLabel() + i18n(
": Error while changing value, "));
167 int ch = tr[ *channel()];
169 tr.unmark(m_lsnOutput);
170 tr.unmark(m_lsnFunction);
171 tr.unmark(m_lsnRange);
172 tr.unmark(m_lsnValue);