diff --git a/AlgebraicDataflowArchitectureModel/models/Accounts.model b/AlgebraicDataflowArchitectureModel/models/Accounts.model index 24710ee..cce8811 100644 --- a/AlgebraicDataflowArchitectureModel/models/Accounts.model +++ b/AlgebraicDataflowArchitectureModel/models/Accounts.model @@ -1,7 +1,6 @@ -channel CIO1 { - out accounts(l:List, signup(name:Str)) = append(l, {"name": name}) -} - channel CIO2(uid:Int) { out accounts.{uid}.name(n:Str, changeName(name)) = name } +channel CIO1 { + out accounts(l:List, signup(name:Str)) = append(l, {"name": name}) +} diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model b/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model index 4017f0a..a6f9074 100644 --- a/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model +++ b/AlgebraicDataflowArchitectureModel/models/SimpleUI2.model @@ -1,10 +1,22 @@ init { - variables := { - "a": { - "from": "001", - "to": "002" + screenTemplates := { + "000": { + "widgets": { + "001": {"type": "textInput", "text": "", "state": 0}, + "002": {"type": "button", "text": "Next", "state": 0}, + "005": {"type": "label", "text": "aaa", "state": 0} + }, + "layout": true + }, + "001": { + "widgets": { + "003": {"type": "label", "text": "label", "state": 0}, + "004": {"type": "button", "text": "Back", "state": 0} + }, + "layout": true } } + sender1:= "005" } native channel ScreenUpdate { @@ -23,6 +35,22 @@ in screen.widgets.{wid}.text(curText: Str, setText(nextText)) = nextText } +native channel SetX(wid: Str) { + in screen.widgets.{wid}.x(curX: Int, setX(nextX)) = nextX +} + +native channel SetY(wid: Str) { + in screen.widgets.{wid}.y(curY: Int, setY(nextY)) = nextY +} + +native channel SetWidth(wid: Str) { + in screen.widgets.{wid}.width(curWidth: Int, setWidth(nextWidth)) = nextWidth +} + +native channel SetHeight(wid: Str) { + in screen.widgets.{wid}.height(curHeight: Int, setHeight(nextHeight)) = nextHeight +} + native channel MouseEvent(wid: Str) { out screen.widgets.{wid}.state(curState: Int, mouseEvent(nextState)) = nextState } @@ -31,13 +59,40 @@ out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText } -channel AddTextInput { - out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0}) +channel ChangeCurScreen { + out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId } -channel ChangeText(wid: Str) { - ref variables.a.from(from, updateText(from, to, newText)) - ref variables.a.to(to, updateText(from, to, nexText)) - in screen.widgets.{wid}.text(curText: Str, updateText(from, to, nexText)) = curText - out screen.widgets.{to}.text(curText: Str, updateText(from, to, nexText)) = if(wid == from, nextText, curText) +channel ScreenTransition { + in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId + 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, dispatchEvent(curScId, wid, nextText: Str)) = nextText + ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextText)) + out screenTemplates.{curScId}.widgets.{wid}.text(curText: Str, dispatchEvent(curScId, wid, nextText)) = nextText +} + +channel EventHandler1(scId: Str, wid: Str) { + in screenTemplates.{scId="000"}.widgets.{wid="002"}.state(curState: Int, handleEvent1(nextState)) = nextState + out curScreen(curScId: Str, handleEvent1(nextState)) = if(nextState == 0, "001", curScId) +} + +channel EventHandler2(scId: Str, wid: Str) { + in screenTemplates.{scId="001"}.widgets.{wid="004"}.state(curState: Int, handleEvent2(nextState)) = nextState + out curScreen(curScId: Str, handleEvent2(nextState)) = if(nextState == 0, "000", curScId) +} + +channel EventHandler3(scId: Str, wid: Str) { + in screenTemplates.{scId="000"}.widgets.{wid="001"}.text(curText: Str, handleEvent3(nextText: Str, target)) = nextText + ref sender1(target, handleEvent3(nextText, target)) + out screen.widgets.{target}.text(curText: Str, handleEvent3(nextText, target)) = nextText } diff --git a/AlgebraicDataflowArchitectureModel/models/SimpleUI3.model b/AlgebraicDataflowArchitectureModel/models/SimpleUI3.model index 14614ef..79643c3 100644 --- a/AlgebraicDataflowArchitectureModel/models/SimpleUI3.model +++ b/AlgebraicDataflowArchitectureModel/models/SimpleUI3.model @@ -1,9 +1,41 @@ init { - screen1 := { - "button1": { - "text": "bad" + screenTemplates := { + "000": { + "widgets": { + "001": {"type": "label", "text": "aid", "state": 0}, + "002": {"type": "textInput", "text": "", "state": 0}, + "003": {"type": "label", "text": "name", "state": 0}, + "004": {"type": "textInput", "text": "", "state": 0}, + "005": {"type": "button", "text": "ok", "state": 0}, + "006": {"type": "button", "text": "search", "state": 0} + }, + "layout": true + }, + "001" :{ + "widgets": { + "101": {"type": "label", "text": "success!", "state": 0}, + "102": {"type": "button", "text": "back", "state": 0} + }, + "layout": true + }, + "002": { + "widgets": { + "201": {"type": "textInput", "text": "", "state": 0}, + "202": {"type": "label", "text": "aid", "state": 0}, + "203": {"type": "label", "text": "", "state": 0} + } + }, + "409": { + "widgets": { + "491": {"type": "label", "text": "conflilct!", "state": 0}, + "492": {"type": "button", "text": "back", "state": 0} + }, + "layout": true } } + sender1 := "002" + sender2 := "004" + sender3 := "203" } native channel ScreenUpdate { @@ -46,53 +78,65 @@ out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText } -channel ChangeLayout { - out screen.layout(curLayout: Bool, changeLayout(layout)) = layout +channel addAccount { + out accounts(accounts, addAccounts(aid: Str, name: Str)) = insert(accounts, aid, name) } -channel ChangeX(wid: Str) { - out screen.widgets.{wid}.x(curX: Int, changeX(x)) = x +channel changeName(aid: Str) { + out accounts.{aid}.name(curName, changeName(nextName)) = nextName } -channel ChangeY(wid: Str) { - out screen.widgets.{wid}.y(curY: Int, changeY(y)) = y +channel ChangeCurScreen { + out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId } -channel AddButton { - out screen.widgets(widgets: Map, addButton(wid: Str, text: Str)) = insert(widgets, wid, {"type": "button", "text": text, "state": 0, "wid": wid}) +channel ScreenTransition { + in curScreen(curScId: Str, transScreen(nextScId, screen)) = nextScId + ref screenTemplates.{nextScId}(screen, transScreen(nextScId, screen)) + out screen(curS, transScreen(nextScId, screen)) = screen } -channel AddLabel { - out screen.widgets(widgets: Map, addLabel(wid: Str, text: Str)) = insert(widgets, wid, {"type": "label", "text": text, "state": 0, "wid": wid}) +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 AddTextInput { - out screen.widgets(widgets: Map, addTextInput(wid: Str)) = insert(widgets, wid, {"type": "textInput", "text": "", "state": 0, "wid": wid}) +channel EventDispatch2(wid: Str) { + in screen.widgets.{wid}.text(curText: Str, dispatchEvent(curScId, wid, nextText)) = nextText + ref curScreen(curScId: Str, dispatchEvent(curScId, wid, nextText)) + out screenTemplates.{curScId}.widgets.{wid}.text(curText: Str, dispatchEvent(curScId, wid, nextText)) = nextText } -channel buttonPushed1(wid: Str) { - in screen.widgets.{wid}.state(curState: Int, changeState(nextState: Int, nextWid)) = nextState - in screen.widgets.{wid}.wid(curWid: Int, changeState(nextState: Int, nextWid: Str)) = nextWid - out screen1.button1.text(curText: Str, changeState(nextState: Int, nextWid)) = if(nextWid == "w1", "hello", curText) +channel EventHandler2(scId: Str, wid: Str) { + in screenTemplates.{scId="000"}.widgets.{wid="006"}.state(curState: Str, handleEvent(nextState)) = nextState + out curScreen(curScId: Str, handleEvent(nextState)) = if(nextState == 0, "002", curScId) } -channel buttonPushed2(wid: Str) { - in screen.widgets.{wid}.state(curState: Int, changeState(nextState: Int, nextWid)) = nextState - in screen.widgets.{wid}.wid(curWid: Int, changeState(nextState: Int, nextWid: Str)) = nextWid - out screen1.button1.text(curText: Str, changeState(nextState: Int, nextWid)) = if(nextWid == "w2", "bad", curText) +channel EventHandler3(scId: Str, wid: Str) { + in screenTemplates.{scId="000"}.widgets.{wid="005"}.state(curState: Str, handleEvent3(nextState, t1, t2, aid, name, accounts)) = nextState + ref sender1(t1, handleEvent3(nextState, t1, t2, aid, name, accounts)) + ref sender2(t2, handleEvent3(nextState, t1, t2, aid, name, accounts)) + ref screen.widgets.{t1}.text(aid, handleEvent3(nextState, t1, t2, aid, name, accounts)) + ref screen.widgets.{t2}.text(name, handleEvent3(nextState, t1, t2, aid, name, accounts)) + ref accounts(accounts, handleEvent3(nextState, t1, t2, aid, name, accounts)) + out accounts(accounts, handleEvent3(nextState, t1, t2, aid, name, tmp)) = if(nextState==0, if(contains(accounts, aid), accounts, insert(accounts, aid, {"name": name})), accounts) + out curScreen(curScId: Str, handleEvent3(nextState, t1, t2, aid, name, accounts)) = if(nextState==0, if(contains(accounts, aid), "409", "001"), curScId) } -channel buttonPushed3{ - in screen1.button1.text(curText: Str, changeText(nextText, nextTarget)) = nextText - in screen1.button1.target(curTarget: Str, changeText(nextText, nextTarget)) = nextTarget - out screen.widgets.{nextTarget}.text(curText, changeText(nextText, nextTarget)) = nextText +channel EventHandler4(scId: Str, wid: Str) { + in screenTemplates.{scId="001"}.widgets.{wid="102"}.state(curState: Str, handleEvent4(nextState)) = nextState + out curScreen(curScId: Str, handleEvent4(nextState)) = if(nextState==0, "000", curScId) } -channel C1 { - in screen1.input1.text(curText: Str, changeText(nextText)) = nextText - out screen1.button1.text(curText: Str, changeText(nextText)) = nextText +channel EventHandler5(scId: Str, wid: Str) { + in screenTemplates.{scId="002"}.widgets.{wid="201"}.text(curText: Str, handleEvent5(nextText, target, accounts)) = nextText + ref sender3(target, handleEvent5(nextText, target, accounts)) + ref accounts(accounts, handleEvent5(nextText, target, accounts)) + out screen.widgets.{target}.text(curText, handleEvent5(nextText, target, accounts)) = if(containe(accounts, nextText), lookup(accounts, nextText), curText) } -channel setText { - out screen1.input1.text(curText: Str, changeText(nextText)) = nextText -} +channel EventHandler5(scId: Str, wid: Str) { + in screenTemplates.{scId="409"}.widgets.{wid="492"}.state(curState: Str, handleEvent5(nextState)) = nextState + out curScreen(curScId: Str, handleEvent4(nextState)) = if(nextState==0, "000", curScId) +} \ No newline at end of file