1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14
.IEC61970
.Meas
.MeasurementValue
import MeasurementValue
19 class AnalogValue(MeasurementValue
):
20 """AnalogValue represents an analog MeasurementValue.
23 def __init__(self
, value
=0.0, AltTieMeas
=None, Analog
=None, AltGeneratingUnit
=None, *args
, **kw_args
):
24 """Initialises a new 'AnalogValue' instance.
26 @param value: The value to supervise.
27 @param AltTieMeas: The usage of the measurement within the control area specification.
28 @param Analog: Measurement to which this value is connected.
29 @param AltGeneratingUnit: The alternate generating unit for which this measurement value applies.
31 #: The value to supervise.
35 self
.AltTieMeas
= [] if AltTieMeas
is None else AltTieMeas
40 self
._AltGeneratingUnit
= []
41 self
.AltGeneratingUnit
= [] if AltGeneratingUnit
is None else AltGeneratingUnit
43 super(AnalogValue
, self
).__init
__(*args
, **kw_args
)
46 _attr_types
= {"value": float}
47 _defaults
= {"value": 0.0}
49 _refs
= ["AltTieMeas", "Analog", "AltGeneratingUnit"]
50 _many_refs
= ["AltTieMeas", "AltGeneratingUnit"]
52 def getAltTieMeas(self
):
53 """The usage of the measurement within the control area specification.
55 return self
._AltTieMeas
57 def setAltTieMeas(self
, value
):
58 for x
in self
._AltTieMeas
:
62 self
._AltTieMeas
= value
64 AltTieMeas
= property(getAltTieMeas
, setAltTieMeas
)
66 def addAltTieMeas(self
, *AltTieMeas
):
67 for obj
in AltTieMeas
:
68 obj
._AnalogValue
= self
69 self
._AltTieMeas
.append(obj
)
71 def removeAltTieMeas(self
, *AltTieMeas
):
72 for obj
in AltTieMeas
:
73 obj
._AnalogValue
= None
74 self
._AltTieMeas
.remove(obj
)
77 """Measurement to which this value is connected.
81 def setAnalog(self
, value
):
82 if self
._Analog
is not None:
83 filtered
= [x
for x
in self
.Analog
.AnalogValues
if x
!= self
]
84 self
._Analog
._AnalogValues
= filtered
87 if self
._Analog
is not None:
88 self
._Analog
._AnalogValues
.append(self
)
90 Analog
= property(getAnalog
, setAnalog
)
92 def getAltGeneratingUnit(self
):
93 """The alternate generating unit for which this measurement value applies.
95 return self
._AltGeneratingUnit
97 def setAltGeneratingUnit(self
, value
):
98 for x
in self
._AltGeneratingUnit
:
101 y
._AnalogValue
= self
102 self
._AltGeneratingUnit
= value
104 AltGeneratingUnit
= property(getAltGeneratingUnit
, setAltGeneratingUnit
)
106 def addAltGeneratingUnit(self
, *AltGeneratingUnit
):
107 for obj
in AltGeneratingUnit
:
108 obj
._AnalogValue
= self
109 self
._AltGeneratingUnit
.append(obj
)
111 def removeAltGeneratingUnit(self
, *AltGeneratingUnit
):
112 for obj
in AltGeneratingUnit
:
113 obj
._AnalogValue
= None
114 self
._AltGeneratingUnit
.remove(obj
)