Reading data from a PLC unit

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Mike on 6th April 2017
Hello everybody,
I'm running an industrial plc with a very small amount of memory and this unit provides IE (with activeX...) graphs.
So I want to bypass this using RGraph. I succeeded with first tests (displays the amount of water used in the week/month/ etc). With week/month, I have no problems because I can put the 7 or 12 values into the script data:[...].
Now, I want to display values taken from a sensor. Unfortunately, the amount of data are far bigger: about 1440.
So, I can write the script with the embedded data, directly extracted from the plc BUT the length will be terrible.
Is it a way to incorporate the data using a loop for/next to read the data and display them nicely (I want to display a line ?

         var line = new RGraph.Line({
             id: 'cvs',
             data: [
                 [15,26,11,16,28,13,23,28.5,37,41,42,15],
             ],

             options: {

should be replaced by something easier like

         var line = new RGraph.Line({
             id: 'cvs',
for x=1 to sensor(length of measured data)
             data: [
                 [displayvalue(x)],
             ],
next
             options: {

etc.
No PHP available, just script into a basic html
Thank you very much to enlight me.
Mike
Posted by Richard on 6th April 2017
Hi there,

Not sure why it matters (it's just source code after all) - but you could do something like this to seperate out the code:


// The data
var data = [4,9,6,3,5,4,6,8,4,5,8,6 ...];


// Configure and display the chart
var line = new RGraph.Line({
     id: 'cvs',
     data: data,
     options: {
     }
}).draw();

How exactly is the PLc device providing the data? A JavaScript array that it injects into the page?




Richard

Add a reply




« Back to message list