Commit a6b7ac0d authored by claes's avatar claes

Trend History added

parent 52bf7040
/*
* Proview $Id: xtt_xnav_gtk.cpp,v 1.6 2008-06-24 08:09:56 claes Exp $
* Proview $Id: xtt_xnav_gtk.cpp,v 1.7 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -60,6 +60,7 @@ typedef void *Widget;
#include "xtt_ge_gtk.h"
#include "xtt_block_gtk.h"
#include "xtt_trend_gtk.h"
#include "xtt_dshist_gtk.h"
#include "xtt_fast_gtk.h"
#include "xtt_xattone_gtk.h"
#include "xtt_clog_gtk.h"
......@@ -217,6 +218,14 @@ XttTrend *XNavGtk::xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *
return new XttTrendGtk( this, parent_wid, name, &w, objar, plotgroup, sts);
}
XttDsHist *XNavGtk::xttdshist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts)
{
GtkWidget *w;
return new XttDsHistGtk( this, parent_wid, name, &w, oid, aname, scctx, sts);
}
XttFast *XNavGtk::xttfast_new( char *name, pwr_tAttrRef *objar, pwr_tStatus *sts)
{
GtkWidget *w;
......
/*
* Proview $Id: xtt_xnav_gtk.h,v 1.4 2008-06-24 08:09:56 claes Exp $
* Proview $Id: xtt_xnav_gtk.h,v 1.5 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -58,6 +58,8 @@ class XNavGtk : public XNav {
Op *op_new( char *opplace, pwr_tStatus *sts);
XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts);
XttDsHist *xttdshist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts);
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);
......
/*
* Proview $Id: xtt_c_object.cpp,v 1.18 2008-05-28 12:04:37 claes Exp $
* Proview $Id: xtt_c_object.cpp,v 1.19 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -398,7 +398,148 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
}
//
// Open trend
// Open History
//
static pwr_tStatus OpenHistory( xmenu_sMenuCall *ip)
{
pwr_tAName name;
char cmd[800];
int sts;
pwr_tObjid child;
pwr_tClassId classid;
int found;
pwr_sAttrRef defhist;
pwr_sAttrRef *objar;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsHist || classid == pwr_cClass_PlotGroup) {
sts = gdh_AttrrefToName( &ip->Pointed, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open hist
sprintf( cmd, "open history /name=%s /title=\"%s\"", name, name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
// Look for attribute DefHistory
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".DefHistory");
sts = gdh_GetObjectInfo( name, (void *)&defhist, sizeof(defhist));
if ( ODD(sts) && cdh_ObjidIsNotNull( defhist.Objid)) {
// Default XttGraph found
sts = gdh_GetAttrRefTid( &defhist, &classid);
if ( ODD(sts) &&
(classid == pwr_cClass_DsHist || classid == pwr_cClass_PlotGroup)) {
sts = gdh_AttrrefToName( &defhist, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open hist
sprintf( cmd, "open history /name=%s /title=\"%s\"", name, name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
}
// Look for DsHist as child
if ( !ip->Pointed.Flags.b.Object)
return 0;
found = 0;
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsHist) {
found = 1;
break;
}
sts = gdh_GetNextSibling( child, &child);
}
if ( !found)
return 1;
sts = gdh_ObjidToName( child, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
// Open history
sprintf( cmd, "open history /name=%s /title=\"%s\"", name, name);
((XNav *)ip->EditorContext)->command( cmd);
return 1;
}
// Open History filter
static pwr_tStatus OpenHistoryFilter( xmenu_sMenuCall *ip)
{
int sts;
pwr_tObjid child;
pwr_tClassId classid;
pwr_sAttrRef defhist;
pwr_tAName name;
pwr_sAttrRef *objar;
if (!ip->ItemList || cdh_ObjidIsNull( ip->ItemList[ip->ChosenItem].CurrentObject.Objid))
objar = &ip->Pointed;
else
objar = &ip->ItemList[ip->ChosenItem].CurrentObject;
sts = gdh_GetAttrRefTid( objar, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsHist || classid == pwr_cClass_PlotGroup) {
return XNAV__SUCCESS;
}
// Check if attribute DefHist exist
sts = gdh_AttrrefToName( objar, name, sizeof(name),
cdh_mName_volumeStrict);
if ( EVEN(sts)) return sts;
strcat( name, ".DefHist");
sts = gdh_GetObjectInfo( name, (void *)&defhist, sizeof(defhist));
if ( ODD(sts) && cdh_ObjidIsNotNull( defhist.Objid)) {
// Default XttGraph found
sts = gdh_GetAttrRefTid( &defhist, &classid);
if ( ODD(sts) &&
(classid == pwr_cClass_DsHist || classid == pwr_cClass_PlotGroup))
return XNAV__SUCCESS;
}
// Check if object has a DsHist as child
if ( !objar->Flags.b.Object)
return XNAV__INVISIBLE;
sts = gdh_GetChild( objar->Objid, &child);
while ( ODD(sts)) {
sts = gdh_GetObjectClass( child, &classid);
if ( EVEN(sts)) return sts;
if ( classid == pwr_cClass_DsHist)
return XNAV__SUCCESS;
sts = gdh_GetNextSibling( child, &child);
}
return XNAV__INVISIBLE;
}
//
// Open Fast
//
static pwr_tStatus OpenFast( xmenu_sMenuCall *ip)
{
......@@ -1779,6 +1920,8 @@ pwr_dExport pwr_BindXttMethods($Object) = {
pwr_BindXttMethod(OpenTraceFilter),
pwr_BindXttMethod(OpenTrend),
pwr_BindXttMethod(OpenTrendFilter),
pwr_BindXttMethod(OpenHistory),
pwr_BindXttMethod(OpenHistoryFilter),
pwr_BindXttMethod(OpenFast),
pwr_BindXttMethod(OpenFastFilter),
pwr_BindXttMethod(RtNavigator),
......
/*
* Proview $Id: xtt_xnav.cpp,v 1.40 2008-06-25 07:58:04 claes Exp $
* Proview $Id: xtt_xnav.cpp,v 1.41 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1059,7 +1059,7 @@ XNav::XNav(
menu_tree(NULL), ev(0), op(0), clog(0), closing_down(0),
base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), displayed(0),
current_logging_index(-1), search_last_found(0), search_compiled(0),
attach_audio(0), audio(0), op_close_button(xn_op_close_button), cologin(0)
attach_audio(0), audio(0), op_close_button(xn_op_close_button), cologin(0), scctx(0)
{
strcpy( name, xn_name);
strcpy( opplace_name, xn_opplace_name);
......
/*
* Proview $Id: xtt_xnav.h,v 1.24 2008-06-25 07:58:04 claes Exp $
* Proview $Id: xtt_xnav.h,v 1.25 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -78,6 +78,10 @@ extern "C" {
#include "pwr_privilege.h"
#endif
#ifndef rt_sevcli_h
#include "rt_sevcli.h"
#endif
#define xnav_cVersion "X3.0b"
#define XNAV_BROW_MAX 25
#define XNAV_LOGG_MAX 10
......@@ -87,6 +91,7 @@ class XAtt;
class XCrr;
class Block;
class XttTrend;
class XttDsHist;
class XttFast;
class XAttOne;
class GeCurve;
......@@ -314,6 +319,7 @@ class XNav {
int op_close_button;
static xmenu_sMenuCall *mcp;
CoLogin *cologin;
sevcli_tCtx scctx;
virtual void set_inputfocus() {}
virtual void pop() {}
......@@ -334,6 +340,8 @@ class XNav {
virtual Op *op_new( char *opplace, pwr_tStatus *sts) {return 0;}
virtual XttTrend *xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *plotgroup,
pwr_tStatus *sts) {return 0;}
virtual XttDsHist *xttdshist_new( char *name, pwr_tOid *oid, pwr_tOName *aname,
sevcli_tCtx scctx, pwr_tStatus *sts) {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;}
......
/*
* Proview $Id: xtt_xnav_command.cpp,v 1.37 2008-06-25 12:37:06 claes Exp $
* Proview $Id: xtt_xnav_command.cpp,v 1.38 2008-07-17 11:23:07 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -63,6 +63,7 @@
#include "glow_curvectx.h"
#include "ge_curve.h"
#include "xtt_trend.h"
#include "xtt_dshist.h"
#include "xtt_fast.h"
#include "xtt_xcrr.h"
#include "xtt_menu.h"
......@@ -136,6 +137,8 @@ static int xnav_op_get_alarm_info_cb( void *xnav, evlist_sAlarmInfo *info);
static void xnav_op_ack_last_cb( void *xnav, unsigned long type, unsigned long prio);
static void xnav_trend_close_cb( void *ctx, XttTrend *trend);
static void xnav_trend_help_cb( void *ctx, char *key);
static void xnav_dshist_close_cb( void *ctx, XttDsHist *trend);
static void xnav_dshist_help_cb( void *ctx, char *key);
static void xnav_fast_close_cb( void *ctx, XttFast *fast);
static void xnav_fast_help_cb( void *ctx, char *key);
static void xnav_xao_close_cb( void *ctx, XAttOne *xao);
......@@ -2893,6 +2896,167 @@ static int xnav_open_func( void *client_data,
trend->help_cb = xnav_trend_help_cb;
}
}
else if ( strncmp( arg1_str, "HISTORY", strlen( arg1_str)) == 0)
{
pwr_tAName name_str;
char *name_ptr;
pwr_tAName title_str;
pwr_tAttrRef attr_aref, dshist_aref, histthread_aref;
pwr_tOid histthread_oid;
char server_node[40];
pwr_tOid oidv[11];
pwr_tOName anamev[11];
int sts;
pwr_tAName name_array[10];
int i, names;
int plotgroup_found = 0;
pwr_sAttrRef plotgroup = pwr_cNAttrRef;
pwr_tClassId classid;
pwr_tObjid node_objid;
pwr_tAName hist_name;
XttDsHist *hist;
pwr_tAttrRef aref;
pwr_tAName aname;
char *s;
// Command is "OPEN HISTORY"
/* Get the name qualifier */
if ( ODD( dcli_get_qualifier( "dcli_arg2", name_str, sizeof(name_str)))) {
if ( name_str[0] != '/')
/* Assume that this is the namestring */
name_ptr = name_str;
else {
xnav->message('E', "Syntax error");
return XNAV__HOLDCOMMAND;
}
}
else {
if ( ODD( dcli_get_qualifier( "/NAME", name_str, sizeof(name_str))))
name_ptr = name_str;
else {
/* Get the selected object */
sts = xnav->get_current_aref( &dshist_aref, name_str,
sizeof( name_str), cdh_mName_path | cdh_mName_object | cdh_mName_attribute);
if ( EVEN(sts)) {
xnav->message('E', "Enter name or select an object");
return XNAV__SUCCESS;
}
name_ptr = name_str;
}
}
// The name string can contain several hists separated by ','
names = dcli_parse( name_str, ",", "",
(char *) name_array, sizeof( name_array)/sizeof( name_array[0]),
sizeof( name_array[0]), 0);
for ( i = 0; i < names; i++) {
if ( strncmp( name_array[i], "*-", 2) == 0) {
// Replace * by the node object
sts = gdh_GetNodeObject( 0, &node_objid);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToName( node_objid, hist_name, sizeof(hist_name),
cdh_mNName);
if ( EVEN(sts)) return sts;
strcat( hist_name, &name_array[i][1]);
}
else
strcpy( hist_name, name_array[i]);
sts = gdh_NameToAttrref( pwr_cNObjid, hist_name, &dshist_aref);
if (EVEN(sts)) {
xnav->message('E', "Object not found");
return XNAV__HOLDCOMMAND;
}
sts = gdh_GetAttrRefTid( &dshist_aref, &classid);
if (EVEN(sts)) return sts;
switch ( classid) {
case pwr_cClass_DsHist:
break;
case pwr_cClass_PlotGroup:
xnav->message('E', "Not yet implemented");
return XNAV__HOLDCOMMAND;
default:
xnav->message('E', "Error in object class");
return XNAV__HOLDCOMMAND;
}
if ( plotgroup_found)
break;
sts = gdh_ArefANameToAref( &dshist_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 DsHist configuration");
return XNAV__HOLDCOMMAND;
}
s = strchr( aname, '.');
if ( !s) {
xnav->message('E', "Error in DsHist configuration");
return XNAV__HOLDCOMMAND;
}
strcpy( anamev[i], s+1);
oidv[i] = aref.Objid;
// Get server and connect to server
sts = gdh_ArefANameToAref( &dshist_aref, "ThreadObject", &attr_aref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &attr_aref, &histthread_oid, sizeof(histthread_oid));
if ( EVEN(sts)) return sts;
histthread_aref = cdh_ObjidToAref( histthread_oid);
sts = gdh_ArefANameToAref( &histthread_aref, "ServerNode", &attr_aref);
if ( EVEN(sts)) {
xnav->message('E', "Error in DsHist 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_set_servernode( &sts, xnav->scctx, server_node);
if ( EVEN(sts)) return sts;
}
oidv[i] = pwr_cNOid;
if ( EVEN( dcli_get_qualifier( "/TITLE", title_str, sizeof(title_str)))) {
if ( plotgroup_found) {
pwr_tAName attr;
// Get title from plotgroup object
strcpy( attr, hist_name);
strcat( attr, ".Title");
sts = gdh_GetObjectInfo( attr, &title_str, sizeof(title_str));
if ( EVEN(sts)) return sts;
}
else
strcpy( title_str, "History");
}
if ( plotgroup_found) {
xnav->message('E', "Not yet implemented");
return XNAV__HOLDCOMMAND;
}
else {
hist = xnav->xttdshist_new( title_str, oidv, anamev, xnav->scctx, &sts);
if ( ODD(sts)) {
hist->help_cb = xnav_dshist_help_cb;
}
}
}
else if ( strncmp( arg1_str, "FAST", strlen( arg1_str)) == 0)
{
pwr_tAName name_str;
......@@ -3516,6 +3680,27 @@ static void xnav_trend_help_cb( void *ctx, char *key)
xnav->message( ' ', null_str);
}
static void xnav_dshist_close_cb( void *ctx, XttDsHist *hist)
{
XNav *xnav = (XNav *) ctx;
xnav->appl.remove( (void *)hist);
delete hist;
}
static void xnav_dshist_help_cb( void *ctx, char *key)
{
XNav *xnav = (XNav *) ctx;
int sts;
sts = CoXHelp::dhelp( key, "", navh_eHelpFile_Base, NULL, 0);
if ( EVEN(sts))
xnav->message( 'E', "Unable to find topic");
else
xnav->message( ' ', null_str);
}
static void xnav_fast_close_cb( void *ctx, XttFast *fast)
{
XNav *xnav = (XNav *) ctx;
......
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