15 #include "ui_fourresform.h"
16 #include "interface.h"
19 REGISTER_TYPE(
XDriverList, FourRes,
"Resistance Measurement with Polarity Switching");
21 XFourRes::XFourRes(
const char *name,
bool runtime,
22 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas)
25 dynamic_pointer_cast<
XDriver>(shared_from_this()))),
27 "DMM", false, ref(tr_meas), meas->drivers(), true)),
29 "DCSource", false, ref(tr_meas), meas->drivers(), true)),
30 m_control(create<
XBoolNode>(
"Control", true)),
33 m_form->setWindowTitle(i18n(
"Resistance Measurement with Switching Polarity - ") +
getLabel() );
35 meas->scalarEntries()->insert(tr_meas, resistance());
40 tr[ *control()] =
false;
41 tr[ *
this].value_inverted = 0.0;
43 m_conControl = xqcon_create<XQToggleButtonConnector>(m_control, m_form->m_ckbControl);
44 m_conDMM = xqcon_create<XQComboBoxConnector>(m_dmm, m_form->m_cmbDMM, ref(tr_meas));
45 m_conDCSource = xqcon_create<XQComboBoxConnector>(m_dcsource, m_form->m_cmbDCSource, ref(tr_meas));
46 m_conRes = xqcon_create<XQLCDNumberConnector> (m_resistance->value(), m_form->m_lcdRes);
48 XFourRes::~XFourRes () {
59 shared_ptr<XDMM> dmm__ = shot_this[ *dmm()];
60 shared_ptr<XDCSource> dcsource__ = shot_this[ *dcsource()];
61 if( !dmm__ || !dcsource__)
return false;
62 if(emitter != dmm__.get())
return false;
68 XDriver *emitter)
throw (XRecordError&) {
70 shared_ptr<XDMM> dmm__ = shot_this[ *dmm()];
71 shared_ptr<XDCSource> dcsource__ = shot_this[ *dcsource()];
73 if(shot_emitter[ *dmm__].timeAwared() < shot_others[ *dcsource__].time())
74 throw XSkippedRecordError(__FILE__, __LINE__);
76 double curr = shot_others[ *dcsource__->value()];
77 double var = shot_emitter[ *dmm__].value();
80 tr[ *
this].value_inverted = var;
81 throw XSkippedRecordError(__FILE__, __LINE__);
84 if(shot_this[ *
this].value_inverted == 0.0)
85 throw XSkippedRecordError(__FILE__, __LINE__);
86 resistance()->value(tr, (var - shot_this[ *
this].value_inverted) / 2 / curr);
87 tr[ *
this].value_inverted = 0.0;
93 if(shot[ *control()]) {
94 shared_ptr<XDCSource> dcsource__ = shot[ *dcsource()];
96 double curr = tr[ *dcsource__->value()];
97 tr[ *dcsource__->value()] = -curr;