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

NEW - Active reactive with phase #109

Merged
merged 6 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions primestg/report/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,25 @@ def active_reactive(self, measure, measure_type):
'r4': float(measure.get('R4{}'.format(measure_type))),
}

def active_reactive_with_phase(self, measure, phase_num):
"""
Get the active and reactive measures.

:param measure: an lxml.objectify.StringElement representing a set of \
measures
:param phase_num: the phase number of measure, added at the end of the \
name of each measure (1,2,3)
:return: a dict with the active and reactive phase measures
"""
return {
'ai{}'.format(phase_num): float(measure.get('AI{}'.format(phase_num))),
'ae{}'.format(phase_num): float(measure.get('AE{}'.format(phase_num))),
'r1{}'.format(phase_num): float(measure.get('R1{}'.format(phase_num))),
'r2{}'.format(phase_num): float(measure.get('R2{}'.format(phase_num))),
'r3{}'.format(phase_num): float(measure.get('R3{}'.format(phase_num))),
'r4{}'.format(phase_num): float(measure.get('R4{}'.format(phase_num))),
}


class MeasureAverageVoltageAndCurrent(Measure):
"""
Expand Down
60 changes: 30 additions & 30 deletions primestg/report/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,36 +291,9 @@ def values(self):
return values


class MeasureS52(MeasureActiveReactiveFloat):
"""
Class for a set of measures of report S52.
"""

@property
def values(self):
"""
Set of measures of report S52.

:return: a dict with a set of measures of report S52
"""
try:
values = self.active_reactive(self.objectified, '')
values.update(
{
'timestamp': self._get_timestamp('Fh'),
'bc': self.objectified.get('Bc')
}
)
except Exception as e:
self._warnings.append('ERROR: Thrown exception: {}'.format(e))
return []

return [values]


class OperationS42(Operation):
"""
Class for a set of measures of report S52.
Class for a set of measures of report S42.
"""

@property
Expand All @@ -347,6 +320,33 @@ def values(self):
return values


class MeasureS52(MeasureActiveReactiveFloat):
"""
Class for a set of measures of report S52.
"""

@property
def values(self):
"""
Set of measures of report S52.

:return: a dict with a set of measures of report S52
"""
try:
values = self.active_reactive(self.objectified, '')
values.update(
{
'timestamp': self._get_timestamp('Fh'),
'bc': self.objectified.get('Bc')
}
)
except Exception as e:
self._warnings.append('ERROR: Thrown exception: {}'.format(e))
return []

return [values]


class MeasureEvents(Measure):
"""
Class for a set of measures of report S09.
Expand Down Expand Up @@ -2078,7 +2078,7 @@ class RemoteTerminalUnitS52(RemoteTerminalUnitDetails):

def __init__(self, objectified_rt_unit, report_version, request_id):
"""
Create a RemoteTerminalUnit object for the report S62.
Create a RemoteTerminalUnit object for the report S52.

:param objectified_rt_unit: an lxml.objectify.StringElement \
representing a line supervisor
Expand All @@ -2101,7 +2101,7 @@ def line_supervisor_class(self):
@property
def report_type(self):
"""
The type of report for report S64.
The type of report for report S52.
:return: a string with 'S52'
"""
return 'S52'
Expand Down
Loading