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
6d05efa7
Commit
6d05efa7
authored
May 08, 2009
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Input and output area length added to datafile
parent
052a024d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
233 additions
and
4 deletions
+233
-4
profibus/lib/rt/src/rt_pn_gsdml.cpp
profibus/lib/rt/src/rt_pn_gsdml.cpp
+46
-0
profibus/lib/rt/src/rt_pn_gsdml.h
profibus/lib/rt/src/rt_pn_gsdml.h
+1
-0
profibus/lib/rt/src/rt_pn_gsdml_attrnav.cpp
profibus/lib/rt/src/rt_pn_gsdml_attrnav.cpp
+171
-2
profibus/lib/rt/src/rt_pn_gsdml_data.cpp
profibus/lib/rt/src/rt_pn_gsdml_data.cpp
+10
-1
profibus/lib/rt/src/rt_pn_gsdml_data.h
profibus/lib/rt/src/rt_pn_gsdml_data.h
+5
-1
No files found.
profibus/lib/rt/src/rt_pn_gsdml.cpp
View file @
6d05efa7
...
...
@@ -1862,6 +1862,52 @@ int pn_gsdml::string_to_datavalue( gsdml_eValueDataType datatype, void *value,
return
1
;
}
//
// Get the length of an IO type specified in a data item
//
int
pn_gsdml
::
get_datavalue_length
(
gsdml_eValueDataType
datatype
,
int
strlength
,
unsigned
int
*
len
)
{
switch
(
datatype
)
{
case
gsdml_eValueDataType_Integer8
:
case
gsdml_eValueDataType_Unsigned8
:
*
len
=
1
;
break
;
case
gsdml_eValueDataType_Integer16
:
case
gsdml_eValueDataType_Unsigned16
:
*
len
=
2
;
break
;
case
gsdml_eValueDataType_Integer32
:
case
gsdml_eValueDataType_Unsigned32
:
case
gsdml_eValueDataType_Float32
:
*
len
=
4
;
break
;
case
gsdml_eValueDataType_Integer64
:
case
gsdml_eValueDataType_Unsigned64
:
case
gsdml_eValueDataType_Float64
:
*
len
=
8
;
break
;
case
gsdml_eValueDataType_VisibleString
:
case
gsdml_eValueDataType_OctetString
:
*
len
=
strlength
;
break
;
case
gsdml_eValueDataType_Date
:
case
gsdml_eValueDataType_TimeOfDayWithDate
:
case
gsdml_eValueDataType_TimeOfDayWithoutDate
:
case
gsdml_eValueDataType_TimeDiffWithDate
:
case
gsdml_eValueDataType_TimeDiffWithoutDate
:
case
gsdml_eValueDataType_NetworkTime
:
case
gsdml_eValueDataType_NetworkTimeDiff
:
// TODO
return
PB__NYI
;
*
len
=
0
;
break
;
default:
return
PB__NYI
;
*
len
=
0
;
}
return
PB__SUCCESS
;
}
int
pn_gsdml
::
set_default_values
(
gsdml_eTag
id
,
void
*
data
,
unsigned
int
size
)
{
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
attrlist
)
/
sizeof
(
attrlist
[
0
]);
i
++
)
{
...
...
profibus/lib/rt/src/rt_pn_gsdml.h
View file @
6d05efa7
...
...
@@ -1466,6 +1466,7 @@ class pn_gsdml {
unsigned
int
size
,
char
*
str
,
unsigned
int
strsize
);
int
string_to_datavalue
(
gsdml_eValueDataType
datatype
,
void
*
value
,
unsigned
int
size
,
char
*
str
);
int
get_datavalue_length
(
gsdml_eValueDataType
datatype
,
int
strlength
,
unsigned
int
*
len
);
void
set_classes
(
gsdml_sModuleClass
*
mclist
)
{
module_classlist
=
mclist
;}
int
set_par_record_default
(
unsigned
char
*
data
,
int
size
,
gsdml_ParameterRecordDataItem
*
par_record
);
...
...
profibus/lib/rt/src/rt_pn_gsdml_attrnav.cpp
View file @
6d05efa7
...
...
@@ -1345,6 +1345,7 @@ int GsdmlAttrNav::init_brow_cb( FlowCtx *fctx, void *client_data)
int
GsdmlAttrNav
::
save
(
const
char
*
filename
)
{
int
sts
;
dev_data
.
device_num
=
device_num
;
...
...
@@ -1389,12 +1390,154 @@ int GsdmlAttrNav::save( const char *filename)
cd
->
error_type
=
gsdml
->
ApplicationProcess
->
ChannelDiagList
->
ChannelDiagItem
[
i
]
->
Body
.
ErrorType
;
strncpy
(
cd
->
name
,
(
char
*
)
gsdml
->
ApplicationProcess
->
ChannelDiagList
->
ChannelDiagItem
[
i
]
->
Body
.
Name
.
p
,
sizeof
(
cd
->
name
));
strncpy
(
cd
->
help
,
(
char
*
)
gsdml
->
ApplicationProcess
->
ChannelDiagList
->
ChannelDiagItem
[
i
]
->
Body
.
Help
.
p
,
sizeof
(
cd
->
help
));
if
(
gsdml
->
ApplicationProcess
->
ChannelDiagList
->
ChannelDiagItem
[
i
]
->
Body
.
Help
.
p
)
strncpy
(
cd
->
help
,
(
char
*
)
gsdml
->
ApplicationProcess
->
ChannelDiagList
->
ChannelDiagItem
[
i
]
->
Body
.
Help
.
p
,
sizeof
(
cd
->
help
));
dev_data
.
channel_diag
.
push_back
(
cd
);
}
}
// Calculate subslot IO length
for
(
unsigned
int
i
=
0
;
i
<
dev_data
.
slot_data
.
size
();
i
++
)
{
if
(
i
==
0
)
{
// Device access point
gsdml_DeviceAccessPointItem
*
mi
=
device_item
;
for
(
unsigned
int
j
=
0
;
j
<
dev_data
.
slot_data
[
i
]
->
subslot_data
.
size
();
j
++
)
{
GsdmlSubslotData
*
ssd
=
dev_data
.
slot_data
[
i
]
->
subslot_data
[
j
];
ssd
->
io_input_length
=
0
;
ssd
->
io_output_length
=
0
;
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
()
==
0
)
continue
;
gsdml_VirtualSubmoduleItem
*
vsd
=
0
;
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
()
==
1
)
vsd
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
0
];
else
{
for
(
unsigned
int
k
=
0
;
k
<
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
();
k
++
)
{
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
k
]
->
Body
.
SubmoduleIdentNumber
==
ssd
->
submodule_ident_number
)
{
vsd
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
k
];
break
;
}
}
}
if
(
!
vsd
)
{
continue
;
}
if
(
!
vsd
->
IOData
)
continue
;
if
(
vsd
->
IOData
->
Input
)
{
for
(
unsigned
k
=
0
;
k
<
vsd
->
IOData
->
Input
->
DataItem
.
size
();
k
++
)
{
gsdml_DataItem
*
di
=
vsd
->
IOData
->
Input
->
DataItem
[
k
];
gsdml_eValueDataType
datatype
;
gsdml
->
string_to_value_datatype
(
di
->
Body
.
DataType
,
&
datatype
);
unsigned
int
len
;
sts
=
gsdml
->
get_datavalue_length
(
datatype
,
di
->
Body
.
Length
,
&
len
);
if
(
EVEN
(
sts
))
printf
(
"GSDML-Error, Datatype %s not yet implemented
\n
"
,
di
->
Body
.
DataType
);
ssd
->
io_input_length
+=
len
;
}
}
if
(
vsd
->
IOData
->
Output
)
{
for
(
unsigned
k
=
0
;
k
<
vsd
->
IOData
->
Output
->
DataItem
.
size
();
k
++
)
{
gsdml_DataItem
*
di
=
vsd
->
IOData
->
Output
->
DataItem
[
k
];
gsdml_eValueDataType
datatype
;
gsdml
->
string_to_value_datatype
(
di
->
Body
.
DataType
,
&
datatype
);
unsigned
int
len
;
sts
=
gsdml
->
get_datavalue_length
(
datatype
,
di
->
Body
.
Length
,
&
len
);
if
(
EVEN
(
sts
))
printf
(
"GSDML-Error, Datatype %s not yet implemented
\n
"
,
di
->
Body
.
DataType
);
ssd
->
io_output_length
+=
len
;
}
}
}
}
else
{
if
(
dev_data
.
slot_data
[
i
]
->
module_enum_number
==
0
)
continue
;
gsdml_UseableModules
*
um
=
device_item
->
UseableModules
;
if
(
!
um
)
continue
;
gsdml_ModuleItem
*
mi
=
(
gsdml_ModuleItem
*
)
um
->
ModuleItemRef
[
dev_data
.
slot_data
[
i
]
->
module_enum_number
-
1
]
->
Body
.
ModuleItemTarget
.
p
;
for
(
unsigned
int
j
=
0
;
j
<
dev_data
.
slot_data
[
i
]
->
subslot_data
.
size
();
j
++
)
{
GsdmlSubslotData
*
ssd
=
dev_data
.
slot_data
[
i
]
->
subslot_data
[
j
];
ssd
->
io_input_length
=
0
;
ssd
->
io_output_length
=
0
;
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
()
==
0
)
continue
;
gsdml_VirtualSubmoduleItem
*
vsd
=
0
;
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
()
==
1
)
vsd
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
0
];
else
{
for
(
unsigned
int
k
=
0
;
k
<
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
.
size
();
k
++
)
{
if
(
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
k
]
->
Body
.
SubmoduleIdentNumber
==
ssd
->
submodule_ident_number
)
{
vsd
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
k
];
break
;
}
}
}
if
(
!
vsd
)
{
printf
(
"GSDML-Error, subslot number not found
\n
"
);
continue
;
}
if
(
!
vsd
->
IOData
)
continue
;
if
(
vsd
->
IOData
->
Input
)
{
for
(
unsigned
k
=
0
;
k
<
vsd
->
IOData
->
Input
->
DataItem
.
size
();
k
++
)
{
gsdml_DataItem
*
di
=
vsd
->
IOData
->
Input
->
DataItem
[
k
];
gsdml_eValueDataType
datatype
;
gsdml
->
string_to_value_datatype
(
di
->
Body
.
DataType
,
&
datatype
);
unsigned
int
len
;
sts
=
gsdml
->
get_datavalue_length
(
datatype
,
di
->
Body
.
Length
,
&
len
);
if
(
EVEN
(
sts
))
printf
(
"GSDML-Error, Datatype %s not yet implemented
\n
"
,
di
->
Body
.
DataType
);
ssd
->
io_input_length
+=
len
;
}
}
if
(
vsd
->
IOData
->
Output
)
{
for
(
unsigned
k
=
0
;
k
<
vsd
->
IOData
->
Output
->
DataItem
.
size
();
k
++
)
{
gsdml_DataItem
*
di
=
vsd
->
IOData
->
Output
->
DataItem
[
k
];
gsdml_eValueDataType
datatype
;
gsdml
->
string_to_value_datatype
(
di
->
Body
.
DataType
,
&
datatype
);
unsigned
int
len
;
sts
=
gsdml
->
get_datavalue_length
(
datatype
,
di
->
Body
.
Length
,
&
len
);
if
(
EVEN
(
sts
))
printf
(
"GSDML-Error, Datatype %s not yet implemented
\n
"
,
di
->
Body
.
DataType
);
ssd
->
io_output_length
+=
len
;
}
}
}
}
}
return
dev_data
.
print
(
filename
);
// Unload channel diag
...
...
@@ -1780,12 +1923,17 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
subslot_number
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
subslot_number
)
{
ssd
->
subslot_number
=
subslot_number
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
@@ -1811,12 +1959,17 @@ int ItemPnSlot::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
subslot_number
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
subslot_number
)
{
ssd
->
subslot_number
=
subslot_number
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
@@ -2020,12 +2173,17 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
subslot_number
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
subslot_number
)
{
ssd
->
subslot_number
=
subslot_number
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
@@ -2052,12 +2210,17 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
subslot_number
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
mi
->
VirtualSubmoduleList
->
VirtualSubmoduleItem
[
i
]
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
subslot_number
)
{
ssd
->
subslot_number
=
subslot_number
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
@@ -2093,12 +2256,15 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
ii
->
Body
.
SubslotNumber
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
ii
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
ii
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
ii
->
Body
.
SubslotNumber
)
{
ssd
->
subslot_number
=
ii
->
Body
.
SubslotNumber
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
@@ -2126,12 +2292,15 @@ int ItemPnDAP::open_children( GsdmlAttrNav *attrnav, double x, double y)
ssd
=
new
GsdmlSubslotData
();
ssd
->
subslot_number
=
pi
->
Body
.
SubslotNumber
;
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
pi
->
Body
.
SubmoduleIdentNumber
;
slotdata
->
subslot_data
.
push_back
(
ssd
);
}
else
{
ssd
=
slotdata
->
subslot_data
[
subslot_index
];
ssd
->
subslot_idx
=
subslot_index
;
ssd
->
submodule_ident_number
=
pi
->
Body
.
SubmoduleIdentNumber
;
if
(
ssd
->
subslot_number
!=
pi
->
Body
.
SubslotNumber
)
{
ssd
->
subslot_number
=
pi
->
Body
.
SubslotNumber
;
printf
(
"GSML-Error, datafile corrupt, unexpected subslot number
\n
"
);
}
}
...
...
profibus/lib/rt/src/rt_pn_gsdml_data.cpp
View file @
6d05efa7
...
...
@@ -74,7 +74,10 @@ int GsdmlDataRecord::print( ofstream& fp)
int
GsdmlSubslotData
::
print
(
ofstream
&
fp
)
{
fp
<<
" <Subslot SubslotNumber=
\"
"
<<
subslot_number
<<
"
\"
>"
<<
endl
;
" <Subslot SubslotNumber=
\"
"
<<
subslot_number
<<
"
\"
"
<<
endl
<<
" SubmoduleIdentNumber=
\"
"
<<
submodule_ident_number
<<
"
\"
"
<<
endl
<<
" IOInputLength=
\"
"
<<
io_input_length
<<
"
\"
"
<<
endl
<<
" IOOutputLength=
\"
"
<<
io_output_length
<<
"
\"
>"
<<
endl
;
for
(
unsigned
int
i
=
0
;
i
<
data_record
.
size
();
i
++
)
{
data_record
[
i
]
->
print
(
fp
);
...
...
@@ -431,6 +434,12 @@ int GsdmlDataReader::tag_attribute( const char *name, const char *value)
if
(
strcmp
(
name
,
"SubslotNumber"
)
==
0
)
sscanf
(
value
,
"%u"
,
&
sd
->
subslot_number
);
else
if
(
strcmp
(
name
,
"SubmoduleIdentNumber"
)
==
0
)
sscanf
(
value
,
"%u"
,
&
sd
->
submodule_ident_number
);
else
if
(
strcmp
(
name
,
"IOInputLength"
)
==
0
)
sscanf
(
value
,
"%u"
,
&
sd
->
io_input_length
);
else
if
(
strcmp
(
name
,
"IOOutputLength"
)
==
0
)
sscanf
(
value
,
"%u"
,
&
sd
->
io_output_length
);
break
;
}
case
gsdmldata_eTag_DataRecord
:
{
...
...
profibus/lib/rt/src/rt_pn_gsdml_data.h
View file @
6d05efa7
...
...
@@ -64,11 +64,15 @@ class GsdmlIOCRData {
class
GsdmlSubslotData
{
public:
GsdmlSubslotData
()
:
subslot_number
(
0
),
subslot_idx
(
0
)
{}
GsdmlSubslotData
()
:
subslot_number
(
0
),
subslot_idx
(
0
),
submodule_ident_number
(
0
),
io_input_length
(
0
),
io_output_length
(
0
)
{}
vector
<
GsdmlDataRecord
*>
data_record
;
unsigned
int
subslot_number
;
unsigned
int
subslot_idx
;
unsigned
int
submodule_ident_number
;
unsigned
int
io_input_length
;
unsigned
int
io_output_length
;
~
GsdmlSubslotData
()
{
for
(
unsigned
int
i
=
0
;
i
<
data_record
.
size
();
i
++
)
...
...
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