Commit 81d12cc4 authored by Claes Sjofors's avatar Claes Sjofors

Sev SQLite database implemented

parent 95ad1973
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
* General Public License plus this exception. * General Public License plus this exception.
**/ **/
#if defined PWRE_CONF_MYSQL
#include <math.h> #include <math.h>
#include "pwr.h" #include "pwr.h"
...@@ -88,9 +86,6 @@ int sev_server::init( int noneth) ...@@ -88,9 +86,6 @@ int sev_server::init( int noneth)
pwr_tStatus sts; pwr_tStatus sts;
qcom_sAid aid; qcom_sAid aid;
qcom_sQid qini; qcom_sQid qini;
sev_dbms_env *env;
pwr_tFileName envname;
char socket[200];
m_server_status = PWR__SRVSTARTUP; m_server_status = PWR__SRVSTARTUP;
...@@ -112,40 +107,34 @@ int sev_server::init( int noneth) ...@@ -112,40 +107,34 @@ int sev_server::init( int noneth)
errh_CErrLog( PWR__SRVNOTCONF, 0); errh_CErrLog( PWR__SRVNOTCONF, 0);
exit(0); exit(0);
} }
}
sprintf( envname, "$pwrp_db/%s.db", sev_dbms_env::dbName());
dcli_translate_filename( envname, envname);
env = new sev_dbms_env( envname);
env->open( envname);
if ( !env->exists()) {
cnf_get_value( "mysqlSocket", socket, sizeof(socket));
env->create( envname, "localhost", "pwrp", "", sev_dbms_env::dbName(), 50,
socket);
env->open( envname);
if ( !env->createDb()) { // Get configured database
errh_Fatal("Failed to create to database '%s'", sev_dbms_env::dbName()); pwr_tAttrRef daref;
exit(0); pwr_eSevDatabaseEnum db_enum;
} pwr_tAttrRef aref = cdh_ObjidToAref( conf_oid);
} sts = gdh_ArefANameToAref( &aref, "Database", &daref);
else { if ( ODD(sts)) {
if ( !env->openDb()) { sts = gdh_GetObjectInfoAttrref( &daref, (void *)&db_enum, sizeof(db_enum));
errh_Fatal("Failed to connect to database '%s'", sev_dbms_env::dbName()); if ( ODD(sts)) {
exit(0); switch ( db_enum) {
case pwr_eSevDatabaseEnum_MySQL:
set_dbtype( sev_eDbType_Mysql);
break;
case pwr_eSevDatabaseEnum_SQLite:
set_dbtype( sev_eDbType_Sqlite);
break;
}
}
} }
} }
if( !env->checkAndUpdateVersion(constSevVersion) ) { m_db = sev_db::open_database( m_db_type);
errh_Fatal("Failed to upgrade tables to sev version %d db:'%s'", constSevVersion, sev_dbms_env::dbName()); if ( !m_db) {
errh_Fatal( "Database open error");
exit(0); exit(0);
} }
errh_Info("Database opened '%s'", m_db->dbName());
m_db = new sev_dbms( env);
errh_Info("Database opened '%s'", sev_dbms_env::dbName());
m_db->get_items( &m_sts); m_db->get_items( &m_sts);
m_db->get_objectitems(&m_sts); m_db->get_objectitems(&m_sts);
...@@ -448,6 +437,12 @@ int sev_server::mainloop() ...@@ -448,6 +437,12 @@ int sev_server::mainloop()
m_stat.medium_load = m_stat.current_load; m_stat.medium_load = m_stat.current_load;
else else
m_stat.medium_load = a * m_stat.medium_load + (1.0-a) * m_stat.current_load; m_stat.medium_load = a * m_stat.medium_load + (1.0-a) * m_stat.current_load;
m_stat.storage_rate = (float)m_storage_cnt / (time_DToFloat(0, &busy)+time_DToFloat(0, &idle));
if ( m_stat.medium_storage_rate == 0)
m_stat.medium_storage_rate = m_stat.storage_rate;
else
m_stat.medium_storage_rate = a * m_stat.medium_storage_rate + (1.0-a) * m_stat.storage_rate;
m_storage_cnt = 0;
m_db->store_stat( &m_stat); m_db->store_stat( &m_stat);
time_Aadd( &next_stat, &next_stat, &stat_interval); time_Aadd( &next_stat, &next_stat, &stat_interval);
busy = pwr_cNDeltaTime; busy = pwr_cNDeltaTime;
...@@ -733,6 +728,8 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size) ...@@ -733,6 +728,8 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size)
sev_sHistData *dp = (sev_sHistData *)&msg->Data; sev_sHistData *dp = (sev_sHistData *)&msg->Data;
pwr_tTime time; pwr_tTime time;
m_db->begin_transaction();
while ( (char *)dp - (char *)msg < (int)size) { while ( (char *)dp - (char *)msg < (int)size) {
sev_sRefid *rp; sev_sRefid *rp;
pwr_tRefId rk = dp->sevid; pwr_tRefId rk = dp->sevid;
...@@ -746,9 +743,13 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size) ...@@ -746,9 +743,13 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size)
time = net_NetTimeToTime( &msg->Time); time = net_NetTimeToTime( &msg->Time);
m_db->store_value( &m_sts, idx, 0, time, &dp->data, dp->size); m_db->store_value( &m_sts, idx, 0, time, &dp->data, dp->size);
m_storage_cnt++;
dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size); dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size);
} }
m_db->commit_transaction();
return 1; return 1;
} }
...@@ -981,16 +982,32 @@ void sev_server::garbage_item( int idx) ...@@ -981,16 +982,32 @@ void sev_server::garbage_item( int idx)
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
sev_server srv; sev_server srv;
int noneth = 0; int noneth = 0;
sev_eDbType dbtype = sev_eDbType_;
if ( argc > 1 && strcmp( argv[1], "-n") == 0) if ( argc > 1 && strcmp( argv[1], "-n") == 0)
noneth = 1; noneth = 1;
if ( argc > 2 + noneth && strcmp( argv[1+noneth], "-d") == 0 && strcmp( argv[2+noneth], "sqlite") == 0)
dbtype = sev_eDbType_Sqlite;
else if ( argc > 2 + noneth && strcmp( argv[1+noneth], "-d") == 0 && strcmp( argv[2+noneth], "mysql") == 0)
dbtype = sev_eDbType_Mysql;
if ( dbtype == sev_eDbType_) {
char type[80];
if ( cnf_get_value( "sevDatabaseType", type, sizeof(type))) {
if ( cdh_NoCaseStrcmp( type, "sqlite") == 0)
dbtype = sev_eDbType_Sqlite;
else if ( cdh_NoCaseStrcmp( type, "mysql") == 0)
dbtype = sev_eDbType_Mysql;
}
}
if ( dbtype == sev_eDbType_)
dbtype = sev_eDbType_Mysql;
srv.set_dbtype( dbtype);
srv.init( noneth); srv.init( noneth);
srv.connect(); srv.connect();
srv.mainloop(); srv.mainloop();
} }
#else
int main(){}
#endif
...@@ -71,10 +71,8 @@ typedef struct { ...@@ -71,10 +71,8 @@ typedef struct {
class sev_server { class sev_server {
public: public:
//TODO should this really be in this file? sev_server() : m_server_status(0), m_refid(0), m_msg_id(0), m_storage_cnt(0),
static const unsigned int constSevVersion = 3; m_db_type(sev_eDbType_Sqlite) {memset(&m_stat,0,sizeof(m_stat));}
sev_server() : m_server_status(0), m_refid(0), m_msg_id(0) {memset(&m_stat,0,sizeof(m_stat));}
pwr_tStatus m_sts; pwr_tStatus m_sts;
pwr_tStatus m_server_status; pwr_tStatus m_server_status;
...@@ -83,7 +81,9 @@ class sev_server { ...@@ -83,7 +81,9 @@ class sev_server {
unsigned int m_msg_id; unsigned int m_msg_id;
sev_db *m_db; sev_db *m_db;
int m_noneth; int m_noneth;
unsigned int m_storage_cnt;
sev_sStat m_stat; sev_sStat m_stat;
sev_eDbType m_db_type;
int init( int noneth); int init( int noneth);
int connect(); int connect();
...@@ -99,5 +99,6 @@ class sev_server { ...@@ -99,5 +99,6 @@ class sev_server {
int receive_events( sev_sMsgEventsStore *msg, unsigned int size); int receive_events( sev_sMsgEventsStore *msg, unsigned int size);
void garbage_collector(); void garbage_collector();
void garbage_item( int idx); void garbage_item( int idx);
void set_dbtype( sev_eDbType type) { m_db_type = type;}
}; };
#endif #endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "sev_db.h"
#include "sev_dbms.h"
#include "sev_dbsqlite.h"
sev_db *sev_db::open_database( sev_eDbType type)
{
if ( type == sev_eDbType_Mysql) {
#if defined PWRE_CONF_MYSQL
return sev_dbms::open_database();
#else
printf( "** Release is not built with mysql\n");
return 0;
#endif
}
else if ( type == sev_eDbType_Sqlite)
#if defined PWRE_CONF_SQLITE3
return sev_dbsqlite::open_database();
#else
printf( "** Release is not built with sqlite3\n");
return 0;
#endif
else
return 0;
}
...@@ -45,9 +45,19 @@ ...@@ -45,9 +45,19 @@
using namespace std; using namespace std;
#define sev_cVersion 3
typedef enum {
sev_eDbType_,
sev_eDbType_Mysql,
sev_eDbType_Sqlite
} sev_eDbType;
typedef struct { typedef struct {
float current_load; float current_load;
float medium_load; float medium_load;
float storage_rate;
float medium_storage_rate;
unsigned int datastore_msg_cnt; unsigned int datastore_msg_cnt;
unsigned int dataget_msg_cnt; unsigned int dataget_msg_cnt;
unsigned int items_msg_cnt; unsigned int items_msg_cnt;
...@@ -157,6 +167,10 @@ class sev_db { ...@@ -157,6 +167,10 @@ class sev_db {
virtual int repair_table( pwr_tStatus *sts, char *tablename) { return 0;} virtual int repair_table( pwr_tStatus *sts, char *tablename) { return 0;}
virtual int alter_engine( pwr_tStatus *sts, char *tablename) { return 0;} virtual int alter_engine( pwr_tStatus *sts, char *tablename) { return 0;}
virtual int store_stat( sev_sStat *stat) { return 0;} virtual int store_stat( sev_sStat *stat) { return 0;}
virtual int begin_transaction() { return 0;}
virtual int commit_transaction() { return 0;}
virtual char *dbName() { return 0;}
static sev_db *open_database( sev_eDbType type);
}; };
#endif #endif
...@@ -423,7 +423,7 @@ int sev_dbms_env::createSevVersion2Tables(void) ...@@ -423,7 +423,7 @@ int sev_dbms_env::createSevVersion2Tables(void)
printf( "Create sev_version table: %s\n", mysql_error(m_con)); printf( "Create sev_version table: %s\n", mysql_error(m_con));
} }
sprintf( query, "insert into sev_version (version) values(2)"); sprintf( query, "insert into sev_version (version) values(%d)", sev_cVersion);
rc = mysql_query( m_con, query); rc = mysql_query( m_con, query);
if (rc) { if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__); printf("In %s row %d:\n", __FILE__, __LINE__);
...@@ -473,7 +473,10 @@ int sev_dbms_env::createSevVersion3Tables(void) ...@@ -473,7 +473,10 @@ int sev_dbms_env::createSevVersion3Tables(void)
{ {
char query[400]; char query[400];
sprintf( query, "create table sev_stat (current_load float,medium_load float,datastore_msg_cnt int unsigned,dataget_msg_cnt int unsigned,items_msg_cnt int unsigned,eventstore_msg_cnt int unsigned);"); sprintf( query, "create table sev_stat (current_load float,medium_load float,"
"storage_rate float,medium_storage_rate float,"
"datastore_msg_cnt int unsigned,dataget_msg_cnt int unsigned,"
"items_msg_cnt int unsigned,eventstore_msg_cnt int unsigned);");
int rc = mysql_query( m_con, query); int rc = mysql_query( m_con, query);
if (rc) { if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__); printf("In %s row %d:\n", __FILE__, __LINE__);
...@@ -663,6 +666,50 @@ int sev_dbms_env::get_systemname() ...@@ -663,6 +666,50 @@ int sev_dbms_env::get_systemname()
return 1; return 1;
} }
sev_db *sev_dbms::open_database()
{
pwr_tFileName envname;
char socket[200];
sev_dbms_env *env;
sev_dbms *db;
sprintf( envname, "$pwrp_db/%s.db", sev_dbms_env::dbName());
dcli_translate_filename( envname, envname);
env = new sev_dbms_env( envname);
env->open( envname);
if ( !env->exists()) {
cnf_get_value( "mysqlSocket", socket, sizeof(socket));
env->create( envname, "localhost", "pwrp", "", sev_dbms_env::dbName(), 50,
socket);
env->open( envname);
if ( !env->createDb()) {
errh_Fatal("Failed to create to database '%s'", sev_dbms_env::dbName());
exit(0);
}
}
else {
if ( !env->openDb()) {
errh_Fatal("Failed to connect to database '%s'", sev_dbms_env::dbName());
exit(0);
}
}
if( !env->checkAndUpdateVersion(sev_cVersion) ) {
errh_Fatal("Failed to upgrade tables to sev version %d db:'%s'", sev_cVersion, sev_dbms_env::dbName());
exit(0);
}
db = new sev_dbms( env);
errh_Info("Database opened '%s'", db->dbName());
return db;
}
int sev_dbms::create_table( pwr_tStatus *sts, char *tablename, pwr_eType type, int sev_dbms::create_table( pwr_tStatus *sts, char *tablename, pwr_eType type,
unsigned int size, pwr_tMask options, float deadband) unsigned int size, pwr_tMask options, float deadband)
{ {
...@@ -3730,9 +3777,12 @@ int sev_dbms::store_stat( sev_sStat *stat) ...@@ -3730,9 +3777,12 @@ int sev_dbms::store_stat( sev_sStat *stat)
char query[250]; char query[250];
int rc; int rc;
sprintf( query, "update sev_stat set current_load = %f,medium_load = %f,datastore_msg_cnt=%d,dataget_msg_cnt=%d,items_msg_cnt=%d,eventstore_msg_cnt=%d", sprintf( query, "update sev_stat set current_load = %f,medium_load = %f,"
stat->current_load, stat->medium_load, stat->datastore_msg_cnt, stat->dataget_msg_cnt, stat->items_msg_cnt, "storage_rate=%f,medium_storage_rate=%f,datastore_msg_cnt=%d,"
stat->eventstore_msg_cnt); "dataget_msg_cnt=%d,items_msg_cnt=%d,eventstore_msg_cnt=%d",
stat->current_load, stat->medium_load, stat->storage_rate,
stat->medium_storage_rate, stat->datastore_msg_cnt,
stat->dataget_msg_cnt, stat->items_msg_cnt, stat->eventstore_msg_cnt);
rc = mysql_query( m_env->con(), query); rc = mysql_query( m_env->con(), query);
if (rc) { if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__); printf("In %s row %d:\n", __FILE__, __LINE__);
...@@ -3742,6 +3792,36 @@ int sev_dbms::store_stat( sev_sStat *stat) ...@@ -3742,6 +3792,36 @@ int sev_dbms::store_stat( sev_sStat *stat)
return 1; return 1;
} }
int sev_dbms::begin_transaction()
{
char query[20];
int rc;
strcpy( query, "start transaction");
rc = mysql_query( m_env->con(), query);
if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf( "Begin transaction: %s\n", mysql_error(m_env->con()));
return 0;
}
return 1;
}
int sev_dbms::commit_transaction()
{
char query[20];
int rc;
strcpy( query, "commit");
rc = mysql_query( m_env->con(), query);
if (rc) {
printf("In %s row %d:\n", __FILE__, __LINE__);
printf( "Begin transaction: %s\n", mysql_error(m_env->con()));
return 0;
}
return 1;
}
sev_dbms::~sev_dbms() sev_dbms::~sev_dbms()
{ {
printf("Freeing memory\n"); printf("Freeing memory\n");
......
...@@ -156,7 +156,9 @@ class sev_dbms : public sev_db { ...@@ -156,7 +156,9 @@ class sev_dbms : public sev_db {
char *description, char *unit, pwr_tFloat32 scantime, char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options); pwr_tFloat32 deadband, pwr_tMask options);
int remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname); int remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
static sev_db *open_database();
static char *oid_to_table( pwr_tOid oid, char *aname); static char *oid_to_table( pwr_tOid oid, char *aname);
char *dbName() { return sev_dbms_env::dbName();}
char *pwrtype_to_type( pwr_eType type, unsigned int size); char *pwrtype_to_type( pwr_eType type, unsigned int size);
static int timestr_to_time( char *tstr, pwr_tTime *ts); static int timestr_to_time( char *tstr, pwr_tTime *ts);
int check_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname, int check_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname,
...@@ -195,6 +197,8 @@ class sev_dbms : public sev_db { ...@@ -195,6 +197,8 @@ class sev_dbms : public sev_db {
int repair_table( pwr_tStatus *sts, char *tablename); int repair_table( pwr_tStatus *sts, char *tablename);
int alter_engine( pwr_tStatus *sts, char *tablename); int alter_engine( pwr_tStatus *sts, char *tablename);
int store_stat( sev_sStat *stat); int store_stat( sev_sStat *stat);
int begin_transaction();
int commit_transaction();
inline char* create_colName(unsigned int index, char *attributename) { inline char* create_colName(unsigned int index, char *attributename) {
static char colName[constMaxColNameLength]; static char colName[constMaxColNameLength];
strncpy(colName, attributename, constMaxColNameLength); strncpy(colName, attributename, constMaxColNameLength);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef sev_dbsqlite_h
#define sev_dbsqlite_h
#if defined PWRE_CONF_SQLITE3
#include <vector>
#include "pwr.h"
#include "pwr_class.h"
#include "sev_db.h"
#include <sqlite3.h>
using namespace std;
class sev_dbsqlite_env;
class sev_dbsqlite : public sev_db {
public:
static const unsigned int constMaxColNameLength = 64;
sqlite3 *m_con;
char m_systemName[80];
sev_dbsqlite() { strcpy(m_systemName,"");}
~sev_dbsqlite();
int checkAndUpdateVersion(unsigned int version);
int updateDBToSevVersion2(void);
int createSevVersion2Tables(void);
int createSevVersion3Tables(void);
int get_systemname();
int open_db();
int check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType type, unsigned int size,
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx);
int add_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType type, unsigned int size,
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx);
int store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
pwr_tTime time, void *buf, unsigned int size);
int get_values( pwr_tStatus *sts, pwr_tOid oid, pwr_tMask options, float deadband, char *aname,
pwr_eType type, unsigned int size, pwr_tFloat32 scantime, pwr_tTime *creatime,
pwr_tTime *starttime,
pwr_tTime *endtime, int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_old_data( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit, pwr_tFloat32 scantime, pwr_tFloat32 garbagecycle);
int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int get_items( pwr_tStatus *sts);
int create_table( pwr_tStatus *sts, char *tablename, pwr_eType type, unsigned int size,
pwr_tMask options, float deadband);
int delete_table( pwr_tStatus *sts, char *tablename);
int store_item( pwr_tStatus *sts, char *tabelname, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType vtype, unsigned int vsize,
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options);
int remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
static sev_db *open_database();
static char *oid_to_table( pwr_tOid oid, char *aname);
char *dbName();
char *pwrtype_to_type( pwr_eType type, unsigned int size);
static int timestr_to_time( char *tstr, pwr_tTime *ts);
int check_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime,
char *description, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx);
int add_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime,
char *description, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx);
int store_objectitem( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, char *description, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options);
int create_objecttable( pwr_tStatus *sts, char *tablename, pwr_tMask options, float deadband);
int store_objectvalue( pwr_tStatus *sts, int item_idx, int attr_idx,
pwr_tTime time, void *buf, void *oldbuf, unsigned int size);
int get_item( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename);
int get_objectitem( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename);
int get_objectitems( pwr_tStatus *sts);
int get_objectitemattributes( pwr_tStatus *sts, sev_item *item, char *tablename);
int check_objectitemattr( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *aname, char *oname,
pwr_eType type, unsigned int size, unsigned int *idx);
int delete_old_objectdata( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit, pwr_tFloat32 scantime, pwr_tFloat32 garbagecycle);
int check_deadband(pwr_eType type, unsigned int size, pwr_tFloat32 deadband, void *value, void *oldvalue);
int get_objectvalues( pwr_tStatus *sts, sev_item *item, unsigned int size, pwr_tTime *starttime, pwr_tTime *endtime,
int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_event_table( pwr_tStatus *sts, char *tablename);
int create_event_table( pwr_tStatus *sts, char *tablename, pwr_tMask options);
int store_event( pwr_tStatus *sts, int item_idx, sev_event *ep);
pwr_tUInt64 get_minFromIntegerColumn( char *tablename, char *colname );
pwr_tUInt64 get_maxFromIntegerColumn( char *tablename, char *colname );
pwr_tUInt64 get_nextAutoIncrement( char *tablename );
int handle_itemchange(pwr_tStatus *sts, char *tablename, unsigned int item_idx);
int handle_objectchange(pwr_tStatus *sts, char *tablename, unsigned int item_idx, bool newObject);
int repair_table( pwr_tStatus *sts, char *tablename);
int alter_engine( pwr_tStatus *sts, char *tablename);
int store_stat( sev_sStat *stat);
int begin_transaction();
int commit_transaction();
inline char* create_colName(unsigned int index, char *attributename) {
static char colName[constMaxColNameLength];
strncpy(colName, attributename, constMaxColNameLength);
if(strlen(attributename) > constMaxColNameLength)
{
colName[constMaxColNameLength-5] = 0;
snprintf(&colName[strlen(colName)], 5, "_%d", index);
}
return colName;
}
};
#endif
#endif
...@@ -48,6 +48,7 @@ unknownnode <Unknown server nodename> /error ...@@ -48,6 +48,7 @@ unknownnode <Unknown server nodename> /error
init <Initialization done> /info init <Initialization done> /info
exportfile <Unable to open export file> /error exportfile <Unable to open export file> /error
repair_failed <Repair failed> /error repair_failed <Repair failed> /error
nyi <Not yet implemented> /error
.end .end
......
...@@ -381,6 +381,7 @@ else ...@@ -381,6 +381,7 @@ else
echo "Optional :" echo "Optional :"
pwre_config_check_lib motif MRM motif motif 0 "/usr/lib/libMrm.so" pwre_config_check_lib motif MRM motif motif 0 "/usr/lib/libMrm.so"
pwre_config_check_lib mysql MYSQL lib lib 1 "/usr/lib/libmysqlclient.so:/usr/lib/mysql/libmysqlclient.so:/usr/lib/$hwpl-linux-gnu/libmysqlclient.so" pwre_config_check_lib mysql MYSQL lib lib 1 "/usr/lib/libmysqlclient.so:/usr/lib/mysql/libmysqlclient.so:/usr/lib/$hwpl-linux-gnu/libmysqlclient.so"
pwre_config_check_lib sqlite3 SQLITE3 lib lib 1 "/usr/lib/libsqlite3.so:/usr/lib/$hwpl-linux-gnu/libsqlite3.so"
pwre_config_check_lib mq MQ lib mq 1 "/usr/lib/libdmq.so:/usr/local/dmq/lib/libdmq.so" pwre_config_check_lib mq MQ lib mq 1 "/usr/lib/libdmq.so:/usr/local/dmq/lib/libdmq.so"
pwre_config_check_lib wmq WMQ lib wmq 1 "/usr/lib/libmqic.so" pwre_config_check_lib wmq WMQ lib wmq 1 "/usr/lib/libmqic.so"
pwre_config_check_lib libpnioif PNAK lib pnak 1 "/usr/lib/libpnioif.a:/usr/local/lib/libpnioif.a" pwre_config_check_lib libpnioif PNAK lib pnak 1 "/usr/lib/libpnioif.a:/usr/local/lib/libpnioif.a"
......
...@@ -73,6 +73,14 @@ SObject pwrb:Class ...@@ -73,6 +73,14 @@ SObject pwrb:Class
Attr TypeRef = "pwrs:Type-$String80" Attr TypeRef = "pwrs:Type-$String80"
EndBody EndBody
EndObject EndObject
!/**
! Database type.
!*/
Object Database $Attribute 2
Body SysBody
Attr TypeRef = "pwrb:Type-SevDatabaseEnum"
EndBody
EndObject
EndObject EndObject
EndObject EndObject
EndSObject EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_td_sevdatabaseenum.wb_load -- Defines the enum type SevDatabase
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for Sev database.
!*/
Object SevDatabaseEnum $TypeDef 67
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "SevDatabaseEnum"
EndBody
!/**
! Mysql.
!*/
Object MySQL $Value
Body SysBody
Attr PgmName = "MySQL"
Attr Text = "MySQL"
Attr Value = 0
EndBody
EndObject
!/**
! SQLite.
!*/
Object SQLite $Value
Body SysBody
Attr PgmName = "SQLite"
Attr Text = "SQLite"
Attr Value = 1
EndBody
EndObject
EndObject
EndSObject
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment