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
2c1bef29
Commit
2c1bef29
authored
Oct 14, 2013
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Xtt event log statistics (refs #160)
parent
917fd031
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
148 additions
and
0 deletions
+148
-0
xtt/lib/xtt/gtk/xtt_hist_gtk.cpp
xtt/lib/xtt/gtk/xtt_hist_gtk.cpp
+12
-0
xtt/lib/xtt/gtk/xtt_hist_gtk.h
xtt/lib/xtt/gtk/xtt_hist_gtk.h
+1
-0
xtt/lib/xtt/src/xtt_hist.cpp
xtt/lib/xtt/src/xtt_hist.cpp
+132
-0
xtt/lib/xtt/src/xtt_hist.h
xtt/lib/xtt/src/xtt_hist.h
+1
-0
xtt/mmi/xtt/en_us/xtt_lng.dat
xtt/mmi/xtt/en_us/xtt_lng.dat
+1
-0
xtt/mmi/xtt/sv_se/xtt_lng.dat
xtt/mmi/xtt/sv_se/xtt_lng.dat
+1
-0
No files found.
xtt/lib/xtt/gtk/xtt_hist_gtk.cpp
View file @
2c1bef29
...
...
@@ -168,10 +168,15 @@ HistGtk::HistGtk( void *hist_parent_ctx,
'f'
,
GdkModifierType
(
GDK_CONTROL_MASK
),
GTK_ACCEL_VISIBLE
);
GtkWidget
*
functions_stat
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"S_tatistics"
));
g_signal_connect
(
functions_stat
,
"activate"
,
G_CALLBACK
(
activate_stat
),
this
);
GtkMenu
*
func_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
func_menu
),
functions_open_plc
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
func_menu
),
functions_display_object
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
func_menu
),
functions_search
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
func_menu
),
functions_stat
);
GtkWidget
*
functions
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Functions"
));
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
menu_bar
),
functions
);
...
...
@@ -571,6 +576,13 @@ void HistGtk::activate_display_in_xnav( GtkWidget *w, gpointer data)
histOP
->
hist
->
display_in_xnav
();
}
void
HistGtk
::
activate_stat
(
GtkWidget
*
w
,
gpointer
data
)
{
Hist
*
histOP
=
(
Hist
*
)
data
;
histOP
->
stat
();
}
void
HistGtk
::
activate_disp_hundredth
(
GtkWidget
*
w
,
gpointer
data
)
{
Hist
*
histOP
=
(
Hist
*
)
data
;
...
...
xtt/lib/xtt/gtk/xtt_hist_gtk.h
View file @
2c1bef29
...
...
@@ -91,6 +91,7 @@ class HistGtk : public Hist {
static
void
activate_zoom_out
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_reset
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_open_plc
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_stat
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_display_in_xnav
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_disp_hundredth
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_hide_object
(
GtkWidget
*
w
,
gpointer
data
);
...
...
xtt/lib/xtt/src/xtt_hist.cpp
View file @
2c1bef29
...
...
@@ -50,6 +50,7 @@ using namespace std;
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
extern
"C"
{
#include "co_cdh.h"
...
...
@@ -427,6 +428,137 @@ void Hist::get_hist_list()
hist
->
reset_nodraw
();
}
typedef
struct
{
sEvent
event
;
int
cnt
;
}
sStat
;
struct
evv_greater_than
{
inline
bool
operator
()
(
const
sStat
&
struct1
,
const
sStat
&
struct2
)
{
return
(
struct1
.
cnt
>
struct2
.
cnt
);
}
};
void
Hist
::
stat
()
{
DB
*
dataBaseP
=
NULL
;
pwr_tInt32
ret
;
char
dbName
[
200
];
int
event_cnt
=
0
;
brow_DeleteAll
(
hist
->
brow
->
ctx
);
dcli_translate_filename
(
dbName
,
DATABASE
);
printSearchStr
();
/*create the database if it's not already created*/
if
((
ret
=
db_create
(
&
dataBaseP
,
NULL
,
0
))
!=
0
)
{
/*error creating db-handle send the mess to errh, then exit*/
printf
(
"error db_create: %s
\n
"
,
db_strerror
(
ret
));
printf
(
" Fel vid skapande av databashandtag avslutar
\n
"
);
return
;
}
#if DB_VERSION_MAJOR > 3 && DB_VERSION_MINOR > 0
// int (*open) __P((DB *, DB_TXN *,
// const char *, const char *, DBTYPE, u_int32_t, int));
ret
=
dataBaseP
->
open
(
dataBaseP
,
NULL
,
dbName
,
NULL
,
DATABASETYPE
,
DB_RDONLY
,
0
);
#else
ret
=
dataBaseP
->
open
(
dataBaseP
,
dbName
,
NULL
,
DATABASETYPE
,
DB_RDONLY
,
0
);
#endif
if
(
ret
!=
0
)
{
/*error opening/creating db send the mess to errh, then exit*/
printf
(
"error db_open: %s
\n
"
,
db_strerror
(
ret
));
//goto err;
}
sEvent
*
eventp
;
DBT
data
,
key
;
DBC
*
dbcp
;
vector
<
sStat
>
evv
;
int
found
;
/* Acquire a cursor for the database. */
if
((
ret
=
dataBaseP
->
cursor
(
dataBaseP
,
NULL
,
&
dbcp
,
0
))
!=
0
)
{
printf
(
"error dataBaseP->cursor: %s
\n
"
,
db_strerror
(
ret
));
return
;
}
/* Initialize the key/data return pair. */
memset
(
&
key
,
0
,
sizeof
(
key
));
memset
(
&
data
,
0
,
sizeof
(
data
));
for
(
ret
=
dbcp
->
c_get
(
dbcp
,
&
key
,
&
data
,
DB_FIRST
);
ret
==
0
;
ret
=
dbcp
->
c_get
(
dbcp
,
&
key
,
&
data
,
DB_NEXT
))
{
eventp
=
(
sEvent
*
)
data
.
data
;
switch
(
eventp
->
EventType
)
{
case
mh_eEvent_Alarm
:
case
mh_eEvent_Info
:
event_cnt
++
;
found
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
evv
.
size
();
i
++
)
{
if
(
strcmp
(
eventp
->
Mess
.
message
.
EventText
,
evv
[
i
].
event
.
Mess
.
message
.
EventText
)
==
0
&&
strcmp
(
eventp
->
Mess
.
message
.
EventName
,
evv
[
i
].
event
.
Mess
.
message
.
EventName
)
==
0
)
{
evv
[
i
].
cnt
++
;
found
=
1
;
}
}
if
(
!
found
)
{
sStat
stat
;
stat
.
event
=
*
eventp
;
stat
.
cnt
=
1
;
evv
.
push_back
(
stat
);
}
break
;
case
mh_eEvent_Ack
:
case
mh_eEvent_Cancel
:
case
mh_eEvent_Return
:
case
mh_eEvent_Block
:
case
mh_eEvent_Unblock
:
case
mh_eEvent_Reblock
:
case
mh_eEvent_CancelBlock
:
break
;
default:
;
}
}
std
::
sort
(
evv
.
begin
(),
evv
.
end
(),
evv_greater_than
());
hist
->
set_nodraw
();
for
(
unsigned
int
i
=
0
;
i
<
evv
.
size
();
i
++
)
{
char
tmp
[
80
];
memset
(
&
evv
[
i
].
event
.
Mess
.
message
.
Info
.
EventTime
,
0
,
sizeof
(
evv
[
i
].
event
.
Mess
.
message
.
Info
.
EventTime
));
evv
[
i
].
event
.
Mess
.
message
.
Status
=
0
;
// Print count in beginning of event text
strncpy
(
tmp
,
evv
[
i
].
event
.
Mess
.
message
.
EventText
,
sizeof
(
tmp
));
sprintf
(
evv
[
i
].
event
.
Mess
.
message
.
EventText
,
"%-5d "
,
evv
[
i
].
cnt
);
strncpy
(
&
evv
[
i
].
event
.
Mess
.
message
.
EventText
[
6
],
tmp
,
sizeof
(
evv
[
i
].
event
.
Mess
.
message
.
EventText
)
-
6
);
evv
[
i
].
event
.
Mess
.
message
.
EventText
[
sizeof
(
evv
[
i
].
event
.
Mess
.
message
.
EventText
)
-
1
]
=
0
;
switch
(
evv
[
i
].
event
.
EventType
)
{
case
mh_eEvent_Alarm
:
hist_add_alarm_mess
(
&
evv
[
i
].
event
.
Mess
.
message
);
break
;
case
mh_eEvent_Info
:
hist_add_info_mess
(
&
evv
[
i
].
event
.
Mess
.
message
);
break
;
default:
;
}
}
hist
->
reset_nodraw
();
set_num_of_events
(
event_cnt
);
set_search_string
(
"Statistics"
,
""
,
""
,
""
);
}
//sorting function that might be more complicated in the future
//we might want to sort the display of the events with more conditions than
//just the time
...
...
xtt/lib/xtt/src/xtt_hist.h
View file @
2c1bef29
...
...
@@ -129,6 +129,7 @@ class Hist {
void
thisw_cb
();
void
all_cb
();
void
time_cb
();
void
stat
();
static
int
GoBackMonth
(
pwr_tTime
TimeIn
,
pwr_tTime
*
FromTime
,
pwr_tTime
*
ToTime
);
...
...
xtt/mmi/xtt/en_us/xtt_lng.dat
View file @
2c1bef29
...
...
@@ -199,6 +199,7 @@ E 1.9.31 " with prio "
E 1.9.32 " with type "
E 1.9.33 " with EventName "
E 1.9.34 " with EventText "
E 1.9.35 "S_tatistics"
#
# Ge Curve
E 1.10.1 "_Refresh"
...
...
xtt/mmi/xtt/sv_se/xtt_lng.dat
View file @
2c1bef29
...
...
@@ -199,6 +199,7 @@ E 1.9.31 " med prio "
E 1.9.32 " med typ "
E 1.9.33 " med Hndelsenamn "
E 1.9.34 " med Hndelsetext "
E 1.9.35 "S_tatistik"
#
# Ge Curve
E 1.10.1 "_Uppdatera"
...
...
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