diff --git a/AlgebraicDataflowArchitectureModel/models/DataStore.model b/AlgebraicDataflowArchitectureModel/models/DataStore.model index 3ad587c..7a5c17a 100644 --- a/AlgebraicDataflowArchitectureModel/models/DataStore.model +++ b/AlgebraicDataflowArchitectureModel/models/DataStore.model @@ -1,11 +1,21 @@ init { - screen := { - "widgets": { - "001": {"type": "button", "text": "a", "state": 0}, - "002": {"type": "textInput", "text": "", "state": 0} - }, - "layout": true - } + variables := { + "a" : { + "target": "w1", + "source": "a1", + "value": "_" + }, + "b": { + "target": "w3", + "source": "w2", + "value": "_" + } + } + datastore := { + "accounts": { + "a1": "hello" + } + } } native channel ScreenUpdate { @@ -40,11 +50,45 @@ out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0}) } - channel signUp{ out datastore.accounts(accounts: Map, signUp(id, name)) = insert(accounts, id, name) } -channel createBook { - out datastore.books(books: Map, createBook(id, title, aid)) = insert(books, id, {"title": title, "aid": aid}) -} \ No newline at end of file +channel changeName(aid: Str) { + out datastore.accounts.{aid}(curName: Str, changeName(newName)) = newName +} + +channel setTarget { + out variables.a.target(curTarget: Str, setTarget(newTarget: Str)) = newTarget +} + +channel setSource { + out variables.a.source(curSource: Str, setSource(newSource: str)) = newSource +} + +channel setTargetB { + out variables.b.target(curTarget: Str, setTarget(newTarget: Str)) = newTarget +} + +channel setSourceB { + out variables.b.source(curSource: Str, setSource(newSource: str)) = newSource +} + +channel setValue { + in variables.a.source(curSource: Str, setValue(nextSource, nextName)) = nextSource + in datastore.accounts.{nextSource}(curName, setValue(nextSource, nextName)) = nextName + out variables.a.value(curValue: Str, setValue(nextSource, nextName)) = nextName +} + +channel setButtonText { + in variables.a.target(curTarget: Str, setButtonText(nextTarget, nextText)) = nextTarget + in variables.a.value(curText: Str, setButtonText(nextTarget, nextText)) = nextText + out screen.widgets.{nextTarget}.text(curText, setButtonText(nextTarget, nextText)) = nextText +} + +channel setInputTextValue { + in variables.b.source(curSource: Str, setValue2(nextSource, nextTarget, nextValue)) = nextSource + in variables.b.target(curTarget: Str, setValue2(nextTarget, nextTarget, nextValue)) = nextTarget + in screen.widgets.{nextSource}.text(curValue: Str, setValue2(nextSource, nextTarget, nextValue)) = nextValue + out screen.widgets.{nextTarget}.text(curText, setValue2(nextTarget, nextTarget, nextValue)) = nextValue +}