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

Bugfix v1.0.2 #43

Open
wants to merge 5 commits into
base: bugfix-v1.0.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions synchrophasor/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ def set_time(self, soc=None, frasec=None):

t = time() # Get current timestamp

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

if frasec:
if frasec is not None:
if isinstance(frasec, collections.Sequence):
self.set_frasec(*frasec)
else:
Expand Down Expand Up @@ -392,7 +392,7 @@ def _int2frasec(frasec_int):
leap_occ = bool(leap_occ)
leap_pen = bool(leap_pen)

fr_seconds = frasec_int & (2**23-1)
fr_seconds = frasec_int & (2**24-1)

return fr_seconds, leap_dir, leap_occ, leap_pen, time_quality

Expand Down Expand Up @@ -1917,7 +1917,7 @@ def _stat2int(measurement_status="ok", sync=True, sorting="timestamp", trigger=F
if isinstance(trigger_reason, str):
trigger_reason = DataFrame.TRIGGER_REASON[trigger_reason]

stat = measurement_status << 2
stat = measurement_status << 1
if not sync:
stat |= 1

Expand Down Expand Up @@ -1952,7 +1952,7 @@ def _stat2int(measurement_status="ok", sync=True, sorting="timestamp", trigger=F
@staticmethod
def _int2stat(stat):

measurement_status = DataFrame.MEASUREMENT_STATUS_WORDS[stat >> 15]
measurement_status = DataFrame.MEASUREMENT_STATUS_WORDS[stat >> 14]
sync = bool(stat & 0x2000)

if stat & 0x1000:
Expand All @@ -1964,8 +1964,8 @@ def _int2stat(stat):
cfg_change = bool(stat & 0x400)
modified = bool(stat & 0x200)

time_quality = DataFrame.TIME_QUALITY_WORDS[stat & 0x1c0]
unlocked = DataFrame.UNLOCKED_TIME_WORDS[stat & 0x30]
time_quality = DataFrame.TIME_QUALITY_WORDS[(stat & 0x1c0)>>6]
unlocked = DataFrame.UNLOCKED_TIME_WORDS[(stat & 0x30)>>4]
trigger_reason = DataFrame.TRIGGER_REASON_WORDS[stat & 0xf]

return measurement_status, sync, sorting, trigger, cfg_change, modified, time_quality, unlocked, trigger_reason
Expand Down Expand Up @@ -2357,7 +2357,7 @@ def get_measurements(self):
"phasors": self.get_phasors()[i],
"analog": self.get_analog()[i],
"digital": self.get_digital()[i],
"frequency": self.cfg.get_fnom()[i] + self.get_freq()[i] / 1000,
"frequency":(self.get_freq()[i]) if (self.cfg.get_data_format()[i])[3] else self.cfg.get_fnom()[i] + self.get_freq()[i] / 1000,
"rocof": self.get_dfreq()[i]}

measurements.append(measurement)
Expand All @@ -2368,7 +2368,7 @@ def get_measurements(self):
"phasors": self.get_phasors(),
"analog": self.get_analog(),
"digital": self.get_digital(),
"frequency": self.cfg.get_fnom() + self.get_freq() / 1000,
"frequency": (self.get_freq()) if (self.cfg.get_data_format())[3] else self.cfg.get_fnom() + self.get_freq() / 1000,
"rocof": self.get_dfreq()
})

Expand Down