Added requiresStoppedTargetState() member function to TargetController command classes.
The TargetController will use this to determine whether to stop the target before handling a given command.
This commit is contained in:
@@ -36,6 +36,10 @@ namespace Bloom::TargetController::Commands
|
|||||||
return Command::type;
|
return Command::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] virtual bool requiresStoppedTargetState() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline std::atomic<CommandIdType> lastCommandId = 0;
|
static inline std::atomic<CommandIdType> lastCommandId = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,5 +35,9 @@ namespace Bloom::TargetController::Commands
|
|||||||
[[nodiscard]] CommandType getType() const override {
|
[[nodiscard]] CommandType getType() const override {
|
||||||
return ReadTargetMemory::type;
|
return ReadTargetMemory::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,9 @@ namespace Bloom::TargetController::Commands
|
|||||||
[[nodiscard]] CommandType getType() const override {
|
[[nodiscard]] CommandType getType() const override {
|
||||||
return ReadTargetRegisters::type;
|
return ReadTargetRegisters::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,5 +13,9 @@ namespace Bloom::TargetController::Commands
|
|||||||
[[nodiscard]] CommandType getType() const override {
|
[[nodiscard]] CommandType getType() const override {
|
||||||
return ResetTarget::type;
|
return ResetTarget::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,9 @@ namespace Bloom::TargetController::Commands
|
|||||||
[[nodiscard]] CommandType getType() const override {
|
[[nodiscard]] CommandType getType() const override {
|
||||||
return ResumeTargetExecution::type;
|
return ResumeTargetExecution::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,5 +21,9 @@ namespace Bloom::TargetController::Commands
|
|||||||
[[nodiscard]] CommandType getType() const override {
|
[[nodiscard]] CommandType getType() const override {
|
||||||
return WriteTargetRegisters::type;
|
return WriteTargetRegisters::type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,6 +285,10 @@ namespace Bloom::TargetController
|
|||||||
throw Exception("No handler registered for this command.");
|
throw Exception("No handler registered for this command.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command->requiresStoppedTargetState() && this->lastTargetState != TargetState::STOPPED) {
|
||||||
|
this->target->stop();
|
||||||
|
}
|
||||||
|
|
||||||
this->registerCommandResponse(
|
this->registerCommandResponse(
|
||||||
commandId,
|
commandId,
|
||||||
this->commandHandlersByCommandType.at(commandType)(*(command.get()))
|
this->commandHandlersByCommandType.at(commandType)(*(command.get()))
|
||||||
|
|||||||
Reference in New Issue
Block a user