def __init__(self, msg_count=10, interval=1.0, payload=""): '''Message source constructor. @param msg_count: the number of messages to emit. @param interval: the lapse of time between messages, in seconds. @param payload: a string to include in message. ''' gwnblock_py.__init__(self, name='msg_source', number_in=0, number_out=1, number_timers=1, number_timeouts=0) ## initialize timers, start self.timers[0].retry = msg_count self.timers[0].interval = interval #self.timers[0].exit_flag = False #self.timers[0].interrupt = False self.timers[0].msg_dc_1['Final'] = 'False' self.timers[0].msg_dc_2['Final'] = 'True' self.timers[0].msg_dc_1['payload'] = payload self.timers[0].msg_dc_2['payload'] = payload self.start_timers() return
def __init__(self): '''Message sink constructor. ''' gwnblock_py.__init__(self, name='msg_sink', number_in=1, number_out=0, number_timers=0, number_timeouts=0) return
def __init__(self, tout_stop=5.0, tout_restart=8.0): '''Message passer constructor. @param tout_stop: a timeout to stop resending, in seconds. @param tout_restart_ a timeout to restart resending, in seconds. ''' gwnblock_py.__init__(self, name='msg_passer', number_in=1, number_out=1, number_timers=0, number_timeouts=2) ## initialize timeouts, start self.timeouts[0].timeout = tout_stop self.timeouts[0].start() self.timeouts[1].timeout = tout_restart self.timeouts[1].start() self.transmit = True # if True passes message to next block return