Communicating with multiple devices in an event handler
Posted: Wed Nov 14, 2018 11:17 pm
It is possible that I am just missing something simple here, but it's not clear how to make an event handler in Python aware of multiple Phidgets (that is, not just the caller Phidget). What I am trying to do is have a cgi script running on a Phidgets SBC change two voltage output settings on voltage output Phidgets connected to the SBC. Of course, the cgi script can't just attach the voltage output Phidgets, set voltages, and then close them, because the voltage outputs go back to zero on close (although this approach would be much more sensible in this application, because the voltage doesn't need to be set very often....is there any way to have the voltage output just keep its setting on close?).
But anyway, based on the documentation, it seems like the way to do this is to have the cgi script attach a Phidgets dictionary, change a value in the dictionary, and then exit. Then a separate program that has also attached the dictionary sets an event handler such that an update to a dictionary value triggers changes in the voltage outputs. So then I need to have a program running in the background that has attached three Phidgets (dictionary, voltage output 1, voltage output 2) and also set an event handler that triggers when a key in the dictionary is updated (by a totally different program in this case). The thing that I'm missing is how to make the event handler (which is triggered by the dictionary object) able to set parameters of the other two objects. Is there some example code that does something like this? Or am I totally out to lunch and there is a different way to do this?
thanks,
But anyway, based on the documentation, it seems like the way to do this is to have the cgi script attach a Phidgets dictionary, change a value in the dictionary, and then exit. Then a separate program that has also attached the dictionary sets an event handler such that an update to a dictionary value triggers changes in the voltage outputs. So then I need to have a program running in the background that has attached three Phidgets (dictionary, voltage output 1, voltage output 2) and also set an event handler that triggers when a key in the dictionary is updated (by a totally different program in this case). The thing that I'm missing is how to make the event handler (which is triggered by the dictionary object) able to set parameters of the other two objects. Is there some example code that does something like this? Or am I totally out to lunch and there is a different way to do this?
thanks,