From 92facf33c7e2bbf4175769b32cbe0fb96d6b505a Mon Sep 17 00:00:00 2001 From: Michael Leuschel <leuschel@uni-duesseldorf.de> Date: Thu, 8 Oct 2020 12:23:02 +0200 Subject: [PATCH] add extended Button example --- Button/button.json | 35 +++++++++++++++++++++++++++++++++++ Button/button.mch | 16 ++++++++++++++++ Button/button.svg | 12 ++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 Button/button.json create mode 100644 Button/button.mch create mode 100644 Button/button.svg diff --git a/Button/button.json b/Button/button.json new file mode 100644 index 0000000..7cd2f2b --- /dev/null +++ b/Button/button.json @@ -0,0 +1,35 @@ +{ + "svg": "button.svg", + "items": [ + { + "id": "button", + "attr": "fill", + "value": "IF button=TRUE THEN \"green\" ELSE \"red\" END" + }, + { + "id": "button", + "attr": "stroke-width", + "value": "IF ENABLED(\"press_button\") THEN 6 ELSE 1 END" + }, + { + "id": "button_%0", + "attr": "visibility", + "value": "IF button=%0 THEN \"visible\" ELSE \"hidden\" END", + "repeat": [ "TRUE", "FALSE" ] + } + ], + "events": [ + { + "id": "button", + "event": "toggle_button" + }, + { + "id": "button_TRUE", + "event": "toggle_button" + }, + { + "id": "button_FALSE", + "event": "press_button" + } + ] +} diff --git a/Button/button.mch b/Button/button.mch new file mode 100644 index 0000000..f3c8931 --- /dev/null +++ b/Button/button.mch @@ -0,0 +1,16 @@ +MACHINE button +DEFINITIONS "LibraryMeta.def" +VARIABLES + button +INVARIANT + button:BOOL +INITIALISATION + button := FALSE +OPERATIONS + press_button = PRE button=FALSE THEN + button:=TRUE + END; + toggle_button = BEGIN + button:= bool(button=FALSE) + END +END \ No newline at end of file diff --git a/Button/button.svg b/Button/button.svg new file mode 100644 index 0000000..829601b --- /dev/null +++ b/Button/button.svg @@ -0,0 +1,12 @@ +<svg height="230" width="200"> + <circle id="button" cx="100" cy="100" r="80" + stroke="black" stroke-width="3" fill="green" /> + <text text-align="left" x="50" y="190" + font-family="sans-serif"> + <tspan dx="0" dy = "0.6em" id="visb_debug_messages">1.</tspan> + </text> + <circle id="button_TRUE" cx="10" cy="200" r="8" + stroke="black" stroke-width="3" fill="green" /> + <circle id="button_FALSE" cx="30" cy="200" r="8" + stroke="black" stroke-width="3" fill="red" /> +</svg> -- GitLab