KM3NeT CLB
2.0
KM3NeT CLB v2 Embedded Software
|
The CLB stare module tracks is responsible for state management of the various sub-systems on the CLB. More...
#include <stdint.h>
#include <stdbool.h>
#include "cfg_subsys.h"
#include "util/macro.h"
#include "kernel/err.h"
#include "appcode.h"
Go to the source code of this file.
Macros | |
#define | E_CLBSTATE_STATECHANGE ( E_CLBSTATE + 0x01 ) |
Invalid state change. | |
#define | E_CLBSTATE_STATECHANGE_DESCR "Invalid State Change" |
#define | CLB_SUB_ALL 255 |
Indicates all subsystems. Can be used in clbStateGoto. | |
#define | CLB_STATUS_PENDING BIT(0) |
Indicates that the subsystem is in transit to a new state. | |
#define | CLB_STATUS_ERROR BIT(1) |
#define | SUBS(IDX, ID, NAME) void _subs ## NAME ## ExecEvent (ClbEvent event); |
#define | SUBS(IDX, ID, NAME) bool _subs ## NAME ## Update (ClbState state, uint32_t time) __attribute__((weak)); |
Enumerations | |
enum | ClbState { clbStateUndefined = 0, clbStateIdle = 1, clbStateStandBy = 2, clbStateReady = 3, clbStatePaused = 4, clbStateRunning = 5 } |
Various states. More... | |
enum | ClbEvent { clbEventNone = -1, clbEventBoot = 0, clbEventInit = 1, clbEventConfigure = 2, clbEventStart = 3, clbEventPause = 4, clbEventContinue = 5, clbEventStop = 6, clbEventQuit = 7, clbEventReset = 8 } |
All state change events. More... | |
Functions | |
void | _subsSysExecEvent (ClbEvent event) |
void | _subsNetExecEvent (ClbEvent event) |
void | _subsOptExecEvent (ClbEvent event) |
void | _subsAcsExecEvent (ClbEvent event) |
void | _subsInsExecEvent (ClbEvent event) |
bool | _subsSysUpdate (ClbState state, uint32_t time) |
bool | _subsNetUpdate (ClbState state, uint32_t time) |
bool | _subsOptUpdate (ClbState state, uint32_t time) |
bool | _subsAcsUpdate (ClbState state, uint32_t time) |
bool | _subsInsUpdate (ClbState state, uint32_t time) |
void | clbStateInit () |
Initializes the state machine. | |
bool | clbEvent (int idx, ClbEvent event) |
Request a subsystem to go to a certain state. More... | |
void | clbAutoEventSeq (ClbEvent *events, int seqLen) |
Executes an autonomous a sequence of events. More... | |
void | _clbStateUpdate (int idx, ClbEvent event, uint8_t status) |
Invoked by the subsystem to indicate a state change has happened. More... | |
int | clbSubId (int idx) |
Returns the subsystem ID code for the provided index. More... | |
void | _clbStateError (int idx, int error, const char *message, const char *name) |
Invoked by subsystem to indicate an error happened. More... | |
static void | _clbStateModErr (int idx) |
Invoked by subsystem to indicate an error happened. More... | |
bool | clbStateError (int idx, int *code, const char **message) |
Retrieves the error of a subsystem (if any). More... | |
ClbState | clbState (int idx) |
Returns the current clbSubState for the specified subsystem. More... | |
uint8_t | clbStatus (int idx) |
Returns the current subsystem status. More... | |
void | clbClearErrorState (int idx) |
Clears the error state of the specific subsystem. More... | |
void | clbUpdateSubsys () |
Invoked the update method on each subsystem. | |
Variables | |
const char *const | clbSubsystemNames [5] |
Contains a list of all the subsystems. | |
const char *const | clbStateNames [6] |
Contains list of the state names. | |
uint8_t | clbSys2Idx [6] |
Mapping from subsystem ID to index. | |
const char *const | clbEventNames [9] |
All state change event names. | |
The CLB stare module tracks is responsible for state management of the various sub-systems on the CLB.
It also tracks the error of each subsystem. CLB State machine
The following state machine is used:
* +-----------+ +-----------+ * | | | | * | Undefined |----Boot---->| Idle | * | | | | * +-----------+ +-----------+ * ^ | * Reset Init * | V * +-----------+ +-----------+ * | |<-Configure--| | * | Ready | | StandBy | * | |----Quit---->| | * +-----------+ +-----------+ * | ^ * Start Stop * V | * +-----------+ +-----------+ * | |<--Continue--| | * | Running | | Paused | * | |---Pause---->| | * +-----------+ +-----------+ *
Definition in file clbstate.h.
enum ClbEvent |
All state change events.
Definition at line 88 of file clbstate.h.
enum ClbState |
Various states.
Definition at line 59 of file clbstate.h.
void _clbStateError | ( | int | idx, |
int | error, | ||
const char * | message, | ||
const char * | name | ||
) |
Invoked by subsystem to indicate an error happened.
The state will automatically be set to clbStateError.
idx | The subsystem index. |
error | The error code |
message | The message, if any |
Definition at line 258 of file clbstate.c.
|
inlinestatic |
Invoked by subsystem to indicate an error happened.
The state will automatically be set to clbStateError. This copies the error from the error module and clears it.
idx | The subsystem index. |
Definition at line 189 of file clbstate.h.
void _clbStateUpdate | ( | int | idx, |
ClbEvent | event, | ||
uint8_t | status | ||
) |
Invoked by the subsystem to indicate a state change has happened.
idx | The subsystem index which the state change was effected on |
event | The event triggered |
status | The current status |
Definition at line 204 of file clbstate.c.
void clbAutoEventSeq | ( | ClbEvent * | events, |
int | seqLen | ||
) |
Executes an autonomous a sequence of events.
Change updates are suppressed during this operation.
events | A list of events to execute |
seqLen | The number of events. |
Definition at line 317 of file clbstate.c.
void clbClearErrorState | ( | int | idx | ) |
Clears the error state of the specific subsystem.
idx | The index of the subsystem. |
Definition at line 241 of file clbstate.c.
bool clbEvent | ( | int | idx, |
ClbEvent | event | ||
) |
Request a subsystem to go to a certain state.
idx | The index, or CLB_SUB_ALL for all subsystems. |
event | The event to execute |
Definition at line 221 of file clbstate.c.
ClbState clbState | ( | int | idx | ) |
Returns the current clbSubState for the specified subsystem.
idx | The subsystem index to request the state of. |
Definition at line 92 of file clbstate.c.
bool clbStateError | ( | int | idx, |
int * | code, | ||
const char ** | message | ||
) |
Retrieves the error of a subsystem (if any).
idx | Subsystem index |
code | Pointer in which the code will be written |
message | Pointer to which the message will be set |
true | Subsystem has an error |
false | Subsystem does not have an error |
Definition at line 106 of file clbstate.c.
uint8_t clbStatus | ( | int | idx | ) |
Returns the current subsystem status.
idx | The subsystem index to request the state of. |
Definition at line 118 of file clbstate.c.
int clbSubId | ( | int | idx | ) |
Returns the subsystem ID code for the provided index.
idx | Subsystem index. |
Definition at line 99 of file clbstate.c.