EnumUnion (hwx.inspire.Attributes)#

class EnumUnion(enum, *args, **kwds)#

Bases: CompositeAttribute

Group of mutually exclusive attributes where only one is active at at time.

The active attribute is controlled by a separate Enum Attribute.

Method Table#

Name

Description

getActiveKey (self, obj)

Returns the active attribute.

Example

from hwx.inspire import *

class Motor(GeneralObject):
type  = Enum('ANGLE SPEED ACCELERATION')
value = EnumUnion(type,
   Double ("45 deg",   units='angle'),
   Double ("60 rpm",   units='ang_velocity'),
   Double ("1 rad/s2", units='ang_acceleration'),
)

motor = Motor()
print(motor.type, motor.value, motor.value.units)

motor.type = 'SPEED'
print(motor.type, motor.value, motor.value.units)
getActiveKey(obj)#

Returns the active attribute.