#include /* # if !defined OLC93SU523_H # include "olc93su523.h" # endif */ #include "f93olc.h" # if !defined OLC3COMMON_H # include "olc3common.h" # endif # if !defined ACTIVEINSTANCE_H # include "activeinstance.h" # endif # if !defined STATE_H # include "state.h" # endif /* ** ActiveInstanceFirst ** ActiveInstanceNext ** ActiveInstanceDelete */ STANDARDROUTINES(ActiveInstance, AI) FUNCTION3( hcg_key ActiveInstanceCreate, const char *, ActiveInstanceName, hcg_key, ACid, const char *, CurrentState ) { hcg_key AIid; #ifdef GENV7 char databuffer[BUFSIZE]; KEYBUFFER(AIkey); KEYBUFFER(ACkey); decode(ACkey, &ACid); pr_gen_pkey("JuicePlant", AI, AIkey); sprintf(databuffer, " %s %s %.*s %.*s", AIkey, ACkey, StatesNameMaxLen, CurrentState, ActiveInstanceNameMaxLen, ActiveInstanceName); pr_add("JuicePlant", databuffer); encode(AIkey, &AIid); #else struct AI *AI_elt; AI_elt = pr_create(AI); pr_set_key(AI_elt, ACid, ACid); pr_set_str(AI_elt, State, CurrentState); pr_set_str(AI_elt, Name, ActiveInstanceName); pr_add("JuicePlant", AI, AI_elt); AIid = pr_get_key(AI_elt, AIid); #endif return AIid; } /* ** ACid and Name are read only. Set only at creation time */ GETROUTINE(hcg_key, ActiveInstance,AI,ACid) GETROUTINE(const char *,ActiveInstance,AI,Name) COPYROUTINE(ActiveInstance,AI,Name) /* ** The State can be read or written. Note, writing the state does ** not activate the action routine associated with the state. */ GETROUTINE(const char *,ActiveInstance,AI,State) COPYROUTINE(ActiveInstance,AI,State) FUNCTION2( void ActiveInstanceSetState, hcg_key, AIid, const char *, NewState ) { pr_find(AI, AIid, AIid); if (AIcurr != 0) { (void)strncpy(AIcurr->State, NewState, StatesNameMaxLen); } }