I'm TRYING to use JavaScript to develop an app for prototypically accurate control of model trains, using JMRI (Java Model Railroad Interface).
JMRI is on a computer connected to my model train layout, and basically makes it easy to do things with computers and model trains.
Now, here's what I want to do.
You probably know model trains are (basically, there's some digital voodoo magic involved now that allows you to run multiple trains on a single electrical circuit, but that's besides the point) controlled by a single speed slider and a direction switch. Real diesel locomotives are not controlled by a single speed slider. I could explain how they are controlled but it's not necessary for this so if you're wondering Google it :P
ANYWAY, I'm trying to use JMRI and some JavaScript to control a model train engine realistically through a web browser. I want to have a web interface that mimics an actual locomotive cab control setup, with a separate lever for braking, notching the throttle, the reverser, etc. I don't need help building the interface, I need help getting it all to communicate with JMRI on the PC connected to the layout.
JMRI has a page explaining their ways of doing this, but I don't completely understand how to send commands to this console using JavaScript.
http://jmri.sourceforge.net/help/en/html/web/JsonServlet.shtml
The "JMRI Web Server" program it mentions here is running on my layout PC and is accessible at http://jmri.mylocaldomainhere:12080/ if anyone needs that info for helping me.
How would I get JavaScript to send a command to the WebSockets server?
Thanks, any and all help is appreciated, if you need any additional info about how I've got things set up let me know. Like I said I don't need help designing the whole program, I basically need someone to tell me how to send a command to the websockets server so I can do something like this with a function:
websocketscmd(command)
and it'll execute it on the layout PC and return the result
TL;DR How do I execute one of these commands with JavaScript?