3 #ifndef siglentSDG_parsers_hpp
4 #define siglentSDG_parsers_hpp
7 #include <mx/ioutils/stringUtils.hpp>
23 const std::string & strRead
26 std::vector<std::string> v;
28 mx::ioutils::parseStringVector(v, strRead,
":, \n");
32 if(v.size() < 2)
return -1;
34 if(v[1] !=
"OUTP")
return -2;
36 if(v[0][0] !=
'C')
return -3;
37 if(v[0].size() < 2)
return -4;
38 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
40 if(v.size() < 3)
return -5;
42 if(v[2] ==
"OFF") output = 0;
43 else if(v[2] ==
"ON") output = 1;
48 #define SDG_PARSEERR_WVTP (-6)
71 const std::string & strRead
85 std::vector<std::string> v;
87 mx::ioutils::parseStringVector(v, strRead,
":, \n");
90 if(v.size() < 4)
return -1;
92 if(v[1] !=
"BSWV")
return -2;
94 if(v[0][0] !=
'C')
return -3;
95 if(v[0].size() < 2)
return -4;
96 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
98 if(v[2] !=
"WVTP")
return -5;
105 if(v.size() < 6)
return -7;
107 if(v[4] !=
"OFST")
return -8;
109 ofst = mx::ioutils::convertFromString<double>(v[5]);
114 if(v.size() < 20)
return -9;
116 if(v[4] !=
"FRQ")
return -10;
117 freq = mx::ioutils::convertFromString<double>(v[5]);
119 if(v[6] !=
"PERI")
return -11;
120 peri = mx::ioutils::convertFromString<double>(v[7]);
122 if(v[8] !=
"AMP")
return -12;
123 amp = mx::ioutils::convertFromString<double>(v[9]);
125 if(v[10] !=
"AMPVRMS")
return -13;
126 ampvrms = mx::ioutils::convertFromString<double>(v[11]);
128 if(v[12] !=
"OFST")
return -14;
129 ofst = mx::ioutils::convertFromString<double>(v[13]);
131 if(v[14] !=
"HLEV")
return -15;
132 hlev = mx::ioutils::convertFromString<double>(v[15]);
134 if(v[16] !=
"LLEV")
return -16;
135 llev = mx::ioutils::convertFromString<double>(v[17]);
139 if(v[18] !=
"PHSE")
return -17;
140 phse = mx::ioutils::convertFromString<double>(v[19]);
145 if(v[20] !=
"WIDTH")
return -18;
146 wdth = mx::ioutils::convertFromString<double>(v[21]);
163 const std::string & strRead
168 std::vector<std::string> v;
170 mx::ioutils::parseStringVector(v, strRead,
":, \n");
173 if(v.size() < 4)
return -1;
175 if(v[1] !=
"MDWV")
return -2;
177 if(v[0][0] !=
'C')
return -3;
178 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
180 if(v[2] !=
"STATE")
return -4;
197 const std::string & strRead
202 std::vector<std::string> v;
204 mx::ioutils::parseStringVector(v, strRead,
":, \n");
207 if(v.size() < 4)
return -1;
209 if(v[1] !=
"SWWV")
return -2;
211 if(v[0][0] !=
'C')
return -3;
212 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
214 if(v[2] !=
"STATE")
return -4;
231 const std::string & strRead
236 std::vector<std::string> v;
238 mx::ioutils::parseStringVector(v, strRead,
":, \n");
241 if(v.size() < 4)
return -1;
243 if(v[1] !=
"BTWV")
return -2;
245 if(v[0][0] !=
'C')
return -3;
246 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
248 if(v[2] !=
"STATE")
return -4;
264 const std::string & strRead
270 std::vector<std::string> v;
272 mx::ioutils::parseStringVector(v, strRead,
":, \n");
275 if(v.size() < 4)
return -1;
277 if(v[1] !=
"ARWV")
return -2;
279 if(v[0][0] !=
'C')
return -3;
280 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
282 if(v[2] !=
"INDEX")
return -4;
283 index = mx::ioutils::convertFromString<int>(v[3]);
298 const std::string & strRead
305 std::vector<std::string> v;
307 mx::ioutils::parseStringVector(v, strRead,
":, \n");
310 if(v.size() < 3)
return -1;
312 if(v[1] !=
"SYNC")
return -2;
314 if(v[0][0] !=
'C')
return -3;
315 channel = mx::ioutils::convertFromString<int>(v[0].substr(1, v[0].size()-1));
322 else if(v[2] ==
"OFF")
int parseOUTP(int &channel, int &output, const std::string &strRead)
Parse the SDG response to the OUTP query.
int parseSWWV(int &channel, std::string &state, const std::string &strRead)
Parse the SDG response to the SWWV query.
int parseMDWV(int &channel, std::string &state, const std::string &strRead)
Parse the SDG response to the MDWV query.
int parseBSWV(int &channel, std::string &wvtp, double &freq, double &peri, double &, double &vrms, double &ofst, double &hlev, double &llev, double &phse, double &wdth, const std::string &strRead)
Parse the SDG response to the BSWV query.
int parseBTWV(int &channel, std::string &state, const std::string &strRead)
Parse the SDG response to the BTWV query.
int parseARWV(int &channel, int &index, const std::string &strRead)
Parse the SDG response to the ARWV query.
int parseSYNC(int &channel, bool &sync, const std::string &strRead)
Parse the SDG response to the SYNC query.
#define SDG_PARSEERR_WVTP