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
988dbcbe
Commit
988dbcbe
authored
Mar 31, 2006
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved to lib/wb
parent
61ae9cef
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
5230 deletions
+0
-5230
profibus/lib/pb/src/os_linux/hw_x86/makefile
profibus/lib/pb/src/os_linux/hw_x86/makefile
+0
-15
profibus/lib/pb/src/pb_gsd.cpp
profibus/lib/pb/src/pb_gsd.cpp
+0
-1994
profibus/lib/pb/src/pb_gsd.h
profibus/lib/pb/src/pb_gsd.h
+0
-239
profibus/lib/pb/src/pb_gsd_attr.cpp
profibus/lib/pb/src/pb_gsd_attr.cpp
+0
-543
profibus/lib/pb/src/pb_gsd_attr.h
profibus/lib/pb/src/pb_gsd_attr.h
+0
-99
profibus/lib/pb/src/pb_gsd_attrnav.cpp
profibus/lib/pb/src/pb_gsd_attrnav.cpp
+0
-2057
profibus/lib/pb/src/pb_gsd_attrnav.h
profibus/lib/pb/src/pb_gsd_attrnav.h
+0
-283
No files found.
profibus/lib/pb/src/os_linux/hw_x86/makefile
deleted
100644 → 0
View file @
61ae9cef
include
$(pwre_dir_symbols)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq
($($(type_name)_generic_mk),)
-include
$(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq
($($(type_name)_generic_mk),)
include
$(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
-include
../../special.mk
-include
../special.mk
-include
special.mk
profibus/lib/pb/src/pb_gsd.cpp
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd.cpp,v 1.1 2006-03-22 14:38:11 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.
*/
/* pb_gsd.cpp -- Parse gsd file */
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rt_pb_msg.h"
#include "pb_gsd.h"
#include "co_dcli.h"
#include "co_cdh.h"
typedef
enum
{
gsd_M
,
gsd_O
,
gsd_D
,
gsd_G
,
gsd_MD
,
// Mandatory with depencency
gsd_OD
// Optional with depencency
}
gsd_eOpt
;
typedef
enum
{
gsd_mSts_Profibus_DP
=
1
<<
0
,
gsd_mSts_Module
=
1
<<
1
,
gsd_mSts_Area
=
1
<<
2
,
gsd_mSts_PrmText
=
1
<<
3
,
gsd_mSts_ExtUserPrmData
=
1
<<
4
}
gsd_mSts
;
gsd_sKeyword
pb_gsd
::
keywordlist
[]
=
{
// General
{
"#Profibus_DP"
,
""
,
gsd_M
,
gsd_ProfibusDP
,
0
},
{
"GSD_Revision"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"Vendor_Name"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"Model_Name"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"Revision"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"Revision_Number"
,
""
,
gsd_O
,
gsd_Unsigned8
,
0
},
{
"Ident_Number"
,
""
,
gsd_M
,
gsd_Unsigned16
,
0
},
{
"Protocol_Ident"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"Station_Type"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"FMS_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Hardware_Release"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"Software_Release"
,
""
,
gsd_M
,
gsd_VString32
,
0
},
{
"9.6_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"19.2_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"31.25_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"45.45_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"93.75_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"187.5_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"500_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"1.5M_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"3M_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"6M_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"12M_supp"
,
"supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"MaxTsdr_9.6"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_19.2"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_31.25"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_45.45"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_93.75"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_187.5"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_500"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_1.5M"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_3M"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_6M"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"MaxTsdr_12M"
,
"MaxTsdr"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Redundancy"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Repeater_Ctrl_Sig"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"24V_Pins"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Implementation_Type"
,
""
,
gsd_O
,
gsd_VString32
,
0
},
{
"Bitmap_Device"
,
""
,
gsd_O
,
gsd_VString8
,
0
},
{
"Bitmap_Diag"
,
""
,
gsd_O
,
gsd_VString8
,
0
},
{
"Bitmap_SF"
,
""
,
gsd_O
,
gsd_VString8
,
0
},
{
"Physical_Interface"
,
""
,
gsd_O
,
gsd_Unsigned8
,
0
},
{
"Transmission_Delay_9.6"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_19.2"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_31.25"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_45.45"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_93.75"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_187.5"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_500"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_1.5M"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_3M"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_6M"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Transmission_Delay_12M"
,
"Transmission_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_9.6"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_19.2"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_31.25"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_45.45"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_93.75"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_187.5"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_500"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_1.5M"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_3M"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_6M"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Reaction_Delay_12M"
,
"Reaction_Delay"
,
gsd_G
,
gsd_Unsigned16
,
0
},
// Master
{
"Master_Freeze_Mode_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Master_Sync_Mode_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Master_Fail_Safe_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Download_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Upload_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Act_Para_Brct_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Act_Param_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Max_MPS_Length"
,
""
,
gsd_M
,
gsd_Unsigned32
,
0
},
{
"Max_Lsdu_MS"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"Min_Poll_Timeout"
,
""
,
gsd_M
,
gsd_Unsigned16
,
0
},
{
"Trdy_9.6"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_19.2"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_31.25"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_45.45"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_93.75"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_187.5"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_500"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_1.5M"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_3M"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_6M"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Trdy_12M"
,
"Trdy"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_9.6"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_19.2"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_31.25"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_45.45"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_93.75"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_187.5"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_500"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_1.5M"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_3M"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_6M"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tqui_12M"
,
"Tqui"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_9.6"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_19.2"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_31.25"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_45.45"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_93.75"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_187.5"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_500"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_1.5M"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_3M"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_6M"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"Tset_12M"
,
"Tset"
,
gsd_G
,
gsd_Unsigned8
,
0
},
{
"LAS_Len"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"Tsdi_9.6"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_19.2"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_31.25"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_45.45"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_93.75"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_187.5"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_500"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_1.5M"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_3M"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_6M"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Tsdi_12M"
,
"Tsdi"
,
gsd_G
,
gsd_Unsigned16
,
0
},
{
"Max_Slaves_supp"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"Max_Master_Input_Len"
,
""
,
gsd_O
,
gsd_Unsigned8
,
0
},
{
"Max_Master_Output_Len"
,
""
,
gsd_O
,
gsd_Unsigned8
,
0
},
{
"Max_Master_Data_Len"
,
""
,
gsd_O
,
gsd_Unsigned16
,
0
},
// Master DP extensions
{
"DPV1_Master"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"DPV1_Conformance_Class"
,
""
,
gsd_O
,
gsd_Unsigned8
,
0
},
{
"C1_Master_Read_Write_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Master_DPV1_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Master_Diagnostic_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Process_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Pull_Plug_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Status_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Update_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Manufacturer_Alarm_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_G
,
gsd_Boolean
,
0
},
{
"Master_Extra_Alarm_SAP_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_MD
,
gsd_Boolean
,
0
},
{
"Master_Alarm_Sequence_Mode"
,
"Master_DPV1_Alarm_Supp"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Master_Alarm_Type_Mode_supp"
,
"Master_DPV1_Alarm_Supp"
,
gsd_MD
,
gsd_Boolean
,
0
},
// Master DP-V2
{
"Isochron_Mode_Synchronised"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"DXB_Master_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"X_Master_Prm_SAP_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
// Slave
{
"Freeze_Mode_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Sync_Mode_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Auto_Baud_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Set_Slave_Add_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"User_Prm_Data_Len"
,
""
,
gsd_D
,
gsd_UserPrmDataLen
,
0
},
{
"User_Prm_Data"
,
""
,
gsd_D
,
gsd_UserPrmData
,
0
},
{
"Min_Slave_Intervall"
,
""
,
gsd_M
,
gsd_Unsigned16
,
0
},
{
"Modular_Station"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Max_Module"
,
"Modular_Station"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Max_Input_Len"
,
"Modular_Station"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Max_Output_Len"
,
"Modular_Station"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Max_Data_Len"
,
"Modular_Station"
,
gsd_OD
,
gsd_Unsigned16
,
0
},
{
"Unit_Diag_Bit"
,
""
,
gsd_O
,
gsd_BitVString32
,
0
},
{
"X_Unit_Diag_Bit"
,
""
,
gsd_O
,
gsd_BitVString32
,
0
},
{
"Unit_Diag_Bit_Help"
,
""
,
gsd_O
,
gsd_BitVString256
,
0
},
{
"X_Unit_Diag_Bit_Help"
,
""
,
gsd_O
,
gsd_BitVString256
,
0
},
{
"Unit_Diag_Not_Bit"
,
""
,
gsd_O
,
gsd_BitVString32
,
0
},
{
"X_Unit_Diag_Not_Bit"
,
""
,
gsd_O
,
gsd_BitVString32
,
0
},
{
"Unit_Diag_Not_Bit_Help"
,
""
,
gsd_O
,
gsd_BitVString256
,
0
},
{
"X_Unit_Diag_Not_Bit_Help"
,
""
,
gsd_O
,
gsd_BitVString256
,
0
},
{
"Unit_Diag_Area"
,
""
,
gsd_O
,
gsd_DiagArea
,
0
},
{
"Unit_Diag_Area_End"
,
""
,
gsd_O
,
gsd_DiagAreaEnd
,
0
},
{
"X_Unit_Diag_Area"
,
""
,
gsd_O
,
gsd_DiagArea
,
0
},
{
"Unit_Diag_Type"
,
""
,
gsd_O
,
gsd_DiagType
,
0
},
{
"Value"
,
"Unit_Diag_Area"
,
gsd_O
,
gsd_Value
,
0
},
{
"Module"
,
""
,
gsd_O
,
gsd_Module
,
0
},
{
"EndModule"
,
""
,
gsd_O
,
gsd_EndModule
,
0
},
{
"Module_Reference"
,
"Module"
,
gsd_O
,
gsd_Unsigned16
,
0
},
{
"Ext_Module_Prm_Data_Len"
,
"Module"
,
gsd_O
,
gsd_Unsigned16
,
0
},
{
"X_Ext_Module_Prm_Data_Len"
,
"Module"
,
gsd_O
,
gsd_Unsigned16
,
0
},
{
"F_Ext_Module_Prm_Data_Len"
,
"Module"
,
gsd_O
,
gsd_Unsigned16
,
0
},
{
"Data_Area_Beg"
,
""
,
gsd_O
,
gsd_DataAreaBegin
,
0
},
{
"Data_Area_End"
,
""
,
gsd_O
,
gsd_DataAreaEnd
,
0
},
{
"Related_CFG_Identifier"
,
"Data_Area"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"IO_Direction"
,
"Data_Area"
,
gsd_MD
,
gsd_Boolean
,
0
},
{
"Length"
,
"Data_Area"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Consistency"
,
"Data_Area"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Publisher_allowed"
,
"Data_Area"
,
gsd_MD
,
gsd_Boolean
,
0
},
{
"DP_Master_allowed"
,
"Data_Area"
,
gsd_MD
,
gsd_Boolean
,
0
},
{
"Data_Type"
,
"Data_Area"
,
gsd_MD
,
gsd_Unsigned8
,
0
},
{
"Channel_Diag"
,
""
,
gsd_O
,
gsd_BitVString32
,
0
},
{
"Channel_Diag_Help"
,
""
,
gsd_O
,
gsd_BitVString256
,
0
},
{
"Fail_Safe"
,
""
,
gsd_O
,
gsd_Boolean
,
0
},
{
"Max_Diag_Data_Len"
,
""
,
gsd_M
,
gsd_Unsigned8
,
0
},
{
"Modul_Offset"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Slave_Family"
,
""
,
gsd_M
,
gsd_SlaveFamily
,
0
},
{
"Family_Name"
,
""
,
gsd_O
,
gsd_VString32
,
0
},
{
"OrderNumber"
,
""
,
gsd_O
,
gsd_VString32
,
0
},
{
"Diag_Update_Delay"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Fail_Safe_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Info_Text"
,
""
,
gsd_O
,
gsd_VString256
,
0
},
{
"PrmText"
,
""
,
gsd_O
,
gsd_PrmText
,
0
},
{
"EndPrmText"
,
""
,
gsd_O
,
gsd_EndPrmText
,
0
},
{
"ExtUserPrmData"
,
""
,
gsd_O
,
gsd_ExtUserPrmData
,
0
},
{
"EndExtUserPrmData"
,
""
,
gsd_O
,
gsd_EndExtUserPrmData
,
0
},
{
"Prm_Text_Ref"
,
"ExtUserPrmData"
,
gsd_O
,
gsd_Unsigned16
,
0
},
{
"Changeable"
,
"ExtUserPrmData"
,
gsd_O
,
gsd_Boolean
,
0
},
{
"Visible"
,
"ExtUserPrmData"
,
gsd_O
,
gsd_Boolean
,
0
},
{
"Text"
,
""
,
gsd_O
,
gsd_Text
,
0
},
{
"Max_User_Prm_Data_Len"
,
""
,
gsd_M
,
gsd_MaxUserPrmDataLen
,
0
},
{
"Ext_User_Prm_Data_Ref"
,
""
,
gsd_M
,
gsd_ExtUserPrmDataRef
,
0
},
{
"Ext_User_Prm_Data_Const"
,
""
,
gsd_M
,
gsd_ExtUserPrmDataConst
,
0
},
// Slave DP extentions
{
"DPV1_Slave"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"C1_Read_Write_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"C2_Read_Write_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"C1_Max_Data_Len"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"C2_Max_Data_Len"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"C1_Response_Timeout"
,
""
,
gsd_D
,
gsd_Unsigned16
,
0
},
{
"C2_Response_Timeout"
,
""
,
gsd_D
,
gsd_Unsigned16
,
0
},
{
"C1_Read_Write_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"C2_Read_Write_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"C2_Max_Count_Channels"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Max_Initiate_PDU_Length"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Diagnostic_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Process_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Pull_Plug_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Status_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Update_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Manufacturer_Specific_Alarm_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Extra_Alarm_SAP_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Alarm_Sequence_Mode_Count"
,
""
,
gsd_D
,
gsd_Unsigned8
,
0
},
{
"Alarm_Type_Mode_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Diagnostic_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Process_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Pull_Plug_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Status_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Update_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Manufacturer_Specific_Alarm_required"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"DPV1_Data_Types"
,
""
,
gsd_O
,
gsd_Boolean
,
0
},
{
"WB_Base_1ms_supp"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
"Check_Cfg_Mode"
,
""
,
gsd_D
,
gsd_Boolean
,
0
},
{
""
,
""
,
0
,
gsd_End
,
0
}
};
#if 0
// malloc check
static void t_free( void *a1) { printf("free: %d\n", a1); free(a1);}
static void *t_calloc( int a1, int a2) {
void *p = calloc(a1,a2);
printf("calloc: %d %d %d\n", p, (char *)p + a2*a1, a2*a1);
return p;
}
static void *t_malloc( int a1) {
void *p = malloc(a1);
printf("malloc: %d %d %d\n", p, (char *)p + a1, a1);
return p;
}
#define calloc( a1, a2) t_calloc(a1,a2)
#define malloc( a1) t_malloc(a1)
#define free(a1) t_free(a1)
#endif
pb_gsd
::
pb_gsd
()
:
dptype
(
0
),
modular_station
(
0
),
max_module
(
0
),
user_prm_data_len
(
0
),
max_user_prm_data_len
(
0
),
status
(
0
),
datalist
(
0
),
modulelist
(
0
),
prm_textlist
(
0
),
extuserprmdatalist
(
0
),
extuserprmdatareflist
(
0
),
current_module
(
0
),
current_area
(
0
),
current_prm_text
(
0
),
current_extuserprmdata
(
0
),
extuserprmdataconst
(
0
),
prm_dataitems
(
0
),
module_conf
(
0
),
module_conf_cnt
(
0
),
module_classlist
(
0
),
copy_buff
(
0
),
modified
(
0
)
{
datalist
=
(
gsd_sData
*
)
calloc
(
sizeof
(
keywordlist
)
/
sizeof
(
keywordlist
[
0
]),
sizeof
(
gsd_sData
));
}
pb_gsd
::~
pb_gsd
()
{
if
(
datalist
)
{
for
(
int
i
=
0
;
i
<
(
int
)(
sizeof
(
keywordlist
)
/
sizeof
(
keywordlist
[
0
]));
i
++
)
{
if
(
datalist
[
i
].
data
)
free
(
datalist
[
i
].
data
);
}
free
(
(
char
*
)
datalist
);
}
gsd_sExtUserPrmDataRef
*
rp
,
*
rnext
;
for
(
rp
=
extuserprmdatareflist
;
rp
;
rp
=
rnext
)
{
rnext
=
rp
->
next
;
free
(
(
char
*
)
rp
);
}
gsd_sExtUserPrmData
*
dp
,
*
dnext
;
for
(
dp
=
extuserprmdatalist
;
dp
;
dp
=
dnext
)
{
dnext
=
dp
->
next
;
free
(
(
char
*
)
dp
);
}
gsd_sModule
*
mp
,
*
mnext
;
for
(
mp
=
modulelist
;
mp
;
mp
=
mnext
)
{
mnext
=
mp
->
next
;
if
(
mp
->
extuserprmdataconst
)
free
(
(
char
*
)
mp
->
extuserprmdataconst
);
for
(
rp
=
mp
->
extuserprmdatareflist
;
rp
;
rp
=
rnext
)
{
rnext
=
rp
->
next
;
free
(
(
char
*
)
rp
);
}
if
(
mp
->
Config
)
free
(
mp
->
Config
);
free
(
(
char
*
)
mp
);
}
gsd_sPrmText
*
ptp
,
*
ptnext
;
gsd_sText
*
tp
,
*
tnext
;
for
(
ptp
=
prm_textlist
;
ptp
;
ptp
=
ptnext
)
{
ptnext
=
ptp
->
next
;
for
(
tp
=
ptp
->
text_list
;
tp
;
tp
=
tnext
)
{
tnext
=
tp
->
next
;
free
(
(
char
*
)
tp
);
}
free
(
(
char
*
)
ptp
);
}
if
(
extuserprmdataconst
)
free
(
(
char
*
)
extuserprmdataconst
);
if
(
prm_dataitems
)
free
(
(
char
*
)
prm_dataitems
);
if
(
module_conf
)
free
(
(
char
*
)
module_conf
);
if
(
copy_buff
)
{
if
(
copy_buff
->
prm_dataitems
)
free
(
(
char
*
)
copy_buff
->
prm_dataitems
);
free
(
copy_buff
);
}
}
int
pb_gsd
::
read
(
char
*
filename
)
{
pwr_tFileName
fname
;
int
state
;
char
line
[
1000
];
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
char
line_part
[
6
][
500
];
char
idxline_part
[
2
][
500
];
int
idxpart_cnt
;
int
has_idx
;
char
idx_str
[
80
];
int
part_cnt
;
int
sts
;
FILE
*
fp
;
int
found
;
int
idx
;
int
read_line_done
=
0
;
printf
(
"-- Processing file %s
\n
"
,
filename
);
dcli_translate_filename
(
fname
,
filename
);
fp
=
fopen
(
fname
,
"r"
);
if
(
!
fp
)
return
PB__GSDFILE
;
state
=
0
;
line_cnt
=
0
;
while
(
1
)
{
if
(
!
read_line_done
)
{
sts
=
read_line
(
line
,
sizeof
(
line
),
fp
);
if
(
!
sts
)
break
;
}
else
read_line_done
=
0
;
compress
(
line
);
part_cnt
=
dcli_parse
(
line
,
" ="
,
""
,
(
char
*
)
line_part
,
sizeof
(
line_part
)
/
sizeof
(
line_part
[
0
]),
sizeof
(
line_part
[
0
]),
0
);
has_idx
=
0
;
if
(
strchr
(
line_part
[
0
],
'('
)
!=
0
)
{
idxpart_cnt
=
dcli_parse
(
line_part
[
0
],
" ()"
,
""
,
(
char
*
)
idxline_part
,
sizeof
(
idxline_part
)
/
sizeof
(
idxline_part
[
0
]),
sizeof
(
idxline_part
[
0
]),
0
);
if
(
idxpart_cnt
==
2
)
{
strcpy
(
line_part
[
0
],
idxline_part
[
0
]);
strcpy
(
idx_str
,
idxline_part
[
1
]);
has_idx
=
1
;
}
}
found
=
0
;
idx
=
0
;
for
(
keyp
=
keywordlist
;
keyp
->
type
!=
gsd_End
;
keyp
++
)
{
if
(
cdh_NoCaseStrcmp
(
line_part
[
0
],
keyp
->
name
)
==
0
)
{
found
=
1
;
break
;
}
idx
++
;
}
if
(
!
found
)
{
printf
(
"Keyword not found, line %d, %s
\n
"
,
line_cnt
,
line_part
[
0
]);
continue
;
}
datap
=
&
datalist
[
idx
];
switch
(
keyp
->
type
)
{
case
gsd_Boolean
:
case
gsd_Unsigned8
:
case
gsd_Unsigned16
:
case
gsd_Unsigned32
:
case
gsd_UserPrmDataLen
:
case
gsd_MaxUserPrmDataLen
:
if
(
line_part
[
1
][
0
]
==
'0'
&&
line_part
[
1
][
1
]
==
'x'
)
sts
=
sscanf
(
&
line_part
[
1
][
2
],
"%x"
,
&
datap
->
value
);
else
sts
=
sscanf
(
line_part
[
1
],
"%d"
,
&
datap
->
value
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d %d (%s) (%s)
\n
"
,
line_cnt
,
sts
,
line_part
[
0
],
line_part
[
1
]);
datap
->
found
=
1
;
if
(
keyp
->
type
==
gsd_UserPrmDataLen
)
user_prm_data_len
=
datap
->
value
;
else
if
(
keyp
->
type
==
gsd_MaxUserPrmDataLen
)
max_user_prm_data_len
=
datap
->
value
;
if
(
strcmp
(
keyp
->
group
,
"Module"
)
==
0
)
{
// Insert in module data
if
(
!
current_module
)
{
printf
(
"Module keyword outside module, line %d
\n
"
,
line_cnt
);
break
;
}
if
(
strcmp
(
keyp
->
name
,
"Module_Reference"
)
==
0
)
current_module
->
Module_Reference
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Ext_Module_Prm_Data_Len"
)
==
0
)
current_module
->
Ext_Module_Prm_Data_Len
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"X_Ext_Module_Prm_Data_Len"
)
==
0
)
current_module
->
X_Ext_Module_Prm_Data_Len
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"F_Ext_Module_Prm_Data_Len"
)
==
0
)
current_module
->
F_Ext_Module_Prm_Data_Len
=
datap
->
value
;
}
else
if
(
strcmp
(
keyp
->
group
,
"Area"
)
==
0
)
{
// Insert in area data
if
(
!
current_area
)
{
printf
(
"Area keyword outside area, line %d
\n
"
,
line_cnt
);
break
;
}
if
(
strcmp
(
keyp
->
name
,
"Related_CFG_Identifier"
)
==
0
)
current_area
->
Related_CFG_Identifier
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"IO_Direction"
)
==
0
)
current_area
->
IO_Direction
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Length"
)
==
0
)
current_area
->
Length
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Consistency"
)
==
0
)
current_area
->
Consistency
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Publisher_allowed"
)
==
0
)
current_area
->
Publisher_allowed
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"DP_Master_allowed"
)
==
0
)
current_area
->
DP_Master_allowed
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Data_Type"
)
==
0
)
current_area
->
Data_Type
[
current_area
->
data_type_cnt
++
]
=
datap
->
value
;
}
else
if
(
strcmp
(
keyp
->
group
,
"ExtUserPrmData"
)
==
0
)
{
// Insert in area data
if
(
!
current_extuserprmdata
)
{
printf
(
"Prm data keyword outside ExtUserPrmData, line %d
\n
"
,
line_cnt
);
break
;
}
if
(
strcmp
(
keyp
->
name
,
"Prm_Text_Ref"
)
==
0
)
current_extuserprmdata
->
Prm_Text_Ref
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Changeable"
)
==
0
)
current_extuserprmdata
->
Changeable
=
datap
->
value
;
else
if
(
strcmp
(
keyp
->
name
,
"Visible"
)
==
0
)
current_extuserprmdata
->
Visible
=
datap
->
value
;
}
else
if
(
strcmp
(
keyp
->
name
,
"Max_Module"
)
==
0
)
{
dptype
=
gsd_DpSlave
;
max_module
=
datap
->
value
;
}
else
if
(
strcmp
(
keyp
->
name
,
"Modular_Station"
)
==
0
)
{
dptype
=
gsd_DpSlave
;
modular_station
=
datap
->
value
;
}
else
if
(
strcmp
(
keyp
->
name
,
"Max_MPS_Length"
)
==
0
)
{
dptype
=
gsd_DpMaster
;
}
break
;
case
gsd_VString8
:
case
gsd_VString32
:
case
gsd_VString256
:
datap
->
data
=
malloc
(
256
);
strcpy
(
(
char
*
)
datap
->
data
,
line_part
[
1
]);
datap
->
found
=
1
;
if
(
strcmp
(
keyp
->
group
,
"Area"
)
==
0
)
{
// Insert in area data
if
(
!
current_area
)
{
printf
(
"Area keyword outside area, line %d
\n
"
,
line_cnt
);
break
;
}
if
(
strcmp
(
keyp
->
name
,
"Area_Name"
)
==
0
)
strcpy
(
current_area
->
Area_Name
,
(
char
*
)
datap
->
data
);
}
break
;
case
gsd_UserPrmData
:
case
gsd_OString
:
{
char
*
s
=
strchr
(
line
,
'='
);
str_to_ostring
(
(
unsigned
char
**
)
&
datap
->
data
,
s
+
1
,
256
,
0
);
datap
->
found
=
1
;
break
;
}
case
gsd_Module
:
{
gsd_sModule
*
mp
;
gsd_sModule
*
m
=
(
gsd_sModule
*
)
calloc
(
1
,
sizeof
(
gsd_sModule
));
strncpy
(
m
->
Mod_Name
,
line_part
[
1
],
sizeof
(
m
->
Mod_Name
));
if
(
part_cnt
>
2
)
str_to_ostring
(
&
m
->
Config
,
line_part
[
2
],
244
,
&
m
->
config_size
);
if
(
!
modulelist
)
modulelist
=
m
;
else
{
mp
=
modulelist
;
while
(
mp
->
next
)
mp
=
mp
->
next
;
mp
->
next
=
m
;
}
datap
->
found
=
1
;
status
|=
gsd_mSts_Module
;
current_module
=
m
;
// Read Module_Reference
sts
=
read_line
(
line
,
sizeof
(
line
),
fp
);
if
(
!
sts
)
break
;
sts
=
sscanf
(
line
,
"%d"
,
&
m
->
Module_Reference
);
if
(
sts
!=
1
)
{
// Module_Reference is missing
read_line_done
=
1
;
}
break
;
}
case
gsd_EndModule
:
status
&=
~
gsd_mSts_Module
;
current_module
=
0
;
break
;
case
gsd_DataAreaBegin
:
{
gsd_sArea
*
ap
;
gsd_sArea
*
a
=
(
gsd_sArea
*
)
calloc
(
1
,
sizeof
(
gsd_sArea
));
if
(
!
current_module
)
{
printf
(
"Area outside module, line %d
\n
"
,
line_cnt
);
break
;
}
if
(
!
current_module
->
arealist
)
current_module
->
arealist
=
a
;
else
{
ap
=
current_module
->
arealist
;
while
(
ap
->
next
)
ap
=
ap
->
next
;
ap
->
next
=
a
;
}
datap
->
found
=
1
;
status
|=
gsd_mSts_Area
;
current_area
=
a
;
break
;
}
case
gsd_DataAreaEnd
:
status
&=
~
gsd_mSts_Area
;
current_area
=
0
;
break
;
case
gsd_PrmText
:
{
gsd_sPrmText
*
p
,
*
pp
;
p
=
(
gsd_sPrmText
*
)
calloc
(
1
,
sizeof
(
gsd_sPrmText
));
sts
=
sscanf
(
line_part
[
1
],
"%d"
,
&
p
->
Reference_Number
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d %d (%s) (%s)
\n
"
,
line_cnt
,
sts
,
line_part
[
0
],
line_part
[
1
]);
if
(
!
prm_textlist
)
prm_textlist
=
p
;
else
{
pp
=
prm_textlist
;
while
(
pp
->
next
)
pp
=
pp
->
next
;
pp
->
next
=
p
;
}
current_prm_text
=
p
;
status
|=
gsd_mSts_PrmText
;
break
;
}
case
gsd_EndPrmText
:
{
status
&=
~
gsd_mSts_PrmText
;
current_prm_text
=
0
;
break
;
}
case
gsd_Text
:
{
gsd_sText
*
t
,
*
tp
;
t
=
(
gsd_sText
*
)
calloc
(
1
,
sizeof
(
gsd_sText
));
if
(
!
has_idx
||
!
current_prm_text
||
part_cnt
<
2
)
{
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line_part
[
0
]);
break
;
}
dcli_remove_blank
(
idx_str
,
idx_str
);
if
(
idx_str
[
0
]
==
'0'
&&
idx_str
[
1
]
==
'x'
)
sts
=
sscanf
(
idx_str
,
"%x"
,
&
t
->
Prm_Data_Value
);
else
sts
=
sscanf
(
idx_str
,
"%d"
,
&
t
->
Prm_Data_Value
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line_part
[
0
]);
strcpy
(
t
->
Text
,
line_part
[
1
]);
if
(
!
current_prm_text
->
text_list
)
current_prm_text
->
text_list
=
t
;
else
{
tp
=
current_prm_text
->
text_list
;
while
(
tp
->
next
)
tp
=
tp
->
next
;
tp
->
next
=
t
;
}
break
;
}
case
gsd_ExtUserPrmData
:
{
gsd_sExtUserPrmData
*
e
,
*
ep
;
char
*
t
;
char
minval
[
20
],
maxval
[
20
];
e
=
(
gsd_sExtUserPrmData
*
)
calloc
(
1
,
sizeof
(
gsd_sExtUserPrmData
));
sts
=
sscanf
(
line_part
[
1
],
"%d"
,
&
e
->
Reference_Number
);
e
->
Changeable
=
1
;
e
->
Visible
=
1
;
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
if
(
part_cnt
>
2
)
strncpy
(
e
->
Ext_User_Prm_Data_Name
,
line_part
[
2
],
sizeof
(
e
->
Ext_User_Prm_Data_Name
));
// Read Data_Type
sts
=
read_line
(
line
,
sizeof
(
line
),
fp
);
if
(
!
sts
)
break
;
part_cnt
=
dcli_parse
(
line
,
" ="
,
""
,
(
char
*
)
line_part
,
sizeof
(
line_part
)
/
sizeof
(
line_part
[
0
]),
sizeof
(
line_part
[
0
]),
0
);
if
(
strchr
(
line_part
[
0
],
'('
)
!=
0
)
{
idxpart_cnt
=
dcli_parse
(
line_part
[
0
],
" ()"
,
""
,
(
char
*
)
idxline_part
,
sizeof
(
idxline_part
)
/
sizeof
(
idxline_part
[
0
]),
sizeof
(
idxline_part
[
0
]),
0
);
if
(
idxpart_cnt
==
2
)
{
strcpy
(
line_part
[
0
],
idxline_part
[
0
]);
strcpy
(
idx_str
,
idxline_part
[
1
]);
}
if
(
cdh_NoCaseStrcmp
(
line_part
[
0
],
"Bit"
)
==
0
)
{
sts
=
sscanf
(
idx_str
,
"%d"
,
&
e
->
bit_num
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
else
if
(
cdh_NoCaseStrcmp
(
line_part
[
0
],
"BitArea"
)
==
0
)
{
if
(
(
t
=
strrchr
(
idx_str
,
'-'
))
&&
t
!=
idx_str
)
{
strncpy
(
minval
,
idx_str
,
(
int
)(
t
-
idx_str
));
minval
[
t
-
idx_str
]
=
0
;
strcpy
(
maxval
,
t
+
1
);
sts
=
sscanf
(
minval
,
"%d"
,
&
e
->
bitarea_min
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
sts
=
sscanf
(
maxval
,
"%d"
,
&
e
->
bitarea_max
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
else
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
}
strcpy
(
e
->
Data_Type_Name
,
line_part
[
0
]);
if
(
part_cnt
>
1
)
{
sts
=
sscanf
(
line_part
[
1
],
"%d"
,
&
e
->
Default_Value
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
if
(
part_cnt
>
2
)
{
if
(
(
t
=
strrchr
(
line_part
[
2
],
'-'
))
&&
t
!=
line_part
[
2
])
{
strncpy
(
minval
,
line_part
[
2
],
(
int
)(
t
-
line_part
[
2
]));
minval
[
t
-
line_part
[
2
]]
=
0
;
strcpy
(
maxval
,
t
+
1
);
sts
=
sscanf
(
minval
,
"%d"
,
&
e
->
Min_Value
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
sts
=
sscanf
(
maxval
,
"%d"
,
&
e
->
Max_Value
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
else
{
char
allstr
[
16
][
10
];
int
all_cnt
;
all_cnt
=
dcli_parse
(
line_part
[
2
],
" ,"
,
""
,
(
char
*
)
allstr
,
sizeof
(
allstr
)
/
sizeof
(
allstr
[
0
]),
sizeof
(
allstr
[
0
]),
0
);
for
(
int
i
=
0
;
i
<
all_cnt
;
i
++
)
{
sts
=
sscanf
(
allstr
[
i
],
"%d"
,
&
e
->
Allowed_Values
[
i
]);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
}
e
->
allowed_cnt
=
all_cnt
;
}
}
if
(
!
extuserprmdatalist
)
extuserprmdatalist
=
e
;
else
{
ep
=
extuserprmdatalist
;
while
(
ep
->
next
)
ep
=
ep
->
next
;
ep
->
next
=
e
;
}
current_extuserprmdata
=
e
;
status
|=
gsd_mSts_ExtUserPrmData
;
break
;
}
case
gsd_EndExtUserPrmData
:
{
status
&=
~
gsd_mSts_ExtUserPrmData
;
current_extuserprmdata
=
0
;
break
;
}
case
gsd_ExtUserPrmDataRef
:
{
gsd_sExtUserPrmDataRef
*
e
,
*
ep
;
e
=
(
gsd_sExtUserPrmDataRef
*
)
calloc
(
1
,
sizeof
(
gsd_sExtUserPrmDataRef
));
sts
=
sscanf
(
line_part
[
1
],
"%d"
,
&
e
->
Reference_Number
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
dcli_remove_blank
(
idx_str
,
idx_str
);
if
(
idx_str
[
0
]
==
'0'
&&
idx_str
[
1
]
==
'x'
)
sts
=
sscanf
(
idx_str
,
"%x"
,
&
e
->
Reference_Offset
);
else
sts
=
sscanf
(
idx_str
,
"%d"
,
&
e
->
Reference_Offset
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line_part
[
0
]);
if
(
status
&
gsd_mSts_Module
)
{
if
(
!
current_module
->
extuserprmdatareflist
)
current_module
->
extuserprmdatareflist
=
e
;
else
{
ep
=
current_module
->
extuserprmdatareflist
;
while
(
ep
->
next
)
ep
=
ep
->
next
;
ep
->
next
=
e
;
}
}
else
{
if
(
!
extuserprmdatareflist
)
extuserprmdatareflist
=
e
;
else
{
ep
=
extuserprmdatareflist
;
while
(
ep
->
next
)
ep
=
ep
->
next
;
ep
->
next
=
e
;
}
}
break
;
}
case
gsd_ExtUserPrmDataConst
:
{
gsd_sExtUserPrmDataConst
*
e
;
unsigned
char
*
t
;
char
*
s
;
e
=
(
gsd_sExtUserPrmDataConst
*
)
calloc
(
1
,
sizeof
(
gsd_sExtUserPrmDataConst
));
dcli_remove_blank
(
idx_str
,
idx_str
);
if
(
idx_str
[
0
]
==
'0'
&&
idx_str
[
1
]
==
'x'
)
sts
=
sscanf
(
idx_str
,
"%x"
,
&
e
->
Const_Offset
);
else
sts
=
sscanf
(
idx_str
,
"%d"
,
&
e
->
Const_Offset
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line_part
[
0
]);
if
(
(
s
=
strchr
(
line
,
'='
)))
{
str_to_ostring
(
&
t
,
s
+
1
,
sizeof
(
e
->
Const_Prm_Data
),
&
e
->
len
);
if
(
e
->
len
+
e
->
Const_Offset
>
(
int
)
sizeof
(
e
->
Const_Prm_Data
))
printf
(
"Const length too large, line %d (%s)
\n
"
,
line_cnt
,
line_part
[
0
]);
memcpy
(
(
char
*
)
e
->
Const_Prm_Data
+
e
->
Const_Offset
,
(
char
*
)
t
,
sizeof
(
e
->
Const_Prm_Data
)
-
e
->
Const_Offset
);
free
(
t
);
}
if
(
status
&
gsd_mSts_Module
)
{
current_module
->
extuserprmdataconst
=
e
;
}
else
{
extuserprmdataconst
=
e
;
}
break
;
}
case
gsd_ProfibusDP
:
status
|=
gsd_mSts_Profibus_DP
;
break
;
case
gsd_SlaveFamily
:
{
char
fam_part
[
20
][
4
];
int
fam_cnt
;
int
family
;
fam_cnt
=
dcli_parse
(
line_part
[
1
],
" @"
,
""
,
(
char
*
)
fam_part
,
sizeof
(
fam_part
)
/
sizeof
(
fam_part
[
0
]),
sizeof
(
fam_part
[
0
]),
0
);
if
(
fam_cnt
<
1
)
{
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
break
;
}
sts
=
sscanf
(
fam_part
[
0
],
"%d"
,
&
family
);
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d (%s)
\n
"
,
line_cnt
,
line
);
datap
->
data
=
malloc
(
256
);
datap
->
found
=
1
;
switch
(
family
)
{
case
0
:
strcpy
(
(
char
*
)
datap
->
data
,
"General"
);
break
;
case
1
:
strcpy
(
(
char
*
)
datap
->
data
,
"Drives"
);
break
;
case
2
:
strcpy
(
(
char
*
)
datap
->
data
,
"Switching devices"
);
break
;
case
3
:
strcpy
(
(
char
*
)
datap
->
data
,
"I/O"
);
break
;
case
4
:
strcpy
(
(
char
*
)
datap
->
data
,
"Valves"
);
break
;
case
5
:
strcpy
(
(
char
*
)
datap
->
data
,
"Controllers"
);
break
;
case
6
:
strcpy
(
(
char
*
)
datap
->
data
,
"HMI"
);
break
;
case
7
:
strcpy
(
(
char
*
)
datap
->
data
,
"Encoders"
);
break
;
case
8
:
strcpy
(
(
char
*
)
datap
->
data
,
"NC/RC"
);
break
;
case
9
:
strcpy
(
(
char
*
)
datap
->
data
,
"Gateway"
);
break
;
case
10
:
strcpy
(
(
char
*
)
datap
->
data
,
"Programmable Logic Controllers"
);
break
;
case
11
:
strcpy
(
(
char
*
)
datap
->
data
,
"Ident systems"
);
break
;
case
12
:
strcpy
(
(
char
*
)
datap
->
data
,
"Profibus PA Profile"
);
break
;
default:
strcpy
(
(
char
*
)
datap
->
data
,
"Unknown"
);
}
for
(
int
i
=
1
;
i
<
fam_cnt
;
i
++
)
{
strcat
(
(
char
*
)
datap
->
data
,
" / "
);
strcat
(
(
char
*
)
datap
->
data
,
fam_part
[
i
]);
}
break
;
}
case
gsd_BitVString32
:
case
gsd_BitVString256
:
case
gsd_DiagArea
:
case
gsd_DiagAreaEnd
:
case
gsd_DiagType
:
case
gsd_Value
:
if
(
part_cnt
>=
2
)
printf
(
"Line %s %s
\n
"
,
keyp
->
name
,
line_part
[
1
]);
else
printf
(
"Line %s
\n
"
,
keyp
->
name
);
break
;
default:
printf
(
"Unknown type, line %d
\n
"
,
line_cnt
);
}
}
build
();
return
1
;
}
int
pb_gsd
::
build
()
{
// Link ExtUserPrmData to PrmText
for
(
gsd_sExtUserPrmData
*
dp
=
extuserprmdatalist
;
dp
;
dp
=
dp
->
next
)
{
if
(
dp
->
Prm_Text_Ref
!=
0
)
{
for
(
gsd_sPrmText
*
tp
=
prm_textlist
;
tp
;
tp
=
tp
->
next
)
{
if
(
dp
->
Prm_Text_Ref
==
tp
->
Reference_Number
)
{
dp
->
prmtext
=
tp
;
break
;
}
}
if
(
!
dp
->
prmtext
)
printf
(
"** Referenced PrmText not found %d
\n
"
,
dp
->
Prm_Text_Ref
);
}
}
// Translate ExtUserPrmData Data_Type_Name
for
(
gsd_sExtUserPrmData
*
dp
=
extuserprmdatalist
;
dp
;
dp
=
dp
->
next
)
{
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Bit"
)
==
0
)
dp
->
data_type
=
gsd_Bit
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"BitArea"
)
==
0
)
dp
->
data_type
=
gsd_BitArea
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Unsigned8"
)
==
0
)
dp
->
data_type
=
gsd_Unsigned8
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Unsigned16"
)
==
0
)
dp
->
data_type
=
gsd_Unsigned16
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Unsigned32"
)
==
0
)
dp
->
data_type
=
gsd_Unsigned32
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Signed8"
)
==
0
)
dp
->
data_type
=
gsd_Signed8
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Signed16"
)
==
0
)
dp
->
data_type
=
gsd_Signed16
;
else
if
(
cdh_NoCaseStrcmp
(
dp
->
Data_Type_Name
,
"Signed32"
)
==
0
)
dp
->
data_type
=
gsd_Signed32
;
else
printf
(
"** Unknown Data_Type_Name
\"
%s
\"
in ExtUserPrmData %s
\n
"
,
dp
->
Data_Type_Name
,
dp
->
Ext_User_Prm_Data_Name
);
}
// Link ExtUserPrmDataRef to ExtUserPrmData
for
(
gsd_sExtUserPrmDataRef
*
ep
=
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
for
(
gsd_sExtUserPrmData
*
dp
=
extuserprmdatalist
;
dp
;
dp
=
dp
->
next
)
{
if
(
ep
->
Reference_Number
==
dp
->
Reference_Number
)
{
ep
->
prm_data
=
dp
;
break
;
}
}
if
(
!
ep
->
prm_data
)
printf
(
"** Referenced ExtUserPrmData not found %d
\n
"
,
ep
->
Reference_Number
);
}
// Create data items for slave ExtPrmData
prm_dataitems_cnt
=
0
;
for
(
gsd_sExtUserPrmDataRef
*
ep
=
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
prm_dataitems_cnt
++
;
prm_dataitems
=
(
gsd_sPrmDataItem
*
)
calloc
(
prm_dataitems_cnt
,
sizeof
(
gsd_sPrmDataItem
));
int
i
=
0
;
for
(
gsd_sExtUserPrmDataRef
*
ep
=
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
prm_dataitems
[
i
].
ref
=
ep
;
i
++
;
}
// Link Module UserPrmDataRef to ExtUserPrmData
for
(
gsd_sModule
*
mp
=
modulelist
;
mp
;
mp
=
mp
->
next
)
{
for
(
gsd_sExtUserPrmDataRef
*
ep
=
mp
->
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
for
(
gsd_sExtUserPrmData
*
dp
=
extuserprmdatalist
;
dp
;
dp
=
dp
->
next
)
{
if
(
ep
->
Reference_Number
==
dp
->
Reference_Number
)
{
ep
->
prm_data
=
dp
;
break
;
}
}
if
(
!
ep
->
prm_data
)
printf
(
"** Referenced ExtUserPrmData not found %d
\n
"
,
ep
->
Reference_Number
);
}
}
// Check Module UserPrmDataLen
for
(
gsd_sModule
*
mp
=
modulelist
;
mp
;
mp
=
mp
->
next
)
{
if
(
mp
->
Ext_Module_Prm_Data_Len
==
0
&&
mp
->
extuserprmdataconst
)
mp
->
Ext_Module_Prm_Data_Len
=
mp
->
extuserprmdataconst
->
len
;
else
if
(
mp
->
extuserprmdataconst
&&
mp
->
Ext_Module_Prm_Data_Len
!=
mp
->
extuserprmdataconst
->
len
)
{
printf
(
"** ExtUserPrmDataLen differs (%d) (%d), Module %s
\n
"
,
mp
->
Ext_Module_Prm_Data_Len
,
mp
->
extuserprmdataconst
->
len
,
mp
->
Mod_Name
);
}
}
if
(
dptype
==
gsd_DpSlave
)
{
// Create data items for modules
if
(
!
modular_station
)
module_conf_cnt
=
1
;
else
module_conf_cnt
=
max_module
;
module_conf
=
(
gsd_sModuleConf
*
)
calloc
(
module_conf_cnt
,
sizeof
(
gsd_sModuleConf
));
}
if
(
!
extuserprmdataconst
)
extuserprmdataconst
=
(
gsd_sExtUserPrmDataConst
*
)
calloc
(
1
,
sizeof
(
gsd_sExtUserPrmDataConst
));
return
1
;
}
int
pb_gsd
::
prm_items_to_data
(
gsd_sPrmDataItem
*
item
,
int
item_size
,
unsigned
char
*
data
,
int
data_size
)
{
gsd_sExtUserPrmData
*
pd
;
for
(
int
i
=
0
;
i
<
item_size
;
i
++
)
{
pd
=
item
[
i
].
ref
->
prm_data
;
// Check value
if
(
pd
->
allowed_cnt
==
0
)
{
if
(
item
[
i
].
value
<
pd
->
Min_Value
)
printf
(
"** Value too low
\"
%s
\"
%d (%d-%d)
\n
"
,
pd
->
Ext_User_Prm_Data_Name
,
item
[
i
].
value
,
pd
->
Min_Value
,
pd
->
Max_Value
);
else
if
(
item
[
i
].
value
>
pd
->
Max_Value
)
printf
(
"** Value too high
\"
%s
\"
%d (%d-%d)
\n
"
,
pd
->
Ext_User_Prm_Data_Name
,
item
[
i
].
value
,
pd
->
Min_Value
,
pd
->
Max_Value
);
}
else
{
int
found
=
0
;
for
(
int
j
=
0
;
j
<
pd
->
allowed_cnt
;
j
++
)
{
if
(
pd
->
Allowed_Values
[
j
]
==
item
[
i
].
value
)
{
found
=
1
;
break
;
}
}
if
(
!
found
)
printf
(
"** Value not allowed
\n
"
);
}
switch
(
pd
->
data_type
)
{
case
gsd_Bit
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
unsigned
char
v
=
1
<<
pd
->
bit_num
;
if
(
item
[
i
].
value
)
data
[
item
[
i
].
ref
->
Reference_Offset
]
|=
v
;
else
data
[
item
[
i
].
ref
->
Reference_Offset
]
&=
~
v
;
break
;
}
case
gsd_BitArea
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
unsigned
char
mask
=
0
;
unsigned
char
v
=
(
unsigned
char
)
item
[
i
].
value
;
for
(
int
j
=
0
;
j
<=
pd
->
bitarea_max
-
pd
->
bitarea_min
;
j
++
)
mask
=
(
mask
<<
1
)
+
1
;
mask
=
mask
<<
pd
->
bitarea_min
;
v
=
v
<<
pd
->
bitarea_min
;
data
[
item
[
i
].
ref
->
Reference_Offset
]
&=
~
mask
;
data
[
item
[
i
].
ref
->
Reference_Offset
]
|=
v
;
break
;
}
case
gsd_Unsigned8
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
unsigned
char
v
=
(
unsigned
char
)
item
[
i
].
value
;
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
break
;
}
case
gsd_Signed8
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
char
v
=
(
char
)
item
[
i
].
value
;
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
break
;
}
case
gsd_Unsigned16
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
-
1
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
unsigned
short
v
=
(
unsigned
short
)
item
[
i
].
value
;
#if (pwr_dHost_byteOrder == pwr_dLittleEndian)
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
#elif (pwr_dHost_byteOrder == pwr_dBigEndian)
unsigned
char
b
[
2
];
memcpy
(
b
,
&
v
,
sizeof
(
b
));
data
[
item
[
i
].
ref
->
Reference_Offset
]
=
b
[
1
];
data
[
item
[
i
].
ref
->
Reference_Offset
+
1
]
=
b
[
0
];
#endif
break
;
}
case
gsd_Signed16
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
-
1
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
short
v
=
(
short
)
item
[
i
].
value
;
#if (pwr_dHost_byteOrder == pwr_dLittleEndian)
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
#elif (pwr_dHost_byteOrder == pwr_dBigEndian)
unsigned
char
b
[
2
];
memcpy
(
b
,
&
v
,
sizeof
(
b
));
data
[
item
[
i
].
ref
->
Reference_Offset
]
=
b
[
1
];
data
[
item
[
i
].
ref
->
Reference_Offset
+
1
]
=
b
[
0
];
#endif
break
;
}
case
gsd_Unsigned32
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
-
3
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
unsigned
int
v
=
(
unsigned
int
)
item
[
i
].
value
;
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
break
;
}
case
gsd_Signed32
:
{
if
(
item
[
i
].
ref
->
Reference_Offset
>=
data_size
-
3
)
{
printf
(
"** Prm Reference_Offset out of range
\n
"
);
return
0
;
}
int
v
=
(
int
)
item
[
i
].
value
;
memcpy
(
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
&
v
,
sizeof
(
v
));
break
;
}
default:
printf
(
"** Unknown data type
\n
"
);;
}
}
printf
(
"To Data: "
);
for
(
int
i
=
0
;
i
<
data_size
;
i
++
)
printf
(
"0x%x,"
,
data
[
i
]);
printf
(
"
\n
"
);
return
1
;
}
int
pb_gsd
::
prm_data_to_items
(
gsd_sPrmDataItem
*
item
,
int
item_size
,
unsigned
char
*
data
,
int
data_size
,
int
set_default
)
{
gsd_sExtUserPrmData
*
pd
;
for
(
int
i
=
0
;
i
<
item_size
;
i
++
)
{
pd
=
item
[
i
].
ref
->
prm_data
;
switch
(
pd
->
data_type
)
{
case
gsd_Bit
:
{
unsigned
char
mask
=
1
<<
pd
->
bit_num
;
item
[
i
].
value
=
(
(
data
[
item
[
i
].
ref
->
Reference_Offset
]
&
mask
)
!=
0
);
break
;
}
case
gsd_BitArea
:
{
unsigned
char
mask
=
0
;
unsigned
char
v
=
(
unsigned
char
)
item
[
i
].
value
;
for
(
int
j
=
0
;
j
<=
pd
->
bitarea_max
-
pd
->
bitarea_min
;
j
++
)
mask
=
(
mask
<<
1
)
+
1
;
mask
=
mask
<<
pd
->
bitarea_min
;
v
=
data
[
item
[
i
].
ref
->
Reference_Offset
]
&
mask
;
v
=
v
>>
pd
->
bitarea_min
;
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Unsigned8
:
{
unsigned
char
v
;
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Signed8
:
{
char
v
;
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Unsigned16
:
{
unsigned
short
v
;
#if (pwr_dHost_byteOrder == pwr_dLittleEndian)
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
#elif (pwr_dHost_byteOrder == pwr_dBigEndian)
unsigned
char
b
[
2
];
b
[
1
]
=
data
[
item
[
i
].
ref
->
Reference_Offset
];
b
[
0
]
=
data
[
item
[
i
].
ref
->
Reference_Offset
+
1
];
memcpy
(
&
v
,
b
,
sizeof
(
v
));
#endif
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Signed16
:
{
short
v
;
#if (pwr_dHost_byteOrder == pwr_dLittleEndian)
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
#elif (pwr_dHost_byteOrder == pwr_dBigEndian)
unsigned
char
b
[
2
];
b
[
1
]
=
data
[
item
[
i
].
ref
->
Reference_Offset
];
b
[
0
]
=
data
[
item
[
i
].
ref
->
Reference_Offset
+
1
];
memcpy
(
&
v
,
b
,
sizeof
(
v
));
#endif
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Unsigned32
:
{
unsigned
int
v
;
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
item
[
i
].
value
=
v
;
break
;
}
case
gsd_Signed32
:
{
int
v
;
memcpy
(
&
v
,
&
data
[
item
[
i
].
ref
->
Reference_Offset
],
sizeof
(
v
));
item
[
i
].
value
=
v
;
break
;
}
default:
printf
(
"** Unknown data type
\n
"
);;
}
// Set default value
switch
(
pd
->
data_type
)
{
case
gsd_BitArea
:
case
gsd_Unsigned8
:
case
gsd_Signed8
:
case
gsd_Unsigned16
:
case
gsd_Signed16
:
case
gsd_Unsigned32
:
case
gsd_Signed32
:
if
(
set_default
)
{
if
(
item
[
i
].
value
<
pd
->
Min_Value
||
item
[
i
].
value
>
pd
->
Max_Value
)
item
[
i
].
value
=
pd
->
Default_Value
;
}
break
;
default:
;
}
}
printf
(
"From Data: "
);
for
(
int
i
=
0
;
i
<
data_size
;
i
++
)
printf
(
"0x%x,"
,
data
[
i
]);
printf
(
"
\n
"
);
return
1
;
}
int
pb_gsd
::
prm_text_val_to_str
(
gsd_sPrmText
*
prmtext
,
int
val
,
char
*
str
)
{
for
(
gsd_sText
*
tp
=
prmtext
->
text_list
;
tp
;
tp
=
tp
->
next
)
{
if
(
tp
->
Prm_Data_Value
==
val
)
{
strcpy
(
str
,
tp
->
Text
);
return
1
;
}
}
strcpy
(
str
,
""
);
return
0
;
}
int
pb_gsd
::
get_svalue
(
char
*
key
,
char
*
value
,
int
size
)
{
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
for
(
keyp
=
keywordlist
,
datap
=
datalist
;
keyp
->
type
!=
gsd_End
;
keyp
++
,
datap
++
)
{
if
(
cdh_NoCaseStrcmp
(
key
,
keyp
->
name
)
==
0
)
{
if
(
!
datap
->
found
)
return
0
;
switch
(
keyp
->
type
)
{
case
gsd_VString8
:
case
gsd_VString32
:
case
gsd_VString256
:
case
gsd_SlaveFamily
:
strncpy
(
value
,
(
char
*
)
datap
->
data
,
size
);
return
1
;
default:
return
0
;
}
}
}
return
0
;
}
int
pb_gsd
::
get_ivalue
(
char
*
key
,
int
*
value
)
{
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
for
(
keyp
=
keywordlist
,
datap
=
datalist
;
keyp
->
type
!=
gsd_End
;
keyp
++
,
datap
++
)
{
if
(
cdh_NoCaseStrcmp
(
key
,
keyp
->
name
)
==
0
)
{
if
(
!
datap
->
found
)
return
0
;
switch
(
keyp
->
type
)
{
case
gsd_ProfibusDP
:
case
gsd_Boolean
:
case
gsd_Unsigned8
:
case
gsd_Unsigned16
:
case
gsd_Unsigned32
:
case
gsd_UserPrmDataLen
:
*
value
=
datap
->
value
;
return
1
;
default:
return
0
;
}
}
}
return
0
;
}
int
pb_gsd
::
print
()
{
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
unsigned
int
val
;
for
(
keyp
=
keywordlist
,
datap
=
datalist
;
keyp
->
type
!=
gsd_End
;
keyp
++
,
datap
++
)
{
if
(
datap
->
found
)
{
switch
(
keyp
->
type
)
{
case
gsd_ProfibusDP
:
case
gsd_Boolean
:
case
gsd_Unsigned8
:
case
gsd_Unsigned16
:
case
gsd_Unsigned32
:
case
gsd_UserPrmDataLen
:
printf
(
"%s %d
\n
"
,
keyp
->
name
,
datap
->
value
);
break
;
case
gsd_VString8
:
case
gsd_VString32
:
case
gsd_VString256
:
case
gsd_SlaveFamily
:
printf
(
"%s %s
\n
"
,
keyp
->
name
,
(
char
*
)
datap
->
data
);
break
;
case
gsd_OString
:
case
gsd_UserPrmData
:
{
int
size
=
256
;
if
(
keyp
->
type
==
gsd_UserPrmData
)
size
=
user_prm_data_len
;
printf
(
"%s "
,
keyp
->
name
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
val
=
*
((
unsigned
char
*
)
datap
->
data
+
i
);
printf
(
"0x%x,"
,
val
);
}
printf
(
"
\n
"
);
break
;
}
case
gsd_Module
:
{
break
;
}
case
gsd_BitVString32
:
case
gsd_BitVString256
:
case
gsd_DiagArea
:
case
gsd_DiagType
:
case
gsd_EndModule
:
case
gsd_DataAreaBegin
:
case
gsd_DataAreaEnd
:
case
gsd_Value
:
case
gsd_MaxUserPrmDataLen
:
break
;
default:
printf
(
"Unknown type %s
\n
"
,
keyp
->
name
);
}
}
}
// Print modules
for
(
gsd_sModule
*
mp
=
modulelist
;
mp
;
mp
=
mp
->
next
)
{
printf
(
"Module %s "
,
mp
->
Mod_Name
);
for
(
int
i
=
0
;
i
<
mp
->
config_size
;
i
++
)
{
val
=
*
(
mp
->
Config
+
i
);
printf
(
"0x%x,"
,
val
);
}
printf
(
"
\n
"
);
printf
(
" Module_Reference %d
\n
"
,
mp
->
Module_Reference
);
// Print ExtUserPrmDataRef
for
(
gsd_sExtUserPrmDataRef
*
ep
=
mp
->
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
printf
(
" ExtUserPrmDataRef %d %d
\n
"
,
ep
->
Reference_Offset
,
ep
->
Reference_Number
);
}
printf
(
" Ext_Module_Prm_Data_Len %d
\n
"
,
mp
->
Ext_Module_Prm_Data_Len
);
if
(
mp
->
extuserprmdataconst
)
{
printf
(
" ExtUserPrmDataConst %d "
,
mp
->
extuserprmdataconst
->
Const_Offset
);
for
(
int
i
=
0
;
i
<
mp
->
extuserprmdataconst
->
len
;
i
++
)
printf
(
"%d,"
,
mp
->
extuserprmdataconst
->
Const_Prm_Data
[
i
]);
printf
(
"
\n
"
);
}
// Print areas
for
(
gsd_sArea
*
ap
=
mp
->
arealist
;
ap
;
ap
=
ap
->
next
)
{
printf
(
"Area %s
\n
"
,
ap
->
Area_Name
);
printf
(
" Related_CFG_Identifier %d
\n
"
,
ap
->
Related_CFG_Identifier
);
printf
(
" IO_Direction %d
\n
"
,
ap
->
IO_Direction
);
printf
(
" Length %d
\n
"
,
ap
->
Length
);
printf
(
" Publisher_allowed %d
\n
"
,
ap
->
Publisher_allowed
);
printf
(
" DP_Master_allowed %d
\n
"
,
ap
->
DP_Master_allowed
);
for
(
int
i
=
0
;
i
<
ap
->
data_type_cnt
;
i
++
)
printf
(
" Data_Type %d
\n
"
,
ap
->
Data_Type
[
i
]);
}
}
// Print PrmText
for
(
gsd_sPrmText
*
tp
=
prm_textlist
;
tp
;
tp
=
tp
->
next
)
{
printf
(
"PrmText %d
\n
"
,
tp
->
Reference_Number
);
// Print Text
for
(
gsd_sText
*
xp
=
tp
->
text_list
;
xp
;
xp
=
xp
->
next
)
{
printf
(
" Text %d
\"
%s
\"\n
"
,
xp
->
Prm_Data_Value
,
xp
->
Text
);
}
}
// Print ExtUserPrmData
for
(
gsd_sExtUserPrmData
*
ep
=
extuserprmdatalist
;
ep
;
ep
=
ep
->
next
)
{
printf
(
"ExtPrmUserData %d
\"
%s
\"\n
"
,
ep
->
Reference_Number
,
ep
->
Ext_User_Prm_Data_Name
);
printf
(
" Data_Type_Name %s"
,
ep
->
Data_Type_Name
);
if
(
cdh_NoCaseStrcmp
(
ep
->
Data_Type_Name
,
"Bit"
)
==
0
)
printf
(
" %d
\n
"
,
ep
->
bit_num
);
else
if
(
cdh_NoCaseStrcmp
(
ep
->
Data_Type_Name
,
"BitArea"
)
==
0
)
printf
(
" %d-%d
\n
"
,
ep
->
bitarea_min
,
ep
->
bitarea_max
);
else
printf
(
"
\n
"
);
printf
(
" Min_Value %d
\n
"
,
ep
->
Min_Value
);
printf
(
" Max_Value %d
\n
"
,
ep
->
Max_Value
);
if
(
ep
->
allowed_cnt
)
{
printf
(
" Allowed_Values "
);
for
(
int
i
=
0
;
i
<
ep
->
allowed_cnt
;
i
++
)
printf
(
"%d,"
,
ep
->
Allowed_Values
[
i
]);
printf
(
"
\n
"
);
}
printf
(
" Prm_Text_Ref %d
\n
"
,
ep
->
Prm_Text_Ref
);
printf
(
" Changeable %d
\n
"
,
ep
->
Changeable
);
printf
(
" Visible %d
\n
"
,
ep
->
Visible
);
}
// Print ExtUserPrmRef
for
(
gsd_sExtUserPrmDataRef
*
ep
=
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
printf
(
"ExtUserPrmDataRef %d %d
\n
"
,
ep
->
Reference_Offset
,
ep
->
Reference_Number
);
}
if
(
extuserprmdataconst
)
{
printf
(
"ExtUserPrmDataConst %d "
,
extuserprmdataconst
->
Const_Offset
);
for
(
int
i
=
0
;
i
<
extuserprmdataconst
->
len
;
i
++
)
printf
(
"%d,"
,
extuserprmdataconst
->
Const_Prm_Data
[
i
]);
printf
(
"
\n
"
);
}
return
1
;
}
int
pb_gsd
::
str_to_ostring
(
unsigned
char
**
data
,
char
*
str
,
int
size
,
int
*
rsize
)
{
char
valstr
[
40
];
int
valcnt
;
unsigned
int
val
;
char
*
s
,
*
t
;
int
sts
;
*
data
=
(
unsigned
char
*
)
malloc
(
size
);
t
=
str
;
valcnt
=
0
;
for
(
s
=
str
;;
s
++
)
{
if
(
valcnt
>
size
)
{
printf
(
"** Size error"
);
break
;
}
if
(
*
s
==
','
||
*
s
==
0
)
{
strncpy
(
valstr
,
t
,
s
-
t
);
valstr
[
s
-
t
]
=
0
;
dcli_remove_blank
(
valstr
,
valstr
);
if
(
valstr
[
0
]
==
'0'
&&
valstr
[
1
]
==
'x'
)
sts
=
sscanf
(
&
valstr
[
2
],
"%x"
,
&
val
);
else
sts
=
sscanf
(
valstr
,
"%d"
,
&
val
);
*
(
*
data
+
valcnt
++
)
=
(
unsigned
char
)
val
;
if
(
sts
!=
1
)
printf
(
"Syntax error, line %d
\n
"
,
line_cnt
);
t
=
s
+
1
;
}
if
(
*
s
==
0
)
break
;
}
if
(
rsize
)
*
rsize
=
valcnt
;
return
1
;
}
int
pb_gsd
::
read_line
(
char
*
line
,
int
lsize
,
FILE
*
fp
)
{
int
sts
;
int
in_string
;
char
*
s
;
while
(
1
)
{
sts
=
dcli_read_line
(
line
,
lsize
,
fp
);
if
(
!
sts
)
return
sts
;
else
{
line_cnt
++
;
// Remove comments
in_string
=
0
;
for
(
s
=
line
;
*
s
;
s
++
)
{
if
(
*
s
==
'"'
)
in_string
=
!
in_string
;
if
(
*
s
==
';'
&&
!
in_string
)
{
*
s
=
0
;
break
;
}
}
dcli_remove_blank
(
line
,
line
);
if
(
line
[
strlen
(
line
)
-
1
]
==
'\r'
)
line
[
strlen
(
line
)
-
1
]
=
0
;
if
(
strcmp
(
line
,
""
)
==
0
||
(
line
[
0
]
==
'\r'
&&
line
[
1
]
==
'\0'
))
continue
;
while
(
1
)
{
if
(
line
[
strlen
(
line
)
-
1
]
==
'\\'
)
{
// Add next line
sts
=
dcli_read_line
(
&
line
[
strlen
(
line
)
-
1
],
lsize
-
strlen
(
line
),
fp
);
if
(
!
sts
)
break
;
line_cnt
++
;
// Remove comments
in_string
=
0
;
for
(
s
=
line
;
*
s
;
s
++
)
{
if
(
*
s
==
'"'
)
in_string
=
!
in_string
;
if
(
*
s
==
';'
&&
!
in_string
)
*
s
=
0
;
}
dcli_remove_blank
(
line
,
line
);
}
else
if
(
line
[
strlen
(
line
)
-
2
]
==
'\\'
)
{
// Add next line
sts
=
dcli_read_line
(
&
line
[
strlen
(
line
)
-
2
],
lsize
-
strlen
(
line
),
fp
);
if
(
!
sts
)
break
;
line_cnt
++
;
dcli_remove_blank
(
line
,
line
);
}
else
break
;
}
}
break
;
}
return
sts
;
}
int
pb_gsd
::
add_module_conf
(
pwr_tCid
cid
,
pwr_tOid
oid
,
char
*
name
,
char
*
module_name
)
{
int
idx
;
gsd_sModule
*
mp
;
int
i
;
int
found
;
// Find first free module conf
for
(
idx
=
0
;
idx
<
module_conf_cnt
;
idx
++
)
{
if
(
module_conf
[
idx
].
module
==
0
)
break
;
}
if
(
module_conf
[
idx
].
module
!=
0
)
// All is occupied
return
PB__MODOCC
;
module_conf
[
idx
].
oid
=
oid
;
module_conf
[
idx
].
cid
=
cid
;
strcpy
(
module_conf
[
idx
].
name
,
name
);
i
=
0
;
found
=
0
;
for
(
mp
=
modulelist
;
mp
;
mp
=
mp
->
next
)
{
if
(
strcmp
(
module_name
,
mp
->
Mod_Name
)
==
0
)
{
found
=
1
;
break
;
}
i
++
;
}
if
(
!
found
)
return
0
;
module_conf
[
idx
].
idx
=
i
+
1
;
configure_module
(
&
module_conf
[
idx
]);
return
1
;
}
int
pb_gsd
::
move_module_conf
(
gsd_sModuleConf
*
src
,
gsd_sModuleConf
*
dest
)
{
int
src_idx
=
((
char
*
)
src
-
(
char
*
)
module_conf
)
/
sizeof
(
gsd_sModuleConf
);
int
dest_idx
;
if
(
!
dest
)
dest_idx
=
0
;
else
dest_idx
=
((
char
*
)
dest
-
(
char
*
)
module_conf
)
/
sizeof
(
gsd_sModuleConf
);
if
(
src_idx
==
dest_idx
)
return
1
;
if
(
src_idx
<
0
||
src_idx
>=
module_conf_cnt
||
dest_idx
<
0
||
dest_idx
>=
module_conf_cnt
)
return
0
;
gsd_sModuleConf
tmp
=
module_conf
[
src_idx
];
if
(
src_idx
>
dest_idx
)
{
for
(
int
i
=
src_idx
-
1
;
i
>=
dest_idx
;
i
--
)
{
module_conf
[
i
+
1
]
=
module_conf
[
i
];
}
module_conf
[
dest_idx
]
=
tmp
;
}
else
{
for
(
int
i
=
src_idx
;
i
<
dest_idx
;
i
++
)
{
module_conf
[
i
]
=
module_conf
[
i
+
1
];
}
module_conf
[
dest_idx
]
=
tmp
;
}
return
1
;
}
int
pb_gsd
::
copy_module_conf
(
gsd_sModuleConf
*
m
)
{
if
(
copy_buff
&&
copy_buff
->
prm_dataitems
)
{
free
(
copy_buff
->
prm_dataitems
);
}
else
if
(
!
copy_buff
)
copy_buff
=
(
gsd_sModuleConf
*
)
calloc
(
1
,
sizeof
(
gsd_sModuleConf
));
// Copy m to copy_buff
*
copy_buff
=
*
m
;
copy_buff
->
oid
=
pwr_cNOid
;
if
(
m
->
prm_dataitems
)
{
copy_buff
->
prm_dataitems
=
(
gsd_sPrmDataItem
*
)
calloc
(
m
->
prm_dataitems_cnt
,
sizeof
(
gsd_sPrmDataItem
));
memcpy
(
copy_buff
->
prm_dataitems
,
m
->
prm_dataitems
,
m
->
prm_dataitems_cnt
*
sizeof
(
gsd_sPrmDataItem
));
}
return
1
;
}
int
pb_gsd
::
cut_module_conf
(
gsd_sModuleConf
*
m
)
{
int
idx
=
((
char
*
)
m
-
(
char
*
)
module_conf
)
/
sizeof
(
gsd_sModuleConf
);
if
(
copy_buff
&&
copy_buff
->
prm_dataitems
)
{
free
(
copy_buff
->
prm_dataitems
);
}
else
if
(
!
copy_buff
)
copy_buff
=
(
gsd_sModuleConf
*
)
calloc
(
1
,
sizeof
(
gsd_sModuleConf
));
// Copy m to copy_buff
*
copy_buff
=
*
m
;
copy_buff
->
oid
=
pwr_cNOid
;
// Shift modules of higher index
for
(
int
i
=
idx
;
i
<
module_conf_cnt
-
1
;
i
++
)
{
module_conf
[
i
]
=
module_conf
[
i
+
1
];
}
memset
(
&
module_conf
[
module_conf_cnt
-
1
],
0
,
sizeof
(
gsd_sModuleConf
));
return
1
;
}
int
pb_gsd
::
paste_module_conf
(
gsd_sModuleConf
*
m
)
{
int
idx
=
((
char
*
)
m
-
(
char
*
)
module_conf
)
/
sizeof
(
gsd_sModuleConf
);
if
(
!
copy_buff
)
// Nothing copied
return
0
;
// Last module will be lost
if
(
module_conf
[
module_conf_cnt
-
1
].
prm_dataitems
)
free
(
(
char
*
)
module_conf
[
module_conf_cnt
-
1
].
prm_dataitems
);
// Shift to make space for new module
for
(
int
i
=
module_conf_cnt
-
1
;
i
>=
idx
+
1
;
i
--
)
module_conf
[
i
]
=
module_conf
[
i
-
1
];
// Insert module
module_conf
[
idx
]
=
*
copy_buff
;
if
(
copy_buff
->
prm_dataitems
)
{
module_conf
[
idx
].
prm_dataitems
=
(
gsd_sPrmDataItem
*
)
calloc
(
module_conf
[
idx
].
prm_dataitems_cnt
,
sizeof
(
gsd_sPrmDataItem
));
memcpy
(
module_conf
[
idx
].
prm_dataitems
,
copy_buff
->
prm_dataitems
,
module_conf
[
idx
].
prm_dataitems_cnt
*
sizeof
(
gsd_sPrmDataItem
));
}
return
1
;
}
int
pb_gsd
::
configure_module
(
gsd_sModuleConf
*
m
)
{
if
(
m
->
idx
==
0
)
{
// Module removed
if
(
m
->
module
)
m
->
module
=
0
;
if
(
m
->
prm_dataitems
)
{
free
(
m
->
prm_dataitems
);
m
->
prm_dataitems
=
0
;
m
->
prm_dataitems_cnt
=
0
;
}
}
else
{
int
new_module
=
1
;
gsd_sModule
*
mp
;
int
i
=
1
;
for
(
mp
=
modulelist
;
mp
;
mp
=
mp
->
next
)
{
if
(
i
==
m
->
idx
)
break
;
i
++
;
}
if
(
!
mp
)
{
printf
(
"** Module index out of range
\n
"
);
return
PB__MODULEIDX
;
}
if
(
m
->
module
)
{
// Check if new module index
if
(
mp
!=
m
->
module
)
{
// New module configured, remove previous module
if
(
m
->
module
)
m
->
module
=
0
;
if
(
m
->
prm_dataitems
)
{
free
(
m
->
prm_dataitems
);
m
->
prm_dataitems
=
0
;
m
->
prm_dataitems_cnt
=
0
;
}
}
else
new_module
=
0
;
}
if
(
new_module
)
{
m
->
module
=
mp
;
// Create data items for module ExtPrmData
m
->
prm_dataitems_cnt
=
0
;
for
(
gsd_sExtUserPrmDataRef
*
ep
=
mp
->
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
m
->
prm_dataitems_cnt
++
;
m
->
prm_dataitems
=
(
gsd_sPrmDataItem
*
)
calloc
(
m
->
prm_dataitems_cnt
,
sizeof
(
gsd_sPrmDataItem
));
int
i
=
0
;
for
(
gsd_sExtUserPrmDataRef
*
ep
=
mp
->
extuserprmdatareflist
;
ep
;
ep
=
ep
->
next
)
{
m
->
prm_dataitems
[
i
].
ref
=
ep
;
i
++
;
}
if
(
m
->
module
->
extuserprmdataconst
)
{
prm_data_to_items
(
m
->
prm_dataitems
,
m
->
prm_dataitems_cnt
,
m
->
module
->
extuserprmdataconst
->
Const_Prm_Data
,
m
->
module
->
extuserprmdataconst
->
len
,
1
);
// Test Remove this !!!
prm_items_to_data
(
m
->
prm_dataitems
,
m
->
prm_dataitems_cnt
,
m
->
module
->
extuserprmdataconst
->
Const_Prm_Data
,
m
->
module
->
extuserprmdataconst
->
len
);
}
}
}
if
(
m
->
module
)
{
if
(
strcmp
(
m
->
name
,
""
)
==
0
)
{
int
idx
=
((
char
*
)
m
-
(
char
*
)
module_conf
)
/
sizeof
(
gsd_sModuleConf
);
sprintf
(
m
->
name
,
"M%d"
,
idx
+
1
);
}
}
else
strcpy
(
m
->
name
,
""
);
return
1
;
}
void
pb_gsd
::
pack_config
(
char
*
config
,
int
*
len
)
{
int
i
;
short
conf_idx
;
conf_idx
=
2
;
for
(
i
=
0
;
i
<
module_conf_cnt
;
i
++
)
{
if
(
!
module_conf
[
i
].
module
||
!
module_conf
[
i
].
module
->
Config
)
continue
;
memcpy
(
&
config
[
conf_idx
],
module_conf
[
i
].
module
->
Config
,
module_conf
[
i
].
module
->
config_size
);
conf_idx
+=
module_conf
[
i
].
module
->
config_size
;
}
// Length in first two bytes
memcpy
(
config
,
&
conf_idx
,
sizeof
(
conf_idx
));
*
len
=
conf_idx
;
}
void
pb_gsd
::
pack_ext_user_prm_data
(
char
*
data
,
int
*
len
)
{
int
i
;
short
data_idx
;
prm_items_to_data
(
prm_dataitems
,
prm_dataitems_cnt
,
extuserprmdataconst
->
Const_Prm_Data
,
extuserprmdataconst
->
len
);
data_idx
=
0
;
memcpy
(
&
data
[
data_idx
],
extuserprmdataconst
->
Const_Prm_Data
,
extuserprmdataconst
->
len
);
data_idx
+=
extuserprmdataconst
->
len
;
for
(
i
=
0
;
i
<
module_conf_cnt
;
i
++
)
{
if
(
!
module_conf
[
i
].
module
||
!
module_conf
[
i
].
module
->
extuserprmdataconst
)
continue
;
prm_items_to_data
(
module_conf
[
i
].
prm_dataitems
,
module_conf
[
i
].
prm_dataitems_cnt
,
module_conf
[
i
].
module
->
extuserprmdataconst
->
Const_Prm_Data
,
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
);
memcpy
(
&
data
[
data_idx
],
module_conf
[
i
].
module
->
extuserprmdataconst
->
Const_Prm_Data
,
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
);
data_idx
+=
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
;
}
*
len
=
data_idx
;
}
int
pb_gsd
::
unpack_ext_user_prm_data
(
char
*
data
,
int
len
)
{
int
i
;
short
data_idx
;
data_idx
=
0
;
memcpy
(
extuserprmdataconst
->
Const_Prm_Data
,
&
data
[
data_idx
],
extuserprmdataconst
->
len
);
data_idx
+=
extuserprmdataconst
->
len
;
prm_data_to_items
(
prm_dataitems
,
prm_dataitems_cnt
,
extuserprmdataconst
->
Const_Prm_Data
,
extuserprmdataconst
->
len
);
for
(
i
=
0
;
i
<
module_conf_cnt
;
i
++
)
{
if
(
!
module_conf
[
i
].
module
||
!
module_conf
[
i
].
module
->
extuserprmdataconst
)
continue
;
memcpy
(
module_conf
[
i
].
module
->
extuserprmdataconst
->
Const_Prm_Data
,
&
data
[
data_idx
],
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
);
data_idx
+=
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
;
prm_data_to_items
(
module_conf
[
i
].
prm_dataitems
,
module_conf
[
i
].
prm_dataitems_cnt
,
module_conf
[
i
].
module
->
extuserprmdataconst
->
Const_Prm_Data
,
module_conf
[
i
].
module
->
extuserprmdataconst
->
len
);
}
if
(
len
!=
data_idx
)
return
PB__USERPRMDATALEN
;
return
1
;
}
// Remove spaces inside () and after ','
void
pb_gsd
::
compress
(
char
*
line
)
{
char
*
tmp
=
(
char
*
)
malloc
(
strlen
(
line
)
+
1
);
char
*
s
,
*
t
;
int
inpar
=
0
;
int
instr
=
0
;
for
(
s
=
line
,
t
=
tmp
;
*
s
;
s
++
)
{
if
(
*
s
==
'('
&&
!
instr
)
inpar
=
1
;
else
if
(
*
s
==
')'
&&
!
instr
)
inpar
=
0
;
else
if
(
*
s
==
'"'
)
instr
=
!
instr
;
if
(
inpar
&&
*
s
==
' '
)
continue
;
if
(
!
instr
&&
*
s
==
','
)
{
while
(
*
t
==
' '
)
t
--
;
*
t
=
*
s
;
t
++
;
s
++
;
while
(
*
s
==
' '
)
s
++
;
s
--
;
continue
;
}
*
t
=
*
s
;
t
++
;
}
*
t
=
0
;
strcpy
(
line
,
tmp
);
free
(
tmp
);
}
int
pb_gsd
::
syntax_check
(
int
*
idx
)
{
for
(
int
i
=
0
;
i
<
module_conf_cnt
;
i
++
)
{
if
(
module_conf
[
i
].
module
)
{
// Check that name is not null
if
(
strcmp
(
module_conf
[
i
].
name
,
""
)
==
0
)
{
*
idx
=
i
;
return
PB__NOMODULENAME
;
}
// Check that name is unic
for
(
int
j
=
0
;
j
<
module_conf_cnt
;
j
++
)
{
if
(
i
!=
j
&&
cdh_NoCaseStrcmp
(
module_conf
[
i
].
name
,
module_conf
[
j
].
name
)
==
0
)
{
*
idx
=
i
;
return
PB__DUPLMODULENAME
;
}
}
// Check that class is not null
if
(
module_conf
[
i
].
cid
==
pwr_cNCid
)
{
*
idx
=
i
;
return
PB__NOMODULECLASS
;
}
}
}
return
PB__SUCCESS
;
}
#if 0
int main()
{
pb_gsd gsd;
gsd.read("test.gsd");
gsd.print();
}
#endif
profibus/lib/pb/src/pb_gsd.h
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd.h,v 1.1 2006-03-22 14:38:11 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 pb_gsd_h
#define pb_gsd_h
#ifndef pwr_h
# include "pwr.h"
#endif
typedef
enum
{
gsd_DpSlave
,
gsd_DpMaster
}
gsd_eDpType
;
typedef
enum
{
gsd_ProfibusDP
,
gsd_Boolean
,
gsd_Bit
,
gsd_BitArea
,
gsd_VString8
,
gsd_VString32
,
gsd_VString256
,
gsd_OString
,
gsd_Signed8
,
gsd_Signed16
,
gsd_Signed32
,
gsd_Unsigned8
,
gsd_Unsigned16
,
gsd_Unsigned32
,
gsd_BitVString32
,
gsd_BitVString256
,
gsd_DiagArea
,
gsd_DiagAreaEnd
,
gsd_Value
,
gsd_DiagType
,
gsd_Module
,
gsd_EndModule
,
gsd_DataAreaBegin
,
gsd_DataAreaEnd
,
gsd_SlaveFamily
,
gsd_UserPrmDataLen
,
gsd_UserPrmData
,
gsd_ExtModulePrmDataLen
,
gsd_PrmText
,
gsd_EndPrmText
,
gsd_ExtUserPrmData
,
gsd_EndExtUserPrmData
,
gsd_MaxUserPrmDataLen
,
gsd_ExtUserPrmDataRef
,
gsd_ExtUserPrmDataConst
,
gsd_Text
,
gsd_End
}
gsd_eType
;
typedef
struct
{
char
name
[
50
];
char
group
[
50
];
int
option
;
int
type
;
unsigned
int
value_default
;
}
gsd_sKeyword
;
typedef
struct
{
char
name
[
32
];
pwr_tCid
cid
;
}
gsd_sModuleClass
;
typedef
struct
{
unsigned
int
value
;
void
*
data
;
int
found
;
}
gsd_sData
;
typedef
struct
sArea
{
char
Area_Name
[
33
];
int
Related_CFG_Identifier
;
int
IO_Direction
;
int
Length
;
int
Consistency
;
int
Publisher_allowed
;
int
DP_Master_allowed
;
int
Data_Type
[
100
];
int
data_type_cnt
;
struct
sArea
*
next
;
}
gsd_sArea
;
typedef
struct
{
int
Const_Offset
;
unsigned
char
Const_Prm_Data
[
237
];
int
len
;
}
gsd_sExtUserPrmDataConst
;
typedef
struct
sText
{
int
Prm_Data_Value
;
char
Text
[
33
];
struct
sText
*
next
;
}
gsd_sText
;
typedef
struct
sPrmText
{
int
Reference_Number
;
gsd_sText
*
text_list
;
struct
sPrmText
*
next
;
}
gsd_sPrmText
;
typedef
struct
sExtUserPrmData
{
int
Reference_Number
;
char
Ext_User_Prm_Data_Name
[
33
];
char
Data_Type_Name
[
33
];
int
Default_Value
;
int
Min_Value
;
int
Max_Value
;
int
Allowed_Values
[
16
];
int
allowed_cnt
;
int
Prm_Text_Ref
;
int
Changeable
;
int
Visible
;
int
data_type
;
int
bitarea_min
;
int
bitarea_max
;
int
bit_num
;
gsd_sPrmText
*
prmtext
;
struct
sExtUserPrmData
*
next
;
}
gsd_sExtUserPrmData
;
typedef
struct
sExtUserPrmDataRef
{
int
Reference_Offset
;
int
Reference_Number
;
gsd_sExtUserPrmData
*
prm_data
;
sExtUserPrmDataRef
*
next
;
}
gsd_sExtUserPrmDataRef
;
typedef
struct
{
gsd_sExtUserPrmDataRef
*
ref
;
int
value
;
}
gsd_sPrmDataItem
;
typedef
struct
sModule
{
char
Mod_Name
[
33
];
unsigned
char
*
Config
;
int
config_size
;
int
Module_Reference
;
int
Ext_Module_Prm_Data_Len
;
int
X_Ext_Module_Prm_Data_Len
;
int
F_Ext_Module_Prm_Data_Len
;
gsd_sExtUserPrmDataConst
*
extuserprmdataconst
;
gsd_sArea
*
arealist
;
gsd_sExtUserPrmDataRef
*
extuserprmdatareflist
;
struct
sModule
*
next
;
}
gsd_sModule
;
typedef
struct
{
int
idx
;
gsd_sModule
*
module
;
char
name
[
80
];
pwr_tOid
oid
;
pwr_tCid
cid
;
gsd_sPrmDataItem
*
prm_dataitems
;
int
prm_dataitems_cnt
;
}
gsd_sModuleConf
;
class
pb_gsd
{
public:
pb_gsd
();
~
pb_gsd
();
int
dptype
;
int
modular_station
;
int
max_module
;
int
user_prm_data_len
;
int
max_user_prm_data_len
;
int
line_cnt
;
int
status
;
gsd_sData
*
datalist
;
gsd_sModule
*
modulelist
;
gsd_sPrmText
*
prm_textlist
;
gsd_sExtUserPrmData
*
extuserprmdatalist
;
gsd_sExtUserPrmDataRef
*
extuserprmdatareflist
;
gsd_sModule
*
current_module
;
gsd_sArea
*
current_area
;
gsd_sPrmText
*
current_prm_text
;
gsd_sExtUserPrmData
*
current_extuserprmdata
;
gsd_sExtUserPrmDataConst
*
extuserprmdataconst
;
gsd_sPrmDataItem
*
prm_dataitems
;
int
prm_dataitems_cnt
;
gsd_sModuleConf
*
module_conf
;
int
module_conf_cnt
;
gsd_sModuleClass
*
module_classlist
;
gsd_sModuleConf
*
copy_buff
;
int
modified
;
static
gsd_sKeyword
keywordlist
[];
int
read
(
char
*
filename
);
int
read_line
(
char
*
line
,
int
lsize
,
FILE
*
fp
);
int
str_to_ostring
(
unsigned
char
**
data
,
char
*
str
,
int
size
,
int
*
rsize
);
int
prm_text_val_to_str
(
gsd_sPrmText
*
prmtext
,
int
val
,
char
*
str
);
int
print
();
int
build
();
int
configure_module
(
gsd_sModuleConf
*
mclist
);
int
prm_items_to_data
(
gsd_sPrmDataItem
*
item
,
int
item_size
,
unsigned
char
*
data
,
int
data_size
);
int
prm_data_to_items
(
gsd_sPrmDataItem
*
item
,
int
item_size
,
unsigned
char
*
data
,
int
data_size
,
int
set_default
=
0
);
void
set_classes
(
gsd_sModuleClass
*
mclist
)
{
module_classlist
=
mclist
;}
int
get_svalue
(
char
*
key
,
char
*
value
,
int
size
);
int
get_ivalue
(
char
*
key
,
int
*
value
);
int
add_module_conf
(
pwr_tCid
cid
,
pwr_tOid
oid
,
char
*
name
,
char
*
module_name
);
int
move_module_conf
(
gsd_sModuleConf
*
src
,
gsd_sModuleConf
*
dest
);
int
copy_module_conf
(
gsd_sModuleConf
*
m
);
int
cut_module_conf
(
gsd_sModuleConf
*
m
);
int
paste_module_conf
(
gsd_sModuleConf
*
m
);
void
pack_config
(
char
*
config
,
int
*
len
);
int
unpack_ext_user_prm_data
(
char
*
data
,
int
len
);
void
pack_ext_user_prm_data
(
char
*
data
,
int
*
len
);
void
compress
(
char
*
line
);
int
syntax_check
(
int
*
idx
);
void
set_modified
(
int
mod
)
{
modified
=
mod
;}
int
is_modified
()
{
return
modified
;}
};
#endif
profibus/lib/pb/src/pb_gsd_attr.cpp
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd_attr.cpp,v 1.1 2006-03-22 14:38:11 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.
**/
/* pb_gsd_attr.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
extern
"C"
{
#include "co_cdh.h"
#include "co_time.h"
#include "co_mrm_util.h"
#include "co_dcli.h"
#include "co_wow.h"
#include "flow_x.h"
}
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget.h"
#include "flow_msg.h"
#include "rt_pb_msg.h"
#include "pb_gsd_attr.h"
#include "pb_gsd_attrnav.h"
// Static memeber variables
char
GsdAttr
::
value_recall
[
30
][
160
];
static
void
gsdattr_valchanged_cmd_input
(
Widget
w
,
XEvent
*
event
);
static
void
gsdattr_cmd_close_apply_cb
(
void
*
ctx
,
void
*
data
);
static
void
gsdattr_cmd_close_no_cb
(
void
*
ctx
,
void
*
data
);
static
void
gsdattr_message
(
void
*
attr
,
char
severity
,
char
*
message
)
{
((
GsdAttr
*
)
attr
)
->
message
(
severity
,
message
);
}
void
GsdAttr
::
message
(
char
severity
,
char
*
message
)
{
Arg
args
[
2
];
XmString
cstr
;
cstr
=
XmStringCreateLtoR
(
message
,
"ISO8859-1"
);
XtSetArg
(
args
[
0
],
XmNlabelString
,
cstr
);
XtSetValues
(
msg_label
,
args
,
1
);
XmStringFree
(
cstr
);
}
void
GsdAttr
::
set_prompt
(
char
*
prompt
)
{
Arg
args
[
3
];
XmString
cstr
;
cstr
=
XmStringCreateLtoR
(
prompt
,
"ISO8859-1"
);
XtSetArg
(
args
[
0
],
XmNlabelString
,
cstr
);
XtSetArg
(
args
[
1
],
XmNwidth
,
50
);
XtSetArg
(
args
[
2
],
XmNheight
,
30
);
XtSetValues
(
cmd_prompt
,
args
,
3
);
XmStringFree
(
cstr
);
}
void
GsdAttr
::
change_value
()
{
int
sts
;
Widget
text_w
;
char
*
value
;
if
(
input_open
)
{
XtUnmanageChild
(
cmd_input
);
set_prompt
(
""
);
input_open
=
0
;
return
;
}
if
(
!
edit_mode
)
{
message
(
'E'
,
"Not in edit mode"
);
return
;
}
sts
=
((
GsdAttrNav
*
)
attrnav
)
->
check_attr_value
(
&
value
);
if
(
EVEN
(
sts
))
{
if
(
sts
==
PB__NOATTRSEL
)
message
(
'E'
,
"No attribute is selected"
);
else
message
(
'E'
,
"Attribute can't be modified"
);
return
;
}
text_w
=
cmd_input
;
XtManageChild
(
text_w
);
message
(
' '
,
""
);
flow_SetInputFocus
(
text_w
);
if
(
value
)
{
XmTextSetString
(
text_w
,
value
);
XmTextSetInsertionPosition
(
text_w
,
strlen
(
value
));
XmTextSetSelection
(
text_w
,
0
,
strlen
(
value
),
CurrentTime
);
}
else
{
XmTextSetString
(
cmd_input
,
""
);
}
set_prompt
(
"value >"
);
input_open
=
1
;
}
static
void
gsdattr_change_value_cb
(
void
*
attr_ctx
)
{
GsdAttr
*
attr
=
(
GsdAttr
*
)
attr_ctx
;
attr
->
change_value
();
}
//
// Callbackfunctions from menu entries
//
static
void
gsdattr_activate_change_value
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
change_value
();
}
static
void
gsdattr_activate_exit
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
if
(
attr
->
close_cb
)
{
if
(
attr
->
gsd
->
is_modified
())
{
wow_DisplayQuestion
(
(
void
*
)
attr
,
attr
->
toplevel
,
"Apply"
,
"Do you want to apply changes"
,
gsdattr_cmd_close_apply_cb
,
gsdattr_cmd_close_no_cb
,
0
);
}
else
(
attr
->
close_cb
)(
attr
->
parent_ctx
);
}
else
delete
attr
;
}
static
void
gsdattr_activate_help
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
// Not yet implemented
}
static
void
gsdattr_activate_copy
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
ItemPbModule
*
item
;
int
sts
;
sts
=
attr
->
attrnav
->
get_select
(
(
ItemPb
**
)
&
item
);
if
(
EVEN
(
sts
))
{
attr
->
message
(
'E'
,
"Select a module"
);
return
;
}
if
(
item
->
type
!=
attrnav_eItemType_PbModule
)
{
attr
->
message
(
'E'
,
"Only modules can be copied"
);
return
;
}
attr
->
gsd
->
copy_module_conf
(
item
->
mconf
);
attr
->
message
(
'I'
,
"Module copied"
);
}
static
void
gsdattr_activate_cut
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
ItemPbModule
*
item
;
int
sts
;
sts
=
attr
->
attrnav
->
get_select
(
(
ItemPb
**
)
&
item
);
if
(
EVEN
(
sts
))
{
attr
->
message
(
'E'
,
"Select a module"
);
return
;
}
if
(
item
->
type
!=
attrnav_eItemType_PbModule
)
{
attr
->
message
(
'E'
,
"Only modules can be copied"
);
return
;
}
attr
->
gsd
->
cut_module_conf
(
item
->
mconf
);
}
static
void
gsdattr_activate_paste
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
ItemPbModule
*
item
;
int
sts
;
sts
=
attr
->
attrnav
->
get_select
(
(
ItemPb
**
)
&
item
);
if
(
EVEN
(
sts
))
{
attr
->
message
(
'E'
,
"Select a module"
);
return
;
}
if
(
item
->
type
!=
attrnav_eItemType_PbModule
)
{
attr
->
message
(
'E'
,
"Only modules can be copied"
);
return
;
}
attr
->
gsd
->
paste_module_conf
(
item
->
mconf
);
}
static
void
gsdattr_activate_zoom_in
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
double
zoom_factor
;
attr
->
attrnav
->
get_zoom
(
&
zoom_factor
);
if
(
zoom_factor
>
40
)
return
;
attr
->
attrnav
->
zoom
(
1.18
);
}
static
void
gsdattr_activate_zoom_out
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
double
zoom_factor
;
attr
->
attrnav
->
get_zoom
(
&
zoom_factor
);
if
(
zoom_factor
<
15
)
return
;
attr
->
attrnav
->
zoom
(
1.0
/
1.18
);
}
static
void
gsdattr_activate_zoom_reset
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
attrnav
->
unzoom
();
}
static
void
gsdattr_activate_print
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
char
filename
[
80
]
=
"pwrp_tmp:wnav.ps"
;
char
cmd
[
200
];
int
sts
;
dcli_translate_filename
(
filename
,
filename
);
attr
->
attrnav
->
print
(
filename
);
sprintf
(
cmd
,
"wb_gre_print.sh %s"
,
filename
);
sts
=
system
(
cmd
);
}
static
void
gsdattr_activate_cmd_ok
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
int
sts
;
int
idx
;
char
msg
[
80
];
if
(
attr
->
save_cb
)
{
// Check syntax
sts
=
attr
->
gsd
->
syntax_check
(
&
idx
);
if
(
EVEN
(
sts
))
{
switch
(
sts
)
{
case
PB__NOMODULENAME
:
sprintf
(
msg
,
"Syntax error in module %d, No module name"
,
idx
+
1
);
break
;
case
PB__DUPLMODULENAME
:
sprintf
(
msg
,
"Syntax error in module %s, Duplicate module name"
,
attr
->
gsd
->
module_conf
[
idx
].
name
);
break
;
case
PB__NOMODULECLASS
:
sprintf
(
msg
,
"Syntax error in module %s, Module class is missing"
,
attr
->
gsd
->
module_conf
[
idx
].
name
);
break
;
default:
sprintf
(
msg
,
"Syntax error in module %d"
);
}
attr
->
message
(
'E'
,
msg
);
return
;
}
sts
=
(
attr
->
save_cb
)(
attr
->
parent_ctx
);
if
(
EVEN
(
sts
))
attr
->
message
(
'E'
,
"Error saving profibus data"
);
else
attr
->
gsd
->
set_modified
(
0
);
}
}
static
void
gsdattr_cmd_close_apply_cb
(
void
*
ctx
,
void
*
data
)
{
GsdAttr
*
attr
=
(
GsdAttr
*
)
ctx
;
int
sts
;
sts
=
(
attr
->
save_cb
)(
attr
->
parent_ctx
);
if
(
EVEN
(
sts
))
attr
->
message
(
'E'
,
"Error saving profibus data"
);
else
{
attr
->
gsd
->
set_modified
(
0
);
(
attr
->
close_cb
)(
attr
->
parent_ctx
);
}
}
static
void
gsdattr_cmd_close_no_cb
(
void
*
ctx
,
void
*
data
)
{
GsdAttr
*
attr
=
(
GsdAttr
*
)
ctx
;
(
attr
->
close_cb
)(
attr
->
parent_ctx
);
}
static
void
gsdattr_activate_cmd_ca
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
if
(
attr
->
close_cb
)
{
if
(
attr
->
gsd
->
is_modified
())
{
wow_DisplayQuestion
(
(
void
*
)
attr
,
attr
->
toplevel
,
"Apply"
,
"Do you want to apply changes"
,
gsdattr_cmd_close_apply_cb
,
gsdattr_cmd_close_no_cb
,
0
);
}
else
(
attr
->
close_cb
)(
attr
->
parent_ctx
);
}
}
static
void
gsdattr_create_msg_label
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
msg_label
=
w
;
}
static
void
gsdattr_create_cmd_prompt
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
cmd_prompt
=
w
;
}
static
void
gsdattr_create_cmd_ok
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
cmd_ok
=
w
;
}
static
void
gsdattr_create_cmd_ca
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
cmd_cancel
=
w
;
}
static
void
gsdattr_create_cmd_input
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
Arg
args
[
2
];
XtSetArg
(
args
[
0
],
XmNuserData
,
attr
);
XtSetValues
(
w
,
args
,
1
);
mrm_TextInit
(
w
,
(
XtActionProc
)
gsdattr_valchanged_cmd_input
,
mrm_eUtility_GsdAttr
);
attr
->
cmd_input
=
w
;
}
static
void
gsdattr_create_attrnav_form
(
Widget
w
,
GsdAttr
*
attr
,
XmAnyCallbackStruct
*
data
)
{
attr
->
attrnav_form
=
w
;
}
static
void
gsdattr_action_inputfocus
(
Widget
w
,
XmAnyCallbackStruct
*
data
)
{
Arg
args
[
1
];
GsdAttr
*
attr
;
XtSetArg
(
args
[
0
],
XmNuserData
,
&
attr
);
XtGetValues
(
w
,
args
,
1
);
if
(
!
attr
)
return
;
if
(
flow_IsManaged
(
attr
->
cmd_input
))
flow_SetInputFocus
(
attr
->
cmd_input
);
else
if
(
attr
->
attrnav
)
((
GsdAttrNav
*
)
attr
->
attrnav
)
->
set_inputfocus
();
}
static
void
gsdattr_valchanged_cmd_input
(
Widget
w
,
XEvent
*
event
)
{
GsdAttr
*
attr
;
int
sts
;
char
*
text
;
Arg
args
[
2
];
XtSetArg
(
args
[
0
],
XmNuserData
,
&
attr
);
XtGetValues
(
w
,
args
,
1
);
sts
=
mrm_TextInput
(
w
,
event
,
(
char
*
)
attr
->
value_recall
,
sizeof
(
attr
->
value_recall
[
0
]),
sizeof
(
attr
->
value_recall
)
/
sizeof
(
attr
->
value_recall
[
0
]),
&
attr
->
value_current_recall
);
if
(
sts
)
{
text
=
XmTextGetString
(
w
);
if
(
attr
->
input_open
)
{
sts
=
((
GsdAttrNav
*
)
attr
->
attrnav
)
->
set_attr_value
(
text
);
XtUnmanageChild
(
w
);
attr
->
set_prompt
(
""
);
attr
->
input_open
=
0
;
((
GsdAttrNav
*
)
attr
->
attrnav
)
->
set_inputfocus
();
}
}
}
GsdAttr
::~
GsdAttr
()
{
delete
(
GsdAttrNav
*
)
attrnav
;
XtDestroyWidget
(
parent_wid
);
}
GsdAttr
::
GsdAttr
(
Widget
a_parent_wid
,
void
*
a_parent_ctx
,
void
*
a_object
,
pb_gsd
*
a_gsd
,
int
a_edit_mode
)
:
parent_ctx
(
a_parent_ctx
),
gsd
(
a_gsd
),
edit_mode
(
a_edit_mode
),
input_open
(
0
),
object
(
a_object
),
close_cb
(
0
),
save_cb
(
0
),
client_data
(
0
),
recall_idx
(
-
1
),
value_current_recall
(
0
)
{
char
uid_filename
[
120
]
=
{
"pwr_exe:pb_gsd_attr.uid"
};
char
*
uid_filename_p
=
uid_filename
;
Arg
args
[
20
];
pwr_tStatus
sts
;
char
title
[
80
];
int
i
;
MrmHierarchy
s_DRMh
;
MrmType
dclass
;
char
name
[]
=
"Proview/R Navigator"
;
static
char
translations
[]
=
"<FocusIn>: gsdattr_inputfocus()
\n
"
;
static
XtTranslations
compiled_translations
=
NULL
;
static
XtActionsRec
actions
[]
=
{
{
"gsdattr_inputfocus"
,
(
XtActionProc
)
gsdattr_action_inputfocus
}
};
static
MrmRegisterArg
reglist
[]
=
{
{
"gsdattr_ctx"
,
0
},
{
"gsdattr_activate_exit"
,(
caddr_t
)
gsdattr_activate_exit
},
{
"gsdattr_activate_print"
,(
caddr_t
)
gsdattr_activate_print
},
{
"gsdattr_activate_copy"
,(
caddr_t
)
gsdattr_activate_copy
},
{
"gsdattr_activate_cut"
,(
caddr_t
)
gsdattr_activate_cut
},
{
"gsdattr_activate_paste"
,(
caddr_t
)
gsdattr_activate_paste
},
{
"gsdattr_activate_zoom_in"
,(
caddr_t
)
gsdattr_activate_zoom_in
},
{
"gsdattr_activate_zoom_out"
,(
caddr_t
)
gsdattr_activate_zoom_out
},
{
"gsdattr_activate_zoom_reset"
,(
caddr_t
)
gsdattr_activate_zoom_reset
},
{
"gsdattr_activate_change_value"
,(
caddr_t
)
gsdattr_activate_change_value
},
{
"gsdattr_activate_help"
,(
caddr_t
)
gsdattr_activate_help
},
{
"gsdattr_create_msg_label"
,(
caddr_t
)
gsdattr_create_msg_label
},
{
"gsdattr_create_cmd_prompt"
,(
caddr_t
)
gsdattr_create_cmd_prompt
},
{
"gsdattr_create_cmd_input"
,(
caddr_t
)
gsdattr_create_cmd_input
},
{
"gsdattr_create_attrnav_form"
,(
caddr_t
)
gsdattr_create_attrnav_form
},
{
"gsdattr_create_cmd_ok"
,(
caddr_t
)
gsdattr_create_cmd_ok
},
{
"gsdattr_activate_cmd_ok"
,(
caddr_t
)
gsdattr_activate_cmd_ok
},
{
"gsdattr_create_cmd_ca"
,(
caddr_t
)
gsdattr_create_cmd_ca
},
{
"gsdattr_activate_cmd_ca"
,(
caddr_t
)
gsdattr_activate_cmd_ca
}
};
static
int
reglist_num
=
(
sizeof
reglist
/
sizeof
reglist
[
0
]);
dcli_translate_filename
(
uid_filename
,
uid_filename
);
// Motif
MrmInitialize
();
strcpy
(
title
,
"PwR GsdAttr"
);
reglist
[
0
].
value
=
(
caddr_t
)
this
;
// Save the context structure in the widget
XtSetArg
(
args
[
0
],
XmNuserData
,
(
unsigned
int
)
this
);
sts
=
MrmOpenHierarchy
(
1
,
&
uid_filename_p
,
NULL
,
&
s_DRMh
);
if
(
sts
!=
MrmSUCCESS
)
printf
(
"can't open %s
\n
"
,
uid_filename
);
MrmRegisterNames
(
reglist
,
reglist_num
);
parent_wid
=
XtCreatePopupShell
(
"pbGsdEditor"
,
topLevelShellWidgetClass
,
a_parent_wid
,
args
,
0
);
sts
=
MrmFetchWidgetOverride
(
s_DRMh
,
"gsd_attr_window"
,
parent_wid
,
name
,
args
,
1
,
&
toplevel
,
&
dclass
);
if
(
sts
!=
MrmSUCCESS
)
printf
(
"can't fetch %s
\n
"
,
name
);
MrmCloseHierarchy
(
s_DRMh
);
if
(
compiled_translations
==
NULL
)
XtAppAddActions
(
XtWidgetToApplicationContext
(
toplevel
),
actions
,
XtNumber
(
actions
));
if
(
compiled_translations
==
NULL
)
compiled_translations
=
XtParseTranslationTable
(
translations
);
XtOverrideTranslations
(
toplevel
,
compiled_translations
);
i
=
0
;
XtSetArg
(
args
[
i
],
XmNwidth
,
500
);
i
++
;
XtSetArg
(
args
[
i
],
XmNheight
,
700
);
i
++
;
XtSetValues
(
toplevel
,
args
,
i
);
i
=
0
;
XtSetArg
(
args
[
i
],
XmNdeleteResponse
,
XmDO_NOTHING
);
i
++
;
XtSetValues
(
parent_wid
,
args
,
i
);
XtManageChild
(
toplevel
);
XtUnmanageChild
(
cmd_input
);
attrnav
=
new
GsdAttrNav
(
this
,
attrnav_form
,
"Plant"
,
gsd
,
edit_mode
,
&
brow_widget
,
&
sts
);
((
GsdAttrNav
*
)
attrnav
)
->
message_cb
=
&
gsdattr_message
;
((
GsdAttrNav
*
)
attrnav
)
->
change_value_cb
=
&
gsdattr_change_value_cb
;
XtPopup
(
parent_wid
,
XtGrabNone
);
if
(
!
edit_mode
)
{
i
=
0
;
XtSetArg
(
args
[
i
],
XmNsensitive
,
0
);
i
++
;
XtSetValues
(
cmd_ok
,
args
,
i
);
}
// Connect the window manager close-button to exit
flow_AddCloseVMProtocolCb
(
parent_wid
,
(
XtCallbackProc
)
gsdattr_activate_exit
,
this
);
}
profibus/lib/pb/src/pb_gsd_attr.h
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd_attr.h,v 1.1 2006-03-22 14:38:11 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 pb_gsd_attr_h
#define pb_gsd_attr_h
/* pb_gsd_attr.h -- Profibus gsd attribute editor */
#include "pb_gsd.h"
#if defined __cplusplus
extern
"C"
{
#endif
typedef
struct
{
void
*
value
;
char
name
[
80
];
int
type
;
int
size
;
double
minlimit
;
double
maxlimit
;
int
noedit
;
int
multiline
;
int
mask
;
}
attr_sItem
;
class
GsdAttrNav
;
class
GsdAttr
{
public:
GsdAttr
(
Widget
a_parent_wid
,
void
*
a_parent_ctx
,
void
*
a_object
,
// void (*close_cb) (attr_tCtx),
// void (*redraw_cb) (attr_tCtx),
pb_gsd
*
a_gsd
,
int
a_edit_mode
);
void
*
parent_ctx
;
Widget
parent_wid
;
char
name
[
80
];
pb_gsd
*
gsd
;
int
edit_mode
;
Widget
brow_widget
;
Widget
form_widget
;
Widget
toplevel
;
GsdAttrNav
*
attrnav
;
Widget
msg_label
;
Widget
cmd_prompt
;
Widget
cmd_input
;
Widget
attrnav_form
;
Widget
cmd_ok
;
Widget
cmd_cancel
;
int
input_open
;
void
*
object
;
void
(
*
close_cb
)
(
void
*
);
int
(
*
save_cb
)
(
void
*
);
void
*
client_data
;
int
recall_idx
;
static
char
value_recall
[
30
][
160
];
int
value_current_recall
;
void
message
(
char
severity
,
char
*
message
);
void
set_prompt
(
char
*
prompt
);
void
change_value
();
~
GsdAttr
();
};
/*@}*/
#if defined __cplusplus
}
#endif
#endif
profibus/lib/pb/src/pb_gsd_attrnav.cpp
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd_attrnav.cpp,v 1.1 2006-03-22 14:38:11 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.
**/
/* pb_gsd_attrnav.cpp -- Display gsd attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
extern
"C"
{
#include "co_cdh.h"
#include "co_time.h"
}
#include <Xm/Xm.h>
#include <Xm/XmP.h>
#include <Xm/Text.h>
#include <Mrm/MrmPublic.h>
#include <X11/Intrinsic.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget.h"
#include "flow_msg.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget.h"
#include "pb_gsd.h"
#include "pb_gsd_attr.h"
#include "pb_gsd_attrnav.h"
#include "rt_pb_msg.h"
#include "xnav_bitmap_leaf8.h"
#include "xnav_bitmap_leaf10.h"
#include "xnav_bitmap_leaf12.h"
#include "xnav_bitmap_leaf14.h"
#include "xnav_bitmap_leaf16.h"
#include "xnav_bitmap_leaf18.h"
#include "xnav_bitmap_leaf20.h"
#include "xnav_bitmap_leaf24.h"
#include "xnav_bitmap_map8.h"
#include "xnav_bitmap_map10.h"
#include "xnav_bitmap_map12.h"
#include "xnav_bitmap_map14.h"
#include "xnav_bitmap_map16.h"
#include "xnav_bitmap_map18.h"
#include "xnav_bitmap_map20.h"
#include "xnav_bitmap_map24.h"
#include "xnav_bitmap_openmap8.h"
#include "xnav_bitmap_openmap10.h"
#include "xnav_bitmap_openmap12.h"
#include "xnav_bitmap_openmap14.h"
#include "xnav_bitmap_openmap16.h"
#include "xnav_bitmap_openmap18.h"
#include "xnav_bitmap_openmap20.h"
#include "xnav_bitmap_openmap24.h"
#include "xnav_bitmap_attr8.h"
#include "xnav_bitmap_attr10.h"
#include "xnav_bitmap_attr12.h"
#include "xnav_bitmap_attr14.h"
#include "xnav_bitmap_attr16.h"
#include "xnav_bitmap_attr18.h"
#include "xnav_bitmap_attr20.h"
#include "xnav_bitmap_attr24.h"
#include "xnav_bitmap_attrarra8.h"
#include "xnav_bitmap_attrarra10.h"
#include "xnav_bitmap_attrarra12.h"
#include "xnav_bitmap_attrarra14.h"
#include "xnav_bitmap_attrarra16.h"
#include "xnav_bitmap_attrarra18.h"
#include "xnav_bitmap_attrarra20.h"
#include "xnav_bitmap_attrarra24.h"
#include "xnav_bitmap_attrenum8.h"
#include "xnav_bitmap_attrenum10.h"
#include "xnav_bitmap_attrenum12.h"
#include "xnav_bitmap_attrenum14.h"
#include "xnav_bitmap_attrenum16.h"
#include "xnav_bitmap_attrenum18.h"
#include "xnav_bitmap_attrenum20.h"
#include "xnav_bitmap_attrenum24.h"
#define ATTRNAV__INPUT_SYNTAX 2
#define ATTRNAV__OBJNOTFOUND 4
#define ATTRNAV__STRINGTOLONG 6
#define ATTRNAV__ITEM_NOCREA 8
#define ATTRNAV__SUCCESS 1
static
char
null_str
[]
=
""
;
static
void
attrnav_trace_scan
(
GsdAttrNav
*
attrnav
);
static
int
attrnav_trace_scan_bc
(
brow_tObject
object
,
void
*
p
);
static
int
attrnav_trace_connect_bc
(
brow_tObject
object
,
char
*
name
,
char
*
attr
,
flow_eTraceType
type
,
/* flow_eDrawType color, */
void
**
p
);
static
int
attrnav_trace_disconnect_bc
(
brow_tObject
object
);
static
int
attrnav_init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
);
//
// Convert attribute string to value
//
static
int
attrnav_attr_string_to_value
(
int
type_id
,
char
*
value_str
,
void
*
buffer_ptr
,
int
buff_size
,
int
attr_size
)
{
switch
(
type_id
)
{
case
pwr_eType_Boolean
:
{
if
(
sscanf
(
value_str
,
"%d"
,
(
pwr_tBoolean
*
)
buffer_ptr
)
!=
1
)
return
ATTRNAV__INPUT_SYNTAX
;
if
(
*
(
pwr_tBoolean
*
)
buffer_ptr
>
1
)
return
ATTRNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_Float32
:
{
pwr_tFloat32
f
;
if
(
sscanf
(
value_str
,
"%f"
,
&
f
)
!=
1
)
return
ATTRNAV__INPUT_SYNTAX
;
memcpy
(
buffer_ptr
,
(
char
*
)
&
f
,
sizeof
(
f
));
break
;
}
case
pwr_eType_Int32
:
{
if
(
sscanf
(
value_str
,
"%d"
,
(
int
*
)
buffer_ptr
)
!=
1
)
return
ATTRNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_UInt32
:
{
if
(
sscanf
(
value_str
,
"%u"
,
(
int
*
)
buffer_ptr
)
!=
1
)
return
ATTRNAV__INPUT_SYNTAX
;
break
;
}
case
pwr_eType_String
:
{
if
(
(
int
)
strlen
(
value_str
)
>=
attr_size
)
return
ATTRNAV__STRINGTOLONG
;
strncpy
(
(
char
*
)
buffer_ptr
,
value_str
,
min
(
attr_size
,
buff_size
));
break
;
}
}
return
1
;
}
//
// Convert attribute value to string
//
static
void
attrnav_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"
,
*
(
float
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
float
*
)
value_ptr
);
break
;
}
case
pwr_eType_UInt32
:
{
if
(
!
format
)
*
len
=
sprintf
(
str
,
"%u"
,
*
(
int
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
int
*
)
value_ptr
);
break
;
}
case
pwr_eType_Int32
:
{
if
(
!
format
)
*
len
=
sprintf
(
str
,
"%d"
,
*
(
int
*
)
value_ptr
);
else
*
len
=
sprintf
(
str
,
format
,
*
(
int
*
)
value_ptr
);
break
;
}
case
pwr_eType_String
:
{
strncpy
(
str
,
(
char
*
)
value_ptr
,
size
);
str
[
size
-
1
]
=
0
;
*
len
=
strlen
(
str
);
break
;
}
}
}
void
GsdAttrNav
::
message
(
char
sev
,
char
*
text
)
{
(
message_cb
)(
parent_ctx
,
sev
,
text
);
}
//
// Free pixmaps
//
void
GsdAttrNavBrow
::
free_pixmaps
()
{
brow_FreeAnnotPixmap
(
ctx
,
pixmap_leaf
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_map
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_openmap
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_attr
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_attrarray
);
brow_FreeAnnotPixmap
(
ctx
,
pixmap_attrenum
);
}
//
// Create pixmaps for leaf, closed map and open map
//
void
GsdAttrNavBrow
::
allocate_pixmaps
()
{
flow_sPixmapData
pixmap_data
;
int
i
;
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf10_bits
;
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
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_leaf24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_leaf24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_leaf24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_leaf
);
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map10_bits
;
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
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_map24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_map24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_map24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_map
);
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap10_bits
;
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
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_openmap24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_openmap24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_openmap24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_openmap
);
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr10_bits
;
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
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attr24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attr24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attr24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_attr
);
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra10_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra12_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra12_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra12_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrarra24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrarra24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrarra24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_attrarray
);
i
=
0
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum8_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum8_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum8_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum10_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum10_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum10_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum12_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum12_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum12_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum14_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum14_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum14_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum16_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum16_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum16_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum18_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum18_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum18_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum20_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum20_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum20_bits
;
pixmap_data
[
i
].
width
=
xnav_bitmap_attrenum24_width
;
pixmap_data
[
i
].
height
=
xnav_bitmap_attrenum24_height
;
pixmap_data
[
i
++
].
bits
=
(
char
*
)
xnav_bitmap_attrenum24_bits
;
brow_AllocAnnotPixmap
(
ctx
,
&
pixmap_data
,
&
pixmap_attrenum
);
}
//
// Create the navigator widget
//
GsdAttrNav
::
GsdAttrNav
(
void
*
xn_parent_ctx
,
Widget
xn_parent_wid
,
char
*
xn_name
,
pb_gsd
*
xn_gsd
,
int
xn_edit_mode
,
Widget
*
w
,
pwr_tStatus
*
status
)
:
parent_ctx
(
xn_parent_ctx
),
parent_wid
(
xn_parent_wid
),
gsd
(
xn_gsd
),
edit_mode
(
xn_edit_mode
),
trace_started
(
0
),
message_cb
(
0
),
change_value_cb
(
0
)
{
strcpy
(
name
,
xn_name
);
form_widget
=
ScrolledBrowCreate
(
parent_wid
,
name
,
NULL
,
0
,
attrnav_init_brow_cb
,
this
,
(
Widget
*
)
&
brow_widget
);
XtManageChild
(
form_widget
);
// Create the root item
*
w
=
form_widget
;
*
status
=
1
;
}
//
// Delete a nav context
//
GsdAttrNav
::~
GsdAttrNav
()
{
if
(
trace_started
)
XtRemoveTimeOut
(
trace_timerid
);
delete
brow
;
XtDestroyWidget
(
form_widget
);
}
GsdAttrNavBrow
::~
GsdAttrNavBrow
()
{
free_pixmaps
();
}
void
GsdAttrNav
::
set_inputfocus
()
{
XtCallAcceptFocus
(
brow_widget
,
CurrentTime
);
}
//
// Get current zoom factor
//
void
GsdAttrNav
::
get_zoom
(
double
*
zoom_factor
)
{
brow_GetZoom
(
brow
->
ctx
,
zoom_factor
);
}
//
// Zoom
//
void
GsdAttrNav
::
zoom
(
double
zoom_factor
)
{
brow_Zoom
(
brow
->
ctx
,
zoom_factor
);
}
//
// Return to base zoom factor
//
void
GsdAttrNav
::
unzoom
()
{
brow_UnZoom
(
brow
->
ctx
);
}
// Get selected item
int
GsdAttrNav
::
get_select
(
ItemPb
**
item
)
{
brow_tNode
*
node_list
;
int
node_count
;
ItemPb
*
base_item
;
brow_GetSelectedNodes
(
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
return
0
;
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
base_item
);
free
(
node_list
);
*
item
=
base_item
;
return
1
;
}
//
// Set attribute value
//
int
GsdAttrNav
::
set_attr_value
(
char
*
value_str
)
{
brow_tNode
*
node_list
;
int
node_count
;
ItemPb
*
base_item
;
int
sts
;
char
buffer
[
1024
];
brow_GetSelectedNodes
(
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
return
0
;
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
base_item
);
free
(
node_list
);
switch
(
base_item
->
type
)
{
case
attrnav_eItemType_PbBase
:
{
ItemPbBase
*
item
=
(
ItemPbBase
*
)
base_item
;
sts
=
attrnav_attr_string_to_value
(
item
->
type_id
,
value_str
,
buffer
,
sizeof
(
buffer
),
item
->
size
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
item
->
max_limit
!=
0
||
item
->
min_limit
!=
0
)
{
switch
(
item
->
type_id
)
{
case
pwr_eType_Int32
:
case
pwr_eType_UInt32
:
if
(
*
(
int
*
)
&
buffer
<
item
->
min_limit
||
*
(
int
*
)
&
buffer
>
item
->
max_limit
)
{
message
(
'E'
,
"Min or maxvalue exceeded"
);
return
0
;
}
break
;
default:
;
}
}
memcpy
(
item
->
value_p
,
buffer
,
item
->
size
);
gsd
->
set_modified
(
1
);
break
;
}
default:
;
}
return
1
;
}
//
// Check that the current selected item is valid for change
//
int
GsdAttrNav
::
check_attr_value
(
char
**
value
)
{
brow_tNode
*
node_list
;
int
node_count
;
ItemPb
*
base_item
;
static
char
buf
[
200
];
int
len
;
brow_GetSelectedNodes
(
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
return
PB__NOATTRSEL
;
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
base_item
);
free
(
node_list
);
switch
(
base_item
->
type
)
{
case
attrnav_eItemType_PbBase
:
{
ItemPbBase
*
item
=
(
ItemPbBase
*
)
base_item
;
if
(
item
->
noedit
)
{
*
value
=
0
;
return
PB__ATTRNOEDIT
;
}
attrnav_attrvalue_to_string
(
item
->
type_id
,
item
->
value_p
,
buf
,
sizeof
(
buf
),
&
len
,
NULL
);
*
value
=
buf
;
return
PB__SUCCESS
;
}
default:
*
value
=
0
;
return
PB__ATTRNOEDIT
;
}
return
PB__SUCCESS
;
}
//
// Callbacks from brow
//
static
int
attrnav_brow_cb
(
FlowCtx
*
ctx
,
flow_tEvent
event
)
{
GsdAttrNav
*
attrnav
;
ItemPb
*
item
;
if
(
event
->
event
==
flow_eEvent_ObjectDeleted
)
{
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
delete
item
;
return
1
;
}
brow_GetCtxUserData
(
(
BrowCtx
*
)
ctx
,
(
void
**
)
&
attrnav
);
attrnav
->
message
(
' '
,
null_str
);
switch
(
event
->
event
)
{
case
flow_eEvent_Key_Up
:
{
brow_tNode
*
node_list
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
attrnav
->
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
{
sts
=
brow_GetLast
(
attrnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
sts
=
brow_GetPrevious
(
attrnav
->
brow
->
ctx
,
node_list
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
sts
=
brow_GetLast
(
attrnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
{
if
(
node_count
)
free
(
node_list
);
return
1
;
}
}
}
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
attrnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
attrnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
attrnav
->
brow
->
ctx
,
object
,
0.25
);
if
(
node_count
)
free
(
node_list
);
break
;
}
case
flow_eEvent_Key_Down
:
{
brow_tNode
*
node_list
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
attrnav
->
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
{
sts
=
brow_GetFirst
(
attrnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
return
1
;
}
else
{
sts
=
brow_GetNext
(
attrnav
->
brow
->
ctx
,
node_list
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
sts
=
brow_GetFirst
(
attrnav
->
brow
->
ctx
,
&
object
);
if
(
EVEN
(
sts
))
{
if
(
node_count
)
free
(
node_list
);
return
1
;
}
}
}
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
attrnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
attrnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
attrnav
->
brow
->
ctx
,
object
,
0.75
);
if
(
node_count
)
free
(
node_list
);
break
;
}
case
flow_eEvent_SelectClear
:
brow_ResetSelectInverse
(
attrnav
->
brow
->
ctx
);
break
;
case
flow_eEvent_MB1Click
:
// Select
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
int
sts
;
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
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
;
doubleclick_event
=
(
flow_tEvent
)
calloc
(
1
,
sizeof
(
*
doubleclick_event
));
memcpy
(
doubleclick_event
,
event
,
sizeof
(
*
doubleclick_event
));
doubleclick_event
->
event
=
flow_eEvent_MB1DoubleClick
;
sts
=
attrnav_brow_cb
(
ctx
,
doubleclick_event
);
free
(
(
char
*
)
doubleclick_event
);
return
sts
;
}
if
(
brow_FindSelectedObject
(
attrnav
->
brow
->
ctx
,
event
->
object
.
object
))
{
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
}
else
{
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
brow_SetInverse
(
event
->
object
.
object
,
1
);
brow_SelectInsert
(
attrnav
->
brow
->
ctx
,
event
->
object
.
object
);
}
break
;
default:
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
}
break
;
case
flow_eEvent_MB2Click
:
{
// Select
brow_tNode
*
node_list
;
int
node_count
;
int
sts
;
if
(
!
attrnav
->
edit_mode
)
{
attrnav
->
message
(
'E'
,
"Not in edit mode"
);
break
;
}
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
brow_GetSelectedNodes
(
attrnav
->
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
{
attrnav
->
message
(
'E'
,
"Select a module"
);
break
;
}
else
if
(
node_count
>
1
)
{
attrnav
->
message
(
'E'
,
"Select one module"
);
free
(
node_list
);
break
;
}
ItemPbModule
*
item_dest
,
*
item_src
;
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item_src
);
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item_dest
);
if
(
item_src
->
type
!=
attrnav_eItemType_PbModule
)
{
attrnav
->
message
(
'E'
,
"Unable to move this object"
);
free
(
node_list
);
break
;
}
if
(
item_dest
->
type
!=
attrnav_eItemType_PbModule
)
{
attrnav
->
message
(
'E'
,
"Invalid destination"
);
free
(
node_list
);
break
;
}
sts
=
attrnav
->
gsd
->
move_module_conf
(
item_src
->
mconf
,
item_dest
->
mconf
);
if
(
ODD
(
sts
))
{
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
brow_SetInverse
(
event
->
object
.
object
,
1
);
brow_SelectInsert
(
attrnav
->
brow
->
ctx
,
event
->
object
.
object
);
}
free
(
node_list
);
break
;
default:
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
}
break
;
}
case
flow_eEvent_Key_Left
:
{
brow_tNode
*
node_list
;
int
node_count
;
brow_tObject
object
;
int
sts
;
brow_GetSelectedNodes
(
attrnav
->
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
return
1
;
if
(
brow_IsOpen
(
node_list
[
0
]))
// Close this node
object
=
node_list
[
0
];
else
{
// Close parent
sts
=
brow_GetParent
(
attrnav
->
brow
->
ctx
,
node_list
[
0
],
&
object
);
if
(
EVEN
(
sts
))
{
free
(
node_list
);
return
1
;
}
}
brow_GetUserData
(
object
,
(
void
**
)
&
item
);
item
->
close
(
attrnav
,
0
,
0
);
brow_SelectClear
(
attrnav
->
brow
->
ctx
);
brow_SetInverse
(
object
,
1
);
brow_SelectInsert
(
attrnav
->
brow
->
ctx
,
object
);
if
(
!
brow_IsVisible
(
attrnav
->
brow
->
ctx
,
object
,
flow_eVisible_Full
))
brow_CenterObject
(
attrnav
->
brow
->
ctx
,
object
,
0.25
);
free
(
node_list
);
break
;
}
case
flow_eEvent_Key_Right
:
{
brow_tNode
*
node_list
;
int
node_count
;
brow_GetSelectedNodes
(
attrnav
->
brow
->
ctx
,
&
node_list
,
&
node_count
);
if
(
!
node_count
)
return
1
;
brow_GetUserData
(
node_list
[
0
],
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
case
attrnav_eItemType_PbBase
:
case
attrnav_eItemType_PbEnum
:
if
(
((
ItemPbBase
*
)
item
)
->
parent
)
item
->
open_children
(
attrnav
,
0
,
0
);
else
if
(
!
((
ItemPbBase
*
)
item
)
->
parent
&&
attrnav
->
change_value_cb
)
(
attrnav
->
change_value_cb
)
(
attrnav
->
parent_ctx
);
break
;
case
attrnav_eItemType_PbEnumValue
:
{
int
value
;
if
(
!
attrnav
->
edit_mode
)
{
attrnav
->
message
(
'E'
,
"Not in edit mode"
);
break
;
}
brow_GetRadiobutton
(
node_list
[
0
],
0
,
&
value
);
if
(
!
value
)
{
brow_SetRadiobutton
(
node_list
[
0
],
0
,
1
);
*
(
int
*
)((
ItemPbEnumValue
*
)
item
)
->
value_p
=
((
ItemPbEnumValue
*
)
item
)
->
num
;
attrnav
->
gsd
->
set_modified
(
1
);
}
break
;
default:
item
->
open_children
(
attrnav
,
0
,
0
);
}
break
;
}
}
case
flow_eEvent_MB1DoubleClick
:
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
item
->
open_children
(
attrnav
,
event
->
object
.
x
,
event
->
object
.
y
);
break
;
default:
;
}
break
;
case
flow_eEvent_MB1DoubleClickCtrl
:
break
;
case
flow_eEvent_Radiobutton
:
{
if
(
!
attrnav
->
edit_mode
)
{
attrnav
->
message
(
'E'
,
"Not in edit mode"
);
break
;
}
switch
(
event
->
object
.
object_type
)
{
case
flow_eObjectType_Node
:
brow_GetUserData
(
event
->
object
.
object
,
(
void
**
)
&
item
);
switch
(
item
->
type
)
{
case
attrnav_eItemType_PbEnumValue
:
if
(
!
event
->
radiobutton
.
value
)
{
brow_SetRadiobutton
(
event
->
radiobutton
.
object
,
event
->
radiobutton
.
number
,
!
event
->
radiobutton
.
value
);
*
(
int
*
)((
ItemPbEnumValue
*
)
item
)
->
value_p
=
((
ItemPbEnumValue
*
)
item
)
->
num
;
attrnav
->
gsd
->
set_modified
(
1
);
}
break
;
default:
;
}
break
;
default:
;
}
break
;
}
case
flow_eEvent_Key_PageDown
:
{
brow_Page
(
attrnav
->
brow
->
ctx
,
0.8
);
break
;
}
case
flow_eEvent_Key_PageUp
:
{
brow_Page
(
attrnav
->
brow
->
ctx
,
-
0.8
);
break
;
}
default:
;
}
return
1
;
}
static
void
attrnav_trace_scan
(
GsdAttrNav
*
attrnav
)
{
int
time
=
200
;
if
(
attrnav
->
trace_started
)
{
brow_TraceScan
(
attrnav
->
brow
->
ctx
);
attrnav
->
trace_timerid
=
XtAppAddTimeOut
(
XtWidgetToApplicationContext
(
attrnav
->
brow_widget
)
,
time
,
(
XtTimerCallbackProc
)
attrnav_trace_scan
,
attrnav
);
}
}
void
GsdAttrNav
::
force_trace_scan
()
{
if
(
trace_started
)
brow_TraceScan
(
brow
->
ctx
);
}
static
int
attrnav_trace_scan_bc
(
brow_tObject
object
,
void
*
p
)
{
ItemPb
*
base_item
;
char
buf
[
200
];
int
len
;
GsdAttrNav
*
attrnav
;
brow_GetUserData
(
object
,
(
void
**
)
&
base_item
);
switch
(
base_item
->
type
)
{
case
attrnav_eItemType_PbBase
:
{
ItemPbBase
*
item
;
item
=
(
ItemPbBase
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
size
>
(
int
)
sizeof
(
item
->
old_value
)
&&
item
->
type_id
==
glow_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
;
attrnav_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
attrnav_eItemType_PbEnum
:
{
ItemPbEnum
*
item
;
item
=
(
ItemPbEnum
*
)
base_item
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
old_value
==
*
(
int
*
)
p
)
// No change since last time
return
1
;
}
else
item
->
first_scan
=
0
;
brow_GetCtxUserData
(
brow_GetCtx
(
object
),
(
void
**
)
&
attrnav
);
attrnav
->
gsd
->
prm_text_val_to_str
(
item
->
enumtext
,
*
(
int
*
)
p
,
buf
);
brow_SetAnnotation
(
object
,
1
,
buf
,
strlen
(
buf
));
item
->
old_value
=
*
(
int
*
)
p
;
break
;
}
case
attrnav_eItemType_PbModuleType
:
{
ItemPbModuleType
*
item
;
int
sts
;
item
=
(
ItemPbModuleType
*
)
base_item
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
old_value
==
*
(
int
*
)
p
)
// No change since last time
return
1
;
}
brow_GetCtxUserData
(
brow_GetCtx
(
object
),
(
void
**
)
&
attrnav
);
if
(
*
(
int
*
)
p
==
0
)
strcpy
(
buf
,
"No"
);
else
{
int
idx
=
1
;
gsd_sModule
*
mp
;
for
(
mp
=
attrnav
->
gsd
->
modulelist
;
mp
;
mp
=
mp
->
next
)
{
if
(
idx
++
==
*
(
int
*
)
p
)
break
;
}
if
(
!
mp
)
strcpy
(
buf
,
"Unknown module"
);
else
strcpy
(
buf
,
mp
->
Mod_Name
);
}
brow_SetAnnotation
(
object
,
1
,
buf
,
strlen
(
buf
));
item
->
old_value
=
*
(
int
*
)
p
;
if
(
!
item
->
first_scan
)
{
ItemPbModuleData
*
prm_item
;
attrnav
->
gsd
->
configure_module
(
item
->
mconf
);
// Update Data map
brow_tObject
odata
;
sts
=
brow_GetNextSibling
(
attrnav
->
brow
->
ctx
,
object
,
&
odata
);
brow_GetUserData
(
odata
,
(
void
**
)
&
prm_item
);
prm_item
->
update
(
attrnav
);
}
else
item
->
first_scan
=
0
;
break
;
}
case
attrnav_eItemType_PbModuleClass
:
{
ItemPbModuleClass
*
item
=
(
ItemPbModuleClass
*
)
base_item
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
old_value
==
*
(
int
*
)
p
)
// No change since last time
return
1
;
}
brow_GetCtxUserData
(
brow_GetCtx
(
object
),
(
void
**
)
&
attrnav
);
if
(
*
(
int
*
)
p
==
0
)
strcpy
(
buf
,
"No"
);
else
{
int
found
=
0
;
int
i
;
for
(
i
=
0
;
attrnav
->
gsd
->
module_classlist
[
i
].
cid
;
i
++
)
{
if
(
attrnav
->
gsd
->
module_classlist
[
i
].
cid
==
*
(
pwr_tCid
*
)
p
)
{
found
=
1
;
break
;
}
}
if
(
!
found
)
strcpy
(
buf
,
"Unknown class"
);
else
strcpy
(
buf
,
attrnav
->
gsd
->
module_classlist
[
i
].
name
);
}
brow_SetAnnotation
(
object
,
1
,
buf
,
strlen
(
buf
));
item
->
old_value
=
*
(
int
*
)
p
;
if
(
item
->
first_scan
)
item
->
first_scan
=
0
;
break
;
}
case
attrnav_eItemType_PbModule
:
{
ItemPbModule
*
item
=
(
ItemPbModule
*
)
base_item
;
brow_GetCtxUserData
(
brow_GetCtx
(
object
),
(
void
**
)
&
attrnav
);
if
(
!
item
->
mconf
->
module
)
strcpy
(
buf
,
""
);
else
strcpy
(
buf
,
item
->
mconf
->
module
->
Mod_Name
);
if
(
strcmp
(
buf
,
item
->
old_type
)
!=
0
)
{
brow_SetAnnotation
(
object
,
2
,
buf
,
strlen
(
buf
));
strcpy
(
item
->
old_type
,
buf
);
}
if
(
!
item
->
first_scan
)
{
if
(
strcmp
(
item
->
old_value
,
(
char
*
)
p
)
==
0
)
// No change since last time
return
1
;
}
strcpy
(
buf
,
(
char
*
)
p
);
brow_SetAnnotation
(
object
,
1
,
buf
,
strlen
(
buf
));
strcpy
(
item
->
old_value
,
(
char
*
)
p
);
if
(
item
->
first_scan
)
item
->
first_scan
=
0
;
break
;
}
case
attrnav_eItemType_PbEnumValue
:
{
ItemPbEnumValue
*
item
;
item
=
(
ItemPbEnumValue
*
)
base_item
;
if
(
!
item
->
first_scan
)
{
if
(
item
->
old_value
==
*
(
int
*
)
p
)
// No change since last time
return
1
;
}
else
item
->
first_scan
=
0
;
if
(
*
(
int
*
)
p
==
item
->
num
)
brow_SetRadiobutton
(
item
->
node
,
0
,
1
);
else
brow_SetRadiobutton
(
item
->
node
,
0
,
0
);
item
->
old_value
=
*
(
int
*
)
p
;
break
;
}
default:
;
}
return
1
;
}
static
int
attrnav_trace_connect_bc
(
brow_tObject
object
,
char
*
name
,
char
*
attr
,
flow_eTraceType
type
,
/* flow_eDrawType color, */
void
**
p
)
{
ItemPb
*
base_item
;
/* printf( "Connecting %s.%s\n", name, attr); */
if
(
strcmp
(
name
,
""
)
==
0
)
return
1
;
brow_GetUserData
(
object
,
(
void
**
)
&
base_item
);
switch
(
base_item
->
type
)
{
case
attrnav_eItemType_PbBase
:
case
attrnav_eItemType_PbEnum
:
{
ItemPbBase
*
item
=
(
ItemPbBase
*
)
base_item
;
if
(
item
->
size
==
0
)
break
;
*
p
=
item
->
value_p
;
break
;
}
case
attrnav_eItemType_PbModuleType
:
{
ItemPbModuleType
*
item
=
(
ItemPbModuleType
*
)
base_item
;
*
p
=
&
item
->
mconf
->
idx
;
break
;
}
case
attrnav_eItemType_PbModule
:
{
ItemPbModule
*
item
=
(
ItemPbModule
*
)
base_item
;
*
p
=
&
item
->
mconf
->
name
;
break
;
}
case
attrnav_eItemType_PbModuleClass
:
{
ItemPbModuleClass
*
item
=
(
ItemPbModuleClass
*
)
base_item
;
*
p
=
&
item
->
mconf
->
cid
;
break
;
}
case
attrnav_eItemType_PbEnumValue
:
{
ItemPbEnumValue
*
item
=
(
ItemPbEnumValue
*
)
base_item
;
*
p
=
item
->
value_p
;
break
;
}
default:
;
}
return
1
;
}
static
int
attrnav_trace_disconnect_bc
(
brow_tObject
object
)
{
ItemPb
*
base_item
;
brow_GetUserData
(
object
,
(
void
**
)
&
base_item
);
switch
(
base_item
->
type
)
{
default:
;
}
return
1
;
}
//
// Create nodeclasses
//
void
GsdAttrNavBrow
::
create_nodeclasses
()
{
allocate_pixmaps
();
// Create common-class
brow_CreateNodeClass
(
ctx
,
"NavigatorDefault"
,
flow_eNodeGroup_Common
,
&
nc_object
);
brow_AddFrame
(
nc_object
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_Line
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_object
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnotPixmap
(
nc_object
,
1
,
1.1
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_object
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_object
,
7
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_object
,
12
,
0.6
,
2
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"NavigatorGsdAttr"
,
flow_eNodeGroup_Common
,
&
nc_attr
);
brow_AddFrame
(
nc_attr
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_Line
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_attr
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_attr
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_attr
,
12
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create multiline attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"NavigatorGsdAttrMultiLine"
,
flow_eNodeGroup_Common
,
&
nc_attr_multiline
);
brow_AddFrame
(
nc_attr_multiline
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_Line
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_attr_multiline
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_attr_multiline
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_attr_multiline
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_MultiLine
,
1
);
// Create attribute nodeclass
brow_CreateNodeClass
(
ctx
,
"NavigatorEnum"
,
flow_eNodeGroup_Common
,
&
nc_enum
);
brow_AddRadiobutton
(
nc_enum
,
15
,
0.1
,
0.7
,
0.7
,
0
,
flow_eDrawType_Line
,
1
);
brow_AddFrame
(
nc_enum
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_Line
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_enum
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_enum
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
// Create table nodeclass
brow_CreateNodeClass
(
ctx
,
"NavigatorTable"
,
flow_eNodeGroup_Common
,
&
nc_table
);
brow_AddFrame
(
nc_table
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_Line
,
-
1
,
1
);
brow_AddAnnotPixmap
(
nc_table
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnotPixmap
(
nc_table
,
1
,
1.1
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_table
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
12
,
0.6
,
2
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
16
,
0.6
,
3
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
20
,
0.6
,
4
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
24
,
0.6
,
5
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
28
,
0.6
,
6
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
32
,
0.6
,
7
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
35
,
0.6
,
8
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
brow_AddAnnot
(
nc_table
,
38
,
0.6
,
9
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create Header
brow_CreateNodeClass
(
ctx
,
"NavigatorHead"
,
flow_eNodeGroup_Common
,
&
nc_header
);
brow_AddFrame
(
nc_header
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_LineGray
,
2
,
1
);
brow_AddAnnotPixmap
(
nc_header
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_header
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_header
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
1
);
// Create TableHeader
brow_CreateNodeClass
(
ctx
,
"NavigatorTableHead"
,
flow_eNodeGroup_Common
,
&
nc_table_header
);
brow_AddFrame
(
nc_table_header
,
0
,
0
,
20
,
0.8
,
flow_eDrawType_LineGray
,
2
,
1
);
brow_AddAnnotPixmap
(
nc_table_header
,
0
,
0.2
,
0.1
,
flow_eDrawType_Line
,
2
,
0
);
brow_AddAnnot
(
nc_table_header
,
2
,
0.6
,
0
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
8
,
0.6
,
1
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
12
,
0.6
,
2
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
16
,
0.6
,
3
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
20
,
0.6
,
4
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
24
,
0.6
,
5
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
28
,
0.6
,
6
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
32
,
0.6
,
7
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
35
,
0.6
,
8
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
brow_AddAnnot
(
nc_table_header
,
38
,
0.6
,
9
,
flow_eDrawType_TextHelveticaBold
,
2
,
flow_eAnnotType_OneLine
,
0
);
}
void
GsdAttrNav
::
print
(
char
*
filename
)
{
brow_Print
(
brow
->
ctx
,
filename
);
}
int
GsdAttrNav
::
object_attr
()
{
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
unsigned
int
type
;
int
size
;
void
*
p
;
brow_SetNodraw
(
brow
->
ctx
);
for
(
keyp
=
gsd
->
keywordlist
,
datap
=
gsd
->
datalist
;
keyp
->
type
!=
gsd_End
;
keyp
++
,
datap
++
)
{
if
(
datap
->
found
)
{
if
(
!
(
strcmp
(
keyp
->
name
,
"Vendor_Name"
)
==
0
||
strcmp
(
keyp
->
name
,
"Model_Name"
)
==
0
))
continue
;
switch
(
keyp
->
type
)
{
case
gsd_ProfibusDP
:
case
gsd_Boolean
:
case
gsd_Unsigned8
:
case
gsd_Unsigned16
:
case
gsd_Unsigned32
:
case
gsd_UserPrmDataLen
:
type
=
pwr_eType_UInt32
;
size
=
sizeof
(
pwr_tUInt32
);
p
=
&
datap
->
value
;
break
;
case
gsd_VString8
:
type
=
pwr_eType_String
;
size
=
8
;
p
=
datap
->
data
;
break
;
case
gsd_SlaveFamily
:
case
gsd_VString32
:
type
=
pwr_eType_String
;
size
=
32
;
p
=
datap
->
data
;
break
;
case
gsd_VString256
:
type
=
pwr_eType_String
;
size
=
256
;
p
=
datap
->
data
;
break
;
default:
size
=
0
;
break
;
}
if
(
size
!=
0
)
new
ItemPbBase
(
this
,
keyp
->
name
,
"LocalGsdAttr"
,
type
,
size
,
0
,
0
,
p
,
1
,
0
,
NULL
,
flow_eDest_IntoLast
);
}
}
new
ItemPbMoreData
(
this
,
"SlaveGsdData"
,
NULL
,
flow_eDest_IntoLast
);
new
ItemPbPrmData
(
this
,
"UserPrmData"
,
NULL
,
flow_eDest_IntoLast
);
for
(
int
i
=
0
;
i
<
gsd
->
module_conf_cnt
;
i
++
)
{
new
ItemPbModule
(
this
,
"Module"
,
&
gsd
->
module_conf
[
i
],
NULL
,
flow_eDest_IntoLast
);
}
brow_ResetNodraw
(
brow
->
ctx
);
brow_Redraw
(
brow
->
ctx
,
0
);
force_trace_scan
();
return
PB__SUCCESS
;
}
void
GsdAttrNavBrow
::
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
,
attrnav
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB1Click
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB2Click
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB1DoubleClick
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_MB1DoubleClickCtrl
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_SelectClear
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_ObjectDeleted
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Up
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Down
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Right
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_Left
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PF3
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Radiobutton
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PageUp
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
brow_EnableEvent
(
ctx
,
flow_eEvent_Key_PageDown
,
flow_eEventType_CallBack
,
attrnav_brow_cb
);
}
//
// Backcall routine called at creation of the brow widget
// Enable event, create nodeclasses and insert the root objects.
//
static
int
attrnav_init_brow_cb
(
FlowCtx
*
fctx
,
void
*
client_data
)
{
GsdAttrNav
*
attrnav
=
(
GsdAttrNav
*
)
client_data
;
BrowCtx
*
ctx
=
(
BrowCtx
*
)
fctx
;
int
sts
;
attrnav
->
brow
=
new
GsdAttrNavBrow
(
ctx
,
(
void
*
)
attrnav
);
attrnav
->
brow
->
brow_setup
();
attrnav
->
brow
->
create_nodeclasses
();
// Create the root item
attrnav
->
object_attr
();
sts
=
brow_TraceInit
(
ctx
,
attrnav_trace_connect_bc
,
attrnav_trace_disconnect_bc
,
attrnav_trace_scan_bc
);
attrnav
->
trace_started
=
1
;
attrnav_trace_scan
(
attrnav
);
return
1
;
}
ItemPbBase
::
ItemPbBase
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
double
attr_min_limit
,
double
attr_max_limit
,
void
*
attr_value_p
,
int
attr_noedit
,
gsd_sPrmText
*
attr_enumtext
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
value_p
(
attr_value_p
),
first_scan
(
1
),
type_id
(
attr_type
),
size
(
attr_size
),
min_limit
(
attr_min_limit
),
max_limit
(
attr_max_limit
),
noedit
(
attr_noedit
),
enumtext
(
attr_enumtext
),
subgraph
(
0
)
{
type
=
attrnav_eItemType_PbBase
;
strcpy
(
name
,
item_name
);
memset
(
old_value
,
0
,
sizeof
(
old_value
));
if
(
enumtext
)
parent
=
1
;
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attr
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
attr
,
""
,
flow_eTraceType_User
);
}
ItemPbEnum
::
ItemPbEnum
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
double
attr_min_limit
,
double
attr_max_limit
,
void
*
attr_value_p
,
int
attr_noedit
,
gsd_sPrmText
*
attr_enumtext
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
ItemPbBase
(
attrnav
,
item_name
,
attr
,
attr_type
,
attr_size
,
attr_min_limit
,
attr_max_limit
,
attr_value_p
,
attr_noedit
,
attr_enumtext
,
dest
,
dest_code
)
{
type
=
attrnav_eItemType_PbEnum
;
}
int
ItemPbEnum
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
if
(
parent
&&
!
noedit
&&
enumtext
)
{
int
found
;
found
=
0
;
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
for
(
gsd_sText
*
tp
=
enumtext
->
text_list
;
tp
;
tp
=
tp
->
next
)
{
new
ItemPbEnumValue
(
attrnav
,
tp
->
Text
,
tp
->
Prm_Data_Value
,
pwr_eType_UInt32
,
this
->
value_p
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
int
ItemPb
::
close
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
{
switch
(
type
)
{
case
attrnav_eItemType_PbEnum
:
case
attrnav_eItemType_PbModuleType
:
case
attrnav_eItemType_PbModuleClass
:
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
break
;
default:
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_leaf
);
}
}
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbEnumValue
::
ItemPbEnumValue
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
int
item_num
,
int
item_type_id
,
void
*
attr_value_p
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
num
(
item_num
),
type_id
(
item_type_id
),
value_p
(
attr_value_p
),
first_scan
(
1
)
{
type
=
attrnav_eItemType_PbEnumValue
;
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_enum
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attr
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
if
(
*
(
int
*
)
value_p
==
num
)
brow_SetRadiobutton
(
node
,
0
,
1
);
else
brow_SetRadiobutton
(
node
,
0
,
0
);
brow_SetTraceAttr
(
node
,
name
,
""
,
flow_eTraceType_User
);
}
ItemPbModule
::
ItemPbModule
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
mconf
(
item_mconf
),
first_scan
(
1
)
{
type
=
attrnav_eItemType_PbModule
;
strcpy
(
name
,
item_name
);
parent
=
1
;
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_object
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
name
,
""
,
flow_eTraceType_User
);
}
int
ItemPbModule
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
#if 0
new ItemPbBase( this, gsd->prm_dataitems[i].ref->prm_data->Ext_User_Prm_Data_Name,
"LocalGsdAttr",
type, size,
gsd->prm_dataitems[i].ref->prm_data->Min_Value,
gsd->prm_dataitems[i].ref->prm_data->Max_Value,
p, 0, 0,
NULL, flow_eDest_IntoLast);
#endif
new
ItemPbBase
(
attrnav
,
"ObjectName"
,
"LocalGsdAttr"
,
pwr_eType_String
,
32
,
0
,
0
,
mconf
->
name
,
0
,
0
,
node
,
flow_eDest_IntoLast
);
new
ItemPbModuleType
(
attrnav
,
"Type"
,
mconf
,
node
,
flow_eDest_IntoLast
);
new
ItemPbModuleData
(
attrnav
,
"UserPrmData"
,
mconf
,
node
,
flow_eDest_IntoLast
);
if
(
attrnav
->
gsd
->
module_classlist
)
{
new
ItemPbModuleClass
(
attrnav
,
"Class"
,
mconf
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbModuleType
::
ItemPbModuleType
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
mconf
(
item_mconf
),
first_scan
(
1
)
{
type
=
attrnav_eItemType_PbModuleType
;
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
name
,
""
,
flow_eTraceType_User
);
}
int
ItemPbModuleType
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
int
idx
=
0
;
new
ItemPbEnumValue
(
attrnav
,
"No"
,
idx
++
,
pwr_eType_UInt32
,
&
this
->
mconf
->
idx
,
node
,
flow_eDest_IntoLast
);
for
(
gsd_sModule
*
mp
=
attrnav
->
gsd
->
modulelist
;
mp
;
mp
=
mp
->
next
)
{
new
ItemPbEnumValue
(
attrnav
,
mp
->
Mod_Name
,
idx
++
,
pwr_eType_UInt32
,
&
this
->
mconf
->
idx
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbModuleData
::
ItemPbModuleData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
mconf
(
item_mconf
)
{
type
=
attrnav_eItemType_PbModuleData
;
parent
=
(
mconf
->
prm_dataitems_cnt
>
0
);
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_leaf
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
}
void
ItemPbModuleData
::
update
(
GsdAttrNav
*
attrnav
)
{
parent
=
(
mconf
->
prm_dataitems_cnt
>
0
);
// If open close
if
(
brow_IsOpen
(
node
))
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_leaf
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
0
);
}
else
{
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_leaf
);
}
}
int
ItemPbModuleData
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
if
(
mconf
->
module
)
{
unsigned
int
type
;
int
size
;
void
*
p
;
for
(
int
i
=
0
;
i
<
mconf
->
prm_dataitems_cnt
;
i
++
)
{
p
=
&
mconf
->
prm_dataitems
[
i
].
value
;
switch
(
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
data_type
)
{
case
gsd_Signed32
:
case
gsd_Signed16
:
case
gsd_Signed8
:
type
=
pwr_eType_UInt32
;
break
;
default:
type
=
pwr_eType_Int32
;
}
size
=
sizeof
(
pwr_tUInt32
);
if
(
!
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
prmtext
)
new
ItemPbBase
(
attrnav
,
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Ext_User_Prm_Data_Name
,
"LocalGsdAttr"
,
type
,
size
,
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Min_Value
,
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Max_Value
,
p
,
0
,
0
,
node
,
flow_eDest_IntoLast
);
else
new
ItemPbEnum
(
attrnav
,
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Ext_User_Prm_Data_Name
,
"LocalGsdAttr"
,
type
,
size
,
0
,
0
,
p
,
0
,
mconf
->
prm_dataitems
[
i
].
ref
->
prm_data
->
prmtext
,
node
,
flow_eDest_IntoLast
);
}
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbModuleClass
::
ItemPbModuleClass
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
)
:
mconf
(
item_mconf
),
first_scan
(
1
)
{
type
=
attrnav_eItemType_PbModuleClass
;
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
brow_SetTraceAttr
(
node
,
name
,
""
,
flow_eTraceType_User
);
}
int
ItemPbModuleClass
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_attrenum
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
for
(
int
i
=
0
;
attrnav
->
gsd
->
module_classlist
[
i
].
cid
;
i
++
)
{
new
ItemPbEnumValue
(
attrnav
,
attrnav
->
gsd
->
module_classlist
[
i
].
name
,
attrnav
->
gsd
->
module_classlist
[
i
].
cid
,
pwr_eType_UInt32
,
&
this
->
mconf
->
cid
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbPrmData
::
ItemPbPrmData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
)
{
type
=
attrnav_eItemType_PbPrmData
;
parent
=
(
attrnav
->
gsd
->
prm_dataitems_cnt
>
0
);
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
if
(
parent
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
else
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_leaf
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
}
int
ItemPbPrmData
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
unsigned
int
type
;
int
size
;
void
*
p
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
for
(
int
i
=
0
;
i
<
attrnav
->
gsd
->
prm_dataitems_cnt
;
i
++
)
{
p
=
&
attrnav
->
gsd
->
prm_dataitems
[
i
].
value
;
type
=
pwr_eType_UInt32
;
size
=
sizeof
(
pwr_tUInt32
);
if
(
!
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
prmtext
)
new
ItemPbBase
(
attrnav
,
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Ext_User_Prm_Data_Name
,
"LocalGsdAttr"
,
type
,
size
,
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Min_Value
,
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Max_Value
,
p
,
0
,
0
,
node
,
flow_eDest_IntoLast
);
else
new
ItemPbEnum
(
attrnav
,
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
Ext_User_Prm_Data_Name
,
"LocalGsdAttr"
,
type
,
size
,
0
,
0
,
p
,
0
,
attrnav
->
gsd
->
prm_dataitems
[
i
].
ref
->
prm_data
->
prmtext
,
node
,
flow_eDest_IntoLast
);
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
ItemPbMoreData
::
ItemPbMoreData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
)
{
type
=
attrnav_eItemType_PbMoreData
;
parent
=
1
;
strcpy
(
name
,
item_name
);
brow_CreateNode
(
attrnav
->
brow
->
ctx
,
item_name
,
attrnav
->
brow
->
nc_attr
,
dest
,
dest_code
,
(
void
*
)
this
,
1
,
&
node
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_SetAnnotation
(
node
,
0
,
item_name
,
strlen
(
item_name
));
}
int
ItemPbMoreData
::
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
double
node_x
,
node_y
;
unsigned
int
type
;
int
size
;
void
*
p
;
gsd_sKeyword
*
keyp
;
gsd_sData
*
datap
;
brow_GetNodePosition
(
node
,
&
node_x
,
&
node_y
);
if
(
brow_IsOpen
(
node
))
{
// Close
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
brow_CloseNode
(
attrnav
->
brow
->
ctx
,
node
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Attributes
)
brow_RemoveAnnotPixmap
(
node
,
1
);
if
(
brow_IsOpen
(
node
)
&
attrnav_mOpen_Children
)
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_map
);
brow_ResetOpen
(
node
,
attrnav_mOpen_All
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
else
{
brow_SetNodraw
(
attrnav
->
brow
->
ctx
);
for
(
keyp
=
attrnav
->
gsd
->
keywordlist
,
datap
=
attrnav
->
gsd
->
datalist
;
keyp
->
type
!=
gsd_End
;
keyp
++
,
datap
++
)
{
if
(
strcmp
(
keyp
->
name
,
"Vendor_Name"
)
==
0
||
strcmp
(
keyp
->
name
,
"Model_Name"
)
==
0
)
continue
;
if
(
datap
->
found
)
{
switch
(
keyp
->
type
)
{
case
gsd_ProfibusDP
:
case
gsd_Boolean
:
case
gsd_Unsigned8
:
case
gsd_Unsigned16
:
case
gsd_Unsigned32
:
case
gsd_UserPrmDataLen
:
type
=
pwr_eType_UInt32
;
size
=
sizeof
(
pwr_tUInt32
);
p
=
&
datap
->
value
;
break
;
case
gsd_VString8
:
type
=
pwr_eType_String
;
size
=
8
;
p
=
datap
->
data
;
break
;
case
gsd_SlaveFamily
:
case
gsd_VString32
:
type
=
pwr_eType_String
;
size
=
32
;
p
=
datap
->
data
;
break
;
case
gsd_VString256
:
type
=
pwr_eType_String
;
size
=
256
;
p
=
datap
->
data
;
break
;
default:
size
=
0
;
break
;
}
if
(
size
!=
0
)
new
ItemPbBase
(
attrnav
,
keyp
->
name
,
"LocalGsdAttr"
,
type
,
size
,
0
,
0
,
p
,
1
,
0
,
node
,
flow_eDest_IntoLast
);
}
}
brow_SetOpen
(
node
,
attrnav_mOpen_Children
);
brow_SetAnnotPixmap
(
node
,
0
,
attrnav
->
brow
->
pixmap_openmap
);
brow_ResetNodraw
(
attrnav
->
brow
->
ctx
);
brow_Redraw
(
attrnav
->
brow
->
ctx
,
node_y
);
}
return
1
;
}
profibus/lib/pb/src/pb_gsd_attrnav.h
deleted
100644 → 0
View file @
61ae9cef
/*
* Proview $Id: pb_gsd_attrnav.h,v 1.1 2006-03-22 14:38:11 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 pb_gsd_attrnav_h
#define pb_gsd_attrnav_h
/* pb_gsd_attrnav.h -- Profibus gsd configurator navigator */
#if defined __cplusplus
extern
"C"
{
#endif
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef glow_h
#include "glow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browapi.h"
#endif
#ifndef glow_growctx_h
#include "glow_growctx.h"
#endif
#ifndef glow_growapi_h
#include "glow_growapi.h"
#endif
#ifndef pb_gsd_atttr_h
#include "pb_gsd_attr.h"
#endif
typedef
enum
{
attrnav_eItemType_PbBase
,
attrnav_eItemType_PbEnum
,
attrnav_eItemType_PbEnumValue
,
attrnav_eItemType_PbModule
,
attrnav_eItemType_PbModuleType
,
attrnav_eItemType_PbModuleData
,
attrnav_eItemType_PbModuleClass
,
attrnav_eItemType_PbPrmData
,
attrnav_eItemType_PbMoreData
}
attrnav_eItemType
;
typedef
enum
{
attrnav_mOpen_All
=
~
0
,
attrnav_mOpen_Children
=
1
<<
0
,
attrnav_mOpen_Attributes
=
1
<<
1
}
attrnav_mOpen
;
class
ItemPb
;
//! Class for handling of brow.
class
GsdAttrNavBrow
{
public:
GsdAttrNavBrow
(
BrowCtx
*
brow_ctx
,
void
*
xn
)
:
ctx
(
brow_ctx
),
attrnav
(
xn
)
{};
~
GsdAttrNavBrow
();
BrowCtx
*
ctx
;
void
*
attrnav
;
brow_tNodeClass
nc_object
;
brow_tNodeClass
nc_attr
;
brow_tNodeClass
nc_attr_multiline
;
brow_tNodeClass
nc_table
;
brow_tNodeClass
nc_header
;
brow_tNodeClass
nc_table_header
;
brow_tNodeClass
nc_enum
;
flow_sAnnotPixmap
*
pixmap_leaf
;
flow_sAnnotPixmap
*
pixmap_map
;
flow_sAnnotPixmap
*
pixmap_openmap
;
flow_sAnnotPixmap
*
pixmap_attr
;
flow_sAnnotPixmap
*
pixmap_attrarray
;
flow_sAnnotPixmap
*
pixmap_attrenum
;
void
free_pixmaps
();
void
allocate_pixmaps
();
void
create_nodeclasses
();
void
brow_setup
();
};
//! The navigation area of the attribute editor.
class
GsdAttrNav
{
public:
GsdAttrNav
(
void
*
xn_parent_ctx
,
Widget
xn_parent_wid
,
char
*
xn_name
,
pb_gsd
*
xn_gsd
,
int
xn_edit_mode
,
Widget
*
w
,
pwr_tStatus
*
status
);
~
GsdAttrNav
();
void
*
parent_ctx
;
Widget
parent_wid
;
pb_gsd
*
gsd
;
char
name
[
80
];
Widget
brow_widget
;
Widget
form_widget
;
Widget
toplevel
;
GsdAttrNavBrow
*
brow
;
attr_sItem
*
itemlist
;
int
item_cnt
;
int
edit_mode
;
XtIntervalId
trace_timerid
;
int
trace_started
;
void
(
*
message_cb
)(
void
*
,
char
,
char
*
);
void
(
*
change_value_cb
)(
void
*
);
void
start_trace
(
pwr_tObjid
Objid
,
char
*
object_str
);
int
set_attr_value
(
char
*
value_str
);
int
check_attr_value
(
char
**
value
);
int
get_select
(
pwr_sAttrRef
*
attrref
,
int
*
is_attr
);
void
message
(
char
sev
,
char
*
text
);
void
set_inputfocus
();
void
force_trace_scan
();
int
object_attr
();
void
print
(
char
*
filename
);
int
get_select
(
ItemPb
**
item
);
void
zoom
(
double
zoom_factor
);
void
unzoom
();
void
get_zoom
(
double
*
zoom_factor
);
};
class
ItemPb
{
public:
ItemPb
()
:
parent
(
0
)
{}
attrnav_eItemType
type
;
brow_tNode
node
;
char
name
[
120
];
int
parent
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
)
{
return
1
;}
virtual
int
close
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for a normal attribute.
class
ItemPbBase
:
public
ItemPb
{
public:
ItemPbBase
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
double
attr_min_limit
,
double
attr_max_limit
,
void
*
attr_value_p
,
int
attr_noedit
,
gsd_sPrmText
*
attr_enumtext
,
brow_tNode
dest
,
flow_eDest
dest_code
);
void
*
value_p
;
char
old_value
[
80
];
int
first_scan
;
int
type_id
;
int
size
;
double
min_limit
;
double
max_limit
;
int
noedit
;
gsd_sPrmText
*
enumtext
;
int
subgraph
;
};
class
ItemPbEnum
:
public
ItemPbBase
{
public:
ItemPbEnum
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
char
*
attr
,
int
attr_type
,
int
attr_size
,
double
attr_min_limit
,
double
attr_max_limit
,
void
*
attr_value_p
,
int
attr_noedit
,
gsd_sPrmText
*
attr_enumtext
,
brow_tNode
dest
,
flow_eDest
dest_code
);
int
old_value
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for an enum attribute.
class
ItemPbEnumValue
:
public
ItemPb
{
public:
ItemPbEnumValue
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
int
item_num
,
int
item_type_id
,
void
*
attr_value_p
,
brow_tNode
dest
,
flow_eDest
dest_code
);
int
num
;
int
type_id
;
void
*
value_p
;
int
old_value
;
int
first_scan
;
};
//! Item for a module.
class
ItemPbModule
:
public
ItemPb
{
public:
ItemPbModule
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
);
gsd_sModuleConf
*
mconf
;
char
old_value
[
80
];
char
old_type
[
80
];
int
first_scan
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for module type selection.
class
ItemPbModuleType
:
public
ItemPb
{
public:
ItemPbModuleType
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
);
gsd_sModuleConf
*
mconf
;
int
old_value
;
int
first_scan
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for module type selection.
class
ItemPbModuleData
:
public
ItemPb
{
public:
ItemPbModuleData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
);
gsd_sModuleConf
*
mconf
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
void
update
(
GsdAttrNav
*
attrnav
);
};
//! Item for module class selection.
class
ItemPbModuleClass
:
public
ItemPb
{
public:
ItemPbModuleClass
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
gsd_sModuleConf
*
item_mconf
,
brow_tNode
dest
,
flow_eDest
dest_code
);
gsd_sModuleConf
*
mconf
;
int
old_value
;
int
first_scan
;
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for slave prmdata.
class
ItemPbPrmData
:
public
ItemPb
{
public:
ItemPbPrmData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
//! Item for slave prmdata.
class
ItemPbMoreData
:
public
ItemPb
{
public:
ItemPbMoreData
(
GsdAttrNav
*
attrnav
,
char
*
item_name
,
brow_tNode
dest
,
flow_eDest
dest_code
);
virtual
int
open_children
(
GsdAttrNav
*
attrnav
,
double
x
,
double
y
);
};
/*@}*/
#if defined __cplusplus
}
#endif
#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