17 #include "charinterface.h"
20 REGISTER_TYPE(
XDriverList, KE2000,
"Keithley 2000/2001 DMM");
21 REGISTER_TYPE(
XDriverList, KE2182,
"Keithley 2182 nanovolt meter");
22 REGISTER_TYPE(
XDriverList, HP34420A,
"Agilent 34420A nanovolt meter");
23 REGISTER_TYPE(
XDriverList, HP3458A,
"Agilent 3458A DMM");
24 REGISTER_TYPE(
XDriverList, HP3478A,
"Agilent 3478A DMM");
25 REGISTER_TYPE(
XDriverList, SanwaPC500,
"SANWA PC500/510/520M DMM");
26 REGISTER_TYPE(
XDriverList, SanwaPC5000,
"SANWA PC5000 DMM");
30 XString func = ( **
function())->to_str();
32 interface()->sendf(
":CONF:%s", func.c_str());
36 interface()->query(
":FETC?");
37 return interface()->toDouble();
41 interface()->query(
":READ?");
42 return interface()->toDouble();
53 XHP3458A::XHP3458A(
const char *name,
bool runtime,
54 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
56 interface()->setGPIBMAVbit(0x80);
57 interface()->setGPIBUseSerialPollOnWrite(
false);
59 const char *funcs[] = {
60 "DCV",
"ACV",
"ACDCV",
"OHM",
"OHMF",
"DCI",
"ACI",
"ACDCI",
"FREQ",
"PER",
"DSAC",
"DSDC",
"SSAC",
"SSDC",
""
62 for(
const char **func = funcs; strlen( *func); func++) {
63 tr[ *
function()].add( *func);
69 XString func = ( **
function())->to_str();
71 interface()->sendf(
"FUNC %s;ARANGE ON", func.c_str());
75 interface()->receive();
76 return interface()->toDouble();
80 interface()->query(
"END ALWAYS;OFORMAT ASCII;QFORMAT NUM;NRDGS 1;TRIG AUTO;TARM SGL");
81 return interface()->toDouble();
85 XHP3478A::XHP3478A(
const char *name,
bool runtime,
86 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
88 interface()->setGPIBUseSerialPollOnWrite(
false);
89 interface()->setGPIBMAVbit(0x01);
92 const char *funcs[] = {
93 "DCV",
"ACV",
"OHM",
"OHMF",
"DCI",
"ACI",
""
95 for(
const char **func = funcs; strlen( *func); func++) {
96 tr[ *
function()].add( *func);
102 int func = ***
function();
106 interface()->sendf(
"F%dRAZ1", func + 1);
110 interface()->receive();
111 return interface()->toDouble();
115 interface()->query(
"T3");
116 return interface()->toDouble();
119 XSanwaPC500::XSanwaPC500(
const char *name,
bool runtime,
120 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
122 interface()->setSerialBaudRate(9600);
123 interface()->setSerialStopBits(2);
126 const char *funcs[] = {
127 "AcV",
"DcV",
"Ac+DcV",
"Cx",
"Dx",
"Dx",
"TC",
"TC",
"TF",
"Ohm",
128 "Conti",
"AcA",
"DcA",
"Ac+DcA",
"Hz",
"Duty%",
"%mA",
"dB",
"?",
""
130 for(
const char **func = funcs; strlen( *func); func++) {
131 tr[ *
function()].add( *func);
133 tr[ *
function()].str(
XString(
"?"));
140 XSanwaPC500::fetch() {
143 interface()->receive(8);
144 if((interface()->buffer()[0] != 0x10) ||
145 (interface()->buffer()[1] != 0x02))
147 if((interface()->buffer()[6] != 0x00) ||
148 (interface()->buffer()[7] != 0x00))
150 const int funcs[] = {0x05, 0x06, 0x07, 0x08, 0x04, 0x14, 0x00, 0x20, 0x40, 0x80,
151 0x180, 0x201, 0x202, 0x203, 0x400, 0x800, 0x802, 0x2000
153 int f = (int)interface()->buffer()[4] + (int)interface()->buffer()[5] * 256u;
154 for(
int i = 0; i < (int)
sizeof(funcs) / (int)
sizeof(
int); i++) {
156 trans( *
function()) = i;
160 int dlen = interface()->buffer()[3] - 1;
161 interface()->receive(dlen);
162 std::vector<char> buf(dlen);
163 memcpy(&buf[0], &interface()->buffer()[0], dlen);
167 buf[dlen - 3] =
'\0';
168 if((
XString( &buf[0]) ==
"+OL") || (
XString( &buf[0]) ==
" OL")) {
171 if(
XString( &buf[0]) ==
"-OL") {
177 if(sscanf( &buf[0],
"%8lf", &x) != 1) {
181 if(sscanf( &buf[8],
"E%2lf", &e) != 1) {
184 return x * pow(10.0, e);
192 char bytes[8] = {0x10, 0x02, 0x42, 0x00, 0x00, 0x00, 0x10, 0x03};
193 interface()->write(bytes,
sizeof(bytes));
195 XSanwaPC5000::XSanwaPC5000(
const char *name,
bool runtime,
196 Transaction &tr_meas,
const shared_ptr<XMeasure> &meas) :
203 char bytes[8] = {0x10, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03};
204 interface()->write(bytes,
sizeof(bytes));