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, point): # NOTE: Task objects hold all triggers defined for the task # in all cycling graph sections in this data structure: # self.triggers[sequence] = [list of triggers for this # sequence] # The list of triggers associated with sequenceX will only be # used by a particular task if the task's cycle point is a # valid member of sequenceX's sequence of cycle points. # 1) non-conditional triggers pp = plain_prerequisites(sself.id, self.start_point) sp = plain_prerequisites(sself.id, self.start_point) 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. p_next = None adjusted = [] for seq in self.sequences: nxt = seq.get_next_point(sself.point) if nxt: # may be None if beyond the sequence bounds adjusted.append(nxt) if adjusted: p_next = min(adjusted) if (sself.cleanup_cutoff is not None and sself.cleanup_cutoff < p_next): sself.cleanup_cutoff = p_next p_prev = None adjusted = [] for seq in self.sequences: prv = seq.get_nearest_prev_point(sself.point) if prv: # may be None if out of sequence bounds adjusted.append(prv) if adjusted: p_prev = max(adjusted) pp.add(TaskID.get(sself.name, str(p_prev)) + ' succeeded') for sequence in self.triggers: for trig in self.triggers[sequence]: if not sequence.is_valid(sself.point): # This trigger is not used in current cycle continue if (trig.graph_offset_string is None or (get_point_relative(trig.graph_offset_string, point) >= self.start_point)): # i.c.t. can be None after a restart, if one # is not specified in the suite definition. message, prereq_point = trig.get(point) prereq_offset = prereq_point - point if (prereq_offset > get_interval_cls().get_null() and (sself.max_future_prereq_offset is None or prereq_offset > sself.max_future_prereq_offset)): sself.max_future_prereq_offset = prereq_offset if trig.suicide: sp.add(message) else: pp.add(message) sself.prerequisites.add_requisites(pp) sself.suicide_prerequisites.add_requisites(sp) # 2) conditional triggers for sequence in self.cond_triggers.keys(): for ctrig, exp in self.cond_triggers[sequence]: foo = ctrig.keys()[0] if not sequence.is_valid(sself.point): # This trigger is not valid for current cycle (see NOTE just above) continue cp = conditional_prerequisites(sself.id, self.start_point) for label in ctrig: trig = ctrig[label] if trig.graph_offset_string is not None: is_less_than_start = (get_point_relative( trig.graph_offset_string, point) < self.start_point) cp.add( trig.get(point)[0], label, is_less_than_start) else: cp.add(trig.get(point)[0], 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 )