def tclass_add_prerequisites( sself, startup, tag ): # NOTE: Task objects hold all triggers defined for the task # in all cycling graph sections in this data structure: # self.triggers[cycler] = [list of triggers for this cycler] # The list of triggers associated with cyclerX will only be # used by a particular task if the task's cycle time is a # valid member of cyclerX's sequence of cycle times. # 1) non-conditional triggers pp = plain_prerequisites( sself.id, self.ict ) sp = plain_prerequisites( sself.id, self.ict ) lp = loose_prerequisites( sself.id, self.ict ) for cyc in self.triggers: for trig in self.triggers[ cyc ]: if trig.startup and not startup: continue if trig.cycling and not cyc.valid( ct(sself.tag) ): # This trigger is not used in current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. if trig.async_repeating: lp.add( trig.get( tag, cyc )) else: if trig.suicide: sp.add( trig.get( tag, cyc )) else: pp.add( trig.get( tag, cyc)) sself.prerequisites.add_requisites( pp ) sself.prerequisites.add_requisites( lp ) sself.suicide_prerequisites.add_requisites( sp ) # 2) conditional triggers for cyc in self.cond_triggers.keys(): for ctrig, exp in self.cond_triggers[ cyc ]: foo = ctrig.keys()[0] if ctrig[foo].startup and not startup: continue if ctrig[foo].cycling and not cyc.valid( ct(sself.tag)): # This trigger is not valid for current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. cp = conditional_prerequisites( sself.id, self.ict ) for label in ctrig: trig = ctrig[label] cp.add( trig.get( tag, cyc ), label ) cp.set_condition( exp ) if ctrig[foo].suicide: sself.suicide_prerequisites.add_requisites( cp ) else: sself.prerequisites.add_requisites( cp )
def tclass_add_prerequisites(sself, startup, tag): # NOTE: Task objects hold all triggers defined for the task # in all cycling graph sections in this data structure: # self.triggers[cycler] = [list of triggers for this cycler] # The list of triggers associated with cyclerX will only be # used by a particular task if the task's cycle time is a # valid member of cyclerX's sequence of cycle times. # 1) non-conditional triggers pp = plain_prerequisites(sself.id, self.ict) sp = plain_prerequisites(sself.id, self.ict) lp = loose_prerequisites(sself.id, self.ict) for cyc in self.triggers: for trig in self.triggers[cyc]: if trig.startup and not startup: continue if trig.cycling and not cyc.valid(ct(sself.tag)): # This trigger is not used in current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. if trig.async_repeating: lp.add(trig.get(tag, cyc)) else: if trig.suicide: sp.add(trig.get(tag, cyc)) else: pp.add(trig.get(tag, cyc)) sself.prerequisites.add_requisites(pp) sself.prerequisites.add_requisites(lp) sself.suicide_prerequisites.add_requisites(sp) # 2) conditional triggers for cyc in self.cond_triggers.keys(): for ctrig, exp in self.cond_triggers[cyc]: foo = ctrig.keys()[0] if ctrig[foo].startup and not startup: continue if ctrig[foo].cycling and not cyc.valid(ct(sself.tag)): # This trigger is not valid for current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. cp = conditional_prerequisites(sself.id, self.ict) for label in ctrig: trig = ctrig[label] cp.add(trig.get(tag, cyc), label) cp.set_condition(exp) if ctrig[foo].suicide: sself.suicide_prerequisites.add_requisites(cp) else: sself.prerequisites.add_requisites(cp)
def tclass_add_prerequisites( sself, startup, tag ): # NOTE: Task objects hold all triggers defined for the task # in all cycling graph sections in this data structure: # self.triggers[cycler] = [list of triggers for this cycler] # The list of triggers associated with cyclerX will only be # used by a particular task if the task's cycle time is a # valid member of cyclerX's sequence of cycle times. # 1) non-conditional triggers pp = plain_prerequisites( sself.id, self.ict ) sp = plain_prerequisites( sself.id, self.ict ) lp = loose_prerequisites( sself.id, self.ict ) if self.sequential: # For tasks declared 'sequential' we automatically add a # previous-instance inter-cycle trigger, and adjust the # cleanup cutoff (determined by inter-cycle triggers) # accordingly. pp.add( sself.name + '.' + sself.cycon.prev( sself.c_time ) + ' succeeded' ) next_inst_ct = sself.cycon.next( sself.c_time ) if int(sself.cleanup_cutoff) < int(next_inst_ct): sself.cleanup_cutoff = next_inst_ct for cyc in self.triggers: for trig in self.triggers[ cyc ]: if trig.startup and not startup: continue if trig.cycling and not cyc.valid( ct(sself.tag) ): # This trigger is not used in current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. if trig.async_repeating: lp.add( trig.get( tag, cyc )) elif self.ict is None or \ trig.evaluation_offset is None or \ (int(tag) - int(trig.evaluation_offset)) >= int(self.ict): # i.c.t. can be None after a restart, if one # is not specified in the suite definition. if trig.suicide: sp.add( trig.get( tag, cyc )) else: pp.add( trig.get( tag, cyc)) sself.prerequisites.add_requisites( pp ) sself.prerequisites.add_requisites( lp ) sself.suicide_prerequisites.add_requisites( sp ) # 2) conditional triggers for cyc in self.cond_triggers.keys(): for ctrig, exp in self.cond_triggers[ cyc ]: foo = ctrig.keys()[0] if ctrig[foo].startup and not startup: continue if ctrig[foo].cycling and not cyc.valid( ct(sself.tag)): # This trigger is not valid for current cycle (see NOTE just above) continue # NOTE that if we need to check validity of async # tags, async tasks can appear in cycling sections # in which case cyc.valid( at(sself.tag)) will fail. cp = conditional_prerequisites( sself.id, self.ict ) for label in ctrig: trig = ctrig[label] if self.ict is not None and trig.evaluation_offset is not None: cp.add( trig.get( tag, cyc ), label, (int(tag) - int(trig.evaluation_offset)) < int(self.ict)) else: cp.add( trig.get( tag, cyc ), label ) cp.set_condition( exp ) if ctrig[foo].suicide: sself.suicide_prerequisites.add_requisites( cp ) else: sself.prerequisites.add_requisites( cp )