summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/uscxml/transform/ChartToVHDL.cpp50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/uscxml/transform/ChartToVHDL.cpp b/src/uscxml/transform/ChartToVHDL.cpp
index 286998d..dec4406 100644
--- a/src/uscxml/transform/ChartToVHDL.cpp
+++ b/src/uscxml/transform/ChartToVHDL.cpp
@@ -1173,7 +1173,8 @@ namespace uscxml {
VLINE("in_entry_set_" + toStr(i) + "_sig"),
(VAND,
VLINE("in_complete_entry_set_" + toStr(i) + "_sig"),
- (VOR, VLINE("state_active_" + toStr(i) + "_sig"), (VNOT, VLINE("in_exit_set_" + toStr(i) + "_sig")))));
+ (VOR, VLINE("in_exit_set_" + toStr(i) + "_sig"),
+ (VNOT, VLINE("state_active_" + toStr(i) + "_sig")))));
tree->print(stream);
stream << ";" << std::endl;
@@ -1181,22 +1182,26 @@ namespace uscxml {
}
void ChartToVHDL::writeDefaultCompletions(std::ostream & stream) {
+ // TODO direct connect the line in complete entry set (no extra line needed ...)
stream << "-- default completion assignments" << std::endl;
+ stream << "-- indikates if the state for which I am the def-completion is active" << std::endl;
std::map<Element<std::string>, NodeSet<std::string> > completions;
+
for (size_t i = 0; i < _states.size(); i++) {
Element<std::string> state(_states[i]);
completions[state]; // initialize other completions to 0
- std::string completion = ATTR(state, "completionBools");
- for (size_t j = 0; j < _states.size(); j++) {
- if (completion[j] == '1') {
- // completions[Element<std::string>(_states[j])].push_back(state);
- completions[state].push_back(Element<std::string>(_states[j]));
- stream << "-- " << toStr(i) << " ("
- << ATTR(state, "id") << ") completed through "
- << toStr(j) << " ("
- << ATTR_CAST(_states[j], "id") << ")"
- << std::endl;
+ // we just need this if parent is a compound state
+ std::string parent = ATTR(state, "parent");
+ if (!parent.empty()
+ && isCompound(Element<std::string>(_states[strTo<size_t>(parent)]))) {
+
+ // Am I default completen ?
+ std::string completion = ATTR_CAST(_states[strTo<size_t>(parent)], "completionBools");
+ if (completion[i] == '1') {
+ // Yes? then give me the parent line
+ completions[state].push_back(Element<std::string>(_states[strTo<size_t>(parent)]));
+
}
}
}
@@ -1210,8 +1215,11 @@ namespace uscxml {
VContainer defaultCompleters = VOR;
for (size_t i = 0; i < refs.size(); i++) {
- *defaultCompleters += VLINE("in_complete_entry_set_" +
- ATTR_CAST(refs[i],"documentOrder") + "_sig ");
+ // *defaultCompleters += VLINE("in_complete_entry_set_" +
+ // TODO: default completion just when state is entered the first time ?
+ // if yes then we use the following code. If not we have to revert
+ *defaultCompleters += VLINE("in_entry_set_" +
+ ATTR_CAST(refs[i], "documentOrder") + "_sig ");
}
VBranch* tree = (VASSIGN,
@@ -1249,7 +1257,7 @@ namespace uscxml {
stream << "--" << state.getNodeName() << std::endl; // for debugging
if (isCompound(state) || isParallel(state)) { // <- true for scxml? TODO
for (size_t j = 0; j < _states.size(); j++) {
- if (children[j] != '1') // <- ? TODO Was ist hier der vergleich?
+ if (children[j] != '1') // if is child of state j
continue;
*completeEntrysetters += VLINE("in_complete_entry_set_up_" + toStr(j) + "_sig");
}
@@ -1259,6 +1267,8 @@ namespace uscxml {
VLINE("in_complete_entry_set_up_" + toStr(i) + "_sig"),
(VOR, optimalEntrysetters, completeEntrysetters)
);
+ (VOR, optimalEntrysetters, completeEntrysetters)
+ );
tree->print(stream);
stream << ";" << std::endl;
@@ -1291,7 +1301,6 @@ namespace uscxml {
Element<std::string> state(_states[i]);
std::string completion = ATTR(state, "completionBools");
std::string ancestors = ATTR(state, "ancBools");
- std::string children = ATTR(state, "childBools");
std::string parent = ATTR(state, "parent");
if (parent.size() == 0) {
@@ -1300,11 +1309,16 @@ namespace uscxml {
VContainer tmp1 = VAND;
// if parent is compound
- if (isCompound(Element<std::string>(_states[strTo<size_t>(parent)]))) {
- // TODO: if this state is the default completion of parent
- // --> init attr. or if not present first in document order
+ if (!parent.empty() &&
+ isCompound(Element<std::string>(_states[strTo<size_t>(parent)]))) {
+ std::string children = ATTR_CAST(_states[strTo<size_t>(parent)],
+ "childBools");
+ // TODO: do not add default_completion line if not needed
+ // --> just if this state is the default completion of parent
+ // --> init attr. or if not present first in document order <-- = completion bool ?
*tmp1 += VLINE("default_completion_" + ATTR(state, "documentOrder") + "_sig");
+ //TODO check this
for (size_t j = 0; j < _states.size(); j++) {
if (children[j] != '1')
continue;