Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SCDDS-core
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
SCDDS
SCDDS-core
Commits
188a9625
Commit
188a9625
authored
2 years ago
by
Cristian Galperti
Browse files
Options
Downloads
Patches
Plain Diff
bus2marte2cfg file output switch added
parent
fadd630a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
functions/marte2cfg/bus2marte2cfg.m
+8
-7
8 additions, 7 deletions
functions/marte2cfg/bus2marte2cfg.m
functions/marte2cfg/bus2marte2cfg_test.m
+1
-1
1 addition, 1 deletion
functions/marte2cfg/bus2marte2cfg_test.m
with
9 additions
and
8 deletions
functions/marte2cfg/bus2marte2cfg.m
+
8
−
7
View file @
188a9625
function
[
signallist
]
=
bus2marte2cfg
(
bus
,
name
,
datasourcename
,
varargin
)
function
[
signallist
]
=
bus2marte2cfg
(
bus
,
name
,
datasourcename
,
fid
,
varargin
)
%Translates a simulink bus object into MARTe2 cfg description
% This function takes a Simuink.Bus object
% as input and prints out its MARTe2 configuration
...
...
@@ -6,9 +6,10 @@ function [signallist] = bus2marte2cfg(bus, name, datasourcename, varargin)
% Inputs:
% bus: the Simulink.Bus object to be analyzed
% name: its root name
% datasourcename: name of the datasource to insert
% fid: target fid for fprintf (fopen result or 1 for screen output)
if
nargin
<=
3
if
nargin
<=
4
assert
(
isa
(
bus
,
'Simulink.Bus'
),
'bus must be a Simulink.Bus object'
);
depth
=
0
;
assignin
(
'base'
,
'tempbus'
,
bus
);
...
...
@@ -27,23 +28,23 @@ for ii=1:depth, spacer=[spacer ' ']; end
if
isa
(
busstruct
,
'struct'
)
% called on a bus, scan into
fprintf
(
"%s%s={\n"
,
spacer
,
name
);
fprintf
(
fid
,
"%s%s={\n"
,
spacer
,
name
);
f
=
fields
(
busstruct
);
for
ii
=
1
:
numel
(
f
)
if
isa
(
busstruct
.
(
f
{
ii
}),
'struct'
)
signallist
=
bus2marte2cfg
(
busstruct
.
(
f
{
ii
}),
f
{
ii
},
datasourcename
,
depth
+
1
,[
basealiasname
'-'
f
{
ii
}],
signallist
);
signallist
=
bus2marte2cfg
(
busstruct
.
(
f
{
ii
}),
f
{
ii
},
datasourcename
,
fid
,
depth
+
1
,[
basealiasname
'-'
f
{
ii
}],
signallist
);
else
martetype
=
type2marte2
(
busstruct
.
(
f
{
ii
}));
martedims
=
dims2marte2
(
busstruct
.
(
f
{
ii
}));
marteelems
=
elems2marte2
(
busstruct
.
(
f
{
ii
}));
fprintf
(
"%s %s = { Type = %s NumberOfDimensions = %d NumberOfElements = %d DataSource = %s Alias = %s }\n"
,
...
fprintf
(
fid
,
"%s %s = { Type = %s NumberOfDimensions = %d NumberOfElements = %d DataSource = %s Alias = %s }\n"
,
...
spacer
,
f
{
ii
},
martetype
,
martedims
,
marteelems
,
datasourcename
,
...
[
basealiasname
'-'
f
{
ii
}]);
signalinfo
=
{{[
basealiasname
'-'
f
{
ii
}]}
{
martetype
}
{
martedims
}
{
marteelems
}
{
f
{
ii
}}};
signallist
{
end
+
1
}
=
signalinfo
;
end
end
fprintf
(
"%s}\n"
,
spacer
);
fprintf
(
fid
,
"%s}\n"
,
spacer
);
else
error
(
'SCDDScore:bus2marte2cfg'
,
'Wrong input datatype in bus parsing'
);
end
...
...
This diff is collapsed.
Click to expand it.
functions/marte2cfg/bus2marte2cfg_test.m
+
1
−
1
View file @
188a9625
...
...
@@ -27,4 +27,4 @@ busInfo=Simulink.Bus.createObject(genstruct);
testbus
=
eval
(
busInfo
.
busName
);
% Function call
bus2marte2cfg
(
testbus
,
'rootbus'
,
'DDB1'
);
bus2marte2cfg
(
testbus
,
'rootbus'
,
'DDB1'
,
1
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment