TACOS/include/sta/README.md
2024-11-20 18:49:11 +01:00

2.6 KiB

TACOS.hpp

The TACOS API is defined in the tacos.hpp, in normal use cases you should only need to include this file.

Functions

uint16_t getState()

Retrieves the current state of the TACOS state machine.


void requestState(uint32_t from, uint32_t to, uint32_t lockout = 0, bool publish = true)

Requests a state transition. Invalid state transitions will be dismissed. First come, first serve.

  • Parameters:
    • from: The starting state for the transition.
    • to: The target state to transition to.
    • lockout: (Optional) A timer to block further transitions.
    • publish: (Optional) Whether to publish the state transition to the CAN bus.
void forceState(uint32_t from, uint32_t to, uint32_t lockout = 0, bool publish = true)

Forces a state transition. Will be ignored if already in the given state. Triggers instantly.

  • Parameters:
    • from: The starting state for the transition.
    • to: The target state to transition to.
    • lockout: (Optional) A timer to block further transitions.
    • publish: (Optional) Whether to publish the state transition to the CAN bus.

void setStateTimed(uint32_t from, uint32_t to, uint32_t millis, uint32_t lockout = 0, bool publish = false)

Requests a state transition after a specified time.

  • Parameters:
    • from: The starting state.
    • to: The target state.
    • millis: The wait time in milliseconds before requesting the transition.
    • lockout: (Optional) A timer for blocking subsequent transitions.

template<typename T, typename ... Args> std::shared_ptr<T> addThread(std::set<uint16_t> states, Args ... args)

Registers a new thread to be run by TACOS.

  • Template Parameters:
    • T: The class type of the thread, which should inherit from TacosThread.
  • Parameters:
    • states: A set of states in which the thread should be active.
    • args: The constructor arguments for the thread class.

CAN Bus Functions (Conditional)

The following functions are available only if STA_TACOS_CAN_BUS_ENABLED is defined:

bool queueCanBusMsg(CanSysMsg & msg, uint32_t timeout)

Queues a message to be sent over the CAN bus.

  • Parameters:
    • msg: The message to be sent.
    • timeout: The maximum time to wait for sending the message.

bool publishState(uint32_t from, uint32_t to, uint32_t timeout = 0)

Publishes a state transition message to the CAN bus.

  • Parameters:
    • from: The starting state for the transition.
    • to: The target state.
    • timeout: (Optional) A timeout for CAN communication.