Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp issues #7

Open
RadevicI opened this issue Jun 28, 2018 · 1 comment
Open

Timestamp issues #7

RadevicI opened this issue Jun 28, 2018 · 1 comment
Labels

Comments

@RadevicI
Copy link

RadevicI commented Jun 28, 2018

Hi to all,

In order to test the performance of the algorithm running in my PMU prototype, I decided to use your pyPMU model to enable connection between the sensor and local PDC in the lab. In case when the reporting rate is set to be 50 frames/s, the data are being sent each 20 ms (50 Hz systems). Therefore, fraction of second is getting the values equal to 0, 20000, 40000, .... 900000,...0 etc. It has been noticed that each time when timestamp of 0 fraction of second is sent, PDC received the frasec of the system time (time.time()) instead of 0.

The problem is solved by modifying the frame.py in def set_time:

Instead of:

    t = time()  # Get current timestamp

   if soc:
         self.set_soc(soc)
    else:
        self.set_soc(int(t))  # Get current timestamp##

    if frasec:
        if isinstance(frasec, collections.Sequence):
            self.set_frasec(*frasec)
        else:
            self.set_frasec(frasec)  # Just set fraction of second and use default values for other arguments.
    else:
         Calculate fraction of second (after decimal point) using only first 7 digits to avoid
         overflow (24 bit number).
        self.set_frasec(int((((repr((t % 1))).split("."))[1])[0:6]))

This code is written:

    if soc :
        self.set_soc(soc)
        if isinstance(frasec, collections.Sequence):
                self.set_frasec(*frasec)
        else:
                self.set_frasec(frasec)
    else:
        t = time()  # Get current timestamp
        self.set_soc(int(t))  # Get current timestamp
        self.set_frasec(int((((repr((t % 1))).split("."))[1])[0:6]))

BR,

Isidora

@RadevicI RadevicI changed the title sending own timestamp, without using the system time Timestamp issues Jun 28, 2018
@sstevan
Copy link
Contributor

sstevan commented Jun 28, 2018

Hello @RadevicI,

Thanks for reporting this issue.

The thing is that if frasec: resolves as False if frasec is zero.

We will fix this issue by checking if frasec is not None: (and if soc is not None:).
Methods set_soc() and set_frasec() will validate values.

So it will look like this:

        t = time()  # Get current timestamp

        if soc is not None:
            self.set_soc(soc)
        else:
            self.set_soc(int(t))  # Get current timestamp

        if frasec is not None:
            if isinstance(frasec, collections.Sequence):
                self.set_frasec(*frasec)
            else:
                self.set_frasec(frasec)  # Just set fraction of second and use default values for other arguments.
        else:
            # Calculate fraction of second (after decimal point) using only first 7 digits to avoid
            # overflow (24 bit number).
            self.set_frasec(int((((repr((t % 1))).split("."))[1])[0:6]))

@sstevan sstevan added the bug label Jun 28, 2018
veljkoDjurkovic added a commit to veljkoDjurkovic/pypmu that referenced this issue Jul 28, 2022
If soc or frasec is zero by input, it is considered to be false, so it should be written like this.
Skalar2001 added a commit to Skalar2001/pypmu-popravka that referenced this issue Jul 28, 2022
The thing is that if frasec: resolves as False if frasec is zero.

We will fix this issue by checking if frasec is not None: (and if soc is not None:).
Methods set_soc() and set_frasec() will validate values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants