Commit e1c401d3 authored by Claes Sjofors's avatar Claes Sjofors

Xtt sevhist, SevPlotGroup added, PlotGroup and SevPlotgoup in fastavail,...

Xtt sevhist, SevPlotGroup added, PlotGroup and SevPlotgoup in fastavail, preset of layout and timerange, command 'open plotgroup', split digital curves, time range and curve drawing bugfixes
parent dc6f77ae
......@@ -162,13 +162,3 @@ void ini_ProcTable (
}
}
void ini_LoadSev(
pwr_tStatus *sts,
ini_sContext *cp
)
{
pwr_tObjid oid;
*sts = gdh_CreateObject("pwrNode-sev", pwr_eClass_NodeHier, 0,
&oid, pwr_cNObjid, 0, pwr_cNObjid);
}
......@@ -41,6 +41,5 @@
#include "rt_ini_load.h"
void ini_ProcTable(pwr_tStatus*, ini_sContext*);
void ini_LoadSev(pwr_tStatus*, ini_sContext *cp);
#endif
......@@ -131,7 +131,6 @@ static pwr_tStatus start( ini_sContext *cp)
ini_CreateDb(&sts, cp);
ini_LoadNode(&sts, cp);
ini_BuildNode(&sts, cp);
ini_LoadSev(&sts, cp);
}
/* Logfile is always $pwrp_log/pwr.log from V4.0.0 and handled by Linux log rotation */
......
......@@ -837,7 +837,10 @@ void *sev_server::send_histdata_thread( void *arg)
endtime = net_NetTimeToTime( &rmsg->EndTime);
sev->m_db->get_item_idx(&sts, &item_idx, rmsg->Oid, rmsg->AName);
if ( EVEN(sts)) return (void *) 1;
if ( EVEN(sts)) {
qcom_Free( &lsts, rmsg);
return (void *) 1;
}
sev->m_db->get_values( &sts, rmsg->Oid, sev->m_db->m_items[item_idx].options,
sev->m_db->m_items[item_idx].deadband,
......
......@@ -55,6 +55,16 @@ pwr_tStatus sev_db::tree_update()
pwr_sClass_SevItem ritem;
char oname_array[20][pwr_cSizObjName + 1];
pwr_tObjName itemname;
char root[] = "pwrNode-sev";
// Check root object
sts = gdh_NameToObjid( root, &oid);
if ( EVEN(sts)) {
sts = gdh_CreateObject( root, pwr_eClass_NodeHier, 0,
&oid, pwr_cNObjid, 0, pwr_cNObjid);
if ( EVEN(sts)) return sts;
}
for ( unsigned int i = 0; i < m_items.size(); i++) {
if ( m_items[i].deleted)
......@@ -89,7 +99,7 @@ pwr_tStatus sev_db::tree_update()
(char *) oname_array, sizeof( oname_array)/sizeof( oname_array[0]),
sizeof( oname_array[0]), 0);
strcpy( hname, "pwrNode-sev");
strcpy( hname, root);
for ( int j = 0; j < num; j++) {
strcat( hname, "-");
strcat( hname, oname_array[j]);
......@@ -105,7 +115,7 @@ pwr_tStatus sev_db::tree_update()
new_item = 1;
}
}
sprintf( itemname, "%sItem%d", m_items[i].attrnum > 1 ? "O" : "", m_items[i].id);
sprintf( itemname, "%sItem", m_items[i].attrnum > 1 ? "O" : "");
strcat( hname, "-");
strcat( hname, itemname);
if ( !new_item)
......@@ -142,9 +152,11 @@ pwr_tStatus sev_db::tree_update()
ritem.AttrType = m_items[i].attr[0].type;
ritem.NoOfAttr = m_items[i].attrnum;
ritem.Oid = m_items[i].oid;
ritem.Id = m_items[i].id;
ritem.Options = m_items[i].options;
ritem.Deadband = m_items[i].deadband;
ritem.ScanTime = m_items[i].scantime;
ritem.StorageTime = m_items[i].storagetime;
strncpy( ritem.Description, m_items[i].description, sizeof(ritem.Description));
sts = gdh_SetObjectInfo( hname, &ritem, sizeof(ritem));
......
......@@ -1792,7 +1792,9 @@ void time_Period( time_ePeriod period, pwr_tTime *from, pwr_tTime *to, pwr_tTime
break;
case time_ePeriod_OneDay:
if ( !center) {
time_Period( time_ePeriod_LastHour, from, to, center, daybreak);
sts = time_GetTime( to);
*from = *to;
from->tv_sec -= ONEDAY;
return;
}
time_PeriodSec( from, to, center, ONEDAY);
......@@ -2282,4 +2284,4 @@ int time_PrintA( const char *format, pwr_tTime *ts)
time_AtoAscii( ts, time_eFormat_DateAndTime, timstr, sizeof(timstr));
return printf( format, timstr);
}
\ No newline at end of file
}
......@@ -529,7 +529,7 @@ int sevcli_get_objectitemdata( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid,
*sts = rmsg->Status;
if ( EVEN(*sts)) {
qcom_Free( sts, rmsg);
qcom_Free( &lsts, rmsg);
return 0;
}
if( rmsg->NumPoints == 0 ) {
......@@ -631,4 +631,4 @@ int sevcli_delete_item( pwr_tStatus *sts, sevcli_tCtx ctx, pwr_tOid oid, char *a
return 0;
qcom_Free( sts, rmsg);
return 1;
}
\ No newline at end of file
}
......@@ -145,9 +145,19 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Storage time.
!*/
Object StorageTime $Attribute 10
Body SysBody
Attr TypeRef = "pwrs:Type-$DeltaTime"
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! Objid.
!*/
Object Oid $Attribute 10
Object Oid $Attribute 11
Body SysBody
Attr TypeRef = "pwrs:Type-$Objid"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -156,9 +166,19 @@ SObject pwrb:Class
EndBody
EndObject
!/**
! Item identity.
!*/
Object Id $Attribute 12
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_STATE
EndBody
EndObject
!/**
! Receive counter.
!*/
Object ReceiveCount $Attribute 11
Object ReceiveCount $Attribute 13
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -168,7 +188,7 @@ SObject pwrb:Class
!/**
! Write counter.
!*/
Object WriteCount $Attribute 12
Object WriteCount $Attribute 14
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -178,7 +198,7 @@ SObject pwrb:Class
!/**
! Write quota in percentage.
!*/
Object WriteQuota $Attribute 13
Object WriteQuota $Attribute 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -188,7 +208,7 @@ SObject pwrb:Class
!/**
! Time for mean value.
!*/
Object MeanValueTime $Attribute 14
Object MeanValueTime $Attribute 16
Body SysBody
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -198,7 +218,7 @@ SObject pwrb:Class
!/**
! Mean value.
!*/
Object MeanValue $Attribute 15
Object MeanValue $Attribute 17
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -208,7 +228,7 @@ SObject pwrb:Class
!/**
! Standard deviation in last mean value interval.
!*/
Object StandardDeviation $Attribute 16
Object StandardDeviation $Attribute 18
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_NOEDIT
......@@ -218,7 +238,7 @@ SObject pwrb:Class
!/**
! Time for last write.
!*/
Object LastTime $Attribute 17
Object LastTime $Attribute 19
Body SysBody
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_NOEDIT
......
......@@ -37,7 +37,7 @@
!
SObject pwrb:Class
!/**
! @Version 2.0
! @Version 2.1
! @Group Operator,NodeConfiguration
! @Summary Configures a group of trend or fast graphs
! Configures a group of trend or fast graphs.
......@@ -234,6 +234,22 @@ SObject pwrb:Class
Attr TypeRef = "pwrb:Type-CurveLayoutMask"
EndBody
EndObject
!/**
! Curve window time range.
!*/
Object TimeRange $Attribute 17
Body SysBody
Attr TypeRef = "pwrb:Type-TimeRangeEnum"
EndBody
EndObject
!/**
! Button text in operator window.
!*/
Object ButtonText $Attribute 18
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
EndObject
EndObject
EndSObject
\ No newline at end of file
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2017 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_sevplotgroup.wb_load -- Defines the class SevPlotGroup.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Group Operator,NodeConfiguration
! @Summary Configures a group of history curves one a storage station.
! Configures a group of history curves on a storage station.
!
! The SevPlotGroup object brings together a number of
! history graphs into a group of graphs by the
! corresponding data storage objects
! being pointed out by YObjectName.
! Up to 20 graphs from storage objects can be displayed.
! The graphs brought together, in reality the measured quantities,
! may be sampled by different frequencies.
!
! @b Object graph
! @image orm_sevplotgroup_og.gif
!*/
Object SevPlotGroup $ClassDef 698
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "SevPlotGroup"
EndBody
!/**
! Optional description.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Window title.
!*/
Object Title $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
!/**
! Specifies the names of up to 20 sev item objects.
!*/
Object ObjectName $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String256"
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 20
EndBody
EndObject
!/**
! Curve window layout.
!*/
Object Layout $Attribute 4
Body SysBody
Attr TypeRef = "pwrb:Type-CurveLayoutMask"
EndBody
EndObject
!/**
! Curve window time range.
!*/
Object TimeRange $Attribute 5
Body SysBody
Attr TypeRef = "pwrb:Type-TimeRangeEnum"
EndBody
EndObject
!/**
! Button text in operator window.
!*/
Object ButtonText $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$String40"
EndBody
EndObject
EndObject
EndObject
EndSObject
\ No newline at end of file
......@@ -66,5 +66,75 @@ SObject pwrb:Type
Attr Value = 1
EndBody
EndObject
!/**
! Curve type line.
!*/
Object CurveTypeLine $Bit
Body SysBody
Attr PgmName = "CurveTypeLine"
Attr Text = "CurveTypeLine"
Attr Value = 2
EndBody
EndObject
!/**
! Curve type points.
!*/
Object CurveTypePoints $Bit
Body SysBody
Attr PgmName = "CurveTypePoints"
Attr Text = "CurveTypePoints"
Attr Value = 4
EndBody
EndObject
!/**
! Curve type line and points.
!*/
Object CurveTypeLinePoints $Bit
Body SysBody
Attr PgmName = "CurveTypeLinePoints"
Attr Text = "CurveTypeLinePoints"
Attr Value = 8
EndBody
EndObject
!/**
! Curve type square.
!*/
Object CurveTypeSquare $Bit
Body SysBody
Attr PgmName = "CurveTypeSquare"
Attr Text = "CurveTypeSquare"
Attr Value = 16
EndBody
EndObject
!/**
! Fill curve.
!*/
Object FillCurve $Bit
Body SysBody
Attr PgmName = "FillCurve"
Attr Text = "FillCurve"
Attr Value = 32
EndBody
EndObject
!/**
! Split digital curves.
!*/
Object SplitDigital $Bit
Body SysBody
Attr PgmName = "SplitDigital"
Attr Text = "SplitDigital"
Attr Value = 64
EndBody
EndObject
!/**
! Light digram background.
!*/
Object LightBackground $Bit
Body SysBody
Attr PgmName = "LightBackground"
Attr Text = "LightBackground"
Attr Value = 128
EndBody
EndObject
EndObject
EndSObject
\ No newline at end of file
EndSObject
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2017 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_timerangeenum.wb_load -- Defines the enum type TimeRangeEnum
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Time range for curve.
!*/
Object TimeRangeEnum $TypeDef 88
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "TimeRangeEnum"
EndBody
!/**
! Default range.
!*/
Object Default $Value
Body SysBody
Attr PgmName = "Default"
Attr Text = "Default"
Attr Value = 0
EndBody
EndObject
!/**
! Time range second.
!*/
Object Second $Value
Body SysBody
Attr PgmName = "Second"
Attr Text = "Second"
Attr Value = 1
EndBody
EndObject
!/**
! Time range 10 seconds.
!*/
Object 10Seconds $Value
Body SysBody
Attr PgmName = "10Seconds"
Attr Text = "10Seconds"
Attr Value = 2
EndBody
EndObject
!/**
! Time range minute.
!*/
Object Minute $Value
Body SysBody
Attr PgmName = "Minute"
Attr Text = "Minute"
Attr Value = 3
EndBody
EndObject
!/**
! Time range 10 minutes.
!*/
Object 10Minutes $Value
Body SysBody
Attr PgmName = "10Minutes"
Attr Text = "10Minutes"
Attr Value = 4
EndBody
EndObject
!/**
! Time range hour.
!*/
Object Hour $Value
Body SysBody
Attr PgmName = "Hour"
Attr Text = "Hour"
Attr Value = 5
EndBody
EndObject
!/**
! Time range day.
!*/
Object Day $Value
Body SysBody
Attr PgmName = "Day"
Attr Text = "Day"
Attr Value = 6
EndBody
EndObject
!/**
! Time range week.
!*/
Object Week $Value
Body SysBody
Attr PgmName = "Week"
Attr Text = "Week"
Attr Value = 7
EndBody
EndObject
!/**
! Time range month.
!*/
Object Month $Value
Body SysBody
Attr PgmName = "Month"
Attr Text = "Month"
Attr Value = 8
EndBody
EndObject
!/**
! Time range Year.
!*/
Object Year $Value
Body SysBody
Attr PgmName = "Year"
Attr Text = "Year"
Attr Value = 9
EndBody
EndObject
EndObject
EndSObject
\ No newline at end of file
......@@ -531,7 +531,7 @@ static void wnav_message_dialog_read( GtkWidget *w, gpointer data)
void WNavGtk::message_dialog( char *title, char *text)
{
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(toplevel),
GtkWidget *dialog = gtk_message_dialog_new( GTK_WINDOW(gtk_widget_get_toplevel(toplevel)),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK, text);
......@@ -691,4 +691,4 @@ int WNavGtk::prompt_dialog( char *title, char *text, char **value)
return 0;
}
return 0;
}
\ No newline at end of file
}
......@@ -395,11 +395,13 @@ void Xtt::activate_opengraph()
case pwr_cClass_SevItemInt:
case pwr_cClass_SevItemFloat:
case pwr_cClass_SevItemBoolean:
case pwr_cClass_SevPlotGroup:
// Open history
sprintf( cmd, "open history /name=%s /title=\"%s\"", vname, name);
xnav->command( cmd);
return;
case pwr_cClass_PlotGroup: {
#if 0
pwr_tAName aname;
pwr_tAttrRef yo;
......@@ -434,6 +436,10 @@ void Xtt::activate_opengraph()
return;
}
return;
#endif
sprintf( cmd, "open plotgroup /name=%s /title=\"%s\"", name, name);
xnav->command( cmd);
return;
}
default:
sprintf( cmd, "open graph /class/inst=%s/name=\"%s\"", vname, name);
......
......@@ -349,6 +349,13 @@ void GeCurveGtk::activate_curvetype_square( GtkWidget *w, gpointer data)
curve->activate_curvetype( glow_eCurveType_Square);
}
void GeCurveGtk::activate_digsplit( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
curve->activate_digsplit();
}
void GeCurveGtk::activate_xlimits( GtkWidget *w, gpointer data)
{
GeCurve *curve = (GeCurve *)data;
......@@ -571,6 +578,8 @@ void GeCurveGtk::enable( unsigned int mask)
g_object_set( tools_curvetype_square, "visible", TRUE, NULL);
if ( mask & curve_mEnable_FillCurve)
g_object_set( tools_curve_fill, "visible", TRUE, NULL);
if ( mask & curve_mEnable_DigitalSplit)
g_object_set( tools_curve_digsplit, "visible", TRUE, NULL);
layout_mask = mask;
}
......@@ -589,6 +598,7 @@ void GeCurveGtk::setup( unsigned int mask)
g_object_set( tools_curvetype_linepoints, "visible", mask & curve_mEnable_CurveType ? TRUE : FALSE, NULL);
g_object_set( tools_curvetype_square, "visible", mask & curve_mEnable_CurveType ? TRUE : FALSE, NULL);
g_object_set( tools_curve_fill, "visible", mask & curve_mEnable_CurveType ? TRUE : FALSE, NULL);
g_object_set( tools_curve_digsplit, "visible", mask & curve_mEnable_DigitalSplit ? TRUE : FALSE, NULL);
layout_mask = mask;
}
......@@ -1079,6 +1089,14 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
g_object_set( tools_curve_fill, "can-focus", FALSE, NULL);
gtk_toolbar_append_widget( tools, tools_curve_fill, CoWowGtk::translate_utf8("Filled curves"), "");
tools_curve_digsplit = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_curve_digsplit.png");
gtk_container_add( GTK_CONTAINER(tools_curve_digsplit),
gtk_image_new_from_file( fname));
g_signal_connect(tools_curve_digsplit, "clicked", G_CALLBACK(activate_digsplit), this);
g_object_set( tools_curve_digsplit, "can-focus", FALSE, NULL);
gtk_toolbar_append_widget( tools, tools_curve_digsplit, CoWowGtk::translate_utf8("Split digital curves"), "");
tools_snapshot = gtk_button_new();
dcli_translate_filename( fname, "$pwr_exe/xtt_snapshot.png");
gtk_container_add( GTK_CONTAINER(tools_snapshot),
......@@ -1252,6 +1270,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
g_object_set( tools_curvetype_linepoints, "visible", FALSE, NULL);
g_object_set( tools_curvetype_square, "visible", FALSE, NULL);
g_object_set( tools_curve_fill, "visible", FALSE, NULL);
g_object_set( tools_curve_digsplit, "visible", FALSE, NULL);
wow = new CoWowGtk( toplevel);
......
......@@ -80,6 +80,7 @@ class GeCurveGtk : public GeCurve {
GtkWidget *tools_curvetype_linepoints;
GtkWidget *tools_curvetype_square;
GtkWidget *tools_curve_fill;
GtkWidget *tools_curve_digsplit;
GtkWidget *export_widget;
GtkWidget *export_attrcombo_widget;
GtkWidget *export_fromtime_widget;
......@@ -147,6 +148,7 @@ class GeCurveGtk : public GeCurve {
static void activate_curvetype_points( GtkWidget *w, gpointer data);
static void activate_curvetype_linepoints( GtkWidget *w, gpointer data);
static void activate_curvetype_square( GtkWidget *w, gpointer data);
static void activate_digsplit( GtkWidget *w, gpointer data);
static void activate_xlimits( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_minmax_ok( GtkWidget *w, gpointer data);
......
......@@ -192,6 +192,15 @@ void GeCurve::activate_curvetype( int type)
grow_NavRedraw( growcurve_ctx);
}
void GeCurve::activate_digsplit()
{
int split;
grow_GetCurveDigitalSplit( curve_object, &split);
grow_SetCurveDigitalSplit( curve_object, !split);
configure_curves();
grow_NavRedraw( growcurve_ctx);
}
void GeCurve::activate_help()
{
if ( help_cb)
......@@ -211,7 +220,7 @@ void GeCurve::activate_period( time_ePeriod period)
double ll_x, ll_y, ur_x, ur_y;
int low, high;
if ( center_from_window) {
if ( center_from_window && !(cd->x_max_value_axis[0] == 0 && cd->x_max_value_axis[0] == 0)) {
// Get the center time
measure_window( &ll_x, &ll_y, &ur_x, &ur_y);
......@@ -221,7 +230,7 @@ void GeCurve::activate_period( time_ePeriod period)
ur_x / 200 * (cd->x_max_value_axis[0] - cd->x_min_value_axis[0]));
center_from_window = 0;
}
}
else {
// Get period from current time intervall
pwr_tStatus sts;
......@@ -328,6 +337,12 @@ void GeCurve::update_times_markers()
void GeCurve::activate_minmax_ok( double min_value, double max_value)
{
if ( min_value > max_value) {
double tmp = max_value;
max_value = min_value;
min_value = tmp;
}
int i = minmax_idx;
if ( minmax_idx < cd->cols)
cd->scale( cd->y_axis_type[i], cd->y_value_type[i],
......@@ -366,6 +381,12 @@ void GeCurve::activate_minmax_save( double min_value, double max_value)
FILE *fp;
int i = minmax_idx;
if ( min_value > max_value) {
double tmp = max_value;
max_value = min_value;
min_value = tmp;
}
fp = fopen( minmax_filename(cd->y_name[i]), "w");
if ( !fp)
return;
......@@ -745,6 +766,23 @@ int GeCurve::init_growcurve_cb( GlowCtx *fctx, void *client_data)
200, 0, 200, 0);
// grow_SetMode( curve->growcurve_ctx, grow_eMode_Edit);
if ( curve->options & curve_mOptions_CurveTypeLinePoints)
grow_SetCurveType( curve->curve_object, glow_eCurveType_LinePoints);
else if ( curve->options & curve_mOptions_CurveTypePoints)
grow_SetCurveType( curve->curve_object, glow_eCurveType_Points);
else if ( curve->options & curve_mOptions_CurveTypeSquare)
grow_SetCurveType( curve->curve_object, glow_eCurveType_Square);
if ( curve->options & curve_mOptions_FillCurve)
grow_SetTrendFillCurve( curve->curve_object, 1);
if ( curve->options & curve_mOptions_SplitDigital)
grow_SetCurveDigitalSplit( curve->curve_object, 1);
if ( curve->options & curve_mOptions_LightBackground) {
curve->curve_color = curve->background_bright;
curve->curve_border = curve->border_bright;
grow_SetObjectFillColor( curve->curve_object, curve->curve_color);
grow_SetObjectBorderColor( curve->curve_object, curve->curve_border);
curve->cd->select_color( curve->curve_color == curve->background_dark);
}
curve->configure_curves();
if ( curve->deferred_configure_axes)
curve->configure_axes();
......@@ -1397,7 +1435,7 @@ int GeCurve::configure_curves()
gcd.color[idx] = cd->color[i];
gcd.fillcolor[idx] = cd->fillcolor[i];
gcd.curve_type[idx] = glow_eCurveType_Inherit;
if ( cd->y_value_type[i] == pwr_eType_Boolean)
if ( cd->y_orig_type[i] == pwr_eType_Boolean)
gcd.curve_type[idx] = glow_eCurveType_DigSquare;
else
gcd.curve_type[idx] = glow_eCurveType_Inherit;
......@@ -1536,7 +1574,7 @@ void GeCurve::redraw()
grow_Redraw( growcurve_ctx);
}
void GeCurve::points_added( unsigned int no_of_points)
void GeCurve::points_added( unsigned int *no_of_points)
{
int i, idx;
glow_sCurveData gcd;
......@@ -2030,6 +2068,9 @@ void GeCurveData::select_color( bool dark_bg)
}
}
#define T1 0.99999
#define T0 0.00001
void GeCurveData::scale( int axis_type, int value_type,
double min_value, double max_value,
double *min_value_axis, double *max_value_axis,
......@@ -2177,66 +2218,84 @@ void GeCurveData::scale( int axis_type, int value_type,
min_zero = 0;
max_zero = 0;
// Power for max_value
if ( (max_value < DBL_EPSILON && !not_zero) ||
fabs(max_value) < DBL_EPSILON) {
maxval = 0;
max_lines = 0;
max_n = 0;
max_zero = 1;
}
else {
value = fabs(max_value);
if ( fabs(max_value - min_value) < max(fabs(max_value), fabs(min_value)) / 2) {
value = fabs(max_value - min_value);
n = 0;
if ( value >= 1) {
while ( value / 10 > 1) {
value = value / 10;
n++;
}
max_n = n;
max_n = min_n = n;
}
else {
while ( value * 10 < 10) {
value = value * 10;
n++;
}
max_n = -n;
max_n = min_n = -n;
}
}
// Power for min_value
if ( (min_value > -DBL_EPSILON && !not_zero) ||
fabs(min_value) < DBL_EPSILON) {
minval = 0;
min_lines = 0;
min_n = 0;
min_zero = 1;
}
else {
value = fabs(min_value);
n = 0;
if ( value >= 1) {
while ( value / 10 > 1) {
value = value / 10;
n++;
}
min_n = n;
}
else {
while ( value * 10 < 10) {
value = value * 10;
n++;
}
min_n = -n;
}
// Power for max_value
if ( (max_value < DBL_EPSILON && !not_zero) ||
fabs(max_value) < DBL_EPSILON) {
maxval = 0;
max_lines = 0;
max_n = 0;
max_zero = 1;
}
else {
value = fabs(max_value);
n = 0;
if ( value >= 1) {
while ( value / 10 > 1) {
value = value / 10;
n++;
}
max_n = n;
}
else {
while ( value * 10 < 10) {
value = value * 10;
n++;
}
max_n = -n;
}
}
// Power for min_value
if ( (min_value > -DBL_EPSILON && !not_zero) ||
fabs(min_value) < DBL_EPSILON) {
minval = 0;
min_lines = 0;
min_n = 0;
min_zero = 1;
}
else {
value = fabs(min_value);
n = 0;
if ( value >= 1) {
while ( value / 10 > 1) {
value = value / 10;
n++;
}
min_n = n;
}
else {
while ( value * 10 < 10) {
value = value * 10;
n++;
}
min_n = -n;
}
}
}
if ( min_zero) {
// Use power for max_value
i_value = int( max_value * pow(10, -max_n)) + 1;
if ( fabs(double(i_value-1) - max_value * pow(10, -n)) < 1e-10)
i_value--;
i_value = int( max_value * pow(10, -max_n) + (max_value > 0 ? T1 : -T0));
if ( ODD(i_value) && i_value != 5 && !allow_odd)
i_value += 1;
maxval = double(i_value) * pow( 10, max_n);
......@@ -2246,9 +2305,7 @@ void GeCurveData::scale( int axis_type, int value_type,
else if ( max_zero) {
// Use power for min_value
i_value = int( min_value * pow(10, -min_n)) + ((min_value < 0) ? -1 : 1);
if ( fabs(double(i_value+1) - min_value * pow(10, -n)) < 1e-10)
i_value++;
i_value = int( min_value * pow(10, -min_n) + (min_value > 0 ? T0 : -T1));
if ( ODD(i_value) && i_value != 5 && !allow_odd)
i_value += 1;
minval = double(i_value) * pow( 10, min_n);
......@@ -2262,25 +2319,13 @@ void GeCurveData::scale( int axis_type, int value_type,
else
n = min_n;
if ( max_value > 0) {
i_value = int( max_value * pow(10, -n)) + 1;
if ( fabs(double(i_value-1) - max_value * pow(10, -n)) < 1e-10)
i_value--;
}
else
i_value = int( max_value * pow(10, -n));
i_value = int( max_value * pow(10, -n) + (max_value > 0 ? T1 : -T0));
if ( ODD(i_value) && i_value != 5 && !allow_odd)
i_value += 1;
maxval = double(i_value) * pow( 10, n);
max_lines = i_value;
if ( min_value < 0) {
i_value = int( min_value * pow(10, -n)) - 1;
if ( fabs(double(i_value+1) - min_value * pow(10, -n)) < 1e-10)
i_value++;
}
else
i_value = int( min_value * pow(10, -n));
i_value = int( min_value * pow(10, -n) + (min_value > 0 ? T0 : -T1));
if ( ODD(i_value) && i_value != 5 && !allow_odd)
i_value -= 1;
minval = double(i_value) * pow( 10, n);
......
......@@ -53,13 +53,26 @@
#define ge_ePeriod_Markers ((time_ePeriod)1000)
typedef enum {
curve_mOptions_FullScreen = 1 << 0,
curve_mOptions_Maximize = 1 << 1,
curve_mOptions_FullMaximize = 1 << 2,
curve_mOptions_Iconify = 1 << 3,
curve_mOptions_Invisible = 1 << 4,
curve_mOptions_Embedded = 1 << 5,
curve_mOptions_ShowDescrFirst = 1 << 6
curve_mOptions_FullScreen = 1 << 0,
curve_mOptions_Maximize = 1 << 1,
curve_mOptions_FullMaximize = 1 << 2,
curve_mOptions_Iconify = 1 << 3,
curve_mOptions_Invisible = 1 << 4,
curve_mOptions_Embedded = 1 << 5,
curve_mOptions_ShowDescrFirst = 1 << 6,
curve_mOptions_CurveTypeLine = 1 << 7,
curve_mOptions_CurveTypePoints = 1 << 8,
curve_mOptions_CurveTypeLinePoints = 1 << 9,
curve_mOptions_CurveTypeSquare = 1 << 10,
curve_mOptions_FillCurve = 1 << 11,
curve_mOptions_SplitDigital = 1 << 12,
curve_mOptions_LightBackground = 1 << 13,
curve_mOptions_TimeRangeMinute = 1 << 14,
curve_mOptions_TimeRange10Minutes = 1 << 15,
curve_mOptions_TimeRangeHour = 1 << 16,
curve_mOptions_TimeRangeDay = 1 << 17,
curve_mOptions_TimeRangeWeek = 1 << 18,
curve_mOptions_TimeRangeMonth = 1 << 19
} curve_mOptions;
typedef enum {
......@@ -73,7 +86,8 @@ typedef enum {
curve_mEnable_ExportTime = 1 << 7,
curve_mEnable_CurveType = 1 << 8,
curve_mEnable_CurveTypeSquare = 1 << 9,
curve_mEnable_FillCurve = 1 << 10
curve_mEnable_FillCurve = 1 << 10,
curve_mEnable_DigitalSplit = 1 << 11
} curve_mEnable;
typedef enum {
......@@ -135,6 +149,7 @@ class GeCurveData {
double y_axis_width[CURVE_MAX_COLS];
char y_format[CURVE_MAX_COLS][20];
char x_format[CURVE_MAX_COLS][20];
pwr_eType y_orig_type[CURVE_MAX_COLS];
int x_reverse;
curve_eTimeFormat time_format;
......@@ -250,7 +265,7 @@ class GeCurve {
int configure_curves();
int configure_axes();
int config_names();
void points_added( unsigned int no_of_points);
void points_added( unsigned int *no_of_points);
void set_title( char *str);
void set_time( pwr_tTime time);
void print( char *filename);
......@@ -267,6 +282,7 @@ class GeCurve {
void activate_background();
void activate_filledcurves( int set);
void activate_curvetype( int type);
void activate_digsplit();
void activate_help();
void activate_period( time_ePeriod);
void activate_period_markers();
......
......@@ -4971,6 +4971,16 @@ void grow_SetCurveType( grow_tObject object, glow_eCurveType type)
((GrowCurve *)object)->set_type( type);
}
void grow_SetCurveDigitalSplit( grow_tObject object, int set)
{
((GrowCurve *)object)->set_digital_split( set);
}
void grow_GetCurveDigitalSplit( grow_tObject object, int *set)
{
((GrowCurve *)object)->get_digital_split( set);
}
void grow_SetAxisConf( grow_tObject object, double max_val, double min_val,
int no_of_lines, int long_quot, int value_quot, double rot, const char *format)
{
......@@ -5245,7 +5255,7 @@ void grow_CurveConfigure( grow_tObject object, glow_sCurveData *data)
((GrowCurve *)object)->configure_curves( data);
}
void grow_CurveAddPoints( grow_tObject object, glow_sCurveData *data, unsigned int no_of_points)
void grow_CurveAddPoints( grow_tObject object, glow_sCurveData *data, unsigned int *no_of_points)
{
((GrowCurve *)object)->add_points( data, no_of_points);
}
......
......@@ -2428,6 +2428,8 @@ extern "C" {
int horiz_lines);
void grow_SetCurveType( grow_tObject object, glow_eCurveType type);
void grow_SetCurveDigitalSplit( grow_tObject object, int set);
void grow_GetCurveDigitalSplit( grow_tObject object, int *set);
//! Set configuration values for an axis object.
/*!
......@@ -2815,7 +2817,7 @@ extern "C" {
Add the new value first in all the curves, and shift the other values one step forward.
*/
void grow_CurveAddPoints( grow_tObject object, glow_sCurveData *data, unsigned int no_of_points);
void grow_CurveAddPoints( grow_tObject object, glow_sCurveData *data, unsigned int *no_of_points);
//! Get the group the specified object is a member of.
/*!
......
......@@ -53,7 +53,8 @@ GrowCurve::GrowCurve( GrowCtx *glow_ctx, const char *name, glow_sCurveData *data
int fill_rect, int display_border,
glow_eDrawType fill_d_type, int nodraw) :
GrowTrend(glow_ctx,name,x,y,w,h,border_d_type,line_w,
display_lev, fill_rect, display_border, fill_d_type, 1), type(glow_eCurveType_Line)
display_lev, fill_rect, display_border, fill_d_type, 1), type(glow_eCurveType_Line),
split_digsquare(0)
{
if ( data)
configure_curves( data);
......@@ -77,6 +78,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
double y_value, x_value, prev_y_value;
glow_eCurveType curve_type;
int pix = 0;
int dix = 0;
// Remove old curves
ctx->nodraw++;
......@@ -131,7 +133,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
// y_value = MAX( ll.y, MIN( y_value, ur.y));
point_p->y = y_value;
point_p->x = x_value;
......@@ -170,7 +172,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
y_value = ur.y - (data->y_data[idx][i-1] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
// y_value = MAX( ll.y, MIN( y_value, ur.y));
point_p->y = y_value;
point_p->x = x_value;
......@@ -306,9 +308,14 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
points += 3;
pointarray = (glow_sPoint *) calloc( points, sizeof(glow_sPoint));
double y1 = ur.y - (1 - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y1 = MAX( ll.y, MIN( y1, ur.y));
double yoffs;
if ( split_digsquare)
yoffs = (dix % 10) * ( ur.y - ll.y) / 10;
else
yoffs = 0;
dix++;
double y0 = ur.y - yoffs;
double y1 = y0 - (ur.y - ll.y) * 0.08;
if ( !fill_curve) {
pix = 0;
......@@ -322,16 +329,16 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
x_value = MAX( ll.x, MIN( x_value, ur.x));
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
if ( data->y_data[idx][i])
y_value = y1;
else
y_value = y0;
if ( i == 0) {
if ( data->y_data[idx][0] == 1) {
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ll.x;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = x_value;
}
else {
......@@ -365,22 +372,18 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
x_value = MAX( ll.x, MIN( x_value, ur.x));
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
if ( data->y_data[idx][i])
y_value = y1;
else
y_value = y0;
if ( i == 0) {
if ( data->y_data[idx][0] == 1) {
pointarray[pix].y = ur.y;
pointarray[pix++].x = x_value;
pointarray[pix].y = ur.y;
pointarray[pix++].x = x_value;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = x_value;
}
else {
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ll.x;
pointarray[pix].y = y1;
pointarray[pix++].x = ll.x;
......@@ -401,7 +404,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
if ( data->y_data[idx][data->rows[0]-1] != 0) {
pointarray[pix].y = y1;
pointarray[pix++].x = ur.x;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ur.x;
}
points = pix;
......@@ -475,7 +478,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = max( ll.y, min( y_value, ur.y));
// y_value = max( ll.y, min( y_value, ur.y));
pointarray[i].y = y_value;
pointarray[i].x = x_value;
......@@ -495,7 +498,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = max( ll.y, min( y_value, ur.y));
// y_value = max( ll.y, min( y_value, ur.y));
if ( i == 0) {
pointarray[0].y = ur.y;
......@@ -599,11 +602,15 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
pointarray = (glow_sPoint *) calloc( points, sizeof(glow_sPoint));
double y1 = ur.y - (1 - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
double yoffs;
if ( split_digsquare)
yoffs = (dix % 10) * ( ur.y - ll.y) / 10;
else
yoffs = 0;
dix++;
double y0 = ur.y - yoffs;
double y1 = y0 - (ur.y - ll.y) * 0.08;
y1 = MAX( ll.y, MIN( y1, ur.y));
if ( !fill_curve) {
pix = 0;
for ( i = 0; i < data->rows[idx]; i++) {
......@@ -616,16 +623,16 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
x_value = MAX( ll.x, MIN( x_value, ur.x));
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
if ( data->y_data[idx][i])
y_value = y1;
else
y_value = y0;
if ( i == 0) {
if ( data->y_data[idx][0] == 1) {
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ll.x;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = x_value;
}
else {
......@@ -660,22 +667,18 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
x_value = MAX( ll.x, MIN( x_value, ur.x));
y_value = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
if ( data->y_data[idx][i])
y_value = y1;
else
y_value = y0;
if ( i == 0) {
if ( data->y_data[idx][0] == 1) {
pointarray[pix].y = ur.y;
pointarray[pix++].x = x_value;
pointarray[pix].y = ur.y;
pointarray[pix++].x = x_value;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = x_value;
}
else {
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ll.x;
pointarray[pix].y = y1;
pointarray[pix++].x = ll.x;
......@@ -696,7 +699,7 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
if ( data->y_data[idx][data->rows[idx]-1] != 0) {
pointarray[pix].y = y1;
pointarray[pix++].x = ur.x;
pointarray[pix].y = ur.y;
pointarray[pix].y = y0;
pointarray[pix++].x = ur.x;
}
printf( "Points %d pix %d\n", points, pix);
......@@ -731,22 +734,25 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
}
void GrowCurve::add_points( glow_sCurveData *data, unsigned int no_of_points)
void GrowCurve::add_points( glow_sCurveData *data, unsigned int *no_of_points)
{
if ( data->type == glow_eCurveDataType_CommonX) {
// Remove old curves
ctx->nodraw++;
if ( no_of_points == 1) {
double y_value;
int idx;
for ( idx = 0; idx < curve_cnt; idx++) {
y_value = ur.y - (data->y_data[idx][0] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
for ( int idx = 0; idx < curve_cnt; idx++) {
if ( no_of_points[0] == 1) {
double y_value;
y_value = MAX( ll.y, MIN( y_value, ur.y));
if ( no_of_points[idx] == 0) {
// Add old value
y_value = ((GlowPoint *)curve[idx]->a_points[0])->y;
}
else {
y_value = ur.y - (data->y_data[idx][0] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_value = MAX( ll.y, MIN( y_value, ur.y));
}
if ( !fill)
erase( &ctx->mw);
......@@ -755,28 +761,40 @@ void GrowCurve::add_points( glow_sCurveData *data, unsigned int no_of_points)
else
curve[idx]->add_and_shift_y_value_filled( y_value);
}
}
else {
double *y_values;
int i, idx;
else {
double *y_values;
int i;
unsigned int k;
for ( idx = 0; idx < curve_cnt; idx++) {
y_values = (double *)calloc( 1, no_of_points * sizeof(double));
y_values = (double *)calloc( 1, no_of_points[0] * sizeof(double));
for ( i = 0; i < (int)no_of_points; i++) {
y_values[i] = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
if ( no_of_points[idx] == no_of_points[0]) {
for ( i = 0; i < (int)no_of_points[0]; i++) {
y_values[i] = ur.y - (data->y_data[idx][i] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_values[i] = MAX( ll.y, MIN( y_values[i], ur.y));
y_values[i] = MAX( ll.y, MIN( y_values[i], ur.y));
}
}
else {
for ( i = 0; i < (int)no_of_points[0]; i++) {
k = (float) i * no_of_points[idx]/no_of_points[0] + 0.49;
if ( k > no_of_points[0])
k = no_of_points[0];
y_values[i] = ur.y - (data->y_data[idx][k] - y_min_value[idx]) /
(y_max_value[idx] - y_min_value[idx]) * (ur.y - ll.y);
y_values[i] = MAX( ll.y, MIN( y_values[i], ur.y));
}
}
if ( !fill)
erase( &ctx->mw);
if ( !fill_curve)
curve[idx]->add_and_shift_y_values( y_values, no_of_points);
curve[idx]->add_and_shift_y_values( y_values, no_of_points[0]);
else
curve[idx]->add_and_shift_y_values_filled( y_values, no_of_points);
curve[idx]->add_and_shift_y_values_filled( y_values, no_of_points[0]);
free( (char *)y_values);
}
}
......
......@@ -83,8 +83,11 @@ class GrowCurve : public GrowTrend {
int nodraw = 0);
glow_eCurveType type; //!< Type of curve.
int split_digsquare; //!< Split digtal curves on different lines
void set_type( glow_eCurveType t);
void set_digital_split( int set) { split_digsquare = set;}
void get_digital_split( int *set) { *set = split_digsquare;}
//! Configure the curves
/*!
......@@ -100,7 +103,7 @@ class GrowCurve : public GrowTrend {
Add the new value first in all the curves, and shift the other values one step forward.
*/
void add_points( glow_sCurveData *data, unsigned int no_of_points);
void add_points( glow_sCurveData *data, unsigned int *no_of_points);
};
......
......@@ -530,6 +530,7 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( fill_curve)
{
ctx->gdraw->set_clip_rectangle( w, ll_x, ll_y, ur_x, ur_y);
for ( i = 0; i < curve_cnt; i++) {
if ( curve[i])
curve[i]->border = 0;
......@@ -553,6 +554,7 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
if ( curve[i])
curve[i]->border = 1;
}
ctx->gdraw->reset_clip_rectangle( w);
}
for ( i = 0; i < vertical_lines; i++) {
......@@ -582,6 +584,7 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
curve[i]->fill = 0;
}
}
ctx->gdraw->set_clip_rectangle( w, ll_x, ll_y, ur_x, ur_y);
if ( t) {
GlowTransform tmp = *t * trf;
for ( i = 0; i < curve_cnt; i++) {
......@@ -595,6 +598,7 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
curve[i]->draw( w, &trf, highlight, hot, node, colornode);
}
}
ctx->gdraw->reset_clip_rectangle( w);
if ( fill_curve) {
ctx->gdraw->line( w, ll_x, ll_y, ll_x, ur_y, drawtype, idx, 0);
......@@ -1135,4 +1139,4 @@ void GrowTrend::set_mark_color( glow_eDrawType m1color, glow_eDrawType m2color)
{
mark1_color = m1color;
mark2_color = m2color;
}
\ No newline at end of file
}
......@@ -691,7 +691,8 @@ XttMultiViewGtk::XttMultiViewGtk( GtkWidget *mv_parent_wid, void *mv_parent_ctx,
sevhist[i*rows + j] = new XttSevHistGtk( this, toplevel, (char *)"No title", &widget,
oidv, anamev, onamev, sevhistobjectv,
xnav->scctx, w, h,
(unsigned int)curve_mOptions_Embedded, color_theme, 0, sts);
(unsigned int)curve_mOptions_Embedded, color_theme,
time_ePeriod_, 0, sts);
if ( EVEN(*sts)) {
comp_widget[i*rows + j] = error_msg("Unable to load history data", *sts);
break;
......@@ -1260,7 +1261,8 @@ int XttMultiViewGtk::set_subwindow_source( const char *name, char *source, char
ctx = new XttSevHistGtk( this, toplevel, (char *)"No title", &comp_w,
oidv, anamev, onamev, sevhistobjectv,
xnav->scctx, w, h,
(unsigned int)curve_mOptions_Embedded, color_theme, 0, &lsts);
(unsigned int)curve_mOptions_Embedded, color_theme,
time_ePeriod_, 0, &lsts);
if ( EVEN(lsts)) break;
ctx->help_cb = multiview_trend_help_cb;
......@@ -1403,4 +1405,4 @@ void XttMultiViewGtk::signal_send( char *signalname)
}
}
}
}
\ No newline at end of file
}
......@@ -1153,6 +1153,14 @@ int OpGtk::configure( char *opplace_str)
sts = gdh_ClassAttrToAttrref( pwr_cClass_XttCamera, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
break;
case pwr_cClass_SevPlotGroup:
sts = gdh_ClassAttrToAttrref( pwr_cClass_SevPlotGroup, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
break;
case pwr_cClass_PlotGroup:
sts = gdh_ClassAttrToAttrref( pwr_cClass_PlotGroup, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
break;
default:
continue;
}
......@@ -1984,4 +1992,4 @@ void OpGtk::set_text_size()
gtk_widget_modify_font( GTK_WIDGET(gtk_bin_get_child(GTK_BIN(appl_buttons[i]))), fd);
}
}
}
\ No newline at end of file
}
......@@ -74,9 +74,11 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
int xn_height,
unsigned int xn_options,
int xn_color_theme,
time_ePeriod xn_time_range,
void *basewidget,
int *sts) :
XttSevHist( parent_ctx, name, xn_oidv, xn_anamev, xn_onamev, sevhistobjectv, xn_scctx, xn_color_theme, sts),
XttSevHist( parent_ctx, name, xn_oidv, xn_anamev, xn_onamev, sevhistobjectv, xn_scctx, xn_color_theme,
xn_time_range, sts),
parent_widget(parent_wid)
{
char title[250];
......@@ -101,7 +103,8 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
curve->remove_cb = sevhist_remove_cb;
curve->export_cb = sevhist_export_cb;
curve->enable( curve_mEnable_Timebox | curve_mEnable_Export | curve_mEnable_ExportTime |
curve_mEnable_CurveType | curve_mEnable_CurveTypeSquare | curve_mEnable_FillCurve);
curve_mEnable_CurveType | curve_mEnable_CurveTypeSquare | curve_mEnable_FillCurve |
curve_mEnable_DigitalSplit);
if ( initial_period != time_ePeriod_)
curve->set_period( initial_period, 1);
......
......@@ -61,6 +61,7 @@ class XttSevHistGtk : public XttSevHist {
int height,
unsigned int options,
int xn_color_theme,
time_ePeriod xn_time_range,
void *basewidget,
int *sts);
XttSevHistGtk( void *parent_ctx,
......@@ -77,4 +78,4 @@ class XttSevHistGtk : public XttSevHist {
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *));
};
#endif
\ No newline at end of file
#endif
......@@ -287,12 +287,12 @@ XttTrend *XNavGtk::xtttrend_new( char *name, pwr_tAttrRef *objar, pwr_tAttrRef *
XttSevHist *XNavGtk::xttsevhist_new( char *name, pwr_tOid *oidv, pwr_tOName *anamev, pwr_tOName *onamev,
bool *sevhistobjectv, sevcli_tCtx scctx, char *filename,
int width, int height, unsigned int options, int color_theme,
void *basewidget, pwr_tStatus *sts)
time_ePeriod time_range, void *basewidget, pwr_tStatus *sts)
{
GtkWidget *w;
if ( !filename)
return new XttSevHistGtk( this, parent_wid, name, &w, oidv, anamev, onamev, sevhistobjectv, scctx, width, height, options, color_theme, basewidget, sts);
return new XttSevHistGtk( this, parent_wid, name, &w, oidv, anamev, onamev, sevhistobjectv, scctx, width, height, options, color_theme, time_range, basewidget, sts);
else
return new XttSevHistGtk( this, parent_wid, name, &w, filename, color_theme, basewidget, sts);
}
......
......@@ -82,7 +82,7 @@ class XNavGtk : public XNav {
XttSevHist *xttsevhist_new( char *name, pwr_tOid *oidv, pwr_tOName *anamev,
pwr_tOName *onamev, bool *sevhistobjectv, sevcli_tCtx scctx,
char *filename, int width, int height, unsigned int options, int color_theme,
void *basewidget, pwr_tStatus *sts);
time_ePeriod time_range, void *basewidget, pwr_tStatus *sts);
XttTCurve *xtttcurve_new( char *name, pwr_tAttrRef *arefv, int width, int height, unsigned int options,
int color_theme, void *basewidget, pwr_tStatus *sts);
XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, int width, int height, unsigned int options,
......@@ -152,4 +152,4 @@ class XNavGtk : public XNav {
GdkCursor *clock_cursor;
};
#endif
\ No newline at end of file
#endif
......@@ -180,6 +180,7 @@ XttFast::XttFast( void *parent_ctx,
element_size[i] = 4;
}
gcd->rows[i] = max_points;
gcd->y_orig_type[i] = type[i];
}
gcd->cols = fast_cnt;
......
......@@ -121,6 +121,14 @@ int Op::appl_action( int idx)
strcpy( cmd, "ope camera/obj=");
strcat( cmd, name);
break;
case pwr_cClass_SevPlotGroup:
strcpy( cmd, "ope hist ");
strcat( cmd, name);
break;
case pwr_cClass_PlotGroup:
strcpy( cmd, "ope plo ");
strcat( cmd, name);
break;
default:
return 0;
}
......
......@@ -71,6 +71,7 @@ XttSevHist::XttSevHist( void *parent_ctx,
bool *xn_sevhistobjectv,
sevcli_tCtx xn_scctx,
int xn_color_theme,
time_ePeriod time_range,
int *sts) :
xnav(parent_ctx), gcd(0), curve(0), rows(0), vsize(0), timerid(0), close_cb(0), help_cb(0),
get_select_cb(0), first_scan(1), scctx(xn_scctx), wow(0), time_low_old(0), time_high_old(0),
......@@ -95,34 +96,42 @@ XttSevHist::XttSevHist( void *parent_ctx,
memcpy( onamev, xn_onamev, oid_cnt * sizeof(onamev[0]));
memcpy( sevhistobjectv, xn_sevhistobjectv, oid_cnt * sizeof(sevhistobjectv[0]));
if ( time_range == time_ePeriod_)
time_range = time_ePeriod_LastHour;
time_Period( time_range, &from, &to, 0, 0);
#if 0
time_GetTime( &to);
from.tv_sec = to.tv_sec - 3600;
from.tv_nsec = to.tv_nsec;
// time_Period( time_ePeriod_OneHour, &from, &to, 0, 0);
#endif
if ( oid_cnt == 1) {
get_data( sts, from, to);
if ( *sts == SEV__NOPOINTS) {
// Try month
#if 0
from.tv_sec = to.tv_sec - 31 * 24 * 3600;
from.tv_nsec = to.tv_nsec;
time_Period( time_ePeriod_OneMonth, &from, &to, 0, 0);
#endif
time_range = time_ePeriod_LastMonth;
time_Period( time_range, &from, &to, 0, 0);
get_data( sts, from, to);
if ( EVEN(*sts)) return;
initial_period = time_ePeriod_OneMonth;
}
else if ( EVEN(*sts)) return;
else
initial_period = time_ePeriod_OneHour;
initial_period = time_range;
}
else {
get_multidata( sts, from, to);
if ( *sts == SEV__NOPOINTS) {
// Try month
time_Period( time_ePeriod_OneMonth, &from, &to, 0, 0);
time_range = time_ePeriod_LastMonth;
time_Period( time_range, &from, &to, 0, 0);
get_multidata( sts, from, to);
if ( EVEN(*sts)) return;
}
else if ( EVEN(*sts)) return;
initial_period = time_range;
}
cdh_StrncpyCutOff( title, name, sizeof(title), 1);
}
......@@ -231,6 +240,7 @@ int XttSevHist::get_data( pwr_tStatus *sts, pwr_tTime from, pwr_tTime to)
free( vbuf);
gcd->y_axis_type[0] = curve_eAxis_y;
gcd->y_orig_type[0] = vtype;
gcd->cols = 1;
gcd->rows[0] = rows;
......@@ -719,6 +729,7 @@ void XttSevHist::curve_add( pwr_tOid oid, pwr_tOName aname, pwr_tOName oname,
oidv[oid_cnt] = oid;
strncpy( anamev[oid_cnt], aname, sizeof(anamev[0]));
strncpy( onamev[oid_cnt], oname, sizeof(onamev[0]));
sevhistobjectv[oid_cnt] = false;
oid_cnt++;
int curve_cnt = gcd->cols;
......@@ -752,7 +763,8 @@ void XttSevHist::setup()
if ( !curve)
return;
curve->setup( curve_mEnable_Timebox | curve_mEnable_Export | curve_mEnable_ExportTime |
curve_mEnable_CurveType | curve_mEnable_CurveTypeSquare | curve_mEnable_FillCurve);
curve_mEnable_CurveType | curve_mEnable_CurveTypeSquare | curve_mEnable_FillCurve |
curve_mEnable_DigitalSplit);
}
void XttSevHist::sevhist_close_cb( void *ctx)
......@@ -988,7 +1000,7 @@ pwr_tStatus XttSevHist::sevhist_otree_action_cb( void *ctx, pwr_tAttrRef *aref)
sts = gdh_AttrrefToName( &aaref, oname, sizeof(oname), cdh_mNName);
if ( EVEN(sts)) return sts;
s = strrchr( oname, '.');
s = strchr( oname, '.');
if ( s) {
*s = 0;
strncpy( aname, s+1, sizeof(aname));
......
......@@ -108,6 +108,7 @@ class XttSevHist {
bool *sevhistobjectv,
sevcli_tCtx xn_scctx,
int xn_color_theme,
time_ePeriod xn_time_range,
int *sts);
XttSevHist( void *parent_ctx,
const char *name,
......@@ -150,4 +151,4 @@ class XttSevHist {
};
/*@}*/
#endif
\ No newline at end of file
#endif
......@@ -261,6 +261,7 @@ XttTrend::XttTrend( void *parent_ctx,
element_size[i] = 4;
}
gcd->rows[i] = max_points;
gcd->y_orig_type[i] = (pwr_eType)trend_p[i]->DataType;
}
gcd->cols = trend_cnt;
gcd->x_reverse = 1;
......@@ -413,6 +414,7 @@ XttTrend::XttTrend( void *parent_ctx,
for ( i = 0; i < trend_cnt; i++) {
gcd->y_data[i] = (double *) calloc( 1, 8 * max_points);
gcd->y_orig_type[i] = element_type[i];
switch ( element_type[i]) {
case pwr_eType_Float32:
......@@ -608,7 +610,8 @@ void XttTrend::trend_scan( void *data)
if ( trend->trend_tid == pwr_cClass_DsTrend) {
int write_buffer;
int idx;
int values;
int values;
unsigned int size = 1;
int trend_buff_size = (int) sizeof( trend->trend_p[0]->DataBuffer) /
sizeof( trend->trend_p[0]->DataBuffer[0]);
......@@ -642,81 +645,81 @@ void XttTrend::trend_scan( void *data)
trend->gcd->y_data[i][0] = trend->trend_p[i]->DataBuffer[idx];
}
trend->curve->points_added( 1);
trend->curve->points_added( &size);
}
}
}
else if ( trend->trend_tid == pwr_cClass_DsTrendCurve) {
pwr_tStatus sts;
unsigned int size;
unsigned int size[CURVE_MAX_COLS];
sts = cbuf_UpdateCircBuffInfo( trend->cb_info, trend->trend_cnt);
if ( EVEN(sts)) return;
for ( i = 0; i < trend->trend_cnt; i++) {
size = trend->cb_info[i].size;
if ( size > 0) {
size[i] = trend->cb_info[i].size;
if ( size[i] > 0) {
// Shift data
for ( j = trend->cb_info[i].samples - 1; j >= (int)size; j--) {
for ( j = trend->cb_info[i].samples - 1; j >= (int)size[i]; j--) {
if ( j < trend->gcd->rows[i])
trend->gcd->y_data[i][j] = trend->gcd->y_data[i][j-size];
trend->gcd->y_data[i][j] = trend->gcd->y_data[i][j-size[i]];
}
// Insert new value
size[i] = MIN((int)size[i], trend->max_points);
switch ( trend->element_type[i]) {
case pwr_eType_Float64:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tFloat64 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tFloat64));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tFloat64 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tFloat64));
break;
case pwr_eType_Float32:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tFloat32 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tFloat32));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tFloat32 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tFloat32));
break;
case pwr_eType_Boolean:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tBoolean *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tBoolean));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tBoolean *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tBoolean));
break;
case pwr_eType_Int64:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt64 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tInt64));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt64 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tInt64));
break;
case pwr_eType_UInt64:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt64 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tUInt64));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt64 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tUInt64));
break;
case pwr_eType_Int32:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt32 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tInt32));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt32 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tInt32));
break;
case pwr_eType_UInt32:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt32 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tUInt32));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt32 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tUInt32));
break;
case pwr_eType_Int16:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt16 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tInt16));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt16 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tInt16));
break;
case pwr_eType_UInt16:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt16 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tUInt16));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt16 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tUInt16));
break;
case pwr_eType_Int8:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt8 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tInt8));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tInt8 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tInt8));
break;
case pwr_eType_UInt8:
for ( j = 0; j < (int)size; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt8 *)((char *)trend->cb_info[i].bufp + (size - j - 1) * sizeof(pwr_tUInt8));
for ( j = 0; j < (int)size[i]; j++)
trend->gcd->y_data[i][j] = *(pwr_tUInt8 *)((char *)trend->cb_info[i].bufp + (size[i] - j - 1) * sizeof(pwr_tUInt8));
break;
default: ;
}
}
}
if ( size > 0)
trend->curve->points_added( size);
trend->curve->points_added( size);
}
trend->timerid->add( trend->update_time, trend_scan, trend);
}
......
......@@ -55,6 +55,10 @@ extern "C" {
# include "co_regex.h"
#endif
#ifndef co_time_h
# include "co_time.h"
#endif
#ifndef co_nav_help_h
#include "co_nav_help.h"
#endif
......@@ -382,7 +386,7 @@ class XNav {
virtual XttSevHist *xttsevhist_new( char *name, pwr_tOid *oidv, pwr_tOName *aname,
pwr_tOName *oname, bool *sevhistobjectv, sevcli_tCtx scctx,
char *filename, int width, int height, unsigned int options,
int color_theme, void *basewidget, pwr_tStatus *sts) {return 0;}
int color_theme, time_ePeriod time_range, void *basewidget, pwr_tStatus *sts) {return 0;}
virtual XttTCurve *xtttcurve_new( char *name, pwr_tAttrRef *arefv, int width, int height, unsigned int options,
int color_theme, void *basewidget, pwr_tStatus *sts) {return 0;}
virtual XttFast *xttfast_new( char *name, pwr_tAttrRef *objar, int width, int height, unsigned int options,
......
This diff is collapsed.
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