Skip to content

Commit

Permalink
Merge pull request #109 from gisce/new_create_s53_report
Browse files Browse the repository at this point in the history
NEW - Active reactive with phase
  • Loading branch information
tinogis authored Sep 17, 2024
2 parents 5c414d1 + 961ffbf commit 8cb0e62
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 30 deletions.
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

0 comments on commit 8cb0e62

Please sign in to comment.