userqdppms.cpp
1 /***************************************************************************
2  Copyright (C) 2002-2016 Shota Suetsugu and Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #include "userqdppms.h"
15 #include "charinterface.h"
16 
17 
18 REGISTER_TYPE(XDriverList, QDPPMS6000, "Quantum Design PPMS low-level interface");
19 
20 XQDPPMS6000::XQDPPMS6000(const char *name, bool runtime,
21  Transaction &tr_meas, const shared_ptr<XMeasure> &meas) :
22  XCharDeviceDriver<XQDPPMS>(name, runtime, ref(tr_meas), meas) {
23  interface()->setEOS("");
24  interface()->setSerialEOS("\r\n");
25 }
26 
27 void
28 XQDPPMS6000::setField(double field, double rate, int approach_mode, int magnet_mode){
29  interface()->sendf("FIELD %f %f %d %d", field*1e4, rate*1e4, approach_mode, magnet_mode);
30 }
31 
32 void
33 XQDPPMS6000::setPosition(double position, int mode, int slow_down_code){
34  interface()->sendf("MOVE %f %d %d", position, mode, slow_down_code);
35 }
36 
37 void
38 XQDPPMS6000::setTemp(double temp, double rate, int approach_mode){
39  if(temp>0){
40  interface()->sendf("TEMP %f %f %d", temp, rate, approach_mode);
41  }
42  else{
43  interface()->send("SHUTDOWN");
44  }
45 }
46 
47 double
48 XQDPPMS6000::getField(){
49  double magnet_field;
50  interface()->query("GetDat? 4");
51  if( interface()->scanf("4,%*f,%lf", &magnet_field) != 1)
52  throw XInterface::XConvError(__FILE__, __LINE__);
53  return magnet_field;
54 }
55 
56 double
57 XQDPPMS6000::getPosition(){
58  double sample_position;
59  interface()->query("GetDat? 8");
60  if( interface()->scanf("8,%*f,%lf", &sample_position) != 1)
61  throw XInterface::XConvError(__FILE__, __LINE__);
62  return sample_position;
63 }
64 
65 double
66 XQDPPMS6000::getTemp(){
67  double sample_temp;
68  interface()->query("GetDat? 2");
69  if( interface()->scanf("2,%*f,%lf", &sample_temp) != 1)
70  throw XInterface::XConvError(__FILE__, __LINE__);
71  return sample_temp;
72 }
73 
74 double
75 XQDPPMS6000::getUserTemp(){
76  double sample_user_temp;
77  int is_user_temp;
78  interface()->query("USERTEMP?");
79  if( interface()->scanf("%d,%*f,%*f,%*f,%*f",&is_user_temp) != 1)
80  throw XInterface::XConvError(__FILE__, __LINE__);
81  if(is_user_temp){
82  int user_temp_channel = lrint(pow(2,is_user_temp));
83  interface()->queryf("GetDat? %d", user_temp_channel);
84  if( interface()->scanf("%*d,%*f,%lf", &sample_user_temp) != 1)
85  throw XInterface::XConvError(__FILE__, __LINE__);
86  }
87  else{
88  sample_user_temp = 0.0;
89  }
90  return sample_user_temp;
91 }
92 
93 double
94 XQDPPMS6000::getHeliumLevel(){
95  double helium_level;
96  interface()->query("LEVEL?");
97  if( interface()->scanf("%lf,%*f", &helium_level) != 1)
98  throw XInterface::XConvError(__FILE__, __LINE__);
99  return helium_level;
100 }
101 
102 int
103 XQDPPMS6000::getStatus(){
104  int status;
105  interface()->query("GetDat? 1");
106  if( interface()->scanf("1,%*f,%d", &status) != 1)
107  throw XInterface::XConvError(__FILE__, __LINE__);
108  return status;
109 }

Generated for KAME4 by  doxygen 1.8.3