Is this possible?


#1

I am wanting to know if there is a way to pull a database into Pac Control for use. Can I skip Pac Control and go directly through Groov? This not for static display, but would be constantly polling database and displaying updated info.


#2

Short answer. It depends.

Long answer.
http://www.opto22.com/community/showthread.php?t=380

Probably not the whole db. Or possibly the whole thing if it was smallish.
But mostly the answer and how doable it is will depend on if you can have some supporting code around the db.

That mega post I just linked to also works in reverse. I have done it from a pac, we ask (nicely) for some data from the db via the PHP script.
Works great for smallish amounts of data at sensible rates (ie something less than 50 values around once per second is what I tested).

Of course there is more than one way to do this… You have the code way I linked to.
But, you also have the OptoDataLink way. Remember, OptoDataLink comes with PAC Project Pro.
(This is if you want the data in PAC Control)

Lastly, if you have KepserverEX, then you can also have it poll the db and get the data that way.
(This is if you want to skip PAC Control and go direct to groov).
You can see this option in action by visiting demo.groov.com using the username of trail and the password of opto22
Look at the OPC UA demo page, at the bottom is the data being selected from a MySQL database running on a Linux PC.

Lets know if you have any questions about any of these methods and lets know which one you chose in the end (and why for bonus points!).


#3

Update: turns out the data I am going to use is in the form of a CSV text file. I looked around and I didn’t see a good way to bring that into PACdisplay or groov. Am I wrong?


#4

You will need to ‘wash’ the CSV via a bit of OptoScript to put it into a string table or some such in the controller.

In other words, there is no method for PAC Display to display a CSV file natively, and as yet there is no CSV gadget in groov.
They both however can display strings, so it would be a matter of you figuring out what is the best way to take the CSV file and splitting it into strings to be displayed in either product.

Musing out loud here… You raise an interesting point that we hear from time to time (not all that often, but often enough, if that makes sense)… That is, people have a CSV, or a DB and they want to view it in some Opto product. To them, since it’s their data and since they are familiar with it, it seems to be a simple task. I mean, really, how hard can it be, its my data, just display it already.
The problem is, what works for one CSV/DB may not work for another. Where does the data wrap around, how many parts of data are in each structure, does it change during the course of the day (shift work) and so on.
When you dig deep into how to display the data on both PC, Tablet and Smartphones, the complexity gets out of hand pretty quick.
Then you have the end user challenge. They expect it to be a given way, ‘Just make the computer show it how I want it’. As you know, that’s not always possible. We had this on the submarine job I worked on. (The user in this case was a well known movie director).

Long story short, if you move ahead with this job, and you have a moment, lets know what you come up with.


#5

I was hoping there was some way for datalink to pull in a csv file… There is an option for “file”, but I am not sure what that means or what it does.

New info: DataLink can import space separated values… why not add comma as a delimiter option?


#6

Out of curiosity, I tried a space delineated file. It will not work. What am I missing? What does it mean by “incorrect number of values” The manual is VERY vague regarding using files in the data link.

~


#7

Update. Here is what I found:

The DataLink cannot write to the whole array of (in my case) a string table.

[CONT|ip|tcp:192.168.1.80:22001]ST;Value[0-3];DROP_SCHEDULE

This is the default code from DataLink.

Instead it needs individual tags for the cells of the table.

[CONT|ip|tcp:192.168.1.80:22001]ST;Value[0];DROP_SCHEDULE
[CONT|ip|tcp:192.168.1.80:22001]ST;Value[1];DROP_SCHEDULE
[CONT|ip|tcp:192.168.1.80:22001]ST;Value[2];DROP_SCHEDULE
[CONT|ip|tcp:192.168.1.80:22001]ST;Value[3];DROP_SCHEDULE

The good news is the Opto team is working on improving this area and in some future update, a user will be able to select the type of delimiter.

Now to figure out how to use a text file with 27 lines each with multiple columns of data…


#8

Uh, thanks for indirectly answering my question…
“27 lines each with multiple columns of data”.

Hope you get it sorted, and thanks for reporting back and being so proactive. Really appreciate your passion.


#9

OK. I have got my prototype working.

I am putting the test file into a string table using DataLink as shown above, set to update every 5 sec. DataLink rolls through one line of the text file every scan interval so the first string table changes once every data link interval.
I then Use the first number in the table as my index and convert to an integer for comparison to a known value (my drop #).
If the drop # matches what I am looking for I write the current string table to a new table for a more static type of display (it will only visually update with changes). This all now seems simple, but was a lot of work getting all of the pieces in place and working together.


//convert string to int to see what drop we are on
Drop_Sch_temp =  StringToInt32(DROP_SCHEDULE[0]);


//Drop 1 display info
if (Drop_Sch_temp == 1) then
Drop1[0] = DROP_SCHEDULE[0];
Drop1[1] = DROP_SCHEDULE[1];
Drop1[2] = DROP_SCHEDULE[2];
Drop1[3] = DROP_SCHEDULE[3];
endif



//Drop 2 display info
if (Drop_Sch_temp == 2) then
Drop2[0] = DROP_SCHEDULE[0];
Drop2[1] = DROP_SCHEDULE[1];
Drop2[2] = DROP_SCHEDULE[2];
Drop2[3] = DROP_SCHEDULE[3];
endif


//to be continued up to drop 27

I can then put this table into a display page on the groov which is served up to individual displays. I learned something interesting. A [TAB] in the text file acts as a [SPACE]. So, if someone (currently) wants to put a space into a string from a text file they can use the TAB key.

*I did see there is a filter/driver for *.csv files in the OBDC database section on the datalink that I need to explore.