1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM14
.IEC61970
.Meas
.MeasurementValue
import MeasurementValue
23 class AnalogValue(MeasurementValue
):
24 """AnalogValue represents an analog MeasurementValue.
27 def __init__(self
, value
=0.0, AltTieMeas
=None, Analog
=None, AltGeneratingUnit
=None, *args
, **kw_args
):
28 """Initialises a new 'AnalogValue' instance.
30 @param value: The value to supervise.
31 @param AltTieMeas: The usage of the measurement within the control area specification.
32 @param Analog: Measurement to which this value is connected.
33 @param AltGeneratingUnit: The alternate generating unit for which this measurement value applies.
35 #: The value to supervise.
39 self
.AltTieMeas
= [] if AltTieMeas
is None else AltTieMeas
44 self
._AltGeneratingUnit
= []
45 self
.AltGeneratingUnit
= [] if AltGeneratingUnit
is None else AltGeneratingUnit
47 super(AnalogValue
, self
).__init
__(*args
, **kw_args
)
50 _attr_types
= {"value": float}
51 _defaults
= {"value": 0.0}
53 _refs
= ["AltTieMeas", "Analog", "AltGeneratingUnit"]
54 _many_refs
= ["AltTieMeas", "AltGeneratingUnit"]
56 def getAltTieMeas(self
):
57 """The usage of the measurement within the control area specification.
59 return self
._AltTieMeas
61 def setAltTieMeas(self
, value
):
62 for x
in self
._AltTieMeas
:
66 self
._AltTieMeas
= value
68 AltTieMeas
= property(getAltTieMeas
, setAltTieMeas
)
70 def addAltTieMeas(self
, *AltTieMeas
):
71 for obj
in AltTieMeas
:
72 obj
.AnalogValue
= self
74 def removeAltTieMeas(self
, *AltTieMeas
):
75 for obj
in AltTieMeas
:
76 obj
.AnalogValue
= None
79 """Measurement to which this value is connected.
83 def setAnalog(self
, value
):
84 if self
._Analog
is not None:
85 filtered
= [x
for x
in self
.Analog
.AnalogValues
if x
!= self
]
86 self
._Analog
._AnalogValues
= filtered
89 if self
._Analog
is not None:
90 if self
not in self
._Analog
._AnalogValues
:
91 self
._Analog
._AnalogValues
.append(self
)
93 Analog
= property(getAnalog
, setAnalog
)
95 def getAltGeneratingUnit(self
):
96 """The alternate generating unit for which this measurement value applies.
98 return self
._AltGeneratingUnit
100 def setAltGeneratingUnit(self
, value
):
101 for x
in self
._AltGeneratingUnit
:
104 y
._AnalogValue
= self
105 self
._AltGeneratingUnit
= value
107 AltGeneratingUnit
= property(getAltGeneratingUnit
, setAltGeneratingUnit
)
109 def addAltGeneratingUnit(self
, *AltGeneratingUnit
):
110 for obj
in AltGeneratingUnit
:
111 obj
.AnalogValue
= self
113 def removeAltGeneratingUnit(self
, *AltGeneratingUnit
):
114 for obj
in AltGeneratingUnit
:
115 obj
.AnalogValue
= None