Pattern 6 levels (#493)

* separating pattern levels from command name: command line done

* separated patten level from command in examples and default pattern files in servers

* command line and server works

* python: patnloop not verified, wip

* works except for patloop (set, and get does not list properly)

* minor

* fixed tests

* added 3 more levels for ctb and moench

* wip

* minor err msg

* minor

* binaries in

* separating pattern levels from command name: command line done

* separated patten level from command in examples and default pattern files in servers

* command line and server works

* python: patnloop not verified, wip

* works except for patloop (set, and get does not list properly)

* minor

* fixed tests

* added 3 more levels for ctb and moench

* wip

* minor err msg

* minor

* binaries in

* python working

* import fix

* changed fw version for ctb and moench. binaries in

Co-authored-by: Erik Frojdh <erik.frojdh@gmail.com>
This commit is contained in:
Dhanya Thattil
2022-07-14 12:00:07 +02:00
committed by GitHub
parent 5be50785fb
commit 8fcec81a67
31 changed files with 955 additions and 643 deletions

View File

@ -2705,7 +2705,30 @@ std::string CmdProxy::PatternWord(int action) {
return os.str();
}
void CmdProxy::GetLevelAndUpdateArgIndex(int action, std::string levelSeparatedCommand, int& level, int& iArg, size_t nGetArgs, size_t nPutArgs) {
if (cmd == levelSeparatedCommand) {
++nGetArgs;
++nPutArgs;
} else {
LOG(logWARNING) << "This command is deprecated and will be removed. Please migrate to " << levelSeparatedCommand;
}
if (action == defs::GET_ACTION && args.size() != nGetArgs) {
WrongNumberOfParameters(nGetArgs);
} else if (action == defs::PUT_ACTION && args.size() != nPutArgs) {
WrongNumberOfParameters(nPutArgs);
}
if (cmd == levelSeparatedCommand) {
level = StringTo<int>(args[iArg++]);
} else {
level = cmd[cmd.find_first_of("012")] - '0';
}
}
std::string CmdProxy::PatternLoopAddresses(int action) {
if (cmd != "patlimits" && cmd != "patloop0" && cmd != "patloop1" && cmd != "patloop2" && cmd != "patloop") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
@ -2713,53 +2736,30 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of complete pattern."
<< '\n';
} else if (cmd == "patloop0") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 0."
<< '\n';
} else if (cmd == "patloop1") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 1."
<< '\n';
} else if (cmd == "patloop2") {
os << "[start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits "
"of loop 2."
} else if (cmd == "patloop") {
os << "[0-6] [start addr] [stop addr] \n\t[Ctb][Moench][Mythen3] Limits of the loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patloop."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patlimits") {
level = -1;
} else if (cmd == "patloop0") {
level = 0;
} else if (cmd == "patloop1") {
level = 1;
} else if (cmd == "patloop2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 2;
if (cmd != "patlimits") {
GetLevelAndUpdateArgIndex(action, "patloop", level, iArg, nGetArgs, nPutArgs);
}
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t =
det->getPatternLoopAddresses(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 2) {
WrongNumberOfParameters(2);
}
int start = StringTo<int>(args[0]);
int stop = StringTo<int>(args[1]);
int start = StringTo<int>(args[iArg++]);
int stop = StringTo<int>(args[iArg++]);
det->setPatternLoopAddresses(level, start, stop,
std::vector<int>{det_id});
std::vector<int>{det_id});
os << '[' << ToStringHex(start, 4) << ", " << ToStringHex(stop, 4)
<< "]\n";
<< "]\n";
} else {
throw RuntimeError("Unknown action");
}
@ -2768,50 +2768,32 @@ std::string CmdProxy::PatternLoopAddresses(int action) {
}
std::string CmdProxy::PatternLoopCycles(int action) {
if (cmd != "patnloop0" && cmd != "patnloop1" && cmd != "patnloop2" && cmd != "patnloop") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patnloop0") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 0."
<< '\n';
} else if (cmd == "patnloop1") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 1."
<< '\n';
} else if (cmd == "patnloop2") {
os << "[n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"loop 2."
if (cmd == "patnloop") {
os << "[0-6] [n_cycles] \n\t[Ctb][Moench][Mythen3] Number of cycles of "
"the loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patnloop."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patnloop0") {
level = 0;
} else if (cmd == "patnloop1") {
level = 1;
} else if (cmd == "patnloop2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patnloop", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternLoopCycles(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setPatternLoopCycles(level, StringTo<int>(args[0]),
std::vector<int>{det_id});
os << args.front() << '\n';
int nloops = StringTo<int>(args[iArg++]);
det->setPatternLoopCycles(level, nloops, std::vector<int>{det_id});
os << nloops << '\n';
} else {
throw RuntimeError("Unknown action");
}
@ -2820,42 +2802,28 @@ std::string CmdProxy::PatternLoopCycles(int action) {
}
std::string CmdProxy::PatternWaitAddress(int action) {
if (cmd != "patwait0" && cmd != "patwait1" && cmd != "patwait2" && cmd != "patwait") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwait0") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 0 address." << '\n';
} else if (cmd == "patwait1") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 1 address." << '\n';
} else if (cmd == "patwait2") {
os << "[addr] \n\t[Ctb][Moench][Mythen3] Wait 2 address." << '\n';
if (cmd == "patwait") {
os << "[0-6] [addr] \n\t[Ctb][Moench][Mythen3] Wait address for loop level provided."
<< "\n\t[Mythen3] Level options: 0-3 only.";
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
os << "Depreciated command. Use patwait.";
}
os << '\n';
} else {
int level = -1;
if (cmd == "patwait0") {
level = 0;
} else if (cmd == "patwait1") {
level = 1;
} else if (cmd == "patwait2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwait", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitAddr(level, std::vector<int>{det_id});
os << OutStringHex(t, 4) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
int addr = StringTo<int>(args[0]);
int addr = StringTo<int>(args[iArg++]);
det->setPatternWaitAddr(level, addr, std::vector<int>{det_id});
os << ToStringHex(addr, 4) << '\n';
} else {
@ -2866,50 +2834,32 @@ std::string CmdProxy::PatternWaitAddress(int action) {
}
std::string CmdProxy::PatternWaitTime(int action) {
if (cmd != "patwaittime0" && cmd != "patwaittime1" && cmd != "patwaittime2" && cmd != "patwaittime") {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "patwaittime0") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 0 time in clock "
"cycles."
<< '\n';
} else if (cmd == "patwaittime1") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 1 time in clock "
"cycles."
<< '\n';
} else if (cmd == "patwaittime2") {
os << "[n_clk] \n\t[Ctb][Moench][Mythen3] Wait 2 time in clock "
"cycles."
if (cmd == "patwaittime") {
os << "[0-6] [n_clk] \n\t[Ctb][Moench][Mythen3] Wait time in clock "
"cycles for the loop provided."
<< "\n\t[Mythen3] Level options: 0-3 only."
<< '\n';
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
os << "Depreciated command. Use patwaittime."
<< '\n';
}
} else {
int level = -1;
if (cmd == "patwaittime0") {
level = 0;
} else if (cmd == "patwaittime1") {
level = 1;
} else if (cmd == "patwaittime2") {
level = 2;
} else {
throw RuntimeError(
"Unknown command, use list to list all commands");
}
int level = -1, iArg = 0, nGetArgs = 0, nPutArgs = 1;
GetLevelAndUpdateArgIndex(action, "patwaittime", level, iArg, nGetArgs, nPutArgs);
if (action == defs::GET_ACTION) {
if (!args.empty()) {
WrongNumberOfParameters(0);
}
auto t = det->getPatternWaitTime(level, std::vector<int>{det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
if (args.size() != 1) {
WrongNumberOfParameters(1);
}
det->setPatternWaitTime(level, StringTo<uint64_t>(args[0]),
{det_id});
os << args.front() << '\n';
uint64_t waittime = StringTo<uint64_t>(args[iArg++]);
det->setPatternWaitTime(level, waittime, {det_id});
os << waittime << '\n';
} else {
throw RuntimeError("Unknown action");
}