Reputation: 1
I am developing a web app that simulates a wire bending machine. I already have the app working but now I need to send the code (list of coordinates that will make a certain piece) to the machine controller. What do you think it's the best way to do this? I'm thinking of WebSockets since the Omron's controller as socket instructions. I used a link instead of the IP adress so I could test that my code could read the content correctly and it did. My code in javascript:
function abrirSocket()
{
ws = new WebSocket('wss://192.168.250.1');
CheckBlankSpace();
var linhas = document.getElementById("txtMaq").length;
var txtMaq = document.getElementById("txtMaq");
var content = "";
for(var i=0; i <=linhas-1; i++)
{
//get the code to send to the machinet
content += txtMaq[i].value + "\n";
};
ws.onopen = function ()
{
ws.send(content);
}
ws.onmessage = function(msg)
{
alert(content);
}
ws.onerror = function (error)
{
alert(`[error] Não foi possível estabelecer uma conexão`);
}
ws.onclose = function ()
{ if (event.wasClean)
{
alert(`[close] Conexão terminada, code=${event.code}`);
}
else
{
alert('[close] Connection died');
}
}
};
Upvotes: 0
Views: 153
Reputation: 21
Try to look at OMRON Fins Protocol. This is (Omron) standard and well documented thing supported by many Omron controllers, also the cheaper one via serial bus. You can read/write values and more. It can use UDP or TCP connection there (both have pros and cons). I have no idea about java script library, but I used Qt and Python binding library for this.
Upvotes: 1