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
.Core
.IdentifiedObject
import IdentifiedObject
23 class Measurement(IdentifiedObject
):
24 """A Measurement represents any measured, calculated or non-measured non-calculated quantity. Any piece of equipment may contain Measurements, e.g. a substation may have temperature measurements and door open indications, a transformer may have oil temperature and tank pressure measurements, a bay may contain a number of power flow measurements and a Breaker may contain a switch status measurement. The PSR - Measurement association is intended to capture this use of Measurement and is included in the naming hierarchy based on EquipmentContainer. The naming hierarchy typically has Measurements as leafs, e.g. Substation-VoltageLevel-Bay-Switch-Measurement. Some Measurements represent quantities related to a particular sensor location in the network, e.g. a voltage transformer (PT) at a busbar or a current transformer (CT) at the bar between a breaker and an isolator. The sensing position is not captured in the PSR - Measurement association. Instead it is captured by the Measurement - Terminal association that is used to define the sensing location in the network topology. The location is defined by the connection of the Terminal to ConductingEquipment. Two possible paths exist: 1) Measurement-Terminal- ConnectivityNode-Terminal-ConductingEquipment 2) Measurement-Terminal-ConductingEquipment Alternative 2 is the only allowed use. When the sensor location is needed both Measurement-PSR and Measurement-Terminal are used. The Measurement-Terminal association is never used alone.
27 def __init__(self
, measurementType
='', PowerSystemResource
=None, Locations
=None, Terminal
=None, Unit
=None, tieToMeasurement0
=None, Asset
=None, Documents
=None, *args
, **kw_args
):
28 """Initialises a new 'Measurement' instance.
30 @param measurementType: Specifies the type of Measurement, e.g. IndoorTemperature, OutDoorTemperature, BusVoltage, GeneratorVoltage, LineFlow etc.
31 @param PowerSystemResource: The PowerSystemResource that contains the Measurement in the naming hierarchy
33 @param Terminal: One or more measurements may be associated with a terminal in the network
34 @param Unit: The Unit for the Measurement
35 @param tieToMeasurement0:
37 @param Documents: Measurements are specified in types of documents, such as procedures.
39 #: Specifies the type of Measurement, e.g. IndoorTemperature, OutDoorTemperature, BusVoltage, GeneratorVoltage, LineFlow etc.
40 self
.measurementType
= measurementType
42 self
._PowerSystemResource
= None
43 self
.PowerSystemResource
= PowerSystemResource
46 self
.Locations
= [] if Locations
is None else Locations
49 self
.Terminal
= Terminal
54 self
._tieToMeasurement
0 = []
55 self
.tieToMeasurement0
= [] if tieToMeasurement0
is None else tieToMeasurement0
61 self
.Documents
= [] if Documents
is None else Documents
63 super(Measurement
, self
).__init
__(*args
, **kw_args
)
65 _attrs
= ["measurementType"]
66 _attr_types
= {"measurementType": str}
67 _defaults
= {"measurementType": ''}
69 _refs
= ["PowerSystemResource", "Locations", "Terminal", "Unit", "tieToMeasurement0", "Asset", "Documents"]
70 _many_refs
= ["Locations", "tieToMeasurement0", "Documents"]
72 def getPowerSystemResource(self
):
73 """The PowerSystemResource that contains the Measurement in the naming hierarchy
75 return self
._PowerSystemResource
77 def setPowerSystemResource(self
, value
):
78 if self
._PowerSystemResource
is not None:
79 filtered
= [x
for x
in self
.PowerSystemResource
.Measurements
if x
!= self
]
80 self
._PowerSystemResource
._Measurements
= filtered
82 self
._PowerSystemResource
= value
83 if self
._PowerSystemResource
is not None:
84 if self
not in self
._PowerSystemResource
._Measurements
:
85 self
._PowerSystemResource
._Measurements
.append(self
)
87 PowerSystemResource
= property(getPowerSystemResource
, setPowerSystemResource
)
89 def getLocations(self
):
91 return self
._Locations
93 def setLocations(self
, value
):
94 for p
in self
._Locations
:
95 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
96 self
._Locations
._Measurements
= filtered
98 if self
not in r
._Measurements
:
99 r
._Measurements
.append(self
)
100 self
._Locations
= value
102 Locations
= property(getLocations
, setLocations
)
104 def addLocations(self
, *Locations
):
105 for obj
in Locations
:
106 if self
not in obj
._Measurements
:
107 obj
._Measurements
.append(self
)
108 self
._Locations
.append(obj
)
110 def removeLocations(self
, *Locations
):
111 for obj
in Locations
:
112 if self
in obj
._Measurements
:
113 obj
._Measurements
.remove(self
)
114 self
._Locations
.remove(obj
)
116 def getTerminal(self
):
117 """One or more measurements may be associated with a terminal in the network
119 return self
._Terminal
121 def setTerminal(self
, value
):
122 if self
._Terminal
is not None:
123 filtered
= [x
for x
in self
.Terminal
.Measurements
if x
!= self
]
124 self
._Terminal
._Measurements
= filtered
126 self
._Terminal
= value
127 if self
._Terminal
is not None:
128 if self
not in self
._Terminal
._Measurements
:
129 self
._Terminal
._Measurements
.append(self
)
131 Terminal
= property(getTerminal
, setTerminal
)
134 """The Unit for the Measurement
138 def setUnit(self
, value
):
139 if self
._Unit
is not None:
140 filtered
= [x
for x
in self
.Unit
.Measurements
if x
!= self
]
141 self
._Unit
._Measurements
= filtered
144 if self
._Unit
is not None:
145 if self
not in self
._Unit
._Measurements
:
146 self
._Unit
._Measurements
.append(self
)
148 Unit
= property(getUnit
, setUnit
)
150 def gettieToMeasurement0(self
):
152 return self
._tieToMeasurement
0
154 def settieToMeasurement0(self
, value
):
155 for x
in self
._tieToMeasurement
0:
156 x
.measurement0
= None
158 y
._measurement
0 = self
159 self
._tieToMeasurement
0 = value
161 tieToMeasurement0
= property(gettieToMeasurement0
, settieToMeasurement0
)
163 def addtieToMeasurement0(self
, *tieToMeasurement0
):
164 for obj
in tieToMeasurement0
:
165 obj
.measurement0
= self
167 def removetieToMeasurement0(self
, *tieToMeasurement0
):
168 for obj
in tieToMeasurement0
:
169 obj
.measurement0
= None
175 def setAsset(self
, value
):
176 if self
._Asset
is not None:
177 filtered
= [x
for x
in self
.Asset
.Measurements
if x
!= self
]
178 self
._Asset
._Measurements
= filtered
181 if self
._Asset
is not None:
182 if self
not in self
._Asset
._Measurements
:
183 self
._Asset
._Measurements
.append(self
)
185 Asset
= property(getAsset
, setAsset
)
187 def getDocuments(self
):
188 """Measurements are specified in types of documents, such as procedures.
190 return self
._Documents
192 def setDocuments(self
, value
):
193 for p
in self
._Documents
:
194 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
195 self
._Documents
._Measurements
= filtered
197 if self
not in r
._Measurements
:
198 r
._Measurements
.append(self
)
199 self
._Documents
= value
201 Documents
= property(getDocuments
, setDocuments
)
203 def addDocuments(self
, *Documents
):
204 for obj
in Documents
:
205 if self
not in obj
._Measurements
:
206 obj
._Measurements
.append(self
)
207 self
._Documents
.append(obj
)
209 def removeDocuments(self
, *Documents
):
210 for obj
in Documents
:
211 if self
in obj
._Measurements
:
212 obj
._Measurements
.remove(self
)
213 self
._Documents
.remove(obj
)