/***************************************************************************** * file: tfcreate.c * * Purpose: * * This file contains the toggle-flip-flop (TFF) create routine * TFFCreate. */ #include #include #include "olc96fa.h" #include "olc3common.h" #include "eventinstance.h" /* */ /* ** FlipFlopFirst ** FlipFlopNext ** FlipFlopDelete */ STANDARDROUTINES(ToggleFlipFlop, TF) /****************************************************/ /* */ /* Create FlipFlop */ /* */ /****************************************************/ FUNCTION5( void ToggleFlipFlopCreate, hcg_key, FlipFlopActiveInstance, /* superclass AI */ hcg_key, FromThisActiveInstance, /* source of events to this AI */ hcg_key, ToThisActiveInstance, /* where to send reply events */ const char *, ThisTypeOfEvent, /* name of reply event type */ int, FirstIntdata /* most-signif bit=3, lssbit=1 */ ) { struct TF *TF_elt; TF_elt = pr_create(TF); pr_set_key(TF_elt, AIid, FlipFlopActiveInstance); pr_set_key(TF_elt, AIid1_source, FromThisActiveInstance); pr_set_key(TF_elt, AIid2_reply, ToThisActiveInstance); pr_set_str(TF_elt, replyETLabel, ThisTypeOfEvent); pr_set_int(TF_elt, bitPosition, FirstIntdata); gen_pr_add("JuicePlant", "TF", (hcg_ptr)TF_elt); /*OWEN*/ #if 0 pr_dump_row(EI,"JuicePlant","run1.dat",1,"a"); #endif } /* */ FUNCTION5( void GenerateFlipFlop, const char *, FlipFlopActiveInstance, const char *, FromThisNamedActiveInstance, const char *, ToThisNamedActiveInstance, const char *, EventLabel, int, FirstIntData ) { 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, FromThisNamedActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s.\n", FromThisNamedActiveInstance); bad = 1; } else { AIid2 = AIcurr->AIid; /* and/or pAIid_source = AIcurr ? */ } find_str_loop("JuicePlant", AI, Name, ToThisNamedActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s\n", ToThisNamedActiveInstance); bad = 1; } else { AIid3 = AIcurr->AIid; /* and/or pAIid_dest = AIcurr ? */ } find_str_loop("JuicePlant", AI, Name, FlipFlopActiveInstance) { break; } if (AIcurr == 0) { printf("Could not find an Active Instance named %s\n", ToThisNamedActiveInstance); bad = 1; } else { AIid1 = AIcurr->AIid; /* and/or pAIid_dest = AIcurr ? */ } find_str_loop("JuicePlant", ET, Label, EventLabel) { break; } if (ETcurr == 0) { printf("Could not find an Event labeled %s.\n", EventLabel); bad = 1; } else { ETid = ETcurr->ETid; /* ETcurr is also uptodate */ } if (bad) { printf("Event not generated\n"); return; } /* ** And have Event Instance Create do the work */ ToggleFlipFlopCreate( AIid1, AIid2, AIid3, EventLabel, FirstIntData); } /* */ FUNCTION5( void TFFCreate, hcg_key, AIid1, hcg_key, AIid2, hcg_key, AIid3, const char *, EventLabel, int, FirstIntData ) { hcg_key ETid; int bad; bad = 0; find_str_loop("JuicePlant", ET, Label, EventLabel) { break; } if (ETcurr == 0) { printf("Could not find an Event labeled %s.\n", EventLabel); bad = 1; } else { ETid = ETcurr->ETid; } if (bad) { printf("Event not generated\n"); return; } /* ** And have Event Instance Create do the work */ ToggleFlipFlopCreate( AIid1, AIid2, AIid3, EventLabel, FirstIntData); } GETROUTINE(hcg_key, ToggleFlipFlop,TF,AIid) GETROUTINE(hcg_key, ToggleFlipFlop,TF,replyETLabel) GETROUTINE(hcg_key, ToggleFlipFlop,TF,AIid1_source) GETROUTINE(hcg_key, ToggleFlipFlop,TF,AIid2_reply) GETROUTINE(int, ToggleFlipFlop,TF,bitPosition)