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 CIM15
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
23 class CUAsset(IdentifiedObject
):
24 """Compatible unit for various types of assets such as transformers switches, substation fences, poles, etc..Compatible unit for various types of assets such as transformers switches, substation fences, poles, etc..
27 def __init__(self
, quantity
="", typeAssetCode
='', CompatibleUnits
=None, TypeAsset
=None, status
=None, *args
, **kw_args
):
28 """Initialises a new 'CUAsset' instance.
30 @param quantity: Quantity of the type asset within the CU.
31 @param typeAssetCode: The code for this type of asset.
32 @param CompatibleUnits:
36 #: Quantity of the type asset within the CU.
37 self
.quantity
= quantity
39 #: The code for this type of asset.
40 self
.typeAssetCode
= typeAssetCode
42 self
._CompatibleUnits
= []
43 self
.CompatibleUnits
= [] if CompatibleUnits
is None else CompatibleUnits
45 self
._TypeAsset
= None
46 self
.TypeAsset
= TypeAsset
50 super(CUAsset
, self
).__init
__(*args
, **kw_args
)
52 _attrs
= ["quantity", "typeAssetCode"]
53 _attr_types
= {"quantity": str, "typeAssetCode": str}
54 _defaults
= {"quantity": "", "typeAssetCode": ''}
56 _refs
= ["CompatibleUnits", "TypeAsset", "status"]
57 _many_refs
= ["CompatibleUnits"]
59 def getCompatibleUnits(self
):
61 return self
._CompatibleUnits
63 def setCompatibleUnits(self
, value
):
64 for p
in self
._CompatibleUnits
:
65 filtered
= [q
for q
in p
.CUAssets
if q
!= self
]
66 self
._CompatibleUnits
._CUAssets
= filtered
68 if self
not in r
._CUAssets
:
69 r
._CUAssets
.append(self
)
70 self
._CompatibleUnits
= value
72 CompatibleUnits
= property(getCompatibleUnits
, setCompatibleUnits
)
74 def addCompatibleUnits(self
, *CompatibleUnits
):
75 for obj
in CompatibleUnits
:
76 if self
not in obj
._CUAssets
:
77 obj
._CUAssets
.append(self
)
78 self
._CompatibleUnits
.append(obj
)
80 def removeCompatibleUnits(self
, *CompatibleUnits
):
81 for obj
in CompatibleUnits
:
82 if self
in obj
._CUAssets
:
83 obj
._CUAssets
.remove(self
)
84 self
._CompatibleUnits
.remove(obj
)
86 def getTypeAsset(self
):
88 return self
._TypeAsset
90 def setTypeAsset(self
, value
):
91 if self
._TypeAsset
is not None:
92 self
._TypeAsset
._CUAsset
= None
94 self
._TypeAsset
= value
95 if self
._TypeAsset
is not None:
96 self
._TypeAsset
.CUAsset
= None
97 self
._TypeAsset
._CUAsset
= self
99 TypeAsset
= property(getTypeAsset
, setTypeAsset
)