1
0
forked from ROMEO/nexosim

Add support for simulation timeouts

This commit is contained in:
Serge Barral
2024-11-08 15:15:28 +01:00
parent c6fd4d90c4
commit e6901386cf
17 changed files with 468 additions and 153 deletions

View File

@ -11,19 +11,20 @@ enum ErrorCode {
INTERNAL_ERROR = 0;
SIMULATION_NOT_STARTED = 1;
SIMULATION_TERMINATED = 2;
SIMULATION_DEADLOCK = 3;
SIMULATION_MODEL_ERROR = 4;
SIMULATION_PANIC = 5;
SIMULATION_BAD_QUERY = 6;
SIMULATION_TIME_OUT_OF_RANGE = 7;
MISSING_ARGUMENT = 10;
INVALID_TIME = 11;
INVALID_DURATION = 12;
INVALID_PERIOD = 13;
INVALID_MESSAGE = 14;
INVALID_KEY = 15;
SOURCE_NOT_FOUND = 20;
SINK_NOT_FOUND = 21;
SIMULATION_TIMEOUT = 3;
SIMULATION_DEADLOCK = 4;
SIMULATION_MODEL_ERROR = 5;
SIMULATION_PANIC = 6;
SIMULATION_BAD_QUERY = 7;
SIMULATION_TIME_OUT_OF_RANGE = 8;
MISSING_ARGUMENT = 20;
INVALID_TIME = 30;
INVALID_DURATION = 31;
INVALID_PERIOD = 32;
INVALID_MESSAGE = 33;
INVALID_KEY = 34;
SOURCE_NOT_FOUND = 40;
SINK_NOT_FOUND = 41;
}
message Error {

View File

@ -339,19 +339,20 @@ pub enum ErrorCode {
InternalError = 0,
SimulationNotStarted = 1,
SimulationTerminated = 2,
SimulationDeadlock = 3,
SimulationModelError = 4,
SimulationPanic = 5,
SimulationBadQuery = 6,
SimulationTimeOutOfRange = 22,
MissingArgument = 7,
InvalidTime = 8,
InvalidDuration = 9,
InvalidPeriod = 10,
InvalidMessage = 11,
InvalidKey = 12,
SourceNotFound = 20,
SinkNotFound = 21,
SimulationTimeout = 3,
SimulationDeadlock = 4,
SimulationModelError = 5,
SimulationPanic = 6,
SimulationBadQuery = 7,
SimulationTimeOutOfRange = 8,
MissingArgument = 20,
InvalidTime = 30,
InvalidDuration = 31,
InvalidPeriod = 32,
InvalidMessage = 33,
InvalidKey = 34,
SourceNotFound = 40,
SinkNotFound = 41,
}
impl ErrorCode {
/// String value of the enum field names used in the ProtoBuf definition.
@ -363,6 +364,7 @@ impl ErrorCode {
ErrorCode::InternalError => "INTERNAL_ERROR",
ErrorCode::SimulationNotStarted => "SIMULATION_NOT_STARTED",
ErrorCode::SimulationTerminated => "SIMULATION_TERMINATED",
ErrorCode::SimulationTimeout => "SIMULATION_TIMEOUT",
ErrorCode::SimulationDeadlock => "SIMULATION_DEADLOCK",
ErrorCode::SimulationModelError => "SIMULATION_MODEL_ERROR",
ErrorCode::SimulationPanic => "SIMULATION_PANIC",
@ -384,6 +386,7 @@ impl ErrorCode {
"INTERNAL_ERROR" => Some(Self::InternalError),
"SIMULATION_NOT_STARTED" => Some(Self::SimulationNotStarted),
"SIMULATION_TERMINATED" => Some(Self::SimulationTerminated),
"SIMULATION_TIMEOUT" => Some(Self::SimulationTimeout),
"SIMULATION_DEADLOCK" => Some(Self::SimulationDeadlock),
"SIMULATION_MODEL_ERROR" => Some(Self::SimulationModelError),
"SIMULATION_PANIC" => Some(Self::SimulationPanic),

View File

@ -38,8 +38,10 @@ fn map_execution_error(error: ExecutionError) -> Error {
ExecutionError::Panic(_) => ErrorCode::SimulationPanic,
ExecutionError::BadQuery => ErrorCode::SimulationBadQuery,
ExecutionError::Terminated => ErrorCode::SimulationTerminated,
ExecutionError::Timeout => ErrorCode::SimulationTimeout,
ExecutionError::InvalidTargetTime(_) => ErrorCode::InvalidTime,
};
let error_message = error.to_string();
to_error(error_code, error_message)