Commit 3aa4f974 authored by Claes Sjofors's avatar Claes Sjofors

Curve window, second mark and export dialog added

parent 8feefb25
...@@ -219,7 +219,10 @@ int dcli_replace_env( char *str, char *newstr) ...@@ -219,7 +219,10 @@ int dcli_replace_env( char *str, char *newstr)
size = (long int) s - (long int) u; size = (long int) s - (long int) u;
strncpy( symbol, u, size); strncpy( symbol, u, size);
symbol[size] = 0; symbol[size] = 0;
cdh_ToLower( lower_symbol, symbol); if ( strcmp( symbol, "HOME") == 0)
strcpy( lower_symbol, symbol);
else
cdh_ToLower( lower_symbol, symbol);
if ( (value = getenv( lower_symbol)) == NULL) { if ( (value = getenv( lower_symbol)) == NULL) {
/* It was no symbol */ /* It was no symbol */
*t = 0; *t = 0;
...@@ -467,7 +470,13 @@ int dcli_translate_filename( char *out, const char *in) ...@@ -467,7 +470,13 @@ int dcli_translate_filename( char *out, const char *in)
else else
{ {
// Already unix syntax // Already unix syntax
strcpy( out_name, in); if ( in[0] == '~') {
strcpy( out_name, "$HOME");
strcat( &out_name[5], &in[1]);
}
else
strcpy( out_name, in);
sts = dcli_replace_env( out_name, out); sts = dcli_replace_env( out_name, out);
return sts; return sts;
} }
......
...@@ -171,7 +171,7 @@ time_Aadd ( ...@@ -171,7 +171,7 @@ time_Aadd (
) )
{ {
pwr_tTime *r = result; pwr_tTime *r = result;
int tv_nsec; pwr_tInt64 tv_nsec;
assertAbs(t); assertAbs(t);
assertDelta(a); assertDelta(a);
...@@ -231,8 +231,8 @@ time_Adiff ( ...@@ -231,8 +231,8 @@ time_Adiff (
pwr_tTime *s pwr_tTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_Assert(r != NULL); pwr_Assert(r != NULL);
assertAbs(t); assertAbs(t);
...@@ -267,8 +267,8 @@ time_Asub ( ...@@ -267,8 +267,8 @@ time_Asub (
pwr_tDeltaTime *s pwr_tDeltaTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = (int)t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_tTime *r = result; pwr_tTime *r = result;
assertAbs(t); assertAbs(t);
...@@ -329,7 +329,7 @@ time_Dadd ( ...@@ -329,7 +329,7 @@ time_Dadd (
) )
{ {
pwr_tDeltaTime *r = result; pwr_tDeltaTime *r = result;
int tv_nsec, tv_sec; pwr_tInt64 tv_nsec, tv_sec;
assertDelta(t); assertDelta(t);
assertDelta(a); assertDelta(a);
...@@ -423,8 +423,8 @@ time_Dsub ( ...@@ -423,8 +423,8 @@ time_Dsub (
pwr_tDeltaTime *s pwr_tDeltaTime *s
) )
{ {
int tv_nsec = t->tv_nsec - s->tv_nsec; pwr_tInt64 tv_nsec = t->tv_nsec - s->tv_nsec;
int tv_sec = t->tv_sec - s->tv_sec; pwr_tInt64 tv_sec = t->tv_sec - s->tv_sec;
pwr_tDeltaTime *r = result; pwr_tDeltaTime *r = result;
assertDelta(t); assertDelta(t);
......
...@@ -269,6 +269,8 @@ scan ( ...@@ -269,6 +269,8 @@ scan (
/* if (sts == TIME__CLKCHANGE) { /* if (sts == TIME__CLKCHANGE) {
tp->after_scan = tp->before_scan; tp->after_scan = tp->before_scan;
}*/ }*/
//if ( tp->PlcThread->Count % 10000 == 0)
// printf( "ba: %9lld %9lld %9lld %9lld\n", tp->before_scan.tv_sec, tp->before_scan.tv_nsec, tp->after_scan.tv_sec, tp->after_scan.tv_nsec);
time_GetTime(&tp->after_scan_abs); time_GetTime(&tp->after_scan_abs);
if (tp->log) if (tp->log)
pwrb_PlcThread_Exec(tp); pwrb_PlcThread_Exec(tp);
...@@ -279,6 +281,8 @@ scan ( ...@@ -279,6 +281,8 @@ scan (
plc_timerhandler(tp); plc_timerhandler(tp);
time_Aadd(NULL, &tp->sync_time, &tp->scan_time); time_Aadd(NULL, &tp->sync_time, &tp->scan_time);
time_Adiff(&delta, &tp->sync_time, &tp->after_scan); time_Adiff(&delta, &tp->sync_time, &tp->after_scan);
//if ( tp->PlcThread->Count % 10000 == 0)
// printf( "ff: %9lld %9lld %9lld %9lld %9lld %9lld\n", tp->sync_time.tv_sec, tp->sync_time.tv_nsec, tp->after_scan.tv_sec, tp->after_scan.tv_nsec, delta.tv_sec, delta.tv_nsec);
if (time_Dcomp(&delta, NULL) > 0) { if (time_Dcomp(&delta, NULL) > 0) {
pwr_tStatus sts; pwr_tStatus sts;
int phase = 0; int phase = 0;
...@@ -312,11 +316,22 @@ scan ( ...@@ -312,11 +316,22 @@ scan (
* END REMARK * END REMARK
*/ */
// phase = (int)que_Get(&sts, &tp->q_in, &delta, NULL); // phase = (int)que_Get(&sts, &tp->q_in, &delta, NULL);
struct timespec ts; struct timespec ts;
ts.tv_sec = tp->sync_time.tv_sec; ts.tv_sec = tp->sync_time.tv_sec;
ts.tv_nsec = tp->sync_time.tv_nsec; ts.tv_nsec = tp->sync_time.tv_nsec;
//if ( tp->PlcThread->Count % 10000 == 0)
//printf( "st: %9d %9d %9lld %9lld\n", ts.tv_sec, ts.tv_nsec, tp->scan_time.tv_sec, tp->scan_time.tv_nsec);
pwr_tTime sleep1, sleep2;
time_GetTimeMonotonic(&sleep1);
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL); clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL);
time_GetTimeMonotonic(&sleep2);
if ( tp->PlcThread->Count % 10000 == 0)
printf( "st: %9lld %9lld %9lld %9lld %9d %9d %11.9f\n", sleep1.tv_sec, sleep1.tv_nsec, sleep2.tv_sec, sleep2.tv_nsec, ts.tv_sec, ts.tv_nsec, ((float)sleep2.tv_nsec-sleep1.tv_nsec)/1000000000);
#endif #endif
if (phase > 0) { if (phase > 0) {
tp->exit = TRUE; tp->exit = TRUE;
......
...@@ -29,6 +29,7 @@ nodatatime <No data found in this time interval> /error ...@@ -29,6 +29,7 @@ nodatatime <No data found in this time interval> /error
noitems <No items found> /error noitems <No items found> /error
unknownnode <Unknown server nodename> /error unknownnode <Unknown server nodename> /error
init <Initialization done> /info init <Initialization done> /info
exportfile <Unable to open export file> /error
.end .end
......
...@@ -734,6 +734,23 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx, ...@@ -734,6 +734,23 @@ void CoWowGtk::CreateFileSelDia( const char *title, void *parent_ctx,
gtk_file_filter_add_pattern( filter, "*"); gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter); gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
} }
else if ( file_type == wow_eFileSelType_History) {
pwr_tFileName folder;
dcli_translate_filename( folder, "~");
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(dialog), folder);
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "*.txt,*.csv,*.skv");
gtk_file_filter_add_pattern( filter, "*.txt");
gtk_file_filter_add_pattern( filter, "*.csv");
gtk_file_filter_add_pattern( filter, "*.skv");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
filter = gtk_file_filter_new();
gtk_file_filter_set_name( filter, "All Files");
gtk_file_filter_add_pattern( filter, "*");
gtk_file_chooser_add_filter( GTK_FILE_CHOOSER(dialog), filter);
}
if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { if ( gtk_dialog_run( GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
char *filename; char *filename;
......
...@@ -32,6 +32,7 @@ typedef enum { ...@@ -32,6 +32,7 @@ typedef enum {
wow_eFileSelType_WblClass, wow_eFileSelType_WblClass,
wow_eFileSelType_Graph, wow_eFileSelType_Graph,
wow_eFileSelType_Image, wow_eFileSelType_Image,
wow_eFileSelType_History,
wow_eFileSelType__ wow_eFileSelType__
} wow_eFileSelType; } wow_eFileSelType;
......
This diff is collapsed.
...@@ -47,6 +47,13 @@ class GeCurveGtk : public GeCurve { ...@@ -47,6 +47,13 @@ class GeCurveGtk : public GeCurve {
GtkWidget *minmax_widget; GtkWidget *minmax_widget;
GtkWidget *minmax_textmin_widget; GtkWidget *minmax_textmin_widget;
GtkWidget *minmax_textmax_widget; GtkWidget *minmax_textmax_widget;
GtkWidget *menu_export;
GtkWidget *export_widget;
GtkWidget *export_attrcombo_widget;
GtkWidget *export_fromtime_widget;
GtkWidget *export_totime_widget;
GtkWidget *export_rows_widget;
GtkWidget *export_filename_widget;
GtkWidget *sea_timebox; GtkWidget *sea_timebox;
GtkWidget *timebox_start_time; GtkWidget *timebox_start_time;
GtkWidget *timebox_stop_time; GtkWidget *timebox_stop_time;
...@@ -58,10 +65,13 @@ class GeCurveGtk : public GeCurve { ...@@ -58,10 +65,13 @@ class GeCurveGtk : public GeCurve {
void write_title( char *str); void write_title( char *str);
void resize(); void resize();
void open_minmax( int idx); void open_minmax( int idx);
void open_export( pwr_tTime *from, pwr_tTime *to, int rows, char *filename);
void axis_set_width( int width); void axis_set_width( int width);
void create_minmax_dialog(); void create_minmax_dialog();
void create_export_dialog();
void set_inputfocus(); void set_inputfocus();
void enable_timebox(); void enable_timebox();
void enable_export();
void set_times( pwr_tTime *from, pwr_tTime *to); void set_times( pwr_tTime *from, pwr_tTime *to);
void set_times_sensitivity( int sensitive); void set_times_sensitivity( int sensitive);
pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to); pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to);
...@@ -73,6 +83,7 @@ class GeCurveGtk : public GeCurve { ...@@ -73,6 +83,7 @@ class GeCurveGtk : public GeCurve {
static void activate_exit( GtkWidget *w, gpointer data); static void activate_exit( GtkWidget *w, gpointer data);
static void activate_configure( GtkWidget *w, gpointer data); static void activate_configure( GtkWidget *w, gpointer data);
static void activate_print( GtkWidget *w, gpointer data); static void activate_print( GtkWidget *w, gpointer data);
static void activate_export( GtkWidget *w, gpointer data);
static void activate_zoomin( GtkWidget *w, gpointer data); static void activate_zoomin( GtkWidget *w, gpointer data);
static void activate_zoomout( GtkWidget *w, gpointer data); static void activate_zoomout( GtkWidget *w, gpointer data);
static void activate_zoomreset( GtkWidget *w, gpointer data); static void activate_zoomreset( GtkWidget *w, gpointer data);
...@@ -95,6 +106,10 @@ class GeCurveGtk : public GeCurve { ...@@ -95,6 +106,10 @@ class GeCurveGtk : public GeCurve {
static void activate_help( GtkWidget *w, gpointer data); static void activate_help( GtkWidget *w, gpointer data);
static void activate_minmax_ok( GtkWidget *w, gpointer data); static void activate_minmax_ok( GtkWidget *w, gpointer data);
static void activate_minmax_cancel( GtkWidget *w, gpointer data); static void activate_minmax_cancel( GtkWidget *w, gpointer data);
static void activate_export_ok( GtkWidget *w, gpointer data);
static void activate_export_cancel( GtkWidget *w, gpointer data);
static void activate_export_browse( GtkWidget *w, gpointer data);
static void export_file_selected_cb( void *ctx, char *filename, wow_eFileSelType file_type);
static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data); static gboolean action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data);
}; };
......
This diff is collapsed.
...@@ -124,7 +124,8 @@ class GeCurve { ...@@ -124,7 +124,8 @@ class GeCurve {
glow_eDrawType border_bright; glow_eDrawType border_bright;
grow_tObject curve_object; grow_tObject curve_object;
grow_tObject curve_axisobject; grow_tObject curve_axisobject;
grow_tObject curve_markobject; grow_tObject curve_markobject1;
grow_tObject curve_markobject2;
GeCurveData *cd; GeCurveData *cd;
double axis_window_width; double axis_window_width;
int hide[CURVE_MAX_COLS]; int hide[CURVE_MAX_COLS];
...@@ -133,7 +134,8 @@ class GeCurve { ...@@ -133,7 +134,8 @@ class GeCurve {
grow_tObject hide_l1[CURVE_MAX_COLS+1]; grow_tObject hide_l1[CURVE_MAX_COLS+1];
grow_tObject hide_l2[CURVE_MAX_COLS+1]; grow_tObject hide_l2[CURVE_MAX_COLS+1];
grow_tObject scale_rect[CURVE_MAX_COLS+1]; grow_tObject scale_rect[CURVE_MAX_COLS+1];
grow_tObject mark_annot[CURVE_MAX_COLS+1]; grow_tObject mark1_annot[CURVE_MAX_COLS+1];
grow_tObject mark2_annot[CURVE_MAX_COLS+1];
grow_tObject cursor_annot[CURVE_MAX_COLS+1]; grow_tObject cursor_annot[CURVE_MAX_COLS+1];
grow_tObject axis_rect[CURVE_MAX_COLS+1]; grow_tObject axis_rect[CURVE_MAX_COLS+1];
grow_tObject axis_object[CURVE_MAX_COLS+1]; grow_tObject axis_object[CURVE_MAX_COLS+1];
...@@ -150,10 +152,12 @@ class GeCurve { ...@@ -150,10 +152,12 @@ class GeCurve {
void (*next_period_cb)( void *); void (*next_period_cb)( void *);
void (*add_cb)( void *); void (*add_cb)( void *);
void (*remove_cb)( void *); void (*remove_cb)( void *);
int (*export_cb)( void *, pwr_tTime *, pwr_tTime *, int, int, char *);
int initial_right_position; int initial_right_position;
char title[300]; char title[300];
double last_cursor_x; double last_cursor_x;
double last_mark_x; double last_mark1_x;
double last_mark2_x;
int deferred_configure_axes; int deferred_configure_axes;
CoWow *wow; CoWow *wow;
int center_from_window; int center_from_window;
...@@ -165,8 +169,10 @@ class GeCurve { ...@@ -165,8 +169,10 @@ class GeCurve {
virtual void pop() {} virtual void pop() {}
virtual void resize() {} virtual void resize() {}
virtual void open_minmax( int idx) {} virtual void open_minmax( int idx) {}
virtual void open_export( pwr_tTime *from, pwr_tTime *to, int rows, char *filename) {}
virtual void axis_set_width( int width) {} virtual void axis_set_width( int width) {}
virtual void enable_timebox() {} virtual void enable_timebox() {}
virtual void enable_export() {}
virtual void set_times( pwr_tTime *from, pwr_tTime *to) {} virtual void set_times( pwr_tTime *from, pwr_tTime *to) {}
virtual void set_times_sensitivity( int sensitive) {} virtual void set_times_sensitivity( int sensitive) {}
virtual pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to) {return 0;} virtual pwr_tStatus get_times( pwr_tTime *from, pwr_tTime *to) {return 0;}
...@@ -186,6 +192,7 @@ class GeCurve { ...@@ -186,6 +192,7 @@ class GeCurve {
void measure_window( double *ll_x, double *ll_y, double *ur_x, double *ur_y); void measure_window( double *ll_x, double *ll_y, double *ur_x, double *ur_y);
void activate_exit(); void activate_exit();
void activate_configure(); void activate_configure();
void activate_export();
void activate_print(); void activate_print();
void activate_background(); void activate_background();
void activate_filledcurves( int set); void activate_filledcurves( int set);
......
...@@ -76,7 +76,9 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx, ...@@ -76,7 +76,9 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
curve->next_period_cb = sevhist_next_period_cb; curve->next_period_cb = sevhist_next_period_cb;
curve->add_cb = sevhist_add_cb; curve->add_cb = sevhist_add_cb;
curve->remove_cb = sevhist_remove_cb; curve->remove_cb = sevhist_remove_cb;
curve->export_cb = sevhist_export_cb;
curve->enable_timebox(); curve->enable_timebox();
curve->enable_export();
wow = new CoWowGtk( parent_widget); wow = new CoWowGtk( parent_widget);
timerid = wow->timer_new(); timerid = wow->timer_new();
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "co_cdh.h" #include "co_cdh.h"
#include "co_time.h" #include "co_time.h"
#include "co_dcli.h"
#include "cow_wow.h" #include "cow_wow.h"
#include "rt_sev_msg.h" #include "rt_sev_msg.h"
...@@ -827,6 +828,78 @@ void XttSevHist::sevhist_remove_cb( void *ctx) ...@@ -827,6 +828,78 @@ void XttSevHist::sevhist_remove_cb( void *ctx)
// Do do // Do do
} }
int XttSevHist::sevhist_export_cb( void *ctx, pwr_tTime *from, pwr_tTime *to, int rows, int idx,
char *filename)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
pwr_tFileName fname;
pwr_tTime *tbuf;
void *vbuf;
pwr_eType vtype;
unsigned int vsize;
pwr_tStatus sts;
int rrows;
char timestr[40];
FILE *fp;
dcli_translate_filename( fname, filename);
sevcli_get_itemdata( &sts, sevhist->scctx, sevhist->oidv[idx], sevhist->anamev[idx], *from, *to,
rows, &tbuf, &vbuf, &rrows, &vtype, &vsize);
if ( EVEN(sts))
return sts;
if( rrows == 0 ) {
return SEV__NODATATIME;
}
fp = fopen( fname, "w");
if ( !fp)
return SEV__EXPORTFILE;
for ( int i = 0; i < rrows; i++) {
time_AtoAscii( &tbuf[i], time_eFormat_DateAndTime, timestr, sizeof(timestr));
fprintf( fp, "%s, ", timestr);
switch ( vtype) {
case pwr_eType_Int32:
case pwr_eType_Int64:
case pwr_eType_Int16:
case pwr_eType_Int8:
fprintf( fp, "%d", ((pwr_tInt32 *)vbuf)[i]);
break;
case pwr_eType_UInt64:
case pwr_eType_UInt32:
case pwr_eType_UInt16:
case pwr_eType_UInt8:
fprintf( fp, "%u", ((pwr_tUInt32 *)vbuf)[i]);
break;
case pwr_eType_Float32:
fprintf( fp, "%g", ((pwr_tFloat32 *)vbuf)[i]);
break;
case pwr_eType_Float64:
fprintf( fp, "%g", ((pwr_tFloat64 *)vbuf)[i]);
break;
case pwr_eType_Boolean:
fprintf( fp, "%d", ((pwr_tBoolean *)vbuf)[i]);
break;
default:
sts = SEV__CURVETYPE;
}
fprintf( fp, "\n");
}
free( tbuf);
free( vbuf);
fclose( fp);
printf( "Exported %d rows to file \"%s\" (%d)\n", rrows, fname, idx);
if ( EVEN(sts))
return sts;
return SEV__SUCCESS;
}
void XttSevHist::sevhist_help_cb( void *ctx) void XttSevHist::sevhist_help_cb( void *ctx)
{ {
XttSevHist *sevhist = (XttSevHist *) ctx; XttSevHist *sevhist = (XttSevHist *) ctx;
......
...@@ -107,6 +107,8 @@ class XttSevHist { ...@@ -107,6 +107,8 @@ class XttSevHist {
static void sevhist_next_period_cb( void *ctx); static void sevhist_next_period_cb( void *ctx);
static void sevhist_add_cb( void *ctx); static void sevhist_add_cb( void *ctx);
static void sevhist_remove_cb( void *ctx); static void sevhist_remove_cb( void *ctx);
static int sevhist_export_cb( void *ctx, pwr_tTime *from, pwr_tTime *to,
int rows, int idx, char *filename);
static void sevhist_help_cb( void *ctx); static void sevhist_help_cb( void *ctx);
static void sevhist_scan( void *data); static void sevhist_scan( void *data);
......
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