diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleUI5.model b/AlgebraicDataflowArchitectureModel/models/SimpleUI5.model index 6fbe7bc..ca722e7 100644 --- a/AlgebraicDataflowArchitectureModel/models/SimpleUI5.model +++ b/AlgebraicDataflowArchitectureModel/models/SimpleUI5.model @@ -1,17 +1,23 @@ init { - screenTemplates := { - "000": { - "widgets": { - "001": {"type": "textInput", "text": "", "state": 0, "visible": true}, - "002": {"type": "button", "text": "Next", "state": 0, "visible": true}, - "003": {"type": "table", "text": "", "state": 0, "visible": true, "colName": append(append(nil, "id"), "name"), "rowNum": 0, "source": "basic", "colDatas": nil} - }, - "layout": true - } - } - tmp := -100 + screenTemplates := { + "screen1":{ + "widgets": { + "btn1": {"type": "button", "text": "hello", "visible": true, "x": 10, "y": 10, "width": 100, "height": 40} + }, + "layout": false } - + } + curScreen := "screen1" + input1 := "input1" + input2 := "input2" + input3 := "input3" + input1 := "input1" + input2 := "input2" + input3 := "input3" + input1 := "input1" + input2 := "input2" + input3 := "input3" +} native channel ScreenUpdate { in screen(curSc: Json, update(curSc, nextSc)) = nextSc } @@ -61,28 +67,64 @@ ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen)) out screen(curS, transScreen(nextScId, screen)) = screen } - + channel EventDispatch(wid: Str) { in screen.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextState)) out screenTemplates.{curScId}.widgets.{wid}.state(curState: Int, dispatchEvent(curScId, wid, nextState)) = nextState } - + channel EventDispatch2(wid: Str) { - in screen.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText - ref curScreen(curScId: Str, dispatchEvent2(curScId, wid, nextText)) - out screenTemplates.{curScId}.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText + in screen.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText + ref curScreen(curScId: Str, dispatchEvent2(curScId, wid, nextText)) + out screenTemplates.{curScId}.widgets.{wid}.text(curText: Str, dispatchEvent2(curScId, wid, nextText)) = nextText } -channel addBasic { - out basic(basic: Map, addBasic(id: Str, name: Str)) = insert(basic, id, {"name": name}) +channel btn1AccountsSetData(scId: Str, wid: Str){ + in screenTemplates.{scId="screen1"}.widgets.{wid="btn1"}.state(curState, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = nextState + ref input1(input1, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref screen.widgets.{input1}.text(id, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref input2(input2, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref screen.widgets.{input2}.text(name, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref input3(input3, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref screen.widgets.{input3}.text(age, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + ref accounts(accountsRef, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) + out accounts(accounts: Map, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = if((nextState == 0) && (id != "") && (!contains(accountsRef, id)), insert(accounts, id, {"name": name, "age": age}), accounts) + out curScreen(curScreen, btn1AccountsSetData(nextState, id, input1, name, input2, age, input3, accountsRef)) = if((nextState == 0), if((id != "") && (!contains(accountsRef, id)), "screen2", "screen3"), curScreen) } -channel changeNameOfBasic(id: Str) { - out basic.{id}.name(curName, changeNameOfBasic(nextName)) = nextName +channel addAccounts { + out accounts(accounts: Map, addAccounts(id: Str, name: Str, age: Int)) = insert(accounts, id, {"name": name,"age": age}) } -channel tmp(wid: Str) { - in screen.widgets.{wid="002"}.state(curState: Int, tmp(nextState)) = nextState - out tmp(curTmp: Int, tmp(nextState)) = nextState -} \ No newline at end of file +channel changeNameOfAccounts(id: Str) { + out accounts.{id}.name(name: Str, changeNameOfAccounts(newName: Str)) = newName +} + +channel changeAgeOfAccounts(id: Str) { + out accounts.{id}.age(age: Int, changeAgeOfAccounts(newAge: Int)) = newAge +} + +channel addTweets { + out tweets(tweets: Map, addTweets(tweetId: Int, contents: Str, idOfAccounts: Str)) = insert(tweets, tweetId, {"contents": contents,"idOfAccounts": idOfAccounts}) +} + +channel changeContentsOfTweets(tweetId: Int) { + out tweets.{tweetId}.contents(contents: Str, changeContentsOfTweets(newContents: Str)) = newContents +} + +channel changeIdOfAccountsOfTweets(tweetId: Int) { + out tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, changeIdOfAccountsOfTweets(newIdOfAccounts: Str)) = newIdOfAccounts +} + +channel nameOfAccountsOfTweets(tweetId: Int){ + in tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, nameOfAccountsOfTweets(newIdOfAccounts: Str, newNameOfAccounts: Str)) = newIdOfAccounts + in accounts.{newIdOfAccounts}.name(name: Str, nameOfAccountsOfTweets(newIdOfAccounts, newNameOfAccounts)) = newNameOfAccounts + out tweets.{tweetId}.nameOfAccounts(nameOfAccounts, nameOfAccountsOfTweets(newIdOfAccounts, newNameOfAccounts)) = newNameOfAccounts +} + +channel ageOfAccountsOfTweets(tweetId: Int){ + in tweets.{tweetId}.idOfAccounts(idOfAccounts: Str, ageOfAccountsOfTweets(newIdOfAccounts: Str, newAgeOfAccounts: Int)) = newIdOfAccounts + in accounts.{newIdOfAccounts}.age(age: Int, ageOfAccountsOfTweets(newIdOfAccounts, newAgeOfAccounts)) = newAgeOfAccounts + out tweets.{tweetId}.ageOfAccounts(ageOfAccounts, ageOfAccountsOfTweets(newIdOfAccounts, newAgeOfAccounts)) = newAgeOfAccounts +}