mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-25 07:40:03 +02:00
added save pattern, printout of some of the pattern for command line
This commit is contained in:
parent
7abb18e5c8
commit
f123a280bb
@ -999,6 +999,9 @@ class Detector {
|
|||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
void setPattern(const std::string &fname, Positions pos = {});
|
void setPattern(const std::string &fname, Positions pos = {});
|
||||||
|
|
||||||
|
/** [CTB] */
|
||||||
|
void savePattern(const std::string &fname);
|
||||||
|
|
||||||
/** [CTB] */
|
/** [CTB] */
|
||||||
Result<uint64_t> getPatternIOControl(Positions pos = {}) const;
|
Result<uint64_t> getPatternIOControl(Positions pos = {}) const;
|
||||||
|
|
||||||
|
@ -1862,6 +1862,12 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
void setPattern(const std::string &fname, int detPos = -1); //
|
void setPattern(const std::string &fname, int detPos = -1); //
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes and saves pattern to file (CTB/ Moench)
|
||||||
|
* @param fname pattern file to save to
|
||||||
|
*/
|
||||||
|
void savePattern(const std::string &fname); //
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets pattern IO control (CTB/ Moench)
|
* Sets pattern IO control (CTB/ Moench)
|
||||||
* @param word 64bit word to be written, -1 gets
|
* @param word 64bit word to be written, -1 gets
|
||||||
|
@ -25,6 +25,10 @@ void Detector::loadParameters(const std::string &fname) {
|
|||||||
pimpl->retrieveDetectorSetup(fname, 0);
|
pimpl->retrieveDetectorSetup(fname, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Detector::savePattern(const std::string &fname) {
|
||||||
|
pimpl->savePattern(fname);
|
||||||
|
}
|
||||||
|
|
||||||
Result<std::string> Detector::getHostname(Positions pos) const {
|
Result<std::string> Detector::getHostname(Positions pos) const {
|
||||||
return pimpl->Parallel(&slsDetector::getHostname, pos);
|
return pimpl->Parallel(&slsDetector::getHostname, pos);
|
||||||
}
|
}
|
||||||
|
@ -3282,6 +3282,45 @@ void multiSlsDetector::setPattern(const std::string &fname, int detPos) {
|
|||||||
parallelCall(&slsDetector::setPattern, fname);
|
parallelCall(&slsDetector::setPattern, fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void multiSlsDetector::savePattern(const std::string &fname) {
|
||||||
|
std::ofstream outfile;
|
||||||
|
outfile.open(fname.c_str(), std::ios_base::out);
|
||||||
|
if (!outfile.is_open()) {
|
||||||
|
throw RuntimeError("Could not create file to save pattern");
|
||||||
|
}
|
||||||
|
// get pattern limits
|
||||||
|
auto r = getPatternLoops(-1);
|
||||||
|
// pattern words
|
||||||
|
for (int i = r[0]; i <= r[1]; ++i) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "patword 0x" << std::hex << i;
|
||||||
|
std::string cmd = os.str();
|
||||||
|
multiSlsDetectorClient(cmd, GET_ACTION, this, outfile);
|
||||||
|
}
|
||||||
|
// rest of pattern file
|
||||||
|
const std::vector<std::string> commands{
|
||||||
|
"patioctrl",
|
||||||
|
"patclkctrl",
|
||||||
|
"patlimits",
|
||||||
|
"patloop0",
|
||||||
|
"patnloop0",
|
||||||
|
"patloop1",
|
||||||
|
"patnloop1",
|
||||||
|
"patloop2",
|
||||||
|
"patnloop2",
|
||||||
|
"patwait0",
|
||||||
|
"patwaittime0",
|
||||||
|
"patwait1",
|
||||||
|
"patwaittime1",
|
||||||
|
"patwait2",
|
||||||
|
"patwaittime2",
|
||||||
|
"patmask",
|
||||||
|
"patsetbit",
|
||||||
|
};
|
||||||
|
for (const auto &cmd : commands)
|
||||||
|
multiSlsDetectorClient(cmd, GET_ACTION, this, outfile);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t multiSlsDetector::setPatternIOControl(uint64_t word, int detPos) {
|
uint64_t multiSlsDetector::setPatternIOControl(uint64_t word, int detPos) {
|
||||||
// single
|
// single
|
||||||
if (detPos >= 0) {
|
if (detPos >= 0) {
|
||||||
|
@ -1846,6 +1846,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
|||||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
|
/*! \page prototype
|
||||||
|
- <b>savepattern fn</b> save pattern to file (ascii). This also executes the pattern.
|
||||||
|
*/
|
||||||
|
descrToFuncMap[i].m_pFuncName = "savepattern";
|
||||||
|
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdPattern;
|
||||||
|
++i;
|
||||||
|
|
||||||
/*! \page prototype
|
/*! \page prototype
|
||||||
- <b>patword addr [word]</b> sets/gets 64 bit word at address addr of pattern memory. Both address and word in hex format. Advanced!
|
- <b>patword addr [word]</b> sets/gets 64 bit word at address addr of pattern memory. Both address and word in hex format. Advanced!
|
||||||
*/
|
*/
|
||||||
@ -4834,6 +4841,13 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
os << "successful";
|
os << "successful";
|
||||||
} else if (action == GET_ACTION)
|
} else if (action == GET_ACTION)
|
||||||
os << "Cannot get";
|
os << "Cannot get";
|
||||||
|
} else if (cmd == "savepattern") {
|
||||||
|
if (narg < 2) {
|
||||||
|
return helpPattern(action);
|
||||||
|
}
|
||||||
|
fname = std::string(args[1]);
|
||||||
|
myDet->savePattern(args[1]);
|
||||||
|
os << "Pattern executed and saved to " << fname;
|
||||||
} else if (cmd == "patword") {
|
} else if (cmd == "patword") {
|
||||||
|
|
||||||
if (action == PUT_ACTION) {
|
if (action == PUT_ACTION) {
|
||||||
@ -4852,10 +4866,14 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
else
|
else
|
||||||
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]);
|
return std::string("Could not scan value (hexadecimal fomat) ") + std::string(args[2]);
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternWord(addr, word, detPos) << std::dec;
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << addr << " 0x" << std::setw(16) << myDet->setPatternWord(addr, word, detPos) << std::dec;
|
||||||
} else if (action == GET_ACTION)
|
} else if (action == GET_ACTION) {
|
||||||
os << "Cannot get";
|
if (narg < 2)
|
||||||
|
return std::string("wrong usage: should specify address (hexadecimal fomat) ");
|
||||||
|
if (!sscanf(args[1], "%x", &addr))
|
||||||
|
return std::string("Could not scan address (hexadecimal fomat) ") + std::string(args[1]);
|
||||||
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << addr << " 0x" << std::setw(16) << myDet->setPatternWord(addr, -1, detPos) << std::dec;
|
||||||
|
}
|
||||||
} else if (cmd == "patioctrl") {
|
} else if (cmd == "patioctrl") {
|
||||||
//get word from stdin
|
//get word from stdin
|
||||||
|
|
||||||
@ -4869,7 +4887,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternIOControl(word, detPos);
|
myDet->setPatternIOControl(word, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternIOControl(-1, detPos) << std::dec;
|
os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->setPatternIOControl(-1, detPos) << std::dec;
|
||||||
} else if (cmd == "patclkctrl") {
|
} else if (cmd == "patclkctrl") {
|
||||||
//get word from stdin
|
//get word from stdin
|
||||||
|
|
||||||
@ -4883,7 +4901,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternClockControl(word, detPos);
|
myDet->setPatternClockControl(word, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternClockControl(-1, detPos) << std::dec;
|
os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->setPatternClockControl(-1, detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "patlimits") {
|
} else if (cmd == "patlimits") {
|
||||||
//get start, stop from stdin
|
//get start, stop from stdin
|
||||||
@ -4905,7 +4923,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto r = myDet->getPatternLoops(-1, detPos);
|
auto r = myDet->getPatternLoops(-1, detPos);
|
||||||
os << std::hex << r[0] << " " << r[1];
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1];
|
||||||
} else if (cmd == "patloop0") {
|
} else if (cmd == "patloop0") {
|
||||||
//get start, stop from stdin
|
//get start, stop from stdin
|
||||||
|
|
||||||
@ -4928,7 +4946,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto r = myDet->getPatternLoops(0, detPos);
|
auto r = myDet->getPatternLoops(0, detPos);
|
||||||
os << std::hex << r[0] << " " << r[1];
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1];
|
||||||
|
|
||||||
} else if (cmd == "patloop1") {
|
} else if (cmd == "patloop1") {
|
||||||
|
|
||||||
@ -4951,7 +4969,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto r = myDet->getPatternLoops(1, detPos);
|
auto r = myDet->getPatternLoops(1, detPos);
|
||||||
os << std::hex << r[0] << " " << r[1];
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1];
|
||||||
|
|
||||||
} else if (cmd == "patloop2") {
|
} else if (cmd == "patloop2") {
|
||||||
|
|
||||||
@ -4974,7 +4992,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto r = myDet->getPatternLoops(2, detPos);
|
auto r = myDet->getPatternLoops(2, detPos);
|
||||||
os << std::hex << r[0] << " " << r[1];
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << r[0] << " 0x" << std::setw(4) << std::setfill('0') << r[1];
|
||||||
} else if (cmd == "patnloop0") {
|
} else if (cmd == "patnloop0") {
|
||||||
start = -1;
|
start = -1;
|
||||||
stop = -1;
|
stop = -1;
|
||||||
@ -5039,7 +5057,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternWaitAddr(0, addr, detPos);
|
myDet->setPatternWaitAddr(0, addr, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternWaitAddr(0, -1, detPos) << std::dec ;
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << myDet->setPatternWaitAddr(0, -1, detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "patwait1") {
|
} else if (cmd == "patwait1") {
|
||||||
|
|
||||||
@ -5053,7 +5071,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternWaitAddr(1, addr, detPos);
|
myDet->setPatternWaitAddr(1, addr, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternWaitAddr(1, -1, detPos) << std::dec ;
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << myDet->setPatternWaitAddr(1, -1, detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "patwait2") {
|
} else if (cmd == "patwait2") {
|
||||||
|
|
||||||
@ -5067,7 +5085,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternWaitAddr(2, addr, detPos);
|
myDet->setPatternWaitAddr(2, addr, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << std::hex << myDet->setPatternWaitAddr(2, -1, detPos) << std::dec ;
|
os << "0x" << std::setw(4) << std::setfill('0') << std::hex << myDet->setPatternWaitAddr(2, -1, detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "patwaittime0") {
|
} else if (cmd == "patwaittime0") {
|
||||||
|
|
||||||
@ -5121,7 +5139,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternMask(word, detPos);
|
myDet->setPatternMask(word, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "0x" << std::hex << myDet->getPatternMask(detPos) << std::dec;
|
os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->getPatternMask(detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "patsetbit") {
|
} else if (cmd == "patsetbit") {
|
||||||
if (action == PUT_ACTION) {
|
if (action == PUT_ACTION) {
|
||||||
@ -5134,7 +5152,7 @@ std::string slsDetectorCommand::cmdPattern(int narg, const char * const args[],
|
|||||||
myDet->setPatternBitMask(word, detPos);
|
myDet->setPatternBitMask(word, detPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
os << "0x" << std::hex << myDet->getPatternBitMask(detPos) << std::dec;
|
os << "0x" << std::setw(16) << std::setfill('0') << std::hex << myDet->getPatternBitMask(detPos) << std::dec;
|
||||||
|
|
||||||
} else if (cmd == "adcenable") {
|
} else if (cmd == "adcenable") {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user