Add RST command, parse command tree from root for each line

This commit is contained in:
Jan Käberich 2024-04-07 12:54:42 +02:00
parent 124feb5b6b
commit bb66883de2
4 changed files with 33 additions and 20 deletions

View file

@ -5,7 +5,6 @@
SCPI::SCPI() :
SCPINode("")
{
lastNode = this;
add(new SCPICommand("*LST", nullptr, [=](QStringList){
QString list;
createCommandList("", list);
@ -97,16 +96,19 @@ QString SCPI::getResultName(SCPI::Result r)
void SCPI::input(QString line)
{
auto cmds = line.split(";");
SCPINode *lastNode = this;
for(auto cmd : cmds) {
if(cmd[0] == ':' || cmd[0] == '*') {
// reset to root node
lastNode = this;
if(cmd.size() > 0) {
if(cmd[0] == ':' || cmd[0] == '*') {
// reset to root node
lastNode = this;
}
if(cmd[0] == ':') {
cmd.remove(0, 1);
}
auto response = lastNode->parse(cmd, lastNode);
emit output(response);
}
if(cmd[0] == ':') {
cmd.remove(0, 1);
}
auto response = lastNode->parse(cmd, lastNode);
emit output(response);
}
}