Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
c8af77cb
Commit
c8af77cb
authored
Feb 17, 2015
by
Ludovic Apvrille
Browse files
Options
Downloads
Patches
Plain Diff
Adding ports to basic channels
parent
7c345c41
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
src/tmltranslator/TMLChannel.java
+39
-0
39 additions, 0 deletions
src/tmltranslator/TMLChannel.java
src/tmltranslator/TMLTextSpecification.java
+52
-37
52 additions, 37 deletions
src/tmltranslator/TMLTextSpecification.java
with
93 additions
and
39 deletions
Makefile
+
2
−
2
View file @
c8af77cb
...
...
@@ -100,7 +100,7 @@ myrelease: basic launcher ttooljar
basic
:
$(
JAVAC
)
$(
CLASSPATH
)
$(
TTOOL_SRC
)
$(
TTOOL_SRC
)
/
*
.java
jar
:
launcher ttooljar
jar
:
launcher ttooljar
tiftranslator tmltranslator rundse remotesimulator
ttooljar
:
rm
-f
$(
TTOOL_BIN
)
/
$(
TTOOL_BINARY
)
...
...
This diff is collapsed.
Click to expand it.
src/tmltranslator/TMLChannel.java
+
39
−
0
View file @
c8af77cb
...
...
@@ -60,6 +60,7 @@ public class TMLChannel extends TMLCommunicationElement {
// Used on for 1 -> 1 channel
protected
TMLTask
origin
,
destination
;
protected
TMLPort
originPort
,
destinationPort
;
// Not used by the simulator
// Used for 1 -> many channel, or for many -> 1 channel
protected
ArrayList
<
TMLTask
>
originTasks
,
destinationTasks
;
...
...
@@ -83,6 +84,31 @@ public class TMLChannel extends TMLCommunicationElement {
return
(
originTasks
.
size
()
==
0
);
}
public
boolean
isBadComplexChannel
()
{
if
((
originTasks
.
size
()
==
1
)
&&
(
destinationTasks
.
size
()
>=
1
))
{
return
false
;
}
if
((
destinationTasks
.
size
()
==
1
)
&&
(
originTasks
.
size
()
>=
1
))
{
return
false
;
}
return
true
;
}
public
void
toBasicIfPossible
()
{
if
((
originTasks
.
size
()
==
1
)
&&
(
destinationTasks
.
size
()
==
1
))
{
origin
=
originTasks
.
get
(
0
);
destination
=
destinationTasks
.
get
(
0
);
originPort
=
originPorts
.
get
(
0
);
destinationPort
=
destinationPorts
.
get
(
0
);
originTasks
=
new
ArrayList
<
TMLTask
>();
destinationTasks
=
new
ArrayList
<
TMLTask
>();
originPorts
=
new
ArrayList
<
TMLPort
>();
destinationPorts
=
new
ArrayList
<
TMLPort
>();
}
}
public
void
addTaskPort
(
TMLTask
_task
,
TMLPort
_port
,
boolean
isOrigin
)
{
if
(
isOrigin
)
{
originTasks
.
add
(
_task
);
...
...
@@ -118,6 +144,11 @@ public class TMLChannel extends TMLCommunicationElement {
destination
=
_destination
;
}
public
void
setPorts
(
TMLPort
_origin
,
TMLPort
_destination
)
{
originPort
=
_origin
;
destinationPort
=
_destination
;
}
public
TMLTask
getOriginTask
()
{
return
origin
;
}
...
...
@@ -126,6 +157,14 @@ public class TMLChannel extends TMLCommunicationElement {
return
destination
;
}
public
TMLPort
getOriginPort
()
{
return
originPort
;
}
public
TMLPort
getDestinationPort
()
{
return
destinationPort
;
}
public
void
setPriority
(
int
_priority
)
{
priority
=
_priority
;
}
...
...
This diff is collapsed.
Click to expand it.
src/tmltranslator/TMLTextSpecification.java
+
52
−
37
View file @
c8af77cb
...
...
@@ -658,18 +658,12 @@ public class TMLTextSpecification {
return
-
1
;
}
if
(!((
_split
.
length
>
5
)
&&
(
_split
.
length
<
8
)))
{
error
=
"A channel must be declared with
only 5 or 6 parameters
, and not "
+
(
_split
.
length
-
1
)
;
if
(!((
_split
.
length
<
9
)))
{
error
=
"A channel must be declared with
at least 7
, and not
:
"
+
(
_split
.
length
-
1
)
;
addError
(
0
,
_lineNb
,
0
,
error
);
return
-
1
;
}
if
(
_split
.
length
==
7
)
{
dec
=
1
;
}
else
{
dec
=
0
;
}
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
1
,
0
,
_lineNb
))
{
return
-
1
;
}
...
...
@@ -682,18 +676,33 @@ public class TMLTextSpecification {
return
-
1
;
}
if
(
_split
.
length
==
7
)
{
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
4
,
1
,
_lineNb
))
{
// Max nb of elements?
try
{
tmp
=
Integer
.
decode
(
_split
[
4
]).
intValue
();
dec
=
1
;
}
catch
(
Exception
e
)
{
dec
=
0
;
tmp
=
8
;}
TraceManager
.
addDev
(
"Checking OUT"
);
// "OUT" keyword?
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
4
+
dec
,
10
,
_lineNb
))
{
return
-
1
;
}
}
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
4
+
dec
,
0
,
_lineNb
))
{
TraceManager
.
addDev
(
"Checking other params of channels"
);
int
indexOfIN
=
-
1
;
for
(
i
=
5
+
dec
;
i
<
_split
.
length
;
i
++)
{
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
i
,
0
,
_lineNb
))
{
return
-
1
;
}
if
(
_split
[
i
].
compareTo
(
"IN"
)
==
0
)
{
indexOfIN
=
i
;
}
}
if
(!
checkParameter
(
"CHANNEL"
,
_split
,
5
+
dec
,
0
,
_lineNb
))
{
if
(
indexOfIN
==
-
1
)
{
error
=
"\"IN\" keyword is missing"
;
addError
(
0
,
_lineNb
,
0
,
error
);
return
-
1
;
}
...
...
@@ -713,28 +722,29 @@ public class TMLTextSpecification {
tmp
=
Integer
.
decode
(
_split
[
3
]).
intValue
();
}
catch
(
Exception
e
)
{
tmp
=
4
;}
ch
.
setSize
(
tmp
);
if
(
_split
.
length
==
7
)
{
try
{
tmp
=
Integer
.
decode
(
_split
[
4
]).
intValue
();
}
catch
(
Exception
e
)
{
tmp
=
8
;}
//TraceManager.addDev("Setting max to" + tmp);
ch
.
setMax
(
tmp
);
}
t1
=
tmlm
.
getTMLTaskByName
(
_split
[
4
+
dec
]);
for
(
i
=
5
+
dec
;
i
<
_split
.
length
;
i
++)
{
if
(
i
!=
indexOfIN
)
{
t1
=
tmlm
.
getTMLTaskByName
(
_split
[
i
]);
if
(
t1
==
null
)
{
t1
=
new
TMLTask
(
_split
[
4
+
dec
],
null
,
null
);
t1
=
new
TMLTask
(
_split
[
i
],
null
,
null
);
//TraceManager.addDev("New task:" + _split[4+dec]);
tmlm
.
addTask
(
t1
);
}
t2
=
tmlm
.
getTMLTaskByName
(
_split
[
5
+
dec
]);
if
(
t2
==
null
)
{
t2
=
new
TMLTask
(
_split
[
5
+
dec
],
null
,
null
);
//TraceManager.addDev("New task:" + _split[5+dec]);
tmlm
.
addTask
(
t2
);
ch
.
addTaskPort
(
t1
,
null
,
(
i
<
indexOfIN
));
}
}
ch
.
toBasicIfPossible
();
if
(!(
ch
.
isBasicChannel
()))
{
if
(
ch
.
isBadComplexChannel
())
{
error
=
"A complex channel must be \"1 -> many\" of \"many -> 1\""
;
addError
(
0
,
_lineNb
,
0
,
error
);
return
-
1
;
}
}
ch
.
setTasks
(
t1
,
t2
);
tmlm
.
addChannel
(
ch
);
}
// CHANNEL
...
...
@@ -2436,6 +2446,11 @@ public class TMLTextSpecification {
err
=
true
;
}
break
;
case
10
:
if
(!(
_split
[
_parameter
].
compareTo
(
"OUT"
)
==
0
))
{
err
=
true
;
}
break
;
}
}
else
{
err
=
true
;
...
...
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
sign in
to comment