Commit b4d82252 authored by Claes Sjofors's avatar Claes Sjofors

Operator logging, logging and replay of ge graph events implemented

parent 2346efc4
......@@ -162,6 +162,12 @@ static void displayerror_ok_cb( GtkWidget *w, gint arg1, gpointer data)
gtk_widget_destroy( w);
}
static gboolean displayerror_remove_cb( void *data)
{
gtk_widget_destroy( (GtkWidget *)data);
return FALSE;
}
void CoWowGtk::DisplayError( const char *title, const char *text)
{
GtkWidget *parent = m_parent;
......@@ -180,6 +186,10 @@ void CoWowGtk::DisplayError( const char *title, const char *text)
G_CALLBACK(displayerror_ok_cb), NULL);
gtk_window_set_title( GTK_WINDOW(dialog), title);
gtk_widget_show_all( dialog);
if ( m_autoremove)
g_timeout_add( 1000, displayerror_remove_cb, dialog);
}
/************************************************************************
......
......@@ -26,6 +26,8 @@
#include "pwr.h"
#include "cow_wow.h"
bool CoWow::m_autoremove = false;
int CoWow::HideWarranty()
{
static int hide = 0;
......
......@@ -82,6 +82,9 @@ class CoWowRecall {
};
class CoWow {
protected:
static bool m_autoremove;
public:
CoWow() {}
virtual ~CoWow() {}
......@@ -114,6 +117,7 @@ class CoWow {
virtual CoWowTimer *timer_new() { return 0;}
virtual pwr_tStatus CreateMenuItem( const char *name, void *menu, int pixmap, int append, void *w) { return 0;}
virtual pwr_tStatus DeleteMenuItem( const char *name, void *menu) { return 0;}
static void SetAutoRemove( bool on) { m_autoremove = on;}
};
#endif
......
......@@ -150,7 +150,7 @@ Graph::Graph(
message_dialog_cb(NULL), is_authorized_cb(NULL),
traverse_focus_cb(NULL), set_focus_cb(NULL), get_ldhses_cb(NULL),
get_current_objects_cb(NULL), popup_menu_cb(NULL), call_method_cb(NULL),
sound_cb(0), create_modal_dialog_cb(0),
sound_cb(0), create_modal_dialog_cb(0), eventlog_cb(0),
linewidth(1), linetype(glow_eLineType_Solid), textsize(0),
textbold(0), textfont(glow_eFont_Helvetica),
border_color(1), fill_color(1), fill(0), border(1), shadow(0),
......@@ -2747,6 +2747,16 @@ static int graph_grow_cb( GlowCtx *ctx, glow_tEvent event)
return 1;
}
void graph_eventlog_cb( void *ctx, void *data, unsigned int size)
{
Graph *graph;
grow_GetCtxUserData( (GrowCtx *)ctx, (void **) &graph);
if ( graph && graph->eventlog_cb)
(graph->eventlog_cb) ( graph->parent_ctx, data, size);
}
void graph_userdata_save_cb( void *f, void *object, glow_eUserdataCbType utype)
{
ofstream *fp = (ofstream *)f;
......@@ -3065,6 +3075,7 @@ void GraphGrow::grow_trace_setup()
grow_EnableEvent( ctx, glow_eEvent_MenuDelete, glow_eEventType_CallBack,
graph_grow_cb);
grow_RegisterEventLogCallback( ctx, graph_eventlog_cb);
}
//
......
......@@ -454,6 +454,7 @@ class Graph {
int (*sound_cb)(void *, pwr_tAttrRef *);
int (*create_modal_dialog_cb)( void *, const char *, const char *, const char *, const char *,
const char *, const char *);
void (*eventlog_cb)(void *, void *, unsigned int);
int linewidth; //!< Selected linewidth.
glow_eLineType linetype; //!< Selected linetype.
int textsize; //!< Selected text size.
......@@ -1420,6 +1421,8 @@ class Graph {
int ccm_get_variable( char *name, int type, void *data);
int ccm_ref_variable( char *name, int type, void **data);
void event_exec( void *event, unsigned int size) { grow_EventExec( grow->ctx, event, size);}
//! Destructor
/*! Stop trace (if started), delete open attribute editors, free local database, delete grow and
destroy the widget.
......
......@@ -584,6 +584,11 @@ int GlowDrawGtk::event_handler( GdkEvent event)
// button_clicked << " c&p " << button_clicked_and_pressed << endl;
if ( event.any.window == m_wind.window || event.type == GDK_KEY_PRESS) {
#if defined PWRE_EVENTLOGGING_ENABLED
log_event( &event);
#endif
switch ( event.type) {
case GDK_KEY_PRESS : {
guint keysym;
......@@ -3610,3 +3615,91 @@ int GlowDrawGtk::get_text_extent_pango( const char *text, int len,
return 1;
}
void GlowDrawGtk::log_event( GdkEvent *event)
{
if ( ctx->eventlog_callback) {
GdkEvent e;
memcpy( &e, event, sizeof(e));
switch ( e.type) {
case GDK_KEY_PRESS:
*(gchar *)&e.key.string = e.key.string[0];
break;
case GDK_MOTION_NOTIFY: {
int x, y;
if ( e.motion.is_hint) {
gdk_window_get_pointer( e.any.window, &x, &y, NULL);
e.button.x = x;
e.button.y = y;
e.motion.is_hint = 0;
}
break;
}
case GDK_EXPOSE: {
int width, height;
get_window_size( &ctx->mw, &width, &height);
if ( e.expose.area.x == 0 && e.expose.area.y == 0) {
e.expose.area.x = -999;
e.expose.area.y = -999;
e.expose.area.width = width;
e.expose.area.height = height;
}
break;
}
default: ;
}
(ctx->eventlog_callback) ( ctx, &e, sizeof(e));
}
}
void GlowDrawGtk::event_exec( void *event, unsigned int size)
{
GdkEvent e;
if ( size != sizeof(e))
return;
memcpy( &e, event, size);
e.any.window = m_wind.window;
switch ( e.type) {
case GDK_KEY_PRESS: {
gchar *p = (gchar *)malloc(1);
*p = *(gchar *)&e.key.string;
e.key.string = p;
break;
}
case GDK_EXPOSE: {
if ( e.expose.area.x == -999 && e.expose.area.y == -999) {
GtkWidget *parent;
parent = gtk_widget_get_parent( m_wind.toplevel);
while( !GTK_IS_WINDOW(parent))
parent = gtk_widget_get_parent( parent);
gtk_window_resize( GTK_WINDOW(parent), e.expose.area.width, e.expose.area.height);
// set_window_size( &ctx->mw, e.expose.area.width, e.expose.area.height);
e.expose.area.x = 0;
e.expose.area.y = 0;
}
break;
}
default: ;
}
event_handler( e);
switch ( e.type) {
case GDK_KEY_PRESS: {
free( e.key.string);
break;
}
default: ;
}
}
......@@ -227,6 +227,8 @@ class GlowDrawGtk : public GlowDraw {
int get_text_extent_pango( const char *text, int len,
glow_eDrawType gc_type, int idx, glow_eFont font_idx,
int *width, int *height, int *descent, double size);
void log_event( GdkEvent *event);
virtual void event_exec( void *event, unsigned int size);
};
......
......@@ -79,7 +79,7 @@ GlowCtx::GlowCtx( const char *ctx_name, double zoom_fact, int offs_x, int offs_y
default_hot_mode(glow_eHotMode_SingleObject), hot_found(0),
userdata_save_callback(0), userdata_open_callback(0), userdata_copy_callback(0),
version(GLOW_VERSION), inputfocus_object(0), is_component(0), comment(0),
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2)
hot_indication(glow_eHotIndication_LightColor), tiptext_size(2), eventlog_callback(0)
{
strcpy(name, ctx_name);
memset( (void *)event_callback, 0, sizeof(event_callback));
......
......@@ -102,6 +102,7 @@ typedef struct {
typedef void (*glow_tUserDataSaveCb) ( ofstream *, void *, glow_eUserdataCbType);
typedef void (*glow_tUserDataOpenCb) ( ifstream *, void *, glow_eUserdataCbType);
typedef void (*glow_tUserDataCopyCb) ( void *, void *, void **, glow_eUserdataCbType);
typedef void (*glow_tEventLogCb) ( void *, void *, unsigned int);
//! Class for a drawing window populated with drawing objects and components.
/*! GlowCtx is the base class for the drawing area in Glow. It contains array with
......@@ -824,6 +825,7 @@ class GlowCtx {
CtxComment *comment;
glow_eHotIndication hot_indication; //!< Specification of how hots object should be drawn.
int tiptext_size; //!< Size of tooltip text
glow_tEventLogCb eventlog_callback; //!< Callback function to log events.
//! Register scrollbar callback function
/*!
......@@ -882,6 +884,13 @@ class GlowCtx {
userdata_open_callback = open_callback;
userdata_copy_callback = copy_callback;}
//! Register callback functions for event logging.
/*!
\param log_callback Callback function that will be called to log an event.
*/
void register_eventlog_callback( glow_tEventLogCb log_callback)
{ eventlog_callback = log_callback;}
//! Destructor
/*! Delete all objects in the context. */
~GlowCtx();
......
......@@ -165,6 +165,7 @@ class GlowDraw {
glow_eDrawType d0, glow_eDrawType d1, glow_eDrawType d2,
glow_eGradient gradient)
{return fill_polyline( wind, points, point_cnt, d0, 0);}
virtual void event_exec( void *event, unsigned int size) {}
};
class DrawWind {
......
......@@ -4385,6 +4385,12 @@ void grow_RegisterUserDataCallbacks( grow_tCtx ctx,
(glow_tUserDataCopyCb) copy);
}
void grow_RegisterEventLogCallback( grow_tCtx ctx,
void (*log_cb)( void *, void *, unsigned int))
{
((GrowCtx *)ctx)->register_eventlog_callback( (glow_tEventLogCb) log_cb);
}
void grow_GetVersion( grow_tCtx ctx, int *grow_version, int *graph_version)
{
*graph_version = ctx->version;
......@@ -4688,6 +4694,11 @@ void grow_SetTextCoding( grow_tCtx ctx, glow_eTextCoding coding)
ctx->set_text_coding( coding);
}
void grow_EventExec( grow_tCtx ctx, void *event, unsigned int size)
{
ctx->gdraw->event_exec( event, size);
}
/*@}*/
......
......@@ -2716,6 +2716,9 @@ extern "C" {
void (*open)( void *, void *, glow_eUserdataCbType),
void (*copy)( void *, void *, void **, glow_eUserdataCbType));
void grow_RegisterEventLogCallback( grow_tCtx ctx,
void (*log_cb)( void *, void *, unsigned int));
//! Get grow versions.
/*!
\param ctx Grow context.
......@@ -2970,6 +2973,7 @@ extern "C" {
void grow_ObjectRead( grow_tCtx ctx, ifstream& fp, grow_tObject *object);
int grow_GetDimension( char *filename, int *width, int *height);
void grow_SetTextCoding( grow_tCtx ctx, glow_eTextCoding coding);
void grow_EventExec( grow_tCtx ctx, void *event, unsigned int size);
/*@}*/
#if defined __cplusplus
......
......@@ -40,6 +40,7 @@ typedef void *Widget;
#include "co_lng.h"
#include "xtt_ge_gtk.h"
#include "ge_graph_gtk.h"
#include "xtt_log.h"
gboolean XttGeGtk::action_inputfocus( GtkWidget *w, GdkEvent *event, gpointer data)
{
......@@ -147,6 +148,17 @@ void XttGeGtk::activate_value_input( GtkWidget *w, gpointer data)
g_free( text);
}
void XttGeGtk::confirm_reply( int ok)
{
if ( !confirm_open)
return;
g_object_set( confirm_widget, "visible", FALSE, NULL);
confirm_open = 0;
if ( ok)
graph->confirm_ok( current_confirm_object);
}
void XttGeGtk::activate_confirm_ok( GtkWidget *w, gpointer data)
{
XttGe *ge = (XttGe *)data;
......@@ -154,6 +166,8 @@ void XttGeGtk::activate_confirm_ok( GtkWidget *w, gpointer data)
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
ge->confirm_open = 0;
ge->graph->confirm_ok( ge->current_confirm_object);
if ( ge->eventlog_cb)
(ge->eventlog_cb)( ge->parent_ctx, ge, xttlog_eCategory_GeConfirmOk, 0, 0);
}
void XttGeGtk::activate_confirm_cancel( GtkWidget *w, gpointer data)
......@@ -162,6 +176,8 @@ void XttGeGtk::activate_confirm_cancel( GtkWidget *w, gpointer data)
ge->confirm_open = 0;
g_object_set( ((XttGeGtk *)ge)->confirm_widget, "visible", FALSE, NULL);
if ( ge->eventlog_cb)
(ge->eventlog_cb)( ge->parent_ctx, ge, xttlog_eCategory_GeConfirmCancel, 0, 0);
}
void XttGeGtk::activate_exit( GtkWidget *w, gpointer data)
......@@ -366,6 +382,7 @@ XttGeGtk::XttGeGtk( GtkWidget *xg_parent_wid, void *xg_parent_ctx, const char *x
graph->popup_menu_cb = &ge_popup_menu_cb;
graph->call_method_cb = &ge_call_method_cb;
graph->sound_cb = &ge_sound_cb;
graph->eventlog_cb = &ge_eventlog_cb;
//g_signal_connect( graph_form, "check_resize", G_CALLBACK(action_resize), this);
g_signal_connect( ((GraphGtk *)graph)->grow_widget, "size_allocate", G_CALLBACK(action_resize), this);
......
......@@ -58,6 +58,7 @@ class XttGeGtk : public XttGe {
void pop();
void set_size( int width, int height);
void create_confirm_dialog();
void confirm_reply( int ok);
static void ge_change_value_cb( void *ge_ctx, void *value_object, char *text);
static void confirm_cb( void *ge_ctx, void *confirm_object, char *text);
......
......@@ -34,6 +34,7 @@
#include "co_lng.h"
#include "xtt_ge.h"
#include "ge_graph.h"
#include "xtt_log.h"
void XttGe::graph_init_cb( void *client_data)
{
......@@ -140,6 +141,14 @@ int XttGe::ge_get_current_objects_cb( void *ge_ctx, pwr_sAttrRef **alist,
return 0;
}
void XttGe::ge_eventlog_cb( void *ge_ctx, void *data, unsigned int size)
{
XttGe *ge = (XttGe *)ge_ctx;
if ( ge->eventlog_cb)
(ge->eventlog_cb)( ge->parent_ctx, ge, xttlog_eCategory_Event, data, size);
}
void XttGe::message_cb( void *ctx, char severity, const char *msg)
{
((XttGe *)ctx)->message( severity, msg);
......@@ -188,6 +197,22 @@ void XttGe::swap( int mode)
graph->swap( mode);
}
void XttGe::event_exec( int type, void *event, unsigned int size)
{
switch ( type) {
case xttlog_eCategory_Event:
graph->event_exec( event, size);
break;
case xttlog_eCategory_GeConfirmOk:
confirm_reply( 1);
break;
case xttlog_eCategory_GeConfirmCancel:
confirm_reply( 0);
break;
default: ;
}
}
XttGe::XttGe( void *xg_parent_ctx, const char *xg_name, const char *xg_filename,
int xg_scrollbar, int xg_menu, int xg_navigator, int xg_width, int xg_height,
int x, int y, double scan_time, const char *object_name,
......@@ -200,7 +225,7 @@ XttGe::XttGe( void *xg_parent_ctx, const char *xg_name, const char *xg_filename,
current_confirm_object(0), value_input_open(0), confirm_open(0),
command_cb(xg_command_cb), close_cb(0), help_cb(0), display_in_xnav_cb(0),
is_authorized_cb(xg_is_authorized_cb), popup_menu_cb(0), call_method_cb(0),
get_current_objects_cb(xg_get_current_objects_cb), sound_cb(0),
get_current_objects_cb(xg_get_current_objects_cb), sound_cb(0), eventlog_cb(0),
width(xg_width), height(xg_height)
{
strcpy( filename, xg_filename);
......
......@@ -51,6 +51,7 @@ class XttGe {
unsigned long, unsigned long, char *);
int (*get_current_objects_cb)(void *, pwr_sAttrRef **, int **);
int (*sound_cb)(void *, pwr_tAttrRef *);
void (*eventlog_cb)(void *, void *, int, void *, unsigned int);
int width;
int height;
......@@ -65,6 +66,7 @@ class XttGe {
virtual void pop() {}
virtual void set_size( int width, int height) {}
virtual void confirm_reply( int ok) {}
void message( char severity, const char *msg);
void print();
......@@ -72,6 +74,7 @@ class XttGe {
int set_folder_index( const char *name, int idx);
int set_subwindow_source( const char *name, char *source);
void swap( int mode);
void event_exec( int type, void *event, unsigned int size);
static void graph_init_cb( void *client_data);
static void graph_close_cb( void *client_data);
......@@ -87,6 +90,7 @@ class XttGe {
static int ge_is_authorized_cb( void *ge_ctx, unsigned int access);
static int ge_get_current_objects_cb( void *ge_ctx, pwr_sAttrRef **alist,
int **is_alist);
static void ge_eventlog_cb( void *ge_ctx, void *value, unsigned int size);
static void message_cb( void *ctx, char severity, const char *msg);
};
......
......@@ -38,7 +38,7 @@ using namespace std;
XttLog *XttLog::m_default_log = 0;
XttLog::XttLog( const char *filename) : m_level(1)
XttLog::XttLog( const char *filename, int event) : m_event(event), m_level(1)
{
char category_str[20];
......@@ -48,7 +48,7 @@ XttLog::XttLog( const char *filename) : m_level(1)
gdh_RegisterLogFunction( gdh_log_bc);
category_to_string(xttlog_eCategory_LogStart, category_str);
log( category_str, 0, 0, 0);
log( category_str, 0, 0, 0, 0);
}
void XttLog::delete_default()
......@@ -59,33 +59,59 @@ void XttLog::delete_default()
}
}
void XttLog::gdh_log_bc( char *name, void *value, unsigned int size)
void XttLog::value_to_octstring( const void *value, unsigned int value_size, char *str, unsigned int str_size)
{
char str[1000];
unsigned int strsize = sizeof(str);
unsigned int len = 0;
for ( unsigned int i = 0; i < size; i++) {
if ( i == size - 1) {
if ( len + 4 >= strsize)
for ( unsigned int i = 0; i < value_size; i++) {
if ( i == value_size - 1) {
if ( len + 4 >= str_size)
break;
len += sprintf( &str[i*5], "0x%02hhx", *(((unsigned char *)value)+i));
}
else {
if ( len + 5 >= strsize)
if ( len + 5 >= str_size)
break;
len += sprintf( &str[i*5], "0x%02hhx,", *(((unsigned char *)value)+i));
}
}
}
void XttLog::octstring_to_value( char *str, void *value, unsigned int size, unsigned int *value_size)
{
char *buf = (char *)value;
unsigned int len;
unsigned int i = 0;
while (1) {
len = sscanf( &str[i*5+1], "0x%2hhx", &buf[i]);
if ( len != 1)
break;
i++;
if ( str[i*5] != ',' || i >= size)
break;
}
*value_size = i;
}
void XttLog::gdh_log_bc( char *name, void *value, unsigned int size)
{
char str[1000];
value_to_octstring( value, size, str, sizeof(str));
dlog( xttlog_eCategory_SetObjectInfo, name, str, 0);
}
void XttLog::dlog( xttlog_eCategory category, const char *str, const char *value, unsigned int opt)
void XttLog::dlog( xttlog_eCategory category, const char *str, const char *value, unsigned int opt,
unsigned int size)
{
char category_str[40];
category_to_string(category, category_str);
if ( m_default_log)
m_default_log->log( category_str, str, value, opt);
if ( m_default_log) {
if ( !m_default_log->m_event && category == xttlog_eCategory_Event)
return;
m_default_log->log( category_str, str, value, opt, size);
}
}
......@@ -113,6 +139,15 @@ void XttLog::category_to_string( xttlog_eCategory category, char *str)
case xttlog_eCategory_LogStart:
strcpy( str, "LogStart");
break;
case xttlog_eCategory_Event:
strcpy( str, "Event");
break;
case xttlog_eCategory_GeConfirmOk:
strcpy( str, "GeConfirmOk");
break;
case xttlog_eCategory_GeConfirmCancel:
strcpy( str, "GeConfirmCancel");
break;
default:
strcpy( str, "");
}
......@@ -134,12 +169,18 @@ void XttLog::string_to_category( char *str, xttlog_eCategory *category)
*category = xttlog_eCategory_ApplDelete;
else if ( strcmp( str, "LogStart") == 0)
*category = xttlog_eCategory_LogStart;
else if ( strcmp( str, "Event") == 0)
*category = xttlog_eCategory_Event;
else if ( strcmp( str, "GeConfirmOk") == 0)
*category = xttlog_eCategory_GeConfirmOk;
else if ( strcmp( str, "GeConfirmCancel") == 0)
*category = xttlog_eCategory_GeConfirmCancel;
else
*category = xttlog_eCategory_;
}
void XttLog::log( const char *category, const char *str, const char *value,
unsigned int opt)
unsigned int opt, unsigned int size)
{
ofstream fp;
pwr_tStatus sts;
......@@ -178,8 +219,17 @@ void XttLog::log( const char *category, const char *str, const char *value,
fp << " ";
if ( str)
fp << str;
if ( value)
if ( value) {
if ( opt & xttlog_mOption_Binary) {
char str[1000];
value_to_octstring( value, size, str, sizeof(str));
fp << " \"" << str << "\"";
}
else
fp << " \"" << value << "\"";
}
fp << endl;
fp.close();
}
......@@ -214,6 +264,8 @@ int XttLog::play( XNav *xnav, char *filename, double speed, int pid)
if ( !fp)
return 0;
CoWow::SetAutoRemove( 1);
while( fp.getline( line, sizeof(line))) {
num = sscanf( line, "%d %s %s %d %s %s", &ind, t1, t2, &lpid, type, user);
......@@ -260,23 +312,14 @@ int XttLog::play( XNav *xnav, char *filename, double speed, int pid)
break;
}
case xttlog_eCategory_SetObjectInfo: {
unsigned int len;
unsigned char buf[500];
int size;
unsigned int size;
pwr_tStatus sts;
sscanf( s, "%s %s", attr, value);
unsigned int i = 0;
while (1) {
len = sscanf( &value[i*5+1], "0x%2hhx", &buf[i]);
if ( len != 1)
break;
i++;
if ( value[i*5] != ',' || i >= sizeof(buf))
break;
}
size = i;
octstring_to_value( value, buf, sizeof(buf), &size);
if ( size) {
sts = gdh_SetObjectInfo( attr, buf, size);
if ( EVEN(sts)) {
......@@ -286,6 +329,51 @@ int XttLog::play( XNav *xnav, char *filename, double speed, int pid)
printf( "%8.3f %-14s %9d %s %s\n", diff_time_f, type, sts, attr, value);
break;
}
case xttlog_eCategory_Event: {
unsigned char buf[500];
unsigned int size;
pwr_tStatus sts;
char graph[600];
pwr_tAName instance;
char *t;
sts = 0;
sscanf( s, "%s %s", graph, value);
octstring_to_value( value, buf, sizeof(buf), &size);
t = strchr( graph, ':');
if ( !t) break;
*t = 0;
strcpy( instance, t+1);
xnav->ge_event_exec( xttlog_eCategory_Event, graph, instance, buf, size);
printf( "%8.3f %-14s %9d %s %10.10s\n", diff_time_f, type, sts, graph, value);
break;
}
case xttlog_eCategory_GeConfirmOk:
case xttlog_eCategory_GeConfirmCancel: {
pwr_tStatus sts;
char graph[600];
pwr_tAName instance;
char *t;
sts = 0;
strcpy( graph, s);
t = strchr( graph, ':');
if ( !t) break;
*t = 0;
strcpy( instance, t+1);
xnav->ge_event_exec( category, graph, instance, 0, 0);
printf( "%8.3f %-14s %9d %s\n", diff_time_f, type, sts, graph);
break;
}
case xttlog_eCategory_LogStart:
printf( "%8.3f %-14s\n", diff_time_f, type);
break;
......@@ -297,6 +385,7 @@ int XttLog::play( XNav *xnav, char *filename, double speed, int pid)
first = 0;
}
CoWow::SetAutoRemove( 0);
printf( " %-14s\n", "EndOfFile");
return 1;
}
......@@ -34,9 +34,15 @@ typedef enum {
xttlog_eCategory_ApplDelete,
xttlog_eCategory_SetObjectInfo,
xttlog_eCategory_LogStart,
xttlog_eCategory__,
xttlog_eCategory_Event,
xttlog_eCategory_GeConfirmOk,
xttlog_eCategory_GeConfirmCancel,
xttlog_eCategory__
} xttlog_eCategory;
typedef enum {
xttlog_mOption_Binary = 1 << 0
} xttlog_mOption;
class XttLog;
class XNav;
......@@ -44,6 +50,7 @@ class XNav;
class XttLog
{
pwr_tFileName m_filename;
int m_event;
int m_level;
char m_pid[40];
static XttLog *m_default_log;
......@@ -56,20 +63,23 @@ class XttLog
m_level = 1;
}
XttLog( const char *filename);
XttLog( const char *filename, int event);
~XttLog() { if ( this == m_default_log) m_default_log = 0;}
void set_default() { m_default_log = this;}
void log( const char *category, const char *str, const char *value,
unsigned int opt);
unsigned int opt, unsigned int size);
static void dlog( xttlog_eCategory category, const char *str, const char *value, unsigned int opt = 0);
static void dlog( xttlog_eCategory category, const char *str, const char *value, unsigned int opt = 0,
unsigned int size = 0);
static void category_to_string( xttlog_eCategory category, char *str);
static void string_to_category( char *str, xttlog_eCategory *category);
static void dpush() {
if ( m_default_log) m_default_log->push();}
static void dpull() {
if ( m_default_log) m_default_log->pull();}
static void value_to_octstring( const void *value, unsigned int value_size, char *str, unsigned int str_size);
static void octstring_to_value( char *str, void *value, unsigned int size, unsigned int *value_size);
static void gdh_log_bc( char *name, void *buf, unsigned int bufsize);
static int play( XNav *xnav, char *filename, double speed, int pid);
static void delete_default();
......
......@@ -3724,6 +3724,20 @@ int ApplList::find( applist_eType type, const char *name, const char *instance,
return 0;
}
int ApplList::find( applist_eType type, void *ctx, char *name, char *instance)
{
ApplListElem *elem;
for ( elem = root; elem; elem = elem->next) {
if ( elem->type == type && elem->ctx == ctx) {
strcpy( instance, elem->instance);
strcpy( name, elem->name);
return 1;
}
}
return 0;
}
void ApplList::swap( int mode)
{
ApplListElem *elem;
......
......@@ -216,6 +216,7 @@ class ApplList {
int find( applist_eType type, const char *name, const char *instance, void **ctx);
int find( applist_eType type, pwr_sAttrRef *arp, void **ctx);
int find( applist_eType type, pwr_tObjid objid, void **ctx);
int find( applist_eType type, void *ctx, char *name, char *instance);
void swap( int mode);
};
......@@ -496,6 +497,7 @@ class XNav {
int exec_xttgraph( pwr_tObjid xttgraph, char *instance,
char *focus, int inputempty,
int use_default_access, unsigned int access);
void ge_event_exec( int type, char *name, char *instance, void *event, unsigned int size);
int set_parameter( char *name_str, char *value_str, int bypass);
void open_rttlog( char *name, char *filename);
int search( char *search_str, int regexp);
......
......@@ -130,6 +130,7 @@ static int xnav_ev_sound_cb( void *xnav, pwr_sAttrRef *arp);
static void xnav_ev_pop_cb( void *xnav);
static void xnav_ev_update_info_cb( void *xnav);
static int xnav_ge_sound_cb( void *xnav, pwr_sAttrRef *arp);
static void xnav_ge_eventlog_cb( void *xnav, void *gectx, void *value, unsigned int size);
static void xnav_ge_display_in_xnav_cb( void *xnav, pwr_sAttrRef *arp);
static int xnav_ge_is_authorized_cb( void *xnav, unsigned int access);
static int xnav_attribute_func (
......@@ -389,7 +390,7 @@ dcli_tCmdTable xnav_command_table[] = {
{
"OPLOG",
&xnav_oplog_func,
{ "dcli_arg1", "/FILE", "/SPEED", "/PID", ""}
{ "dcli_arg1", "/FILE", "/SPEED", "/PID", "/EVENT", ""}
},
{"",}};
......@@ -2601,10 +2602,12 @@ static int xnav_open_func( void *client_data,
return XNAV__SUCCESS;
}
if ( ODD( dcli_get_qualifier( "dcli_arg2", file_str, sizeof(file_str)))) {
#if 0
if ( file_str[0] == '/') {
xnav->message('E', "Syntax error");
return XNAV__HOLDCOMMAND;
}
#endif
// Get base class graphs on $pwr_exe
cdh_ToLower( fname, file_str);
......@@ -2678,8 +2681,14 @@ static int xnav_open_func( void *client_data,
cdh_mName_pathStrict);
if ( EVEN(sts)) return sts;
}
else {
if ( file_str[0] == '/') {
char *t = strrchr( file_str, '/');
strncpy( name_str, t+1, sizeof(name_str));
}
else
strcpy( name_str, file_str);
strncpy( name_str, file_str, sizeof(name_str));
}
}
if ( ODD( dcli_get_qualifier( "/FOCUS", focus_str, sizeof(focus_str))))
focus_p = focus_str;
......@@ -3720,10 +3729,12 @@ static int xnav_close_func( void *client_data,
// Command is "CLOSE GRAPH"
if ( ODD( dcli_get_qualifier( "dcli_arg2", file_str, sizeof(file_str)))) {
#if 0
if ( file_str[0] == '/') {
xnav->message('E', "Syntax error");
return XNAV__HOLDCOMMAND;
char *t = strrchr( file_str, '/');
cdh_Strcpy( file_str, t+1);
}
#endif
}
else if ( classgraph) {
// Get file from class of instance object
......@@ -5566,11 +5577,13 @@ static int xnav_oplog_func(void *client_data,
if ( cdh_NoCaseStrncmp( arg1_str, "START", strlen( arg1_str)) == 0) {
pwr_tFileName file_str;
int event = ODD( dcli_get_qualifier( "/EVENT", 0, 0));
if ( EVEN( dcli_get_qualifier( "/FILE", file_str, sizeof(file_str)))) {
strcpy( file_str, xttlog_cLogFile);
}
XttLog *log = new XttLog( file_str);
XttLog *log = new XttLog( file_str, event);
XttLog::delete_default();
log->set_default();
......@@ -7115,6 +7128,22 @@ static int xnav_ge_sound_cb( void *xnav, pwr_sAttrRef *arp)
return ((XNav *)xnav)->sound( arp);
}
static void xnav_ge_eventlog_cb( void *xnav, void *gectx, int type, void *data, unsigned int size)
{
int sts;
char name[80];
pwr_tAName instance;
char text[600];
sts = ((XNav *)xnav)->appl.find( applist_eType_Graph, gectx, name, instance);
if ( ODD(sts)) {
strcpy( text, name);
strcat( text, ":");
strcat( text, instance);
XttLog::dlog( (xttlog_eCategory) type, text, (const char *)data, xttlog_mOption_Binary, size);
}
}
static void xnav_ev_pop_cb( void *xnav)
{
if (((XNav *)xnav)->op)
......@@ -7177,6 +7206,7 @@ void XNav::open_graph( const char *name, const char *filename, int scrollbar, in
gectx->popup_menu_cb = xnav_popup_menu_cb;
gectx->call_method_cb = xnav_call_method_cb;
gectx->sound_cb = xnav_ge_sound_cb;
gectx->eventlog_cb = xnav_ge_eventlog_cb;
appl.insert( applist_eType_Graph, (void *)gectx, pwr_cNObjid, filename,
object_name);
......@@ -7259,6 +7289,17 @@ int XNav::exec_xttgraph( pwr_tObjid xttgraph, char *instance,
return XNAV__SUCCESS;
}
void XNav::ge_event_exec( int type, char *name, char *instance, void *event, unsigned int size)
{
int sts;
XttGe *gectx;
sts = appl.find( applist_eType_Graph, name, instance, (void **)&gectx);
if ( ODD(sts)) {
gectx->event_exec( type, event, size);
}
}
static int xnav_op_get_alarm_info_cb( void *xnav, evlist_sAlarmInfo *info)
{
if ( ((XNav *)xnav)->ev)
......
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