Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
af3
AF3
Commits
2e2846fd
Commit
2e2846fd
authored
Sep 09, 2019
by
Simon Barner
Browse files
Merge branch 'master' of
https://git.fortiss.org/af3/af3.git
into 3746
parents
3a8263c2
d15e4f62
Changes
13
Hide whitespace changes
Inline
Side-by-side
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/UtilizationPatternGUI.java
View file @
2e2846fd
...
...
@@ -51,7 +51,7 @@ public class UtilizationPatternGUI extends Composite {
super
(
parent
,
style
);
setLayout
(
new
GridLayout
(
1
,
false
));
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
);
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
,
"UtilizationPattern"
);
header
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
,
1
,
1
));
header
.
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/.ratings
View file @
2e2846fd
AllocationPatternCompositeBackend.java
3ce29c907932fd803e3ef977a91008edef63289a
GREEN
ConstraintPatternHeader.java
6e6b46562953f3490ff3beeaa446d169a366cb48
GREEN
AllocationPatternCompositeBackend.java
e5ff1026f9d8f6116d638842d2a92bfb08555e32
GREEN
ConstraintPatternHeader.java
3f0b194738c36b3b666a74cb988660938e67e4f3
GREEN
ConstraintViewBackend.java 4099a405a81ccdf05e3f517d6b1de3f2f2b2d926 GREEN
FunctionCouplingCompositeBackend.java
7a60b7b73ae0330bc24c310b8167c515c6942fed
GREEN
FunctionCouplingCompositeBackend.java
e5b7cabaa3535d500b9f3171cb4eccdb46548e06
GREEN
MemoryPatternBackend.java c452fa46dce1d8646a60ba48ee7bcdd2b39debd7 GREEN
SafetyPatternBackend.java bfb2d61e387f33cdff9270978253868d50308b43 GREEN
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/AllocationPatternCompositeBackend.java
View file @
2e2846fd
...
...
@@ -15,14 +15,13 @@
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.exploration.ui.perspective.targetdef.constraint
;
import
static
java
.
util
.
stream
.
Collectors
.
joining
;
import
static
org
.
fortiss
.
af3
.
exploration
.
smt
.
util
.
Z3ModelElementFactory
.
createSMTConstraint
;
import
static
org
.
fortiss
.
af3
.
exploration
.
ui
.
perspective
.
service
.
IEventListener
.
DSE_EVENT
.
DSE_REMOVED_EVENT
;
import
static
org
.
fortiss
.
af3
.
exploration
.
ui
.
perspective
.
service
.
IEventListener
.
DSE_EVENT
.
DSE_SELECTED_EVENT
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
PatternFactoryUtils
.
calcPatternName
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
EcoreUtils
.
pickInstanceOf
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
org.eclipse.jface.viewers.ISelectionChangedListener
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
...
...
@@ -43,7 +42,6 @@ import org.fortiss.af3.exploration.util.PatternFactoryUtils;
import
org.fortiss.af3.platform.model.ExecutionUnit
;
import
org.fortiss.af3.task.model.Task
;
import
org.fortiss.tooling.base.model.element.IModelElement
;
import
org.fortiss.tooling.kernel.model.INamedElement
;
import
org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider
;
/**
...
...
@@ -55,16 +53,10 @@ import org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider;
public
class
AllocationPatternCompositeBackend
extends
AllocationPatternCompositeGUI
implements
IEventListener
{
/** The left set of element(s). allocation source. */
private
Set
<
IModelElement
>
taskSet
;
/** The right set of element(s). allocation destination. */
private
Set
<
IModelElement
>
ecuSet
;
/** Separation marker for allocation targets. */
final
String
SEPARATION_STRING_LEFT
=
"; "
;
/** Separation marker for allocation targets. */
final
String
SEPARATION_STRING_RIGHT
=
" | "
;
/** Maximum length of one side of the expression (string representation). */
int
MAX_ALLOC_SIZE_PER_SIDE
=
50
;
/** The left list of element(s). allocation source. */
private
List
<
Task
>
taskList
;
/** The right list of element(s). allocation destination. */
private
List
<
ExecutionUnit
>
ecuList
;
/** Constructor. */
public
AllocationPatternCompositeBackend
(
Composite
parent
,
int
style
)
{
...
...
@@ -80,8 +72,8 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
leftTreeViewer
.
setLabelProvider
(
new
ModelElementLabelProvider
());
leftTreeViewer
.
addSelectionChangedListener
(
new
TreeModelElementSelectionListener
());
btnAllocation
.
addSelectionListener
(
new
OperatorSelctionAdapter
());
btnDislocation
.
addSelectionListener
(
new
OperatorSelctionAdapter
());
btnAllocation
.
addSelectionListener
(
new
OperatorSel
e
ctionAdapter
());
btnDislocation
.
addSelectionListener
(
new
OperatorSel
e
ctionAdapter
());
rightTreeViewer
.
setContentProvider
(
new
SuperSetContentProvider
());
rightTreeViewer
.
setLabelProvider
(
new
ModelElementLabelProvider
());
...
...
@@ -105,8 +97,8 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
IDSEPerspectiveManager
pm
=
IDSEPerspectiveManager
.
INSTANCE
;
pm
.
addExplorationTarget
(
constraint
);
// Reset the fields and GUI elements.
task
Se
t
=
null
;
ecu
Se
t
=
null
;
task
Lis
t
=
null
;
ecu
Lis
t
=
null
;
leftTreeViewer
.
setSelection
(
StructuredSelection
.
EMPTY
);
rightTreeViewer
.
setSelection
(
StructuredSelection
.
EMPTY
);
header
.
setConstraintName
(
""
);
...
...
@@ -124,16 +116,16 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
((
IStructuredSelection
)
event
.
getSelection
()).
toList
();
Object
eventSource
=
event
.
getSource
();
if
(
eventSource
.
equals
(
leftTreeViewer
))
{
task
Se
t
=
new
HashSet
<
IModelElement
>(
selectionList
);
task
Lis
t
=
pickInstanceOf
(
Task
.
class
,
selectionList
);
}
else
if
(
eventSource
.
equals
(
rightTreeViewer
))
{
ecu
Se
t
=
new
HashSet
<
IModelElement
>(
selectionList
);
ecu
Lis
t
=
pickInstanceOf
(
ExecutionUnit
.
class
,
selectionList
);
}
updateConstraint
();
}
}
/** Selection adapter for operator radio buttons. */
private
class
OperatorSelctionAdapter
extends
SelectionAdapter
{
private
class
OperatorSel
e
ctionAdapter
extends
SelectionAdapter
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
...
...
@@ -145,16 +137,16 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
private
void
updateConstraint
()
{
// Calculate the name.
String
constraintText
=
""
;
if
(
task
Se
t
!=
null
)
{
constraintText
=
calc
AllocLeftRightName
(
taskSet
,
SEPARATION_STRING_LEFT
);
if
(
task
Lis
t
!=
null
)
{
constraintText
=
calc
PatternName
(
taskList
,
"; "
);
}
if
(
btnAllocation
.
getSelection
())
{
constraintText
+=
" -> "
;
}
else
{
constraintText
+=
" -/> "
;
}
if
(
ecu
Se
t
!=
null
)
{
constraintText
+=
calc
AllocLeftRightName
(
ecuSet
,
SEPARATION_STRING_RIGHT
);
if
(
ecu
Lis
t
!=
null
)
{
constraintText
+=
calc
PatternName
(
ecuList
,
" | "
);
}
// Update the GUI elements displaying the name.
...
...
@@ -162,52 +154,15 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
header
.
setConstraintName
(
constraintText
);
// Make add button available only if constraint is fully specified.
if
(
task
Se
t
!=
null
&&
ecu
Se
t
!=
null
)
{
if
(
task
Lis
t
!=
null
&&
ecu
Lis
t
!=
null
)
{
btnAdd
.
setEnabled
(
isConstraintComplete
());
}
}
/**
* Calculates the "name" of constraints. It supports sets and shortening the name if it becomes
* "too long". The contained elements of sets can still be easily seen by setting
* "DSE_DEBUG_VERBOSE" to "true" in the environment variable section.
*/
private
String
calcAllocLeftRightName
(
Set
<
IModelElement
>
selectedElements
,
String
separator
)
{
String
constraintNamePart
=
" "
;
if
(
selectedElements
!=
null
)
{
// Denote Sets if needed.
if
(
selectedElements
.
size
()
<=
1
)
{
constraintNamePart
=
""
;
}
else
{
constraintNamePart
=
"{"
;
}
// Add the element names.
constraintNamePart
+=
selectedElements
.
stream
()
.
map
(
e
->
((
INamedElement
)
e
).
getName
()
+
separator
).
collect
(
joining
());
// Remove the tailing separator.
if
(
constraintNamePart
.
length
()
>
separator
.
length
())
{
constraintNamePart
=
constraintNamePart
.
substring
(
0
,
constraintNamePart
.
length
()
-
separator
.
length
());
}
if
(
selectedElements
.
size
()
>
1
)
{
constraintNamePart
+=
"}"
;
}
// Trim the element description if needed (aware of long names & sets with many
// elements).
if
(
constraintNamePart
.
length
()
>
MAX_ALLOC_SIZE_PER_SIDE
)
{
constraintNamePart
=
constraintNamePart
.
substring
(
0
,
MAX_ALLOC_SIZE_PER_SIDE
);
if
(
selectedElements
.
size
()
>
1
)
{
constraintNamePart
=
"{"
+
constraintNamePart
+
"...; ...}"
;
}
}
}
return
constraintNamePart
;
}
/** Check if constraint is fully specified. */
private
boolean
isConstraintComplete
()
{
boolean
complete
=
true
;
if
(
task
Se
t
==
null
||
ecu
Se
t
==
null
)
{
if
(
task
Lis
t
==
null
||
ecu
Lis
t
==
null
)
{
complete
=
false
;
}
return
complete
;
...
...
@@ -219,7 +174,7 @@ public class AllocationPatternCompositeBackend extends AllocationPatternComposit
boolean
isAllocation
=
btnAllocation
.
getSelection
();
// Cannot use static import due to function name clash
IExpression
allocationPattern
=
PatternFactoryUtils
.
createAllocationPatternExpression
(
dse
,
isAllocation
,
task
Se
t
,
ecu
Se
t
);
isAllocation
,
task
Lis
t
,
ecu
Lis
t
);
SMTConstraint
constraint
=
createSMTConstraint
(
header
.
getConstraintName
(),
allocationPattern
,
false
);
constraint
.
setDimension
(
header
.
getCategoryName
());
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/AllocationPatternCompositeGUI.java
View file @
2e2846fd
...
...
@@ -54,7 +54,7 @@ public class AllocationPatternCompositeGUI extends Composite {
composite
.
setLayout
(
new
GridLayout
(
1
,
false
));
composite
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
,
1
,
1
));
header
=
new
ConstraintPatternHeader
(
composite
,
SWT
.
NONE
);
header
=
new
ConstraintPatternHeader
(
composite
,
SWT
.
NONE
,
"task -> ecu"
);
header
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
false
,
false
,
1
,
1
));
header
.
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/ConstraintPatternHeader.java
View file @
2e2846fd
...
...
@@ -54,7 +54,7 @@ public class ConstraintPatternHeader extends Composite implements IEventListener
private
Label
description
;
/** Constructor. */
public
ConstraintPatternHeader
(
Composite
parent
,
int
style
)
{
public
ConstraintPatternHeader
(
Composite
parent
,
int
style
,
String
name
)
{
super
(
parent
,
style
);
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
@@ -66,7 +66,7 @@ public class ConstraintPatternHeader extends Composite implements IEventListener
txtName
=
new
Text
(
this
,
SWT
.
BORDER
);
txtName
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
txtName
.
setSize
(
83
,
19
);
txtName
.
setText
(
"Pattern"
);
txtName
.
setText
(
name
);
Label
lblCategory
=
new
Label
(
this
,
SWT
.
NONE
);
lblCategory
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
FILL
,
false
,
false
,
1
,
1
));
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/FunctionCouplingCompositeBackend.java
View file @
2e2846fd
...
...
@@ -19,8 +19,10 @@ import static org.conqat.ide.commons.ui.selection.SelectionUtils.checkAndSelectA
import
static
org
.
fortiss
.
af3
.
exploration
.
smt
.
util
.
Z3ModelElementFactory
.
createSMTConstraint
;
import
static
org
.
fortiss
.
af3
.
exploration
.
ui
.
perspective
.
service
.
IEventListener
.
DSE_EVENT
.
DSE_REMOVED_EVENT
;
import
static
org
.
fortiss
.
af3
.
exploration
.
ui
.
perspective
.
service
.
IEventListener
.
DSE_EVENT
.
DSE_SELECTED_EVENT
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
PatternFactoryUtils
.
calcPatternName
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
PatternFactoryUtils
.
createFunctionCouplingPattern
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
ui
.
util
.
SelectionUtils
.
checkAndPickFirst
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
EcoreUtils
.
pickInstanceOf
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
UniqueIDUtils
.
prepareUniqueID
;
import
java.util.List
;
...
...
@@ -53,6 +55,10 @@ import org.fortiss.tooling.kernel.ui.presentation.ModelElementLabelProvider;
*/
public
class
FunctionCouplingCompositeBackend
extends
FunctionCouplingCompositeGUI
implements
IEventListener
{
/** The list of selected tasks. */
private
List
<
Task
>
taskList
;
/** Constructor. */
public
FunctionCouplingCompositeBackend
(
Composite
parent
,
int
style
)
{
super
(
parent
,
style
);
...
...
@@ -69,12 +75,19 @@ public class FunctionCouplingCompositeBackend extends FunctionCouplingCompositeG
private
void
createControls
()
{
treeViewerSet1Selection
.
setContentProvider
(
new
SuperSetContentProvider
());
treeViewerSet1Selection
.
setLabelProvider
(
new
ModelElementLabelProvider
());
btnCoupling
.
addSelectionListener
(
new
OperatorSelectionAdapter
());
btnDecoupling
.
addSelectionListener
(
new
OperatorSelectionAdapter
());
treeViewerSet1Selection
.
addSelectionChangedListener
(
new
ISelectionChangedListener
()
{
/** */
/** {@inheritDoc} */
@SuppressWarnings
(
"unchecked"
)
@Override
public
void
selectionChanged
(
SelectionChangedEvent
event
)
{
Task
task
=
checkAndPickFirst
(
event
.
getSelection
(),
Task
.
class
);
btnAdd
.
setEnabled
(
task
!=
null
);
taskList
=
pickInstanceOf
(
Task
.
class
,
((
IStructuredSelection
)
event
.
getSelection
()).
toList
());
updateConstraint
();
}
});
...
...
@@ -104,8 +117,6 @@ public class FunctionCouplingCompositeBackend extends FunctionCouplingCompositeG
/** Current Error Message for Predicate Creation. */
private
String
errorMessage
=
"No Error"
;
/** Name of the selected Constraint. */
private
String
selectedConstName
;
/** Returns the {@link ExecutionUnit}s referenced in the current {@link SuperSetMap}. */
private
List
<
ExecutionUnit
>
getExecutionUnits
()
{
...
...
@@ -119,7 +130,6 @@ public class FunctionCouplingCompositeBackend extends FunctionCouplingCompositeG
public
void
widgetSelected
(
SelectionEvent
e
)
{
selectedTasks
=
checkAndSelectAll
(
treeViewerSet1Selection
.
getSelection
(),
Task
.
class
);
selectedConstName
=
header
.
getConstraintName
();
if
(!
isValidSelection
())
{
printMessage
(
errorMessage
);
return
;
...
...
@@ -129,7 +139,7 @@ public class FunctionCouplingCompositeBackend extends FunctionCouplingCompositeG
DSE
dse
=
pm
.
getCurrentlySelectedDSE
();
SMTConstraint
constraint
=
createSMTConstraint
();
constraint
.
setName
(
selectedCons
tName
);
constraint
.
setName
(
header
.
getConstrain
tName
()
);
constraint
.
setExpression
(
createFunctionCouplingPattern
(
dse
,
btnCoupling
.
getSelection
(),
selectedTasks
));
constraint
.
setDimension
(
header
.
getCategoryName
());
...
...
@@ -163,6 +173,39 @@ public class FunctionCouplingCompositeBackend extends FunctionCouplingCompositeG
}
}
/** Selection adapter for operator radio buttons. */
private
class
OperatorSelectionAdapter
extends
SelectionAdapter
{
/** {@inheritDoc} */
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
updateConstraint
();
}
}
/** Update the constraint expression with the given elements. */
private
void
updateConstraint
()
{
if
(
taskList
==
null
)
{
return
;
}
// Calculate the name
String
name
;
if
(
btnCoupling
.
getSelection
())
{
name
=
"Coupling "
;
}
else
{
name
=
"Decoupling "
;
}
if
(
taskList
.
size
()
==
1
)
{
name
=
name
+
"{"
;
}
name
=
name
+
calcPatternName
(
taskList
,
", "
);
if
(
taskList
.
size
()
==
1
)
{
name
=
name
+
"}"
;
}
// Update the GUI elements displaying the name.
header
.
setConstraintName
(
name
);
btnAdd
.
setEnabled
(
taskList
.
size
()
>
1
);
}
/** {@inheritDoc} */
@Override
public
void
propertyChanged
(
Object
source
,
DSE_EVENT
event
)
{
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/FunctionCouplingCompositeGUI.java
View file @
2e2846fd
...
...
@@ -46,7 +46,7 @@ public class FunctionCouplingCompositeGUI extends Composite {
super
(
parent
,
style
);
setLayout
(
new
GridLayout
(
1
,
false
));
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
);
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
,
"Coupling{}"
);
header
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
,
1
,
1
));
header
.
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/constraint/SafetyPatternCompositeGUI.java
View file @
2e2846fd
...
...
@@ -51,7 +51,7 @@ public class SafetyPatternCompositeGUI extends Composite {
super
(
parent
,
style
);
setLayout
(
new
GridLayout
(
1
,
false
));
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
);
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
,
"SafetyPattern"
);
header
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
false
,
false
,
1
,
1
));
header
.
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
org.fortiss.af3.exploration.ui/src/org/fortiss/af3/exploration/ui/perspective/targetdef/objective/BusBandwidthOptimzationPatternCompositeGUI.java
View file @
2e2846fd
...
...
@@ -47,7 +47,7 @@ public class BusBandwidthOptimzationPatternCompositeGUI extends Composite {
super
(
parent
,
style
);
setLayout
(
new
GridLayout
(
1
,
false
));
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
);
header
=
new
ConstraintPatternHeader
(
this
,
SWT
.
NONE
,
"BusBandwidthOptimizationPattern"
);
header
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
,
1
,
1
));
header
.
setLayout
(
new
GridLayout
(
2
,
false
));
...
...
org.fortiss.af3.exploration/src/org/fortiss/af3/exploration/util/.ratings
View file @
2e2846fd
...
...
@@ -6,4 +6,4 @@ ExplorationModelElementFactory.java bb48b2d09b92efcb1b2d3e382555089bb7ed5db5 GRE
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationUtils.java 3e317c851bd1a0b48fbec3fdbe039d8b66506c51 GREEN
ModelSnapshotExtractUtils.java dde8b42c5a7228478ffe8c67820bcac91e875562 GREEN
PatternFactoryUtils.java
6b3c61d421258967af94ce019fdb778e3161c90d
GREEN
PatternFactoryUtils.java
bcb1d325aecfef12d29d4eb53b28fe59dbd20e9a
GREEN
org.fortiss.af3.exploration/src/org/fortiss/af3/exploration/util/PatternFactoryUtils.java
View file @
2e2846fd
...
...
@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package
org.fortiss.af3.exploration.util
;
import
static
java
.
util
.
stream
.
Collectors
.
joining
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
DSMLModelElementFactory
.
createAllocation
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
DSMLModelElementFactory
.
createAnd
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
DSMLModelElementFactory
.
createArithmeticLiteral
;
...
...
@@ -37,10 +38,8 @@ import static org.fortiss.af3.exploration.util.DSMLModelElementFactory.createSum
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
DSMLModelElementFactory
.
createUses
;
import
static
org
.
fortiss
.
af3
.
exploration
.
util
.
DSMLModelElementFactory
.
createWeight
;
import
static
org
.
fortiss
.
af3
.
platform
.
utils
.
RouteUtils
.
busUsesRoute
;
import
static
org
.
fortiss
.
tooling
.
kernel
.
utils
.
EcoreUtils
.
pickInstanceOf
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -77,6 +76,7 @@ import org.fortiss.af3.task.model.Signal;
import
org.fortiss.af3.task.model.Task
;
import
org.fortiss.tooling.base.model.element.IAnnotatedSpecification
;
import
org.fortiss.tooling.base.model.element.IModelElement
;
import
org.fortiss.tooling.kernel.model.INamedElement
;
/**
* Utility methods for generating DSEML constraints and objectives according to patterns.
...
...
@@ -85,6 +85,9 @@ import org.fortiss.tooling.base.model.element.IModelElement;
*/
public
class
PatternFactoryUtils
{
/** Maximum length of one side of the expression (string representation). */
static
int
MAX_ALLOC_SIZE_PER_SIDE
=
50
;
/**
* Creates an {@link IExpression} according to the {@link Route} weight constraint pattern.
*
...
...
@@ -342,17 +345,17 @@ public class PatternFactoryUtils {
* @param isAllocation
* {@code boolean} specifying whether to generate an allocation constraint
* ({@code true}) or a dislocation constraint ({@code false})
* @param task
Se
t
* {@link
Collection
} of {@link
IModelElement
}s containing the {@link Task}s to
* @param task
Lis
t
* {@link
List
} of {@link
Task
}s containing the {@link Task}s to
* allocate or dislocate
* @param ecu
Se
t
* {@link
Collection
} of {@link
IModelElemen
t}s containing the {@link ExecutionUnit}s
* @param ecu
Lis
t
* {@link
List
} of {@link
ExecutionUni
t}s containing the {@link ExecutionUnit}s
* the expression applies to
* @return {@link IExpression} allocating/dislocating {@link Task}s to/from
* {@link ExecutionUnit}s
*/
public
static
IExpression
createAllocationPatternExpression
(
DSE
dse
,
boolean
isAllocation
,
Collection
<
IModelElement
>
taskSet
,
Coll
ection
<
IModelElemen
t
>
ecu
Se
t
)
{
List
<
Task
>
taskList
,
List
<
Ex
ec
u
tion
Uni
t
>
ecu
Lis
t
)
{
SuperSetMap
dseSets
=
dse
.
getCurrentStep
().
getSuperSetMap
();
ILocationExpression
locationConstraint
=
null
;
...
...
@@ -362,17 +365,14 @@ public class PatternFactoryUtils {
locationConstraint
=
createDislocation
(
null
,
null
);
}
List
<
Task
>
tasks
=
pickInstanceOf
(
Task
.
class
,
new
ArrayList
<
IModelElement
>(
taskSet
));
SuperSet
<
Task
>
tSet
=
dseSets
.
get
(
Task
.
class
);
Set
<
IModelElement
>
leftSet
=
createSet
(
tSet
,
task
s
,
"Tasks"
,
Task
.
class
).
getCastedSet
(
IModelElement
.
class
);
createSet
(
tSet
,
task
List
,
"Tasks"
,
Task
.
class
).
getCastedSet
(
IModelElement
.
class
);
locationConstraint
.
setLeft
(
createModelElementLiteral
(
leftSet
));
List
<
ExecutionUnit
>
executionUnits
=
pickInstanceOf
(
ExecutionUnit
.
class
,
new
ArrayList
<
IModelElement
>(
ecuSet
));
SuperSet
<
ExecutionUnit
>
exUSet
=
dseSets
.
get
(
ExecutionUnit
.
class
);
Set
<
IModelElement
>
rightSet
=
createSet
(
exUSet
,
e
xecutionUnits
,
"ExecutionUnits"
,
ExecutionUnit
.
class
)
createSet
(
exUSet
,
e
cuList
,
"ExecutionUnits"
,
ExecutionUnit
.
class
)
.
getCastedSet
(
IModelElement
.
class
);
locationConstraint
.
setRight
(
createModelElementLiteral
(
rightSet
));
...
...
@@ -458,4 +458,42 @@ public class PatternFactoryUtils {
return
expression
;
}
/**
* Calculates the "name" of constraints. It supports sets and shortening the name if it becomes
* "too long". The contained elements of sets can still be easily seen by setting
* "DSE_DEBUG_VERBOSE" to "true" in the environment variable section.
*/
public
static
String
calcPatternName
(
List
<?
extends
INamedElement
>
selectedElements
,
String
separator
)
{
String
constraintNamePart
=
" "
;
if
(
selectedElements
!=
null
)
{
// Denote Sets if needed.
if
(
selectedElements
.
size
()
<=
1
)
{
constraintNamePart
=
""
;
}
else
{
constraintNamePart
=
"{"
;
}
// Add the element names.
constraintNamePart
+=
selectedElements
.
stream
().
map
(
e
->
e
.
getName
()
+
separator
).
collect
(
joining
());
// Remove the tailing separator.
if
(
constraintNamePart
.
length
()
>
separator
.
length
())
{
constraintNamePart
=
constraintNamePart
.
substring
(
0
,
constraintNamePart
.
length
()
-
separator
.
length
());
}
if
(
selectedElements
.
size
()
>
1
)
{
constraintNamePart
+=
"}"
;
}
// Trim the element description if needed (aware of long names & sets with many
// elements).
if
(
constraintNamePart
.
length
()
>
MAX_ALLOC_SIZE_PER_SIDE
)
{
constraintNamePart
=
constraintNamePart
.
substring
(
0
,
MAX_ALLOC_SIZE_PER_SIDE
);
if
(
selectedElements
.
size
()
>
1
)
{
constraintNamePart
=
constraintNamePart
+
"...; ...}"
;
}
}
}
return
constraintNamePart
;
}
}
org.fortiss.af3.safetycases/plugin.xml
View file @
2e2846fd
...
...
@@ -343,7 +343,7 @@
</objectClass>
</migrationProvider>
<migrationProvider
migrationProvider=
"org.fortiss.af3.safetycases.migration.SolutionDeploymentToCa2HwMigration"
>
<objectClass
objectClass=
"org.fortiss.af3.
safetycases.model.Solution
"
/>
<objectClass
objectClass=
"org.fortiss.af3.
deployment.model.Deployment
"
/>
</migrationProvider>
</extension>
...
...
org.fortiss.af3.schedule/plugin.xml
View file @
2e2846fd
...
...
@@ -34,7 +34,7 @@
<extension
point=
"org.fortiss.tooling.kernel.migrationProvider"
>
<migrationProvider
migrationProvider=
"org.fortiss.af3.schedule.migration.SystemScheduleDeploymentToAllocationMigration"
>
<objectClass
objectClass=
"org.fortiss.af3.
schedule.model.SystemSchedule
"
/>
<objectClass
objectClass=
"org.fortiss.af3.
deployment.model.Deployment
"
/>
</migrationProvider>
</extension>
</plugin>
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