I want to thank you for this free flexible development.
I was looking for a way to read modbus tcp from a web page and I found mblogic. I'm using it to display values from some data acquisition devices, wich are part of a system that uses scada, database y reports, all developed in comercial software, and accessed from diferent aplications. My intention is to provide a parallel way to do all this with mblogic as server and an internet browser as single end user interfase.
I came from plc world mostly, I did write some code in C, VBasic and SQL also, but that's all. With your detailed instruction and a lot of patience I could run mblogic and now I have a parallel scada running.
Sorry for the long introduction, now come my two questions:
1. I want to replace the report app. Wich way should I take to make a SQL connection and querys to the data base from mblogic xhtml page? I want to add a section of reports to the mblogic scada that I'm running, from a SQL server already installed.
As you may see I'm very newbie in this world, my first aproach was download Xampp (php apache) and try to do the report with a php page. But then I think: maybe I could do it directly from mblogic xhtml page with java code.
2. I read in some place of mblogic page that in future release the functionality of events and alarms would be saved in persistent way. How you plan to implement that? And when you think you could release it?
Thanks again and sorry for the long text.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You have a couple of questions here which I will try to deal with individually.
1) You said you wish to replace your reporting application. Reporting typically involves presenting the data rather than collecting it, so I will limit this answer to that question. Your idea of using PHP sounds reasonable if you are trying to pull data out of a database and turn it into a web page. That is what PHP is meant for.
If you are trying to mix *live* data (data direct from the device, rather than from a historical database) into the same web page as the historical data, then you can use MBLogic or HMIServer as a Modbus/TCP "driver". There are a couple of ways of doing this, but the one I would recommend would be to use the Cascadas protocol interface (which is the same protocol the HMI uses). It's a simple JSON based web service. If you are interested, I can give you details.
The web based HMI in MBLogic and HMIServer is not intended for historical data reports. It is intended for continuous live data updates. However, a system can mix both historical and live updates by simply using different web pages for each (some people are currently doing this). The historical reports can come from a conventional PHP web app, and the live data can come from MBLogic.
2) At present, the alarm and event history is stored in RAM and is lost if the server is restarted. For a lot of applications that are just trying to replace a conventional HMI panel, that is good enough. The eventual plans for saving alarms and events would simply be to save the alarm and event history tables to a file (either a SQLite or DBM database) so they would survive a server restart. That will be similar to how the soft logic data table can be saved to disk (so the data table values are saved if the system is shut off). That won't turn the system into a full fledged SCADA system however, so I'm not sure it would help you very much.
If I haven't answered your questions sufficiently then let me know and I will try to help you further.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Carlos: I have done mostly what you comment. I did it in php, using the Cakephp framework. But, mixing realtime access using mblogic & hmiserver with php code made me do some ugly hacks to keep the consistence of the whole application. I had to use a proxy (varnish) to mix the authentication system in php with the hmiserver views. I just didn't like the final result.
I also did a small python application that polls the PLC and saves the data in a database. This application can use MySql and sqlite as the backend.
After doing some other proofs of concept, finally I'm reimplementing it all in python, using the web2py framework. It's very easy and simple to use and all the solution is python based. I've made a reduced version of hmiserver acting as a xmlrpc server , and the web part uses the Cascadas protocol , as mgriffing suggests, to draw everything and makes xmlrpc calls to hmiserver to get the data that's sent to the web page. web2py has integrated the authentication, database use or even ajax use for your site.
As I'm rewritting everything using web2py, I haven't finished it yet. I can send it to you after finished, or in the meantime, I can send you the application that polls data and store in a database.
Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank both for quikly and helpfull answers.
Besides being newbie in this world, english is not my native language, so maybe I'm not so clear in the questions.
I not need to mix live data with stored data in the same page, so I'll continue trying to implement the reports with a php, and put a link in the hmi page to access the report page.
In my current knowlege (very limited by the way) I can do this with two serves, hmiserver and apache. I found mblogic a few weeks ago, and this week php+apache (googling) so I'm just in the inicial stage. Before getting started to understand how to put another server, I wondered if could do it all from the same server (hmiserver), but now I fall that this would be mixing things that not need to be together, and could bring problems as it says José.
José: thanks for your offering, your development sounds very interesting, when I'm more advanced I'll ask for your code to try to use it.
Meanwhile, if I experience any problem, I'll be bothering again.
Thanks again.
Regards
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As another suggestion, I have implemented historical trending functionality using Cacti (www.cacti.org). I use simple perl scripts (example below) to read the MB data using the MBrest protocol. Of course, cacti uses rrd files as the storage mechanism, so you would have to come up with a way regularly dump to sql (rrddump converts rrd to xml, as a starting point)
There is a simple example here: http://mblogic.sourceforge.net/mbapps/AppCascadas.html showing how to use the HMI protocol (Cascadas) to read data from HMIServer or MBLogic. This example shows how your own program can use HMIServer or MBLogic as a communications driver.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@ jredrejo, Can you post or send your data logging/reporting application? I am interested in how it works.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2010-07-13
Jose,
Seria posible disponer del codigo en python mencionado?
Estoy viendo como generar un historico de unas DI y seria un buen punto de partida.
Desde ya muchas gracias.
Slds.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to thank you for this free flexible development.
I was looking for a way to read modbus tcp from a web page and I found mblogic. I'm using it to display values from some data acquisition devices, wich are part of a system that uses scada, database y reports, all developed in comercial software, and accessed from diferent aplications. My intention is to provide a parallel way to do all this with mblogic as server and an internet browser as single end user interfase.
I came from plc world mostly, I did write some code in C, VBasic and SQL also, but that's all. With your detailed instruction and a lot of patience I could run mblogic and now I have a parallel scada running.
Sorry for the long introduction, now come my two questions:
1. I want to replace the report app. Wich way should I take to make a SQL connection and querys to the data base from mblogic xhtml page? I want to add a section of reports to the mblogic scada that I'm running, from a SQL server already installed.
As you may see I'm very newbie in this world, my first aproach was download Xampp (php apache) and try to do the report with a php page. But then I think: maybe I could do it directly from mblogic xhtml page with java code.
2. I read in some place of mblogic page that in future release the functionality of events and alarms would be saved in persistent way. How you plan to implement that? And when you think you could release it?
Thanks again and sorry for the long text.
You have a couple of questions here which I will try to deal with individually.
1) You said you wish to replace your reporting application. Reporting typically involves presenting the data rather than collecting it, so I will limit this answer to that question. Your idea of using PHP sounds reasonable if you are trying to pull data out of a database and turn it into a web page. That is what PHP is meant for.
If you are trying to mix *live* data (data direct from the device, rather than from a historical database) into the same web page as the historical data, then you can use MBLogic or HMIServer as a Modbus/TCP "driver". There are a couple of ways of doing this, but the one I would recommend would be to use the Cascadas protocol interface (which is the same protocol the HMI uses). It's a simple JSON based web service. If you are interested, I can give you details.
The web based HMI in MBLogic and HMIServer is not intended for historical data reports. It is intended for continuous live data updates. However, a system can mix both historical and live updates by simply using different web pages for each (some people are currently doing this). The historical reports can come from a conventional PHP web app, and the live data can come from MBLogic.
2) At present, the alarm and event history is stored in RAM and is lost if the server is restarted. For a lot of applications that are just trying to replace a conventional HMI panel, that is good enough. The eventual plans for saving alarms and events would simply be to save the alarm and event history tables to a file (either a SQLite or DBM database) so they would survive a server restart. That will be similar to how the soft logic data table can be saved to disk (so the data table values are saved if the system is shut off). That won't turn the system into a full fledged SCADA system however, so I'm not sure it would help you very much.
If I haven't answered your questions sufficiently then let me know and I will try to help you further.
Carlos: I have done mostly what you comment. I did it in php, using the Cakephp framework. But, mixing realtime access using mblogic & hmiserver with php code made me do some ugly hacks to keep the consistence of the whole application. I had to use a proxy (varnish) to mix the authentication system in php with the hmiserver views. I just didn't like the final result.
I also did a small python application that polls the PLC and saves the data in a database. This application can use MySql and sqlite as the backend.
After doing some other proofs of concept, finally I'm reimplementing it all in python, using the web2py framework. It's very easy and simple to use and all the solution is python based. I've made a reduced version of hmiserver acting as a xmlrpc server , and the web part uses the Cascadas protocol , as mgriffing suggests, to draw everything and makes xmlrpc calls to hmiserver to get the data that's sent to the web page. web2py has integrated the authentication, database use or even ajax use for your site.
As I'm rewritting everything using web2py, I haven't finished it yet. I can send it to you after finished, or in the meantime, I can send you the application that polls data and store in a database.
Regards.
Thank both for quikly and helpfull answers.
Besides being newbie in this world, english is not my native language, so maybe I'm not so clear in the questions.
I not need to mix live data with stored data in the same page, so I'll continue trying to implement the reports with a php, and put a link in the hmi page to access the report page.
In my current knowlege (very limited by the way) I can do this with two serves, hmiserver and apache. I found mblogic a few weeks ago, and this week php+apache (googling) so I'm just in the inicial stage. Before getting started to understand how to put another server, I wondered if could do it all from the same server (hmiserver), but now I fall that this would be mixing things that not need to be together, and could bring problems as it says José.
José: thanks for your offering, your development sounds very interesting, when I'm more advanced I'll ask for your code to try to use it.
Meanwhile, if I experience any problem, I'll be bothering again.
Thanks again.
Regards
If you need any further help with this, let me know.
As another suggestion, I have implemented historical trending functionality using Cacti (www.cacti.org). I use simple perl scripts (example below) to read the MB data using the MBrest protocol. Of course, cacti uses rrd files as the storage mechanism, so you would have to come up with a way regularly dump to sql (rrddump converts rrd to xml, as a starting point)
#!/usr/bin/perl
$host = $ARGV;
$addr = $ARGV;
$scale = $ARGV;
$offset = $ARGV;
if ($scale == 0) {
$scale = 1;
}
if ($offset == 0) {
$offset = 0;
}
$output = `/bin/bash -c 'wget -quiet -O - \"http:\/\/$host:8085\/modbus\/4\/$addr" | grep msgdata'`;
print $scale*(hex(substr($output,13,4))) + $offset;
print "\n";
There is a simple example here: http://mblogic.sourceforge.net/mbapps/AppCascadas.html showing how to use the HMI protocol (Cascadas) to read data from HMIServer or MBLogic. This example shows how your own program can use HMIServer or MBLogic as a communications driver.
@ jredrejo, Can you post or send your data logging/reporting application? I am interested in how it works.
Thanks
Jose,
Seria posible disponer del codigo en python mencionado?
Estoy viendo como generar un historico de unas DI y seria un buen punto de partida.
Desde ya muchas gracias.
Slds.
Dear Jredrejo, any news about the web2py app?
BR.