Skip to content

Commit

Permalink
test inheritance diagram
Browse files Browse the repository at this point in the history
alarm object documentation, condition documentation
  • Loading branch information
sneakers-the-rat committed Aug 17, 2020
1 parent ceb9a0d commit 198496b
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 26 deletions.
4 changes: 4 additions & 0 deletions _docs/alarm.alarm.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Alarm Objects
================

Alarm objects represent the state and severity of active alarms, but are otherwise intentionally quite featureless.

They are created and maintained by the :class:`.Alarm_Manager` and sent to any listeners registered in :class:`.Alarm_Manager.callbacks` .

.. automodule:: pvp.alarm.alarm
:members:
:undoc-members:
Expand Down
14 changes: 14 additions & 0 deletions _docs/alarm.condition.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
Alarm Condition
===================

Condition objects define conditions that can raise alarms.

Each has to define a :meth:`.Condition.check` method that accepts :class:`.SensorValues` .
The method should return ``True`` if the alarm condition is met, and ``False`` otherwise.

Conditions can be added (``+``) together to make compound conditions, and a single call to ``check`` will only return true
if both conditions return true. If any condition in the chain returns false, evaluation is stopped and
the alarm is not raised.

Conditions can

.. inheritance-diagram:: pvp.alarm.condition

.. automodule:: pvp.alarm.condition
:members:
:undoc-members:
:autosummary:
:show-inheritance:
1 change: 0 additions & 1 deletion _docs/alarm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Alarm
==========



Alarm System Overview
----------------------

Expand Down
1 change: 1 addition & 0 deletions _docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
'sphinx.ext.intersphinx', # include documentation from other projects
'sphinx.ext.todo', # todo directive
'sphinx.ext.viewcode',
'sphinx.ext.inheritance-diagram',
# 'sphinx_automodapi.automodapi',
'sphinxcontrib.napoleon', # parse google style docstrings
'autodocsumm',
Expand Down
51 changes: 30 additions & 21 deletions pvp/alarm/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Alarm:
"""
Class used by the program to control and coordinate alarms.
Representation of alarm status and parameters
Parameterized by a :class:`Alarm_Rule` and managed by :class:`Alarm_Manager`
"""
Expand All @@ -27,16 +27,21 @@ def __init__(self,
value=None,
message=None):
"""
Attributes:
id (int): unique alarm ID
Args:
alarm_type :
severity:
start_time:
cause (ValueName): The value that caused the alarm to be fired
alarm_type ( :class:`.AlarmType` ): Type of alarm
severity ( :class:`.AlarmSeverity` ) : Severity of alarm
start_time (float): Timestamp of alarm start, (as generated by ``time.time()``
cause (ValueName): The :class:`.ValueName` that caused the alarm to be fired
value (int, float): optional - numerical value that generated the alarm
message (str): optional - override default text generated by :class:`~pvp.gui.alarm_manager.AlarmManager`
Attributes:
id (int): unique alarm ID
end_time (None, float): If None, alarm has not ended. otherwise timestamp
active (bool): Whether or not the alarm is currently active
"""


Expand Down Expand Up @@ -67,31 +72,35 @@ def __init__(self,
# if not managed:
# self.manager.register_alarm(self)

# @property
# def manager(self):
# """
# have ta do it this janky way to avoid circular imports
# """
# try:
# return Alarm_Manager()
# except:
# # import into the module namespace
# manager_module = importlib.import_module('pvp.alarm.alarm_manager')
# globals()['Alarm_Manager'] = getattr(manager_module, 'Alarm_Manager')
# return Alarm_Manager()

@property
def severity(self) -> AlarmSeverity:
"""
Alarm Severity, property without setter to prevent change after instantiation
Returns:
:class:`.AlarmSeverity`
"""
# no setter, don't want to be able to change after instantiation
return self._severity

@property
def alarm_type(self) -> AlarmType:
"""
Alarm Type, property without setter to prevent change after instantiation
Returns:
:class:`.AlarmType`
"""
return self._alarm_type



def deactivate(self):
"""
If active, register an end time and set as ``active == False``
Returns:
"""
if not self.active:
return

Expand Down
6 changes: 2 additions & 4 deletions pvp/alarm/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ class Condition(object):
"""
Base class for specifying alarm test conditions
Need to be able to condition alarms based on
* value ranges
* value ranges & durations
* levels of other alarms
Subclasses must define :meth:`.Condition.check` and :meth:`.Conditino.reset`
Condition objects can be added together to create compound conditions.
Attributes:
manager (:class:`pvp.alarm.alarm_manager.Alarm_Manager`): alarm manager, used to get status of alarms
Expand Down

0 comments on commit 198496b

Please sign in to comment.