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
1f134bf3
Commit
1f134bf3
authored
Apr 24, 2017
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Profinet viewer, configured devices displayed
parent
116e419a
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
328 additions
and
23 deletions
+328
-23
profibus/exe/profinet_viewer/gtk/os_templ/link_rule.mk
profibus/exe/profinet_viewer/gtk/os_templ/link_rule.mk
+2
-1
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.cpp
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.cpp
+32
-2
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.h
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.h
+2
-0
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.cpp
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.cpp
+2
-1
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.h
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.h
+3
-2
profibus/exe/profinet_viewer/src/pn_viewer.cpp
profibus/exe/profinet_viewer/src/pn_viewer.cpp
+138
-5
profibus/exe/profinet_viewer/src/pn_viewer.h
profibus/exe/profinet_viewer/src/pn_viewer.h
+5
-0
profibus/exe/profinet_viewer/src/pn_viewernav.cpp
profibus/exe/profinet_viewer/src/pn_viewernav.cpp
+21
-9
profibus/exe/profinet_viewer/src/pn_viewernav.h
profibus/exe/profinet_viewer/src/pn_viewernav.h
+21
-3
profibus/lib/wb/src/wb_c_pndevice.cpp
profibus/lib/wb/src/wb_c_pndevice.cpp
+102
-0
No files found.
profibus/exe/profinet_viewer/gtk/os_templ/link_rule.mk
View file @
1f134bf3
...
@@ -4,7 +4,8 @@ link_rule_mk := 1
...
@@ -4,7 +4,8 @@ link_rule_mk := 1
link
=
$(ldxx)
-L
$(pwr_elib)
$(elinkflags)
$(domap)
-o
$(pwr_exe)
/profinet_viewer_gtk
\
link
=
$(ldxx)
-L
$(pwr_elib)
$(elinkflags)
$(domap)
-o
$(pwr_exe)
/profinet_viewer_gtk
\
$(bld_dir)
/profinet_viewer_gtk.o
\
$(bld_dir)
/profinet_viewer_gtk.o
\
$(bld_dir)
/pn_viewer_gtk.o
$(bld_dir)
/pn_viewernav_gtk.o
\
$(bld_dir)
/pn_viewer_gtk.o
$(bld_dir)
/pn_viewernav_gtk.o
\
$(bld_dir)
/pn_viewer.o
$(bld_dir)
/pn_viewernav.o
$(bld_dir)
/pn_viewer_pnac.o
\
$(bld_dir)
/pn_viewer.o
$(bld_dir)
/pn_viewernav.o
\
$(bld_dir)
/pn_viewer_pnac.o
\
$(wb_msg_eobjs)
$(rt_msg_eobjs)
\
$(wb_msg_eobjs)
$(rt_msg_eobjs)
\
$(pwr_eobj)
/rt_io_user.o
\
$(pwr_eobj)
/rt_io_user.o
\
$(pwre_conf_libdir)
$(pwre_conf_libpwrxttgtk)
$(pwre_conf_libpwrxtt)
$(pwre_conf_libgtk)
\
$(pwre_conf_libdir)
$(pwre_conf_libpwrxttgtk)
$(pwre_conf_libpwrxtt)
$(pwre_conf_libgtk)
\
...
...
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.cpp
View file @
1f134bf3
...
@@ -108,6 +108,9 @@ PnViewerGtk::PnViewerGtk (
...
@@ -108,6 +108,9 @@ PnViewerGtk::PnViewerGtk (
GtkWidget
*
functions_update
=
gtk_menu_item_new_with_mnemonic
(
"_Update"
);
GtkWidget
*
functions_update
=
gtk_menu_item_new_with_mnemonic
(
"_Update"
);
g_signal_connect
(
functions_update
,
"activate"
,
G_CALLBACK
(
activate_update
),
this
);
g_signal_connect
(
functions_update
,
"activate"
,
G_CALLBACK
(
activate_update
),
this
);
GtkWidget
*
functions_filter
=
gtk_menu_item_new_with_mnemonic
(
"_Filter"
);
g_signal_connect
(
functions_filter
,
"activate"
,
G_CALLBACK
(
activate_filter
),
this
);
GtkWidget
*
functions_setdevice
=
gtk_menu_item_new_with_mnemonic
(
"_Set Device Properties"
);
GtkWidget
*
functions_setdevice
=
gtk_menu_item_new_with_mnemonic
(
"_Set Device Properties"
);
g_signal_connect
(
functions_setdevice
,
"activate"
,
G_CALLBACK
(
activate_setdevice
),
this
);
g_signal_connect
(
functions_setdevice
,
"activate"
,
G_CALLBACK
(
activate_setdevice
),
this
);
...
@@ -118,6 +121,7 @@ PnViewerGtk::PnViewerGtk (
...
@@ -118,6 +121,7 @@ PnViewerGtk::PnViewerGtk (
GtkMenu
*
functions_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
GtkMenu
*
functions_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_update
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_update
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_filter
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_setdevice
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_setdevice
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_changevalue
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
functions_menu
),
functions_changevalue
);
...
@@ -181,12 +185,31 @@ PnViewerGtk::PnViewerGtk (
...
@@ -181,12 +185,31 @@ PnViewerGtk::PnViewerGtk (
gtk_widget_show_all
(
statusbar
);
gtk_widget_show_all
(
statusbar
);
// Create viewernav
// Create viewernav
viewernav
=
new
PnViewerNavGtk
(
this
,
form
,
&
nav_widget
);
GtkWidget
*
nav_paned
=
gtk_hpaned_new
();
GtkWidget
*
nav_left
=
gtk_vbox_new
(
FALSE
,
0
);
GtkWidget
*
nav_right
=
gtk_vbox_new
(
FALSE
,
0
);
GtkWidget
*
header_left
=
gtk_label_new
(
"Devices on Network"
);
GtkWidget
*
header_right
=
gtk_label_new
(
"Devices from Configuration"
);
viewernav
=
new
PnViewerNavGtk
(
this
,
nav_right
,
viewer_eType_Network
,
&
nav_widget
);
viewernav
->
change_value_cb
=
&
change_value
;
viewernav
->
change_value_cb
=
&
change_value
;
viewernav
->
message_cb
=
&
message_cb
;
viewernav
->
message_cb
=
&
message_cb
;
viewernavconf
=
new
PnViewerNavGtk
(
this
,
nav_left
,
viewer_eType_Configuration
,
&
navconf_widget
);
viewernavconf
->
change_value_cb
=
&
change_value
;
viewernavconf
->
message_cb
=
&
message_cb
;
gtk_box_pack_start
(
GTK_BOX
(
nav_left
),
header_left
,
FALSE
,
FALSE
,
5
);
gtk_box_pack_start
(
GTK_BOX
(
nav_left
),
nav_widget
,
TRUE
,
TRUE
,
5
);
gtk_box_pack_start
(
GTK_BOX
(
nav_right
),
header_right
,
FALSE
,
FALSE
,
5
);
gtk_box_pack_start
(
GTK_BOX
(
nav_right
),
navconf_widget
,
TRUE
,
TRUE
,
5
);
gtk_paned_pack1
(
GTK_PANED
(
nav_paned
),
nav_left
,
TRUE
,
TRUE
);
gtk_paned_pack2
(
GTK_PANED
(
nav_paned
),
nav_right
,
FALSE
,
TRUE
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
menu_bar
),
FALSE
,
FALSE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
nav_
widget
),
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
nav_
paned
),
TRUE
,
TRUE
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
statusbar
),
FALSE
,
FALSE
,
3
);
gtk_box_pack_start
(
GTK_BOX
(
form
),
GTK_WIDGET
(
statusbar
),
FALSE
,
FALSE
,
3
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
form
);
gtk_container_add
(
GTK_CONTAINER
(
toplevel
),
form
);
...
@@ -311,6 +334,13 @@ void PnViewerGtk::activate_update( GtkWidget *w, gpointer data)
...
@@ -311,6 +334,13 @@ void PnViewerGtk::activate_update( GtkWidget *w, gpointer data)
viewer
->
activate_update
();
viewer
->
activate_update
();
}
}
void
PnViewerGtk
::
activate_filter
(
GtkWidget
*
w
,
gpointer
data
)
{
PnViewer
*
viewer
=
(
PnViewer
*
)
data
;
viewer
->
activate_filter
(
viewer_eFilterType_NotMatching
);
}
void
PnViewerGtk
::
activate_setdevice
(
GtkWidget
*
w
,
gpointer
data
)
void
PnViewerGtk
::
activate_setdevice
(
GtkWidget
*
w
,
gpointer
data
)
{
{
PnViewer
*
viewer
=
(
PnViewer
*
)
data
;
PnViewer
*
viewer
=
(
PnViewer
*
)
data
;
...
...
profibus/exe/profinet_viewer/gtk/pn_viewer_gtk.h
View file @
1f134bf3
...
@@ -63,6 +63,7 @@ class PnViewerGtk : public PnViewer {
...
@@ -63,6 +63,7 @@ class PnViewerGtk : public PnViewer {
GtkWidget
*
toplevel
;
GtkWidget
*
toplevel
;
GtkWidget
*
form
;
GtkWidget
*
form
;
GtkWidget
*
nav_widget
;
GtkWidget
*
nav_widget
;
GtkWidget
*
navconf_widget
;
GtkWidget
*
msg_label
;
GtkWidget
*
msg_label
;
GtkWidget
*
cmd_prompt
;
GtkWidget
*
cmd_prompt
;
GtkWidget
*
cmd_input
;
GtkWidget
*
cmd_input
;
...
@@ -79,6 +80,7 @@ class PnViewerGtk : public PnViewer {
...
@@ -79,6 +80,7 @@ class PnViewerGtk : public PnViewer {
static
void
valchanged_cmd_input
(
GtkWidget
*
w
,
gpointer
data
);
static
void
valchanged_cmd_input
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_exit
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_exit
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_update
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_update
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_filter
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_setdevice
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_setdevice
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_changevalue
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_changevalue
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoom_in
(
GtkWidget
*
w
,
gpointer
data
);
...
...
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.cpp
View file @
1f134bf3
...
@@ -58,8 +58,9 @@ extern "C" {
...
@@ -58,8 +58,9 @@ extern "C" {
PnViewerNavGtk
::
PnViewerNavGtk
(
PnViewerNavGtk
::
PnViewerNavGtk
(
void
*
l_parent_ctx
,
void
*
l_parent_ctx
,
GtkWidget
*
l_parent_wid
,
GtkWidget
*
l_parent_wid
,
viewer_eType
l_type
,
GtkWidget
**
w
)
:
GtkWidget
**
w
)
:
PnViewerNav
(
l_parent_ctx
),
parent_wid
(
l_parent_wid
)
PnViewerNav
(
l_parent_ctx
,
l_type
),
parent_wid
(
l_parent_wid
)
{
{
form_widget
=
scrolledbrowwidgetgtk_new
(
form_widget
=
scrolledbrowwidgetgtk_new
(
PnViewerNav
::
init_brow_cb
,
this
,
&
brow_widget
);
PnViewerNav
::
init_brow_cb
,
this
,
&
brow_widget
);
...
...
profibus/exe/profinet_viewer/gtk/pn_viewernav_gtk.h
View file @
1f134bf3
...
@@ -46,8 +46,9 @@
...
@@ -46,8 +46,9 @@
class
PnViewerNavGtk
:
public
PnViewerNav
{
class
PnViewerNavGtk
:
public
PnViewerNav
{
public:
public:
PnViewerNavGtk
(
PnViewerNavGtk
(
void
*
ev_parent_ctx
,
void
*
v_parent_ctx
,
GtkWidget
*
ev_parent_wid
,
GtkWidget
*
v_parent_wid
,
viewer_eType
v_type
,
GtkWidget
**
w
);
GtkWidget
**
w
);
~
PnViewerNavGtk
();
~
PnViewerNavGtk
();
...
...
profibus/exe/profinet_viewer/src/pn_viewer.cpp
View file @
1f134bf3
...
@@ -54,17 +54,20 @@
...
@@ -54,17 +54,20 @@
#include "pn_viewer.h"
#include "pn_viewer.h"
static
int
test
=
0
;
PnViewer
::
PnViewer
(
PnViewer
::
PnViewer
(
void
*
v_parent_ctx
,
void
*
v_parent_ctx
,
const
char
*
v_name
,
const
char
*
v_name
,
const
char
*
v_device
,
const
char
*
v_device
,
pwr_tStatus
*
status
)
:
pwr_tStatus
*
status
)
:
parent_ctx
(
v_parent_ctx
),
viewernav
(
NULL
),
wow
(
0
),
input_open
(
0
),
pnet
(
0
),
close_cb
(
0
)
parent_ctx
(
v_parent_ctx
),
viewernav
(
NULL
),
viewernavconf
(
NULL
),
wow
(
0
),
input_open
(
0
),
pnet
(
0
),
close_cb
(
0
)
{
{
strcpy
(
name
,
v_name
);
strcpy
(
name
,
v_name
);
strcpy
(
device
,
v_device
);
strcpy
(
device
,
v_device
);
pnet
=
new
PnViewerPNAC
(
status
,
device
);
if
(
!
test
)
pnet
=
new
PnViewerPNAC
(
status
,
device
);
}
}
PnViewer
::~
PnViewer
()
PnViewer
::~
PnViewer
()
...
@@ -74,10 +77,135 @@ PnViewer::~PnViewer()
...
@@ -74,10 +77,135 @@ PnViewer::~PnViewer()
void
PnViewer
::
update_devices
()
void
PnViewer
::
update_devices
()
{
{
dev_vect
.
clear
();
int
sts
;
pnet
->
fetch_devices
(
dev_vect
);
if
(
!
test
)
{
dev_vect
.
clear
();
pnet
->
fetch_devices
(
dev_vect
);
conf_vect
.
clear
();
sts
=
fetch_config
(
dev_vect
);
if
(
EVEN
(
sts
))
printf
(
"Error reading configuration file
\n
"
);
viewernav
->
set
(
dev_vect
);
viewernavconf
->
set
(
conf_vect
);
}
else
{
dev_vect
.
clear
();
sts
=
fetch_config
(
dev_vect
);
if
(
EVEN
(
sts
))
printf
(
"Error reading configuration file
\n
"
);
viewernav
->
set
(
dev_vect
);
strcpy
(
device
,
"test"
);
// Test
conf_vect
.
clear
();
sts
=
fetch_config
(
conf_vect
);
if
(
EVEN
(
sts
))
printf
(
"Error reading configuration file
\n
"
);
viewernavconf
->
set
(
conf_vect
);
}
}
void
PnViewer
::
filter
(
viewer_eFilterType
filtertype
)
{
switch
(
filtertype
)
{
case
viewer_eFilterType_No
:
for
(
unsigned
int
i
=
0
;
i
<
dev_vect
.
size
();
i
++
)
dev_vect
[
i
].
hide
=
false
;
for
(
unsigned
int
i
=
0
;
i
<
conf_vect
.
size
();
i
++
)
conf_vect
[
i
].
hide
=
false
;
break
;
case
viewer_eFilterType_NotMatching
:
// Compare dev_vect and conf_vect and display device that doesn't match
// Set all
for
(
unsigned
int
i
=
0
;
i
<
dev_vect
.
size
();
i
++
)
dev_vect
[
i
].
hide
=
false
;
for
(
unsigned
int
i
=
0
;
i
<
conf_vect
.
size
();
i
++
)
conf_vect
[
i
].
hide
=
false
;
for
(
unsigned
int
i
=
0
;
i
<
dev_vect
.
size
();
i
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
conf_vect
.
size
();
j
++
)
{
if
(
strcmp
(
dev_vect
[
i
].
devname
,
conf_vect
[
j
].
devname
)
==
0
&&
dev_vect
[
i
].
vendorid
==
conf_vect
[
j
].
vendorid
&&
dev_vect
[
i
].
deviceid
==
conf_vect
[
j
].
deviceid
&&
dev_vect
[
i
].
ipaddress
[
0
]
==
conf_vect
[
j
].
ipaddress
[
0
]
&&
dev_vect
[
i
].
ipaddress
[
1
]
==
conf_vect
[
j
].
ipaddress
[
1
]
&&
dev_vect
[
i
].
ipaddress
[
2
]
==
conf_vect
[
j
].
ipaddress
[
2
]
&&
dev_vect
[
i
].
ipaddress
[
3
]
==
conf_vect
[
j
].
ipaddress
[
3
])
{
dev_vect
[
i
].
hide
=
true
;
conf_vect
[
j
].
hide
=
true
;
break
;
}
}
}
break
;
}
viewernav
->
set
(
dev_vect
);
viewernavconf
->
set
(
conf_vect
);
}
int
PnViewer
::
fetch_config
(
vector
<
PnDevice
>&
vect
)
{
PnDevice
pndevice
;
pwr_tFileName
fname
;
char
edev
[
20
];
FILE
*
fp
;
char
line
[
500
];
char
elemv
[
7
][
100
];
int
nr
;
int
sts
;
cdh_ToLower
(
edev
,
device
);
sprintf
(
fname
,
"$pwrp_load/pwr_pnviewer_%s.dat"
,
edev
);
dcli_translate_filename
(
fname
,
fname
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
0
;
while
(
dcli_read_line
(
line
,
sizeof
(
line
),
fp
))
{
nr
=
dcli_parse
(
line
,
" "
,
""
,
(
char
*
)
elemv
,
sizeof
(
elemv
)
/
sizeof
(
elemv
[
0
]),
sizeof
(
elemv
[
0
]),
0
);
if
(
nr
!=
6
)
continue
;
strncpy
(
pndevice
.
devname
,
elemv
[
1
],
sizeof
(
pndevice
.
devname
));
sts
=
sscanf
(
elemv
[
2
],
"%hhu.%hhu.%hhu.%hhu"
,
&
pndevice
.
ipaddress
[
0
],
&
pndevice
.
ipaddress
[
1
],
&
pndevice
.
ipaddress
[
2
],
&
pndevice
.
ipaddress
[
3
]);
if
(
sts
!=
4
)
{
printf
(
"Not a valid IP address: %s
\n
"
,
elemv
[
2
]);
pndevice
.
ipaddress
[
0
]
=
0
;
pndevice
.
ipaddress
[
1
]
=
0
;
pndevice
.
ipaddress
[
2
]
=
0
;
pndevice
.
ipaddress
[
3
]
=
0
;
}
viewernav
->
set
(
dev_vect
);
sts
=
sscanf
(
elemv
[
3
],
"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx"
,
&
pndevice
.
macaddress
[
0
],
&
pndevice
.
macaddress
[
1
],
&
pndevice
.
macaddress
[
2
],
&
pndevice
.
macaddress
[
3
],
&
pndevice
.
macaddress
[
4
],
&
pndevice
.
macaddress
[
5
]);
if
(
sts
!=
6
)
{
printf
(
"Not a valid MAC address: %s
\n
"
,
elemv
[
3
]);
pndevice
.
macaddress
[
0
]
=
0
;
pndevice
.
macaddress
[
1
]
=
0
;
pndevice
.
macaddress
[
2
]
=
0
;
pndevice
.
macaddress
[
3
]
=
0
;
pndevice
.
macaddress
[
4
]
=
0
;
pndevice
.
macaddress
[
5
]
=
0
;
}
sts
=
sscanf
(
elemv
[
4
],
"%u"
,
&
pndevice
.
vendorid
);
if
(
sts
!=
1
)
return
0
;
sts
=
sscanf
(
elemv
[
5
],
"%u"
,
&
pndevice
.
deviceid
);
if
(
sts
!=
1
)
return
0
;
vect
.
push_back
(
pndevice
);
}
fclose
(
fp
);
return
1
;
}
}
void
PnViewer
::
set_device_properties
(
unsigned
char
*
macaddress
,
unsigned
char
*
ipaddress
,
void
PnViewer
::
set_device_properties
(
unsigned
char
*
macaddress
,
unsigned
char
*
ipaddress
,
...
@@ -109,6 +237,11 @@ void PnViewer::activate_update()
...
@@ -109,6 +237,11 @@ void PnViewer::activate_update()
printf
(
"** Update exception: %s
\n
"
,
e
.
what
().
c_str
());
printf
(
"** Update exception: %s
\n
"
,
e
.
what
().
c_str
());
}
}
}
}
void
PnViewer
::
activate_filter
(
viewer_eFilterType
filtertype
)
{
filter
(
filtertype
);
}
void
PnViewer
::
activate_setdevice
()
void
PnViewer
::
activate_setdevice
()
{
{
...
...
profibus/exe/profinet_viewer/src/pn_viewer.h
View file @
1f134bf3
...
@@ -69,7 +69,10 @@ class PnViewer {
...
@@ -69,7 +69,10 @@ class PnViewer {
void
update_devices
();
void
update_devices
();
void
set_device_properties
(
unsigned
char
*
macaddress
,
unsigned
char
*
ipaddress
,
void
set_device_properties
(
unsigned
char
*
macaddress
,
unsigned
char
*
ipaddress
,
char
*
devname
);
char
*
devname
);
int
fetch_config
(
vector
<
PnDevice
>&
vect
);
void
filter
(
viewer_eFilterType
filtertype
);
void
activate_update
();
void
activate_update
();
void
activate_filter
(
viewer_eFilterType
filtertype
);
void
activate_setdevice
();
void
activate_setdevice
();
void
activate_changevalue
();
void
activate_changevalue
();
void
activate_close
();
void
activate_close
();
...
@@ -82,9 +85,11 @@ class PnViewer {
...
@@ -82,9 +85,11 @@ class PnViewer {
char
name
[
80
];
char
name
[
80
];
char
device
[
20
];
char
device
[
20
];
PnViewerNav
*
viewernav
;
PnViewerNav
*
viewernav
;
PnViewerNav
*
viewernavconf
;
CoWow
*
wow
;
CoWow
*
wow
;
int
input_open
;
int
input_open
;
vector
<
PnDevice
>
dev_vect
;
vector
<
PnDevice
>
dev_vect
;
vector
<
PnDevice
>
conf_vect
;
PnViewerPNAC
*
pnet
;
PnViewerPNAC
*
pnet
;
void
(
*
close_cb
)(
void
*
);
void
(
*
close_cb
)(
void
*
);
...
...
profibus/exe/profinet_viewer/src/pn_viewernav.cpp
View file @
1f134bf3
...
@@ -344,8 +344,8 @@ int PnViewerNav::init_brow_cb( FlowCtx *fctx, void *client_data)
...
@@ -344,8 +344,8 @@ int PnViewerNav::init_brow_cb( FlowCtx *fctx, void *client_data)
return
1
;
return
1
;
}
}
PnViewerNav
::
PnViewerNav
(
void
*
l_parent_ctx
)
:
PnViewerNav
::
PnViewerNav
(
void
*
l_parent_ctx
,
viewer_eType
l_type
)
:
parent_ctx
(
l_parent_ctx
),
change_value_cb
(
0
)
type
(
l_type
),
parent_ctx
(
l_parent_ctx
),
change_value_cb
(
0
)
{
{
}
}
...
@@ -562,6 +562,8 @@ int PnViewerNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -562,6 +562,8 @@ int PnViewerNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
int
sts
;
int
sts
;
viewernav
->
set_input_focus
();
switch
(
event
->
object
.
object_type
)
switch
(
event
->
object
.
object_type
)
{
{
case
flow_eObjectType_Node
:
case
flow_eObjectType_Node
:
...
@@ -612,6 +614,13 @@ int PnViewerNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
...
@@ -612,6 +614,13 @@ int PnViewerNav::brow_cb( FlowCtx *ctx, flow_tEvent event)
break
;
break
;
}
}
case
flow_eEvent_MB1DoubleClick
:
case
flow_eEvent_MB1DoubleClick
:
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
case
viewitem_eItemType_Device
:
sts
=
item
->
open_children
(
viewernav
);
break
;
default:
;
}
break
;
break
;
default:
default:
;
;
...
@@ -706,8 +715,9 @@ int PnViewerNav::check_attr_value()
...
@@ -706,8 +715,9 @@ int PnViewerNav::check_attr_value()
switch
(
base_item
->
type
)
{
switch
(
base_item
->
type
)
{
case
viewitem_eItemType_DeviceAttr
:
case
viewitem_eItemType_DeviceAttr
:
if
((
strcmp
(
base_item
->
name
,
"DeviceName"
)
==
0
)
||
if
(
type
==
viewer_eType_Network
&&
(
strcmp
(
base_item
->
name
,
"IP Address"
)
==
0
))
(
strcmp
(
base_item
->
name
,
"DeviceName"
)
==
0
||
strcmp
(
base_item
->
name
,
"IP Address"
)
==
0
))
return
1
;
return
1
;
else
else
return
PB__ATTRNOEDIT
;
return
PB__ATTRNOEDIT
;
...
@@ -724,9 +734,10 @@ void PnViewerNav::set( vector<PnDevice>& dev_vect)
...
@@ -724,9 +734,10 @@ void PnViewerNav::set( vector<PnDevice>& dev_vect)
brow_DeleteAll
(
brow
->
ctx
);
brow_DeleteAll
(
brow
->
ctx
);
for
(
unsigned
int
i
=
0
;
i
<
dev_vect
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
dev_vect
.
size
();
i
++
)
{
new
ItemDevice
(
this
,
""
,
dev_vect
[
i
].
ipaddress
,
dev_vect
[
i
].
macaddress
,
if
(
!
dev_vect
[
i
].
hide
)
dev_vect
[
i
].
devname
,
dev_vect
[
i
].
vendorid
,
dev_vect
[
i
].
deviceid
,
new
ItemDevice
(
this
,
""
,
dev_vect
[
i
].
ipaddress
,
dev_vect
[
i
].
macaddress
,
0
,
flow_eDest_IntoLast
);
dev_vect
[
i
].
devname
,
dev_vect
[
i
].
vendorid
,
dev_vect
[
i
].
deviceid
,
0
,
flow_eDest_IntoLast
);
}
}
brow_ResetNodraw
(
brow
->
ctx
);
brow_ResetNodraw
(
brow
->
ctx
);
...
@@ -927,8 +938,9 @@ ItemDeviceAttr::ItemDeviceAttr( PnViewerNav *viewernav, const char *item_name, p
...
@@ -927,8 +938,9 @@ ItemDeviceAttr::ItemDeviceAttr( PnViewerNav *viewernav, const char *item_name, p
brow_SetAnnotation
(
node
,
1
,
value
,
strlen
(
value
));
brow_SetAnnotation
(
node
,
1
,
value
,
strlen
(
value
));
brow_SetAnnotPixmap
(
node
,
0
,
viewernav
->
brow
->
pixmap_attr
);
brow_SetAnnotPixmap
(
node
,
0
,
viewernav
->
brow
->
pixmap_attr
);
if
(
strcmp
(
item_name
,
"DeviceName"
)
==
0
||
if
(
viewernav
->
type
==
viewer_eType_Network
&&
strcmp
(
item_name
,
"IP Address"
)
==
0
)
(
strcmp
(
item_name
,
"DeviceName"
)
==
0
||
strcmp
(
item_name
,
"IP Address"
)
==
0
))
brow_SetAnnotPixmap
(
node
,
1
,
viewernav
->
brow
->
pixmap_edit
);
brow_SetAnnotPixmap
(
node
,
1
,
viewernav
->
brow
->
pixmap_edit
);
}
}
...
...
profibus/exe/profinet_viewer/src/pn_viewernav.h
View file @
1f134bf3
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
/* pn_viewernav.h -- Profinet viewer */
/* pn_viewernav.h -- Profinet viewer */
#include <vector>
#include <vector>
#include <string.h>
#ifndef pwr_h
#ifndef pwr_h
# include "pwr.h"
# include "pwr.h"
...
@@ -63,16 +64,32 @@
...
@@ -63,16 +64,32 @@
class
PnDevice
{
class
PnDevice
{
public:
public:
PnDevice
()
{}
PnDevice
()
:
vendorid
(
0
),
deviceid
(
0
),
hide
(
false
)
{
strcpy
(
devname
,
""
);
memset
(
&
ipaddress
,
0
,
sizeof
(
ipaddress
));
memset
(
&
macaddress
,
0
,
sizeof
(
macaddress
));
}
unsigned
char
ipaddress
[
4
];
unsigned
char
ipaddress
[
4
];
unsigned
char
macaddress
[
6
];
unsigned
char
macaddress
[
6
];
char
devname
[
80
];
char
devname
[
80
];
int
vendorid
;
int
vendorid
;
int
deviceid
;
int
deviceid
;
bool
hide
;
};
};
class
ItemDevice
;
class
ItemDevice
;
typedef
enum
{
viewer_eType_Network
,
viewer_eType_Configuration
}
viewer_eType
;
typedef
enum
{
viewer_eFilterType_No
,
viewer_eFilterType_NotMatching
}
viewer_eFilterType
;
typedef
enum
{
typedef
enum
{
viewitem_eItemType_Device
,
viewitem_eItemType_Device
,
viewitem_eItemType_DeviceAttr
viewitem_eItemType_DeviceAttr
...
@@ -100,9 +117,10 @@ class PnViewerNavBrow {
...
@@ -100,9 +117,10 @@ class PnViewerNavBrow {
class
PnViewerNav
{
class
PnViewerNav
{
public:
public:
PnViewerNav
(
void
*
v_parent_ctx
);
PnViewerNav
(
void
*
l_parent_ctx
,
viewer_eType
l_type
);
virtual
~
PnViewerNav
();
virtual
~
PnViewerNav
();
viewer_eType
type
;
void
*
parent_ctx
;
void
*
parent_ctx
;
PnViewerNavBrow
*
brow
;
PnViewerNavBrow
*
brow
;
void
(
*
change_value_cb
)(
void
*
);
void
(
*
change_value_cb
)(
void
*
);
...
@@ -115,7 +133,7 @@ class PnViewerNav {
...
@@ -115,7 +133,7 @@ class PnViewerNav {
void
unzoom
();
void
unzoom
();
void
set
(
vector
<
PnDevice
>&
dev_vect
);
void
set
(
vector
<
PnDevice
>&
dev_vect
);
int
set_attr_value
(
char
*
value_str
);
int
set_attr_value
(
char
*
value_str
);
int
check_attr_value
();
virtual
int
check_attr_value
();
int
get_selected_device
(
ItemDevice
**
device
);
int
get_selected_device
(
ItemDevice
**
device
);
void
vendorid_to_str
(
unsigned
int
vendorid
,
char
*
vendorid_str
,
int
size
);
void
vendorid_to_str
(
unsigned
int
vendorid
,
char
*
vendorid_str
,
int
size
);
void
get_device_info
(
unsigned
int
vendorid
,
unsigned
int
deviceid
,
void
get_device_info
(
unsigned
int
vendorid
,
unsigned
int
deviceid
,
...
...
profibus/lib/wb/src/wb_c_pndevice.cpp
View file @
1f134bf3
...
@@ -73,6 +73,8 @@
...
@@ -73,6 +73,8 @@
using
namespace
std
;
using
namespace
std
;
static
pwr_tStatus
generate_viewer_data
(
device_sCtx
*
ctx
);
class
ChanItem
{
class
ChanItem
{
public:
public:
ChanItem
()
:
subslot_number
(
0
),
representation
(
0
),
number
(
0
),
use_as_bit
(
0
),
cid
(
0
)
{}
ChanItem
()
:
subslot_number
(
0
),
representation
(
0
),
number
(
0
),
use_as_bit
(
0
),
cid
(
0
)
{}
...
@@ -416,12 +418,112 @@ int pndevice_save_cb( void *sctx)
...
@@ -416,12 +418,112 @@ int pndevice_save_cb( void *sctx)
}
}
}
}
}
}
// Write data of all devices for profinet viewer
// Data is device name, IP and MAC address
sts
=
generate_viewer_data
(
ctx
);
sts
=
rsts
;
sts
=
rsts
;
return_now:
return_now:
((
WNav
*
)
ctx
->
editor_ctx
)
->
reset_nodraw
();
((
WNav
*
)
ctx
->
editor_ctx
)
->
reset_nodraw
();
return
sts
;
return
sts
;
}
}
static
pwr_tStatus
generate_viewer_data
(
device_sCtx
*
ctx
)
{
pwr_tOid
controller
;
pwr_tCid
ccid
;
FILE
*
fp
;
FILE
*
ofp
;
pwr_tFileName
fname
;
char
line
[
500
];
char
elemv
[
3
][
200
];
int
nr
;
char
device_text
[
200
];
char
device_name
[
80
];
char
ip_address
[
80
];
char
mac_address
[
80
];
unsigned
int
vendor_id
=
0
;
unsigned
int
device_id
=
0
;
char
*
s
;
pwr_tStatus
sts
;
pwr_tOid
oid
;
char
*
ethernet_device
;
int
size
;
sts
=
ldh_GetParent
(
ctx
->
ldhses
,
ctx
->
aref
.
Objid
,
&
controller
);
if
(
EVEN
(
sts
))
return
sts
;
sts
=
ldh_GetObjectClass
(
ctx
->
ldhses
,
controller
,
&
ccid
);
if
(
ODD
(
sts
)
&&
ccid
==
pwr_cClass_PnControllerSoftingPNAK
)
{
sts
=
ldh_GetObjectPar
(
ctx
->
ldhses
,
controller
,
"RtBody"
,
"EthernetDevice"
,
(
char
**
)
&
ethernet_device
,
&
size
);
if
(
EVEN
(
sts
))
return
sts
;
dcli_trim
(
ethernet_device
,
ethernet_device
);
cdh_ToLower
(
ethernet_device
,
ethernet_device
);
sprintf
(
fname
,
"$pwrp_load/pwr_pnviewer_%s.dat"
,
ethernet_device
);
free
(
ethernet_device
);
dcli_translate_filename
(
fname
,
fname
);
ofp
=
fopen
(
fname
,
"w"
);
if
(
!
ofp
)
return
0
;
for
(
sts
=
ldh_GetChild
(
ctx
->
ldhses
,
controller
,
&
oid
);
ODD
(
sts
);
sts
=
ldh_GetNextSibling
(
ctx
->
ldhses
,
oid
,
&
oid
))
{
sprintf
(
fname
,
"$pwrp_load/pwr_pn_%s.xml"
,
cdh_ObjidToFnString
(
0
,
oid
));
dcli_translate_filename
(
fname
,
fname
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
0
;
while
(
dcli_read_line
(
line
,
sizeof
(
line
),
fp
))
{
dcli_trim
(
line
,
line
);
nr
=
dcli_parse
(
line
,
"="
,
""
,
(
char
*
)
elemv
,
sizeof
(
elemv
)
/
sizeof
(
elemv
[
0
]),
sizeof
(
elemv
[
0
]),
0
);
if
(
nr
!=
2
)
continue
;
if
(
strcmp
(
elemv
[
0
],
"DeviceText"
)
==
0
)
{
strncpy
(
device_text
,
elemv
[
1
],
sizeof
(
device_text
));
}
else
if
(
strcmp
(
elemv
[
0
],
"VendorId"
)
==
0
)
{
sscanf
(
elemv
[
1
],
"%d"
,
&
vendor_id
);
}
else
if
(
strcmp
(
elemv
[
0
],
"DeviceId"
)
==
0
)
{
sscanf
(
elemv
[
1
],
"%d"
,
&
device_id
);
}
else
if
(
strcmp
(
elemv
[
0
],
"DeviceName"
)
==
0
)
{
strncpy
(
device_name
,
elemv
[
1
],
sizeof
(
device_name
));
}
else
if
(
strcmp
(
elemv
[
0
],
"IP_Address"
)
==
0
)
{
strncpy
(
ip_address
,
elemv
[
1
],
sizeof
(
ip_address
));
}
else
if
(
strcmp
(
elemv
[
0
],
"MAC_Address"
)
==
0
)
{
strncpy
(
mac_address
,
elemv
[
1
],
sizeof
(
mac_address
));
if
(
(
s
=
strchr
(
mac_address
,
'/'
)))
*
s
=
0
;
dcli_trim
(
mac_address
,
mac_address
);
break
;
}
}
fclose
(
fp
);
fprintf
(
ofp
,
"
\"
%s
\"
\"
%s
\"
\"
%s
\"
\"
%s
\"
%d %d
\n
"
,
device_text
,
device_name
,
ip_address
,
mac_address
,
vendor_id
,
device_id
);
}
fclose
(
ofp
);
}
return
1
;
}
static
int
pndevice_check_io
(
device_sCtx
*
ctx
,
gsdml_VirtualSubmoduleList
*
vsl
,
static
int
pndevice_check_io
(
device_sCtx
*
ctx
,
gsdml_VirtualSubmoduleList
*
vsl
,
vector
<
ChanItem
>&
input_vect
,
vector
<
ChanItem
>&
output_vect
)
vector
<
ChanItem
>&
input_vect
,
vector
<
ChanItem
>&
output_vect
)
...
...
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