8 #include "../../../tests/catch2/catch.hpp"
9 #include "../../tests/testMacrosINDI.hpp"
12 #include "../siglentSDG.hpp"
25 m_configName = device;
71 SCENARIO(
"Parsing the OUTP? response",
"[siglentSDG]" )
73 GIVEN(
"A valid response to OUTP from the SDG")
77 WHEN(
"Valid OUTP passed, off")
82 rv =
parseOUTP(channel, outp,
"C1:OUTP OFF,LOAD,HZ,PLRT,NOR");
89 WHEN(
"Valid OUTP passed, on")
94 rv =
parseOUTP(channel, outp,
"C2:OUTP ON,LOAD,HZ,PLRT,NOR");
101 WHEN(
"Valid OUTP passed, two-digit channel on")
106 rv =
parseOUTP(channel, outp,
"C35:OUTP ON,LOAD,HZ,PLRT,NOR");
113 GIVEN(
"An invalid response to OUTP from the SDG")
117 WHEN(
"Invalid OUTP passed, no sp")
122 rv =
parseOUTP(channel, outp,
"C2:OUTPON,LOAD,HZ,PLRT,NOR");
127 WHEN(
"Invalid OUTP passed, end before N in ON")
132 rv =
parseOUTP(channel, outp,
"C2:OUTP O");
137 WHEN(
"Invalid OUTP passed, end before :")
147 WHEN(
"Wrong Command Reply")
152 rv =
parseOUTP(channel, outp,
"C1:BSWV WVTP,SINE,FRQ,10HZ,PERI,0.1S,AMP,2V,AMPVRMS,0.707Vrms,OFST,0V,HLEV,1V,LLEV,-1V,PHSE,0");
159 SCENARIO(
"Parsing the BSWV? response",
"[siglentSDG]" )
161 GIVEN(
"A valid response to BSWV from the SDG")
165 WHEN(
"Valid BSWV passed")
178 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
179 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth,resp);
195 GIVEN(
"An invalid response to BSWV from the SDG")
199 WHEN(
"An invalid BSWV passed - not enough args")
212 std::string resp=
"C1:BSWV WVTP";
213 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
218 WHEN(
"An invalid BSWV passed - wrong response")
231 std::string resp=
"C1:MDWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
232 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
237 WHEN(
"An invalid BSWV passed - bad channel spec, no C")
250 std::string resp=
"X1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
251 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
256 WHEN(
"An invalid BSWV passed - bad channel spec, too short ")
269 std::string resp=
"C:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
270 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
275 WHEN(
"An invalid BSWV passed - bad WVTP indicator")
288 std::string resp=
"C1:BSWV WVTQ,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
289 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
294 WHEN(
"An invalid BSWV passed - wvtp not SINE")
307 std::string resp=
"C1:BSWV WVTP,UPIY,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
308 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
313 WHEN(
"An invalid BSWV passed - bad FRQ indicator")
326 std::string resp=
"C1:BSWV WVTP,SINE,FRZ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
327 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
332 WHEN(
"An invalid BSWV passed - bad PERI indicator")
345 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERZ,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
346 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
351 WHEN(
"An invalid BSWV passed - bad AMP indicator")
364 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,A/P,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
365 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
370 WHEN(
"An invalid BSWV passed - bad AMPVRMS indicator")
383 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,APVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
384 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
389 WHEN(
"An invalid BSWV passed - bad OFST indicator")
402 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,O,0.34V,HLEV,1.3V,LLEV,-2.567V,PHSE,4.3567";
403 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
408 WHEN(
"An invalid BSWV passed - bad HLEV indicator")
421 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLV,1.3V,LLEV,-2.567V,PHSE,4.3567";
422 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
427 WHEN(
"An invalid BSWV passed - bad LLEV indicator")
440 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,QLEV,-2.567V,PHSE,4.3567";
441 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
446 WHEN(
"An invalid BSWV passed - bad PHSE indicator")
459 std::string resp=
"C1:BSWV WVTP,SINE,FRQ,10.123HZ,PERI,0.8345S,AMP,2.567V,AMPVRMS,0.707Vrms,OFST,0.34V,HLEV,1.3V,LLEV,-2.567V,XXXXX,4.3567";
460 rv =
parseBSWV(channel, wvtp, freq, peri, amp, ampvrms, ofst, hlev, llev, phse, wdth, resp);
467 SCENARIO(
"Parsing the MDWV? response",
"[siglentSDG]" )
469 GIVEN(
"A valid response to MDWV from the SDG")
473 WHEN(
"Valid MDWV passed, with state off")
477 std::string resp=
"C1:MDWV STATE,OFF";
485 WHEN(
"Valid MDWV passed, with state on")
490 std::string resp=
"C1:MDWV STATE,ON,AM,MDSP,SINE,SRC,INT,FRQ,100HZ,DEPTH,100,CARR,WVTP,SINE,FRQ,1000HZ,AMP,4V,AMPVRMS,1.414Vrms,OFST,0V,PHSE,0";
499 GIVEN(
"An invalid response to MDWV from the SDG")
503 WHEN(
"invalid MDWV passed - too short")
507 std::string resp=
"C1:MDWV S";
513 WHEN(
"invalid MDWV passed - wrong command")
517 std::string resp=
"C1:MDWQ STATE,OFF";
523 WHEN(
"invalid MDWV passed - no C")
527 std::string resp=
"X1:MDWV STATE,OFF";
533 WHEN(
"invalid MDWV passed - no channel")
537 std::string resp=
"C:MDWV STATE,OFF";
544 WHEN(
"invalid MDWV passed - no STATE")
548 std::string resp=
"C1:MDWV STAT,OFF";
556 SCENARIO(
"Parsing the SWWV? response",
"[siglentSDG]" )
558 GIVEN(
"A valid response to SWWV from the SDG")
562 WHEN(
"Valid SWWV passed, with state off")
566 std::string resp=
"C1:SWWV STATE,OFF";
574 WHEN(
"Valid SWWV passed, with state on")
579 std::string resp=
"C1:SWWV STATE,ON,TIME,1S,STOP,1500HZ,START,500HZ,TRSR,INT,TRMD,OFF,SWMD,LINE,DIR,UP,SYM,0.000000,CARR,WVTP,SINE,FRQ,1000HZ,AMP,4V,AMPVRMS,1.414Vrms,OFST,0V,PHSE,0";
588 GIVEN(
"An invalid response to SWWV from the SDG")
592 WHEN(
"invalid SWWV passed - too short")
596 std::string resp=
"C1:SWWV S";
602 WHEN(
"invalid SWWV passed - wrong command")
606 std::string resp=
"C1:SWWQ STATE,OFF";
612 WHEN(
"invalid SWWV passed - no C")
616 std::string resp=
"X1:SWWV STATE,OFF";
622 WHEN(
"invalid SWWV passed - no channel")
626 std::string resp=
"C:SWWV STATE,OFF";
633 WHEN(
"invalid SWWV passed - no STATE")
637 std::string resp=
"C1:SWWV STAT,OFF";
646 SCENARIO(
"Parsing the BTWV? response",
"[siglentSDG]" )
648 GIVEN(
"A valid response to BTWV from the SDG")
652 WHEN(
"Valid BTWV passed, with state off")
656 std::string resp=
"C1:BTWV STATE,OFF";
664 WHEN(
"Valid BTWV passed, with state on")
669 std::string resp=
"C1:BTWV STATE,ON,PRD,0.01S,STPS,0,TRSR,INT,TRMD,OFF,TIME,1,DLAY,5.21035e-07S,GATE_NCYC,NCYC,CARR,WVTP,SINE,FRQ,1000HZ,AMP,4V,AMPVRMS,1.414Vrms,OFST,0V,PHSE,0";
678 GIVEN(
"An invalid response to BTWV from the SDG")
682 WHEN(
"invalid BTWV passed - too short")
686 std::string resp=
"C1:BTWV S";
692 WHEN(
"invalid BTWV passed - wrong command")
696 std::string resp=
"C1:BTWQ STATE,OFF";
702 WHEN(
"invalid BTWV passed - no C")
706 std::string resp=
"X1:BTWV STATE,OFF";
712 WHEN(
"invalid BTWV passed - no channel")
716 std::string resp=
"C:BTWV STATE,OFF";
723 WHEN(
"invalid BTWV passed - no STATE")
727 std::string resp=
"C1:BTWV STAT,OFF";
735 SCENARIO(
"Parsing the ARWV? response",
"[siglentSDG]" )
737 GIVEN(
"A valid response to ARWV from the SDG")
741 WHEN(
"Valid ARWV passed, with index 0")
746 std::string resp=
"C1:ARWV INDEX,0,NAME,";
754 WHEN(
"Valid ARWV passed, with index 1")
759 std::string resp=
"C2:ARWV INDEX,1,NAME,";
768 GIVEN(
"An invalid response to ARWV from the SDG")
772 WHEN(
"invalid ARWV passed - too short")
776 std::string resp=
"C1:ARWV I";
782 WHEN(
"invalid ARWV passed - wrong command")
786 std::string resp=
"C1:ARWQ INDEX,0";
792 WHEN(
"invalid ARWV passed - no C")
796 std::string resp=
"X1:ARWV INDEX,0";
802 WHEN(
"invalid ARWV passed - no channel")
806 std::string resp=
"C:ARWV INDEX,0";
813 WHEN(
"invalid ARWV passed - no INDEX")
817 std::string resp=
"C1:ARWV INDX,0";
siglentSDG_test(const std::string device)
#define XWCTEST_INDI_NEW_CALLBACK(testclass, propname)
Catch-2 tests for whether a NEW callback properly validates the input property properly.
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.
SCENARIO("Parsing the ARWV? response", "[siglentSDG]")
#define XWCTEST_SETUP_INDI_NEW_PROP(propname)