Browse Source

Re-add processing of input/output to the AL for our own FSA

Yentl Van Tendeloo 5 years ago
parent
commit
89c94ea60e
1 changed files with 14 additions and 9 deletions
  1. 14 9
      New_MM.ipynb

+ 14 - 9
New_MM.ipynb

@@ -172,8 +172,8 @@
        " ('State.name', 'String'),\n",
        " ('Transition', 'Association'),\n",
        " ('Transition.name', 'String'),\n",
-       " ('__1049608', 'Class_name'),\n",
-       " ('__1049680', 'Class_name')}"
+       " ('__1049604', 'Class_name'),\n",
+       " ('__1049676', 'Class_name')}"
       ]
      },
      "execution_count": 7,
@@ -193,7 +193,7 @@
     {
      "data": {
       "text/plain": [
-       "'__1054148'"
+       "'__1054144'"
       ]
      },
      "execution_count": 8,
@@ -257,8 +257,8 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "All initial element IDs: {'__1063127'}\n",
-      "All state element IDs: {'__1063127', '__1054148'}\n"
+      "All initial element IDs: {'__1063123'}\n",
+      "All state element IDs: {'__1054144', '__1063123'}\n"
      ]
     }
    ],
@@ -362,7 +362,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Lower cardinality violation for outgoing edge of type State_name at NODE __1054148 (ID: 1054148)\n"
+      "Lower cardinality violation for outgoing edge of type State_name at NODE __1054144 (ID: 1054144)\n"
      ]
     }
    ],
@@ -819,7 +819,7 @@
       "Before:\n",
       "[]\n",
       "After:\n",
-      "[{'__id': '__1250764', '__type': 'State', 'name': 'new_state'}]\n"
+      "[{'__id': '__1278420', '__type': 'State', 'name': 'new_state'}]\n"
      ]
     }
    ],
@@ -860,7 +860,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 28,
    "metadata": {
     "scrolled": false
    },
@@ -899,10 +899,14 @@
     "    while (time() - start_time < 10.0):\n",
     "        if (has_input()):\n",
     "            input_value = list_read(string_split(input(), \"\\\\n\"), 0)\n",
+    "            log(\"Received input value: \" + cast_string(input_value))\n",
+    "            if (input_value == \"__EXIT__\"):\n",
+    "                break!\n",
     "\n",
     "            transitions = allOutgoingAssociationInstances(model, current_state, \"FSA/Transition\")\n",
     "            while (set_len(transitions) > 0):\n",
     "                transition = set_pop(transitions)\n",
+    "                log(\"Compare against \" + cast_string(read_attribute(model, transition, \"trigger\")))\n",
     "                if (cast_string(read_attribute(model, transition, \"trigger\")) == input_value):\n",
     "                    if (element_neq(read_attribute(model, transition, \"raise\"), read_root())):\n",
     "                        log(cast_value(time() - start_time) + \" output \" + cast_string(read_attribute(model, transition, \"raise\")))\n",
@@ -915,6 +919,7 @@
     "                    break!\n",
     "\n",
     "        log(cast_value(time() - start_time) + \" \" + cast_string(read_attribute(model, current_state, \"name\")))\n",
+    "        output(cast_value(time() - start_time) + \" \" + cast_string(read_attribute(model, current_state, \"name\")))\n",
     "        sleep(0.2)\n",
     "    return True!\n",
     "    \"\"\")"
@@ -1050,7 +1055,7 @@
      "output_type": "stream",
      "text": [
       "Before:\n",
-      "{'c', 'b', 'a'}\n",
+      "{'a', 'c', 'b'}\n",
       "After:\n",
       "{'a', 'b'}\n"
      ]