Sample Duet Code
Spire_Jeff Posts: 1,917
Here is a sample module that was sent to me by Stephen Steiner from AMX. It helped me clarify a couple of things in my head, so I am posting it here (with permission) in hopes that it might help someone else. I will also be posting a sample piece of code that I am working on that works with buttons and channels to drive events.
Thanks for posting that source. I think this will help out a lot.
Interesting that he chose to extend the switcher class. I thought I read previously on the forums that the utility class was meant to be used for this sort of stuff?
Maybe, I'll try and rework the code to use the utility class instead.
As soon as I figure it out, I'll try to post a little tutorial aimed at those that are experienced in NetLinx, and have some idea of using Java, but have not had a chance to make the jump. I will say that there was a LOT of functionality I could add in Java very easily, so I regret not being able to figure it out.
I'm checking the log file because there are a few statements in the Java source that look like messages are being sent there and I'm sending every command data_event that I get from the module to a text box on a panel, but I'm still not seeing any feedback.
I think my next step is going to be to start digging into the Java debugging system and try and step through the code if that's possible.
It appears that based on the send_command text that I send to the virtual device, different event handlers in the Java module are triggered. For example, if I do this: only the handleAdvancedEvent() is triggered.
But if I send anything with an equals sign in it: or then the handleDataEvent() is triggered followed by the handleAdvancedEvent() after handleDataEvent() has exited.
What is so special about the handleDataEvent() handler that it wouldn't be triggered in the first example, but would be in the second? Maybe I should just always use the handleAdvancedEvent() handler instead so that I'm always certain that I'll be getting all the data from the send_command?
And why make the equals sign the thing that causes the handleDataEvent() to be triggered when AMX has always used commas as the delimiters between property names and values?
I did find this though, if you mouse over the declarations for some of the methods you can get some documentation about that method. So, when I moused over the handleAdvancedEvent() this is what it says:
So, there is some sort of pre-processing going on between the send_command in my NetLinx code and the actual event handler which is causing the JVM to choose one event handler over the other.