My question is, is there a way to dynamically create the correct type?
Cannot use ch.__class__ as it is always an instance of class Phidget.
Is it possible to use ch.getChannelClassName() to somehow create the proper class instance?
Otherwise we get code like this:
Code: Select all
def on_manager_attach_handler(self, ch):
if ch.getChannelClass() == ChannelClass.PHIDCHCLASS_DIGITALINPUT:
ch_new = DigitalInput()
elif ch.getChannelClass() == ChannelClass.PHIDCHCLASS_DIGITALOUTPUT:
ch_new = DigitalOutput()
...