Exemplo n.º 1
0
 def call(self, arg: CallArg, __, proxor: IProcessorAPI) -> CallResult:
     return CallResult([
         Call(arg + 1,
              Address(actor='source', proc='feed'),
              call_step=proxor.step_count + 10),
         Call(arg, Address(processor='C', actor='compute', proc='data1'))
     ])
Exemplo n.º 2
0
 def call(self, arg: CallArg, _, proxor: IProcessorAPI) -> CallResult:
     logging.warning('PONG - time: {}, pong'.format(repr_time(proxor.time)))
     # Note that busy waiting still happens even though the simulation
     # hardware of the pong agent is very slow (due to the sleep below)
     time.sleep(0.2)
     out_call = Call(arg, Address(processor='A', actor='ping'))
     return CallResult([out_call])
Exemplo n.º 3
0
 def call(self, arg: CallArg, _, proxor: IProcessorAPI) -> CallResult:
     count = int(arg)
     if count >= 3:
         return proxor.exit()
     logging.warning('time: {}, count: {}'.format(repr_time(proxor.time),
                                                  count))
     time.sleep(0.3)
     return CallResult([Call(count + 1, self._target)])
Exemplo n.º 4
0
 def create_timer_call(self,
                       proxor: IProcessorAPI,
                       immediate: bool = False) -> Call:
     call_step_count = int(proxor.frequency / self._timer_freq)
     if call_step_count <= 0:
         raise ValueError(
             "Period freq {} to high for processor freq {}".format(
                 self._timer_freq, proxor.frequency))
     call_step_count = call_step_count + self._jitter_call_steps(proxor)
     call_step = (0 if immediate else (call_step_count + proxor.step_count))
     return Call(None,
                 Address(actor=self._actor_name, proc=self.name),
                 call_step=call_step)
Exemplo n.º 5
0
 def call(self, arg: CallArg, _, __) -> CallResult:
     return CallResult([Call(arg, Address(actor='ping'))])
Exemplo n.º 6
0
 def create_call() -> Call:
     return Call(None, Address(actor='pong'))
Exemplo n.º 7
0
 def call(self, arg: CallArg, __, proxor: IProcessorAPI) -> CallResult:
     result = [arg, self._actor.accum]
     self._actor.accum = []
     return CallResult([Call(result, Address(processor='D', actor='sink'))])
Exemplo n.º 8
0
 def call(self, arg: CallArg, __, proxor: IProcessorAPI) -> CallResult:
     return CallResult([
         Call(None, Address(actor='source', proc='feed')),
         Call(1, Address(processor='C', actor='compute', proc='data2'))
     ], 4)
Exemplo n.º 9
0
def compute_main(processor: Processor) -> None:
    processor.add_actor(ComputeActor())
    processor.put_calls(
        [Call(None, Address(actor='compute', proc='send'), call_step=5)])
Exemplo n.º 10
0
def actor_C_main(processor: Processor) -> None:
    processor.add_actor(CountActor(target=Address(processor='A')))
    processor.put_calls([Call(0, Address(actor='counter'))])
Exemplo n.º 11
0
 def call(self, arg: CallArg, _, proxor: IProcessorAPI) -> CallResult:
     return CallResult(
         [Call(self._actor._value, Address(processor='C', actor='sink'))])
Exemplo n.º 12
0
 def call(self, arg: CallArg, __, proxor: IProcessorAPI) -> CallResult:
     return CallResult([Call(arg, Address(processor='C', actor='sink'))],
                       random.randint(0, 5))
Exemplo n.º 13
0
 def gen_call(self, arg: CallArg, proxor: IProcessorAPI):
     return Call(arg, target=self._address)
Exemplo n.º 14
0
def ping_main(processor: Processor) -> None:
    processor.add_actor(PingActor(3))
    processor.put_calls([Call(None, Address(actor='ping'))])
Exemplo n.º 15
0
 def create_call() -> Token:
     return Call(None, Address(processor='B', actor='pong'))
Exemplo n.º 16
0
 def call(self, arg: CallArg, __, proxor: IProcessorAPI) -> CallResult:
     return CallResult([
         Call(arg + 1, Address(actor='source', proc='feed')),
         Call(arg, Address(processor='B', actor='sink'))
     ])
Exemplo n.º 17
0
def source_main(processor: Processor) -> None:
    processor.add_actor(SourceActor())
    processor.put_calls([Call(0, Address(actor='source'))])
Exemplo n.º 18
0
def source_main(processor: Processor) -> None:
    processor.put_calls([
        Call('OK',
             Address(processor='B', actor='compute'),
             call_step=random.randint(0, 10))
    ])