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
.Core
.IdentifiedObject
import IdentifiedObject
19 class Measurement(IdentifiedObject
):
20 """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.
23 def __init__(self
, measurementType
='', PowerSystemResource
=None, Locations
=None, Terminal
=None, Unit
=None, tieToMeasurement0
=None, Asset
=None, Documents
=None, *args
, **kw_args
):
24 """Initialises a new 'Measurement' instance.
26 @param measurementType: Specifies the type of Measurement, e.g. IndoorTemperature, OutDoorTemperature, BusVoltage, GeneratorVoltage, LineFlow etc.
27 @param PowerSystemResource: The PowerSystemResource that contains the Measurement in the naming hierarchy
29 @param Terminal: One or more measurements may be associated with a terminal in the network
30 @param Unit: The Unit for the Measurement
31 @param tieToMeasurement0:
33 @param Documents: Measurements are specified in types of documents, such as procedures.
35 #: Specifies the type of Measurement, e.g. IndoorTemperature, OutDoorTemperature, BusVoltage, GeneratorVoltage, LineFlow etc.
36 self
.measurementType
= measurementType
38 self
._PowerSystemResource
= None
39 self
.PowerSystemResource
= PowerSystemResource
42 self
.Locations
= [] if Locations
is None else Locations
45 self
.Terminal
= Terminal
50 self
._tieToMeasurement
0 = []
51 self
.tieToMeasurement0
= [] if tieToMeasurement0
is None else tieToMeasurement0
57 self
.Documents
= [] if Documents
is None else Documents
59 super(Measurement
, self
).__init
__(*args
, **kw_args
)
61 _attrs
= ["measurementType"]
62 _attr_types
= {"measurementType": str}
63 _defaults
= {"measurementType": ''}
65 _refs
= ["PowerSystemResource", "Locations", "Terminal", "Unit", "tieToMeasurement0", "Asset", "Documents"]
66 _many_refs
= ["Locations", "tieToMeasurement0", "Documents"]
68 def getPowerSystemResource(self
):
69 """The PowerSystemResource that contains the Measurement in the naming hierarchy
71 return self
._PowerSystemResource
73 def setPowerSystemResource(self
, value
):
74 if self
._PowerSystemResource
is not None:
75 filtered
= [x
for x
in self
.PowerSystemResource
.Measurements
if x
!= self
]
76 self
._PowerSystemResource
._Measurements
= filtered
78 self
._PowerSystemResource
= value
79 if self
._PowerSystemResource
is not None:
80 self
._PowerSystemResource
._Measurements
.append(self
)
82 PowerSystemResource
= property(getPowerSystemResource
, setPowerSystemResource
)
84 def getLocations(self
):
86 return self
._Locations
88 def setLocations(self
, value
):
89 for p
in self
._Locations
:
90 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
91 self
._Locations
._Measurements
= filtered
93 if self
not in r
._Measurements
:
94 r
._Measurements
.append(self
)
95 self
._Locations
= value
97 Locations
= property(getLocations
, setLocations
)
99 def addLocations(self
, *Locations
):
100 for obj
in Locations
:
101 if self
not in obj
._Measurements
:
102 obj
._Measurements
.append(self
)
103 self
._Locations
.append(obj
)
105 def removeLocations(self
, *Locations
):
106 for obj
in Locations
:
107 if self
in obj
._Measurements
:
108 obj
._Measurements
.remove(self
)
109 self
._Locations
.remove(obj
)
111 def getTerminal(self
):
112 """One or more measurements may be associated with a terminal in the network
114 return self
._Terminal
116 def setTerminal(self
, value
):
117 if self
._Terminal
is not None:
118 filtered
= [x
for x
in self
.Terminal
.Measurements
if x
!= self
]
119 self
._Terminal
._Measurements
= filtered
121 self
._Terminal
= value
122 if self
._Terminal
is not None:
123 self
._Terminal
._Measurements
.append(self
)
125 Terminal
= property(getTerminal
, setTerminal
)
128 """The Unit for the Measurement
132 def setUnit(self
, value
):
133 if self
._Unit
is not None:
134 filtered
= [x
for x
in self
.Unit
.Measurements
if x
!= self
]
135 self
._Unit
._Measurements
= filtered
138 if self
._Unit
is not None:
139 self
._Unit
._Measurements
.append(self
)
141 Unit
= property(getUnit
, setUnit
)
143 def gettieToMeasurement0(self
):
145 return self
._tieToMeasurement
0
147 def settieToMeasurement0(self
, value
):
148 for x
in self
._tieToMeasurement
0:
149 x
._measurement
0 = None
151 y
._measurement
0 = self
152 self
._tieToMeasurement
0 = value
154 tieToMeasurement0
= property(gettieToMeasurement0
, settieToMeasurement0
)
156 def addtieToMeasurement0(self
, *tieToMeasurement0
):
157 for obj
in tieToMeasurement0
:
158 obj
._measurement
0 = self
159 self
._tieToMeasurement
0.append(obj
)
161 def removetieToMeasurement0(self
, *tieToMeasurement0
):
162 for obj
in tieToMeasurement0
:
163 obj
._measurement
0 = None
164 self
._tieToMeasurement
0.remove(obj
)
170 def setAsset(self
, value
):
171 if self
._Asset
is not None:
172 filtered
= [x
for x
in self
.Asset
.Measurements
if x
!= self
]
173 self
._Asset
._Measurements
= filtered
176 if self
._Asset
is not None:
177 self
._Asset
._Measurements
.append(self
)
179 Asset
= property(getAsset
, setAsset
)
181 def getDocuments(self
):
182 """Measurements are specified in types of documents, such as procedures.
184 return self
._Documents
186 def setDocuments(self
, value
):
187 for p
in self
._Documents
:
188 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
189 self
._Documents
._Measurements
= filtered
191 if self
not in r
._Measurements
:
192 r
._Measurements
.append(self
)
193 self
._Documents
= value
195 Documents
= property(getDocuments
, setDocuments
)
197 def addDocuments(self
, *Documents
):
198 for obj
in Documents
:
199 if self
not in obj
._Measurements
:
200 obj
._Measurements
.append(self
)
201 self
._Documents
.append(obj
)
203 def removeDocuments(self
, *Documents
):
204 for obj
in Documents
:
205 if self
in obj
._Measurements
:
206 obj
._Measurements
.remove(self
)
207 self
._Documents
.remove(obj
)