Commit e9f37cd6 authored by claes's avatar claes

Name changed to sev

parent c9ea7bd6
/*
* Proview $Id: xtt_sevhist_gtk.cpp,v 1.1 2008-09-18 14:52:58 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.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_sevhist_gtk.h"
#include "ge_curve_gtk.h"
XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
GtkWidget *parent_wid,
char *name,
GtkWidget **w,
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)
{
char title[250];
if ( EVEN(*sts))
// Error from XttSevHist
return;
*sts = XNAV__SUCCESS;
curve = new GeCurveGtk( this, parent_widget, title, NULL, gcd, 0);
curve->close_cb = sevhist_close_cb;
curve->help_cb = sevhist_help_cb;
curve->higher_res_cb = sevhist_higher_res_cb;
curve->lower_res_cb = sevhist_lower_res_cb;
wow = new CoWowGtk( parent_widget);
timerid = wow->timer_new();
timerid->add( 1000, sevhist_scan, this);
}
XttSevHistGtk::~XttSevHistGtk()
{
timerid->remove();
delete curve;
}
/*
* Proview $Id: xtt_sevhist_gtk.h,v 1.1 2008-09-18 14:52:58 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.
*/
#ifndef xtt_sevhist_gtk_h
#define xtt_sevhist_gtk_h
/* xtt_sevhist_gtk.h -- SevHist curves */
#ifndef xtt_sevhist_h
# include "xtt_sevhist.h"
#endif
class XttSevHistGtk : public XttSevHist {
public:
GtkWidget *parent_widget; //!< Parent widget.
XttSevHistGtk( void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
char *xn_name,
GtkWidget **w,
pwr_tOid *xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts);
~XttSevHistGtk();
};
#endif
/*
* Proview $Id: xtt_sevhist.cpp,v 1.1 2008-09-18 14:52:58 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.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_wow.h"
#include "rt_sev_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_sevhist.h"
#include "ge_curve.h"
XttSevHist::XttSevHist( void *parent_ctx,
char *name,
pwr_tOid *xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts) :
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])
{
strncpy( aname, xn_aname[0], sizeof(aname));
get_data( sts, pwr_cNTime, pwr_cNTime);
if ( EVEN(*sts)) return;
cdh_StrncpyCutOff( title, name, sizeof(title), 1);
}
XttSevHist::~XttSevHist()
{
}
int XttSevHist::get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
{
pwr_tTime *tbuf;
void *vbuf;
pwr_tDeltaTime trange;
sevcli_get_itemdata( sts, scctx, oid, aname, from, to, 1000, &tbuf, &vbuf,
&rows, &vtype, &vsize);
if ( EVEN(*sts))
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");
strcpy( gcd->name[1], aname);
gcd->data[1] = (double *) calloc( 1, 8 * rows);
for ( int i = 0; i < rows; i++) {
switch ( vtype) {
case pwr_eType_Int64:
gcd->data[1][i] = ((pwr_tInt32 *)vbuf)[i];
break;
case pwr_eType_Int32:
gcd->data[1][i] = ((pwr_tInt32 *)vbuf)[i];
break;
case pwr_eType_Int16:
gcd->data[1][i] = ((pwr_tInt32 *)vbuf)[i];
break;
case pwr_eType_Int8:
gcd->data[1][i] = ((pwr_tInt32 *)vbuf)[i];
break;
case pwr_eType_UInt64:
gcd->data[1][i] = ((pwr_tUInt32 *)vbuf)[i];
break;
case pwr_eType_UInt32:
gcd->data[1][i] = ((pwr_tUInt32 *)vbuf)[i];
break;
case pwr_eType_UInt16:
gcd->data[1][i] = ((pwr_tUInt32 *)vbuf)[i];
break;
case pwr_eType_UInt8:
gcd->data[1][i] = ((pwr_tUInt32 *)vbuf)[i];
break;
case pwr_eType_Float32:
gcd->data[1][i] = ((pwr_tFloat32 *)vbuf)[i];
break;
case pwr_eType_Float64:
gcd->data[1][i] = ((pwr_tFloat64 *)vbuf)[i];
break;
case pwr_eType_Boolean:
gcd->data[1][i] = ((pwr_tBoolean *)vbuf)[i];
break;
default:
*sts = SEV__CURVETYPE;
return 0;
}
}
free( tbuf);
free( vbuf);
gcd->axis_type[1] = curve_eAxis_y;
gcd->cols = 1 + 1;
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();
}
void XttSevHist::sevhist_close_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
if ( sevhist->close_cb)
(sevhist->close_cb)( sevhist->xnav, sevhist);
else
delete sevhist;
}
void XttSevHist::sevhist_higher_res_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
double ll_x, ll_y, ur_x, ur_y;
pwr_tTime t_low, t_high;
pwr_tStatus sts;
sevhist->curve->measure_window( &ll_x, &ll_y, &ur_x, &ur_y);
t_low.tv_sec = int( sevhist->gcd->min_value_axis[0] +
ll_x / 200 * (sevhist->gcd->max_value_axis[0] - sevhist->gcd->min_value_axis[0]));
t_low.tv_nsec = 0;
t_high.tv_sec = int( sevhist->gcd->min_value_axis[0] +
ur_x / 200 * (sevhist->gcd->max_value_axis[0] - sevhist->gcd->min_value_axis[0]));
t_high.tv_nsec = 0;
{
char s1[40], s2[40];
time_AtoAscii( &t_low, time_eFormat_NumDateAndTime, s1, sizeof(s1));
time_AtoAscii( &t_high, time_eFormat_NumDateAndTime, s2, sizeof(s2));
printf( "Low: %s, High: %s\n", s1, s2);
}
sevhist->get_data( &sts, t_low, t_high);
}
void XttSevHist::sevhist_lower_res_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
double ll_x, ll_y, ur_x, ur_y;
pwr_tTime t_low, t_high;
pwr_tStatus sts;
sevhist->curve->measure_window( &ll_x, &ll_y, &ur_x, &ur_y);
t_low.tv_sec = int( sevhist->gcd->min_value_axis[0] -
5 * (sevhist->gcd->max_value_axis[0] - sevhist->gcd->min_value_axis[0]));
t_low.tv_nsec = 0;
t_high.tv_sec = int( sevhist->gcd->max_value_axis[0] +
5 * (sevhist->gcd->max_value_axis[0] - sevhist->gcd->min_value_axis[0]));
t_high.tv_nsec = 0;
{
char s1[40], s2[40];
time_AtoAscii( &t_low, time_eFormat_NumDateAndTime, s1, sizeof(s1));
time_AtoAscii( &t_high, time_eFormat_NumDateAndTime, s2, sizeof(s2));
printf( "Low: %s, High: %s\n", s1, s2);
}
sevhist->get_data( &sts, t_low, t_high);
}
void XttSevHist::sevhist_help_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
if ( sevhist->help_cb)
(sevhist->help_cb)( sevhist->xnav, "sevhistwindow");
}
void XttSevHist::sevhist_scan( void *data)
{
XttSevHist *sevhist = (XttSevHist *) data;
if ( sevhist->timerid)
sevhist->timerid->add( 1000, sevhist_scan, sevhist);
}
/*
* Proview $Id: xtt_sevhist.h,v 1.1 2008-09-18 14:52:58 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund 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.
*/
#ifndef xtt_sevhist_h
#define xtt_sevhist_h
/* xtt_sevhist.h -- Sevhist curves */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef ge_curve_h
# include "ge_curve.h"
#endif
#ifndef rt_sevcli_h
# include "rt_sevcli.h"
#endif
/*! \file xtt_sevhist.h
\brief Contains the XttSevHist class. */
/*! \addtogroup Xtt */
/*@{*/
#define XTT_SEVHIST_MAX 20
class CoWow;
class CoWowTimer;
//! Window that displays sevhist curve in a SevHistCurve object.
/*!
A SevHistCurve references a data array for the time axis, and up to 10 data arrays
with stored data. These arrays are displayed in the XttSevHist window. The measurement
of these curves are triggered manually, on a digital signal, or on a level of one of
the attributes. When the measurement is completed this is signaled with the New attribute
in the SevHistCurve object. The XttSevHist window then has to read the new data and
reconfigure the curves. XttSevHist uses the GeCurve class to display the curves.
*/
class XttSevHist {
public:
void *xnav; //!< Pointer to parent XNav.
GeCurveData *gcd; //!< Curve data for GeCurve object.
GeCurve *curve; //!< Curve window.
int rows; //!< Max number of points in curves.
pwr_eType vtype;
unsigned int vsize;
CoWowTimer *timerid; //!< Time id for scan.
void (*close_cb)( void *, XttSevHist *); //!< Close callback to parent.
void (*help_cb)( void *, char *); //!< Open help window.
bool first_scan; //!< Indicates that this is the first scan.
char title[250]; //!< Window title
sevcli_tCtx scctx;
pwr_tOName aname;
pwr_tOid oid;
CoWow *wow;
//! Constructor
XttSevHist( void *xn_parent_ctx,
char *xn_name,
pwr_tOid* xn_oid,
pwr_tOName *xn_aname,
sevcli_tCtx xn_scctx,
int *sts);
//! Destructor
virtual ~XttSevHist();
//! Pop sevhist window.
void pop();
int get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to);
static void sevhist_close_cb( void *ctx);
static void sevhist_higher_res_cb( void *ctx);
static void sevhist_lower_res_cb( void *ctx);
static void sevhist_help_cb( void *ctx);
static void sevhist_scan( void *data);
};
/*@}*/
#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