/***************************************************************************** * file: ckcreate.c * * Purpose: * * This file contains the Periodic TImer (CK) create routine * CKCreate. */ # include # include #include "olc96fa.h" #include "olc3common.h" #include "timer.h" /* ** ClockFirst ** ClockNext ** ClockDelete */ STANDARDROUTINES(Clock,CK) /****************************************************/ /* */ /* Create Clock */ /* */ /****************************************************/ FUNCTION5( void ClockCreate, hcg_key, ClockActiveInstance, hcg_key, FireFromThisActiveInstance, hcg_key, FireToThisActiveInstance, hcg_key, FireThisTypeOfEvent, int, clockperiod ) { #ifdef GENV7 char databuffer[BUFSIZE]; KEYBUFFER(TIkey); KEYBUFFER(AI1key); KEYBUFFER(AI2key); KEYBUFFER(AI3key); KEYBUFFER(ET1key); /* ** Get the keys we need */ decode(AI1key, &ClockActiveInstance); decode(AI2key, &FireFromThisActiveInstance); decode(AI3key, &FireToThisActiveInstance); decode(ET1key, &FireThisTypeOfEvent); pr_gen_pkey("JuicePlantTransfer", CK, CKkey); /* ** Form the new table line //RJL: This shows that genv7 was used, NOT genv8: */ sprintf(databuffer, " %s %s %s %s %s %d ", CKkey, AI1key, AI2key, AI3key, ET1key, clockperiod ); /* ** And add it */ pr_add("JuicePlantTransfer", databuffer); #else struct CK *CK_elt; CK_elt = pr_create(CK); pr_set_key(CK_elt, AIid1, ClockActiveInstance); pr_set_key(CK_elt, AIid2, FireFromThisActiveInstance); pr_set_key(CK_elt, AIid3, FireToThisActiveInstance); pr_set_key(CK_elt, ETid, FireThisTypeOfEvent); pr_set_int(CK_elt, period, clockperiod); #ifdef ORIG pr_add("JuicePlantTransfer", CK, CK_elt); #else gen_pr_add("JuicePlant", "CK", (hcg_ptr)CK_elt); #endif #endif } FUNCTION5( void GenerateClock, const char *, ClockActiveInstance, const char *, FireFromThisActiveInstance, const char *, FireToThisActiveInstance, const char *, FireThisTypeOfEvent, int, clockperiod ) { hcg_key AIid1; hcg_key AIid2; hcg_key AIid3; hcg_key ETid; int bad; /* ** Convert the names of the Active Instances and the Label of the ** event into keys */ bad = 0; find_str_loop("JuicePlant", AI, Name, FireFromThisActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s.\n", FireFromThisActiveInstance); bad = 1; } else { AIid2 = AIcurr->AIid; } find_str_loop("JuicePlant", AI, Name, FireToThisActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s\n", FireToThisActiveInstance); bad = 1; } else { AIid3 = AIcurr->AIid; } find_str_loop("JuicePlant", AI, Name, ClockActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s\n", ClockActiveInstance); bad = 1; } else { AIid1 = AIcurr->AIid; } find_str_loop("JuicePlant", ET, Label, FireThisTypeOfEvent) { break; } if (ETcurr == 0) { printf("Could not find an Event labeled %s.\n", FireThisTypeOfEvent); bad = 1; } else { ETid = ETcurr->ETid; } if (bad) { printf("Event not generated\n"); return; } ClockCreate( AIid1, AIid2, AIid3, ETid, clockperiod ); } FUNCTION5( void CKCreate, hcg_key , AIid1, hcg_key , AIid2, hcg_key , AIid3, const char *, FireThisTypeOfEvent, int , clockperiod ) { hcg_key ETid; int bad; /* ** Convert the names of the Active Instances and the Label of the ** event into keys */ bad = 0; find_str_loop("JuicePlant", ET, Label, FireThisTypeOfEvent) { break; } if (ETcurr == 0) { printf("Could not find an Event labeled %s.\n", FireThisTypeOfEvent); bad = 1; } else { ETid = ETcurr->ETid; } if (bad) { printf("Event not generated\n"); return; } ClockCreate( AIid1, AIid2, AIid3, ETid, clockperiod ); } GETROUTINE(hcg_key, Clock,CK,AIid1) GETROUTINE(hcg_key, Clock,CK,AIid2) GETROUTINE(hcg_key, Clock,CK,AIid3) GETROUTINE(hcg_key, Clock,CK,ETid) GETROUTINE(int, Clock,CK,period)