15 #include "usertempcontrol.h"
16 #include "charinterface.h"
18 REGISTER_TYPE(
XDriverList, CryoconM32,
"Cryocon M32 temp. controller");
19 REGISTER_TYPE(
XDriverList, CryoconM62,
"Cryocon M62 temp. controller");
20 REGISTER_TYPE(
XDriverList, LakeShore340,
"LakeShore 340 temp. controller");
21 REGISTER_TYPE(
XDriverList, LakeShore370,
"LakeShore 370 AC res. bridge");
22 REGISTER_TYPE(
XDriverList, AVS47IB,
"Picowatt AVS-47 AC res. bridge");
23 REGISTER_TYPE(
XDriverList, ITC503,
"Oxford ITC-503 temp. controller");
24 REGISTER_TYPE(
XDriverList, NeoceraLTC21,
"Neocera LTC-21 temp. controller");
25 REGISTER_TYPE(
XDriverList, LinearResearch700,
"LinearResearch LR-700 AC res. bridge");
26 REGISTER_TYPE(
XDriverList, KE2700w7700,
"Keithley 2700&7700 as temp. controller");
28 XITC503::XITC503(
const char *name,
bool runtime,
29 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
33 {}, {
"HEATER",
"GASFLOW"});
38 interface()->query(
"X");
39 int stat, automan, locrem, sweep, ctrlsens, autopid;
40 if(interface()->scanf(
"X%1dA%dC%1dS%2dH%1dL%1d", &stat, &automan, &locrem, &sweep, &ctrlsens, &autopid) != 6)
45 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
46 if( !hasExtDevice(shot, idx)) {
47 tr[ *heaterMode(idx)].clear();
48 tr[ *heaterMode(idx)].add({
"AUTO",
"MAN"});
49 tr[ *powerMax(idx)].setUIEnabled(
false);
50 tr[ *powerMin(idx)].setUIEnabled(
false);
51 tr[ *currentChannel(idx)].str(formatString(
"%d", ctrlsens));
52 tr[ *heaterMode(idx)] = (automan & ((idx == 0) ? 1 : 2)) ? 0 : 1;
54 tr[ *powerRange(idx)].setUIEnabled(
false);
59 trans( *targetTemp(0)) = t;
60 trans( *targetTemp(1)).setUIEnabled(
false);
65 trans( *interval(0)) = i;
66 trans( *deriv(0)) = d;
67 trans( *prop(1)).setUIEnabled(
false);
68 trans( *interval(1)).setUIEnabled(
false);
69 trans( *deriv(1)).setUIEnabled(
false);
72 interface()->send(
"X");
73 return read(QString(channel->getName()).toInt());
76 interface()->send(
"X");
77 return read(QString(channel->getName()).toInt());
80 return read(loop ? 7: 5);
82 void XITC503::onPChanged(
unsigned int loop,
double p) {
84 interface()->sendf(
"P%f", p);
86 void XITC503::onIChanged(
unsigned int loop,
double i) {
88 interface()->sendf(
"I%f", i);
90 void XITC503::onDChanged(
unsigned int loop,
double d) {
92 interface()->sendf(
"D%f", d);
94 void XITC503::onTargetTempChanged(
unsigned int loop,
double temp) {
96 if(( **heaterMode(0))->to_str() ==
"AUTO")
97 interface()->sendf(
"T%f", temp);
99 void XITC503::onManualPowerChanged(
unsigned int loop,
double pow) {
101 if(( **heaterMode(0))->to_str() ==
"MAN")
102 interface()->sendf(
"O%f", pow);
105 if(( **heaterMode(1))->to_str() ==
"MAN")
106 interface()->sendf(
"G%f", pow);
109 void XITC503::onHeaterModeChanged(
unsigned int loop,
int) {
110 int mode = ((( **heaterMode(0))->to_str() ==
"MAN") ? 0 : 1) + ((( **heaterMode(1))->to_str() ==
"MAN") ? 0 : 2);
111 interface()->sendf(
"A%d", mode);
113 void XITC503::onPowerRangeChanged(
unsigned int ,
int) {
115 void XITC503::onCurrentChannelChanged(
unsigned int loop,
const shared_ptr<XChannel> &ch) {
117 interface()->send(
"H" + ch->getName());
119 void XITC503::onExcitationChanged(
const shared_ptr<XChannel> &,
int) {
122 XAVS47IB::XAVS47IB(
const char *name,
bool runtime,
123 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
126 {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7"},
127 {
"0",
"3uV",
"10uV",
"30uV",
"100uV",
"300uV",
"1mV",
"3mV"},
132 interface()->setGPIBWaitBeforeWrite(10);
133 interface()->setGPIBWaitBeforeRead(10);
137 double XAVS47IB::read(
const char *str) {
139 interface()->queryf(
"%s?", str);
141 if(interface()->scanf(
"%3s %lf", buf, &x) != 2)
143 if(strncmp(buf, str, 3))
147 void XAVS47IB::onPChanged(
unsigned int ,
double p) {
153 ip = lrint(ip / 5.0 - 1.0);
154 interface()->sendf(
"PRO %u", ip);
156 void XAVS47IB::onIChanged(
unsigned int ,
double i) {
160 ii = (ii < 2) ? 0 : lrint(log10((
double) ii) * 3.0);
161 interface()->sendf(
"ITC %u", ii);
163 void XAVS47IB::onDChanged(
unsigned int ,
double d) {
165 id = (
id < 1) ? 0 : lrint(log10((
double)
id) * 3.0) + 1;
166 interface()->sendf(
"DTC %u",
id);
168 void XAVS47IB::onTargetTempChanged(
unsigned int ,
double) {
171 void XAVS47IB::onManualPowerChanged(
unsigned int ,
double) {
173 void XAVS47IB::onHeaterModeChanged(
unsigned int ,
int) {
175 void XAVS47IB::onPowerRangeChanged(
unsigned int ,
int ran) {
178 void XAVS47IB::onCurrentChannelChanged(
unsigned int ,
const shared_ptr<XChannel> &ch) {
180 interface()->send(
"ARN 0;INP 0;ARN 0;RAN 7");
181 interface()->sendf(
"DIS 0;MUX %u;ARN 0",
182 QString(shot[ *currentChannel(0)].to_str()).toInt());
183 if(shot[ *ch->excitation()] >= 1)
184 interface()->sendf(
"EXC %u", (
unsigned int) (shot[ *ch->excitation()]));
186 interface()->send(
"ARN 0;INP 1;ARN 0;RAN 6");
187 m_autorange_wait = 0;
189 void XAVS47IB::onExcitationChanged(
const shared_ptr<XChannel> &ch,
int exc) {
191 if( !interface()->isOpened())
194 if(ch != shared_ptr<XChannel>(shot[ *currentChannel(0)]))
196 interface()->sendf(
"EXC %u", (
unsigned int) exc);
197 m_autorange_wait = 0;
200 tr[ *powerRange(0)].add({
"0",
"1uW",
"10uW",
"100uW",
"1mW",
"10mW",
"100mW",
"1W"});
211 interface()->send(
"REM 1;ARN 0;DIS 0");
212 trans( *currentChannel(0)).str(formatString(
"%d", (
int) lrint(read(
"MUX"))));
213 onCurrentChannelChanged(0, ***currentChannel(0));
219 if( !hasExtDevice(shot, 0)) {
220 tr[ *heaterMode(0)].clear();
221 tr[ *heaterMode(0)].add(
"PID");
222 tr[ *powerMax(0)].setUIEnabled(
false);
223 tr[ *powerMin(0)].setUIEnabled(
false);
229 if( !interface()->isOpened())
232 interface()->send(
"REM 0");
241 int XAVS47IB::setRange(
unsigned int range) {
242 int rangebuf = ***powerRange(0);
243 interface()->send(
"POW 0");
246 interface()->queryf(
"ARN 0;RAN %u;*OPC?", range);
248 interface()->sendf(
"POW %u", rangebuf);
250 m_autorange_wait = 0;
254 double XAVS47IB::getRes() {
258 int wait = interface()->gpibWaitBeforeRead();
259 interface()->setGPIBWaitBeforeRead(300);
260 interface()->query(
"AVE 1;*OPC?");
261 interface()->setGPIBWaitBeforeRead(wait);
264 if(m_autorange_wait++ > 10) {
265 int range = getRange();
266 if(lrint(read(
"OVL")) == 0) {
267 if(fabs(x) < 0.1 * pow(10.0, range - 1))
268 setRange(std::max(range - 1, 1));
269 if(fabs(x) > 1.6 * pow(10.0, range - 1))
270 setRange(std::min(range + 1, 7));
273 setRange(std::min(range + 1, 7));
278 int XAVS47IB::getRange() {
279 return lrint(read(
"RAN"));
281 int XAVS47IB::setPoint() {
283 shared_ptr<XChannel> ch = shot[ *currentChannel(0)];
286 shared_ptr<XThermometer> thermo = shot[ *ch->thermometer()];
289 double res = thermo->getRawValue(shot[ *targetTemp(0)]);
291 int val = lrint(10000.0 * res / pow(10.0, getRange() - 1));
292 val = std::min(val, 20000);
293 interface()->sendf(
"SPT %d", val);
297 int XAVS47IB::setBias(
unsigned int bias) {
298 interface()->sendf(
"BIA %u", bias);
301 void XAVS47IB::setPowerRange(
int range) {
302 interface()->sendf(
"POW %u", range);
308 XCryocon::XCryocon(
const char *name,
bool runtime,
309 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
311 interface()->setEOS(
"");
312 interface()->setGPIBUseSerialPollOnWrite(
false);
313 interface()->setGPIBUseSerialPollOnRead(
false);
314 interface()->setGPIBWaitBeforeWrite(20);
316 interface()->setGPIBWaitBeforeRead(20);
317 interface()->setSerialEOS(
"\n");
318 interface()->setSerialBaudRate(9600);
319 interface()->setSerialStopBits(1);
320 interface()->setSerialFlushBeforeWrite(
true);
322 XCryoconM62::XCryoconM62(
const char *name,
bool runtime,
323 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
324 XCryocon(name, runtime, ref(tr_meas), meas) {
327 {
"10UV",
"30UV",
"100UV",
"333UV",
"1.0MV",
"3.3MV"},
330 XCryoconM32::XCryoconM32(
const char *name,
bool runtime,
331 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
332 XCryocon(name, runtime, ref(tr_meas), meas) {
335 {
"CI",
"10MV",
"3MV",
"1MV"},
336 {
"Loop#1",
"Loop#2"});
341 assert(list.size() == 2);
342 shared_ptr<XChannel> ch0 = static_pointer_cast<
XChannel>(list.at(0));
343 shared_ptr<XChannel> ch1 = static_pointer_cast<
XChannel>(list.at(1));
344 interface()->query(
"INPUT A:VBIAS?");
345 trans( *ch0->excitation()).str(interface()->toStrSimplified());
346 interface()->query(
"INPUT B:VBIAS?");
347 trans( *ch1->excitation()).str(interface()->toStrSimplified());
350 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
351 trans( *powerRange(idx)).clear();
352 if( !hasExtDevice(shot, idx)) {
354 interface()->queryf(
"%s:PMAN?", loopString(idx));
355 trans( *manualPower(idx)).str(
XString( &interface()->buffer()[0]));
356 interface()->queryf(
"%s:PGAIN?", loopString(idx));
357 trans( *prop(idx)).str(
XString( &interface()->buffer()[0]));
358 interface()->queryf(
"%s:IGAIN?", loopString(idx));
359 trans( *interval(idx)).str(
XString( &interface()->buffer()[0]));
360 interface()->queryf(
"%s:DGAIN?", loopString(idx));
361 trans( *deriv(idx)).str(
XString( &interface()->buffer()[0]));
364 tr[ *heaterMode(idx)].clear();
365 tr[ *heaterMode(idx)].add({
"OFF",
"PID",
"MAN"});
366 tr[ *powerMin(idx)].setUIEnabled(
false);
368 interface()->queryf(
"%s:TYPE?", loopString(idx));
369 trans( *heaterMode(idx)).str(interface()->toStrSimplified());
373 interface()->queryf(
"%s:RANGE?", loopString(0));
374 trans( *powerRange(0)).str(interface()->toStrSimplified());
382 tr[ *powerRange(0)].add({
"HI",
"MID",
"LOW"});
385 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
386 if( !hasExtDevice(shot, idx)) {
387 interface()->queryf(
"%s:MAXPWR?", loopString(idx));
388 trans( *powerMax(idx)).str(
XString( &interface()->buffer()[0]));
392 void XCryoconM32::onPowerMaxChanged(
unsigned int loop,
double x) {
393 interface()->sendf(
"%s:MAXPWR %f ", loopString(loop), x);
398 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
399 powerMax(idx)->setUIEnabled(
false);
402 interface()->query(
"HEATER:LOAD?");
404 if(interface()->toInt() == 50) {
405 tr[ *powerRange(0)].add({
"0.05W",
"0.5W",
"5.0W",
"50W"});
408 tr[ *powerRange(0)].add({
"0.03W",
"0.3W",
"2.5W",
"25W"});
412 void XCryocon::onPChanged(
unsigned int loop,
double p) {
413 interface()->sendf(
"%s:PGAIN %f", loopString(loop), p);
415 void XCryocon::onIChanged(
unsigned int loop,
double i) {
416 interface()->sendf(
"%s:IGAIN %f", loopString(loop), i);
418 void XCryocon::onDChanged(
unsigned int loop,
double d) {
419 interface()->sendf(
"%s:DGAIN %f", loopString(loop), d);
421 void XCryocon::onTargetTempChanged(
unsigned int loop,
double temp) {
424 void XCryocon::onManualPowerChanged(
unsigned int loop,
double pow) {
425 interface()->sendf(
"%s:PMAN %f", loopString(loop), pow);
427 void XCryocon::onHeaterModeChanged(
unsigned int loop,
int) {
430 void XCryocon::onPowerRangeChanged(
unsigned int loop,
int) {
433 interface()->sendf(
"%s:RANGE %s", loopString(loop), ( **powerRange(loop))->to_str().c_str());
435 void XCryocon::onCurrentChannelChanged(
unsigned int loop,
const shared_ptr<XChannel> &ch) {
436 interface()->sendf(
"%s:SOURCE %s", loopString(loop), ch->getName().c_str());
438 void XCryocon::onExcitationChanged(
const shared_ptr<XChannel> &ch,
int) {
440 if( !interface()->isOpened())
442 interface()->send(
"INPUT " + ch->getName() +
":VBIAS "
443 + ( **ch->excitation())->to_str());
445 void XCryocon::setTemp(
unsigned int loop,
double temp) {
452 shared_ptr<XThermometer> thermo = shot[ *(shared_ptr<XChannel>(shot[ *currentChannel(loop)])->thermometer())];
454 setHeaterSetPoint(loop, thermo->getRawValue(temp));
456 setHeaterSetPoint(loop, temp);
460 x = getInput(channel);
465 x = getInput(channel);
468 void XCryocon::getChannel(
unsigned int loop) {
469 interface()->queryf(
"%s:SOURCE?", loopString(loop));
471 if(interface()->scanf(
"CH%s", s) != 1)
473 trans( *currentChannel(loop)).str(
XString(s));
475 void XCryocon::setHeaterMode(
unsigned int loop) {
477 if(shot[ *heaterMode(loop)].to_str() ==
"Off")
482 interface()->sendf(
"%s:TYPE %s", loopString(loop), shot[ *heaterMode(loop)].to_str().c_str());
485 interface()->queryf(
"%s:OUTP?", loopString(loop));
486 return interface()->toDouble();
489 int XCryocon::control() {
490 interface()->send(
"CONTROL");
493 int XCryocon::stopControl() {
494 interface()->send(
"STOP");
497 double XCryocon::getInput(shared_ptr<XChannel> &channel) {
498 interface()->query(
"INPUT? " + channel->getName());
500 if(interface()->scanf(
"%lf", &x) != 1)
505 int XCryocon::setHeaterSetPoint(
unsigned int loop,
double value) {
506 interface()->sendf(
"%s:SETPT %f", loopString(loop), value);
510 XNeoceraLTC21::XNeoceraLTC21(
const char *name,
bool runtime,
511 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
517 interface()->setEOS(
"");
518 interface()->setSerialEOS(
"\n");
520 tr[ *powerRange(0)].add({
"0",
"0.05W",
"0.5W",
"5W",
"50W"});
524 interface()->send(
"SCONT;");
527 interface()->send(
"SMON;");
531 interface()->query(
"QSAMP?" + channel->getName() +
";");
533 if(interface()->scanf(
"%7lf", &x) != 1)
538 interface()->query(
"QSAMP?" + channel->getName() +
";");
540 if(interface()->scanf(
"%7lf", &x) != 1)
547 interface()->query(
"QHEAT?;");
549 if(interface()->scanf(
"%5lf", &x) != 1)
555 interface()->sendf(
"SPID%u,%f,%f,%f,%f,100.0,%f;", loop + 1, (
double)shot[ *prop(loop)],
556 (
double)shot[ *interval(loop)], (
double)shot[ *deriv(loop)], (
double)shot[ *manualPower(loop)],
557 (
double)shot[ *powerMax(loop)]);
559 void XNeoceraLTC21::onPChanged(
unsigned int loop,
double ) {
562 void XNeoceraLTC21::onIChanged(
unsigned int loop,
double ) {
565 void XNeoceraLTC21::onDChanged(
unsigned int loop,
double ) {
568 void XNeoceraLTC21::onTargetTempChanged(
unsigned int loop,
double temp) {
569 interface()->sendf(
"SETP%u,%.5f;", loop + 1, temp);
571 void XNeoceraLTC21::onManualPowerChanged(
unsigned int loop,
double ) {
574 void XNeoceraLTC21::onPowerMaxChanged(
unsigned int loop,
double ) {
577 void XNeoceraLTC21::onHeaterModeChanged(
unsigned int loop,
int x) {
581 interface()->sendf(
"SHCONT%d;", x);
587 void XNeoceraLTC21::onPowerRangeChanged(
unsigned int loop,
int ran) {
590 interface()->sendf(
"SHMXPWR%d;", ran);
592 void XNeoceraLTC21::onCurrentChannelChanged(
unsigned int loop,
const shared_ptr<XChannel> &cch) {
593 int ch = atoi(cch->getName().c_str());
596 interface()->sendf(
"SOSEN%u,%d;", loop + 1, ch);
598 void XNeoceraLTC21::onExcitationChanged(
const shared_ptr<XChannel> &,
int) {
600 if( !interface()->isOpened())
605 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
606 if( !hasExtDevice(shot, idx)) {
607 interface()->queryf(
"QOUT?%u;", idx + 1);
608 int sens, cmode, range;
610 if(interface()->scanf(
"%1d;%1d;%1d;", &sens, &cmode, &range) != 3)
614 if(interface()->scanf(
"%1d;%1d;", &sens, &cmode) != 2)
618 tr[ *currentChannel(idx)].str(formatString(
"%d", sens));
620 tr[ *heaterMode(idx)].clear();
621 tr[ *heaterMode(idx)].add({
"AUTO P",
"AUTO PI",
"AUTO PID",
"PID",
"TABLE",
"DEFAULT",
"MONITOR"});
623 tr[ *heaterMode(idx)] = cmode;
625 tr[ *powerRange(idx)] = range;
628 interface()->queryf(
"QPID?%u;", idx + 1);
629 double p, i, d, power, limit;
630 if(interface()->scanf(
"%lf;%lf;%lf;%lf;%lf;", &p, &i, &d, &power,
635 tr[ *interval(idx)] = i;
636 tr[ *deriv(idx)] = d;
637 tr[ *manualPower(idx)] = power;
638 tr[ *powerMax(idx)] = limit;
639 tr[ *powerMin(0)].setUIEnabled(
false);
647 XLakeShoreBridge::XLakeShoreBridge(
const char *name,
bool runtime,
648 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
650 interface()->setEOS(
"\r\n");
651 interface()->setGPIBUseSerialPollOnWrite(
false);
652 interface()->setGPIBUseSerialPollOnRead(
false);
653 interface()->setGPIBWaitBeforeWrite(40);
655 interface()->setGPIBWaitBeforeRead(40);
658 XLakeShore340::XLakeShore340(
const char *name,
bool runtime,
659 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
669 interface()->query(
"SRDG? " + channel->getName());
670 return interface()->toDouble();
673 interface()->query(
"KRDG? " + channel->getName());
674 return interface()->toDouble();
678 interface()->query(
"HTR?");
681 interface()->query(
"ANALOG?2");
683 if(interface()->scanf(
"%*d,%d", &mode) != 1)
687 interface()->query(
"AOUT?2");
689 return interface()->toDouble();
691 void XLakeShore340::onPChanged(
unsigned int loop,
double p) {
692 interface()->sendf(
"PID %u,%f", loop + 1, p);
694 void XLakeShore340::onIChanged(
unsigned int loop,
double i) {
695 interface()->sendf(
"PID %u,,%f", loop + 1, i);
697 void XLakeShore340::onDChanged(
unsigned int loop,
double d) {
698 interface()->sendf(
"PID %u,,,%f", loop + 1, d);
700 void XLakeShore340::onTargetTempChanged(
unsigned int loop,
double temp) {
702 shared_ptr<XThermometer> thermo = shot[ *shared_ptr<XChannel> ( shot[ *currentChannel(loop)])->thermometer()];
704 interface()->sendf(
"CSET %u,%s,3,1", loop + 1,
705 (
const char*)shot[ *currentChannel(loop)].to_str().c_str());
706 temp = thermo->getRawValue(temp);
709 interface()->sendf(
"CSET %u,%s,1,1", loop + 1,
710 (
const char*)shot[ *currentChannel(loop)].to_str().c_str());
712 interface()->sendf(
"SETP %u,%f", loop + 1, temp);
714 void XLakeShore340::onManualPowerChanged(
unsigned int loop,
double pow) {
715 interface()->sendf(
"MOUT %u,%f", loop + 1, pow);
717 void XLakeShore340::onPowerMaxChanged(
unsigned int loop,
double pow) {
719 interface()->sendf(
"CLIMI %f", pow);
721 void XLakeShore340::onHeaterModeChanged(
unsigned int loop,
int) {
723 if(shot[ *heaterMode(loop)].to_str() ==
"PID") {
724 interface()->sendf(
"CMODE %u,1", loop + 1);
726 if(shot[ *heaterMode(loop)].to_str() ==
"Man") {
727 interface()->sendf(
"CMODE %u,3", loop + 1);
730 void XLakeShore340::onPowerRangeChanged(
unsigned int loop,
int ran) {
733 interface()->sendf(
"RANGE %d", ran);
735 void XLakeShore340::onCurrentChannelChanged(
unsigned int loop,
const shared_ptr<XChannel> &ch) {
736 interface()->sendf(
"CSET %u,%s", loop + 1, (
const char *) ch->getName().c_str());
738 void XLakeShore340::onExcitationChanged(
const shared_ptr<XChannel> &,
int) {
740 if( !interface()->isOpened())
745 for(
unsigned int idx = 0; idx <
numOfLoops(); ++idx) {
746 interface()->queryf(
"CDISP? %u", idx + 1);
747 int res, maxcurr_idx;
748 if(interface()->scanf(
"%*d,%d", &res) != 1)
750 interface()->queryf(
"CLIMIT? %u", idx + 1);
751 if(interface()->scanf(
"%*f,%*f,%*f,%d", &maxcurr_idx) != 1)
754 interface()->query(
"CLIMI?");
755 double max_curr_loop1 = 0.0;
757 max_curr_loop1 = interface()->toDouble();
761 max_curr_loop1 = 2.0;
762 powerMax(0)->setUIEnabled(
false);
765 double maxcurr = pow(2.0, maxcurr_idx) * 0.125;
767 tr[ *powerRange(idx)].clear();
769 tr[ *powerRange(idx)].add(
"0");
770 for(
int i = 1; i < 6; i++) {
771 tr[ *powerRange(idx)].add(formatString(
"%.2g W", (
double) pow(10.0, i - 5.0)
772 * pow(maxcurr, 2.0) * res));
776 if( !hasExtDevice(shot, idx)) {
777 interface()->queryf(
"CSET? %u", idx + 1);
780 if(interface()->scanf(
"%1s", ch) == 1)
781 tr[ *currentChannel(idx)].str(
XString(ch));
783 tr[ *heaterMode(idx)].clear();
784 tr[ *heaterMode(idx)].add({
"PID",
"Man"});
787 tr[ *powerMax(idx)] = max_curr_loop1;
789 tr[ *powerMax(idx)].setUIEnabled(
false);
790 tr[ *powerMin(idx)].setUIEnabled(
false);
793 interface()->queryf(
"CMODE? %u", idx + 1);
794 switch(interface()->toInt()) {
796 trans( *heaterMode(idx)).str(
XString(
"PID"));
799 trans( *heaterMode(idx)).str(
XString(
"Man"));
805 interface()->query(
"RANGE?");
806 int range = interface()->toInt();
807 trans( *powerRange(0)) = range;
810 interface()->queryf(
"MOUT? %u", idx + 1);
811 trans( *manualPower(idx)) = interface()->toDouble();
812 interface()->queryf(
"PID? %u", idx + 1);
814 if(interface()->scanf(
"%lf,%lf,%lf", &p, &i, &d) != 3)
818 tr[ *interval(idx)] = i;
819 tr[ *deriv(idx)] = d;
826 XLakeShore370::XLakeShore370(
const char *name,
bool runtime,
827 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
831 {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8"},
837 interface()->query(
"RDGR? " + channel->getName());
838 return interface()->toDouble();
841 interface()->query(
"RDGK? " + channel->getName());
842 return interface()->toDouble();
845 interface()->query(
"HTR?");
846 return interface()->toDouble();
848 void XLakeShore370::onPChanged(
unsigned int ,
double p) {
849 interface()->sendf(
"PID %f", p);
851 void XLakeShore370::onIChanged(
unsigned int ,
double i) {
852 interface()->sendf(
"PID ,,%f", i);
854 void XLakeShore370::onDChanged(
unsigned int ,
double d) {
855 interface()->sendf(
"PID ,,,%f", d);
857 void XLakeShore370::onTargetTempChanged(
unsigned int ,
double temp) {
859 shared_ptr<XThermometer> thermo = shot[ *shared_ptr<XChannel> ( shot[ *currentChannel(0)])->thermometer()];
861 interface()->sendf(
"CSET %s,,2",
862 (
const char*)shot[ *currentChannel(0)].to_str().c_str());
863 temp = thermo->getRawValue(temp);
866 interface()->sendf(
"CSET %s,,1",
867 (
const char*)shot[ *currentChannel(0)].to_str().c_str());
869 interface()->sendf(
"SETP %f", temp);
871 void XLakeShore370::onManualPowerChanged(
unsigned int ,
double pow) {
872 interface()->sendf(
"MOUT %f", pow);
874 void XLakeShore370::onHeaterModeChanged(
unsigned int ,
int) {
876 if(shot[ *heaterMode(0)].to_str() ==
"Off") {
877 interface()->send(
"CMODE 4");
879 if(shot[ *heaterMode(0)].to_str() ==
"PID") {
880 interface()->send(
"CMODE 1");
882 if(shot[ *heaterMode(0)].to_str() ==
"Man") {
883 interface()->send(
"CMODE 3");
886 void XLakeShore370::onPowerRangeChanged(
unsigned int ,
int ran) {
887 interface()->sendf(
"HTRRNG %d", ran);
889 void XLakeShore370::onCurrentChannelChanged(
unsigned int ,
const shared_ptr<XChannel> &ch) {
890 interface()->sendf(
"CSET %s", (
const char *) ch->getName().c_str());
892 void XLakeShore370::onExcitationChanged(
const shared_ptr<XChannel> &,
int) {
894 if( !interface()->isOpened())
899 interface()->query(
"CSET?");
900 int ctrl_ch, units, htr_limit;
902 if(interface()->scanf(
"%d,%*d,%d,%*d,%*d,%d,%lf", &ctrl_ch, &units, &htr_limit, &htr_res) != 4)
906 tr[ *powerRange(0)].clear();
907 tr[ *powerRange(0)].add(
"0");
908 for(
int i = 1; i < htr_limit; i++) {
909 double pwr = htr_res * (pow(10.0, i) * 1e-7);
911 tr[ *powerRange(0)].add(formatString(
"%.2g uW", pwr * 1e3));
913 tr[ *powerRange(0)].add(formatString(
"%.2g mW", pwr));
916 if( !hasExtDevice(shot, 0)) {
918 tr[ *currentChannel(0)].str(formatString(
"%d", ctrl_ch ));
919 tr[ *heaterMode(0)].clear();
920 tr[ *heaterMode(0)].add({
"Off",
"PID",
"Man"});
923 interface()->query(
"CMODE?");
924 switch(interface()->toInt()) {
926 trans( *heaterMode(0)).str(
XString(
"PID"));
929 trans( *heaterMode(0)).str(
XString(
"Man"));
934 interface()->query(
"HTRRNG?");
935 int range = interface()->toInt();
936 trans( *powerRange(0)) = range;
938 interface()->query(
"MOUT?");
939 trans( *manualPower(0)) = interface()->toDouble();
940 interface()->query(
"PID?");
942 if(interface()->scanf(
"%lf,%lf,%lf", &p, &i, &d) != 3)
946 tr[ *interval(0)] = i;
948 tr[ *powerMax(0)].setUIEnabled(
false);
949 tr[ *powerMin(0)].setUIEnabled(
false);
956 XLinearResearch700::XLinearResearch700(
const char *name,
bool runtime,
957 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
959 interface()->setEOS(
"\n");
960 interface()->setGPIBUseSerialPollOnWrite(
false);
961 interface()->setGPIBUseSerialPollOnRead(
false);
962 interface()->setGPIBWaitBeforeWrite(40);
963 interface()->setGPIBWaitBeforeRead(40);
967 {
"20uV",
"60uV",
"200uV",
"600uV",
"2mV",
"6mV",
"20mV"},
970 tr[ *powerRange(0)].add({
"30uA",
"100uA",
"300uA",
"1mA",
"3mA",
"10mA",
"30mA",
"100mA",
"300mA",
"1A",
"3A"});
975 XLinearResearch700::parseResponseMessage() {
977 int ret = interface()->scanf(
"%lf%c", &v, &unit);
978 if((ret != 1) && (ret != 2))
992 interface()->query(
"GET 0");
993 double res = parseResponseMessage();
1000 interface()->query(
"GET 8");
1002 if(interface()->scanf(
"%lf V", &v) != 1)
1006 void XLinearResearch700::onPChanged(
unsigned int loop,
double p) {
1007 int x = lrint(log10(p / 0.1) * 3);
1008 interface()->sendf(
"HEATER G=%02d", x);
1010 void XLinearResearch700::onIChanged(
unsigned int loop,
double i) {
1011 int x = lrint(log10(i / 0.2) * 3);
1012 interface()->sendf(
"HEATER T=%02d", x);
1014 void XLinearResearch700::onDChanged(
unsigned int loop,
double d) {
1016 void XLinearResearch700::onTargetTempChanged(
unsigned int loop,
double temp) {
1018 shared_ptr<XThermometer> thermo = shot[ *shared_ptr<XChannel> ( shot[ *currentChannel(loop)])->thermometer()];
1020 temp = thermo->getRawValue(temp);
1022 interface()->sendf(
"OFFSET R=%f", temp);
1024 void XLinearResearch700::onManualPowerChanged(
unsigned int loop,
double pow) {
1025 interface()->sendf(
"HEATER Q=%+03d", (
int)lrint(pow * 10.0));
1027 void XLinearResearch700::onHeaterModeChanged(
unsigned int loop,
int) {
1029 if(shot[ *heaterMode(loop)].to_str() ==
"Normal") {
1030 interface()->sendf(
"HEATER L=0");
1031 interface()->send(
"HEATER 1");
1034 if(shot[ *heaterMode(loop)].to_str() ==
"Inverted") {
1035 interface()->sendf(
"HEATER L=1");
1036 interface()->send(
"HEATER 1");
1039 if(shot[ *heaterMode(loop)].to_str() ==
"Open") {
1040 interface()->sendf(
"HEATER L=2");
1041 interface()->send(
"HEATER 1");
1044 interface()->send(
"HEATER 0");
1046 void XLinearResearch700::onPowerRangeChanged(
unsigned int loop,
int ran) {
1047 interface()->sendf(
"HEATER R=%02d", ran);
1049 void XLinearResearch700::onCurrentChannelChanged(
unsigned int loop,
const shared_ptr<XChannel> &ch) {
1051 void XLinearResearch700::onExcitationChanged(
const shared_ptr<XChannel> &,
int exc) {
1052 interface()->sendf(
"EXCITATION %d", exc);
1057 assert(list.size() == 1);
1058 shared_ptr<XChannel> ch0 = static_pointer_cast<
XChannel>(list.at(0));
1060 interface()->query(
"GET 6");
1061 int range, exc, vexc, fil, mode, ll, snum;
1062 if(interface()->scanf(
"%1dR,%1dE,%3d%%,%1dF,%1dM,%1dL,%2dS", &range, &exc, &vexc, &fil, &mode, &ll, &snum) != 7)
1066 tr[ *powerRange(0)] = range;
1067 tr[ *ch0->excitation()] = exc;
1072 XKE2700w7700::XKE2700w7700(
const char *name,
bool runtime,
1073 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
1076 {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10"},
1082 interface()->send(
"TRAC:CLE");
1083 interface()->send(
"INIT:CONT OFF");
1084 interface()->send(
"TRIG:SOUR IMM");
1085 interface()->send(
"TRIG:COUN 1");
1088 int ch = atoi(channel->getName().c_str());
1089 interface()->sendf(
"ROUT:CLOS (@1%1d%1d)", ch / 10, ch % 10);
1090 interface()->query(
"READ?");
1092 if(interface()->scanf(
"%lf", &x) != 1)