Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse ESCET (Supervisory Control Engineering Toolkit)
escet
Commits
1041d130
Commit
1041d130
authored
May 17, 2022
by
Albert Hofkamp
Browse files
#368
Generate the first column text from the dependency matrixx data as well and clean up.
parent
c7cfea9f
Pipeline
#4132
failed with stage
in 0 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cif/org.eclipse.escet.cif.cif2dsm/src/org/eclipse/escet/cif/cif2dsm/Cif2DsmCore.java
View file @
1041d130
...
...
@@ -20,7 +20,6 @@ import static org.eclipse.escet.cif.common.CifInvariantUtils.getSupKind;
import
static
org
.
eclipse
.
escet
.
cif
.
metamodel
.
cif
.
SupKind
.
PLANT
;
import
static
org
.
eclipse
.
escet
.
cif
.
metamodel
.
cif
.
SupKind
.
REQUIREMENT
;
import
static
org
.
eclipse
.
escet
.
common
.
java
.
Lists
.
list
;
import
static
org
.
eclipse
.
escet
.
common
.
java
.
Lists
.
listc
;
import
static
org
.
eclipse
.
escet
.
common
.
java
.
Maps
.
mapc
;
import
java.util.BitSet
;
...
...
@@ -41,12 +40,6 @@ import org.eclipse.escet.common.box.MemoryCodeBox;
/** Class for creating the DSM from a CIF specification. */
public
class
Cif2DsmCore
{
/** Prefix added to plant automaton names in the DSM output. */
public
static
final
String
PLANT_AUT_PREFIX
=
"G"
;
/** Prefix added to plant input variable names in the DSM output. */
public
static
final
String
PLANT_INPUT_VAR_PREFIX
=
"V"
;
/** Constructor of the {@link Cif2DsmCore} class. */
private
Cif2DsmCore
()
{
// Static class.
...
...
@@ -92,10 +85,9 @@ public class Cif2DsmCore {
// Collect input variables.
List
<
InputVariable
>
inputVars
=
collectInputVariables
(
spec
,
list
());
// Perform calculations to determine the specification structure while also collecting data to write to the
// output.
int
numDataColumns
=
reqAuts
.
size
()
+
reqInvs
.
size
();
if
(
AppEnv
.
isTerminationRequested
())
{
return
;
}
// Construct the collection of independent groups of plant automata, not sharing events, used locations,
// and variables.
...
...
@@ -126,9 +118,6 @@ public class Cif2DsmCore {
return
;
}
// Names of the elements in the first column.
List
<
String
>
firstColumn
=
listc
(
productSystems
.
size
()
+
inputVars
.
size
());
// In case of an undirected DSM, {@code directedLines} will not be used. In case of directed DSMs,
// {@code lines} will be used to create the event dependencies, and {@code directedLines} the condition
// dependencies.
...
...
@@ -149,9 +138,6 @@ public class Cif2DsmCore {
for
(
int
row
=
0
;
row
<
productSystems
.
size
();
row
++)
{
ProductSystem
prodSys
=
productSystems
.
get
(
row
);
// Add the name of the line.
firstColumn
.
add
(
PLANT_AUT_PREFIX
+
String
.
valueOf
(
row
+
1
));
// Check intersection of the product system with requirement automata.
BitSet
autLine
=
lineRels
.
topLeft
.
getRelationRow
(
row
);
// directedAutLine is 0 since with directed DSMs the pre-checker ensures forbids requirement automata.
...
...
@@ -163,9 +149,9 @@ public class Cif2DsmCore {
column
++;
}
// Check intersection of the product system with requirement invariants.
autLine
=
lineRels
.
topRight
.
getRelationRow
(
row
);
BitSet
directedAutLine
=
directedLineRels
.
topRight
.
getRelationRow
(
row
);
// Check intersection of the product system with requirement invariants.
column
=
0
;
for
(
Invariant
inv:
reqInvs
)
{
RequirementInvariantElements
reqInvData
=
reqInvDatas
.
get
(
inv
);
...
...
@@ -189,14 +175,10 @@ public class Cif2DsmCore {
return
;
}
// Second, go over the input variables and compute their relation with all requirement automata and requirement
// invariants.
// Second, go over the input variables and compute their relation with all requirement automata.
for
(
int
row
=
0
;
row
<
inputVars
.
size
();
row
++)
{
InputVariable
iv
=
inputVars
.
get
(
row
);
// Add the name of the line.
firstColumn
.
add
(
PLANT_INPUT_VAR_PREFIX
+
CifTextUtils
.
getAbsName
(
iv
));
// In case of an undirected DSM, {@code directedLine} will not be used. In case of directed DSMs,
// {@code line} will be used to create the event dependencies, and {@code lineDir} the condition
// dependencies.
...
...
@@ -209,6 +191,7 @@ public class Cif2DsmCore {
column
++;
}
// Compute relations with requirement invariants as well.
inpVarLine
=
lineRels
.
bottomRight
.
getRelationRow
(
row
);
BitSet
directedinpVarLine
=
directedLineRels
.
bottomRight
.
getRelationRow
(
row
);
column
=
0
;
...
...
@@ -228,16 +211,17 @@ public class Cif2DsmCore {
// Generate output.
outDsmFilename
=
Paths
.
resolve
(
outDsmFilename
);
if
(
directed
)
{
MemoryCodeBox
fileLines
=
makeFileLines
(
firstColumn
,
lineRels
,
numDataColumn
s
);
MemoryCodeBox
fileLines
=
makeFileLines
(
lineRel
s
);
fileLines
.
writeToFile
(
outDsmFilename
.
replace
(
".txt"
,
"_EventDeps.txt"
));
fileLines
=
makeFileLines
(
firstColumn
,
directedLineRels
,
numDataColumns
);
fileLines
=
makeFileLines
(
directedLineRels
);
fileLines
.
writeToFile
(
outDsmFilename
.
replace
(
".txt"
,
"_ConditionDeps.txt"
));
}
else
{
MemoryCodeBox
fileLines
=
makeFileLines
(
firstColumn
,
lineRels
,
numDataColumn
s
);
MemoryCodeBox
fileLines
=
makeFileLines
(
lineRel
s
);
fileLines
.
writeToFile
(
outDsmFilename
);
}
// Write the product systems file containing the automata of each most refiened product system.
CodeBox
lines2
=
transformProdSysMap
(
productSystems
);
outProdSysFilename
=
Paths
.
resolve
(
outProdSysFilename
);
lines2
.
writeToFile
(
outProdSysFilename
);
...
...
@@ -258,7 +242,6 @@ public class Cif2DsmCore {
}
// Compute the collection of most refined product systems.
//
List
<
ProductSystem
>
productSystems
=
list
();
for
(
Entry
<
Automaton
,
PlantAutomatonElements
>
entry:
plantAutDatas
.
entrySet
())
{
Automaton
plant
=
entry
.
getKey
();
...
...
@@ -292,21 +275,16 @@ public class Cif2DsmCore {
/**
* Construct textual version of the generated relations.
*
* @param firstColumn First column with names of the rows.
* @param depMat Dependency matrix indicating relations between the rows and the columns.
* @param numDataColumns Number of columns with 0/1 data.
* @return The constructed textual version of the data.
*/
private
static
MemoryCodeBox
makeFileLines
(
List
<
String
>
firstColumn
,
DependencyMatrix
depMat
,
int
numDataColumns
)
{
private
static
MemoryCodeBox
makeFileLines
(
DependencyMatrix
depMat
)
{
MemoryCodeBox
fileLines
=
new
MemoryCodeBox
();
fileLines
.
add
(
depMat
.
makeFirstLine
());
// Add all rows, with a different value from firstColumn for each row.
for
(
int
row
=
0
;
row
<
firstColumn
.
size
();
row
++)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
firstColumn
.
get
(
row
));
depMat
.
writeRelations
(
sb
,
row
);
fileLines
.
add
(
sb
.
toString
());
for
(
int
row
=
0
;
row
<
depMat
.
getNumRows
();
row
++)
{
fileLines
.
add
(
depMat
.
makeMatrixRow
(
row
));
}
return
fileLines
;
}
...
...
cif/org.eclipse.escet.cif.cif2dsm/src/org/eclipse/escet/cif/cif2dsm/DependencyMatrix.java
View file @
1041d130
...
...
@@ -23,6 +23,12 @@ import org.eclipse.escet.common.java.Assert;
/** Dependency matrix. */
public
class
DependencyMatrix
{
/** Prefix added to plant automaton names in the DSM output. */
public
static
final
String
PLANT_AUT_PREFIX
=
"G"
;
/** Prefix added to plant input variable names in the DSM output. */
public
static
final
String
PLANT_INPUT_VAR_PREFIX
=
"V"
;
/** Top-left part of the matrix, dependencies between product systems and requirement automata. */
public
final
DependencyMatrixPart
<
ProductSystem
,
Automaton
>
topLeft
;
...
...
@@ -52,6 +58,24 @@ public class DependencyMatrix {
bottomRight
=
new
DependencyMatrixPart
<>(
inputVars
,
reqInvs
);
}
/**
* Get the number of columns in the matrix.
*
* @return Number of columns in the matrix.
*/
public
int
getNumColumns
()
{
return
topLeft
.
columnData
.
size
()
+
topRight
.
columnData
.
size
();
}
/**
* Get the number of rows in the matrix.
*
* @return Number of rows in the matrix.
*/
public
int
getNumRows
()
{
return
topLeft
.
rowData
.
size
()
+
bottomLeft
.
rowData
.
size
();
}
/**
* Construct a header line for the dependency matrix.
*
...
...
@@ -76,27 +100,29 @@ public class DependencyMatrix {
}
/**
* Write a line of relations into the provided buffer.
*
* <p>
* First character written is a {@code ','}.
* </p>
* Construct a text line describing the relations at the given row.
*
* @param
strBuffer Buffer to write into
.
* @
param row Number of the row to writ
e.
* @param
row Number of the row to create
.
* @
return The constructed text lin
e.
*/
public
void
writeRelations
(
StringBuilder
strBuffer
,
int
row
)
{
public
String
makeMatrixRow
(
int
row
)
{
Assert
.
check
(
row
>=
0
);
StringBuilder
strBuffer
=
new
StringBuilder
();
if
(
row
<
topLeft
.
rowData
.
size
())
{
strBuffer
.
append
(
PLANT_AUT_PREFIX
+
String
.
valueOf
(
row
+
1
));
topLeft
.
writeRelations
(
strBuffer
,
row
);
topRight
.
writeRelations
(
strBuffer
,
row
);
return
;
return
strBuffer
.
toString
()
;
}
row
-=
topLeft
.
rowData
.
size
();
Assert
.
check
(
row
<
bottomLeft
.
rowData
.
size
());
InputVariable
inputVar
=
bottomLeft
.
rowData
.
get
(
row
);
strBuffer
.
append
(
PLANT_INPUT_VAR_PREFIX
+
CifTextUtils
.
getAbsName
(
inputVar
));
bottomLeft
.
writeRelations
(
strBuffer
,
row
);
bottomRight
.
writeRelations
(
strBuffer
,
row
);
return
strBuffer
.
toString
();
}
}
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