Commit 2724a881 authored by claes's avatar claes

Symbols in SelectList

parent e3fdde5b
......@@ -42,6 +42,7 @@ static Ev *ev = NULL;
static void ev_eve_display_in_xnav_cb( void *ctx, pwr_sAttrRef *arp);
static void ev_ala_display_in_xnav_cb( void *ctx, pwr_sAttrRef *arp);
static void ev_blk_display_in_xnav_cb( void *ctx, pwr_sAttrRef *arp);
static char *ev_name_to_alias_cb( void *ctx, char *name);
static void ev_eve_start_trace_cb( void *ctx, pwr_tObjid objid, char *name);
static void ev_ala_start_trace_cb( void *ctx, pwr_tObjid objid, char *name);
static void ev_blk_start_trace_cb( void *ctx, pwr_tObjid objid, char *name);
......@@ -215,6 +216,7 @@ Ev::Ev(
ala_size = userobject_ptr->MaxNoOfAlarms;
eve_size = userobject_ptr->MaxNoOfEvents;
blk_size = 0;
create_aliaslist( userobject_ptr);
reglist[0].value = (caddr_t) this;
......@@ -302,10 +304,12 @@ Ev::Ev(
eve = new EvList( this, form_eve, ev_eType_EventList, eve_size, &eve_widget);
eve->start_trace_cb = &ev_eve_start_trace_cb;
eve->display_in_xnav_cb = &ev_eve_display_in_xnav_cb;
eve->name_to_alias_cb = &ev_name_to_alias_cb;
eve->popup_menu_cb = &ev_popup_menu_cb;
ala = new EvList( this, form_ala, ev_eType_AlarmList, ala_size, &ala_widget);
ala->start_trace_cb = &ev_ala_start_trace_cb;
ala->display_in_xnav_cb = &ev_ala_display_in_xnav_cb;
ala->name_to_alias_cb = &ev_name_to_alias_cb;
ala->popup_menu_cb = &ev_popup_menu_cb;
blk = new EvList( this, form_blk, ev_eType_BlockList, blk_size, &blk_widget);
blk->start_trace_cb = &ev_blk_start_trace_cb;
......@@ -468,6 +472,11 @@ static void ev_popup_menu_cb( void *ctx, pwr_sAttrRef attrref,
utility, arg, popup);
}
static char *ev_name_to_alias_cb( void *ctx, char *name)
{
return ((Ev *)ctx)->name_to_alias( name);
}
static void ev_eve_display_in_xnav_cb( void *ctx, pwr_sAttrRef *arp)
{
if ( ((Ev *)ctx)->display_in_xnav_cb)
......@@ -862,6 +871,63 @@ int Ev::get_last_not_acked_prio( mh_sEventId **id, unsigned long type,
return ala->get_last_not_acked_prio( id, type, prio);
}
void Ev::create_aliaslist( void *up)
{
char alias_array[2][80];
int nr;
int i, j;
int alias_size;
ev_sAlias dum;
pwr_sClass_User *userp = (pwr_sClass_User *)up;
int listsize = MIN( sizeof(userp->SelectList)/sizeof(userp->SelectList[0]),
sizeof(alias_list)/sizeof(alias_list[0]));
for ( i = 0, j = 0; i < listsize; i++) {
nr = dcli_parse( userp->SelectList[i], " ", "",
(char *) alias_array, sizeof( alias_array)/sizeof( alias_array[0]),
sizeof( alias_array[0]), 0);
if ( nr < 2)
continue;
cdh_ToUpper( alias_list[j].Object, alias_array[0]);
strncpy( alias_list[j].Alias, alias_array[1], sizeof(alias_list[j].Alias));
alias_list[j].Alias[sizeof(alias_list[j].Alias)-1] = 0;
j++;
}
alias_size = j;
// Order
for ( i = alias_size - 1; i > 0; i--) {
for ( j = 0; j < i; j++) {
if ( strcmp( alias_list[j].Object, alias_list[j+1].Object) <= 0) {
memcpy( &dum, &alias_list[j+1], sizeof(dum));
memcpy( &alias_list[j+1], &alias_list[j], sizeof(dum));
memcpy( &alias_list[j], &dum, sizeof(dum));
}
}
}
}
char *Ev::name_to_alias( char *name)
{
char oname[120];
static char alias[40];
cdh_ToUpper( oname, name);
for ( int i = 0; i < (int)(sizeof(alias_list)/sizeof(alias_list[0])); i++) {
if ( alias_list[i].Alias[0] == 0)
break;
if ( strncmp( oname, alias_list[i].Object, strlen(alias_list[i].Object)) == 0) {
strcpy( alias, alias_list[i].Alias);
return alias;
}
}
strcpy( alias, "");
return alias;
}
static pwr_tStatus ev_mh_ack_bc( mh_sAck *MsgP)
{
if ( ev->eve_display_ack)
......
......@@ -28,6 +28,11 @@ extern "C" {
# include "xtt_focustimer.h"
#endif
typedef struct {
char Object[120];
char Alias[8];
} ev_sAlias;
class Ev {
public:
Ev(
......@@ -84,6 +89,7 @@ class Ev {
FocusTimer eve_focustimer;
FocusTimer ala_focustimer;
FocusTimer blk_focustimer;
ev_sAlias alias_list[20];
int outunit_connect( pwr_tObjid user);
void update( double scantime);
......@@ -100,6 +106,8 @@ class Ev {
void ack_last_prio( unsigned long type, unsigned long prio);
int get_last_not_acked_prio( mh_sEventId **id, unsigned long type,
unsigned long prio);
void create_aliaslist( void *up);
char *name_to_alias( char *name);
};
#endif
......
......@@ -36,6 +36,7 @@ extern "C" {
#include "flow_x.h"
#include "co_mrm_util.h"
}
#include "co_lng.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
......@@ -216,8 +217,7 @@ void EvListBrow::create_nodeclasses()
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);
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,
......@@ -226,7 +226,10 @@ void EvListBrow::create_nodeclasses()
brow_AddAnnot( nc_event, 10, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_event, 26, 0.6, 3,
brow_AddAnnot( nc_event, 12, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
brow_AddAnnot( nc_event, 28, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
......@@ -237,19 +240,17 @@ void EvListBrow::create_nodeclasses()
brow_AddFilledRect( nc_a_alarm, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_LineRed);
brow_AddRect( nc_a_alarm, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_a_alarm, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnotPixmap( nc_a_alarm, 0, 1.6, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnotPixmap( nc_a_alarm, 1, 2.2, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnot( nc_a_alarm, 3.3, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_a_alarm, 10, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_a_alarm, 26, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_a_alarm, 12, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
brow_AddAnnot( nc_a_alarm, 28, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
// Nodeclass for B-alarm
brow_CreateNodeClass( ctx, "B_Alarm",
......@@ -258,19 +259,17 @@ void EvListBrow::create_nodeclasses()
brow_AddFilledRect( nc_b_alarm, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Yellow);
brow_AddRect( nc_b_alarm, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_b_alarm, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnotPixmap( nc_b_alarm, 0, 1.6, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnotPixmap( nc_b_alarm, 1, 2.2, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnot( nc_b_alarm, 3.3, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_b_alarm, 10, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_b_alarm, 26, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_b_alarm, 12, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
brow_AddAnnot( nc_b_alarm, 28, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
// Nodeclass for Info
brow_CreateNodeClass( ctx, "Info",
......@@ -279,19 +278,17 @@ void EvListBrow::create_nodeclasses()
brow_AddFilledRect( nc_info, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Green);
brow_AddRect( nc_info, 0.2, 0.15, 0.4, 0.4, flow_eDrawType_Line, 0, 0);
brow_AddAnnot( nc_info, 0.8, 0.6, 0,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnotPixmap( nc_info, 0, 1.6, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnotPixmap( nc_info, 1, 2.2, 0.1, flow_eDrawType_Line, 2, 0);
brow_AddAnnot( nc_info, 3.3, 0.6, 1,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_info, 10, 0.6, 2,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
0);
brow_AddAnnot( nc_info, 26, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine,
1);
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 0);
brow_AddAnnot( nc_info, 12, 0.6, 3,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
brow_AddAnnot( nc_info, 28, 0.6, 4,
flow_eDrawType_TextHelveticaBold, 2, flow_eAnnotType_OneLine, 1);
}
......@@ -360,7 +357,7 @@ EvList::EvList(
parent_ctx(ev_parent_ctx), parent_wid(ev_parent_wid),
type(ev_type), size(0), max_size(ev_size), display_hundredth(0),
hide_object(0), hide_text(0),
start_trace_cb(NULL), display_in_xnav_cb(NULL), acc_beep_time(0),
start_trace_cb(0), display_in_xnav_cb(0), name_to_alias_cb(0), acc_beep_time(0),
beep_interval(4)
{
if ( max_size <= 0) {
......@@ -1180,10 +1177,15 @@ ItemAlarm::ItemAlarm( EvList *item_evlist, char *item_name, pwr_tTime item_time,
brow_tNodeClass nc;
strcpy( name, item_name);
strncpy( eventtext, item_eventtext, sizeof(eventtext));
strncpy( eventtext, Lng::translate( item_eventtext), sizeof(eventtext));
eventtext[sizeof(eventtext)-1] = 0;
strncpy( eventname, item_eventname, sizeof(eventname));
eventname[sizeof(eventname)-1] = 0;
if ( evlist->name_to_alias_cb)
strcpy( alias, evlist->name_to_alias_cb( evlist->parent_ctx, eventname));
else
strcpy( alias, "");
switch ( event_type) {
case evlist_eEventType_Alarm:
......@@ -1306,24 +1308,30 @@ void ItemAlarm::update_text()
{
case evlist_eEventType_Info:
case evlist_eEventType_Alarm:
if ( ! evlist->hide_text)
brow_SetAnnotation( node, 2, eventtext, strlen(eventtext));
else
if ( ! evlist->hide_text) {
brow_SetAnnotation( node, 2, alias, strlen(alias));
brow_SetAnnotation( node, 3, eventtext, strlen(eventtext));
}
else {
brow_SetAnnotation( node, 2, "", 0);
brow_SetAnnotation( node, 3, "", 0);
}
break;
default:
brow_SetAnnotation( node, 2, "", 0);
brow_SetAnnotation( node, 3, "", 0);
}
if ( !evlist->hide_object && evlist->hide_text)
{
brow_SetAnnotation( node, 2, eventname, strlen(eventname));
brow_SetAnnotation( node, 3, "", 0);
brow_SetAnnotation( node, 4, "", 0);
}
else if ( !evlist->hide_object)
brow_SetAnnotation( node, 3, eventname, strlen(eventname));
brow_SetAnnotation( node, 4, eventname, strlen(eventname));
else
brow_SetAnnotation( node, 3, "", 0);
brow_SetAnnotation( node, 4, "", 0);
}
int EvList::get_last_not_acked( mh_sEventId **id)
......@@ -1461,6 +1469,7 @@ int EvList::get_alarm_info( evlist_sAlarmInfo *info)
if ( a_cnt >= ALARM_INFO_A_SIZE)
break;
strcpy( info->a_alarm_text[a_cnt], object_item->eventtext);
strcpy( info->a_alarm_alias[a_cnt], object_item->alias);
info->a_alarm_active[a_cnt] = object_item->status & mh_mEventStatus_NotRet;
info->a_alarm_exist[a_cnt] = 1;
a_cnt++;
......@@ -1469,6 +1478,7 @@ int EvList::get_alarm_info( evlist_sAlarmInfo *info)
if ( b_cnt >= ALARM_INFO_B_SIZE)
break;
strcpy( info->b_alarm_text[b_cnt], object_item->eventtext);
strcpy( info->b_alarm_alias[b_cnt], object_item->alias);
info->b_alarm_active[b_cnt] = object_item->status & mh_mEventStatus_NotRet;
info->b_alarm_exist[b_cnt] = 1;
b_cnt++;
......@@ -1477,6 +1487,7 @@ int EvList::get_alarm_info( evlist_sAlarmInfo *info)
if ( c_cnt >= ALARM_INFO_C_SIZE)
break;
strcpy( info->c_alarm_text[c_cnt], object_item->eventtext);
strcpy( info->c_alarm_alias[c_cnt], object_item->alias);
info->c_alarm_active[c_cnt] = object_item->status & mh_mEventStatus_NotRet;
info->c_alarm_exist[c_cnt] = 1;
c_cnt++;
......@@ -1485,6 +1496,7 @@ int EvList::get_alarm_info( evlist_sAlarmInfo *info)
if ( d_cnt >= ALARM_INFO_D_SIZE)
break;
strcpy( info->d_alarm_text[d_cnt], object_item->eventtext);
strcpy( info->d_alarm_alias[d_cnt], object_item->alias);
info->d_alarm_active[d_cnt] = object_item->status & mh_mEventStatus_NotRet;
info->d_alarm_exist[d_cnt] = 1;
d_cnt++;
......@@ -1501,6 +1513,7 @@ int EvList::get_alarm_info( evlist_sAlarmInfo *info)
if ( i_cnt >= ALARM_INFO_I_SIZE)
break;
strcpy( info->i_alarm_text[i_cnt], object_item->eventtext);
strcpy( info->i_alarm_alias[i_cnt], object_item->alias);
info->i_alarm_active[i_cnt] = object_item->status & mh_mEventStatus_NotRet;
info->i_alarm_exist[i_cnt] = 1;
i_cnt++;
......
......@@ -51,18 +51,23 @@ extern "C" {
#define ALARM_INFO_I_SIZE 2
typedef struct {
char a_alarm_text[ALARM_INFO_A_SIZE][80];
char a_alarm_alias[ALARM_INFO_A_SIZE][40];
int a_alarm_active[ALARM_INFO_A_SIZE];
int a_alarm_exist[ALARM_INFO_A_SIZE];
char b_alarm_text[ALARM_INFO_B_SIZE][80];
char b_alarm_alias[ALARM_INFO_A_SIZE][40];
int b_alarm_active[ALARM_INFO_B_SIZE];
int b_alarm_exist[ALARM_INFO_B_SIZE];
char c_alarm_text[ALARM_INFO_C_SIZE][80];
char c_alarm_alias[ALARM_INFO_A_SIZE][40];
int c_alarm_active[ALARM_INFO_C_SIZE];
int c_alarm_exist[ALARM_INFO_C_SIZE];
char d_alarm_text[ALARM_INFO_D_SIZE][80];
char d_alarm_alias[ALARM_INFO_A_SIZE][40];
int d_alarm_active[ALARM_INFO_D_SIZE];
int d_alarm_exist[ALARM_INFO_D_SIZE];
char i_alarm_text[ALARM_INFO_I_SIZE][80];
char i_alarm_alias[ALARM_INFO_A_SIZE][40];
int i_alarm_active[ALARM_INFO_I_SIZE];
int i_alarm_exist[ALARM_INFO_I_SIZE];
int alarms_total;
......@@ -145,6 +150,7 @@ class EvList {
void (*display_in_xnav_cb)( void *, pwr_sAttrRef *);
void (*popup_menu_cb)( void *, pwr_sAttrRef, unsigned long,
unsigned long, char *, Widget *);
char *(*name_to_alias_cb)( void *, char *);
double acc_beep_time;
double beep_interval;
......@@ -201,6 +207,7 @@ class ItemAlarm {
mh_sEventId eventid;
pwr_tObjid object;
unsigned long status;
char alias[40];
void update_text();
};
......
......@@ -271,6 +271,7 @@ void Op::update_alarm_info()
int height, active_height;
int background;
char str[40];
char text[120];
if ( get_alarm_info_cb)
{
......@@ -307,7 +308,8 @@ void Op::update_alarm_info()
{
if ( info.a_alarm_exist[i])
{
cstr=XmStringCreateLtoR( info.a_alarm_text[i], "ISO8859-1");
sprintf( text, "%s %s", info.a_alarm_alias[i], info.a_alarm_text[i]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( aalarm_label[i], args, j);
XmStringFree( cstr);
......@@ -340,7 +342,8 @@ void Op::update_alarm_info()
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_B;
cstr=XmStringCreateLtoR( info.b_alarm_text[0], "ISO8859-1");
sprintf( text, "%s %s", info.b_alarm_alias[0], info.b_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
......@@ -366,7 +369,8 @@ void Op::update_alarm_info()
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_C;
cstr=XmStringCreateLtoR( info.c_alarm_text[0], "ISO8859-1");
sprintf( text, "%s %s", info.c_alarm_alias[0], info.c_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
......@@ -392,7 +396,8 @@ void Op::update_alarm_info()
{
balarm_type = evlist_eEventType_Alarm;
balarm_prio = mh_eEventPrio_D;
cstr=XmStringCreateLtoR( info.d_alarm_text[0], "ISO8859-1");
sprintf( text, "%s %s", info.d_alarm_alias[0], info.d_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
......@@ -417,7 +422,8 @@ void Op::update_alarm_info()
else if ( info.i_alarm_exist[0])
{
balarm_type = evlist_eEventType_Info;
cstr=XmStringCreateLtoR( info.i_alarm_text[0], "ISO8859-1");
sprintf( text, "%s %s", info.i_alarm_alias[0], info.i_alarm_text[0]);
cstr=XmStringCreateLtoR( text, "ISO8859-1");
XtSetArg(args[j=0],XmNlabelString, cstr);j++;
XtSetValues( balarm_label, args, j);
XmStringFree( cstr);
......@@ -525,7 +531,7 @@ int Op::configure( char *opplace_str)
sts = gdh_ClassAttrToAttrref( pwr_cClass_XttGraph, ".ButtonText", &attrref);
if ( EVEN(sts)) return sts;
attrref = user_p->FastAvail[i];
attrref = cdh_ArefAdd( &user_p->FastAvail[i], &attrref);
sts = gdh_GetObjectInfoAttrref( &attrref, (void *)button_title[i],
sizeof(button_title[0]));
if ( EVEN(sts))
......
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