16 #include "ui_qdppmsform.h"
18 XQDPPMS::XQDPPMS(
const char *name,
bool runtime,
19 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
22 dynamic_pointer_cast<
XDriver>(shared_from_this()),
"%.3f")),
24 dynamic_pointer_cast<
XDriver>(shared_from_this()),
"%.3f")),
26 dynamic_pointer_cast<
XDriver>(shared_from_this()),
"%.3f")),
28 dynamic_pointer_cast<
XDriver>(shared_from_this()),
"%.3f")),
29 m_heliumLevel(create<
XDoubleNode>(
"HeliumLevel", false)),
30 m_targetField(create<
XDoubleNode>(
"TargetField",true)),
31 m_fieldSweepRate(create<
XDoubleNode>(
"FieldSweepRate",true)),
32 m_fieldApproachMode(create<
XComboNode>(
"FieldApproachMode",true,true)),
33 m_fieldMagnetMode(create<
XComboNode>(
"FieldMagnetMode",true,true)),
34 m_fieldStatus(create<
XStringNode>(
"FieldStatus",false)),
35 m_targetPosition(create<
XDoubleNode>(
"TargetPosition",true)),
36 m_positionApproachMode(create<
XComboNode>(
"PositionApproachMode",true,true)),
37 m_positionSlowDownCode(create<
XIntNode>(
"PositionSlowDownCode",true)),
38 m_positionStatus(create<
XStringNode>(
"PositionStatus",false)),
39 m_targetTemp(create<
XDoubleNode>(
"TargetTemp",true)),
40 m_tempSweepRate(create<
XDoubleNode>(
"TempSweepRate",true)),
41 m_tempApproachMode(create<
XComboNode>(
"TempApproachMode",true,true)),
42 m_tempStatus(create<
XStringNode>(
"TempStatus",false)),
44 meas->scalarEntries()->
insert(tr_meas, m_temp);
45 meas->scalarEntries()->insert(tr_meas, m_user_temp);
46 meas->scalarEntries()->insert(tr_meas, m_field);
47 meas->scalarEntries()->insert(tr_meas, m_position);
52 xqcon_create<XQLCDNumberConnector>(temp()->value(), m_form->m_lcdTemp),
53 xqcon_create<XQLCDNumberConnector>(user_temp()->value(), m_form->m_lcdUserTemp),
54 xqcon_create<XQLCDNumberConnector>(field()->value(), m_form->m_lcdField),
55 xqcon_create<XQLCDNumberConnector>(position()->value(), m_form->m_lcdPosition),
56 xqcon_create<XQLCDNumberConnector>(heliumLevel(), m_form->m_lcdHeliumLevel),
57 xqcon_create<XQLineEditConnector>(targetField(), m_form->m_edTargetField),
58 xqcon_create<XQLineEditConnector>(fieldSweepRate(), m_form->m_edFieldSweepRate),
59 xqcon_create<XQComboBoxConnector>(fieldApproachMode(), m_form->m_cmbFieldApproachMode,
Snapshot( *m_fieldApproachMode)),
60 xqcon_create<XQComboBoxConnector>(fieldMagnetMode(), m_form->m_cmbMagnetMode,
Snapshot( *m_fieldMagnetMode)),
61 xqcon_create<XQLabelConnector>(fieldStatus(), m_form->m_labelFieldStatus),
62 xqcon_create<XQLineEditConnector>(targetTemp(), m_form->m_edTargetTemp),
63 xqcon_create<XQLineEditConnector>(tempSweepRate(), m_form->m_edTempSweepRate),
64 xqcon_create<XQComboBoxConnector>(tempApproachMode(), m_form->m_cmbTempApproachMode,
Snapshot( *m_tempApproachMode)),
65 xqcon_create<XQLabelConnector>(tempStatus(), m_form->m_labelTempStatus),
66 xqcon_create<XQLineEditConnector>(targetPosition(), m_form->m_edTargetPosition),
67 xqcon_create<XQComboBoxConnector>(positionApproachMode(), m_form->m_cmbPositionApproachMode,
Snapshot( *m_positionApproachMode)),
68 xqcon_create<XQLineEditConnector>(positionSlowDownCode(), m_form->m_edPositionSlowDownCode),
69 xqcon_create<XQLabelConnector>(positionStatus(), m_form->m_labelPositionStatus)
73 tr[ *fieldApproachMode()].add({
"Linear",
"No Overshoot",
"Oscillate"});
74 tr[ *fieldMagnetMode()].add({
"Persistent",
"Driven"});
75 tr[ *positionApproachMode()].add(
"default");
76 tr[ *positionSlowDownCode()] = 0;
77 tr[ *tempApproachMode()].add({
"FastSettle",
"No Overshoot"});
78 std::vector<shared_ptr<XNode>> runtime_ui{
79 targetField(), fieldSweepRate(), fieldApproachMode(),
80 fieldMagnetMode(), targetTemp(), tempSweepRate(), tempApproachMode(),
81 targetPosition(), positionApproachMode(), positionSlowDownCode()
83 for(
auto &&x: runtime_ui)
84 tr[ *x].setUIEnabled(
false);
95 tr[ *
this].m_sampleTemp = reader.pop<
float>();
96 tr[ *
this].m_sampleUserTemp = reader.pop<
float>();
97 tr[ *
this].m_magnetField = reader.pop<
float>();
98 tr[ *
this].m_samplePosition = reader.pop<
float>();
99 m_temp->value(tr, tr[ *
this].m_sampleTemp);
100 m_user_temp->value(tr, tr[ *
this].m_sampleUserTemp);
101 m_field->value(tr, tr[ *
this].m_magnetField);
102 m_position->value(tr, tr[*
this].m_samplePosition);
111 double sweepRate = ***fieldSweepRate();
112 int approachMode = ***fieldApproachMode();
113 int magnetMode = ***fieldMagnetMode();
115 setField(shot[ *targetField()], sweepRate,
116 approachMode, magnetMode);
125 int approachMode = ***positionApproachMode();
126 int slowDownCode = ***positionSlowDownCode();
128 setPosition(shot[ *targetPosition()], approachMode, slowDownCode);
137 double sweepRate = ***tempSweepRate();
138 int approachMode = ***tempApproachMode();
140 setTemp(shot[ *targetTemp()], sweepRate, approachMode);
149 std::vector<shared_ptr<XNode>> runtime_ui{
150 targetField(), fieldSweepRate(), fieldApproachMode(),
151 fieldMagnetMode(), targetTemp(), tempSweepRate(), tempApproachMode(),
152 targetPosition(), positionApproachMode(), positionSlowDownCode()
155 for(
auto &&x: runtime_ui)
158 m_lsnFieldSet = tr[ *targetField()].onValueChanged().connectWeakly(
159 shared_from_this(), &XQDPPMS::onFieldChanged);
160 m_lsnTempSet = tr[ *targetTemp()].onValueChanged().connectWeakly(
161 shared_from_this(), &XQDPPMS::onTempChanged);
162 m_lsnPositionSet = tr[ *targetPosition()].onValueChanged().connectWeakly(
163 shared_from_this(), &XQDPPMS::onPositionChanged);
166 while( !terminated) {
170 double sample_user_temp;
171 double sample_position;
177 magnet_field = getField();
178 sample_temp = getTemp();
179 sample_user_temp = getUserTemp();
180 sample_position = getPosition();
181 helium_level = getHeliumLevel();
182 status = getStatus();
188 auto writer = std::make_shared<RawData>();
189 writer->push((
float)sample_temp);
190 writer->push((
float)sample_user_temp);
191 writer->push((
float)magnet_field);
192 writer->push((
float)sample_position);
198 tr[ *heliumLevel()] = helium_level;
199 tr[ *tempStatus()] = std::map<int,std::string>{
207 {0xd,
"Control Disabled"},
208 {0xe,
"Cannot Complete"},
211 tr[ *fieldStatus()] = std::map<int,std::string>{
220 {0x8,
"CurrentError"},
222 }.at((status >> 4) & 0xf);
223 tr[ *positionStatus()] = std::map<int,std::string>{
230 }.at((status >> 12) & 0xf);
233 catch (std::out_of_range &) {
234 gErrPrint(i18n(
"PPMS: unknown status has been returned."));
239 for(
auto &&x: runtime_ui)
243 m_lsnFieldSet.reset();
244 m_lsnTempSet.reset();
245 m_lsnPositionSet.reset();