Commit 030616ca authored by claes's avatar claes

New SystemMessage window

parent fcfd70dd
...@@ -103,6 +103,7 @@ static xnav_sStartMenu system_menu[] = { ...@@ -103,6 +103,7 @@ static xnav_sStartMenu system_menu[] = {
{ "PlcThread", xnav_eItemType_Command, (void *) "show plcthread"}, { "PlcThread", xnav_eItemType_Command, (void *) "show plcthread"},
{ "PlcPgm", xnav_eItemType_Command, (void *) "show plcpgm"}, { "PlcPgm", xnav_eItemType_Command, (void *) "show plcpgm"},
{ "Logging", xnav_eItemType_Menu, (void *)&logging_menu}, { "Logging", xnav_eItemType_Menu, (void *)&logging_menu},
{ "System Messages", xnav_eItemType_Command, (void *) "open consolelog"},
{ "", 0, NULL}}; { "", 0, NULL}};
static xnav_sStartMenu root_menu[] = { static xnav_sStartMenu root_menu[] = {
{ "Database", xnav_eItemType_Command, (void *) "show database"}, { "Database", xnav_eItemType_Command, (void *) "show database"},
......
/* xtt_clog.cpp -- Alarm and event window in xtt
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
extern "C" {
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
}
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/cursorfont.h>
#include <Xm/ToggleB.h>
#include <Xm/List.h>
extern "C" {
#include "flow_x.h"
}
#include "co_lng.h"
#include "co_wow.h"
#include "xtt_clog.h"
#include "rt_xnav_msg.h"
static void clog_action_inputfocus( Widget w, XmAnyCallbackStruct *data);
static void clog_activate_exit( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_select_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_next_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_prev_file( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_zoom_in( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_zoom_out( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_zoom_reset( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_filter( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_help( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_activate_helpmsg( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_create_form( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_filter_tog_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_filter_string_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_filter_act_but_cb( Widget w, CLog *clog);
static void clog_filesel_list_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data);
static void clog_filesel_ok_cb( Widget w, CLog *clog);
static void clog_filesel_cancel_cb( Widget w, CLog *clog);
CLog::CLog(
void *clog_parent_ctx,
Widget clog_parent_wid,
char *clog_name,
pwr_tStatus *status) :
parent_ctx(clog_parent_ctx), parent_wid(clog_parent_wid),
clognav(NULL), clog_displayed(0), help_cb(0), close_cb(0), filesel_loaded(false),
clock_cursor(0)
{
char uid_filename[120] = {"xtt_clog.uid"};
char *uid_filename_p = uid_filename;
Arg args[20];
pwr_tStatus sts;
int i;
MrmHierarchy s_DRMh;
MrmType dclass;
static char clog_translations[] =
"<FocusIn>: clog_inputfocus()\n";
static XtTranslations clog_compiled_translations = NULL;
static XtActionsRec clog_actions[] =
{
{"clog_inputfocus", (XtActionProc) clog_action_inputfocus}
};
static MrmRegisterArg reglist[] = {
{ "clog_ctx", 0 },
{"clog_activate_exit",(caddr_t)clog_activate_exit },
{"clog_activate_select_file",(caddr_t)clog_activate_select_file },
{"clog_activate_next_file",(caddr_t)clog_activate_next_file },
{"clog_activate_prev_file",(caddr_t)clog_activate_prev_file },
{"clog_activate_zoom_in",(caddr_t)clog_activate_zoom_in },
{"clog_activate_zoom_out",(caddr_t)clog_activate_zoom_out },
{"clog_activate_zoom_reset",(caddr_t)clog_activate_zoom_reset },
{"clog_activate_filter",(caddr_t)clog_activate_filter },
{"clog_activate_help",(caddr_t)clog_activate_help },
{"clog_activate_helpmsg",(caddr_t)clog_activate_helpmsg },
{"clog_create_form",(caddr_t)clog_create_form },
{"clog_filter_tog_cr",(caddr_t)clog_filter_tog_cr },
{"clog_filter_string_cr",(caddr_t)clog_filter_string_cr },
{"clog_filter_act_but_cb",(caddr_t)clog_filter_act_but_cb },
{"clog_filesel_ok_cb",(caddr_t)clog_filesel_ok_cb },
{"clog_filesel_cancel_cb",(caddr_t)clog_filesel_cancel_cb },
{"clog_filesel_list_cr",(caddr_t)clog_filesel_list_cr }
};
static int reglist_num = (sizeof reglist / sizeof reglist[0]);
*status = 1;
Lng::get_uid( uid_filename, uid_filename);
reglist[0].value = (caddr_t) this;
// Motif
MrmInitialize();
// Save the context structure in the widget
i = 0;
XtSetArg(args[i], XmNuserData, (unsigned int) this);i++;
XtSetArg(args[i], XmNdeleteResponse, XmDO_NOTHING);i++;
sts = MrmOpenHierarchy( 1, &uid_filename_p, NULL, &s_DRMh);
if (sts != MrmSUCCESS) printf("can't open %s\n", uid_filename);
MrmRegisterNames(reglist, reglist_num);
parent_wid_clog = XtCreatePopupShell( clog_name,
topLevelShellWidgetClass, parent_wid, args, i);
sts = MrmFetchWidgetOverride( s_DRMh, "clog_window", parent_wid_clog,
clog_name, args, 1, &toplevel, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch %s\n", clog_name);
sts = MrmFetchWidget(s_DRMh, "filterForm", toplevel,
&filter_form, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch filter dialog\n");
sts = MrmFetchWidget(s_DRMh, "fileselForm", toplevel,
&filesel_form, &dclass);
if (sts != MrmSUCCESS) printf("can't fetch filesel dialog\n");
MrmCloseHierarchy(s_DRMh);
if ( clog_compiled_translations == NULL)
{
XtAppAddActions( XtWidgetToApplicationContext( toplevel),
clog_actions, XtNumber(clog_actions));
clog_compiled_translations = XtParseTranslationTable( clog_translations);
}
XtOverrideTranslations( toplevel, clog_compiled_translations);
i = 0;
XtSetArg(args[i],XmNwidth,1000);i++;
XtSetArg(args[i],XmNheight,800);i++;
XtSetValues( toplevel ,args,i);
XtManageChild( toplevel);
// Create clognav
clognav = new CLogNav( this, form_clog, &clognav_widget);
XtPopup( parent_wid_clog, XtGrabNone);
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb( parent_wid_clog,
(XtCallbackProc)clog_activate_exit, this);
*status = 1;
}
//
// Delete clog
//
CLog::~CLog()
{
free_cursor();
XtDestroyWidget( parent_wid_clog);
delete clognav;
}
void CLog::pop()
{
flow_UnmapWidget( parent_wid_clog);
flow_MapWidget( parent_wid_clog);
}
void CLog::set_clock_cursor()
{
if ( !clock_cursor)
clock_cursor = XCreateFontCursor( flow_Display(toplevel), XC_watch);
XDefineCursor( flow_Display(toplevel), flow_Window(toplevel), clock_cursor);
XFlush( flow_Display(toplevel));
}
void CLog::reset_cursor()
{
XUndefineCursor( flow_Display(toplevel), flow_Window(toplevel));
}
void CLog::free_cursor()
{
if (clock_cursor)
XFreeCursor( flow_Display(toplevel), clock_cursor);
}
static void clog_action_inputfocus( Widget w, XmAnyCallbackStruct *data)
{
Arg args[1];
CLog *clog;
XtSetArg (args[0], XmNuserData, &clog);
XtGetValues (w, args, 1);
if ( clog && clog->clog_displayed)
clog->clognav->set_input_focus();
}
static void clog_activate_exit( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
if ( clog->close_cb)
(clog->close_cb)( clog->parent_ctx);
else
delete clog;
}
static void clog_activate_zoom_in( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->zoom( 1.2);
}
static void clog_activate_zoom_out( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->zoom( 5.0/6);
}
static void clog_activate_zoom_reset( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->clognav->unzoom();
}
static void clog_activate_filter( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
bool success, info, warning, error, fatal, text;
clog->clognav->get_filter( &success, &info, &warning, &error, &fatal, &text);
XmToggleButtonSetState(clog->show_success_w, success, 0);
XmToggleButtonSetState(clog->show_info_w, info, 0);
XmToggleButtonSetState(clog->show_warning_w, warning, 0);
XmToggleButtonSetState(clog->show_error_w, error, 0);
XmToggleButtonSetState(clog->show_fatal_w, fatal, 0);
XmToggleButtonSetState(clog->show_text_w, text, 0);
XtManageChild( clog->filter_form);
}
static void clog_activate_select_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
XmString cstr;
char str[200];
char *s;
if ( !clog->filesel_loaded) {
for ( int i = 0; i < (int) clog->clognav->file_list.size(); i++) {
time_AtoAscii( &clog->clognav->file_list[i].time, time_eFormat_ComprDateAndTime,
str, sizeof(str));
str[17] = 0;
strcat( str, " ");
s = strrchr( clog->clognav->file_list[i].name, '/');
if ( s)
strcat( str, s+1);
else
strcat( str, clog->clognav->file_list[i].name);
cstr = XmStringCreateSimple( str);
XmListAddItemUnselected( clog->filesel_list_w, cstr, 0);
XmStringFree(cstr);
}
clog->filesel_loaded = true;
}
XtManageChild( clog->filesel_form);
}
static void clog_activate_next_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->set_clock_cursor();
if ( !clog->clognav->next_file())
wow_DisplayError( clog->toplevel, "File error", "No next file found");
clog->reset_cursor();
}
static void clog_activate_prev_file( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->set_clock_cursor();
if ( !clog->clognav->prev_file())
wow_DisplayError( clog->toplevel, "File error", "No previous file found");
clog->reset_cursor();
}
static void clog_activate_help( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
if ( clog->help_cb)
(clog->help_cb)( clog->parent_ctx, "consolelog");
}
static void clog_activate_helpmsg( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
}
static void clog_create_form( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->form_clog = w;
}
static void clog_filter_string_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->filter_string_w = w;
}
static void clog_filter_tog_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
int key;
XtVaGetValues (w, XmNuserData, &key, NULL);
switch (key) {
case 1:
// Success
clog->show_success_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 2:
// Info
clog->show_info_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 3:
// Warning
clog->show_warning_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 4:
// Error
clog->show_error_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 5:
// Fatal
clog->show_fatal_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
case 6:
// Text
clog->show_text_w = w;
XmToggleButtonSetState(w, 1, 0);
break;
default:
break;
}
}
static void clog_filter_act_but_cb( Widget w, CLog *clog)
{
int key;
char *str;
bool success = XmToggleButtonGetState( clog->show_success_w);
bool info = XmToggleButtonGetState( clog->show_info_w);
bool warning = XmToggleButtonGetState( clog->show_warning_w);
bool error = XmToggleButtonGetState( clog->show_error_w);
bool fatal = XmToggleButtonGetState( clog->show_fatal_w);
bool text = XmToggleButtonGetState( clog->show_text_w);
str = XmTextGetString( clog->filter_string_w);
XtVaGetValues(w, XmNuserData, &key, NULL);
switch (key) {
case 1 :
// Ok
XtUnmanageChild( clog->filter_form);
case 2 :
// Apply
clog->set_clock_cursor();
clog->clognav->set_filter( success, info, warning, error, fatal, text, str);
clog->reset_cursor();
break;
case 3 :
// Cancel
XtUnmanageChild( clog->filter_form);
break;
}
}
static void clog_filesel_list_cr( Widget w, CLog *clog, XmAnyCallbackStruct *data)
{
clog->filesel_list_w = w;
}
static void clog_filesel_ok_cb( Widget w, CLog *clog)
{
int *pos_list, pos_cnt;
int key;
if (XmListGetSelectedPos( clog->filesel_list_w, &pos_list, &pos_cnt)) {
clog->set_clock_cursor();
clog->clognav->read( pos_list, pos_cnt);
clog->reset_cursor();
}
XtVaGetValues (w, XmNuserData, &key, NULL);
switch (key) {
case 1:
XtUnmanageChild( clog->filesel_form);
}
}
static void clog_filesel_cancel_cb( Widget w, CLog *clog)
{
XtUnmanageChild( clog->filesel_form);
}
#ifndef xtt_clog_h
#define xtt_clog_h
/* xtt_clog.h -- Alarm and event windows in xtt
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#if defined __cplusplus
extern "C" {
#endif
#ifndef pwr_h
# include "pwr.h"
#endif
#if defined __cplusplus
}
#endif
#ifndef xtt_clognav
# include "xtt_clognav.h"
#endif
class CLog {
public:
CLog(
void *clog_parent_ctx,
Widget clog_parent_wid,
char *clog_name,
pwr_tStatus *status);
~CLog();
void *parent_ctx;
Widget parent_wid;
Widget parent_wid_clog;
char name[80];
Widget toplevel;
Widget form_clog;
Widget clognav_widget;
Widget filter_form;
Widget show_success_w;
Widget show_info_w;
Widget show_warning_w;
Widget show_error_w;
Widget show_fatal_w;
Widget show_text_w;
Widget filter_string_w;
Widget filesel_form;
Widget filesel_list_w;
CLogNav *clognav;
int clog_displayed;
void (*help_cb)( void *, char *);
void (*close_cb)( void *);
bool filesel_loaded;
int clock_cursor;
void pop();
void set_clock_cursor();
void reset_cursor();
void free_cursor();
};
#endif
/* xtt_evlist.cpp -- Console message window.
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
extern "C" {
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_syi.h"
}
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
// Status is defined as int i xlib...
#ifdef Status
# undef Status
#endif
extern "C" {
#include "flow_x.h"
#include "co_mrm_util.h"
}
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget.h"
#include "xtt_clognav.h"
#include "xtt_menu.h"
#include "xnav_bitmap_leaf12.h"
#include "xnav_bitmap_map12.h"
#include "xnav_bitmap_openmap12.h"
static int clognav_init_brow_cb( FlowCtx *fctx, void *client_data);
static int clognav_brow_cb( FlowCtx *ctx, flow_tEvent event);
//
// Free pixmaps
//
void CLogNavBrow::free_pixmaps()
{
brow_FreeAnnotPixmap( ctx, pixmap_leaf);
brow_FreeAnnotPixmap( ctx, pixmap_map);
brow_FreeAnnotPixmap( ctx, pixmap_openmap);
}
//
// Create pixmaps for leaf, closed map and open map
//
void CLogNavBrow::allocate_pixmaps()
{
flow_sPixmapData pixmap_data;
int i;
for ( i = 0; i < 9; i++)
{
pixmap_data[i].width =xnav_bitmap_leaf12_width;
pixmap_data[i].height =xnav_bitmap_leaf12_height;
pixmap_data[i].bits = (char *)xnav_bitmap_leaf12_bits;
}
brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_leaf);
for ( i = 0; i < 9; i++)
{
pixmap_data[i].width =xnav_bitmap_map12_width;
pixmap_data[i].height =xnav_bitmap_map12_height;
pixmap_data[i].bits = (char *)xnav_bitmap_map12_bits;
}
brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_map);
for ( i = 0; i < 9; i++)
{
pixmap_data[i].width =xnav_bitmap_openmap12_width;
pixmap_data[i].height =xnav_bitmap_openmap12_height;
pixmap_data[i].bits = (char *)xnav_bitmap_openmap12_bits;
}
brow_AllocAnnotPixmap( ctx, &pixmap_data, &pixmap_openmap);
}
//
// Create nodeclasses
//
void CLogNavBrow::create_nodeclasses()
{
allocate_pixmaps();
// Create common-class
brow_CreateNodeClass( ctx, "EventDefault",
flow_eNodeGroup_Common, &nc_event);
brow_AddFrame( nc_event, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddAnnot( nc_event, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnotPixmap( nc_event, 0, 1.6, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnotPixmap( nc_event, 1, 2.2, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnot( nc_event, 3.3, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_event, 10, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_event, 26, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
// Nodeclass for Info message
brow_CreateNodeClass( ctx, "InfoMsg",
flow_eNodeGroup_Common, &nc_msg_info);
brow_AddFrame( nc_msg_info, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddFilledRect( nc_msg_info, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Green);
brow_AddRect( nc_msg_info, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_msg_info, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_info, 2, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_info, 8, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_info, 11, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_info, 18, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
// Nodeclass for Warning message
brow_CreateNodeClass( ctx, "WarningMsg",
flow_eNodeGroup_Common, &nc_msg_warning);
brow_AddFrame( nc_msg_warning, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddFilledRect( nc_msg_warning, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Yellow);
brow_AddRect( nc_msg_warning, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_msg_warning, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_warning, 2, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_warning, 8, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_warning, 11, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_warning, 18, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
// Nodeclass for Error message
brow_CreateNodeClass( ctx, "ErrorMsg",
flow_eNodeGroup_Common, &nc_msg_error);
brow_AddFrame( nc_msg_error, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddFilledRect( nc_msg_error, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_LineRed);
brow_AddRect( nc_msg_error, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_msg_error, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_error, 2, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_error, 8, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_error, 11, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_error, 18, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
// Nodeclass for Fatal messages
brow_CreateNodeClass( ctx, "FatalMsg",
flow_eNodeGroup_Common, &nc_msg_fatal);
brow_AddFrame( nc_msg_fatal, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddFilledRect( nc_msg_fatal, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_LineRed);
brow_AddRect( nc_msg_fatal, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 4, 0);
brow_AddAnnot( nc_msg_fatal, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_fatal, 2, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_fatal, 8, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_fatal, 11, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_msg_fatal, 18, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
// Nodeclass for Proview restart
brow_CreateNodeClass( ctx, "Restart",
flow_eNodeGroup_Common, &nc_restart);
brow_AddFrame( nc_restart, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddFilledRect( nc_restart, 0, 0, 48, 0.8, flow_eDrawType_Yellow);
brow_AddAnnot( nc_restart, 11, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_restart, 18, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_CreateNodeClass( ctx, "Text",
flow_eNodeGroup_Common, &nc_text);
brow_AddFrame( nc_text, 0, 0, 35, 0.8, flow_eDrawType_Line, -1, 1);
brow_AddRect( nc_text, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_text, 18, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
}
void CLogNavBrow::brow_setup()
{
brow_sAttributes brow_attr;
unsigned long mask;
mask = 0;
mask |= brow_eAttr_indentation;
brow_attr.indentation = 0.5;
mask |= brow_eAttr_annotation_space;
brow_attr.annotation_space = 0.5;
brow_SetAttributes( ctx, &brow_attr, mask);
brow_SetCtxUserData( ctx, clognav);
brow_EnableEvent( ctx, flow_eEvent_MB1Click, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_MB1DoubleClick, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_MB3Press, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_MB3Down, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_SelectClear, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_ObjectDeleted, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Key_Up, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Key_Down, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Key_Right, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Key_Left, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Key_PF3, flow_eEventType_CallBack,
clognav_brow_cb);
brow_EnableEvent( ctx, flow_eEvent_Radiobutton, flow_eEventType_CallBack,
clognav_brow_cb);
}
//
// Backcall routine called at creation of the brow widget
// Enable event, create nodeclasses and insert the root objects.
//
static int clognav_init_brow_cb( FlowCtx *fctx, void *client_data)
{
int start_idx = 1;
CLogNav *clognav = (CLogNav *) client_data;
BrowCtx *ctx = (BrowCtx *)fctx;
clognav->brow = new CLogNavBrow( ctx, (void *)clognav);
clognav->brow->brow_setup();
clognav->brow->create_nodeclasses();
clognav->get_files();
clognav->read( &start_idx, 1);
return 1;
}
CLogNav::CLogNav(
void *clog_parent_ctx,
Widget clog_parent_wid,
Widget *w) :
parent_ctx(clog_parent_ctx), parent_wid(clog_parent_wid),
clog_size(0), max_size(10000), current_pos_high(0),
current_pos_low(0)
{
form_widget = ScrolledBrowCreate( parent_wid, "CLogNav", NULL, 0,
clognav_init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
*w = form_widget;
}
//
// Delete ev
//
CLogNav::~CLogNav()
{
delete brow;
XtDestroyWidget( form_widget);
}
CLogNavBrow::~CLogNavBrow()
{
free_pixmaps();
}
void CLogNav::set_filter( bool success, bool info, bool warning, bool error, bool fatal,
bool text, char *str)
{
filter.show_success = success;
filter.show_info = info;
filter.show_warning = warning;
filter.show_error = error;
filter.show_fatal = fatal;
filter.show_text = text;
strcpy( filter.str, str);
draw();
}
void CLogNav::get_filter( bool *success, bool *info, bool *warning, bool *error,
bool *fatal, bool *text)
{
*success = filter.show_success;
*info = filter.show_info;
*warning = filter.show_warning;
*error = filter.show_error;
*fatal = filter.show_fatal;
*text = filter.show_text;
}
void CLogNav::get_files()
{
char nodename[40];
pwr_tStatus sts;
char file_spec[200];
char found_file[200];
pwr_tTime time = {0,0};
struct stat info;
syi_NodeName( &sts, nodename, sizeof(nodename));
sprintf( file_spec, "$pwrp_log/pwr_%s.log", nodename);
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
if ( ODD(sts)) {
stat( found_file, &info);
time.tv_sec = info.st_ctime;
CLogFile *cf = new CLogFile( found_file, time);
file_list.push_back( *cf);
delete cf;
}
else {
CLogFile *cf = new CLogFile();
file_list.push_back( *cf);
delete cf;
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
sprintf( file_spec, "$pwrp_log/pwr_%s.log.*.gz", nodename);
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_INIT);
while ( ODD(sts)) {
stat( found_file, &info);
time.tv_sec = info.st_ctime;
CLogFile *cf = new CLogFile( found_file, time);
file_list.push_back( *cf);
delete cf;
sts = dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_NEXT);
}
dcli_search_file( file_spec, found_file, DCLI_DIR_SEARCH_END);
}
int CLogNav::next_file()
{
if ( current_pos_low <= 1)
return 0;
int pos = current_pos_low - 1;
read( &pos, 1);
return 1;
}
int CLogNav::prev_file()
{
if ( current_pos_high >= (int)file_list.size())
return 0;
int pos = current_pos_high + 1;
read( &pos, 1);
return 1;
}
void CLogNav::read( int *pos_list, int pos_cnt)
{
char line[400];
errh_eSeverity severity;
pwr_tTime time;
pwr_tTime ztime = {0,0};
char time_str[40];
char logger[40];
int pid;
int sts;
FILE *fp;
char filename[200];
CLogMsg *msg;
char tmpfile[200] = "/tmp/clog.tmp";
int found;
msg_list.clear();
current_pos_low = file_list.size();
current_pos_high = 0;
for ( int i = file_list.size() - 1; i >= 0; i--) {
found = 0;
for ( int j = 0; j < pos_cnt; j++) {
if ( pos_list[j] -1 == i) {
found = 1;
break;
}
}
if ( !found)
continue;
if ( i + 1 > current_pos_high)
current_pos_high = i + 1;
if ( i + 1 < current_pos_low)
current_pos_low = i + 1;
if ( i == 0) {
strcpy( filename, file_list[0].name);
if ( strcmp( filename, "") == 0)
continue;
}
else {
// Unzip the file
char cmd[300];
sprintf( cmd, "zcat %s > %s", file_list[i].name, tmpfile);
system( cmd);
strcpy( filename, tmpfile);
}
fp = fopen( filename, "r");
if ( !fp)
return;
while( 1) {
sts = dcli_read_line( line, sizeof(line), fp);
if ( !sts)
break;
if ( line[1] == ' ' && line[27] == ' ' &&
(line[0] == 'S' || line[0] == 'I' || line[0] == 'W' ||
line[0] == 'E' || line[0] == 'F')) {
switch ( line[0]) {
case 'S': severity = errh_eSeverity_Success; break;
case 'I': severity = errh_eSeverity_Info; break;
case 'W': severity = errh_eSeverity_Warning; break;
case 'E': severity = errh_eSeverity_Error; break;
case 'F': severity = errh_eSeverity_Fatal; break;
default: ;
}
strncpy( logger, &line[2], 18);
logger[18] = 0;
sts = sscanf( &line[22], "%d", &pid);
if ( sts != 1)
pid = 0;
strncpy( &time_str[2], &line[28], 20);
time_str[0] = '2';
time_str[1] = '0';
time_str[22] = 0;
time_FormAsciiToA( time_str, HUNDRED, GB, &time);
msg = new CLogMsg( severity, logger, pid, time, &line[49]);
msg_list.push_back(*msg);
delete msg;
}
else {
dcli_trim( line, line);
msg = new CLogMsg( errh_eSeverity_Null, "", 0, ztime, line);
msg_list.push_back(*msg);
delete msg;
}
}
fclose( fp);
if ( i != 0)
unlink( filename);
}
draw();
}
void CLogNav::draw()
{
ItemMsgBase *item;
brow_tNode dest = 0;
brow_SetNodraw( brow->ctx);
brow_DeleteAll( brow->ctx);
for ( int i = 0; i < (int)msg_list.size(); i++) {
if ( strncmp( msg_list[i].text, "Setting log file to:", 20) == 0) {
item = new ItemMsgRestart( this, "Restart", msg_list[i].time,
dest, flow_eDest_After);
dest = item->node;
}
bool insert = false;
switch ( msg_list[i].severity) {
case errh_eSeverity_Success:
if ( filter.show_success)
insert = true;
break;
case errh_eSeverity_Info:
if ( filter.show_info)
insert = true;
break;
case errh_eSeverity_Warning:
if ( filter.show_warning)
insert = true;
break;
case errh_eSeverity_Error:
if ( filter.show_error)
insert = true;
break;
case errh_eSeverity_Fatal:
if ( filter.show_fatal)
insert = true;
break;
case errh_eSeverity_Null:
if ( filter.show_text)
insert = true;
break;
}
if ( insert && strcmp( filter.str, "") != 0) {
if ( strstr( msg_list[i].logger, filter.str) == 0 &&
strstr( msg_list[i].text, filter.str) == 0)
insert = false;
}
if ( insert) {
item = new ItemMsg( this, "Msg",
msg_list[i].severity, msg_list[i].logger,
msg_list[i].pid, msg_list[i].time, msg_list[i].text,
dest, flow_eDest_After);
dest = item->node;
}
}
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
}
void CLogNav::set_input_focus()
{
if ( flow_IsViewable( brow_widget))
XtCallAcceptFocus( brow_widget, CurrentTime);
}
//
// Zoom
//
void CLogNav::zoom( double zoom_factor)
{
brow_Zoom( brow->ctx, zoom_factor);
}
//
// Return to base zoom factor
//
void CLogNav::unzoom()
{
brow_UnZoom( brow->ctx);
}
void CLogNav::set_nodraw()
{
brow_SetNodraw( brow->ctx);
}
void CLogNav::reset_nodraw()
{
brow_ResetNodraw( brow->ctx);
brow_Redraw( brow->ctx, 0);
}
//
// Callbacks from brow
//
static int clognav_brow_cb( FlowCtx *ctx, flow_tEvent event)
{
CLogNav *clognav;
ItemMsg *item;
if ( event->event == flow_eEvent_ObjectDeleted)
{
brow_GetUserData( event->object.object, (void **)&item);
delete item;
return 1;
}
brow_GetCtxUserData( (BrowCtx *)ctx, (void **) &clognav);
switch ( event->event)
{
case flow_eEvent_Key_Up:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
int sts;
brow_GetSelectedNodes( clognav->brow->ctx, &node_list, &node_count);
if ( !node_count)
{
sts = brow_GetLast( clognav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else
{
sts = brow_GetPrevious( clognav->brow->ctx, node_list[0], &object);
if ( EVEN(sts))
{
sts = brow_GetLast( clognav->brow->ctx, &object);
if ( EVEN(sts))
{
if ( node_count)
free( node_list);
return 1;
}
}
}
brow_SelectClear( clognav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( clognav->brow->ctx, object);
if ( !brow_IsVisible( clognav->brow->ctx, object))
brow_CenterObject( clognav->brow->ctx, object, 0.25);
if ( node_count)
free( node_list);
break;
}
case flow_eEvent_Key_Down:
{
brow_tNode *node_list;
int node_count;
brow_tObject object;
int sts;
brow_GetSelectedNodes( clognav->brow->ctx, &node_list, &node_count);
if ( !node_count)
{
sts = brow_GetFirst( clognav->brow->ctx, &object);
if ( EVEN(sts)) return 1;
}
else
{
sts = brow_GetNext( clognav->brow->ctx, node_list[0], &object);
if ( EVEN(sts))
{
sts = brow_GetFirst( clognav->brow->ctx, &object);
if ( EVEN(sts))
{
if ( node_count)
free( node_list);
return 1;
}
}
}
brow_SelectClear( clognav->brow->ctx);
brow_SetInverse( object, 1);
brow_SelectInsert( clognav->brow->ctx, object);
if ( !brow_IsVisible( clognav->brow->ctx, object))
brow_CenterObject( clognav->brow->ctx, object, 0.75);
if ( node_count)
free( node_list);
break;
}
case flow_eEvent_SelectClear:
brow_ResetSelectInverse( clognav->brow->ctx);
break;
case flow_eEvent_MB1Click:
// Select
switch ( event->object.object_type)
{
case flow_eObjectType_Node:
if ( brow_FindSelectedObject( clognav->brow->ctx, event->object.object))
{
brow_SelectClear( clognav->brow->ctx);
}
else
{
brow_SelectClear( clognav->brow->ctx);
brow_SetInverse( event->object.object, 1);
brow_SelectInsert( clognav->brow->ctx, event->object.object);
}
break;
default:
brow_SelectClear( clognav->brow->ctx);
}
break;
case flow_eEvent_MB3Down:
{
brow_SetClickSensitivity( clognav->brow->ctx,
flow_mSensitivity_MB3Press);
break;
}
default:
;
}
return 1;
}
ItemMsg::ItemMsg( CLogNav *item_clognav, char *item_name, errh_eSeverity item_severity,
char *item_logger, int item_pid,
pwr_tTime item_time, char *item_text,
brow_tNode dest, flow_eDest dest_code):
ItemMsgBase(item_clognav, item_name, dest),
severity(item_severity), pid(item_pid), time(item_time)
{
char type_str[2];
char time_str[40];
char pid_str[40];
strcpy( logger, item_logger);
strncpy( text, item_text, sizeof(text));
text[sizeof(text)-1] = 0;
switch ( severity) {
case errh_eSeverity_Success:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_msg_info,
dest, dest_code, (void *) this, 1, &node);
strcpy( type_str, "S");
break;
case errh_eSeverity_Info:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_msg_info,
dest, dest_code, (void *) this, 1, &node);
strcpy( type_str, "I");
break;
case errh_eSeverity_Warning:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_msg_warning,
dest, dest_code, (void *) this, 1, &node);
strcpy( type_str, "W");
break;
case errh_eSeverity_Error:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_msg_error,
dest, dest_code, (void *) this, 1, &node);
strcpy( type_str, "E");
break;
case errh_eSeverity_Fatal:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_msg_fatal,
dest, dest_code, (void *) this, 1, &node);
strcpy( type_str, "F");
break;
default:
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_text,
dest, dest_code, (void *) this, 1, &node);
brow_SetAnnotation( node, 0, text, strlen(text));
return;
}
sprintf( pid_str, "%5d", pid);
brow_SetAnnotation( node, 0, type_str, strlen(type_str));
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str,
sizeof(time_str));
brow_SetAnnotation( node, 1, logger, strlen(logger));
brow_SetAnnotation( node, 2, pid_str, strlen(pid_str));
brow_SetAnnotation( node, 3, time_str, strlen(time_str));
brow_SetAnnotation( node, 4, text, strlen(text));
// brow_SetAnnotPixmap( node, 0, clognav->brow->pixmap_leaf);
}
ItemMsgRestart::ItemMsgRestart( CLogNav *item_clognav, char *item_name,
pwr_tTime item_time,
brow_tNode dest, flow_eDest dest_code):
ItemMsgBase(item_clognav, item_name, dest),
time(item_time)
{
char time_str[40];
brow_CreateNode( clognav->brow->ctx, item_name, clognav->brow->nc_restart,
dest, dest_code, (void *) this, 1, &node);
time_AtoAscii( &time, time_eFormat_ComprDateAndTime, time_str,
sizeof(time_str));
brow_SetAnnotation( node, 0, time_str, strlen(time_str));
brow_SetAnnotation( node, 1, "Proview startup", strlen("Proview startup"));
}
#ifndef xtt_clognav_h
#define xtt_clognav_h
/* xtt_clognav.h -- Console message window.
PROVIEW/R
Copyright (C) 1996 by Comator Process AB.
<Description>. */
// Status is defined as int i xlib...
#include <vector>
using namespace std;
#ifdef Status
# undef Status
#endif
#if defined __cplusplus
extern "C" {
#endif
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef rt_errh_h
# include "rt_errh.h"
#endif
#if defined __cplusplus
}
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browctx.h"
#endif
#ifndef flow_browapi_h
#include "flow_browapi.h"
#endif
typedef enum {
clognav_eItemType_Msg,
clognav_eItemType_Restart
} clognav_eItemType;
class CLogNavFilter {
public:
CLogNavFilter() :
show_success(true), show_info(true), show_warning(true), show_error(true),
show_fatal(true), show_text(true)
{ strcpy( str, "");}
bool show_success;
bool show_info;
bool show_warning;
bool show_error;
bool show_fatal;
bool show_text;
char str[200];
};
class CLogNavBrow {
public:
CLogNavBrow( BrowCtx *brow_ctx, void *evl) : ctx(brow_ctx), clognav(evl) {};
~CLogNavBrow();
BrowCtx *ctx;
void *clognav;
brow_tNodeClass nc_event;
brow_tNodeClass nc_msg_info;
brow_tNodeClass nc_msg_warning;
brow_tNodeClass nc_msg_error;
brow_tNodeClass nc_msg_fatal;
brow_tNodeClass nc_restart;
brow_tNodeClass nc_text;
flow_sAnnotPixmap *pixmap_leaf;
flow_sAnnotPixmap *pixmap_map;
flow_sAnnotPixmap *pixmap_openmap;
void free_pixmaps();
void allocate_pixmaps();
void create_nodeclasses();
void brow_setup();
};
class CLogMsg {
public:
CLogMsg( errh_eSeverity msg_severity, char *msg_logger, int msg_pid,
pwr_tTime msg_time, char *msg_text) :
severity(msg_severity), pid(msg_pid), time(msg_time)
{
strncpy( logger, msg_logger, sizeof(logger));
strncpy( text, msg_text, sizeof(text));
}
errh_eSeverity severity;
char logger[40];
int pid;
pwr_tTime time;
char text[200];
};
class CLogFile {
public:
CLogFile()
{
strcpy( name, "");
}
CLogFile( char *file_name, pwr_tTime file_time) :
time( file_time)
{
strcpy( name, file_name);
}
char name[200];
pwr_tTime time;
};
class CLogNav {
public:
CLogNav(
void *ev_parent_ctx,
Widget ev_parent_wid,
Widget *w);
~CLogNav();
void *parent_ctx;
Widget parent_wid;
Widget brow_widget;
Widget form_widget;
Widget toplevel;
CLogNavBrow *brow;
CLogNavFilter filter;
int clog_size;
int max_size;
vector<CLogMsg> msg_list;
vector<CLogFile> file_list;
int current_pos_high;
int current_pos_low;
void set_input_focus();
void zoom( double zoom_factor);
void unzoom();
void set_nodraw();
void reset_nodraw();
void read( int *idx_list, int idx_cnt);
void set_filter( bool success, bool info, bool warning, bool error, bool fatal,
bool text, char *str);
void get_filter( bool *success, bool *info, bool *warning, bool *error, bool *fatal,
bool *text);
void draw();
void get_files();
int next_file();
int prev_file();
};
class ItemMsgBase {
public:
ItemMsgBase( CLogNav *item_clognav, char *item_name, brow_tNode dest) :
clognav(item_clognav), node(dest)
{
strcpy( name, item_name);
}
clognav_eItemType type;
CLogNav *clognav;
brow_tNode node;
char name[40];
};
class ItemMsgRestart : public ItemMsgBase {
public:
ItemMsgRestart( CLogNav *clognav, char *item_name, pwr_tTime item_time,
brow_tNode dest, flow_eDest dest_code);
pwr_tTime time;
};
class ItemMsg : public ItemMsgBase {
public:
ItemMsg( CLogNav *clognav, char *item_name, errh_eSeverity item_severity,
char *item_logger, int item_pid, pwr_tTime item_time, char *item_text,
brow_tNode dest, flow_eDest dest_code);
errh_eSeverity severity;
char logger[40];
int pid;
pwr_tTime time;
char text[200];
};
#endif
...@@ -959,7 +959,7 @@ XNav::XNav( ...@@ -959,7 +959,7 @@ XNav::XNav(
brow_cnt(0), TraceList(NULL), trace_started(0), brow_cnt(0), TraceList(NULL), trace_started(0),
message_cb(NULL), close_cb(NULL), map_cb(NULL), change_value_cb(NULL), message_cb(NULL), close_cb(NULL), map_cb(NULL), change_value_cb(NULL),
set_dimension_cb(NULL), ccm_func_registred(0), verify(0), set_dimension_cb(NULL), ccm_func_registred(0), verify(0),
menu_tree(NULL), ev(NULL), op(NULL), closing_down(0), menu_tree(NULL), ev(0), op(0), clog(0), closing_down(0),
base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), displayed(0), base_priv(pwr_mPrv_System), priv(pwr_mPrv_System), displayed(0),
current_logging_index(-1), search_last_found(0), search_compiled(0) current_logging_index(-1), search_last_found(0), search_compiled(0)
{ {
......
...@@ -80,6 +80,10 @@ extern "C" { ...@@ -80,6 +80,10 @@ extern "C" {
#include "xtt_menu.h" #include "xtt_menu.h"
#endif #endif
#ifndef xtt_clog_h
#include "xtt_clog.h"
#endif
#define xnav_cVersion "X3.0b" #define xnav_cVersion "X3.0b"
#define XNAV_BROW_MAX 25 #define XNAV_BROW_MAX 25
#define XNAV_LOGG_MAX 10 #define XNAV_LOGG_MAX 10
...@@ -259,6 +263,7 @@ class XNav { ...@@ -259,6 +263,7 @@ class XNav {
xnav_sMenu *menu_tree; xnav_sMenu *menu_tree;
Ev *ev; Ev *ev;
Op *op; Op *op;
CLog *clog;
int closing_down; int closing_down;
char opplace_name[80]; char opplace_name[80];
char base_user[80]; char base_user[80];
......
...@@ -103,6 +103,7 @@ static void xnav_op_map_cb( void *ctx); ...@@ -103,6 +103,7 @@ static void xnav_op_map_cb( void *ctx);
static int xnav_op_get_alarm_info_cb( void *xnav, evlist_sAlarmInfo *info); static int xnav_op_get_alarm_info_cb( void *xnav, evlist_sAlarmInfo *info);
static void xnav_op_ack_last_cb( void *xnav, unsigned long type, unsigned long prio); static void xnav_op_ack_last_cb( void *xnav, unsigned long type, unsigned long prio);
static void xnav_trend_close_cb( void *ctx, XttTrend *trend); static void xnav_trend_close_cb( void *ctx, XttTrend *trend);
static void xnav_clog_close_cb( void *ctx);
static int xnav_help_func( void *client_data, static int xnav_help_func( void *client_data,
void *client_flag); void *client_flag);
...@@ -2422,6 +2423,24 @@ static int xnav_open_func( void *client_data, ...@@ -2422,6 +2423,24 @@ static int xnav_open_func( void *client_data,
if ( EVEN(sts)) if ( EVEN(sts))
xnav->message(' ', XNav::get_message(sts)); xnav->message(' ', XNav::get_message(sts));
} }
else if ( strncmp( arg1_str, "CONSOLELOG", strlen( arg1_str)) == 0)
{
int sts;
if ( xnav->clog)
xnav->clog->pop();
else {
xnav->clog = new CLog( xnav, xnav->parent_wid, "Console log", &sts);
if ( EVEN(sts)) {
delete xnav->clog;
xnav->op = 0;
xnav->message('E', "Unable to open console log");
return XNAV__SUCCESS;
}
xnav->clog->help_cb = xnav_ev_help_cb;
xnav->clog->close_cb = xnav_clog_close_cb;
}
}
else else
xnav->message('E',"Syntax error"); xnav->message('E',"Syntax error");
...@@ -5030,6 +5049,13 @@ void xnav_start_trace_cb( void *xnav, pwr_tObjid objid, char *name) ...@@ -5030,6 +5049,13 @@ void xnav_start_trace_cb( void *xnav, pwr_tObjid objid, char *name)
((XNav *)xnav)->start_trace( objid, name); ((XNav *)xnav)->start_trace( objid, name);
} }
static void xnav_clog_close_cb( void *ctx)
{
XNav *xnav = (XNav *)ctx;
delete xnav->clog;
xnav->clog = 0;
}
static void xnav_ev_help_cb( void *ctx, char *key) static void xnav_ev_help_cb( void *ctx, char *key)
{ {
XNav *xnav = (XNav *) ctx; XNav *xnav = (XNav *) ctx;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <stdlib.h> #include <stdlib.h>
extern "C" { extern "C" {
#include "rt_net.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "co_cdh.h" #include "co_cdh.h"
...@@ -44,7 +45,6 @@ extern "C" { ...@@ -44,7 +45,6 @@ extern "C" {
#include "rt_qdb.h" #include "rt_qdb.h"
#include "rt_hash.h" #include "rt_hash.h"
#include "rt_pool.h" #include "rt_pool.h"
#include "rt_net.h"
#include "rt_sub.h" #include "rt_sub.h"
#include "rt_io_base.h" #include "rt_io_base.h"
} }
......
...@@ -58,6 +58,15 @@ c_Hide_event_name : compound_string("Hide event name"); ...@@ -58,6 +58,15 @@ c_Hide_event_name : compound_string("Hide event name");
c_Hide_event_text : compound_string("Hide event text"); c_Hide_event_text : compound_string("Hide event text");
c_Help_on_selected_event : compound_string("Help on selected event"); c_Help_on_selected_event : compound_string("Help on selected event");
! module xtt_clog.uil
c_NextFile : compound_string("Next File");
c_PreviousFile : compound_string("Previous File");
c_SelectFile : compound_string("Select File");
c_Filter : compound_string("Filter");
c_Consolelog : compound_string("ConsoleLog");
c_Help_on_selected_msg : compound_string("Help on selected message");
! module xtt_trace.uil ! module xtt_trace.uil
c_SaveTrace : compound_string("SaveTrace"); c_SaveTrace : compound_string("SaveTrace");
......
! rt_xtt_clog.uil -- <short description>
!
! PROVIEW/R
! Copyright (C) 1996 by Comator Process AB.
!
! <Description>.
!
module rt_xtt_clog
version = 'v1.0'
names = case_sensitive
objects = {
XmSeparator = gadget ;
}
include file 'inc_xtt.uil';
identifier
clog_ctx;
procedure
clog_activate_exit(integer);
clog_activate_select_file(integer);
clog_activate_next_file(integer);
clog_activate_prev_file(integer);
clog_activate_zoom_in(integer);
clog_activate_zoom_out(integer);
clog_activate_zoom_reset(integer);
clog_activate_filter(integer);
clog_activate_help(integer);
clog_activate_helpmsg(integer);
clog_create_form(integer);
value
menu_font : font ('-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1');
!----------------------------------------
! First declare the 'top lclogl' widgets. These are not controlled by
! any other widgets. They are each fetched individually as needed.
!----------------------------------------
object clog_window : XmMainWindow
{
arguments
{
XmNx = 0;
XmNy = 0;
};
controls
{
XmMenuBar clog_menu;
XmForm clog_form;
};
};
object clog_form : XmForm
{
arguments
{
XmNwidth = 200;
XmNheight = 200;
XmNresizePolicy = XmRESIZE_NONE;
};
controls
{
XmPanedWindow clog_pane;
};
};
object clog_menu : XmMenuBar
{
arguments
{
XmNorientation = XmHORIZONTAL;
XmNspacing = 15;
XmNmenuHelpWidget = XmCascadeButton clog_help_entry;
};
controls
{
XmCascadeButton clog_file_entry;
XmCascadeButton clog_view_entry;
XmCascadeButton clog_help_entry;
};
};
object clog_file_entry : XmCascadeButton
{
arguments
{
XmNlabelString = c_File;
XmNfontList = menu_font;
};
controls
{
XmPulldownMenu
{
controls
{
XmPushButton
{
arguments
{
XmNlabelString = c_SelectFile;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_select_file(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_NextFile;
XmNmnemonic = keysym('N');
XmNaccelerator = "Ctrl<Key>N";
XmNacceleratorText = compound_string('Ctrl+N');
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_next_file(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_PreviousFile;
XmNmnemonic = keysym('P');
XmNaccelerator = "Ctrl<Key>P";
XmNacceleratorText = compound_string('Ctrl+P');
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_prev_file(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_Close;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_exit(clog_ctx);
};
};
};
};
};
};
object clog_view_entry : XmCascadeButton
{
arguments
{
XmNlabelString = c_View;
XmNfontList = menu_font;
};
controls
{
XmPulldownMenu
{
controls
{
XmPushButton
{
arguments
{
XmNlabelString = c_Zoom_in;
XmNmnemonic = keysym('I');
XmNaccelerator = "Ctrl<Key>I";
XmNacceleratorText = compound_string('Ctrl+I');
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_zoom_in(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_Zoom_out;
XmNmnemonic = keysym('O');
XmNaccelerator = "Ctrl<Key>O";
XmNacceleratorText = compound_string('Ctrl+O');
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_zoom_out(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_Zoom_reset;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_zoom_reset(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_Filter;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_filter(clog_ctx);
};
};
};
};
};
};
object clog_help_entry : XmCascadeButton
{
arguments
{
XmNlabelString = c_Help;
XmNfontList = menu_font;
};
controls
{
XmPulldownMenu
{
controls
{
XmPushButton
{
arguments
{
XmNlabelString = c_Consolelog;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_help(clog_ctx);
};
};
XmPushButton
{
arguments
{
XmNlabelString = c_Help_on_selected_msg;
XmNfontList = menu_font;
};
callbacks
{
XmNactivateCallback = procedure clog_activate_helpmsg(clog_ctx);
};
};
}; !Controls
}; !Pulldown_menu
}; !Controls
}; ! help_entry
object clog_pane : XmPanedWindow
{
arguments
{
XmNleftAttachment = XmATTACH_FORM;
XmNrightAttachment = XmATTACH_FORM;
XmNbottomAttachment = XmATTACH_FORM;
XmNtopAttachment = XmATTACH_FORM;
};
controls
{
};
callbacks
{
MrmNcreateCallback = procedure clog_create_form( clog_ctx);
};
};
!
! Filter Dialog
!
value
buttonWidth : 70;
buttonBottomOffset : 15;
buttonLeftOffset : 30;
cancelLeftPosition : 45;
titleTopOffset : 20;
titleLeftOffset : 30;
titleTitleLeftOffset : 40;
titleToggleTopOffset : 15;
toggleToggleTopOffset : 2;
procedure
clog_filter_tog_cr(any);
clog_filter_string_cr(any);
clog_filter_act_but_cb(any);
object filterForm : XmFormDialog {
arguments {
XmNdialogTitle = 'Filter';
XmNwidth = 400;
XmNheight = 300;
XmNautoUnmanage = false;
XmNnoResize = true;
XmNbuttonFontList = menu_font;
XmNlabelFontList = menu_font;
XmNtextFontList = menu_font;
};
controls {
XmLabel severityTitle;
XmToggleButton success;
XmToggleButton info;
XmToggleButton warning;
XmToggleButton error;
XmToggleButton fatal;
XmToggleButton text;
XmLabel stringTitle;
XmText string;
XmPushButton okPb;
XmPushButton applyPb;
XmPushButton cancelPb;
};
};
object severityTitle : XmLabel {
arguments {
XmNlabelString = 'Message Severity';
XmNtopAttachment = XmATTACH_FORM;
XmNtopOffset = titleTopOffset;
XmNleftAttachment = XmATTACH_FORM;
XmNleftOffset = titleTitleLeftOffset;
};
};
object success : XmToggleButton {
arguments {
XmNlabelString = 'Success';
XmNtopAttachment = XmATTACH_FORM;
XmNtopOffset = titleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 1;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object info : XmToggleButton {
arguments {
XmNlabelString = 'Info';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton success;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 2;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object warning : XmToggleButton {
arguments {
XmNlabelString = 'Warning';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton info;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 3;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object error : XmToggleButton {
arguments {
XmNlabelString = 'Error';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton warning;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 4;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object fatal : XmToggleButton {
arguments {
XmNlabelString = 'Fatal';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton error;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 5;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object text : XmToggleButton {
arguments {
XmNlabelString = 'Text';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton fatal;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNuserData = 6;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filter_tog_cr(clog_ctx);
};
};
object stringTitle : XmLabel {
arguments {
XmNlabelString = 'String';
XmNtopAttachment = XmATTACH_WIDGET;
XmNtopWidget = XmToggleButton text;
XmNleftAttachment = XmATTACH_FORM;
XmNleftOffset = titleTitleLeftOffset;
};
};
object string : XmText
{
arguments
{
XmNtopAttachment = XmATTACH_OPPOSITE_WIDGET;
XmNtopWidget = XmLabel stringTitle;
XmNtopOffset = toggleToggleTopOffset;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmLabel severityTitle;
XmNleftOffset = buttonLeftOffset;
XmNrightAttachment = XmATTACH_FORM;
XmNrightOffset = 10;
XmNrows = 1;
XmNborderWidth = 0;
XmNshadowThickness = 1;
XmNheight = 30;
XmNfontList = menu_font;
};
controls
{
};
callbacks
{
MrmNcreateCallback = procedure clog_filter_string_cr(clog_ctx);
};
};
!----------------------------
object okPb : XmPushButton {
arguments {
XmNlabelString = 'OK';
XmNleftAttachment = XmATTACH_FORM;
XmNleftOffset = buttonLeftOffset;
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = buttonBottomOffset;
XmNwidth = buttonWidth;
XmNuserData = 1;
};
callbacks {
XmNactivateCallback = procedure clog_filter_act_but_cb(clog_ctx);
};
};
object applyPb : XmPushButton {
arguments {
XmNlabelString = 'Apply';
XmNleftAttachment = XmATTACH_POSITION;
XmNleftPosition = cancelLeftPosition;
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = buttonBottomOffset;
XmNwidth = buttonWidth;
XmNuserData = 2;
};
callbacks {
XmNactivateCallback = procedure clog_filter_act_but_cb(clog_ctx);
};
};
object cancelPb : XmPushButton {
arguments {
XmNlabelString = 'Cancel';
XmNrightAttachment = XmATTACH_FORM;
XmNrightOffset = buttonLeftOffset;
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = buttonBottomOffset;
XmNwidth = buttonWidth;
XmNuserData = 3;
};
callbacks {
XmNactivateCallback = procedure clog_filter_act_but_cb(clog_ctx);
};
};
!-----------------------------------------------------------------
!
! File selection window
!
!________________________________________________________________
procedure
clog_filesel_ok_cb(any);
clog_filesel_cancel_cb(any);
clog_filesel_list_cr(any);
object fileselForm : XmFormDialog {
arguments {
XmNwidth = 320;
XmNheight = 350;
XmNdialogTitle = 'File selection';
XmNdefaultButton = XmPushButton fileselOk;
XmNcancelButton = XmPushButton fileselCancel;
XmNbuttonFontList = menu_font;
XmNlabelFontList = menu_font;
XmNautoUnmanage = false;
XmNtextFontList = menu_font;
};
controls {
XmPushButton fileselOk;
XmPushButton fileselApply;
XmPushButton fileselCancel;
XmScrolledList fileselList;
};
};
object fileselOk : XmPushButton {
arguments {
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = 20;
XmNleftAttachment = XmATTACH_FORM;
XmNleftOffset = 20;
XmNwidth = 80;
XmNlabelString = 'OK';
XmNuserData = 1;
};
controls {
};
callbacks {
XmNactivateCallback = procedure clog_filesel_ok_cb(clog_ctx);
};
};
object fileselApply : XmPushButton {
arguments {
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = 20;
XmNleftAttachment = XmATTACH_WIDGET;
XmNleftWidget = XmPushButton fileselOk;
XmNleftOffset = 10;
XmNwidth = 80;
XmNlabelString = 'Apply';
XmNuserData = 2;
};
controls {
};
callbacks {
XmNactivateCallback = procedure clog_filesel_ok_cb(clog_ctx);
};
};
object fileselCancel : XmPushButton {
arguments {
XmNwidth = 80;
XmNlabelString = 'Cancel';
XmNbottomAttachment = XmATTACH_FORM;
XmNbottomOffset = 20;
XmNrightAttachment = XmATTACH_FORM;
XmNrightOffset = 20;
};
callbacks {
XmNactivateCallback = procedure clog_filesel_cancel_cb(clog_ctx);
};
};
object fileselList : XmScrolledList {
arguments {
XmNbottomAttachment = XmATTACH_WIDGET;
XmNbottomWidget = XmPushButton fileselOk;
XmNbottomOffset = 15;
XmNrightAttachment = XmATTACH_FORM;
XmNrightOffset = 5;
XmNtopAttachment = XmATTACH_FORM;
XmNtopOffset = 5;
XmNleftAttachment = XmATTACH_FORM;
XmNleftOffset = 5;
XmNselectionPolicy = XmEXTENDED_SELECT;
XmNfontList = menu_font;
};
controls {
};
callbacks {
MrmNcreateCallback = procedure clog_filesel_list_cr(clog_ctx);
};
};
end module;
...@@ -58,6 +58,15 @@ c_Hide_event_name : compound_string("D ...@@ -58,6 +58,15 @@ c_Hide_event_name : compound_string("D
c_Hide_event_text : compound_string("Dlj hndelsetext"); c_Hide_event_text : compound_string("Dlj hndelsetext");
c_Help_on_selected_event : compound_string("Hjlp fr utvald hndelse"); c_Help_on_selected_event : compound_string("Hjlp fr utvald hndelse");
! module xtt_clog.uil
c_NextFile : compound_string("Nsta Fil");
c_PreviousFile : compound_string("Fregende Fil");
c_SelectFile : compound_string("Vlj Fil");
c_Filter : compound_string("Filter");
c_Consolelog : compound_string("Konsollogg");
c_Help_on_selected_msg : compound_string("Hjlp fr utvalt meddelande");
! module xtt_trace.uil ! module xtt_trace.uil
c_SaveTrace : compound_string("Spara Trace"); c_SaveTrace : compound_string("Spara Trace");
......
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