Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / models / SimpleUI4.model
init {
    screenTemplates := {
        "screen1":{
    "widgets": {
        "e6f7bcd0c6554748a87b74a3b39eea82": {"type": "button", "text": "button", "visible": true, "x": 175, "y": 200, "width": 100, "height": 40},
		"f6af87118f8c4fa284a4a226f5369dd7": {"type": "label", "text": "label", "visible": true, "x": 99, "y": 23, "width": 100, "height": 40},
		"idInput": {"type": "textInput", "text": "textInput", "visible": true, "x": 94, "y": 64, "width": 100, "height": 40},
		"nameInput": {"type": "textInput", "text": "textInput", "visible": true, "x": 96, "y": 126, "width": 100, "height": 40}
    },
    "layout": false
},
		"screen2":{
    "widgets": {
        "6ce2109a701e4883ac50f3f726ee1e47": {"type": "button", "text": "button", "visible": true, "x": 141, "y": 43, "width": 355, "height": 164}
    },
    "layout": false
}
    }
    idInput := "idInput"
	nameInput := "nameInput"
}
native channel ScreenUpdate {
	in screen(curSc: Json, update(curSc, nextSc)) = nextSc
}

native channel SetLayout {
	in screen.layout(curLayout: Bool, setLayout(nextLayout)) = nextLayout
}

native channel SetVisible(wid: Str) {
	in screen.widgets.{wid}.visible(curVisible: Bool, setVisible(nextVisible)) = nextVisible
}

native channel SetText(wid: Str) {
	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
}

native channel TextEvent(wid: Str) {
	out screen.widgets.{wid}.text(curText: Str, textEvent(nextText)) = nextText
}

channel ChangeCurScreen {
	out curScreen(curScId: Str, changeCurScreen(nextScId)) = nextScId
}

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, 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 e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(scId: Str, wid: Str){
	in screenTemplates.{scId="screen1"}.widgets.{wid="e6f7bcd0c6554748a87b74a3b39eea82"}.state(curState, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef)) = nextState
	ref idInput(idInput, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef))
	ref screen.widgets.{idInput}.text(id, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef))
	ref nameInput(nameInput, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef))
	ref screen.widgets.{nameInput}.text(name, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef))
	ref accounts(accountsRef, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef))
	out accounts(accounts: Map, e6f7bcd0c6554748a87b74a3b39eea82AccountsSetData(nextState, id, idInput, name, nameInput, accountsRef)) = if((nextState == 0) && (id != "") && (!contains(accountsRef, id)), insert(accounts, id, {"name": name}), accounts)
}

channel addTweets {
    out tweets(tweets: Map, addTweets(tid: Str, contents: Str, idOfAuthor: Str)) = insert(tweets, tid, {"contents": contents,"idOfAuthor": idOfAuthor})
}

channel changeContentsOfTweets(tid: Str) {
    out tweets.{tid}.contents(contents: Str, changeContentsOfTweets(newContents: Str)) = newContents
}

channel changeIdOfAuthorOfTweets(tid: Str) {
    out tweets.{tid}.idOfAuthor(idOfAuthor: Str, changeIdOfAuthorOfTweets(newIdOfAuthor: Str)) = newIdOfAuthor
}

channel nameOfAuthorOfTweets(tid: Str){
    in tweets.{tid}.idOfAuthor(idOfAuthor: Str, nameOfAuthorOfTweets(newIdOfAuthor: Str, newNameOfAuthor: Str)) = newIdOfAuthor
    in accounts.{newIdOfAuthor}.name(name: Str, nameOfAuthorOfTweets(newIdOfAuthor, newNameOfAuthor)) = newNameOfAuthor
    out tweets.{tid}.nameOfAuthor(nameOfAuthor, nameOfAuthorOfTweets(newIdOfAuthor, newNameOfAuthor)) = newNameOfAuthor
} 

channel addAccounts {
    out accounts(accounts: Map, addAccounts(id: Str, name: Str)) = insert(accounts, id, {"name": name})
}

channel changeNameOfAccounts(id: Str) {
    out accounts.{id}.name(name: Str, changeNameOfAccounts(newName: Str)) = newName
}