Subrack Simulator
A simple subrack simulator.
- class SubrackSimulator(**kwargs)
A simple simulator of a subrack management board web server.
- class AttributeMetadataType
Type for attribute metadata dictionary.
- __init__(**kwargs)
Initialise a new instance.
- Parameters:
kwargs (
Any
) – initial values, different from the defaults, that the simulator should take.- Raises:
AttributeError – if kwargs refer to an non-existent attribute.
- execute_command(name, argument)
Execute a command on the subrack hardware/simulator.
It works by checking for a method named f”_{name}”; that is, if the command name is “turn_on_tpms”, then it checks for a method named “_turn_on_tpms”. If it finds such a method, it calls it with the provided argument, and returns the return value.
Otherwise, it checks for a method named f”_async_{name}; for example, “_async_turn_on_tpms”. If it finds such a method, it simulates a long running command by returning “STARTED”, then letting a little time pass, then invoking the method.
- Parameters:
- Return type:
- Returns:
the return value. For synchronous commands, this is the returned value of the fully executed command. For asynchronous commands, this is the string “STARTED” or “FAILED”.
- Raises:
AttributeError – if the command method does not exist in the simulator.
- get_attribute(name)
Return the value of a simulator attribute.
- set_attribute(name, value)
Set the value of a simulator attribute.