Attach a condition associated with a state transition
#include <ha/ham.h> ham_condition_t *ham_condition_state( ham_entity_t *ehdl, const char *cname, unsigned fromstate, unsigned tostate, unsigned flags );
libham
This condition is triggered when the specified entity changes from a state matching fromstate to a state matching tostate. CONDSTATEANY can be used to specify a wild card signifying any STATE. The matching of states is based on either an explicit match or special conditions explained in the Flags section below.
The ehdl argument is an entity handle obtained either:
or:
Standard flags that are applicable for conditions are also valid here. (See ham_condition() for more details). In addition, the following flags are also defined:
/* special condition flags */ HCONDSTATEFROMSET /* from state is a set */ HCONDSTATETOSET /* to state is a set */ HCONDSTATEFROMINV /* invert from state set */ HCONDSTATETOINV /* invert to state set */
States can be given using:
If fromstate or tostate refers to a set, the corresponding flag HCONDSTATEFROMSET or HCONDSTATETOSET must be set.
If you want fromstate or tostate to refer to the logical negation of a set of states define HCONDSTATEFROMINV or HCONDSTATETOINV in flags. This would logically invert the set of states specified (equivalent to saying “any state other than this set”).
The connection to the HAM is invalid. This happens when the process that opened the connection (using ham_connect()) and the process that's calling ham_condition() aren't the same.
In addition to the above errors, the HAM returns any error it encounters while servicing this request.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
ham_condition(), ham_condition_raise(), ham_attach() ham_attach_self() ham_entity() ham_entity_control() ham_entity_handle() ham_entity_handle_free() ham_entity_node()