Commit 22039060 authored by Claes Sjofors's avatar Claes Sjofors

Merge branch 'master' of pwrcvs:/data1/git/pwr

parents 27c9bb37 f427f684
This diff is collapsed.
......@@ -51,28 +51,18 @@ typedef struct {
int idx;
} sev_sRefid;
// Struct for binary tree item
typedef struct {
pwr_tOid oid;
pwr_tAName aname;
} sev_sItemKey;
typedef struct {
tree_sNode node;
sev_sItemKey key;
int idx;
} sev_sItem;
class sev_server {
public:
sev_server() : m_server_status(0), m_refid(0), m_item_key(0), m_msg_id(0) {}
//TODO should this really be in this file?
static const unsigned int constSevVersion = 2;
sev_server() : m_server_status(0), m_refid(0), m_msg_id(0) {}
pwr_tStatus m_sts;
pwr_tStatus m_server_status;
vector<sev_node> m_nodes;
tree_sTable *m_refid;
tree_sTable *m_item_key;
unsigned int m_msg_id;
sev_db *m_db;
int m_noneth;
......@@ -84,6 +74,7 @@ class sev_server {
int check_histitems( sev_sMsgHistItems *msg, unsigned int size);
int receive_histdata( sev_sMsgHistDataStore *msg, unsigned int size);
int send_histdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *msg, unsigned int size);
int send_objecthistdata( qcom_sQid tgt, sev_sMsgHistDataGetRequest *rmsg, unsigned int size);
int send_itemlist( qcom_sQid tgt);
int send_server_status( qcom_sQid tgt);
int delete_item( qcom_sQid tgt, sev_sMsgHistItemDelete *rmsg);
......
......@@ -202,7 +202,7 @@ void XttTblGtk::activate_list_layout( GtkWidget *w, gpointer data)
xtt->tblnav->show_list();
}
XttSevHist *XttTblGtk::sevhist_new( pwr_tOid oid, char *aname)
XttSevHist *XttTblGtk::sevhist_new( pwr_tOid oid, char *aname, bool sevhistobject)
{
GtkWidget *w;
pwr_tStatus sts;
......@@ -214,7 +214,7 @@ XttSevHist *XttTblGtk::sevhist_new( pwr_tOid oid, char *aname)
strncpy( anamev[0], aname, sizeof(anamev[0]));
return new XttSevHistGtk( (void *)this, toplevel, "SevHist", &w, oidv, anamev,
sevcli, &sts);
sevcli, &sts, sevhistobject);
}
CoLogin *XttTblGtk::login_new( const char *name,
......
......@@ -49,7 +49,7 @@ class XttTblGtk : public XttTbl {
CoWowEntryGtk *cmd_entry;
void message( char severity, char *message);
XttSevHist *sevhist_new( pwr_tOid oid, char *aname);
XttSevHist *sevhist_new( pwr_tOid oid, char *aname, bool sevhistobject);
CoLogin *login_new( const char *wl_name,
const char *wl_groupname,
void (* wl_bc_success)( void *),
......
......@@ -120,24 +120,41 @@ void XttTbl::activate_print()
void XttTbl::activate_opensevhist()
{
sevcli_sHistItem *hi;
// sevcli_sHistItem *hi;
TblNav_sevhistobject *hi;
if ( !tblnav->get_select( &hi)) {
message( 'E', "Select an storage item");
return;
}
sevhist_new( hi->oid, hi->attr[0].aname);
bool sevhistobject = hi->attrnum > 1;
if( !sevhistobject ) {
sevhist_new( hi->oid, hi->objectattrlist[0].aname, sevhistobject);
}
else {
char *s;
pwr_tAName aname;
s = strchr( hi->oname, '.');
if ( !s) {
//It is a complete object
aname[0] = '\0';
}
else {
strcpy( aname, s+1);
}
sevhist_new( hi->oid, aname, sevhistobject);
}
}
void XttTbl::delete_item_yes( void *ctx, void *data)
{
XttTbl *tbl = (XttTbl *)ctx;
sevcli_sHistItem *hi = (sevcli_sHistItem *)data;
// sevcli_sHistItem *hi = (sevcli_sHistItem *)data;
TblNav_sevhistobject *hi = (TblNav_sevhistobject *)data;
pwr_tStatus sts;
printf("Deleting %s\n", hi->oname);
sevcli_delete_item( &sts, tbl->sevcli, hi->oid, hi->attr[0].aname);
sevcli_delete_item( &sts, tbl->sevcli, hi->oid, hi->objectattrlist[0].aname);
if ( EVEN(sts)) {
tbl->message( 'E', "Delete error");
return;
......@@ -149,7 +166,8 @@ void XttTbl::delete_item_yes( void *ctx, void *data)
void XttTbl::activate_delete_item()
{
sevcli_sHistItem *hi;
//sevcli_sHistItem *hi;
TblNav_sevhistobject *hi;
char msg[300];
if ( !tblnav->get_select( &hi)) {
......@@ -157,7 +175,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->attr[0].aname);
sprintf( msg, "Do you really wan't to delete all stored data for item\n\n%s.%s\n", hi->oname, hi->objectattrlist[0].aname);
wow->DisplayQuestion( this, "Confirm Delete Item", msg, delete_item_yes, 0, hi);
}
......
......@@ -55,7 +55,7 @@ class XttTbl {
int quiet;
virtual void message( char severity, const char *message) {}
virtual XttSevHist *sevhist_new( pwr_tOid oid, char *aname) { return 0;}
virtual XttSevHist *sevhist_new( pwr_tOid oid, char *aname, bool sevhistobject) { return 0;}
virtual CoLogin *login_new( const char *wl_name,
const char *wl_groupname,
void (* wl_bc_success)( void *),
......
This diff is collapsed.
......@@ -63,6 +63,30 @@ typedef enum {
tblnav_mOpen_Attributes = 1 << 1
} tblnav_mOpen;
class TblNav_sevhistobjectattr {
public:
pwr_tAName aname;
pwr_eType type;
unsigned int size;
unsigned int elem;
pwr_tString16 unit;
};
class TblNav_sevhistobject {
public:
pwr_tOid oid;
pwr_tAName oname;
pwr_tDeltaTime storagetime;
pwr_tTime creatime;
pwr_tTime modtime;
pwr_tString80 description;
pwr_tFloat32 scantime;
pwr_tFloat32 deadband;
pwr_tMask options;
unsigned int attrnum;
vector<TblNav_sevhistobjectattr> objectattrlist;
};
class TblTreeNode {
public:
......@@ -73,7 +97,7 @@ public:
int fws;
int bws;
char sname[80];
sevcli_sHistItem *item;
TblNav_sevhistobject *item;
int deleted;
};
......@@ -100,6 +124,7 @@ class TblNavBrow {
};
//! The navigation area of the attribute editor.
class TblNav {
public:
......@@ -112,6 +137,7 @@ class TblNav {
void *parent_ctx;
TblNavBrow *brow;
sevcli_sHistItem *itemlist;
vector<TblNav_sevhistobject> sevhistobjectlist;
int item_cnt;
void (*message_cb)( void *, char, const char *);
int (*is_authorized_cb)( void *, unsigned int, int);
......@@ -122,14 +148,16 @@ class TblNav {
int is_authorized( unsigned int access = pwr_mAccess_AllSev, int msg = 1);
int create_items();
void build_tree();
int get_select( sevcli_sHistItem **hi);
int get_select( TblNav_sevhistobject **hi);
void get_zoom( double *zoom_factor);
void zoom( double zoom_factor);
void unzoom();
void show_tree();
void show_list();
void delete_item( sevcli_sHistItem *hi);
void delete_item( TblNav_sevhistobject *hi);
void create_objectlist( sevcli_sHistItem *xn_itemlist,
int xn_item_cnt,
pwr_tStatus *status);
virtual void message( char sev, const char *text);
virtual void set_inputfocus() {}
static int init_brow_cb( FlowCtx *fctx, void *client_data);
......@@ -146,10 +174,13 @@ class ItemBase {
//! Item for a normal attribute.
class ItemLocal : public ItemBase {
public:
ItemLocal( TblNav *tblnav, sevcli_sHistItem *item, brow_tNode dest, flow_eDest dest_code);
// ItemLocal( TblNav *tblnav, sevcli_sHistItem *item, brow_tNode dest, flow_eDest dest_code);
ItemLocal( TblNav *tblnav, TblNav_sevhistobject *item, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemLocal() {}
sevcli_sHistItem item;
// sevcli_sHistItem item;
TblNav_sevhistobject item;
brow_tNode node;
int open_attributes( TblNav *tblnav, double x, double y);
......@@ -161,14 +192,15 @@ class ItemLocalAttr : public ItemBase {
ItemLocalAttr( TblNav *tblnav, const char *iname, char *ivalue, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemLocalAttr() {}
sevcli_sHistItem item;
TblNav_sevhistobject item;
//sevcli_sHistItem item;
brow_tNode node;
};
//! Item for a normal attribute.
class ItemTreeLocal : public ItemLocal {
public:
ItemTreeLocal( TblNav *tblnav, sevcli_sHistItem *item, int index, brow_tNode dest, flow_eDest dest_code);
ItemTreeLocal( TblNav *tblnav, TblNav_sevhistobject *item, int index, brow_tNode dest, flow_eDest dest_code);
virtual ~ItemTreeLocal() {}
int idx;
......
......@@ -38,9 +38,9 @@ class sev_attr {
class sev_item {
public:
sev_item() : deadband_active(0), last_id(0), first_storage(1), status(0), logged_status(0),
deleted(0)
{ memset( old_value, 0, sizeof(old_value));}
sev_item() : deadband_active(0), last_id(0), value_size(0), old_value(0), first_storage(1), status(0), logged_status(0),
deleted(0)
{ /*memset( old_value, 0, sizeof(old_value));*/}
unsigned int id;
char tablename[256];
pwr_tOid oid;
......@@ -55,10 +55,12 @@ class sev_item {
pwr_tMask options;
int deadband_active;
unsigned int last_id;
char old_value[8];
//char old_value[8];
unsigned int value_size;
void *old_value;
int first_storage;
unsigned int attrnum;
sev_attr attr[1];
vector<sev_attr> attr;
pwr_tStatus status;
pwr_tStatus logged_status;
int deleted;
......@@ -90,7 +92,31 @@ class sev_db {
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_tMask options, pwr_tTime limit) { return 0;}
virtual int delete_old_data( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit, pwr_tFloat32 scantime, pwr_tFloat32 garbagecycle) { return 0;}
virtual 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) { return 0;}
virtual 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) { return 0;}
virtual 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) { return 0;}
virtual int get_item( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename) { return 0;}
virtual int get_objectitem( pwr_tStatus *sts, sev_item *item, pwr_tOid oid, char *attributename) { return 0;}
virtual int get_objectitems( pwr_tStatus *sts) { return 0;}
virtual int check_objectitemattr( pwr_tStatus *sts, char *tablename, pwr_tOid oid, char *aname, char *oname,
pwr_eType type, unsigned int size, unsigned int *idx) { return 0;}
virtual int delete_old_objectdata( pwr_tStatus *sts, char *tablename,
pwr_tMask options, pwr_tTime limit, pwr_tFloat32 scantime, pwr_tFloat32 garbagecycle) { return 0;}
virtual 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) { return 0;}
virtual int handle_objectchange(pwr_tStatus *sts, char *tablename, unsigned int item_idx, bool newObject) { return 0;}
};
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -67,6 +67,9 @@ class sev_dbms_env
int open(const char *host, const char *user, const char *passwd,
const char *dbName, unsigned int port, const char *socket);
int checkAndUpdateVersion(unsigned int version);
int updateDBToSevVersion2(void);
int createSevVersion2Tables(void);
MYSQL *createDb(void);
MYSQL *openDb(void);
bool exists() { return m_exists;}
......@@ -101,10 +104,12 @@ class sev_dbms_env
class sev_dbms : public sev_db {
public:
static const unsigned int constMaxColNameLength = 64;
sev_dbms_env *m_env;
sev_dbms( sev_dbms_env *env) : m_env(env) {}
~sev_dbms() {}
~sev_dbms();
int check_item( pwr_tStatus *sts, pwr_tOid oid, char *oname, char *aname,
pwr_tDeltaTime storagetime, pwr_eType type, unsigned int size,
......@@ -120,23 +125,62 @@ class sev_dbms : public sev_db {
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, pwr_tOid oid, char *aname,
pwr_tMask options, pwr_tTime limit);
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, pwr_tOid oid, char *aname, pwr_eType type, unsigned int size,
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, pwr_tOid oid, char *aname);
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);
char *oid_to_table( pwr_tOid oid, char *aname);
static char *oid_to_table( pwr_tOid oid, char *aname);
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);
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);
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
This diff is collapsed.
......@@ -42,6 +42,32 @@ class sev_sevhist {
pwr_tFloat32 scantime;
};
class sev_sevhistobjectattr {
public:
pwr_tAttrRef aref;
pwr_tString80 description;
pwr_tString16 unit;
pwr_tAName aname;
pwr_tRefId refid;
void *datap;
pwr_eType type;
unsigned int size;
};
class sev_sevhistobject {
public:
pwr_tAttrRef aref;
pwr_tAName aname;
pwr_tDeltaTime storagetime;
pwr_tFloat32 deadband;
pwr_tMask options;
pwr_tRefId sevid;
pwr_tString80 description;
pwr_tFloat32 scantime;
unsigned int datasize;
vector<sev_sevhistobjectattr> sevhistobjectattrlist;
};
class sev_sevhistthread {
public:
sev_sevhistthread() : configerror(0) {}
......@@ -54,6 +80,7 @@ class sev_sevhistthread {
pwr_tRefId refid;
int configerror;
vector<sev_sevhist> sevhistlist;
vector<sev_sevhistobject> sevhistobjectlist;
};
class sev_node {
......@@ -88,6 +115,16 @@ class rt_sevhistmon {
int init();
int init_objects();
int init_sevhistobjects();
void insert_sevhistobjectattr(pwr_sAttrRef *aref,
pwr_tAName objectname,
int hs_idx,
vector<sev_sevhistobjectattr> *listP);
int get_sevhistobjectattributes (pwr_tAName objectname,
vector<sev_sevhistobjectattr> *listP,
int hs_idx,
pwr_tBoolean first);
bool correct_histtype(const pwr_eType type);
int close();
int close_objects();
int mainloop();
......
......@@ -100,9 +100,9 @@ static long int dtt_current_index = 2;
static int dtt_is_rttsys;
static int dtt_opsys = 0;
static int dtt_current_opsys;
static char dtt_source_dir[80];
static char dtt_build_dir[80];
static char dtt_exe_dir[80];
static pwr_tFileName dtt_source_dir;
static pwr_tFileName dtt_build_dir;
static pwr_tFileName dtt_exe_dir;
/*_Local function prototypes_____________________________________________*/
......@@ -613,15 +613,15 @@ static int write_func( edit_ctx ctx,
int sts;
char arg1_str[80];
char arg2_str[80];
char filename[80];
char menu_filename[80];
pwr_tFileName filename;
pwr_tFileName menu_filename;
int messages;
if ( ODD( rtt_get_qualifier( "rtt_arg1", arg1_str)))
{
if ( cdh_NoCaseStrncmp( arg1_str, "ITEMS", strlen( arg1_str)) == 0)
{
char outfilename[80];
pwr_tFileName outfilename;
char message[120];
FILE *outfile;
......@@ -817,8 +817,8 @@ static int save_func( edit_ctx ctx,
{
int sts;
char arg1_str[80];
char filename[80];
char menu_filename[80];
pwr_tFileName filename;
pwr_tFileName menu_filename;
int messages;
int opsys;
int nocompile;
......@@ -977,7 +977,7 @@ static int generate_func( edit_ctx ctx,
{
int sts;
char arg1_str[80];
char filename[80];
pwr_tFileName filename;
char *s, *t;
char index_str[10];
int index;
......@@ -1179,8 +1179,8 @@ static int dtt_exit_func( edit_ctx ctx,
int flag)
{
int sts;
char filename[80];
char menu_filename[80];
pwr_tFileName filename;
pwr_tFileName menu_filename;
int messages;
if (( ctx->ctx_type == DTT_CTX_EDIT) ||
......@@ -1346,7 +1346,7 @@ static int dtt_list_func( edit_ctx ctx,
int sts;
char arg1_str[80];
char arg2_str[80];
char outfilename[80];
pwr_tFileName outfilename;
char message[120];
FILE *outfile;
......@@ -1890,9 +1890,9 @@ static int dtt_edit_func( edit_ctx ctx,
int flag)
{
char arg1_str[80];
char filename[80];
pwr_tFileName filename;
char menuname[80];
char cmd[100];
pwr_tCmd cmd;
if ( EVEN( rtt_get_qualifier( "rtt_arg1", arg1_str)))
{
......@@ -2049,7 +2049,7 @@ static int dtt_include_func( menu_ctx ctx,
}
else if ( cdh_NoCaseStrncmp( arg1_str, "MENU", strlen( arg1_str)) == 0)
{
char filename[80];
pwr_tFileName filename;
/* Check that this is not an edit context */
if ( ctx->ctx_type == DTT_CTX_EDIT)
......@@ -4830,7 +4830,7 @@ int dtt_edit_new( menu_ctx parent_ctx,
unsigned long option;
char input_str[80];
int maxlen = 1;
char filename[80];
pwr_tFileName filename;
unsigned char c;
rtt_t_menu *menu_ptr;
char *title;
......@@ -5132,8 +5132,8 @@ static int dtt_edit_write( edit_ctx ctx,
int i, j, k;
char *char_ptr;
dtt_item item_ptr;
char fname[200];
char fnamebld[200];
pwr_tFileName fname;
pwr_tFileName fnamebld;
char picture_name[80];
int x, y;
int error_count;
......@@ -5444,7 +5444,7 @@ static int dtt_edit_read( edit_ctx ctx,
{
FILE *fin;
char *s;
char filename[80];
pwr_tFileName filename;
int sts;
char line[200];
int i, j;
......@@ -5553,7 +5553,7 @@ static int dtt_edit_read_v27( edit_ctx ctx,
{
FILE *fin;
char *s;
char filename[80];
pwr_tFileName filename;
dtt_t_upd_item item_buffer;
dtt_item item_ptr;
int sts;
......@@ -6897,11 +6897,11 @@ static int dtt_edit_save_menues( char *filename,
FILE *fout_db2;
FILE *fout_decl;
FILE *fout_hlp = 0;
char fname[200];
char fnamebld_noext[200];
char fname_noext[200];
char cmd[200];
char tmpstr[80];
pwr_tFileName fname;
pwr_tFileName fnamebld_noext;
pwr_tFileName fname_noext;
pwr_tCmd cmd;
pwr_tFileName tmpstr;
int nocompile = 0;
if ( dtt_is_rttsys && !generate_only)
......@@ -7065,9 +7065,9 @@ static int dtt_edit_save_one_menu( FILE *fout,
char picture_name[80];
char menu_name[80];
char item_menu_name[80];
char fname[200];
pwr_tFileName fname;
FILE *fout_test = 0;
char tmpstr[200];
pwr_tFileName tmpstr;
menu_ptr = ctx->menu;
......@@ -7415,7 +7415,7 @@ static int dtt_edit_read_menues( char *filename)
int sts;
FILE *fin;
char *s;
char fname[200];
pwr_tFileName fname;
char line[80];
sprintf( fname, "%s%s.dtt_m", dtt_source_dir, filename);
......@@ -7734,8 +7734,8 @@ static int dtt_get_menu_name( int index,
int dtt_start( char *programname)
{
int sts;
char filename[80];
int sts;
pwr_tFileName filename;
rtt_t_menu *menulist;
char first_item[80];
char *s;
......@@ -7991,7 +7991,7 @@ static int dtt_cc( int opsys,
static int dtt_compile_picture( char *filename,
int opsys)
{
char cmd[200];
pwr_tCmd cmd;
char msg[80];
int os;
......@@ -8315,7 +8315,7 @@ static int dtt_edit_write_gdhrefs( char *filename)
{
FILE *outfile;
int sts;
char outfilename[80];
pwr_tFileName outfilename;
char message[80];
/* Open file */
......@@ -8346,7 +8346,7 @@ static int dtt_edit_write_menu_gdhrefs( menu_ctx ctx,
int sts;
rtt_t_menu *menu_ptr;
edit_ctx picture_ctx;
char picturefilename[80];
pwr_tFileName picturefilename;
char *title;
dtt_item item_ptr;
int gdh_item_found;
......@@ -8412,7 +8412,7 @@ static int dtt_edit_pwrplc_gdhrefs( char *filename)
FILE *outfile;
int sts;
int externref_index;
char outfilename[80];
pwr_tFileName outfilename;
char message[80];
externref_index = 0;
......@@ -8459,7 +8459,7 @@ static int dtt_edit_pwrplc_menu_gdhrefs( menu_ctx ctx,
int sts;
rtt_t_menu *menu_ptr;
edit_ctx picture_ctx;
char picturefilename[80];
pwr_tFileName picturefilename;
char *title;
dtt_item item_ptr;
int gdh_item_found;
......@@ -8593,7 +8593,7 @@ static int dtt_edit_list_items_all( char *filename)
{
FILE *outfile;
int sts;
char outfilename[80];
pwr_tFileName outfilename;
char message[80];
/* Open file */
......@@ -8624,7 +8624,7 @@ static int dtt_edit_list_items_picture( menu_ctx ctx,
int sts;
rtt_t_menu *menu_ptr;
edit_ctx picture_ctx;
char picturefilename[80];
pwr_tFileName picturefilename;
char *title;
menu_ptr = ctx->menu;
......@@ -9165,7 +9165,7 @@ static int dtt_edit_save_all( int generate_only,
int opsys)
{
int sts;
char filename[80];
pwr_tFileName filename;
/* Save all pictures */
sts = dtt_edit_process_menues( &dtt_edit_save_picture,
......@@ -9206,8 +9206,8 @@ static int dtt_edit_convert_picture( menu_ctx ctx,
int dum4)
{
int sts;
char picturefilename[80];
char menufilename[80];
pwr_tFileName picturefilename;
pwr_tFileName menufilename;
rtt_t_menu *menu_ptr;
edit_ctx picture_ctx;
char *title;
......@@ -9286,8 +9286,8 @@ static int dtt_edit_save_picture( menu_ctx ctx,
int nocompile)
{
int sts;
char picturefilename[80];
char menufilename[80];
pwr_tFileName picturefilename;
pwr_tFileName menufilename;
rtt_t_menu *menu_ptr;
edit_ctx picture_ctx;
char *title;
......
......@@ -42,7 +42,9 @@ typedef enum {
sev_eMsgType_HistItemDelete,
sev_eMsgType_HistItemStatus,
sev_eMsgType_ServerStatusRequest,
sev_eMsgType_ServerStatus
sev_eMsgType_ServerStatus,
sev_eMsgType_HistObjectDataGetRequest,
sev_eMsgType_HistObjectDataGet
} sev_eMsgType;
typedef struct {
......@@ -83,7 +85,9 @@ typedef struct {
typedef struct {
sev_eMsgType Type;
pwr_tStatus Status;
pwr_tStatus Status;
unsigned int NumItems;
unsigned int NumAttributes;
sev_sHistItem Items[1];
} sev_sMsgHistItems;
......@@ -113,6 +117,18 @@ typedef struct {
int Data[1];
} sev_sMsgHistDataGet;
typedef struct {
sev_eMsgType Type;
pwr_tOid Oid;
pwr_tOName AName;
pwr_tStatus Status;
int NumPoints;
int NumAttributes;
unsigned int TotalDataSize;
sev_sHistAttr Attr[1];
int Data[1];
} sev_sMsgHistObjectDataGet;
typedef struct {
sev_eMsgType Type;
pwr_tOid Oid;
......
......@@ -115,6 +115,102 @@ int sevcli_get_itemlist( pwr_tStatus *sts, sevcli_tCtx ctx, sevcli_sHistItem **l
tgt.qix = sev_eProcSevServer;
put.reply = ctx->qid;
put.type.b = (qcom_eBtype) sev_cMsgClass;
put.type.s = (qcom_eStype) sev_eMsgType_HistItemsRequest;
put.msg_id = ctx->msg_id++;
put.size = sizeof(*msg);
msg = (sev_sMsgAny *) qcom_Alloc( sts, put.size);
put.data = msg;
msg->Type = sev_eMsgType_HistItemsRequest;
if ( !qcom_Put( sts, &tgt, &put)) {
qcom_Free( &lsts, put.data);
return 0;
}
sev_sMsgHistItems *rmsg;
memset( &get, 0, sizeof(get));
for (;;) {
rmsg = (sev_sMsgHistItems *) qcom_Get( sts, &ctx->qid, &get, tmo);
if ( *sts == QCOM__TMO || !rmsg) {
return 0;
}
if ( get.type.b == sev_cMsgClass &&
get.type.s == (qcom_eStype) sev_eMsgType_HistItems)
break;
qcom_Free( sts, rmsg);
}
*sts = rmsg->Status;
if ( EVEN(*sts))
return 0;
//int item_cnt = (get.size - sizeof(sev_sMsgHistItems)) / sizeof(sev_sHistItem) + 1;
int item_cnt = rmsg->NumItems;
int attr_cnt = rmsg->NumAttributes;
unsigned int data_size = (item_cnt * sizeof(sevcli_sHistItem)) + ((attr_cnt - item_cnt) * sizeof(sevcli_sHistAttr));
lp = (sevcli_sHistItem *) malloc( data_size );
sevcli_sHistItem *lp2 = lp;
sev_sHistItem *itemPtr = ((sev_sMsgHistItems *)rmsg)->Items;
for ( i = 0; i < item_cnt; i++) {
lp->oid = itemPtr->oid;
strncpy( lp->oname, itemPtr->oname, sizeof(lp->oname));
lp->storagetime = net_NetTimeToDeltaTime( &itemPtr->storagetime);
lp->deadband = itemPtr->deadband;
lp->options = itemPtr->options;
lp->creatime = net_NetTimeToTime( &itemPtr->creatime);
lp->modtime = net_NetTimeToTime( &itemPtr->modtime);
strncpy( lp->description, itemPtr->description, sizeof(lp->description));
lp->scantime = itemPtr->scantime;
lp->attrnum = itemPtr->attrnum;
size_t j=0;
for( j=0; j < lp->attrnum; j++ ) {
lp->attr[j].type = itemPtr->attr[j].type;
lp->attr[j].size = itemPtr->attr[j].size;
strncpy( lp->attr[j].aname, itemPtr->attr[j].aname, sizeof(lp->attr[0].aname));
strncpy( lp->attr[j].unit, itemPtr->attr[j].unit, sizeof(lp->attr[0].unit));
}
itemPtr = (sev_sHistItem *)&itemPtr->attr[j];
lp = (sevcli_sHistItem *)&lp->attr[j];
}
qcom_Free( sts, rmsg);
*cnt = item_cnt;
*list = lp2;
*sts = SEV__SUCCESS;
return 1;
}
/*
int sevcli_get_itemlist( pwr_tStatus *sts, sevcli_tCtx ctx, sevcli_sHistItem **list,
unsigned int *cnt)
{
sev_sMsgAny *msg;
qcom_sQid tgt;
qcom_sPut put;
pwr_tStatus lsts;
int tmo = 1000;
qcom_sGet get;
sevcli_sHistItem *lp;
int i;
if ( ctx->server)
tgt.nid = ctx->server;
else
tgt.nid = ctx->qid.nid;
tgt.qix = sev_eProcSevServer;
put.reply = ctx->qid;
put.type.b = (qcom_eBtype) sev_cMsgClass;
put.type.s = (qcom_eStype) sev_eMsgType_HistItemsRequest;
......@@ -180,6 +276,7 @@ int sevcli_get_itemlist( pwr_tStatus *sts, sevcli_tCtx ctx, sevcli_sHistItem **l
*sts = SEV__SUCCESS;
return 1;
}
*/
int sevcli_get_itemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
char *aname, pwr_tTime starttime, pwr_tTime endtime, int numpoints,
......@@ -220,6 +317,7 @@ int sevcli_get_itemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
// Empty queue
sev_sMsgHistDataGet *rmsg;
memset( &get, 0, sizeof(get));
for (;;) {
rmsg = (sev_sMsgHistDataGet *) qcom_Get(sts, &ctx->qid, &get, 0);
if ( !rmsg)
......@@ -248,8 +346,10 @@ int sevcli_get_itemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
}
*sts = rmsg->Status;
if ( EVEN(*sts))
if ( EVEN(*sts)) {
qcom_Free( sts, rmsg);
return 0;
}
int item_cnt = rmsg->NumPoints;
......@@ -268,6 +368,119 @@ int sevcli_get_itemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
return 1;
}
int sevcli_get_objectitemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid, char *aname,
pwr_tTime starttime, pwr_tTime endtime, int numpoints,
pwr_tTime **tbuf, void **vbuf, int *rows,
sevcli_sHistAttr **histattr, int *numattributes)
{
sev_sMsgHistDataGetRequest *msg;
qcom_sQid tgt;
qcom_sPut put;
int tmo = 30000;
qcom_sGet get;
pwr_tStatus lsts;
if ( ctx->server)
tgt.nid = ctx->server;
else
tgt.nid = ctx->qid.nid;
tgt.qix = sev_eProcSevServer;
put.reply = ctx->qid;
put.type.b = (qcom_eBtype) sev_cMsgClass;
put.type.s = (qcom_eStype) sev_eMsgType_HistObjectDataGetRequest;
put.msg_id = ctx->msg_id++;
put.size = sizeof(*msg);
msg = (sev_sMsgHistDataGetRequest *) qcom_Alloc( sts, put.size);
put.data = msg;
msg->Type = sev_eMsgType_HistObjectDataGetRequest;
msg->Oid = oid;
strncpy( msg->AName, aname, sizeof(msg->AName));
msg->StartTime = net_TimeToNetTime( &starttime);
msg->EndTime = net_TimeToNetTime( &endtime);
msg->NumPoints = numpoints;
// Empty queue
sev_sMsgHistObjectDataGet *rmsg;
memset(&get, 0, sizeof(get));
for (;;) {
rmsg = (sev_sMsgHistObjectDataGet *) qcom_Get(sts, &ctx->qid, &get, 0);
if ( !rmsg)
break;
}
if ( !qcom_Put( sts, &tgt, &put)) {
qcom_Free( &lsts, put.data);
*sts = 0;
return 0;
}
memset( &get, 0, sizeof(get));
for (;;) {
rmsg = (sev_sMsgHistObjectDataGet *) qcom_Get(sts, &ctx->qid, &get, tmo);
if ( *sts == QCOM__TMO || !rmsg) {
*sts = 0;
return 0;
}
if ( get.type.b == sev_cMsgClass &&
get.type.s == (qcom_eStype) sev_eMsgType_HistObjectDataGet &&
cdh_ObjidIsEqual( oid, rmsg->Oid) &&
cdh_NoCaseStrcmp( aname, rmsg->AName) == 0)
break;
qcom_Free( sts, rmsg);
}
*sts = rmsg->Status;
if ( EVEN(*sts)) {
qcom_Free( sts, rmsg);
return 0;
}
if( rmsg->NumPoints == 0 ) {
qcom_Free( sts, rmsg);
*sts = 0;
return 0;
}
*numattributes = rmsg->NumAttributes;
int item_cnt = rmsg->NumPoints;
unsigned int timebufsize = item_cnt * sizeof(pwr_tTime);
unsigned int databufsize = rmsg->TotalDataSize - timebufsize;
*tbuf = malloc( timebufsize);
*vbuf = malloc( databufsize );
sevcli_sHistAttr *attrptr;
attrptr = calloc( rmsg->NumAttributes, sizeof(sevcli_sHistAttr) );
int attrCount = rmsg->NumAttributes;
void *ptr = &rmsg->Attr[attrCount];
memcpy( *tbuf, ptr, item_cnt * sizeof(pwr_tTime));
memcpy( *vbuf, (char *)ptr + item_cnt * sizeof(pwr_tTime), databufsize );
*rows = item_cnt;
int i = 0;
for( i = 0; i < rmsg->NumAttributes; i++ ) {
strncpy(attrptr[i].aname, rmsg->Attr[i].aname, sizeof(attrptr[0].aname));
attrptr[i].type = rmsg->Attr[i].type;
attrptr[i].size = rmsg->Attr[i].size;
}
*histattr = attrptr;
qcom_Free( sts, rmsg);
*sts = SEV__SUCCESS;
return 1;
}
int sevcli_delete_item( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid, char *aname)
{
sev_sMsgHistItemDelete *msg;
......
......@@ -76,7 +76,10 @@ int sevcli_get_itemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
pwr_tTime **tbuf, void **vbuf, int *rows,
pwr_eType *vtype, unsigned int *vsize);
int sevcli_delete_item( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid, char *aname);
int sevcli_get_objectitemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid, char *aname,
pwr_tTime starttime, pwr_tTime endtime, int numpoints,
pwr_tTime **tbuf, void **vbuf, int *rows,
sevcli_sHistAttr **histattr, int *numattributes);
#ifdef __cplusplus
}
......
......@@ -42,6 +42,7 @@ SObject pwrb:Class
! below the current signal object.
!
! @b See also
! @classlink SevHistObject pwrb_sevhistobject.html
! @classlink SevHistThread pwrb_sevhistthread.html
! @classlink SevHistMonitor pwrb_sevhistmonitor.html
! @classlink SevHistServer pwrb_sevhistserver.html
......
......@@ -33,6 +33,7 @@ SObject pwrb:Class
! @b See also
! @classlink SevHistThread pwrb_sevhistthread.html
! @classlink SevHist pwrb_sevhist.html
! @classlink SevHistObject pwrb_sevhistobject.html
! @classlink SevHistServer pwrb_sevhistserver.html
!*/
Object SevHistMonitor $ClassDef 534
......
!
! Proview $Id: pwrb_c_sevhistobject.wb_load,v 1.2 2009-11-24 16:06:00 claes Exp $
! Copyright (C) 2005 SSAB Oxelsund AB.
!
! 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 the program, if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!
! pwrb_c_sevhistobject.wb_load -- Defines the class SevHistObject.
!
SObject pwrb:Class
!/**
! @Version 2.0
! @Group PlantConfiguration,SevHist
! @Summary Configures historical data storage for an objects all attribute values.
! Configures historical data storage for x scalar
! quantitites or elements in x number of one-dimensional vectors. (Datastorage
! History).
!
! In a relational database, data resides in
! two-dimensional tables known as relations. A relation
! consist of rows and columns.
!
! The SevHistObject object specifies which quantity is to be
! stored and in which relation. Up to three different
! relations can be specified.
!
! @b See also
! @classlink SevHist pwrb_sevhist.html
! @classlink SevHistThread pwrb_sevhistthread.html
! @classlink SevHistMonitor pwrb_sevhistmonitor.html
! @classlink SevHistServer pwrb_sevhistserver.html
!*/
Object SevHistObject $ClassDef 539
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "SevHistObject"
EndBody
!/**
! Optional desription.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Specifies the complete name of the object whose
! attribute values is to be stored.
!*/
Object Object $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
EndBody
EndObject
!/**
! SevHistThread object that specifies the storage scantime
! and in which server the data is stored.
!*/
Object ThreadObject $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
EndBody
EndObject
!/**
! Time the data will be stored in the database.
! Data that is older than this time will be removed from
! the database by a garbage collector.
!*/
Object StorageTime $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$DeltaTime"
EndBody
EndObject
!/**
! The deadband is a range around the last stored value, where no new values
! will be stored, i.e a value has to differ more than the deadband / 2 from
! the last stored value to be stored.
!
! Deadband contains the size of deadband. Note that the DeadBand bit in options also
! has to be set to activte the deadband function.
!*/
Object DeadBand $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Storage options.
!*/
Object Options $Attribute 6
Body SysBody
Attr TypeRef = "pwrb:Type-SevHistOptionsMask"
EndBody
EndObject
EndObject
Object Template SevHistObject
Body RtBody
Attr DeadBand = 0.0
Attr Options = 4
EndBody
EndObject
Object PostCreate $DbCallBack
Body SysBody
Attr MethodName = "SevHist-PostCreate"
EndBody
EndObject
Object PostMove $DbCallBack
Body SysBody
Attr MethodName = "SevHist-PostMove"
EndBody
EndObject
Object ConfiguratorPoson $Menu
Object Pointed $Menu
Object ConnectThread $MenuButton
Body SysBody
Attr ButtonName = "Connect SevHistThread"
Attr MethodName = "$Objid-Connect"
Attr MethodArguments[0] = "ThreadObject"
Attr MethodArguments[1] = "SevHistThread"
Attr FilterName = "$Objid-IsOkConnect"
Attr FilterArguments[0] = "ThreadObject"
Attr FilterArguments[1] = "SevHistThread"
EndBody
EndObject
EndObject
EndObject
EndObject
EndSObject
......@@ -37,6 +37,7 @@ SObject pwrb:Class
! @classlink SevHistThread pwrb_sevhistthread.html
! @classlink SevHistMonitor pwrb_sevhistmonitor.html
! @classlink SevHist pwrb_sevhist.html
! @classlink SevHistObject pwrb_sevhistobject.html
!*/
Object SevServer $ClassDef 535
Body SysBody
......
......@@ -53,6 +53,7 @@ palette NavigatorPalette
class DsFastCurve
class DsTrend
class SevHist
class SevHistObject
}
menu Supervision
{
......
......@@ -51,11 +51,12 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
pwr_tOid *xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts) :
XttSevHist( parent_ctx, name, xn_oid, xn_aname, xn_scctx, sts), parent_widget(parent_wid)
int *sts, bool sevhistobject) :
XttSevHist( parent_ctx, name, xn_oid, xn_aname, xn_scctx, sts, sevhistobject), parent_widget(parent_wid)
{
char title[250];
strncpy(title, name, sizeof(title));
if ( EVEN(*sts))
// Error from XttSevHist
return;
......
......@@ -37,7 +37,8 @@ class XttSevHistGtk : public XttSevHist {
pwr_tOid *xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts);
int *sts,
bool sevhistobject);
~XttSevHistGtk();
};
......
......@@ -221,11 +221,11 @@ XttTrend *XNavGtk::xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *
}
XttSevHist *XNavGtk::xttsevhist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts)
sevcli_tCtx scctx, pwr_tStatus *sts, bool sevhistobject)
{
GtkWidget *w;
return new XttSevHistGtk( this, parent_wid, name, &w, oid, aname, scctx, sts);
return new XttSevHistGtk( this, parent_wid, name, &w, oid, aname, scctx, sts, sevhistobject);
}
XttFast *XNavGtk::xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts)
......
......@@ -59,7 +59,7 @@ class XNavGtk : public XNav {
XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts);
XttSevHist *xttsevhist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts);
sevcli_tCtx scctx, pwr_tStatus *sts, bool sevhistobject=false);
XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts);
XAttOne *xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts);
......
......@@ -422,7 +422,7 @@ static pwr_tStatus OpenHistory( xmenu_sMenuCall *ip)
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_PlotGroup) {
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject || classid == pwr_cClass_PlotGroup) {
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
......@@ -444,7 +444,7 @@ static pwr_tStatus OpenHistory( xmenu_sMenuCall *ip)
// Default XttGraph found
sts = gdh_GetAttrRefTid( &defhist, &classid);
if ( ODD(sts) &&
(classid == pwr_cClass_SevHist || classid == pwr_cClass_PlotGroup)) {
(classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject || classid == pwr_cClass_PlotGroup)) {
sts = gdh_AttrrefToName( &defhist, name, sizeof(name),
cdh_mName_volumeStrict);
......@@ -467,7 +467,7 @@ static pwr_tStatus OpenHistory( xmenu_sMenuCall *ip)
sts = gdh_GetObjectClass( oid, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_SevHist) {
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject) {
found++;
if ( found == 1)
child = oid;
......@@ -516,7 +516,7 @@ static pwr_tStatus OpenHistoryFilter( xmenu_sMenuCall *ip)
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_PlotGroup) {
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject || classid == pwr_cClass_PlotGroup) {
return XNAV__SUCCESS;
}
......@@ -531,7 +531,7 @@ static pwr_tStatus OpenHistoryFilter( xmenu_sMenuCall *ip)
// Default XttGraph found
sts = gdh_GetAttrRefTid( &defhist, &classid);
if ( ODD(sts) &&
(classid == pwr_cClass_SevHist || classid == pwr_cClass_PlotGroup))
(classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject || classid == pwr_cClass_PlotGroup))
return XNAV__SUCCESS;
}
......@@ -544,7 +544,7 @@ static pwr_tStatus OpenHistoryFilter( xmenu_sMenuCall *ip)
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_SevHist)
if ( classid == pwr_cClass_SevHist || classid == pwr_cClass_SevHistObject)
return XNAV__SUCCESS;
sts = gdh_GetNextSibling( child, &child);
......
......@@ -50,12 +50,13 @@ XttSevHist::XttSevHist( void *parent_ctx,
pwr_tOid *xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts) :
int *sts,
bool sevhistobject) :
xnav(parent_ctx), gcd(0), curve(0), rows(0), vsize(0), timerid(0), close_cb(0), help_cb(0),
first_scan(1), scctx(xn_scctx), oid(xn_oid[0]), time_low_old(0), time_high_old(0)
first_scan(1), scctx(xn_scctx), oid(xn_oid[0]), time_low_old(0), time_high_old(0), sevhistobject(sevhistobject)
{
strncpy( aname, xn_aname[0], sizeof(aname));
get_data( sts, pwr_cNTime, pwr_cNTime);
if ( EVEN(*sts)) return;
......@@ -70,6 +71,9 @@ XttSevHist::~XttSevHist()
int XttSevHist::get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
{
if( sevhistobject ) {
return get_objectdata(sts, from, to);
}
pwr_tTime *tbuf;
void *vbuf;
pwr_tDeltaTime trange;
......@@ -79,6 +83,10 @@ int XttSevHist::get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
if ( EVEN(*sts))
return 0;
if( rows == 0 ) {
return 0;
}
// Create data for time axis
gcd = new GeCurveData( curve_eDataType_DsTrend);
......@@ -167,6 +175,155 @@ int XttSevHist::get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
return 1;
}
int XttSevHist::get_objectdata( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
{
pwr_tTime *tbuf;
void *vbuf;
sevcli_sHistAttr *histattrbuf;
int numAttributes;
pwr_tDeltaTime trange;
sevcli_get_objectitemdata( sts, scctx, oid, aname, from, to, 1000, &tbuf, &vbuf,
&rows, &histattrbuf, &numAttributes);
if ( EVEN(*sts))
return 0;
if( rows == 0 ) {
return 0;
}
// Create data for time axis
gcd = new GeCurveData( curve_eDataType_DsTrend);
gcd->data[0] = (double *) calloc( 1, 8 * rows);
for ( int i = 0; i < rows; i++)
gcd->data[0][i] = (double)tbuf[i].tv_sec + (double)1e-9 * tbuf[i].tv_nsec;
strcpy( gcd->name[0], "Time");
gcd->axis_type[0] = curve_eAxis_x;
strcpy( gcd->format[0], "%10t");
//todo linesize br vi kunna f frn sevcli_get_objectitemdata
int linesize = 0;
for( int i = 0; i < numAttributes; i++) {
linesize += histattrbuf[i].size;
}
void *dataptr = vbuf;
int tmp = 0;
gcd->cols = 1;
for( int i = 0; i < numAttributes; i++) {
switch ( histattrbuf[i].type ) {
case pwr_eType_Int64:
case pwr_eType_Int32:
case pwr_eType_Int16:
case pwr_eType_Int8:
case pwr_eType_UInt64:
case pwr_eType_UInt32:
case pwr_eType_UInt16:
case pwr_eType_UInt8:
case pwr_eType_Float32:
case pwr_eType_Float64:
case pwr_eType_Boolean:
break;
default:
tmp += histattrbuf[i].size;
continue;
}
if( gcd->cols >= CURVE_MAX_COLS ) {
printf("To many columns for curve class max:%d\n", CURVE_MAX_COLS);
break;
}
gcd->cols++;
strcpy( gcd->name[gcd->cols-1], histattrbuf[i].aname);
gcd->data[gcd->cols-1] = (double *) calloc( 1, 8 * rows);
gcd->axis_type[gcd->cols-1] = curve_eAxis_y;
dataptr = (char *)vbuf + tmp;
//tmp += histattrbuf[i].size;
for ( int j = 0; j < rows; j++) {
//dataptr = (char *)dataptr + linesize*j;
dataptr = ((char *)vbuf)+ j * linesize + tmp;
switch ( histattrbuf[i].type ) {
case pwr_eType_Int64:
gcd->data[gcd->cols-1][j] = *(pwr_tInt64 *)dataptr;
break;
case pwr_eType_Int32:
gcd->data[gcd->cols-1][j] = *(pwr_tInt32 *)dataptr;
break;
case pwr_eType_Int16:
gcd->data[gcd->cols-1][j] = *(pwr_tInt16 *)dataptr;
break;
case pwr_eType_Int8:
gcd->data[gcd->cols-1][j] = *(pwr_tInt8 *)dataptr;
break;
case pwr_eType_UInt64:
gcd->data[gcd->cols-1][j] = *(pwr_tUInt64 *)dataptr;
break;
case pwr_eType_UInt32:
gcd->data[gcd->cols-1][j] = *(pwr_tUInt32 *)dataptr;
break;
case pwr_eType_UInt16:
gcd->data[gcd->cols-1][j] = *(pwr_tUInt16 *)dataptr;
break;
case pwr_eType_UInt8:
gcd->data[gcd->cols-1][j] = *(pwr_tUInt8 *)dataptr;
break;
case pwr_eType_Float32:
gcd->data[gcd->cols-1][j] = *(pwr_tFloat32 *)dataptr;
break;
case pwr_eType_Float64:
gcd->data[gcd->cols-1][j] = *(pwr_tFloat64 *)dataptr;
break;
case pwr_eType_Boolean:
gcd->data[gcd->cols-1][j] = *(pwr_tBoolean *)dataptr;
break;
default:
*sts = SEV__CURVETYPE;
return 0;
}
}
tmp += histattrbuf[i].size;
}
free( tbuf);
free( vbuf);
free( histattrbuf);
gcd->rows = rows;
gcd->get_borders();
gcd->get_default_axis();
if ( to.tv_sec != 0 && from.tv_sec != 0) {
time_Adiff( &trange, &to, &from);
if ( time_DToFloat( 0, &trange) < 600)
strcpy( gcd->format[0], "%10t");
else
strcpy( gcd->format[0], "%11t");
}
else
strcpy( gcd->format[0], "%11t");
gcd->select_color( 0);
if ( curve) {
curve->set_curvedata( gcd); // This will free the old gcd
curve->configure_curves();
curve->configure_axes();
curve->redraw();
}
*sts = SEV__SUCCESS;
return 1;
}
void XttSevHist::pop()
{
curve->pop();
......
......@@ -73,6 +73,7 @@ class XttSevHist {
CoWow *wow;
long int time_low_old;
long int time_high_old;
bool sevhistobject; //!< Indicates that it is a SevHistObject
//! Constructor
XttSevHist( void *xn_parent_ctx,
......@@ -80,7 +81,7 @@ class XttSevHist {
pwr_tOid* xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts);
int *sts, bool sevhistobject);
//! Destructor
virtual ~XttSevHist();
......@@ -88,6 +89,7 @@ class XttSevHist {
//! Pop sevhist window.
void pop();
int get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to);
int get_objectdata( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to);
static void sevhist_close_cb( void *ctx);
static void sevhist_higher_res_cb( void *ctx);
......
......@@ -337,7 +337,7 @@ class XNav {
virtual XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts) {return 0;}
virtual XttSevHist *xttsevhist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts) {return 0;}
sevcli_tCtx scctx, pwr_tStatus *sts, bool sevhistobject=false) {return 0;}
virtual XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts) {return 0;}
virtual XAttOne *xattone_new( pwr_tAttrRef *objar, char *title, unsigned int priv,
pwr_tStatus *sts) {return 0;}
......
......@@ -3120,6 +3120,7 @@ static int xnav_open_func( void *client_data,
pwr_tAttrRef aref;
pwr_tAName aname;
char *s;
bool sevHistObjectFound = false;
// Command is "OPEN HISTORY"
......@@ -3175,11 +3176,14 @@ static int xnav_open_func( void *client_data,
if (EVEN(sts)) return sts;
switch ( classid) {
case pwr_cClass_SevHist:
break;
case pwr_cClass_SevHist:
break;
case pwr_cClass_SevHistObject:
sevHistObjectFound = true;
break;
case pwr_cClass_PlotGroup:
xnav->message('E', "Not yet implemented");
return XNAV__HOLDCOMMAND;
xnav->message('E', "Not yet implemented");
return XNAV__HOLDCOMMAND;
default:
xnav->message('E', "Error in object class");
return XNAV__HOLDCOMMAND;
......@@ -3187,25 +3191,49 @@ static int xnav_open_func( void *client_data,
if ( plotgroup_found)
break;
sts = gdh_ArefANameToAref( &sevhist_aref, "Attribute", &attr_aref);
if ( EVEN(sts)) return sts;
if( sevHistObjectFound ) {
sts = gdh_ArefANameToAref( &sevhist_aref, "Object", &attr_aref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &attr_aref, &aref, sizeof(aref));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &aref, aname, sizeof(aname), cdh_mNName);
if ( EVEN(sts)) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
sts = gdh_GetObjectInfoAttrref( &attr_aref, &aref, sizeof(aref));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &aref, aname, sizeof(aname), cdh_mNName);
if ( EVEN(sts)) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
}
s = strchr( aname, '.');
if ( !s) {
//It is a complete object
anamev[i][0] = '\0';
}
else {
strcpy( anamev[i], s+1);
}
oidv[i] = aref.Objid;
}
s = strchr( aname, '.');
if ( !s) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
else {
sts = gdh_ArefANameToAref( &sevhist_aref, "Attribute", &attr_aref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &attr_aref, &aref, sizeof(aref));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &aref, aname, sizeof(aname), cdh_mNName);
if ( EVEN(sts)) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
}
s = strchr( aname, '.');
if ( !s) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
}
strcpy( anamev[i], s+1);
oidv[i] = aref.Objid;
}
strcpy( anamev[i], s+1);
oidv[i] = aref.Objid;
// Get server and connect to server
sts = gdh_ArefANameToAref( &sevhist_aref, "ThreadObject", &attr_aref);
......@@ -3217,19 +3245,19 @@ static int xnav_open_func( void *client_data,
histthread_aref = cdh_ObjidToAref( histthread_oid);
sts = gdh_ArefANameToAref( &histthread_aref, "ServerNode", &attr_aref);
if ( EVEN(sts)) {
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
xnav->message('E', "Error in SevHist configuration");
return XNAV__HOLDCOMMAND;
}
sts = gdh_GetObjectInfoAttrref( &attr_aref, server_node, sizeof(server_node));
if ( EVEN(sts)) return sts;
if ( !xnav->scctx) {
sevcli_init( &sts, &xnav->scctx);
if ( EVEN(sts)) return sts;
sevcli_init( &sts, &xnav->scctx);
if ( EVEN(sts)) return sts;
}
sevcli_set_servernode( &sts, xnav->scctx, server_node);
if ( EVEN(sts)) return sts;
if ( EVEN(sts)) return sts;
}
oidv[i] = pwr_cNOid;
......@@ -3251,10 +3279,16 @@ static int xnav_open_func( void *client_data,
xnav->message('E', "Not yet implemented");
return XNAV__HOLDCOMMAND;
}
else if( sevHistObjectFound ) {
hist = xnav->xttsevhist_new( title_str, oidv, anamev, xnav->scctx, &sts, true);
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
}
}
else {
hist = xnav->xttsevhist_new( title_str, oidv, anamev, xnav->scctx, &sts);
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
hist->help_cb = xnav_sevhist_help_cb;
}
}
}
......
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