Connect external devices

Connect external devices

  

Hi, is it possible to connect external devices usingopen protocol commands with Outsystems application? 

Skumar wrote:

Hi, is it possible to connect external devices usingopen protocol commands with Outsystems application? 

Dear Skumar,

Which devices you wanted to connect? Please give some details about your requirement.

Regards,


Hello Skumar,

You need to start providing information if you are talking about Mobile or Web application.

In mobile, maybe. You need to see if there is any Cordova Plugin that allows you to do that.
In Web, probably not (I'm not sure), because you would need to use JavaScript to do that and any browser running your application will prevent this due security risks. In your device is attached to a server, if you can install a Node.js server application in it, than maybe.

Of course, this is as far as I know (I may be wrong).

Cheers.

Eduardo Jauch wrote:

Hello Skumar,

You need to start providing information if you are talking about Mobile or Web application.

In mobile, maybe. You need to see if there is any Cordova Plugin that allows you to do that.
In Web, probably not (I'm not sure), because you would need to use JavaScript to do that and any browser running your application will prevent this due security risks. In your device is attached to a server, if you can install a Node.js server application in it, than maybe.

Of course, this is as far as I know (I may be wrong).

Cheers.

Hello Eduardo & Mohammad,

Thanks for showing interest on my question. 

The detail of my question is, we have programmable torque drivers (Atlas Copco & Apex Tools (Cleco tools)) in our organization. These devises we are using to fastening the screws, nuts & bolts on highly precise with targeted torque value. These devises will provide out put of the torque value applied of each fastenings through 'open protocol' commands. We want to record these values for tractability & future analysis. I developed a application on C# to communicate to these devises & collecting each single torque value & store them on SQL table. 

Due to cyber security issues our IT network team asking to move all windows desktop applications to Outsystems Web application which is highly secured. 

For your reference here below I showing a small C# snippet which will communicate to the torque drivers & collecting the screw fastening data.

Also attached a PDF file of Open Protocol commands.

Snippet

using System;
using System.Text;
using System.Windows;
using System.Net.Sockets;
using System.IO;
using System.Diagnostics;
using System.Windows.Threading;
 
namespace Winsock
{
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        TcpClient LaserIp;
        NetworkStream LaserStream;
        public byte[] dd,dd1;
        StreamReader Sr;
        Stopwatch watch;
        DispatcherTimer timer,timer1;
        bool Check;
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            watch = new Stopwatch();
            watch.Start();
            watch.Stop();
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick += timer_Tick;
            timer.Start();
            timer1 = new DispatcherTimer();
            timer1.Interval = TimeSpan.FromSeconds(10);
            timer1.Tick += timer1_Tick;
            //timer1.Start();
            watch = new Stopwatch();
            watch.Start();
            watch.Stop();
            Check = false;
            lblDesc.Content = "Press Connect Button to Start Communication";
        }
         
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Check = false;
            LaserIp = new TcpClient("192.168.10.10", 9001);
            LaserStream = LaserIp.GetStream();
            Sr = new StreamReader(LaserStream);
            //dd = System.Text.Encoding.ASCII.GetBytes("00200001000         ");
            dd = System.Text.Encoding.ASCII.GetBytes("0020000100          ");
            int i = dd.Length;
            dd1 = new byte[i + 1];
            for (int j = 0; j < 20; j++)
            {
                dd1[j] = dd[j];
            }
            dd1[20] = 0x0;
            LaserStream.Write(dd1, 0, dd1.Length);
            watch.Restart();
            while (true)
            {
                if (watch.ElapsedMilliseconds > 2000)
                {
                    txtBarcode.Text="Controller Connection Problem";
                    return;
                }
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[100];
                    LaserStream.Read(dd2, 0, 100);
                    lblDesc.Content = "Controller Connected";
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    break;
                }
            }
            watch.Stop();
            //Thread.Sleep(1000);
           // dd = System.Text.Encoding.ASCII.GetBytes("00200060000         ");
            dd = System.Text.Encoding.ASCII.GetBytes("0020006000          ");
            i = dd.Length;
            dd1 = new byte[i + 1];
            for (int j = 0; j < 20; j++)
            {
                dd1[j] = dd[j];
            }
            dd1[20] = 0x0;
            LaserStream.Write(dd1, 0, dd1.Length);
            watch.Restart();
            while (true)
            {
                if (watch.ElapsedMilliseconds > 2000)
                {
                    txtBarcode.Text = "Controller Connection Problem";
                    return;
                }
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[100];
                    LaserStream.Read(dd2, 0, 100);
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    lblDesc.Content = "Waiting for Screwing Data";
                    Check = true;
                    break;                 
                }
            }
            watch.Stop();
           
        }

        private void timer_Tick(object sender, EventArgs e)
        {
           if (Check == true)
          {
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[500];
                    LaserStream.Read(dd2, 0, 500);
                    string b = Encoding.ASCII.GetString(dd2);
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    lblDesc.Content = "Screwing Data Received. Waiting for Next Screwing Data";
                }
          }
        }
    }
}

Skumar wrote:

Eduardo Jauch wrote:

Hello Skumar,

You need to start providing information if you are talking about Mobile or Web application.

In mobile, maybe. You need to see if there is any Cordova Plugin that allows you to do that.
In Web, probably not (I'm not sure), because you would need to use JavaScript to do that and any browser running your application will prevent this due security risks. In your device is attached to a server, if you can install a Node.js server application in it, than maybe.

Of course, this is as far as I know (I may be wrong).

Cheers.

Hello Eduardo & Mohammad,

Thanks for showing interest on my question. 

The detail of my question is, we have programmable torque drivers (Atlas Copco & Apex Tools (Cleco tools)) in our organization. These devises we are using to fastening the screws, nuts & bolts on highly precise with targeted torque value. These devises will provide out put of the torque value applied of each fastenings through 'open protocol' commands. We want to record these values for tractability & future analysis. I developed a application on C# to communicate to these devises & collecting each single torque value & store them on SQL table. 

Due to cyber security issues our IT network team asking to move all windows desktop applications to Outsystems Web application which is highly secured. 

For your reference here below I showing a small C# snippet which will communicate to the torque drivers & collecting the screw fastening data.

Also attached a PDF file of Open Protocol commands.

Snippet

using System;
using System.Text;
using System.Windows;
using System.Net.Sockets;
using System.IO;
using System.Diagnostics;
using System.Windows.Threading;
 
namespace Winsock
{
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        TcpClient LaserIp;
        NetworkStream LaserStream;
        public byte[] dd,dd1;
        StreamReader Sr;
        Stopwatch watch;
        DispatcherTimer timer,timer1;
        bool Check;
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            watch = new Stopwatch();
            watch.Start();
            watch.Stop();
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick += timer_Tick;
            timer.Start();
            timer1 = new DispatcherTimer();
            timer1.Interval = TimeSpan.FromSeconds(10);
            timer1.Tick += timer1_Tick;
            //timer1.Start();
            watch = new Stopwatch();
            watch.Start();
            watch.Stop();
            Check = false;
            lblDesc.Content = "Press Connect Button to Start Communication";
        }
         
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Check = false;
            LaserIp = new TcpClient("192.168.10.10", 9001);
            LaserStream = LaserIp.GetStream();
            Sr = new StreamReader(LaserStream);
            //dd = System.Text.Encoding.ASCII.GetBytes("00200001000         ");
            dd = System.Text.Encoding.ASCII.GetBytes("0020000100          ");
            int i = dd.Length;
            dd1 = new byte[i + 1];
            for (int j = 0; j < 20; j++)
            {
                dd1[j] = dd[j];
            }
            dd1[20] = 0x0;
            LaserStream.Write(dd1, 0, dd1.Length);
            watch.Restart();
            while (true)
            {
                if (watch.ElapsedMilliseconds > 2000)
                {
                    txtBarcode.Text="Controller Connection Problem";
                    return;
                }
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[100];
                    LaserStream.Read(dd2, 0, 100);
                    lblDesc.Content = "Controller Connected";
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    break;
                }
            }
            watch.Stop();
            //Thread.Sleep(1000);
           // dd = System.Text.Encoding.ASCII.GetBytes("00200060000         ");
            dd = System.Text.Encoding.ASCII.GetBytes("0020006000          ");
            i = dd.Length;
            dd1 = new byte[i + 1];
            for (int j = 0; j < 20; j++)
            {
                dd1[j] = dd[j];
            }
            dd1[20] = 0x0;
            LaserStream.Write(dd1, 0, dd1.Length);
            watch.Restart();
            while (true)
            {
                if (watch.ElapsedMilliseconds > 2000)
                {
                    txtBarcode.Text = "Controller Connection Problem";
                    return;
                }
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[100];
                    LaserStream.Read(dd2, 0, 100);
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    lblDesc.Content = "Waiting for Screwing Data";
                    Check = true;
                    break;                 
                }
            }
            watch.Stop();
           
        }

        private void timer_Tick(object sender, EventArgs e)
        {
           if (Check == true)
          {
                if (LaserStream.DataAvailable)
                {
                    byte[] dd2;
                    dd2 = new byte[500];
                    LaserStream.Read(dd2, 0, 500);
                    string b = Encoding.ASCII.GetString(dd2);
                    txtBarcode.Text = Encoding.ASCII.GetString(dd2);
                    lblDesc.Content = "Screwing Data Received. Waiting for Next Screwing Data";
                }
          }
        }
    }
}

Dear Skumar,

In my knowledge there is no plugin in outsystems which can be connected directly to these devices.

You need to find out some cordova plugins or need to develop your cordova plugins and then wrap those plugins in Outsystems.

Or you can develop the XIF in integration studio with your C# code. 

Regards,


Just an observation.

Any extension code will run in the SERVER.
So, if the machine is not connected to the server, an extension will not work.
And a browser will not allow an application to access the machine.

So, I think this is one of those cases where the best you can do is to have a comuter connected to the machine, that gets the information and sends it via web service to the application that will take care of it...

In terms of security you can have this machine in an internal network only, for example.

Not sure if there is any other way.

Cheers.