Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
64d17aa8
Commit
64d17aa8
authored
May 16, 2007
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Runtime monitor and Status monitor added
parent
27fd78da
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
3456 additions
and
23 deletions
+3456
-23
src/exe/rt_statussrv/src/rt_statussrv.cpp
src/exe/rt_statussrv/src/rt_statussrv.cpp
+27
-21
src/lib/co/gtk/co_rtmon_gtk.cpp
src/lib/co/gtk/co_rtmon_gtk.cpp
+462
-0
src/lib/co/gtk/co_rtmon_gtk.h
src/lib/co/gtk/co_rtmon_gtk.h
+85
-0
src/lib/co/gtk/co_statusmon_nodelist_gtk.cpp
src/lib/co/gtk/co_statusmon_nodelist_gtk.cpp
+458
-0
src/lib/co/gtk/co_statusmon_nodelist_gtk.h
src/lib/co/gtk/co_statusmon_nodelist_gtk.h
+81
-0
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.cpp
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.cpp
+113
-0
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.h
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.h
+57
-0
src/lib/co/src/co_msgwindow.cpp
src/lib/co/src/co_msgwindow.cpp
+12
-1
src/lib/co/src/co_msgwindow.h
src/lib/co/src/co_msgwindow.h
+3
-1
src/lib/co/src/co_rtmon.cpp
src/lib/co/src/co_rtmon.cpp
+105
-0
src/lib/co/src/co_rtmon.h
src/lib/co/src/co_rtmon.h
+72
-0
src/lib/co/src/co_statusmon_nodelist.cpp
src/lib/co/src/co_statusmon_nodelist.cpp
+105
-0
src/lib/co/src/co_statusmon_nodelist.h
src/lib/co/src/co_statusmon_nodelist.h
+74
-0
src/lib/co/src/co_statusmon_nodelistnav.cpp
src/lib/co/src/co_statusmon_nodelistnav.cpp
+1547
-0
src/lib/co/src/co_statusmon_nodelistnav.h
src/lib/co/src/co_statusmon_nodelistnav.h
+255
-0
No files found.
src/exe/rt_statussrv/src/rt_statussrv.cpp
View file @
64d17aa8
/*
* Proview $Id: rt_statussrv.cpp,v 1.
1 2007-05-11 15:01:23
claes Exp $
* Proview $Id: rt_statussrv.cpp,v 1.
2 2007-05-16 12:32:55
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -62,7 +62,7 @@ static status_server *statussrv;
static
void
*
statussrv_cyclic
(
void
*
arg
);
int
main
()
int
main
(
int
argc
,
char
*
argv
[]
)
{
struct
soap
soap
;
int
m
,
s
;
// Master and slave sockets
...
...
@@ -71,14 +71,20 @@ int main()
qcom_sQid
qini
;
qcom_sQattr
qAttr
;
qcom_sQid
qid
=
qcom_cNQid
;
int
restarts
;
int
restarts
=
10
;
int
ignore_config
=
0
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-i"
)
==
0
)
ignore_config
=
1
;
}
sts
=
gdh_Init
(
"status_server"
);
if
(
EVEN
(
sts
))
{
exit
(
sts
);
}
errh_Init
(
"status_server"
,
errh_e
NAnix
/* errh_eAnix_status_server */
);
errh_Init
(
"status_server"
,
errh_e
Anix_statussrv
);
errh_SetStatus
(
PWR__SRVSTARTUP
);
if
(
!
qcom_Init
(
&
sts
,
0
,
"status_server"
))
{
...
...
@@ -133,25 +139,25 @@ int main()
}
#if 0
// Get StatusServerConfig object
pwr_tOid config_oid;
sts = gdh_GetClassList( pwr_cClass_StatusServerConfig, &config_oid);
if ( EVEN(sts)) {
// Not configured
errh_SetStatus( 0);
exit(sts);
}
sts = gdh_ObjidToPointer( config_oid, (void **)&statussrv->m_config);
if ( EVEN(sts)) {
errh_SetStatus( sts);
exit(sts);
if
(
!
ignore_config
)
{
// Get StatusServerConfig object
pwr_tOid
config_oid
;
sts
=
gdh_GetClassList
(
pwr_cClass_StatusServerConfig
,
&
config_oid
);
if
(
EVEN
(
sts
))
{
// Not configured
errh_SetStatus
(
0
);
exit
(
sts
);
}
sts
=
gdh_ObjidToPointer
(
config_oid
,
(
void
**
)
&
statussrv
->
m_config
);
if
(
EVEN
(
sts
))
{
errh_SetStatus
(
sts
);
exit
(
sts
);
}
aproc_RegisterObject
(
config_oid
);
}
aproc_RegisterObject( config_oid);
#endif
// Read version file
char
buff
[
100
];
...
...
src/lib/co/gtk/co_rtmon_gtk.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_rtmon_gtk.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_rtmon_gtk.cpp -- Console log in statusmon */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "co_lng.h"
#include "co_wow_gtk.h"
#include "co_msgwindow_gtk.h"
#include "co_rtmon.h"
#include "co_dcli.h"
#include "rt_pwr_msg.h"
#include "co_rtmon_gtk.h"
#include "co_statusmon_nodelistnav_gtk.h"
static
gboolean
rtmon_scan
(
void
*
data
);
static
gint
delete_event
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
RtMonGtk
::
activate_exit
(
w
,
data
);
return
TRUE
;
}
static
void
destroy_event
(
GtkWidget
*
w
,
gpointer
data
)
{
}
RtMonGtk
::
RtMonGtk
(
void
*
rtmon_parent_ctx
,
GtkWidget
*
rtmon_parent_wid
,
char
*
rtmon_name
,
pwr_tStatus
*
status
)
:
RtMon
(
rtmon_parent_ctx
,
rtmon_name
,
status
),
parent_wid
(
rtmon_parent_wid
),
clock_cursor
(
0
),
timerid
(
0
),
old_status
(
9999
)
{
toplevel
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
"default-height"
,
330
,
"default-width"
,
480
,
"title"
,
rtmon_name
,
NULL
);
g_signal_connect
(
toplevel
,
"delete_event"
,
G_CALLBACK
(
delete_event
),
this
);
g_signal_connect
(
toplevel
,
"destroy"
,
G_CALLBACK
(
destroy_event
),
this
);
g_signal_connect
(
toplevel
,
"focus-in-event"
,
G_CALLBACK
(
action_inputfocus
),
this
);
CoWowGtk
::
SetWindowIcon
(
toplevel
);
GtkWidget
*
vbox
=
gtk_vbox_new
(
FALSE
,
0
);
// Menu
// Accelerators
GtkAccelGroup
*
accel_g
=
(
GtkAccelGroup
*
)
g_object_new
(
GTK_TYPE_ACCEL_GROUP
,
NULL
);
gtk_window_add_accel_group
(
GTK_WINDOW
(
toplevel
),
accel_g
);
GtkMenuBar
*
menu_bar
=
(
GtkMenuBar
*
)
g_object_new
(
GTK_TYPE_MENU_BAR
,
NULL
);
// File entry
GtkWidget
*
file_close
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Close"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
file_close
),
gtk_image_new_from_stock
(
"gtk-close"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
file_close
,
"activate"
,
G_CALLBACK
(
activate_exit
),
this
);
gtk_widget_add_accelerator
(
file_close
,
"activate"
,
accel_g
,
'w'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
file_reset
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Reset Runtime"
));
g_signal_connect
(
file_reset
,
"activate"
,
G_CALLBACK
(
activate_reset
),
this
);
file_xtt
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Start Runtime Navigator"
));
g_signal_connect
(
file_xtt
,
"activate"
,
G_CALLBACK
(
activate_xtt
),
this
);
file_op
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Start Operator Environment"
));
g_signal_connect
(
file_op
,
"activate"
,
G_CALLBACK
(
activate_op
),
this
);
GtkMenu
*
file_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_reset
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_xtt
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_op
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_close
);
GtkWidget
*
file
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_File"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
file
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
file
),
GTK_WIDGET
(
file_menu
));
// View menu
GtkWidget
*
view_zoom_in
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _In"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_in
),
gtk_image_new_from_stock
(
"gtk-zoom-in"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_in
,
"activate"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
gtk_widget_add_accelerator
(
view_zoom_in
,
"activate"
,
accel_g
,
'i'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_out
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Out"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_out
),
gtk_image_new_from_stock
(
"gtk-zoom-out"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_out
,
"activate"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
gtk_widget_add_accelerator
(
view_zoom_out
,
"activate"
,
accel_g
,
'o'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_reset
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Reset"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_reset
),
gtk_image_new_from_stock
(
"gtk-zoom-100"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_reset
,
"activate"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
GtkMenu
*
view_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_in
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_out
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_reset
);
GtkWidget
*
view
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_View"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
view
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
view
),
GTK_WIDGET
(
view_menu
));
// Menu Help
GtkWidget
*
help_help
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Help"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
help_help
),
gtk_image_new_from_stock
(
"gtk-help"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
help_help
,
"activate"
,
G_CALLBACK
(
activate_help
),
this
);
gtk_widget_add_accelerator
(
help_help
,
"activate"
,
accel_g
,
'h'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkMenu
*
help_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_help
);
GtkWidget
*
help
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Help"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
help
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
help
),
GTK_WIDGET
(
help_menu
));
nodelistnav
=
new
NodelistNavGtk
(
this
,
vbox
,
0
,
nodename
,
0
,
&
nodelistnav_widget
);
// Toolbar
GtkToolbar
*
tools
=
(
GtkToolbar
*
)
g_object_new
(
GTK_TYPE_TOOLBAR
,
NULL
);
pwr_tFileName
fname
;
GtkWidget
*
tools_zoom_in
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_in.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_in
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_in
,
"clicked"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
g_object_set
(
tools_zoom_in
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_in
,
CoWowGtk
::
translate_utf8
(
"Zoom in"
),
""
);
GtkWidget
*
tools_zoom_out
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_out.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_out
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_out
,
"clicked"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
g_object_set
(
tools_zoom_out
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_out
,
CoWowGtk
::
translate_utf8
(
"Zoom out"
),
""
);
GtkWidget
*
tools_zoom_reset
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_zoom_reset.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_reset
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_zoom_reset
,
"clicked"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
g_object_set
(
tools_zoom_reset
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_reset
,
CoWowGtk
::
translate_utf8
(
"Zoom reset"
),
""
);
tools_xtt
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_navigator.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_xtt
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_xtt
,
"clicked"
,
G_CALLBACK
(
activate_xtt
),
this
);
g_object_set
(
tools_xtt
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_xtt
,
CoWowGtk
::
translate_utf8
(
"Start Runtime Navigator"
),
""
);
tools_op
=
gtk_button_new
();
dcli_translate_filename
(
fname
,
"$pwr_exe/xtt_op.png"
);
gtk_container_add
(
GTK_CONTAINER
(
tools_op
),
gtk_image_new_from_file
(
fname
));
g_signal_connect
(
tools_op
,
"clicked"
,
G_CALLBACK
(
activate_op
),
this
);
g_object_set
(
tools_op
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_op
,
CoWowGtk
::
translate_utf8
(
"Start Operator Environment"
),
""
);
// Button box
dcli_translate_filename
(
fname
,
"$pwr_exe/proview_icon2.png"
);
bbox_image
=
gtk_image_new_from_file
(
fname
);
g_object_set
(
bbox_image
,
"xalign"
,
0.5
,
"yalign"
,
0.3
,
NULL
);
dcli_translate_filename
(
fname
,
"$pwr_exe/proview_icon2_gray.png"
);
bbox_image_gray
=
gtk_image_new_from_file
(
fname
);
g_object_set
(
bbox_image_gray
,
"xalign"
,
0.5
,
"yalign"
,
0.3
,
NULL
);
bbox_start
=
gtk_button_new_with_label
(
"Start Runtime"
);
gtk_widget_set_size_request
(
bbox_start
,
170
,
25
);
g_signal_connect
(
bbox_start
,
"clicked"
,
G_CALLBACK
(
activate_start
),
this
);
bbox_restart
=
gtk_button_new_with_label
(
"Restart Runtime"
);
gtk_widget_set_size_request
(
bbox_restart
,
170
,
25
);
g_signal_connect
(
bbox_restart
,
"clicked"
,
G_CALLBACK
(
activate_restart
),
this
);
bbox_stop
=
gtk_button_new_with_label
(
"Stop Runtime"
);
gtk_widget_set_size_request
(
bbox_stop
,
170
,
25
);
g_signal_connect
(
bbox_stop
,
"clicked"
,
G_CALLBACK
(
activate_stop
),
this
);
bbox_label
=
gtk_label_new
(
"Down"
);
bbox_label_eb
=
gtk_event_box_new
();
gtk_container_add
(
GTK_CONTAINER
(
bbox_label_eb
),
bbox_label
);
gtk_widget_set_size_request
(
bbox_label_eb
,
170
,
25
);
GtkWidget
*
bbox_label_fr
=
gtk_frame_new
(
0
);
gtk_container_add
(
GTK_CONTAINER
(
bbox_label_fr
),
bbox_label_eb
);
GtkWidget
*
bbox
=
gtk_vbox_new
(
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
bbox
),
bbox_start
,
FALSE
,
FALSE
,
5
);
gtk_box_pack_start
(
GTK_BOX
(
bbox
),
bbox_restart
,
FALSE
,
FALSE
,
0
);
gtk_box_pack_end
(
GTK_BOX
(
bbox
),
bbox_stop
,
FALSE
,
FALSE
,
5
);
GtkWidget
*
lbox
=
gtk_vbox_new
(
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
lbox
),
bbox_label_fr
,
FALSE
,
FALSE
,
5
);
GtkWidget
*
bbox_vbox
=
gtk_hbox_new
(
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
bbox_vbox
),
bbox_image
,
FALSE
,
FALSE
,
30
);
gtk_box_pack_start
(
GTK_BOX
(
bbox_vbox
),
bbox_image_gray
,
FALSE
,
FALSE
,
30
);
gtk_box_pack_start
(
GTK_BOX
(
bbox_vbox
),
bbox
,
FALSE
,
FALSE
,
15
);
gtk_box_pack_start
(
GTK_BOX
(
bbox_vbox
),
lbox
,
FALSE
,
FALSE
,
15
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
tools
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
bbox_vbox
),
FALSE
,
FALSE
,
10
);
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
nodelistnav_widget
),
TRUE
,
TRUE
,
0
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
vbox
);
gtk_widget_show_all
(
toplevel
);
g_object_set
(
bbox_image
,
"visible"
,
FALSE
,
NULL
);
wow
=
new
CoWowGtk
(
toplevel
);
timerid
=
g_timeout_add
(
1000
,
rtmon_scan
,
this
);
*
status
=
1
;
}
static
gboolean
rtmon_scan
(
void
*
data
)
{
RtMonGtk
*
rtmon
=
(
RtMonGtk
*
)
data
;
if
(
rtmon
->
nodelistnav
->
node_list
[
0
].
item
->
data
.
SystemStatus
!=
rtmon
->
old_status
)
{
GdkColor
color
;
char
text
[
20
];
char
color_name
[
20
];
pwr_tStatus
sts
=
rtmon
->
nodelistnav
->
node_list
[
0
].
item
->
data
.
SystemStatus
;
if
(
sts
==
PWR__SRVCONNECTION
)
{
strcpy
(
color_name
,
"Gray"
);
strcpy
(
text
,
"Down"
);
gtk_widget_set_sensitive
(
rtmon
->
bbox_start
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
bbox_restart
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
bbox_stop
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
tools_xtt
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
tools_op
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
file_xtt
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
file_op
,
FALSE
);
g_object_set
(
rtmon
->
bbox_image
,
"visible"
,
FALSE
,
NULL
);
g_object_set
(
rtmon
->
bbox_image_gray
,
"visible"
,
TRUE
,
NULL
);
}
else
{
if
(
((
sts
&
7
)
==
2
)
||
((
sts
&
7
)
==
4
))
{
strcpy
(
color_name
,
"Red"
);
strcpy
(
text
,
"Running"
);
}
else
if
(
(
sts
&
7
)
==
0
)
{
strcpy
(
color_name
,
"Yellow"
);
strcpy
(
text
,
"Running"
);
}
else
{
strcpy
(
color_name
,
"Green"
);
strcpy
(
text
,
"Running"
);
}
gtk_widget_set_sensitive
(
rtmon
->
bbox_start
,
FALSE
);
gtk_widget_set_sensitive
(
rtmon
->
bbox_restart
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
bbox_stop
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
tools_xtt
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
tools_op
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
file_xtt
,
TRUE
);
gtk_widget_set_sensitive
(
rtmon
->
file_op
,
TRUE
);
g_object_set
(
rtmon
->
bbox_image
,
"visible"
,
TRUE
,
NULL
);
g_object_set
(
rtmon
->
bbox_image_gray
,
"visible"
,
FALSE
,
NULL
);
}
gdk_color_parse
(
color_name
,
&
color
);
gtk_widget_modify_bg
(
rtmon
->
bbox_label_eb
,
GTK_STATE_NORMAL
,
&
color
);
gtk_label_set_text
(
GTK_LABEL
(
rtmon
->
bbox_label
),
text
);
rtmon
->
old_status
=
sts
;
}
rtmon
->
timerid
=
g_timeout_add
(
1000
,
rtmon_scan
,
data
);
return
FALSE
;
}
//
// Delete rtmon
//
RtMonGtk
::~
RtMonGtk
()
{
if
(
timerid
)
g_source_remove
(
timerid
);
free_cursor
();
delete
nodelistnav
;
gtk_widget_destroy
(
toplevel
);
}
void
RtMonGtk
::
pop
()
{
gtk_window_present
(
GTK_WINDOW
(
toplevel
));
}
void
RtMonGtk
::
set_clock_cursor
()
{
if
(
!
clock_cursor
)
clock_cursor
=
gdk_cursor_new_for_display
(
gtk_widget_get_display
(
toplevel
),
GDK_WATCH
);
gdk_window_set_cursor
(
toplevel
->
window
,
clock_cursor
);
gdk_display_flush
(
gtk_widget_get_display
(
toplevel
));
}
void
RtMonGtk
::
reset_cursor
()
{
gdk_window_set_cursor
(
toplevel
->
window
,
NULL
);
}
void
RtMonGtk
::
free_cursor
()
{
if
(
clock_cursor
)
gdk_cursor_unref
(
clock_cursor
);
}
gboolean
RtMonGtk
::
action_inputfocus
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
RtMonGtk
*
rtmon
=
(
RtMonGtk
*
)
data
;
if
(
rtmon
&&
rtmon
->
rtmon_displayed
)
rtmon
->
nodelistnav
->
set_input_focus
();
return
FALSE
;
}
void
RtMonGtk
::
activate_exit
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
if
(
rtmon
->
close_cb
)
(
rtmon
->
close_cb
)(
rtmon
->
parent_ctx
);
else
delete
rtmon
;
}
void
RtMonGtk
::
activate_start
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_start
();
}
void
RtMonGtk
::
activate_restart
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_restart
();
}
void
RtMonGtk
::
activate_stop
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_stop
();
}
void
RtMonGtk
::
activate_reset
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_reset
();
}
void
RtMonGtk
::
activate_xtt
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_xtt
();
}
void
RtMonGtk
::
activate_op
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_op
();
}
void
RtMonGtk
::
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
nodelistnav
->
zoom
(
1.2
);
}
void
RtMonGtk
::
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
nodelistnav
->
zoom
(
5.0
/
6
);
}
void
RtMonGtk
::
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
nodelistnav
->
unzoom
();
}
void
RtMonGtk
::
activate_help
(
GtkWidget
*
w
,
gpointer
data
)
{
RtMon
*
rtmon
=
(
RtMon
*
)
data
;
rtmon
->
activate_help
();
}
src/lib/co/gtk/co_rtmon_gtk.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_rtmon_gtk.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_rtmon_gtk_h
#define co_rtmon_gtk_h
/* co_rtmon_gtk.h -- Status Monitor */
#ifndef co_rtmon_h
# include "co_rtmon.h"
#endif
class
RtMonGtk
:
public
RtMon
{
public:
RtMonGtk
(
void
*
rtmon_parent_ctx
,
GtkWidget
*
rtmon_parent_wid
,
char
*
rtmon_name
,
pwr_tStatus
*
status
);
~
RtMonGtk
();
GtkWidget
*
parent_wid
;
GtkWidget
*
parent_wid_nodelist
;
GtkWidget
*
toplevel
;
GtkWidget
*
form_nodelist
;
GtkWidget
*
nodelistnav_widget
;
GtkWidget
*
bbox_label
;
GtkWidget
*
bbox_label_eb
;
GtkWidget
*
bbox_start
;
GtkWidget
*
bbox_restart
;
GtkWidget
*
bbox_stop
;
GtkWidget
*
bbox_image
;
GtkWidget
*
bbox_image_gray
;
GtkWidget
*
tools_xtt
;
GtkWidget
*
tools_op
;
GtkWidget
*
file_xtt
;
GtkWidget
*
file_op
;
GdkCursor
*
clock_cursor
;
gint
timerid
;
pwr_tStatus
old_status
;
void
pop
();
void
set_clock_cursor
();
void
reset_cursor
();
void
free_cursor
();
void
create_input_dialog
();
void
open_input_dialog
(
char
*
text
,
char
*
title
,
char
*
init_text
,
void
(
*
ok_cb
)(
RtMon
*
,
char
*
));
static
gboolean
action_inputfocus
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
);
static
void
activate_exit
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_start
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_restart
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_stop
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_reset
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_xtt
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_op
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_help
(
GtkWidget
*
w
,
gpointer
data
);
};
#endif
src/lib/co/gtk/co_statusmon_nodelist_gtk.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelist_gtk.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_statusmon_nodelist_gtk.cpp -- Console log in statusmon */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "co_lng.h"
#include "co_wow_gtk.h"
#include "co_msgwindow_gtk.h"
#include "co_statusmon_nodelist.h"
#include "rt_xnav_msg.h"
#include "co_statusmon_nodelist_gtk.h"
#include "co_statusmon_nodelistnav_gtk.h"
static
gint
delete_event
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
NodelistGtk
::
activate_exit
(
w
,
data
);
return
TRUE
;
}
static
void
destroy_event
(
GtkWidget
*
w
,
gpointer
data
)
{
}
NodelistGtk
::
NodelistGtk
(
void
*
nodelist_parent_ctx
,
GtkWidget
*
nodelist_parent_wid
,
char
*
nodelist_name
,
int
msgw_pop
,
pwr_tStatus
*
status
)
:
Nodelist
(
nodelist_parent_ctx
,
nodelist_name
,
status
),
parent_wid
(
nodelist_parent_wid
),
clock_cursor
(
0
),
india_widget
(
0
)
{
pwr_tStatus
sts
;
toplevel
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
"default-height"
,
600
,
"default-width"
,
700
,
"title"
,
nodelist_name
,
NULL
);
g_signal_connect
(
toplevel
,
"delete_event"
,
G_CALLBACK
(
delete_event
),
this
);
g_signal_connect
(
toplevel
,
"destroy"
,
G_CALLBACK
(
destroy_event
),
this
);
g_signal_connect
(
toplevel
,
"focus-in-event"
,
G_CALLBACK
(
action_inputfocus
),
this
);
CoWowGtk
::
SetWindowIcon
(
toplevel
);
GtkWidget
*
vbox
=
gtk_vbox_new
(
FALSE
,
0
);
// Menu
// Accelerators
GtkAccelGroup
*
accel_g
=
(
GtkAccelGroup
*
)
g_object_new
(
GTK_TYPE_ACCEL_GROUP
,
NULL
);
gtk_window_add_accel_group
(
GTK_WINDOW
(
toplevel
),
accel_g
);
GtkMenuBar
*
menu_bar
=
(
GtkMenuBar
*
)
g_object_new
(
GTK_TYPE_MENU_BAR
,
NULL
);
// File entry
GtkWidget
*
file_close
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Close"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
file_close
),
gtk_image_new_from_stock
(
"gtk-close"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
file_close
,
"activate"
,
G_CALLBACK
(
activate_exit
),
this
);
gtk_widget_add_accelerator
(
file_close
,
"activate"
,
accel_g
,
'w'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
file_add_node
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Add Node"
));
g_signal_connect
(
file_add_node
,
"activate"
,
G_CALLBACK
(
activate_add_node
),
this
);
GtkWidget
*
file_remove_node
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Remove Node"
));
g_signal_connect
(
file_remove_node
,
"activate"
,
G_CALLBACK
(
activate_remove_node
),
this
);
GtkWidget
*
file_save
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Save Configuration"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
file_save
),
gtk_image_new_from_stock
(
"gtk-save"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
file_save
,
"activate"
,
G_CALLBACK
(
activate_save
),
this
);
GtkMenu
*
file_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_close
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_add_node
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_remove_node
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_save
);
GtkWidget
*
file
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_File"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
file
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
file
),
GTK_WIDGET
(
file_menu
));
// View menu
GtkWidget
*
view_show_events
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Show _Events"
));
g_signal_connect
(
view_show_events
,
"activate"
,
G_CALLBACK
(
activate_show_events
),
this
);
GtkWidget
*
view_pop_events
=
gtk_check_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Pop Events"
));
g_signal_connect
(
view_pop_events
,
"activate"
,
G_CALLBACK
(
activate_pop_events
),
this
);
GtkWidget
*
view_zoom_in
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _In"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_in
),
gtk_image_new_from_stock
(
"gtk-zoom-in"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_in
,
"activate"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
gtk_widget_add_accelerator
(
view_zoom_in
,
"activate"
,
accel_g
,
'i'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_out
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Out"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_out
),
gtk_image_new_from_stock
(
"gtk-zoom-out"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_out
,
"activate"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
gtk_widget_add_accelerator
(
view_zoom_out
,
"activate"
,
accel_g
,
'o'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkWidget
*
view_zoom_reset
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"Zoom _Reset"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
view_zoom_reset
),
gtk_image_new_from_stock
(
"gtk-zoom-100"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
view_zoom_reset
,
"activate"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
GtkMenu
*
view_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_show_events
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_pop_events
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_in
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_out
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
view_menu
),
view_zoom_reset
);
GtkWidget
*
view
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_View"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
view
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
view
),
GTK_WIDGET
(
view_menu
));
// Menu Help
GtkWidget
*
help_help
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Help"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
help_help
),
gtk_image_new_from_stock
(
"gtk-help"
,
GTK_ICON_SIZE_MENU
));
g_signal_connect
(
help_help
,
"activate"
,
G_CALLBACK
(
activate_help
),
this
);
gtk_widget_add_accelerator
(
help_help
,
"activate"
,
accel_g
,
'h'
,
GDK_CONTROL_MASK
,
GTK_ACCEL_VISIBLE
);
GtkMenu
*
help_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
help_menu
),
help_help
);
GtkWidget
*
help
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Help"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
help
);
gtk_menu_item_set_submenu
(
GTK_MENU_ITEM
(
help
),
GTK_WIDGET
(
help_menu
));
msg_window
=
new
MsgWindowGtk
(
this
,
toplevel
,
"Status Events"
,
&
sts
);
msg_window
->
find_wnav_cb
=
find_node_cb
;
msg_window
->
msg
(
'I'
,
"Status Montitor started"
);
nodelistnav
=
new
NodelistNavGtk
(
this
,
vbox
,
msg_window
,
0
,
msgw_pop
,
&
nodelistnav_widget
);
// Toolbar
GtkToolbar
*
tools
=
(
GtkToolbar
*
)
g_object_new
(
GTK_TYPE_TOOLBAR
,
NULL
);
GtkWidget
*
tools_save
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_save
),
gtk_image_new_from_stock
(
"gtk-save"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_save
,
"clicked"
,
G_CALLBACK
(
activate_save
),
this
);
g_object_set
(
tools_save
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_save
,
CoWowGtk
::
translate_utf8
(
"Save configuration"
),
""
);
GtkWidget
*
tools_add_node
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_add_node
),
gtk_image_new_from_stock
(
"gtk-add"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_add_node
,
"clicked"
,
G_CALLBACK
(
activate_add_node
),
this
);
g_object_set
(
tools_add_node
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_add_node
,
CoWowGtk
::
translate_utf8
(
"Add node"
),
""
);
GtkWidget
*
tools_remove_node
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_remove_node
),
gtk_image_new_from_stock
(
"gtk-remove"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_remove_node
,
"clicked"
,
G_CALLBACK
(
activate_remove_node
),
this
);
g_object_set
(
tools_remove_node
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_remove_node
,
CoWowGtk
::
translate_utf8
(
"Remove node"
),
""
);
GtkWidget
*
tools_zoom_in
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_in
),
gtk_image_new_from_stock
(
"gtk-zoom-in"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_zoom_in
,
"clicked"
,
G_CALLBACK
(
activate_zoom_in
),
this
);
g_object_set
(
tools_zoom_in
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_in
,
CoWowGtk
::
translate_utf8
(
"Zoom in"
),
""
);
GtkWidget
*
tools_zoom_out
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_out
),
gtk_image_new_from_stock
(
"gtk-zoom-out"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_zoom_out
,
"clicked"
,
G_CALLBACK
(
activate_zoom_out
),
this
);
g_object_set
(
tools_zoom_out
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_out
,
CoWowGtk
::
translate_utf8
(
"Zoom out"
),
""
);
GtkWidget
*
tools_zoom_reset
=
gtk_button_new
();
gtk_container_add
(
GTK_CONTAINER
(
tools_zoom_reset
),
gtk_image_new_from_stock
(
"gtk-zoom-100"
,
GTK_ICON_SIZE_SMALL_TOOLBAR
));
g_signal_connect
(
tools_zoom_reset
,
"clicked"
,
G_CALLBACK
(
activate_zoom_reset
),
this
);
g_object_set
(
tools_zoom_reset
,
"can-focus"
,
FALSE
,
NULL
);
gtk_toolbar_append_widget
(
tools
,
tools_zoom_reset
,
CoWowGtk
::
translate_utf8
(
"Zoom reset"
),
""
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
tools
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_end
(
GTK_BOX
(
vbox
),
GTK_WIDGET
(
nodelistnav_widget
),
TRUE
,
TRUE
,
0
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
vbox
);
gtk_widget_show_all
(
toplevel
);
wow
=
new
CoWowGtk
(
toplevel
);
*
status
=
1
;
}
//
// Delete nodelist
//
NodelistGtk
::~
NodelistGtk
()
{
free_cursor
();
delete
nodelistnav
;
gtk_widget_destroy
(
toplevel
);
}
void
NodelistGtk
::
pop
()
{
gtk_window_present
(
GTK_WINDOW
(
toplevel
));
}
void
NodelistGtk
::
set_clock_cursor
()
{
if
(
!
clock_cursor
)
clock_cursor
=
gdk_cursor_new_for_display
(
gtk_widget_get_display
(
toplevel
),
GDK_WATCH
);
gdk_window_set_cursor
(
toplevel
->
window
,
clock_cursor
);
gdk_display_flush
(
gtk_widget_get_display
(
toplevel
));
}
void
NodelistGtk
::
reset_cursor
()
{
gdk_window_set_cursor
(
toplevel
->
window
,
NULL
);
}
void
NodelistGtk
::
free_cursor
()
{
if
(
clock_cursor
)
gdk_cursor_unref
(
clock_cursor
);
}
gboolean
NodelistGtk
::
action_inputfocus
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
)
{
NodelistGtk
*
nodelist
=
(
NodelistGtk
*
)
data
;
if
(
nodelist
->
focustimer
.
disabled
())
return
FALSE
;
if
(
nodelist
->
nodelist_displayed
)
nodelist
->
nodelistnav
->
set_input_focus
();
nodelist
->
focustimer
.
disable
(
400
);
return
FALSE
;
}
void
NodelistGtk
::
activate_exit
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
if
(
nodelist
->
close_cb
)
(
nodelist
->
close_cb
)(
nodelist
->
parent_ctx
);
else
delete
nodelist
;
}
void
NodelistGtk
::
activate_add_node
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
activate_add_node
();
}
void
NodelistGtk
::
activate_remove_node
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
activate_remove_node
();
}
void
NodelistGtk
::
activate_save
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
activate_save
();
}
void
NodelistGtk
::
activate_show_events
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
msg_window
->
map
();
}
void
NodelistGtk
::
activate_pop_events
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
int
set
=
gtk_check_menu_item_get_active
(
GTK_CHECK_MENU_ITEM
(
w
))
?
1
:
0
;
nodelist
->
nodelistnav
->
set_msgw_pop
(
set
);
}
void
NodelistGtk
::
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
nodelistnav
->
zoom
(
1.2
);
}
void
NodelistGtk
::
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
nodelistnav
->
zoom
(
5.0
/
6
);
}
void
NodelistGtk
::
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
nodelistnav
->
unzoom
();
}
void
NodelistGtk
::
activate_help
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
nodelist
->
activate_help
();
}
void
NodelistGtk
::
open_input_dialog
(
char
*
text
,
char
*
title
,
char
*
init_text
,
void
(
*
ok_cb
)(
Nodelist
*
,
char
*
))
{
create_input_dialog
();
g_object_set
(
india_widget
,
"visible"
,
TRUE
,
"title"
,
title
,
NULL
);
gtk_label_set_text
(
GTK_LABEL
(
india_label
),
text
);
gint
pos
=
0
;
gtk_editable_delete_text
(
GTK_EDITABLE
(
india_text
),
0
,
-
1
);
gtk_editable_insert_text
(
GTK_EDITABLE
(
india_text
),
init_text
,
strlen
(
init_text
),
&
pos
);
india_ok_cb
=
ok_cb
;
}
void
NodelistGtk
::
activate_india_ok
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
char
*
text
,
*
textutf8
;
textutf8
=
gtk_editable_get_chars
(
GTK_EDITABLE
(((
NodelistGtk
*
)
nodelist
)
->
india_text
),
0
,
-
1
);
text
=
g_convert
(
textutf8
,
-
1
,
"ISO8859-1"
,
"UTF-8"
,
NULL
,
NULL
,
NULL
);
g_free
(
textutf8
);
g_object_set
(
((
NodelistGtk
*
)
nodelist
)
->
india_widget
,
"visible"
,
FALSE
,
NULL
);
printf
(
"Add node %s
\n
"
,
text
);
(
nodelist
->
india_ok_cb
)(
nodelist
,
text
);
g_free
(
text
);
}
void
NodelistGtk
::
activate_india_cancel
(
GtkWidget
*
w
,
gpointer
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
data
;
g_object_set
(
((
NodelistGtk
*
)
nodelist
)
->
india_widget
,
"visible"
,
FALSE
,
NULL
);
}
static
gint
india_delete_event
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
nodelist
)
{
g_object_set
(
((
NodelistGtk
*
)
nodelist
)
->
india_widget
,
"visible"
,
FALSE
,
NULL
);
return
TRUE
;
}
void
NodelistGtk
::
create_input_dialog
()
{
if
(
india_widget
)
{
g_object_set
(
india_widget
,
"visible"
,
TRUE
,
NULL
);
return
;
}
// Create an input dialog
india_widget
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_WINDOW
,
"default-height"
,
150
,
"default-width"
,
350
,
"title"
,
"Input Dialog"
,
"window-position"
,
GTK_WIN_POS_CENTER
,
NULL
);
g_signal_connect
(
india_widget
,
"delete_event"
,
G_CALLBACK
(
india_delete_event
),
this
);
india_text
=
gtk_entry_new
();
g_signal_connect
(
india_text
,
"activate"
,
G_CALLBACK
(
NodelistGtk
::
activate_india_ok
),
this
);
india_label
=
gtk_label_new
(
""
);
GtkWidget
*
india_image
=
(
GtkWidget
*
)
g_object_new
(
GTK_TYPE_IMAGE
,
"stock"
,
GTK_STOCK_DIALOG_QUESTION
,
"icon-size"
,
GTK_ICON_SIZE_DIALOG
,
"xalign"
,
0.5
,
"yalign"
,
1.0
,
NULL
);
GtkWidget
*
india_ok
=
gtk_button_new_with_label
(
"Ok"
);
gtk_widget_set_size_request
(
india_ok
,
70
,
25
);
g_signal_connect
(
india_ok
,
"clicked"
,
G_CALLBACK
(
NodelistGtk
::
activate_india_ok
),
this
);
GtkWidget
*
india_cancel
=
gtk_button_new_with_label
(
"Cancel"
);
gtk_widget_set_size_request
(
india_cancel
,
70
,
25
);
g_signal_connect
(
india_cancel
,
"clicked"
,
G_CALLBACK
(
NodelistGtk
::
activate_india_cancel
),
this
);
GtkWidget
*
india_hboxtext
=
gtk_hbox_new
(
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
india_hboxtext
),
india_image
,
FALSE
,
FALSE
,
15
);
gtk_box_pack_start
(
GTK_BOX
(
india_hboxtext
),
india_label
,
FALSE
,
FALSE
,
15
);
gtk_box_pack_end
(
GTK_BOX
(
india_hboxtext
),
india_text
,
TRUE
,
TRUE
,
30
);
GtkWidget
*
india_hboxbuttons
=
gtk_hbox_new
(
TRUE
,
40
);
gtk_box_pack_start
(
GTK_BOX
(
india_hboxbuttons
),
india_ok
,
FALSE
,
FALSE
,
0
);
gtk_box_pack_end
(
GTK_BOX
(
india_hboxbuttons
),
india_cancel
,
FALSE
,
FALSE
,
0
);
GtkWidget
*
india_vbox
=
gtk_vbox_new
(
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
india_vbox
),
india_hboxtext
,
TRUE
,
TRUE
,
30
);
gtk_box_pack_start
(
GTK_BOX
(
india_vbox
),
gtk_hseparator_new
(),
FALSE
,
FALSE
,
0
);
gtk_box_pack_end
(
GTK_BOX
(
india_vbox
),
india_hboxbuttons
,
FALSE
,
FALSE
,
15
);
gtk_container_add
(
GTK_CONTAINER
(
india_widget
),
india_vbox
);
gtk_widget_show_all
(
india_widget
);
g_object_set
(
india_widget
,
"visible"
,
FALSE
,
NULL
);
}
src/lib/co/gtk/co_statusmon_nodelist_gtk.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelist_gtk.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_statusmon_nodelist_gtk_h
#define co_statusmon_nodelist_gtk_h
/* co_statusmon_nodelist_gtk.h -- Status Monitor */
#ifndef co_statusmon_nodelist_h
# include "co_statusmon_nodelist.h"
#endif
#ifndef co_wow_gtk_h
# include "co_wow_gtk.h"
#endif
class
NodelistGtk
:
public
Nodelist
{
public:
NodelistGtk
(
void
*
nodelist_parent_ctx
,
GtkWidget
*
nodelist_parent_wid
,
char
*
nodelist_name
,
int
msgw_pop
,
pwr_tStatus
*
status
);
~
NodelistGtk
();
GtkWidget
*
parent_wid
;
GtkWidget
*
parent_wid_nodelist
;
GtkWidget
*
toplevel
;
GtkWidget
*
form_nodelist
;
GtkWidget
*
nodelistnav_widget
;
GdkCursor
*
clock_cursor
;
GtkWidget
*
india_widget
;
GtkWidget
*
india_label
;
GtkWidget
*
india_text
;
CoWowFocusTimerGtk
focustimer
;
void
pop
();
void
set_clock_cursor
();
void
reset_cursor
();
void
free_cursor
();
void
create_input_dialog
();
void
open_input_dialog
(
char
*
text
,
char
*
title
,
char
*
init_text
,
void
(
*
ok_cb
)(
Nodelist
*
,
char
*
));
static
gboolean
action_inputfocus
(
GtkWidget
*
w
,
GdkEvent
*
event
,
gpointer
data
);
static
void
activate_exit
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_add_node
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_remove_node
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_save
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_show_events
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_pop_events
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_help
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_india_ok
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_india_cancel
(
GtkWidget
*
w
,
gpointer
data
);
};
#endif
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelistnav_gtk.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_statusmon_nodelistnav_gtk.cpp -- Console message window. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_wow_gtk.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_syi.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "co_statusmon_nodelistnav_gtk.h"
NodelistNavGtk
::
NodelistNavGtk
(
void
*
nodelist_parent_ctx
,
GtkWidget
*
nodelist_parent_wid
,
MsgWindow
*
nodelist_msg_window
,
char
*
nodelist_nodename
,
int
nodelist_msgw_pop
,
GtkWidget
**
w
)
:
NodelistNav
(
nodelist_parent_ctx
,
nodelist_msg_window
,
nodelist_nodename
,
nodelist_msgw_pop
),
parent_wid
(
nodelist_parent_wid
)
{
form_widget
=
scrolledbrowwidgetgtk_new
(
init_brow_cb
,
this
,
&
brow_widget
);
gtk_widget_show_all
(
brow_widget
);
*
w
=
form_widget
;
wow
=
new
CoWowGtk
(
parent_wid
);
}
//
// Delete ev
//
NodelistNavGtk
::~
NodelistNavGtk
()
{
if
(
trace_started
)
g_source_remove
(
trace_timerid
);
delete
brow
;
gtk_widget_destroy
(
form_widget
);
}
void
NodelistNavGtk
::
beep
()
{
gdk_display_beep
(
gtk_widget_get_display
(
form_widget
));
}
void
NodelistNavGtk
::
set_input_focus
()
{
gtk_widget_grab_focus
(
brow_widget
);
}
void
NodelistNavGtk
::
trace_start
()
{
NodelistNavGtk
::
trace_scan
(
this
);
}
static
gboolean
nodelistnavgtk_trace_scan
(
void
*
data
)
{
NodelistNavGtk
::
trace_scan
(
(
NodelistNav
*
)
data
);
return
FALSE
;
}
void
NodelistNavGtk
::
trace_scan
(
NodelistNav
*
nodelistnav
)
{
if
(
nodelistnav
->
trace_started
)
{
nodelistnav
->
update_nodes
();
brow_TraceScan
(
nodelistnav
->
brow
->
ctx
);
((
NodelistNavGtk
*
)
nodelistnav
)
->
trace_timerid
=
g_timeout_add
(
nodelistnav
->
scantime
,
nodelistnavgtk_trace_scan
,
nodelistnav
);
}
}
src/lib/co/gtk/co_statusmon_nodelistnav_gtk.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelistnav_gtk.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_statusmon_nodelistnav_gtk_h
#define co_statusmon_nodelistnav_gtk_h
/* co_statusmon_nodelistnav_gtk.h -- Console message window. */
// Status is defined as int i xlib...
#ifndef co_statusmon_nodelistnav_h
# include "co_statusmon_nodelistnav.h"
#endif
class
NodelistNavGtk
:
public
NodelistNav
{
public:
NodelistNavGtk
(
void
*
ev_parent_ctx
,
GtkWidget
*
nodelistnav_parent_wid
,
MsgWindow
*
nodelistnav_msg_window
,
char
*
nodelistnav_msg_nodename
,
int
nodelist_msgw_pop
,
GtkWidget
**
w
);
~
NodelistNavGtk
();
GtkWidget
*
parent_wid
;
GtkWidget
*
brow_widget
;
GtkWidget
*
form_widget
;
GtkWidget
*
toplevel
;
gint
trace_timerid
;
void
start_trace
(
pwr_tObjid
Objid
,
char
*
object_str
);
void
set_input_focus
();
void
trace_start
();
void
beep
();
static
void
trace_scan
(
NodelistNav
*
nodelistnav
);
};
#endif
src/lib/co/src/co_msgwindow.cpp
View file @
64d17aa8
/**
* Proview $Id: co_msgwindow.cpp,v 1.1
2 2007-05-11 15:12:45
claes Exp $
* Proview $Id: co_msgwindow.cpp,v 1.1
3 2007-05-16 12:32:26
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -72,6 +72,17 @@ void MsgWindow::message( int severity, const char *text, msgw_ePop pop, pwr_tOid
default_window
->
map
();
}
void
MsgWindow
::
msg
(
int
severity
,
const
char
*
text
,
msgw_ePop
pop
,
pwr_tOid
oid
,
bool
is_plc
)
{
if
(
severity
==
'O'
)
severity
=
'I'
;
insert
(
severity
,
text
,
oid
,
is_plc
);
if
(
(
pop
==
msgw_ePop_Yes
||
(
pop
==
msgw_ePop_Default
&&
(
severity
==
'E'
||
severity
==
'F'
||
severity
==
'W'
))))
map
();
}
void
MsgWindow
::
message
(
const
co_error
&
e
,
const
char
*
text1
,
const
char
*
text2
,
pwr_tOid
oid
,
bool
is_plc
)
{
pwr_tStatus
sts
=
e
.
sts
();
...
...
src/lib/co/src/co_msgwindow.h
View file @
64d17aa8
/**
* Proview $Id: co_msgwindow.h,v 1.
7 2007-01-04 07:51:42
claes Exp $
* Proview $Id: co_msgwindow.h,v 1.
8 2007-05-16 12:32:26
claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -73,6 +73,8 @@ class MsgWindow {
void
insert
(
int
severity
,
const
char
*
text
,
pwr_tOid
oid
=
pwr_cNOid
,
bool
is_plc
=
false
);
void
set_nodraw
()
{
msgnav
->
set_nodraw
();
nodraw
++
;}
void
reset_nodraw
();
void
msg
(
int
severity
,
const
char
*
text
,
msgw_ePop
pop
=
msgw_ePop_Default
,
pwr_tOid
oid
=
pwr_cNOid
,
bool
is_plc
=
false
);
static
void
set_default
(
MsgWindow
*
msgw
)
{
default_window
=
msgw
;}
static
void
message
(
int
severity
,
const
char
*
text
,
msgw_ePop
pop
=
msgw_ePop_Default
,
pwr_tOid
oid
=
pwr_cNOid
,
bool
is_plc
=
false
);
...
...
src/lib/co/src/co_rtmon.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_rtmon.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_statusmon_nodelist.cpp -- Status Monitor */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "co_lng.h"
#include "co_wow.h"
#include "co_rtmon.h"
#include "rt_syi.h"
#include "rt_xnav_msg.h"
RtMon
::
RtMon
(
void
*
nodelist_parent_ctx
,
char
*
nodelist_name
,
pwr_tStatus
*
status
)
:
parent_ctx
(
nodelist_parent_ctx
),
nodelistnav
(
NULL
),
rtmon_displayed
(
0
),
help_cb
(
0
),
close_cb
(
0
)
{
pwr_tStatus
sts
;
syi_NodeName
(
&
sts
,
nodename
,
sizeof
(
nodename
));
*
status
=
1
;
}
//
// Delete nodelist
//
RtMon
::~
RtMon
()
{
}
void
RtMon
::
activate_help
()
{
if
(
help_cb
)
(
help_cb
)(
parent_ctx
,
"runtime monitor"
);
}
void
RtMon
::
activate_start
()
{
char
cmd
[]
=
"rt_ini -i &"
;
system
(
cmd
);
}
void
RtMon
::
activate_restart
()
{
char
cmd
[]
=
"rt_ini -r"
;
system
(
cmd
);
}
void
RtMon
::
activate_stop
()
{
char
cmd
[]
=
"rt_ini -s"
;
system
(
cmd
);
}
void
RtMon
::
activate_reset
()
{
char
cmd
[]
=
"source pwr_stop.sh"
;
system
(
cmd
);
}
void
RtMon
::
activate_xtt
()
{
char
cmd
[]
=
"rt_xtt -q &"
;
system
(
cmd
);
}
void
RtMon
::
activate_op
()
{
char
cmd
[]
=
"rt_xtt -q -s -c &"
;
system
(
cmd
);
}
src/lib/co/src/co_rtmon.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_rtmon.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_rtmon_h
#define co_rtmon_h
/* co_rtmon.h -- Status Monitor node list */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef co_statusmon_nodelistnav
# include "co_statusmon_nodelistnav.h"
#endif
class
CoWow
;
class
MsgWindow
;
class
RtMon
{
public:
RtMon
(
void
*
rtmon_parent_ctx
,
char
*
rtmon_name
,
pwr_tStatus
*
status
);
virtual
~
RtMon
();
void
*
parent_ctx
;
char
name
[
80
];
NodelistNav
*
nodelistnav
;
int
rtmon_displayed
;
void
(
*
help_cb
)(
void
*
,
char
*
);
void
(
*
close_cb
)(
void
*
);
void
(
*
india_ok_cb
)(
RtMon
*
,
char
*
);
CoWow
*
wow
;
char
nodename
[
40
];
virtual
void
pop
()
{}
virtual
void
set_clock_cursor
()
{}
virtual
void
reset_cursor
()
{}
virtual
void
free_cursor
()
{}
void
set_scantime
(
float
scantime
)
{
nodelistnav
->
scantime
=
int
(
scantime
*
1000
);}
void
activate_help
();
void
activate_start
();
void
activate_restart
();
void
activate_stop
();
void
activate_reset
();
void
activate_xtt
();
void
activate_op
();
};
#endif
src/lib/co/src/co_statusmon_nodelist.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelist.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_statusmon_nodelist.cpp -- Status Monitor */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include "co_cdh.h"
#include "co_time.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "co_lng.h"
#include "co_wow.h"
#include "co_statusmon_nodelist.h"
#include "rt_xnav_msg.h"
Nodelist
::
Nodelist
(
void
*
nodelist_parent_ctx
,
char
*
nodelist_name
,
pwr_tStatus
*
status
)
:
parent_ctx
(
nodelist_parent_ctx
),
nodelistnav
(
NULL
),
nodelist_displayed
(
0
),
help_cb
(
0
),
close_cb
(
0
)
{
*
status
=
1
;
}
//
// Delete nodelist
//
Nodelist
::~
Nodelist
()
{
}
void
Nodelist
::
activate_help
()
{
if
(
help_cb
)
(
help_cb
)(
parent_ctx
,
"consolelog"
);
}
void
Nodelist
::
find_node_cb
(
void
*
ctx
,
pwr_tOid
oid
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
ctx
;
if
(
nodelist
->
nodelistnav
->
select_node
(
oid
.
oix
))
nodelist
->
pop
();
}
void
Nodelist
::
add_node_ok
(
Nodelist
*
nodelist
,
char
*
node_name
)
{
nodelist
->
nodelistnav
->
add_node
(
node_name
);
}
void
Nodelist
::
activate_add_node
()
{
open_input_dialog
(
"Enter node name"
,
"Add Node"
,
""
,
add_node_ok
);
}
void
remove_node_ok
(
void
*
ctx
,
void
*
data
)
{
Nodelist
*
nodelist
=
(
Nodelist
*
)
ctx
;
nodelist
->
nodelistnav
->
remove_node
(
(
char
*
)
data
);
}
void
Nodelist
::
activate_remove_node
()
{
static
char
node_name
[
80
];
char
msg
[
100
];
int
sts
;
sts
=
nodelistnav
->
get_selected_node
(
node_name
);
if
(
EVEN
(
sts
))
{
nodelistnav
->
wow
->
DisplayError
(
"Remove Node"
,
"Select a node"
);
return
;
}
sprintf
(
msg
,
"Do you want to remove node %s"
,
node_name
);
nodelistnav
->
wow
->
DisplayQuestion
(
this
,
"Remove Node"
,
msg
,
remove_node_ok
,
NULL
,
node_name
);
}
void
Nodelist
::
activate_save
()
{
nodelistnav
->
save
();
}
src/lib/co/src/co_statusmon_nodelist.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelist.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_statusmon_nodelist_h
#define co_statusmon_nodelist_h
/* co_statusmon_nodelist.h -- Status Monitor node list */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef co_statusmon_nodelistnav
# include "co_statusmon_nodelistnav.h"
#endif
class
CoWow
;
class
MsgWindow
;
class
Nodelist
{
public:
Nodelist
(
void
*
nodelist_parent_ctx
,
char
*
nodelist_name
,
pwr_tStatus
*
status
);
virtual
~
Nodelist
();
void
*
parent_ctx
;
char
name
[
80
];
NodelistNav
*
nodelistnav
;
int
nodelist_displayed
;
void
(
*
help_cb
)(
void
*
,
char
*
);
void
(
*
close_cb
)(
void
*
);
void
(
*
india_ok_cb
)(
Nodelist
*
,
char
*
);
CoWow
*
wow
;
MsgWindow
*
msg_window
;
virtual
void
pop
()
{}
virtual
void
set_clock_cursor
()
{}
virtual
void
reset_cursor
()
{}
virtual
void
free_cursor
()
{}
virtual
void
open_input_dialog
(
char
*
text
,
char
*
title
,
char
*
init_text
,
void
(
*
ok_cb
)(
Nodelist
*
,
char
*
))
{}
void
set_scantime
(
float
scantime
)
{
nodelistnav
->
scantime
=
int
(
scantime
*
1000
);}
void
activate_help
();
void
activate_add_node
();
void
activate_remove_node
();
void
activate_save
();
static
void
find_node_cb
(
void
*
ctx
,
pwr_tOid
oid
);
static
void
add_node_ok
(
Nodelist
*
nodelist
,
char
*
node_name
);
};
#endif
src/lib/co/src/co_statusmon_nodelistnav.cpp
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelistnav.cpp,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* co_statusmon_nodelistnav.cpp -- Status Monitor. */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include "co_cdh.h"
#include "co_dcli.h"
#include "co_time.h"
#include "co_wow.h"
#include "co_msgwindow.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_syi.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "co_statusmon_nodelistnav.h"
#include "statussrv_utl.h"
#include "xnav_bitmap_leaf12.h"
#include "xnav_bitmap_map12.h"
#include "xnav_bitmap_openmap12.h"
#include "xnav_bitmap_attr12.h"
const
char
NodelistNav
::
config_file
[
40
]
=
"$HOME/rt_statusmon.dat"
;
//
// Free pixmaps
//
void
NodelistNavBrow
::
free_pixmaps
()
{
brow_FreeAnnotPixmap
(
ctx
,
pixmap_leaf
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_map
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_openmap
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_attr
);
}
//
// Create pixmaps for leaf, closed map and open map
//
void
NodelistNavBrow
::
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
);
for
(
i
=
0
;
i
<
9
;
i
++
)
{
pixmap_data
[
i
].
width
=
xnav_bitmap_attr12_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr12_height
;
pixmap_data
[
i
].
bits
=
(
char
*
)
xnav_bitmap_attr12_bits
;
}
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_attr
);
}
//
// Create nodeclasses
//
void
NodelistNavBrow
::
create_nodeclasses
()
{
allocate_pixmaps
();
// Create common-class
// Nodeclass for Undefinied message
brow_CreateNodeClass
(
ctx
,
"Undef"
,
flow_eNodeGroup_Common
,
&
nc_node
);
brow_AddFrame
(
nc_node
,
0
,
0
,
35
,
0.8
,
flow_eDrawType_LineGray
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_node
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddFilledRect
(
nc_node
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_DarkGray
);
brow_AddRect
(
nc_node
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_Line
,
0
,
0
);
brow_AddAnnot
(
nc_node
,
2.2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_node
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_node
,
21
,
0.6
,
2
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
// Create attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"Attr"
,
flow_eNodeGroup_Common
,
&
nc_attr
);
brow_AddFrame
(
nc_attr
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_LineGray
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_attr
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_attr
,
2.2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_attr
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create system status attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"SysStsAttr"
,
flow_eNodeGroup_Common
,
&
nc_sys_sts_attr
);
brow_AddFrame
(
nc_sys_sts_attr
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_LineGray
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_sys_sts_attr
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddFilledRect
(
nc_sys_sts_attr
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_DarkGray
);
brow_AddRect
(
nc_sys_sts_attr
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_Line
,
0
,
0
);
brow_AddAnnot
(
nc_sys_sts_attr
,
2.2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_sys_sts_attr
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create system status attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"StsAttr"
,
flow_eNodeGroup_Common
,
&
nc_sts_attr
);
brow_AddFrame
(
nc_sts_attr
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_LineGray
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_sts_attr
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddFilledRect
(
nc_sts_attr
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_DarkGray
);
brow_AddRect
(
nc_sts_attr
,
1.3
,
0.15
,
0.4
,
0.4
,
flow_eDrawType_Line
,
0
,
0
);
brow_AddAnnot
(
nc_sts_attr
,
2.2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_sts_attr
,
5
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_sts_attr
,
10
,
0.6
,
2
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
}
void
NodelistNavBrow
::
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
,
nodelistnav
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB1Click
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB1DoubleClick
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB3Press
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB3Down
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_SelectClear
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_ObjectDeleted
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Up
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Down
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PageUp
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PageDown
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_ScrollUp
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_ScrollDown
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Right
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Left
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PF3
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Radiobutton
,
flow_eEventType_CallBack
,
NodelistNav
::
brow_cb
);
}
//
// Backcall routine called at creation of the brow widget
// Enable event, create nodeclasses and insert the root objects.
//
int
NodelistNav
::
init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
)
{
int
sts
;
NodelistNav
*
nodelistnav
=
(
NodelistNav
*
)
client_data
;
BrowCtx
*
ctx
=
(
BrowCtx
*
)
fctx
;
nodelistnav
->
brow
=
new
NodelistNavBrow
(
ctx
,
(
void
*
)
nodelistnav
);
nodelistnav
->
brow
->
brow_setup
();
nodelistnav
->
brow
->
create_nodeclasses
();
if
(
strcmp
(
nodelistnav
->
nodename
,
""
)
!=
0
)
{
nodelistnav
->
add_node
(
nodelistnav
->
nodename
);
nodelistnav
->
node_list
[
0
].
item
->
open_children
(
nodelistnav
,
0
,
0
);
}
else
nodelistnav
->
read
();
sts
=
brow_TraceInit
(
ctx
,
trace_connect_bc
,
trace_disconnect_bc
,
trace_scan_bc
);
nodelistnav
->
trace_started
=
1
;
nodelistnav
->
trace_start
();
return
1
;
}
NodelistNav
::
NodelistNav
(
void
*
nodelist_parent_ctx
,
MsgWindow
*
nodelistnav_msg_window
,
char
*
nodelistnav_nodename
,
int
nodelistnav_msgw_pop
)
:
parent_ctx
(
nodelist_parent_ctx
),
nodelist_size
(
0
),
trace_started
(
0
),
scantime
(
4000
),
first_scan
(
1
),
msg_window
(
nodelistnav_msg_window
),
msgw_pop
(
nodelistnav_msgw_pop
)
{
if
(
nodelistnav_nodename
)
strcpy
(
nodename
,
nodelistnav_nodename
);
else
strcpy
(
nodename
,
""
);
}
//
// Delete ev
//
NodelistNav
::~
NodelistNav
()
{
}
NodelistNavBrow
::~
NodelistNavBrow
()
{
free_pixmaps
();
}
void
NodelistNav
::
read
()
{
char
line
[
400
];
int
sts
;
FILE
*
fp
;
pwr_tFileName
fname
;
ItemNode
*
item
;
brow_tNode
dest
=
0
;
dcli_translate_filename
(
fname
,
config_file
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
;
while
(
1
)
{
sts
=
dcli_read_line
(
line
,
sizeof
(
line
),
fp
);
if
(
!
sts
)
break
;
dcli_trim
(
line
,
line
);
if
(
line
[
0
]
==
0
||
line
[
0
]
==
'#'
||
line
[
0
]
==
'!'
)
continue
;
NodelistNode
node
(
line
);
node_list
.
push_back
(
node
);
}
fclose
(
fp
);
brow_SetNodraw
(
brow
->
ctx
);
brow_DeleteAll
(
brow
->
ctx
);
for
(
int
i
=
0
;
i
<
(
int
)
node_list
.
size
();
i
++
)
{
item
=
new
ItemNode
(
this
,
node_list
[
i
].
node_name
,
dest
,
flow_eDest_After
);
dest
=
item
->
node
;
node_list
[
i
].
item
=
item
;
}
brow_ResetNodraw
(
brow
->
ctx
);
brow_Redraw
(
brow
->
ctx
,
0
);
}
//
// Zoom
//
void
NodelistNav
::
zoom
(
double
zoom_factor
)
{
brow_Zoom
(
brow
->
ctx
,
zoom_factor
);
}
//
// Return to base zoom factor
//
void
NodelistNav
::
unzoom
()
{
brow_UnZoom
(
brow
->
ctx
);
}
void
NodelistNav
::
set_nodraw
()
{
brow_SetNodraw
(
brow
->
ctx
);
}
void
NodelistNav
::
reset_nodraw
()
{
brow_ResetNodraw
(
brow
->
ctx
);
brow_Redraw
(
brow
->
ctx
,
0
);
}
//
// Callbacks from brow
//
int
NodelistNav
::
brow_cb
(
FlowCtx
*
ctx
,
flow_tEvent
event
)
{
NodelistNav
*
nodelistnav
;
ItemNode
*
item
;
if
(
event
->
event
==
flow_eEvent_ObjectDeleted
)
{
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
delete
item
;
return
1
;
}
brow_GetCtxUserData
(
(
BrowCtx
*
)
ctx
,
(
void
**
)
&
nodelistnav
);
switch
(
event
->
event
)
{
case
flow_eEvent_Key_Up
:
{
brow_tNode
*
nodelist
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
nodelistnav
->
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
!
node_count
)
{
sts
=
brow_GetLastVisible
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
if
(
!
brow_IsVisible
(
nodelistnav
->
brow
->
ctx
,
nodelist
[
0
],
flow_eVisible_Partial
))
{
sts
=
brow_GetLastVisible
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
sts
=
brow_GetPrevious
(
nodelistnav
->
brow
->
ctx
,
nodelist
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
sts
=
brow_GetLast
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
{
if
(
node_count
)
free
(
nodelist
);
return
1
;
}
}
}
}
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
nodelistnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
nodelistnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
nodelistnav
->
brow
->
ctx
,
object
,
0.25
);
if
(
node_count
)
free
(
nodelist
);
break
;
}
case
flow_eEvent_Key_Down
:
{
brow_tNode
*
nodelist
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
nodelistnav
->
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
!
node_count
)
{
sts
=
brow_GetFirstVisible
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
if
(
!
brow_IsVisible
(
nodelistnav
->
brow
->
ctx
,
nodelist
[
0
],
flow_eVisible_Partial
))
{
sts
=
brow_GetFirstVisible
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
sts
=
brow_GetNext
(
nodelistnav
->
brow
->
ctx
,
nodelist
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
sts
=
brow_GetFirst
(
nodelistnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
{
if
(
node_count
)
free
(
nodelist
);
return
1
;
}
}
}
}
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
nodelistnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
nodelistnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
nodelistnav
->
brow
->
ctx
,
object
,
0.75
);
if
(
node_count
)
free
(
nodelist
);
break
;
}
case
flow_eEvent_Key_PageDown
:
{
brow_Page
(
nodelistnav
->
brow
->
ctx
,
0.9
);
break
;
}
case
flow_eEvent_Key_PageUp
:
{
brow_Page
(
nodelistnav
->
brow
->
ctx
,
-
0.9
);
break
;
}
case
flow_eEvent_ScrollDown
:
{
brow_Page
(
nodelistnav
->
brow
->
ctx
,
0.1
);
break
;
}
case
flow_eEvent_ScrollUp
:
{
brow_Page
(
nodelistnav
->
brow
->
ctx
,
-
0.1
);
break
;
}
case
flow_eEvent_SelectClear
:
brow_ResetSelectInverse
(
nodelistnav
->
brow
->
ctx
);
break
;
case
flow_eEvent_MB1Click
:
// Select
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
brow_MeasureNode
(
event
->
object
.
object
,
&
ll_x
,
&
ll_y
,
&
ur_x
,
&
ur_y
);
if
(
event
->
object
.
x
<
ll_x
+
1.0
)
{
// Simulate doubleclick
flow_tEvent
doubleclick_event
;
int
sts
;
doubleclick_event
=
(
flow_tEvent
)
calloc
(
1
,
sizeof
(
*
doubleclick_event
));
memcpy
(
doubleclick_event
,
event
,
sizeof
(
*
doubleclick_event
));
doubleclick_event
->
event
=
flow_eEvent_MB1DoubleClick
;
sts
=
brow_cb
(
ctx
,
doubleclick_event
);
free
(
(
char
*
)
doubleclick_event
);
return
sts
;
}
if
(
brow_FindSelectedObject
(
nodelistnav
->
brow
->
ctx
,
event
->
object
.
object
))
{
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
}
else
{
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
brow_SetInverse
(
event
->
object
.
object
,
1
);
brow_SelectInsert
(
nodelistnav
->
brow
->
ctx
,
event
->
object
.
object
);
}
break
;
default:
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
}
break
;
case
flow_eEvent_Key_Right
:
{
brow_tNode
*
nodelist
;
int
node_count
;
brow_GetSelectedNodes
(
nodelistnav
->
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
!
node_count
)
return
1
;
brow_GetUserData
(
nodelist
[
0
],
(
void
**
)
&
item
);
item
->
open_children
(
nodelistnav
,
0
,
0
);
nodelistnav
->
force_trace_scan
();
free
(
nodelist
);
break
;
}
case
flow_eEvent_Key_Left
:
{
brow_tNode
*
nodelist
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
nodelistnav
->
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
!
node_count
)
return
1
;
if
(
brow_IsOpen
(
nodelist
[
0
]))
// Close this node
object
=
nodelist
[
0
];
else
{
// Close parent
sts
=
brow_GetParent
(
nodelistnav
->
brow
->
ctx
,
nodelist
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
free
(
nodelist
);
return
1
;
}
}
brow_GetUserData
(
object
,
(
void
**
)
&
item
);
item
->
close
(
nodelistnav
,
0
,
0
);
brow_SelectClear
(
nodelistnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
nodelistnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
nodelistnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
nodelistnav
->
brow
->
ctx
,
object
,
0.25
);
free
(
nodelist
);
break
;
}
case
flow_eEvent_MB1DoubleClick
:
{
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
item
->
open_children
(
nodelistnav
,
event
->
object
.
x
,
event
->
object
.
y
);
break
;
default:
;
}
break
;
}
case
flow_eEvent_MB3Down
:
{
brow_SetClickSensitivity
(
nodelistnav
->
brow
->
ctx
,
flow_mSensitivity_MB3Press
);
break
;
}
default:
;
}
return
1
;
}
int
NodelistNav
::
trace_scan_bc
(
brow_tObject
object
,
void
*
p
)
{
ItemBase
*
base_item
;
char
buf
[
200
];
int
len
;
brow_GetUserData
(
object
,
(
void
**
)
&
base_item
);
switch
(
base_item
->
type
)
{
case
nodelistnav_eItemType_Attr
:
{
ItemAttr
*
item
=
(
ItemAttr
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
size
>
(
int
)
sizeof
(
item
->
old_value
)
&&
item
->
type_id
==
pwr_eType_String
&&
strlen
((
char
*
)
p
)
<
sizeof
(
item
->
old_value
)
&&
strcmp
(
(
char
*
)
p
,
item
->
old_value
)
==
0
)
// No change since last time
return
1
;
else
if
(
memcmp
(
item
->
old_value
,
p
,
item
->
size
)
==
0
)
// No change since last time
return
1
;
}
else
item
->
first_scan
=
0
;
attrvalue_to_string
(
item
->
type_id
,
p
,
buf
,
sizeof
(
buf
),
&
len
,
NULL
);
brow_SetAnnotation
(
object
,
1
,
buf
,
len
);
memcpy
(
item
->
old_value
,
p
,
min
(
item
->
size
,
(
int
)
sizeof
(
item
->
old_value
)));
break
;
}
case
nodelistnav_eItemType_AttrSysSts
:
{
ItemAttrSysSts
*
item
=
(
ItemAttrSysSts
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
size
>
(
int
)
sizeof
(
item
->
old_value
)
&&
item
->
type_id
==
pwr_eType_String
&&
strlen
((
char
*
)
p
)
<
sizeof
(
item
->
old_value
)
&&
strcmp
(
(
char
*
)
p
,
item
->
old_value
)
==
0
)
// No change since last time
return
1
;
else
if
(
memcmp
(
item
->
old_value
,
p
,
item
->
size
)
==
0
)
// No change since last time
return
1
;
}
else
item
->
first_scan
=
0
;
attrvalue_to_string
(
item
->
type_id
,
p
,
buf
,
sizeof
(
buf
),
&
len
,
NULL
);
brow_SetAnnotation
(
object
,
1
,
buf
,
len
);
memcpy
(
item
->
old_value
,
p
,
min
(
item
->
size
,
(
int
)
sizeof
(
item
->
old_value
)));
flow_eDrawType
color
;
pwr_tStatus
sts
=
*
(
pwr_tStatus
*
)
item
->
status_p
;
if
(
sts
==
0
)
color
=
flow_eDrawType_DarkGray
;
else
{
switch
(
sts
&
7
)
{
case
3
:
case
1
:
color
=
flow_eDrawType_Green
;
break
;
case
0
:
color
=
flow_eDrawType_Yellow
;
break
;
case
2
:
case
4
:
color
=
flow_eDrawType_LineRed
;
break
;
default:
color
=
flow_eDrawType_DarkGray
;
}
}
brow_SetFillColor
(
item
->
node
,
color
);
break
;
}
case
nodelistnav_eItemType_AttrSts
:
{
ItemAttrSts
*
item
=
(
ItemAttrSts
*
)
base_item
;
if
(
!
item
->
first_scan
)
{
if
(
strcmp
(
(
char
*
)
p
,
item
->
old_value
)
==
0
&&
strcmp
(
item
->
name_p
,
item
->
old_name
)
==
0
)
// No change since last time
return
1
;
}
else
item
->
first_scan
=
0
;
attrvalue_to_string
(
item
->
type_id
,
p
,
buf
,
sizeof
(
buf
),
&
len
,
NULL
);
brow_SetAnnotation
(
object
,
1
,
item
->
name_p
,
strlen
(
item
->
name_p
));
brow_SetAnnotation
(
object
,
2
,
item
->
value_p
,
strlen
(
item
->
value_p
));
strcpy
(
item
->
old_value
,
item
->
value_p
);
strcpy
(
item
->
old_name
,
item
->
name_p
);
flow_eDrawType
color
;
pwr_tStatus
sts
=
*
(
pwr_tStatus
*
)
item
->
status_p
;
if
(
sts
==
0
)
color
=
flow_eDrawType_DarkGray
;
else
{
switch
(
sts
&
7
)
{
case
3
:
case
1
:
color
=
flow_eDrawType_Green
;
break
;
case
0
:
color
=
flow_eDrawType_Yellow
;
break
;
case
2
:
case
4
:
color
=
flow_eDrawType_LineRed
;
break
;
default:
color
=
flow_eDrawType_DarkGray
;
}
}
brow_SetFillColor
(
item
->
node
,
color
);
break
;
}
default:
;
}
return
1
;
}
int
NodelistNav
::
trace_connect_bc
(
brow_tObject
object
,
char
*
name
,
char
*
attr
,
flow_eTraceType
type
,
void
**
p
)
{
ItemBase
*
base_item
;
if
(
strcmp
(
name
,
""
)
==
0
)
return
1
;
brow_GetUserData
(
object
,
(
void
**
)
&
base_item
);
switch
(
base_item
->
type
)
{
case
nodelistnav_eItemType_Attr
:
{
ItemAttr
*
item
=
(
ItemAttr
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
*
p
=
item
->
value_p
;
break
;
}
case
nodelistnav_eItemType_AttrSysSts
:
{
ItemAttrSysSts
*
item
=
(
ItemAttrSysSts
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
*
p
=
item
->
value_p
;
break
;
}
case
nodelistnav_eItemType_AttrSts
:
{
ItemAttrSts
*
item
=
(
ItemAttrSts
*
)
base_item
;
*
p
=
item
->
value_p
;
break
;
}
default:
;
}
return
1
;
}
int
NodelistNav
::
trace_disconnect_bc
(
brow_tObject
object
)
{
return
1
;
}
void
NodelistNav
::
force_trace_scan
()
{
if
(
trace_started
)
brow_TraceScan
(
brow
->
ctx
);
}
void
NodelistNav
::
message
(
pwr_tStatus
sts
,
char
*
node
,
int
idx
,
char
*
text
)
{
int
severity
;
char
msg
[
200
];
pwr_tOid
oid
=
{
0
,
1
};
if
(
!
msg_window
)
return
;
switch
(
sts
&
7
)
{
case
3
:
severity
=
'S'
;
case
1
:
severity
=
'I'
;
break
;
case
0
:
severity
=
'W'
;
break
;
case
2
:
severity
=
'E'
;
break
;
case
4
:
severity
=
'F'
;
break
;
default:
severity
=
' '
;
}
strcpy
(
msg
,
node
);
strcat
(
msg
,
" "
);
strncat
(
msg
,
text
,
sizeof
(
msg
)
-
strlen
(
msg
));
oid
.
oix
=
idx
;
msgw_ePop
pop
;
if
(
msgw_pop
)
pop
=
msgw_ePop_Default
;
else
pop
=
msgw_ePop_No
;
msg_window
->
msg
(
severity
,
msg
,
pop
,
oid
);
if
(
EVEN
(
sts
))
beep
();
}
int
NodelistNav
::
select_node
(
int
idx
)
{
if
(
idx
>=
(
int
)
node_list
.
size
())
return
0
;
brow_tObject
object
=
node_list
[
idx
].
item
->
node
;
brow_SelectClear
(
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
brow
->
ctx
,
object
,
0.25
);
return
1
;
}
int
NodelistNav
::
update_nodes
()
{
pwr_tStatus
sts
;
statussrv_sGetStatus
response
;
int
nodraw
=
0
;
for
(
int
i
=
0
;
i
<
(
int
)
node_list
.
size
();
i
++
)
{
sts
=
statussrv_GetStatus
(
node_list
[
i
].
node_name
,
&
response
);
if
(
!
first_scan
&&
ODD
(
sts
)
&&
EVEN
(
node_list
[
i
].
connection_sts
))
message
(
sts
,
node_list
[
i
].
node_name
,
i
,
"Connection up to server"
);
else
if
(
(
!
first_scan
&&
EVEN
(
sts
)
&&
ODD
(
node_list
[
i
].
connection_sts
))
||
first_scan
&&
EVEN
(
sts
))
message
(
sts
,
node_list
[
i
].
node_name
,
i
,
"Connection down to server"
);
node_list
[
i
].
connection_sts
=
sts
;
if
(
ODD
(
sts
))
{
if
(
memcmp
(
&
node_list
[
i
].
item
->
data
.
BootTime
,
&
response
.
BootTime
,
sizeof
(
pwr_tTime
))
&&
node_list
[
i
].
init_done
)
{
// System restarted
message
(
2
,
node_list
[
i
].
node_name
,
i
,
"Proview restarted"
);
}
if
(
memcmp
(
&
node_list
[
i
].
item
->
data
.
RestartTime
,
&
response
.
RestartTime
,
sizeof
(
pwr_tTime
))
&&
node_list
[
i
].
init_done
)
{
// System restarted
message
(
2
,
node_list
[
i
].
node_name
,
i
,
"Proview restarted"
);
}
}
if
(
node_list
[
i
].
item
->
data
.
SystemStatus
!=
response
.
SystemStatus
)
{
// Change color
if
(
!
nodraw
)
{
brow_SetNodraw
(
brow
->
ctx
);
nodraw
=
1
;
}
node_list
[
i
].
item
->
update_color
(
this
,
response
.
SystemStatus
);
// Message if switch to error
if
(
!
first_scan
&&
ODD
(
sts
))
{
message
(
response
.
SystemStatus
,
node_list
[
i
].
node_name
,
i
,
response
.
SystemStatusStr
);
#if 0
switch ( node_list[i].item->data.SystemStatus & 7) {
case 3:
case 1:
case 0: {
switch ( response.SystemStatus & 7) {
case 2:
case 4: {
// From Info or Warning to Error or Fatal
char msg[200];
sprintf( msg, "Error status on %s\n\n%s", node_list[i].node_name,
response.SystemStatusStr);
wow->DisplayError( "System Status", msg);
beep();
break;
}
}
break;
}
}
#endif
}
else
if
(
EVEN
(
response
.
SystemStatus
)
&&
ODD
(
sts
))
// Message even status first scan
message
(
response
.
SystemStatus
,
node_list
[
i
].
node_name
,
i
,
response
.
SystemStatusStr
);
}
if
(
strcmp
(
node_list
[
i
].
item
->
data
.
SystemStatusStr
,
response
.
SystemStatusStr
)
!=
0
)
brow_SetAnnotation
(
node_list
[
i
].
item
->
node
,
2
,
response
.
SystemStatusStr
,
strlen
(
response
.
SystemStatusStr
));
node_list
[
i
].
item
->
data
.
SystemStatus
=
response
.
SystemStatus
;
strncpy
(
node_list
[
i
].
item
->
data
.
SystemStatusStr
,
response
.
SystemStatusStr
,
sizeof
(
node_list
[
i
].
item
->
data
.
SystemStatusStr
));
if
(
ODD
(
sts
))
{
if
(
strcmp
(
node_list
[
i
].
item
->
data
.
Description
,
response
.
Description
)
!=
0
)
brow_SetAnnotation
(
node_list
[
i
].
item
->
node
,
1
,
response
.
Description
,
strlen
(
response
.
Description
));
strncpy
(
node_list
[
i
].
item
->
data
.
Description
,
response
.
Description
,
sizeof
(
node_list
[
i
].
item
->
data
.
Description
));
strncpy
(
node_list
[
i
].
item
->
data
.
Version
,
response
.
Version
,
sizeof
(
node_list
[
i
].
item
->
data
.
Version
));
node_list
[
i
].
item
->
data
.
SystemTime
=
response
.
SystemTime
;
node_list
[
i
].
item
->
data
.
BootTime
=
response
.
BootTime
;
node_list
[
i
].
item
->
data
.
RestartTime
=
response
.
RestartTime
;
node_list
[
i
].
item
->
data
.
Restarts
=
response
.
Restarts
;
if
(
!
node_list
[
i
].
init_done
)
node_list
[
i
].
init_done
=
1
;
if
(
node_list
[
i
].
item
->
syssts_open
)
{
statussrv_GetExtStatus
(
node_list
[
i
].
node_name
,
&
node_list
[
i
].
item
->
xdata
);
}
}
}
if
(
nodraw
)
{
brow_ResetNodraw
(
brow
->
ctx
);
brow_Redraw
(
brow
->
ctx
,
0
);
}
first_scan
=
0
;
return
1
;
}
void
NodelistNav
::
save
()
{
pwr_tFileName
fname
;
FILE
*
fp
;
dcli_translate_filename
(
fname
,
config_file
);
fp
=
fopen
(
fname
,
"w"
);
if
(
!
fp
)
return
;
for
(
int
i
=
0
;
i
<
(
int
)
node_list
.
size
();
i
++
)
{
fprintf
(
fp
,
"%s
\n
"
,
node_list
[
i
].
node_name
);
}
fclose
(
fp
);
}
int
NodelistNav
::
get_selected_node
(
char
*
name
)
{
brow_tNode
*
nodelist
;
int
node_count
;
ItemNode
*
item
;
brow_GetSelectedNodes
(
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
node_count
!=
1
)
return
0
;
brow_GetUserData
(
nodelist
[
0
],
(
void
**
)
&
item
);
free
(
nodelist
);
if
(
item
->
type
!=
nodelistnav_eItemType_Node
)
return
0
;
strcpy
(
name
,
item
->
name
);
return
1
;
}
void
NodelistNav
::
remove_node
(
char
*
name
)
{
for
(
int
i
=
0
;
i
<
(
int
)
node_list
.
size
();
i
++
)
{
if
(
cdh_NoCaseStrcmp
(
name
,
node_list
[
i
].
node_name
)
==
0
)
{
brow_DeleteNode
(
brow
->
ctx
,
node_list
[
i
].
item
->
node
);
for
(
int
j
=
i
;
j
<
(
int
)
node_list
.
size
()
-
1
;
j
++
)
node_list
[
j
]
=
node_list
[
j
+
1
];
node_list
.
pop_back
();
break
;
}
}
}
void
NodelistNav
::
add_node
(
char
*
name
)
{
brow_tNode
*
nodelist
;
int
node_count
;
ItemNode
*
item
;
int
idx
=
0
;
bool
found
;
brow_GetSelectedNodes
(
brow
->
ctx
,
&
nodelist
,
&
node_count
);
if
(
node_count
>
0
)
{
// Get index for selected node
found
=
false
;
for
(
int
i
=
0
;
i
<
(
int
)
node_list
.
size
();
i
++
)
{
if
(
node_list
[
i
].
item
->
node
==
nodelist
[
0
])
{
idx
=
i
+
1
;
found
=
true
;
break
;
}
}
if
(
!
found
)
return
;
NodelistNode
node
(
name
);
if
(
idx
==
(
int
)
node_list
.
size
())
node_list
.
push_back
(
node
);
else
{
node_list
.
push_back
(
node_list
[
node_list
.
size
()
-
1
]);
for
(
int
i
=
node_list
.
size
()
-
1
;
i
>
idx
;
i
--
)
{
node_list
[
i
]
=
node_list
[
i
-
1
];
}
node_list
[
idx
]
=
node
;
}
item
=
new
ItemNode
(
this
,
name
,
nodelist
[
0
],
flow_eDest_After
);
node_list
[
idx
].
item
=
item
;
}
else
{
// Nothing selected, insert last
NodelistNode
node
(
name
);
node_list
.
push_back
(
node
);
item
=
new
ItemNode
(
this
,
name
,
0
,
flow_eDest_IntoLast
);
node_list
[
node_list
.
size
()
-
1
].
item
=
item
;
}
}
//
// Convert attribute value to string
//
void
NodelistNav
::
attrvalue_to_string
(
int
type_id
,
void
*
value_ptr
,
char
*
str
,
int
size
,
int
*
len
,
char
*
format
)
{
if
(
value_ptr
==
0
)
{
strcpy
(
str
,
"UNDEFINED"
);
return
;
}
switch
(
type_id
)
{
case
pwr_eType_Boolean
:
{
if
(
!
format
)
*
len
=
sprintf
(
str
,
"%d"
,
*
(
pwr_tBoolean
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
pwr_tBoolean
*
)
value_ptr
);
break
;
}
case
pwr_eType_Float32
:
{
if
(
!
format
)
*
len
=
sprintf
(
str
,
"%f"
,
*
(
pwr_tFloat32
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
pwr_tFloat32
*
)
value_ptr
);
break
;
}
case
pwr_eType_Int32
:
{
if
(
!
format
)
*
len
=
sprintf
(
str
,
"%d"
,
*
(
pwr_tInt32
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
pwr_tInt32
*
)
value_ptr
);
break
;
}
case
pwr_eType_String
:
{
strncpy
(
str
,
(
char
*
)
value_ptr
,
size
);
str
[
size
-
1
]
=
0
;
*
len
=
strlen
(
str
);
break
;
}
case
pwr_eType_Time
:
{
char
timstr
[
40
];
pwr_tStatus
sts
;
sts
=
time_AtoAscii
(
(
pwr_tTime
*
)
value_ptr
,
time_eFormat_DateAndTime
,
timstr
,
sizeof
(
timstr
));
if
(
EVEN
(
sts
))
strcpy
(
timstr
,
"-"
);
*
len
=
sprintf
(
str
,
"%s"
,
timstr
);
break
;
}
default:
;
}
}
ItemNode
::
ItemNode
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
item_nodelistnav
,
item_name
),
syssts_open
(
0
)
{
type
=
nodelistnav_eItemType_Node
;
strcpy
(
name
,
item_name
);
memset
(
&
xdata
,
0
,
sizeof
(
xdata
));
brow_CreateNode
(
nodelistnav
->
brow
->
ctx
,
item_name
,
nodelistnav
->
brow
->
nc_node
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotation
(
node
,
0
,
name
,
strlen
(
name
));
brow_SetAnnotation
(
node
,
1
,
data
.
Description
,
strlen
(
data
.
Description
));
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
}
int
ItemNode
::
update_color
(
NodelistNav
*
nodelistnav
,
pwr_tStatus
system_status
)
{
flow_eDrawType
color
;
if
(
system_status
==
0
)
color
=
flow_eDrawType_DarkGray
;
else
{
switch
(
system_status
&
7
)
{
case
3
:
case
1
:
color
=
flow_eDrawType_Green
;
break
;
case
0
:
color
=
flow_eDrawType_Yellow
;
break
;
case
2
:
case
4
:
color
=
flow_eDrawType_LineRed
;
break
;
default:
color
=
flow_eDrawType_DarkGray
;
}
}
brow_SetFillColor
(
node
,
color
);
return
1
;
}
int
ItemNode
::
open_children
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_CloseNode
(
nodelistnav
->
brow
->
ctx
,
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
1
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
new
ItemAttr
(
nodelistnav
,
"Description"
,
"Description"
,
pwr_eType_String
,
sizeof
(
data
.
Description
),
data
.
Description
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSysSts
(
nodelistnav
,
"SystemStatus"
,
"SystemStatus"
,
pwr_eType_String
,
sizeof
(
data
.
SystemStatusStr
),
&
data
.
SystemStatusStr
,
&
data
.
SystemStatus
,
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttr
(
nodelistnav
,
"SystemTime"
,
"SystemTime"
,
pwr_eType_Time
,
sizeof
(
data
.
SystemTime
),
&
data
.
SystemTime
,
node
,
flow_eDest_IntoLast
);
new
ItemAttr
(
nodelistnav
,
"BootTime"
,
"BootTime"
,
pwr_eType_Time
,
sizeof
(
data
.
BootTime
),
&
data
.
BootTime
,
node
,
flow_eDest_IntoLast
);
new
ItemAttr
(
nodelistnav
,
"RestartTime"
,
"RestartTime"
,
pwr_eType_Time
,
sizeof
(
data
.
RestartTime
),
&
data
.
RestartTime
,
node
,
flow_eDest_IntoLast
);
new
ItemAttr
(
nodelistnav
,
"Restarts"
,
"Restarts"
,
pwr_eType_Int32
,
sizeof
(
data
.
Restarts
),
&
data
.
Restarts
,
node
,
flow_eDest_IntoLast
);
new
ItemAttr
(
nodelistnav
,
"Version"
,
"Version"
,
pwr_eType_String
,
sizeof
(
data
.
Version
),
&
data
.
Version
,
node
,
flow_eDest_IntoLast
);
brow_SetOpen
(
node
,
1
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
int
ItemNode
::
close
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_CloseNode
(
nodelistnav
->
brow
->
ctx
,
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
1
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemAttr
::
ItemAttr
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
void
*
attr_value_p
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
item_nodelistnav
,
item_name
),
value_p
(
attr_value_p
),
first_scan
(
1
),
type_id
(
attr_type
),
size
(
attr_size
)
{
type
=
nodelistnav_eItemType_Attr
;
strcpy
(
name
,
item_name
);
memset
(
old_value
,
0
,
sizeof
(
old_value
));
brow_CreateNode
(
nodelistnav
->
brow
->
ctx
,
item_name
,
nodelistnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_attr
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
attr
,
""
,
flow_eTraceType_User
);
}
ItemAttrSysSts
::
ItemAttrSysSts
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
void
*
attr_value_p
,
void
*
attr_status_p
,
ItemNode
*
attr_parent
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
item_nodelistnav
,
item_name
),
value_p
(
attr_value_p
),
status_p
(
attr_status_p
),
first_scan
(
1
),
type_id
(
attr_type
),
size
(
attr_size
),
parent
(
attr_parent
)
{
type
=
nodelistnav_eItemType_AttrSysSts
;
strcpy
(
name
,
item_name
);
memset
(
old_value
,
0
,
sizeof
(
old_value
));
brow_CreateNode
(
nodelistnav
->
brow
->
ctx
,
item_name
,
nodelistnav
->
brow
->
nc_sys_sts_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
attr
,
""
,
flow_eTraceType_User
);
}
int
ItemAttrSysSts
::
open_children
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_CloseNode
(
nodelistnav
->
brow
->
ctx
,
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
1
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
parent
->
syssts_open
=
0
;
memset
(
&
parent
->
xdata
,
0
,
sizeof
(
parent
->
xdata
));
}
else
{
parent
->
syssts_open
=
1
;
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S1"
,
parent
->
xdata
.
ServerStsStr
[
0
],
&
parent
->
xdata
.
ServerSts
[
0
],
parent
->
xdata
.
ServerStsName
[
0
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S2"
,
parent
->
xdata
.
ServerStsStr
[
1
],
&
parent
->
xdata
.
ServerSts
[
1
],
parent
->
xdata
.
ServerStsName
[
1
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S3"
,
parent
->
xdata
.
ServerStsStr
[
2
],
&
parent
->
xdata
.
ServerSts
[
2
],
parent
->
xdata
.
ServerStsName
[
2
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S4"
,
parent
->
xdata
.
ServerStsStr
[
3
],
&
parent
->
xdata
.
ServerSts
[
3
],
parent
->
xdata
.
ServerStsName
[
3
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S5"
,
parent
->
xdata
.
ServerStsStr
[
4
],
&
parent
->
xdata
.
ServerSts
[
4
],
parent
->
xdata
.
ServerStsName
[
4
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S6"
,
parent
->
xdata
.
ServerStsStr
[
5
],
&
parent
->
xdata
.
ServerSts
[
5
],
parent
->
xdata
.
ServerStsName
[
5
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S7"
,
parent
->
xdata
.
ServerStsStr
[
6
],
&
parent
->
xdata
.
ServerSts
[
6
],
parent
->
xdata
.
ServerStsName
[
6
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S8"
,
parent
->
xdata
.
ServerStsStr
[
7
],
&
parent
->
xdata
.
ServerSts
[
7
],
parent
->
xdata
.
ServerStsName
[
7
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S9"
,
parent
->
xdata
.
ServerStsStr
[
8
],
&
parent
->
xdata
.
ServerSts
[
8
],
parent
->
xdata
.
ServerStsName
[
8
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S10"
,
parent
->
xdata
.
ServerStsStr
[
9
],
&
parent
->
xdata
.
ServerSts
[
9
],
parent
->
xdata
.
ServerStsName
[
9
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S11"
,
parent
->
xdata
.
ServerStsStr
[
10
],
&
parent
->
xdata
.
ServerSts
[
10
],
parent
->
xdata
.
ServerStsName
[
10
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S12"
,
parent
->
xdata
.
ServerStsStr
[
11
],
&
parent
->
xdata
.
ServerSts
[
11
],
parent
->
xdata
.
ServerStsName
[
11
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S13"
,
parent
->
xdata
.
ServerStsStr
[
12
],
&
parent
->
xdata
.
ServerSts
[
12
],
parent
->
xdata
.
ServerStsName
[
12
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S14"
,
parent
->
xdata
.
ServerStsStr
[
13
],
&
parent
->
xdata
.
ServerSts
[
13
],
parent
->
xdata
.
ServerStsName
[
13
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S15"
,
parent
->
xdata
.
ServerStsStr
[
14
],
&
parent
->
xdata
.
ServerSts
[
14
],
parent
->
xdata
.
ServerStsName
[
14
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S16"
,
parent
->
xdata
.
ServerStsStr
[
15
],
&
parent
->
xdata
.
ServerSts
[
15
],
parent
->
xdata
.
ServerStsName
[
15
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S17"
,
parent
->
xdata
.
ServerStsStr
[
16
],
&
parent
->
xdata
.
ServerSts
[
16
],
parent
->
xdata
.
ServerStsName
[
16
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S18"
,
parent
->
xdata
.
ServerStsStr
[
17
],
&
parent
->
xdata
.
ServerSts
[
17
],
parent
->
xdata
.
ServerStsName
[
17
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S19"
,
parent
->
xdata
.
ServerStsStr
[
18
],
&
parent
->
xdata
.
ServerSts
[
18
],
parent
->
xdata
.
ServerStsName
[
18
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Sys"
,
"S20"
,
parent
->
xdata
.
ServerStsStr
[
19
],
&
parent
->
xdata
.
ServerSts
[
19
],
parent
->
xdata
.
ServerStsName
[
19
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A1"
,
parent
->
xdata
.
ApplStsStr
[
0
],
&
parent
->
xdata
.
ApplSts
[
0
],
parent
->
xdata
.
ApplStsName
[
0
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A2"
,
parent
->
xdata
.
ApplStsStr
[
1
],
&
parent
->
xdata
.
ApplSts
[
1
],
parent
->
xdata
.
ApplStsName
[
1
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A3"
,
parent
->
xdata
.
ApplStsStr
[
2
],
&
parent
->
xdata
.
ApplSts
[
2
],
parent
->
xdata
.
ApplStsName
[
2
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A4"
,
parent
->
xdata
.
ApplStsStr
[
3
],
&
parent
->
xdata
.
ApplSts
[
3
],
parent
->
xdata
.
ApplStsName
[
3
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A5"
,
parent
->
xdata
.
ApplStsStr
[
4
],
&
parent
->
xdata
.
ApplSts
[
4
],
parent
->
xdata
.
ApplStsName
[
4
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A6"
,
parent
->
xdata
.
ApplStsStr
[
5
],
&
parent
->
xdata
.
ApplSts
[
5
],
parent
->
xdata
.
ApplStsName
[
5
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A7"
,
parent
->
xdata
.
ApplStsStr
[
6
],
&
parent
->
xdata
.
ApplSts
[
6
],
parent
->
xdata
.
ApplStsName
[
6
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A8"
,
parent
->
xdata
.
ApplStsStr
[
7
],
&
parent
->
xdata
.
ApplSts
[
7
],
parent
->
xdata
.
ApplStsName
[
7
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A9"
,
parent
->
xdata
.
ApplStsStr
[
8
],
&
parent
->
xdata
.
ApplSts
[
8
],
parent
->
xdata
.
ApplStsName
[
8
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A10"
,
parent
->
xdata
.
ApplStsStr
[
9
],
&
parent
->
xdata
.
ApplSts
[
9
],
parent
->
xdata
.
ApplStsName
[
9
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A11"
,
parent
->
xdata
.
ApplStsStr
[
10
],
&
parent
->
xdata
.
ApplSts
[
10
],
parent
->
xdata
.
ApplStsName
[
10
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A12"
,
parent
->
xdata
.
ApplStsStr
[
11
],
&
parent
->
xdata
.
ApplSts
[
11
],
parent
->
xdata
.
ApplStsName
[
11
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A13"
,
parent
->
xdata
.
ApplStsStr
[
12
],
&
parent
->
xdata
.
ApplSts
[
12
],
parent
->
xdata
.
ApplStsName
[
12
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A14"
,
parent
->
xdata
.
ApplStsStr
[
13
],
&
parent
->
xdata
.
ApplSts
[
13
],
parent
->
xdata
.
ApplStsName
[
13
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A15"
,
parent
->
xdata
.
ApplStsStr
[
14
],
&
parent
->
xdata
.
ApplSts
[
14
],
parent
->
xdata
.
ApplStsName
[
14
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"A16"
,
"A16"
,
parent
->
xdata
.
ApplStsStr
[
15
],
&
parent
->
xdata
.
ApplSts
[
15
],
parent
->
xdata
.
ApplStsName
[
15
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A17"
,
parent
->
xdata
.
ApplStsStr
[
16
],
&
parent
->
xdata
.
ApplSts
[
16
],
parent
->
xdata
.
ApplStsName
[
16
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A18"
,
parent
->
xdata
.
ApplStsStr
[
17
],
&
parent
->
xdata
.
ApplSts
[
17
],
parent
->
xdata
.
ApplStsName
[
17
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A19"
,
parent
->
xdata
.
ApplStsStr
[
18
],
&
parent
->
xdata
.
ApplSts
[
18
],
parent
->
xdata
.
ApplStsName
[
18
],
this
,
node
,
flow_eDest_IntoLast
);
new
ItemAttrSts
(
nodelistnav
,
"Appl"
,
"A20"
,
parent
->
xdata
.
ApplStsStr
[
19
],
&
parent
->
xdata
.
ApplSts
[
19
],
parent
->
xdata
.
ApplStsName
[
19
],
this
,
node
,
flow_eDest_IntoLast
);
brow_SetOpen
(
node
,
1
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
statussrv_GetExtStatus
(
parent
->
name
,
&
parent
->
xdata
);
nodelistnav
->
force_trace_scan
();
}
return
1
;
}
int
ItemAttrSysSts
::
close
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_CloseNode
(
nodelistnav
->
brow
->
ctx
,
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
1
);
brow_ResetNodraw
(
nodelistnav
->
brow
->
ctx
);
brow_Redraw
(
nodelistnav
->
brow
->
ctx
,
node_y
);
parent
->
syssts_open
=
0
;
memset
(
&
parent
->
xdata
,
0
,
sizeof
(
parent
->
xdata
));
}
return
1
;
}
ItemAttrSts
::
ItemAttrSts
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
char
*
attr_value_p
,
pwr_tStatus
*
attr_status_p
,
char
*
attr_name_p
,
ItemAttrSysSts
*
attr_parent
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemBase
(
item_nodelistnav
,
item_name
),
value_p
(
attr_value_p
),
status_p
(
attr_status_p
),
name_p
(
attr_name_p
),
first_scan
(
1
),
parent
(
attr_parent
)
{
type
=
nodelistnav_eItemType_AttrSts
;
strcpy
(
name
,
item_name
);
memset
(
old_value
,
0
,
sizeof
(
old_value
));
memset
(
old_name
,
0
,
sizeof
(
old_name
));
brow_CreateNode
(
nodelistnav
->
brow
->
ctx
,
item_name
,
nodelistnav
->
brow
->
nc_sts_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
nodelistnav
->
brow
->
pixmap_attr
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
attr
,
""
,
flow_eTraceType_User
);
}
src/lib/co/src/co_statusmon_nodelistnav.h
0 → 100644
View file @
64d17aa8
/*
* Proview $Id: co_statusmon_nodelistnav.h,v 1.1 2007-05-16 12:32:26 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef co_statusmon_nodelistnav_h
#define co_statusmon_nodelistnav_h
/* co_statusmon_nodelistnav.h -- Status Monitor. */
// Status is defined as int i xlib...
#include <vector>
#include "statussrv_utl.h"
using
namespace
std
;
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef rt_errh_h
# include "rt_errh.h"
#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
class
MsgWindow
;
typedef
enum
{
nodelistnav_eItemType_Node
,
nodelistnav_eItemType_Attr
,
nodelistnav_eItemType_AttrSts
,
nodelistnav_eItemType_AttrSysSts
}
nodelistnav_eItemType
;
class
NodelistNavBrow
{
public:
NodelistNavBrow
(
BrowCtx
*
brow_ctx
,
void
*
evl
)
:
ctx
(
brow_ctx
),
nodelistnav
(
evl
)
{};
~
NodelistNavBrow
();
BrowCtx
*
ctx
;
void
*
nodelistnav
;
brow_tNodeClass
nc_event
;
brow_tNodeClass
nc_node
;
brow_tNodeClass
nc_attr
;
brow_tNodeClass
nc_sys_sts_attr
;
brow_tNodeClass
nc_sts_attr
;
flow_sAnnotPixmap
*
pixmap_leaf
;
flow_sAnnotPixmap
*
pixmap_map
;
flow_sAnnotPixmap
*
pixmap_openmap
;
flow_sAnnotPixmap
*
pixmap_attr
;
void
free_pixmaps
();
void
allocate_pixmaps
();
void
create_nodeclasses
();
void
brow_setup
();
};
class
NodeData
{
public:
NodeData
()
:
SystemStatus
(
0
),
SystemTime
(
pwr_cNTime
),
BootTime
(
pwr_cNTime
),
RestartTime
(
pwr_cNTime
),
Restarts
(
0
)
{
strcpy
(
Description
,
""
);
strcpy
(
SystemStatusStr
,
""
);
}
pwr_tStatus
SystemStatus
;
char
SystemStatusStr
[
120
];
pwr_tString80
Description
;
pwr_tTime
SystemTime
;
pwr_tTime
BootTime
;
pwr_tTime
RestartTime
;
int
Restarts
;
char
Version
[
20
];
};
class
ItemNode
;
class
CoWow
;
class
NodelistNode
{
public:
NodelistNode
(
char
*
name
)
:
item
(
0
),
connection_sts
(
0
),
init_done
(
0
)
{
strncpy
(
node_name
,
name
,
sizeof
(
node_name
));
}
char
node_name
[
80
];
ItemNode
*
item
;
pwr_tStatus
connection_sts
;
int
init_done
;
};
class
NodelistNav
{
public:
NodelistNav
(
void
*
ev_parent_ctx
,
MsgWindow
*
nodelistnav_msg_window
,
char
*
nodelistnav_nodename
,
int
nodelistnav_msgw_pop
);
virtual
~
NodelistNav
();
void
*
parent_ctx
;
NodelistNavBrow
*
brow
;
int
nodelist_size
;
int
max_size
;
vector
<
NodelistNode
>
node_list
;
int
trace_started
;
int
scantime
;
int
first_scan
;
CoWow
*
wow
;
MsgWindow
*
msg_window
;
char
nodename
[
40
];
static
const
char
config_file
[
40
];
int
msgw_pop
;
virtual
void
set_input_focus
()
{}
virtual
void
trace_start
()
{}
virtual
void
beep
()
{}
void
zoom
(
double
zoom_factor
);
void
unzoom
();
void
set_nodraw
();
void
reset_nodraw
();
void
read
();
void
draw
();
int
update_nodes
();
void
force_trace_scan
();
void
message
(
pwr_tStatus
sts
,
char
*
node
,
int
idx
,
char
*
text
);
int
select_node
(
int
idx
);
void
remove_node
(
char
*
name
);
int
get_selected_node
(
char
*
name
);
void
save
();
void
add_node
(
char
*
name
);
void
set_msgw_pop
(
int
pop
)
{
msgw_pop
=
pop
;}
static
void
attrvalue_to_string
(
int
type_id
,
void
*
value_ptr
,
char
*
str
,
int
size
,
int
*
len
,
char
*
format
);
static
int
init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
);
static
int
brow_cb
(
FlowCtx
*
ctx
,
flow_tEvent
event
);
static
int
trace_scan_bc
(
brow_tObject
object
,
void
*
p
);
static
int
trace_connect_bc
(
brow_tObject
object
,
char
*
name
,
char
*
attr
,
flow_eTraceType
type
,
void
**
p
);
static
int
trace_disconnect_bc
(
brow_tObject
object
);
};
class
ItemBase
{
public:
ItemBase
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
)
:
nodelistnav
(
item_nodelistnav
)
{
strcpy
(
name
,
item_name
);
}
virtual
~
ItemBase
()
{}
nodelistnav_eItemType
type
;
NodelistNav
*
nodelistnav
;
brow_tNode
node
;
char
name
[
120
];
virtual
int
open_children
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
return
1
;}
virtual
int
close
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
)
{
return
1
;}
};
class
ItemNode
:
public
ItemBase
{
public:
ItemNode
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
);
NodeData
data
;
statussrv_sGetExtStatus
xdata
;
int
syssts_open
;
int
open_children
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
);
int
close
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
);
int
update_color
(
NodelistNav
*
nodelistnav
,
pwr_tStatus
sts
);
};
//! Item for a normal attribute.
class
ItemAttr
:
public
ItemBase
{
public:
ItemAttr
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
void
*
attr_value_p
,
brow_tNode
dest
,
flow_eDest
dest_code
);
void
*
value_p
;
char
old_value
[
120
];
int
first_scan
;
int
type_id
;
int
size
;
};
//! Item for a system status attribute.
class
ItemAttrSysSts
:
public
ItemBase
{
public:
ItemAttrSysSts
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
void
*
attr_value_p
,
void
*
attr_status_p
,
ItemNode
*
attr_parent
,
brow_tNode
dest
,
flow_eDest
dest_code
);
void
*
value_p
;
void
*
status_p
;
char
old_value
[
120
];
int
first_scan
;
int
type_id
;
int
size
;
ItemNode
*
parent
;
virtual
int
open_children
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
);
virtual
int
close
(
NodelistNav
*
nodelistnav
,
double
x
,
double
y
);
};
//! Item for a server status attribute.
class
ItemAttrSts
:
public
ItemBase
{
public:
ItemAttrSts
(
NodelistNav
*
item_nodelistnav
,
char
*
item_name
,
char
*
attr
,
char
*
attr_value_p
,
pwr_tStatus
*
attr_status_p
,
char
*
attr_name_p
,
ItemAttrSysSts
*
attr_parent
,
brow_tNode
dest
,
flow_eDest
dest_code
);
char
*
value_p
;
pwr_tStatus
*
status_p
;
char
*
name_p
;
char
old_value
[
120
];
char
old_name
[
120
];
int
first_scan
;
int
type_id
;
int
size
;
ItemAttrSysSts
*
parent
;
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment