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
.Control
import Control
23 class Command(Control
):
24 """A Command is a discrete control used for supervisory control.
27 def __init__(self
, value
=0, normalValue
=0, ValueAliasSet
=None, Discrete
=None, *args
, **kw_args
):
28 """Initialises a new 'Command' instance.
30 @param value: The value representing the actuator output
31 @param normalValue: Normal value for Control.value e.g. used for percentage scaling
32 @param ValueAliasSet: The Commands using the set for translation.
33 @param Discrete: The Measurement variable used for control.
35 #: The value representing the actuator output
38 #: Normal value for Control.value e.g. used for percentage scaling
39 self
.normalValue
= normalValue
41 self
._ValueAliasSet
= None
42 self
.ValueAliasSet
= ValueAliasSet
45 self
.Discrete
= Discrete
47 super(Command
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["value", "normalValue"]
50 _attr_types
= {"value": int, "normalValue": int}
51 _defaults
= {"value": 0, "normalValue": 0}
53 _refs
= ["ValueAliasSet", "Discrete"]
56 def getValueAliasSet(self
):
57 """The Commands using the set for translation.
59 return self
._ValueAliasSet
61 def setValueAliasSet(self
, value
):
62 if self
._ValueAliasSet
is not None:
63 filtered
= [x
for x
in self
.ValueAliasSet
.Commands
if x
!= self
]
64 self
._ValueAliasSet
._Commands
= filtered
66 self
._ValueAliasSet
= value
67 if self
._ValueAliasSet
is not None:
68 if self
not in self
._ValueAliasSet
._Commands
:
69 self
._ValueAliasSet
._Commands
.append(self
)
71 ValueAliasSet
= property(getValueAliasSet
, setValueAliasSet
)
73 def getDiscrete(self
):
74 """The Measurement variable used for control.
78 def setDiscrete(self
, value
):
79 if self
._Discrete
is not None:
80 self
._Discrete
._Command
= None
82 self
._Discrete
= value
83 if self
._Discrete
is not None:
84 self
._Discrete
.Command
= None
85 self
._Discrete
._Command
= self
87 Discrete
= property(getDiscrete
, setDiscrete
)