You can register all four channels to the same event, like this:
Code: Select all
ch0.setChannel(0)
ch1.setChannel(1)
ch2.setChannel(2)
ch3.setChannel(3)
ch0.setOnVoltageRatioChangeHandler(VoltageRatioChangeHandler)
ch1.setOnVoltageRatioChangeHandler(VoltageRatioChangeHandler)
ch2.setOnVoltageRatioChangeHandler(VoltageRatioChangeHandler)
ch3.setOnVoltageRatioChangeHandler(VoltageRatioChangeHandler)
The change handler can tell the difference between which channel triggered the event by looking at the first parameter:
Code: Select all
def VoltageRatioChangeHandler(e, voltageRatio):
print("CH%d: VoltageRatio: %f" % (e.getChannel(), voltageRatio))
In this case, the first parameter "e" contains all of the information about who triggered the event (in future examples we might rename "e" to "self" to make this more intuitive). As you can see, e.getChannel() tells you which number the triggering channel is set to.