RIAPS / riaps-pycom

Python implementation of the RIAPS component model
Apache License 2.0
7 stars 8 forks source link

timer port period ignored #192

Closed eiselesr closed 3 years ago

eiselesr commented 3 years ago

Version: riaps-core-amd64/now 1.1.19rc1 amd64 riaps-pycom-amd64/now 1.1.19rc1 amd64 [installed,local] riaps-timesync-amd64/unknown,now 1.1.18 amd64 [installed]

Issue: In the .riaps file I set the timer trigger frequency (e.g. timer poller 5 sec;) I added a command to log some output, which is however when running the application the logger is triggering about every 20us. It appears the setting in the riaps file has no impact on the actual frequency.

gkarsai commented 3 years ago

Can you proved the test program? (source code, .riaps/.depl, etc.) It seems to work in Python. As an aside, how did you measure the 20 microsecond triggering?

eiselesr commented 3 years ago

TimerTest.riaps

app TimerTest{

    device TimerDevice(){
        timer poller 5 sec;
    }       

    actor TimerActor(){
        {
            a_timer : TimerDevice();
        }
    }
}

TimerTest.depl

app TimerTest {
    on all TimerActor;
}

TimerDevice.py

from riaps.run.comp import Component
import spdlog
import capnp
import timertest_capnp

class TimerDevice(Component):
    def __init__(self):
        super(TimerDevice, self).__init__()

    def on_poller(self):
        self.logger.info("on_poller")

Output:

[info]:[01-26-2021 16:55:04.672]:[12908]:TimerDevice.TimerDevice:on_poller
... reapeated 112 more times
[info]:[01-26-2021 16:55:04.673]:[12908]:TimerDevice.TimerDevice:on_poller

The triggering was just a rough estimate. I checked log and saw how many times the same timestamp was output. This time there were 113 lines with the same timestamp so about 8us. Basically its just logging as fast as it can.

It could be a problem with the configuration on my machine.

gkarsai commented 3 years ago

Well, in the handler (on_poller) you should receive the message from the port - otherwise it stays there and keeps triggering the component.. I suggest adding a now = self.poller.recv_pyobj() to the TimerDevice.

eiselesr commented 3 years ago

Ah, thanks. I had forgotten that. Ok. We can close this issue.