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 if self
not in self
._PowerSystemResource
._Measurements
:
81 self
._PowerSystemResource
._Measurements
.append(self
)
83 PowerSystemResource
= property(getPowerSystemResource
, setPowerSystemResource
)
85 def getLocations(self
):
87 return self
._Locations
89 def setLocations(self
, value
):
90 for p
in self
._Locations
:
91 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
92 self
._Locations
._Measurements
= filtered
94 if self
not in r
._Measurements
:
95 r
._Measurements
.append(self
)
96 self
._Locations
= value
98 Locations
= property(getLocations
, setLocations
)
100 def addLocations(self
, *Locations
):
101 for obj
in Locations
:
102 if self
not in obj
._Measurements
:
103 obj
._Measurements
.append(self
)
104 self
._Locations
.append(obj
)
106 def removeLocations(self
, *Locations
):
107 for obj
in Locations
:
108 if self
in obj
._Measurements
:
109 obj
._Measurements
.remove(self
)
110 self
._Locations
.remove(obj
)
112 def getTerminal(self
):
113 """One or more measurements may be associated with a terminal in the network
115 return self
._Terminal
117 def setTerminal(self
, value
):
118 if self
._Terminal
is not None:
119 filtered
= [x
for x
in self
.Terminal
.Measurements
if x
!= self
]
120 self
._Terminal
._Measurements
= filtered
122 self
._Terminal
= value
123 if self
._Terminal
is not None:
124 if self
not in self
._Terminal
._Measurements
:
125 self
._Terminal
._Measurements
.append(self
)
127 Terminal
= property(getTerminal
, setTerminal
)
130 """The Unit for the Measurement
134 def setUnit(self
, value
):
135 if self
._Unit
is not None:
136 filtered
= [x
for x
in self
.Unit
.Measurements
if x
!= self
]
137 self
._Unit
._Measurements
= filtered
140 if self
._Unit
is not None:
141 if self
not in self
._Unit
._Measurements
:
142 self
._Unit
._Measurements
.append(self
)
144 Unit
= property(getUnit
, setUnit
)
146 def gettieToMeasurement0(self
):
148 return self
._tieToMeasurement
0
150 def settieToMeasurement0(self
, value
):
151 for x
in self
._tieToMeasurement
0:
152 x
.measurement0
= None
154 y
._measurement
0 = self
155 self
._tieToMeasurement
0 = value
157 tieToMeasurement0
= property(gettieToMeasurement0
, settieToMeasurement0
)
159 def addtieToMeasurement0(self
, *tieToMeasurement0
):
160 for obj
in tieToMeasurement0
:
161 obj
.measurement0
= self
163 def removetieToMeasurement0(self
, *tieToMeasurement0
):
164 for obj
in tieToMeasurement0
:
165 obj
.measurement0
= None
171 def setAsset(self
, value
):
172 if self
._Asset
is not None:
173 filtered
= [x
for x
in self
.Asset
.Measurements
if x
!= self
]
174 self
._Asset
._Measurements
= filtered
177 if self
._Asset
is not None:
178 if self
not in self
._Asset
._Measurements
:
179 self
._Asset
._Measurements
.append(self
)
181 Asset
= property(getAsset
, setAsset
)
183 def getDocuments(self
):
184 """Measurements are specified in types of documents, such as procedures.
186 return self
._Documents
188 def setDocuments(self
, value
):
189 for p
in self
._Documents
:
190 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
191 self
._Documents
._Measurements
= filtered
193 if self
not in r
._Measurements
:
194 r
._Measurements
.append(self
)
195 self
._Documents
= value
197 Documents
= property(getDocuments
, setDocuments
)
199 def addDocuments(self
, *Documents
):
200 for obj
in Documents
:
201 if self
not in obj
._Measurements
:
202 obj
._Measurements
.append(self
)
203 self
._Documents
.append(obj
)
205 def removeDocuments(self
, *Documents
):
206 for obj
in Documents
:
207 if self
in obj
._Measurements
:
208 obj
._Measurements
.remove(self
)
209 self
._Documents
.remove(obj
)