58#ifndef guWhiteboard_FSMControlStatus_DEFINED
59#define guWhiteboard_FSMControlStatus_DEFINED
60#define guWhiteboard_FSMNames_DEFINED
61#define guWhiteboard_FSMNames_DEFINED
70#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
110 void set(
int fsm,
bool value) { value ?
set(fsm) :
clr(fsm); }
113 void reset() { memset(
this, 0,
sizeof(*
this)); }
118#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
125 std::ostringstream ss;
137 std::istringstream iss(str);
139 if (getline(iss, token,
','))
142 while (getline(iss, token,
','))
144 size_t i =
static_cast<size_t>(atol(token.c_str()));
159 PROPERTY(uint16_t, startoffs)
164 FSMNames(uint16_t startoffs = 0,
const char *
names = NULLPTR): _startoffs(startoffs)
168 else _names[i++] =
'\0';
175 memcpy(_names, other._names,
sizeof(_names));
185 const char *
end() {
return &_names[
sizeof(_names)]; }
188 char *
next_name(
const char *name = NULLPTR) {
if (!name)
return names();
while (name <
end() && *name++) {}
return const_cast<char *
>(name); }
191 char *
next_slot(
const char *name = NULLPTR) {
while (*(name =
next_name(name)) && name <
end()) {}
return const_cast<char *
>(name); }
201 if (n <= 0)
return NULLPTR;
202 gu_strlcpy(pos, name,
size_t(n));
206#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
213 std::stringstream ss;
225 std::istringstream iss(str);
227 if (getline(iss, token,
','))
229 set_startoffs(
static_cast<uint16_t
>(atoi(token.c_str())));
230 while (getline(iss, token,
','))
232 int len = int(token.length());
235 strcpy(dst, token.c_str());
240 else set_startoffs(0);
288#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
295 std::stringstream ss;
296 size_t sizeAtLastValidState = 0;
299 ss << static_cast<unsigned>(state) << ((machineID < (
STATE_BYTE_SIZE-1))?
"," :
"");
301 sizeAtLastValidState = ss.str().size() -
static_cast<size_t>(((machineID < (
STATE_BYTE_SIZE-1))? 1 : 0));
304 std::string message = ss.str();
305 message.erase(sizeAtLastValidState, message.size()-sizeAtLastValidState);
313 std::istringstream iss(states);
315 uint8_t machineID = 0;
317 getline(iss, token,
',');
Class for controlling and getting the status of FSMs.
FSMControlStatus(const FSMControlStatus &other)
copy constructor
FSMControlStatus(const std::string &names)
string constructor
void set(int fsm, bool value)
machine control/status setter / clearer
void clr(int fsm)
machine control/status clearer
bool operator==(const FSMControlStatus &other) const
comparison operator
std::string description() const
convert to a string
FSMControlType command() const
command getter
const FSMControlStatus & operator=(const FSMControlStatus &other)
assignment operator
FSMControlStatus(FSMControlType t=FSMStatus)
designated constructor
void set(int fsm)
machine control/status setter
void reset()
clear all machines and reset back to status
bool get(int fsm) const
machine status setter
void set_command(FSMControlType command)
command setter
void from_string(const std::string &str)
convert from a string
Class for transmitting machine names over the whiteboard.
int available_space(const char *pos)
return the available space after a given pointer
char * names()
names getter
char * next_name(const char *name=NULLPTR)
get the next name
char * add_name(char *name)
try to add a new name
std::string description()
convert to a string
char * next_slot(const char *name=NULLPTR)
get the next empty slot
const char * end()
end of string
FSMNames(const FSMNames &other)
copy constructor
FSMNames(uint16_t startoffs=0, const char *names=NULLPTR)
designated constructor
const FSMNames & operator=(const FSMNames &other)
assignment operator
FSMNames(std::string names)
string constructor
void from_string(const std::string &str)
convert from a string
Class for transmitting machine names over the whiteboard.
void setStateForMachineID(uint8_t machineID, uint8_t state)
Record the given state for the given Machine ID.
const FSMState & operator=(const FSMState &other)
assignment operator
uint8_t getStateForMachineID(uint8_t machineID)
names getter
void from_string(const std::string &states)
convert from a string
std::string description()
convert to a string
FSMState(const FSMState &other)
copy constructor
FSMState()
designated constructor
void reset()
Reset all machines to INVALIDMACHINE.
FSMState(std::string states)
string constructor
FSMControlType
command for ControlStatus
@ FSMStatus
check status only
Finite State Machine Control and Status information.
Idempotent Message publicising the state -about to be executed- (0-254) of up-to the first 128 machin...
union type that is used to store data in shared memory
#define CONTROLSTATUS_GET_CMD(s)
#define CONTROLSTATUS_CLR_FSM(s, fsm)
#define CONTROLSTATUS_GET_FSM(s, fsm)
#define CONTROLSTATUS_SET_CMD(s, cmd)
#define CONTROLSTATUS_BIT_SIZE
#define CONTROLSTATUS_SET_FSM(s, fsm)
#define CONTROLSTATUS_NUM_FSMS
#define STATESTATUS_GET_STATE(s, machineID)
#define STATESTATUS_SET_STATE(s, machineID, state)