Commit 9d007f29 authored by claes's avatar claes

More sev work done

parent 996259a8
/*
* Proview $Id: ini.c,v 1.1 2008-09-05 08:38:58 claes Exp $
* Proview $Id: ini.c,v 1.2 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -416,7 +416,7 @@ void ini_ProcTable (
pp->flags.b.qmon = 1;
pp->proc.flags.b.system = 1;
pp = ini_ProcInsert(sts, cp, "pwr_sev_server", "pwr_sev_server_%d", 0, 1, "sev_server", cPrio_sev_server, 0, "");
pp = ini_ProcInsert(sts, cp, "pwr_sev_server", "pwr_sev_server_%d", 0, 1, "sev_server", cPrio_sev_server, 0, "-n");
pp->proc.flags.b.system = 1;
......
/*
* Proview $Id: sev_server.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: sev_server.cpp,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,14 +26,18 @@
#include "rt_qcom.h"
#include "rt_qcom_msg.h"
#include "rt_ini_event.h"
#include "rt_gdh.h"
#include "sev_server.h"
#include "rt_sev_net.h"
#include "sev_dbms.h"
#include "rt_sev_msg.h"
#include "rt_pwr_msg.h"
#include "rt_errh.h"
#include "pwr_baseclasses.h"
#define sev_cGarbageInterval 120
int sev_server::init()
int sev_server::init( int noneth)
{
qcom_sNode node;
pwr_tNid nid;
......@@ -44,13 +48,28 @@ int sev_server::init()
m_db->get_items( &m_sts);
for ( unsigned int i = 0; i < m_db->m_items.size(); i++) {
sev_item_key items_key( m_db->m_items[i].oid, m_db->m_items[i].aname);
sev_item_key items_key( m_db->m_items[i].oid, m_db->m_items[i].attr[0].aname);
m_item_key[items_key] = i;
}
qcom_Init( &m_sts, &aid, "sev_server");
if ( EVEN(m_sts)) throw co_error(m_sts);
m_noneth = noneth;
if (!m_noneth) {
// Check server config object
pwr_tOid conf_oid;
sts = gdh_Init( "sev_server");
if ( EVEN(m_sts)) throw co_error(m_sts);
sts = gdh_GetClassList( pwr_cClass_SevServer, &conf_oid);
if ( EVEN(sts)) {
errh_CErrLog( PWR__SRVNOTCONF, 0);
exit(0);
}
}
// Create a queue to server
qcom_sQattr attr;
qcom_sQid qid;
......@@ -188,13 +207,18 @@ int sev_server::send_itemlist( qcom_sQid tgt)
continue;
((sev_sMsgHistItems *)put.data)->Items[idx].oid = m_db->m_items[i].oid;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].oname, m_db->m_items[i].oname);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].aname, m_db->m_items[i].aname);
((sev_sMsgHistItems *)put.data)->Items[idx].storagetime = m_db->m_items[i].storagetime;
((sev_sMsgHistItems *)put.data)->Items[idx].type = m_db->m_items[i].vtype;
((sev_sMsgHistItems *)put.data)->Items[idx].size = m_db->m_items[i].vsize;
((sev_sMsgHistItems *)put.data)->Items[idx].creatime = m_db->m_items[i].creatime;
((sev_sMsgHistItems *)put.data)->Items[idx].modtime = m_db->m_items[i].modtime;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].description, m_db->m_items[i].description);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].unit, m_db->m_items[i].unit);
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].aname, m_db->m_items[i].attr[0].aname);
((sev_sMsgHistItems *)put.data)->Items[idx].attrnum = m_db->m_items[i].attrnum;
((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].type = m_db->m_items[i].attr[0].type;
((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].size = m_db->m_items[i].attr[0].size;
strcpy( ((sev_sMsgHistItems *)put.data)->Items[idx].attr[0].unit, m_db->m_items[i].attr[0].unit);
((sev_sMsgHistItems *)put.data)->Items[idx].scantime = m_db->m_items[i].scantime;
((sev_sMsgHistItems *)put.data)->Items[idx].deadband = m_db->m_items[i].deadband;
((sev_sMsgHistItems *)put.data)->Items[idx].options = m_db->m_items[i].options;
idx++;
}
......@@ -268,7 +292,6 @@ int sev_server::mainloop()
clock_gettime( CLOCK_REALTIME, &currenttime);
if ( time_Acomp( &currenttime, &next_garco) == 1) {
printf( "Run garbage collector\n");
garbage_collector();
time_Aadd( &next_garco, &next_garco, &garco_interval);
}
......@@ -277,7 +300,6 @@ int sev_server::mainloop()
switch (get.type.b) {
case sev_cMsgClass:
printf( "Message received\n");
switch ( get.type.s) {
case sev_eMsgType_NodeUp:
request_items( get.reply.nid);
......@@ -333,16 +355,22 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
}
for ( int i = 0; i < item_cnt; i++) {
printf( "Received: %s.%s\n", msg->Items[i].oname, msg->Items[i].aname);
if ( !m_db->check_item( &m_sts, msg->Items[i].oid, msg->Items[i].oname, msg->Items[i].aname,
msg->Items[i].storagetime, msg->Items[i].type, msg->Items[i].size,
msg->Items[i].description, msg->Items[i].unit, msg->Items[i].scantime,
&idx)) {
m_db->add_item( &m_sts, msg->Items[i].oid, msg->Items[i].oname, msg->Items[i].aname,
msg->Items[i].storagetime, msg->Items[i].type, msg->Items[i].size,
msg->Items[i].description, msg->Items[i].unit, msg->Items[i].scantime, &idx);
// Deadband requires id variable
if ( msg->Items[i].options & pwr_mSevOptionsMask_UseDeadBand)
msg->Items[i].options |= pwr_mSevOptionsMask_ReadOptimized;
// printf( "Received: %s.%s\n", msg->Items[i].oname, msg->Items[i].attr[0].aname);
if ( !m_db->check_item( &m_sts, msg->Items[i].oid, msg->Items[i].oname, msg->Items[i].attr[0].aname,
msg->Items[i].storagetime, msg->Items[i].attr[0].type, msg->Items[i].attr[0].size,
msg->Items[i].description, msg->Items[i].attr[0].unit, msg->Items[i].scantime,
msg->Items[i].deadband, msg->Items[i].options, &idx)) {
m_db->add_item( &m_sts, msg->Items[i].oid, msg->Items[i].oname, msg->Items[i].attr[0].aname,
msg->Items[i].storagetime, msg->Items[i].attr[0].type, msg->Items[i].attr[0].size,
msg->Items[i].description, msg->Items[i].attr[0].unit, msg->Items[i].scantime,
msg->Items[i].deadband, msg->Items[i].options, &idx);
sev_item_key item_key( msg->Items[i].oid, msg->Items[i].aname);
sev_item_key item_key( msg->Items[i].oid, msg->Items[i].attr[0].aname);
m_item_key[item_key] = idx;
}
......@@ -352,9 +380,9 @@ int sev_server::check_histitems( sev_sMsgHistItems *msg, unsigned int size)
}
printf( "---- Node up ----\n");
for ( iterator_refid it = m_refid.begin(); it != m_refid.end(); it++) {
printf( "Refid: %d,%d Name %s\n", it->first.id.nid, it->first.id.rix, m_db->m_items[it->second].oname);
}
// for ( iterator_refid it = m_refid.begin(); it != m_refid.end(); it++)
// printf( "Refid: %d,%d Name %s\n", it->first.id.nid, it->first.id.rix, m_db->m_items[it->second].oname);
return 1;
}
......@@ -371,8 +399,7 @@ int sev_server::receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size)
}
unsigned int idx = it->second;
m_db->store_value( &m_sts, m_db->m_items[idx].oid, m_db->m_items[idx].aname,
m_db->m_items[idx].vtype, msg->Time, &dp->data, dp->size);
m_db->store_value( &m_sts, idx, 0, msg->Time, &dp->data, dp->size);
dp = (sev_sHistData *)((char *)dp + sizeof( *dp) - sizeof(dp->data) + dp->size);
}
......@@ -401,12 +428,13 @@ int sev_server::send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *rmsg,
if ( ODD(m_sts)) {
idx = it->second;
m_db->get_values( &m_sts, rmsg->Oid, rmsg->AName, m_db->m_items[idx].vtype,
m_db->m_items[idx].vsize, m_db->m_items[idx].scantime,
m_db->get_values( &m_sts, rmsg->Oid, m_db->m_items[idx].options, m_db->m_items[idx].deadband,
rmsg->AName, m_db->m_items[idx].attr[0].type, m_db->m_items[idx].attr[0].size,
m_db->m_items[idx].scantime,
&rmsg->StartTime, &rmsg->EndTime, rmsg->NumPoints, &tbuf, &vbuf, &rows);
}
if ( ODD(m_sts))
msize = rows * ( sizeof(pwr_tTime) + m_db->m_items[idx].vsize) + sizeof(*msg) - sizeof(msg->Data);
msize = rows * ( sizeof(pwr_tTime) + m_db->m_items[idx].attr[0].size) + sizeof(*msg) - sizeof(msg->Data);
else
msize = sizeof(*msg);
......@@ -425,14 +453,14 @@ int sev_server::send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *rmsg,
strncpy( msg->AName, rmsg->AName, sizeof(msg->AName));
if ( ODD(m_sts)) {
msg->NumPoints = rows;
msg->VType = m_db->m_items[idx].vtype;
msg->VSize = m_db->m_items[idx].vsize;
msg->VType = m_db->m_items[idx].attr[0].type;
msg->VSize = m_db->m_items[idx].attr[0].size;
}
msg->Status = m_sts;
if ( ODD(m_sts) && rows) {
memcpy( &msg->Data, tbuf, sizeof(pwr_tTime) * rows);
memcpy( (char *)&msg->Data + sizeof(pwr_tTime) * rows, vbuf, m_db->m_items[idx].vsize * rows);
memcpy( (char *)&msg->Data + sizeof(pwr_tTime) * rows, vbuf, m_db->m_items[idx].attr[0].size * rows);
}
if ( !qcom_Put( &sts, &tgt, &put)) {
qcom_Free( &sts, put.data);
......@@ -455,17 +483,22 @@ void sev_server::garbage_collector()
time_Asub( &limit, &currenttime, &m_db->m_items[i].storagetime);
m_db->delete_old_data( &m_sts, m_db->m_items[i].oid, m_db->m_items[i].aname, limit);
m_db->delete_old_data( &m_sts, m_db->m_items[i].oid, m_db->m_items[i].attr[0].aname,
m_db->m_items[i].options, limit);
}
}
int main()
int main (int argc, char *argv[])
{
sev_server srv;
sev_dbms_env *env;
pwr_tFileName envname;
char socket[200];
int noneth = 0;
if ( argc > 1 && strcmp( argv[1], "-n") == 0)
noneth = 1;
sprintf( envname, "$pwrp_db/%s.db", sev_dbms_env::dbName());
dcli_translate_filename( envname, envname);
......@@ -486,7 +519,7 @@ int main()
srv.m_db = new sev_dbms( env);
srv.init();
srv.init( noneth);
srv.connect();
srv.mainloop();
}
/*
* Proview $Id: sev_server.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: sev_server.h,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -79,8 +79,9 @@ class sev_server {
map<sev_item_key, unsigned int> m_item_key;
unsigned int m_msg_id;
sev_db *m_db;
int m_noneth;
int init();
int init( int noneth);
int connect();
int request_items( pwr_tNid nid);
int sev_server::mainloop();
......
/*
* Proview $Id: xtt_tbl_gtk.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: xtt_tbl_gtk.cpp,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -43,7 +43,7 @@
#include "xtt_tbl_gtk.h"
#include "xtt_tblnav_gtk.h"
#include "xtt_dshist_gtk.h"
#include "xtt_sevhist_gtk.h"
void XttTblGtk::message( char severity, char *message)
{
......@@ -162,14 +162,14 @@ void XttTblGtk::activate_help_proview( GtkWidget *w, gpointer data)
xtt->activate_help_proview();
}
void XttTblGtk::activate_opendshist( GtkWidget *w, gpointer data)
void XttTblGtk::activate_opensevhist( GtkWidget *w, gpointer data)
{
XttTbl *xtt = (XttTbl *)data;
if ( !xtt->is_authorized())
return;
xtt->activate_opendshist();
xtt->activate_opensevhist();
}
void XttTblGtk::activate_delete_item( GtkWidget *w, gpointer data)
......@@ -202,7 +202,7 @@ void XttTblGtk::activate_list_layout( GtkWidget *w, gpointer data)
xtt->tblnav->show_list();
}
XttDsHist *XttTblGtk::dshist_new( pwr_tOid oid, char *aname)
XttSevHist *XttTblGtk::sevhist_new( pwr_tOid oid, char *aname)
{
GtkWidget *w;
pwr_tStatus sts;
......@@ -213,7 +213,7 @@ XttDsHist *XttTblGtk::dshist_new( pwr_tOid oid, char *aname)
oidv[1] = pwr_cNOid;
strncpy( anamev[0], aname, sizeof(anamev[0]));
return new XttDsHistGtk( (void *)this, toplevel, "DsHist", &w, oidv, anamev,
return new XttSevHistGtk( (void *)this, toplevel, "SevHist", &w, oidv, anamev,
sevcli, &sts);
}
......@@ -344,8 +344,8 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
// Functions entry
GtkWidget *functions_opendshist = gtk_menu_item_new_with_mnemonic( "_Open DsHist");
g_signal_connect(functions_opendshist, "activate", G_CALLBACK(activate_opendshist), this);
GtkWidget *functions_opensevhist = gtk_menu_item_new_with_mnemonic( "_Open SevHist");
g_signal_connect(functions_opensevhist, "activate", G_CALLBACK(activate_opensevhist), this);
GtkWidget *functions_command = gtk_menu_item_new_with_mnemonic(CoWowGtk::translate_utf8("Co_mmand"));
g_signal_connect( functions_command, "activate",
......@@ -358,7 +358,7 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
g_signal_connect(functions_delete_item, "activate", G_CALLBACK(activate_delete_item), this);
GtkMenu *functions_menu = (GtkMenu *) g_object_new( GTK_TYPE_MENU, NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_opendshist);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_opensevhist);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_command);
gtk_menu_shell_append(GTK_MENU_SHELL(functions_menu), functions_delete_item);
......@@ -432,13 +432,13 @@ XttTblGtk::XttTblGtk( GtkWidget *a_parent_wid,
// Toolbar
GtkToolbar *tools = (GtkToolbar *) g_object_new(GTK_TYPE_TOOLBAR, NULL);
GtkWidget *tools_opendshist = gtk_button_new();
GtkWidget *tools_opensevhist = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_meth_trend.png");
gtk_container_add( GTK_CONTAINER(tools_opendshist),
gtk_container_add( GTK_CONTAINER(tools_opensevhist),
gtk_image_new_from_file( fname));
g_signal_connect(tools_opendshist, "clicked", G_CALLBACK(activate_opendshist), this);
g_object_set( tools_opendshist, "can-focus", FALSE, NULL);
gtk_toolbar_append_widget( tools, tools_opendshist,CoWowGtk::translate_utf8("Open hist item"), "");
g_signal_connect(tools_opensevhist, "clicked", G_CALLBACK(activate_opensevhist), this);
g_object_set( tools_opensevhist, "can-focus", FALSE, NULL);
gtk_toolbar_append_widget( tools, tools_opensevhist,CoWowGtk::translate_utf8("Open hist item"), "");
GtkWidget *tools_zoom_in = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_zoom_in.png");
......
/*
* Proview $Id: xtt_tbl_gtk.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: xtt_tbl_gtk.h,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -49,7 +49,7 @@ class XttTblGtk : public XttTbl {
CoWowEntryGtk *cmd_entry;
void message( char severity, char *message);
XttDsHist *dshist_new( pwr_tOid oid, char *aname);
XttSevHist *sevhist_new( pwr_tOid oid, char *aname);
CoLogin *login_new( char *wl_name,
char *wl_groupname,
void (* wl_bc_success)( void *),
......@@ -63,7 +63,7 @@ class XttTblGtk : public XttTbl {
static void activate_login( GtkWidget *w, gpointer data);
static void activate_logout( GtkWidget *w, gpointer data);
static void activate_close( GtkWidget *w, gpointer data);
static void activate_opendshist( GtkWidget *w, gpointer data);
static void activate_opensevhist( GtkWidget *w, gpointer data);
static void activate_delete_item( GtkWidget *w, gpointer data);
static void activate_tree_layout( GtkWidget *w, gpointer data);
static void activate_list_layout( GtkWidget *w, gpointer data);
......
/*
* Proview $Id: xtt_tbl.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: xtt_tbl.cpp,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -118,13 +118,16 @@ void XttTbl::activate_print()
system(cmd);
}
void XttTbl::activate_opendshist()
void XttTbl::activate_opensevhist()
{
sevcli_sHistItem *hi;
tblnav->get_select( &hi);
if ( !tblnav->get_select( &hi)) {
message( 'E', "Select an storage item");
return;
}
dshist_new( hi->oid, hi->aname);
sevhist_new( hi->oid, hi->attr[0].aname);
}
void XttTbl::delete_item_yes( void *ctx, void *data)
......@@ -134,7 +137,7 @@ void XttTbl::delete_item_yes( void *ctx, void *data)
pwr_tStatus sts;
printf("Deleting %s\n", hi->oname);
sevcli_delete_item( &sts, tbl->sevcli, hi->oid, hi->aname);
sevcli_delete_item( &sts, tbl->sevcli, hi->oid, hi->attr[0].aname);
if ( EVEN(sts)) {
tbl->message( 'E', "Delete error");
return;
......@@ -154,7 +157,7 @@ void XttTbl::activate_delete_item()
return;
}
sprintf( msg, "Do you really wan't to delete all stored data for item\n\n%s.%s\n", hi->oname, hi->aname);
sprintf( msg, "Do you really wan't to delete all stored data for item\n\n%s.%s\n", hi->oname, hi->attr[0].aname);
wow->DisplayQuestion( this, "Confirm Delete Item", msg, delete_item_yes, 0, hi);
}
......
/*
* Proview $Id: xtt_tbl.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: xtt_tbl.h,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -31,7 +31,7 @@
class TblNav;
class XttDsHist;
class XttSevHist;
class CoLogin;
class CoWow;
......@@ -55,7 +55,7 @@ class XttTbl {
int quiet;
virtual void message( char severity, char *message) {}
virtual XttDsHist *dshist_new( pwr_tOid oid, char *aname) { return 0;}
virtual XttSevHist *sevhist_new( pwr_tOid oid, char *aname) { return 0;}
virtual CoLogin *login_new( char *wl_name,
char *wl_groupname,
void (* wl_bc_success)( void *),
......@@ -67,7 +67,7 @@ class XttTbl {
void open_login();
void logout();
void activate_print();
void activate_opendshist();
void activate_opensevhist();
void activate_delete_item();
void activate_zoom_in();
void activate_zoom_out();
......
/*
* Proview $Id: xtt_tblnav.cpp,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: xtt_tblnav.cpp,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <vector.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
......@@ -585,7 +587,7 @@ void TblNav::delete_item( sevcli_sHistItem *hi)
continue;
if ( tree[i].item &&
cdh_ObjidIsEqual( tree[i].item->oid, hi->oid) &&
strcmp( tree[i].item->aname, hi->aname) == 0) {
strcmp( tree[i].item->attr[0].aname, hi->attr[0].aname) == 0) {
tree[i].deleted = 1;
}
}
......@@ -601,7 +603,7 @@ void TblNav::delete_item( sevcli_sHistItem *hi)
case tblnav_eItemType_TreeLocal: {
ItemLocal *item = (ItemLocal *)baseitem;
if ( cdh_ObjidIsEqual( hi->oid, item->item.oid) &&
strcmp( hi->aname, item->item.aname) == 0) {
strcmp( hi->attr[0].aname, item->item.attr[0].aname) == 0) {
brow_DeleteNode( brow->ctx, item->node);
found = 1;
}
......@@ -628,7 +630,7 @@ ItemLocal::ItemLocal( TblNav *tblnav, sevcli_sHistItem *xitem,
strcpy( aname, item.oname);
strcat( aname, ".");
strcat( aname, item.aname);
strcat( aname, item.attr[0].aname);
brow_SetAnnotation( node, 0, aname, strlen(aname));
brow_SetAnnotation( node, 1, item.description, strlen(item.description));
}
......@@ -650,6 +652,7 @@ int ItemLocal::open_attributes( TblNav *tblnav, double x, double y)
}
else {
char value[256];
char txt[80];
brow_SetNodraw( tblnav->brow->ctx);
......@@ -662,39 +665,64 @@ int ItemLocal::open_attributes( TblNav *tblnav, double x, double y)
new ItemLocalAttr( tblnav, "Object", item.oname, node, flow_eDest_IntoLast);
new ItemLocalAttr( tblnav, "Attribute", item.aname, node, flow_eDest_IntoLast);
time_DtoAscii( &item.storagetime, 0, value, sizeof(value));
new ItemLocalAttr( tblnav, "StorageTime", value, node, flow_eDest_IntoLast);
switch ( item.type) {
case pwr_eType_Int64: strcpy( value, "Int64"); break;
case pwr_eType_Int32: strcpy( value, "Int32"); break;
case pwr_eType_Int16: strcpy( value, "Int16"); break;
case pwr_eType_Int8: strcpy( value, "Int8"); break;
case pwr_eType_UInt64: strcpy( value, "UInt64"); break;
case pwr_eType_UInt32: strcpy( value, "UInt32"); break;
case pwr_eType_UInt16: strcpy( value, "UInt16"); break;
case pwr_eType_UInt8: strcpy( value, "UInt8"); break;
case pwr_eType_Boolean: strcpy( value, "Boolean"); break;
case pwr_eType_Char: strcpy( value, "Char"); break;
case pwr_eType_Float32: strcpy( value, "Float32"); break;
case pwr_eType_Float64: strcpy( value, "Float64"); break;
case pwr_eType_String: strcpy( value, "String"); break;
case pwr_eType_Time: strcpy( value, "Time"); break;
case pwr_eType_DeltaTime: strcpy( value, "DeltaTime"); break;
default: strcpy( value, "Unknown");
}
new ItemLocalAttr( tblnav, "DataType", value, node, flow_eDest_IntoLast);
time_AtoAscii( &item.creatime, time_eFormat_DateAndTime, value, sizeof(value));
new ItemLocalAttr( tblnav, "CreationTime", value, node, flow_eDest_IntoLast);
sprintf( value, "%d", item.size);
new ItemLocalAttr( tblnav, "DataSize", value, node, flow_eDest_IntoLast);
new ItemLocalAttr( tblnav, "Unit", item.unit, node, flow_eDest_IntoLast);
time_AtoAscii( &item.modtime, time_eFormat_DateAndTime, value, sizeof(value));
new ItemLocalAttr( tblnav, "ModificationTime", value, node, flow_eDest_IntoLast);
sprintf( value, "%f", item.scantime);
new ItemLocalAttr( tblnav, "ScanTime", value, node, flow_eDest_IntoLast);
strcpy( value, "");
if ( item.options & pwr_mSevOptionsMask_PosixTime)
strcat( value, " PosixTime");
if ( item.options & pwr_mSevOptionsMask_HighTimeResolution)
strcat( value, " HighTimeResolution");
if ( item.options & pwr_mSevOptionsMask_ReadOptimized)
strcat( value, " ReadOptimized");
if ( item.options & pwr_mSevOptionsMask_UseDeadBand)
strcat( value, " UseDeadBand");
new ItemLocalAttr( tblnav, "Options", value, node, flow_eDest_IntoLast);
sprintf( value, "%f", item.deadband);
new ItemLocalAttr( tblnav, "Deadband", value, node, flow_eDest_IntoLast);
for ( int i = 0; i < 1; i++) {
sprintf( txt, "Attr[%d].Name", i);
new ItemLocalAttr( tblnav, txt, item.attr[0].aname, node, flow_eDest_IntoLast);
switch ( item.attr[0].type) {
case pwr_eType_Int64: strcpy( value, "Int64"); break;
case pwr_eType_Int32: strcpy( value, "Int32"); break;
case pwr_eType_Int16: strcpy( value, "Int16"); break;
case pwr_eType_Int8: strcpy( value, "Int8"); break;
case pwr_eType_UInt64: strcpy( value, "UInt64"); break;
case pwr_eType_UInt32: strcpy( value, "UInt32"); break;
case pwr_eType_UInt16: strcpy( value, "UInt16"); break;
case pwr_eType_UInt8: strcpy( value, "UInt8"); break;
case pwr_eType_Boolean: strcpy( value, "Boolean"); break;
case pwr_eType_Char: strcpy( value, "Char"); break;
case pwr_eType_Float32: strcpy( value, "Float32"); break;
case pwr_eType_Float64: strcpy( value, "Float64"); break;
case pwr_eType_String: strcpy( value, "String"); break;
case pwr_eType_Time: strcpy( value, "Time"); break;
case pwr_eType_DeltaTime: strcpy( value, "DeltaTime"); break;
default: strcpy( value, "Unknown");
}
sprintf( txt, "Attr[%d].DataType", i);
new ItemLocalAttr( tblnav, txt, value, node, flow_eDest_IntoLast);
sprintf( txt, "Attr[%d].DataSize", i);
sprintf( value, "%d", item.attr[0].size);
new ItemLocalAttr( tblnav, txt, value, node, flow_eDest_IntoLast);
sprintf( txt, "Attr[%d].Unit", i);
new ItemLocalAttr( tblnav, txt, item.attr[0].unit, node, flow_eDest_IntoLast);
}
brow_SetOpen( node, tblnav_mOpen_Attributes);
brow_ResetNodraw( tblnav->brow->ctx);
brow_Redraw( tblnav->brow->ctx, node_y);
......@@ -747,7 +775,7 @@ ItemTreeLocal::ItemTreeLocal( TblNav *tblnav, sevcli_sHistItem *xitem, int index
else
strcpy( aname, item.oname);
strcat( aname, ".");
strcat( aname, item.aname);
strcat( aname, item.attr[0].aname);
brow_SetAnnotation( node, 0, aname, strlen(aname));
}
......@@ -828,7 +856,7 @@ void TblNav::build_tree()
strcpy( aname, itemlist[i].oname);
strcat( aname, ".");
strcat( aname, itemlist[i].aname);
strcat( aname, itemlist[i].attr[0].aname);
seg = dcli_parse( aname, "-", "",
(char *) name_array, sizeof( name_array)/sizeof( name_array[0]),
......
/*
* Proview $Id: sev_db.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: sev_db.h,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,23 +26,37 @@
#include "pwr_class.h"
class sev_attr {
public:
pwr_tOName aname;
pwr_eType type;
unsigned int size;
unsigned int elem;
pwr_tString16 unit;
};
class sev_item {
public:
sev_item() : deleted(0) {}
sev_item() : deadband_active(0), last_id(0), first_storage(1), deleted(0)
{ memset( old_value, 0, sizeof(old_value));}
unsigned int id;
char tablename[256];
pwr_tOid oid;
pwr_tOName aname;
pwr_tOName oname;
pwr_tTime cretime;
pwr_tTime uptime;
pwr_tTime creatime;
pwr_tTime modtime;
pwr_tDeltaTime storagetime;
pwr_eType vtype;
unsigned int vsize;
pwr_tRefId sevid;
pwr_tString80 description;
pwr_tString16 unit;
pwr_tFloat32 scantime;
pwr_tFloat32 deadband;
pwr_tMask options;
int deadband_active;
unsigned int last_id;
char old_value[8];
int first_storage;
unsigned int attrnum;
sev_attr attr[1];
int deleted;
};
......@@ -55,21 +69,24 @@ class sev_db {
virtual ~sev_db() {}
virtual int check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storatetime, pwr_eType type, unsigned int size,
char *description, char *unit, pwr_tFloat32 scantime, unsigned int *idx)
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx)
{ return 0;}
virtual 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, unsigned int *idx)
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options, unsigned int *idx)
{ return 0;}
virtual int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname) { return 0;}
virtual int store_value( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type,
virtual int store_value( pwr_tStatus *sts, int item_idx, int attr_idx,
pwr_tTime time, void *buf, unsigned int size) { return 0;}
virtual int get_values( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type,
virtual 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 *starttime,
pwr_tTime *endtime, int maxsize, pwr_tTime **tbuf, void **vbuf,
unsigned int *bsize) { return 0;}
virtual int get_items( pwr_tStatus *sts) { return 0;}
virtual int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname,
pwr_tTime limit) { return 0;}
pwr_tMask options, pwr_tTime limit) { return 0;}
};
#endif
This diff is collapsed.
/*
* Proview $Id: sev_dbms.h,v 1.2 2008-09-05 08:38:58 claes Exp $
* Proview $Id: sev_dbms.h,v 1.3 2008-09-18 14:37:43 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -19,6 +19,7 @@
#ifndef sev_dbms_h
#define sev_dbms_h
#if defined PWRE_CONF_MYSQL
#include <vector.h>
......@@ -105,24 +106,29 @@ class sev_dbms : public sev_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, unsigned int *idx);
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, unsigned int *idx);
int store_value( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, pwr_tTime time,
void *buf, unsigned int size);
int get_values( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size,
pwr_tFloat32 scantime, pwr_tTime *starttime, pwr_tTime *endtime,
int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_tTime limit);
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 *starttime,
pwr_tTime *endtime, int maxsize, pwr_tTime **tbuf, void **vbuf, unsigned int *bsize);
int delete_old_data( pwr_tStatus *sts, pwr_tOid oid, char *aname,
pwr_tMask options, pwr_tTime limit);
int delete_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
int get_items( pwr_tStatus *sts);
int create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size);
int create_table( pwr_tStatus *sts, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size,
pwr_tMask options, float deadband);
int delete_table( pwr_tStatus *sts, pwr_tOid oid, char *aname);
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);
char *description, char *unit, pwr_tFloat32 scantime,
pwr_tFloat32 deadband, pwr_tMask options);
int remove_item( pwr_tStatus *sts, pwr_tOid oid, char *aname);
char *oid_to_table( pwr_tOid oid, char *aname);
char *pwrtype_to_type( pwr_eType type, unsigned int size);
......@@ -130,3 +136,4 @@ class sev_dbms : public sev_db {
};
#endif
#endif
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