Skip to content
Snippets Groups Projects
Commit 79483a51 authored by René Schöne's avatar René Schöne
Browse files

Comp.selectedimpl is now a real terminal.

parent 2118e055
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
->name ->Property* ->* <- <<- ->SubResources ->value ; common ->name ->Property* ->* <- <<- ->SubResources ->value ; common
->HWRoot ->SWRoot ; Root ->HWRoot ->SWRoot ; Root
->Comp* ->RealProperty* ; SWRoot ->Comp* ->RealProperty* ; SWRoot
->Impl* ->selected-impl ; Comp ->Impl* ; Comp
->Mode* ->deployed-on ->selected-mode ; Impl ->Mode* ->deployed-on ->selected-mode ; Impl
->Clause* ; Mode ->Clause* ; Mode
->ReturnType ->comparator ; Clause ->ReturnType ->comparator ; Clause
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
(define (->RealProperty* n) (ast-child 'RealProperty* n)) (define (->RealProperty* n) (ast-child 'RealProperty* n))
(define (->name n) (ast-child 'name n)) (define (->name n) (ast-child 'name n))
(define (->Impl* n) (ast-child 'Impl* n)) (define (->Impl* n) (ast-child 'Impl* n))
(define (->selected-impl n) (ast-child 'selectedimpl n)) ; (define (->selected-impl n) (ast-child 'selectedimpl n))
(define (->Property* n) (ast-child 'Property* n)) (define (->Property* n) (ast-child 'Property* n))
(define (->deployed-on n) (ast-child 'deployedon n)) (define (->deployed-on n) (ast-child 'deployedon n))
(define (->selected-mode n) (ast-child 'selectedmode n)) (define (->selected-mode n) (ast-child 'selectedmode n))
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
(ast-rule 'Root->HWRoot-SWRoot-Request-config) (ast-rule 'Root->HWRoot-SWRoot-Request-config)
(ast-rule 'SWRoot->Comp*-RealProperty*) (ast-rule 'SWRoot->Comp*-RealProperty*)
; selectedimpl points to a Impl
(ast-rule 'Comp->name-Impl*-selectedimpl-Property*) (ast-rule 'Comp->name-Impl*-selectedimpl-Property*)
(ast-rule 'Impl->name-Mode*-reqcomps-deployedon-selectedmode) (ast-rule 'Impl->name-Mode*-reqcomps-deployedon-selectedmode)
(ast-rule 'Mode->name-Clause*) (ast-rule 'Mode->name-Clause*)
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
(define (<=request n) (att-value 'get-request n)) (define (<=request n) (att-value 'get-request n))
(define (=real n) (att-value 'real n)) (define (=real n) (att-value 'real n))
(define (<=root n) (att-value 'get-root n)) (define (<=root n) (att-value 'get-root n))
(define (=selected-impl n) (att-value 'selected-impl n))
(define (=selected? n) (att-value 'selected? n)) (define (=selected? n) (att-value 'selected? n))
(define =target (define =target
(case-lambda [(n name) (att-value 'target n name)] (case-lambda [(n name) (att-value 'target n name)]
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
; hw → search in deployedon for name and type ; hw → search in deployedon for name and type
(=provided-clause (->deployed-on (<=impl n)) propName target) (=provided-clause (->deployed-on (<=impl n)) propName target)
; sw → search in target-component ; sw → search in target-component
(=provided-clause (=mode-to-use (->selected-impl target)) propName))) (=provided-clause (=mode-to-use (=selected-impl target)) propName)))
(->MetaParameter* (<=request n)))))) ; Params from request, applied to the value function (->MetaParameter* (<=request n)))))) ; Params from request, applied to the value function
(ProvClause (lambda (n) (=eval n)))) (ProvClause (lambda (n) (=eval n))))
...@@ -100,7 +101,7 @@ ...@@ -100,7 +101,7 @@
(ag-rule (ag-rule
clauses-met? clauses-met?
(Root (lambda (n) (and (=clauses-met? (<=request n)) (for-all =clauses-met? (->* (->Comp* (->SWRoot n))))))) (Root (lambda (n) (and (=clauses-met? (<=request n)) (for-all =clauses-met? (->* (->Comp* (->SWRoot n)))))))
(Comp (lambda (n) (=clauses-met? (->selected-impl n)))) (Comp (lambda (n) (=clauses-met? (=selected-impl n))))
(Impl (lambda (n) (=clauses-met? (=mode-to-use n)))) (Impl (lambda (n) (=clauses-met? (=mode-to-use n))))
(Mode (lambda (n) (for-all =clauses-met? (->* (->Clause* n))))) (Mode (lambda (n) (for-all =clauses-met? (->* (->Clause* n)))))
(ReqClause (lambda (n) ((comp->f (->comparator n)) (=eval n) (=actual-value n)))) (ReqClause (lambda (n) ((comp->f (->comparator n)) (=eval n) (=actual-value n))))
...@@ -225,7 +226,7 @@ ...@@ -225,7 +226,7 @@
objective-value objective-value
(Root (lambda (n) (=objective-val (->SWRoot n)))) (Root (lambda (n) (=objective-val (->SWRoot n))))
(SWRoot (lambda (n) (fold-left (lambda (total comp) (+ total (=objective-val comp))) 0 (->* (->Comp* (->SWRoot n)))))) (SWRoot (lambda (n) (fold-left (lambda (total comp) (+ total (=objective-val comp))) 0 (->* (->Comp* (->SWRoot n))))))
(Comp (lambda (n) (=objective-val (->selected-impl n)))) (Comp (lambda (n) (=objective-val (=selected-impl n))))
(Impl (lambda (n) (=objective-val (=mode-to-use n)))) (Impl (lambda (n) (=objective-val (=mode-to-use n))))
(Mode (lambda (n) (=eval (=provided-clause n (=objective-name n)))))) (Mode (lambda (n) (=eval (=provided-clause n (=objective-name n))))))
...@@ -319,8 +320,14 @@ ...@@ -319,8 +320,14 @@
(Resource (lambda (n name) (or (string=? (->name n) name) (ast-find-child (lambda (i pe) (=search-pe pe name)) (Resource (lambda (n name) (or (string=? (->name n) name) (ast-find-child (lambda (i pe) (=search-pe pe name))
(->SubResources n)))))) (->SubResources n))))))
; =selected-impl: Resolves the selected implementation of a component
(ag-rule
selected-impl
(Comp (lambda (n) (let ([si (ast-child 'selectedimpl n)])
(and si (ast-find-child (lambda (j i) (string=? si (->name i))) (->Impl* n)))))))
; =selected?: Returns #t, if the Implementation is selected by its component ; =selected?: Returns #t, if the Implementation is selected by its component
(ag-rule selected? (Impl (lambda (n) (eq? (->selected-impl (<<- n)) n)))) (ag-rule selected? (Impl (lambda (n) (eq? (=selected-impl (<<- n)) n))))
; [DEBUGGING] Returns whether the ResourceType, the Resource is pointing to, is a container ; [DEBUGGING] Returns whether the ResourceType, the Resource is pointing to, is a container
(ag-rule remote-container (Resource (lambda (n) (->container? (=type n))))) (ag-rule remote-container (Resource (lambda (n) (->container? (=type n)))))
......
...@@ -87,10 +87,10 @@ ...@@ -87,10 +87,10 @@
; Given a component (or an impl) and a resource, change deployed-on of the selected impl ; Given a component (or an impl) and a resource, change deployed-on of the selected impl
; of the given component (or the given impl) to the given resource, returning the old resource ; of the given component (or the given impl) to the given resource, returning the old resource
(define (deploy-on x new-pe) (rewrite-terminal 'deployedon (if (ast-subtype? x 'Comp) (->selected-impl x) x) new-pe)) (define (deploy-on x new-pe) (rewrite-terminal 'deployedon (if (ast-subtype? x 'Comp) (=selected-impl x) x) new-pe))
(define (use-next-impl comp) (define (use-next-impl comp)
(let* ([former-impl (->selected-impl comp)] (let* ([former-impl (=selected-impl comp)]
[former-index (ast-child-index former-impl)] [former-index (ast-child-index former-impl)]
[num-impls (ast-num-children (->Impl* comp))] [num-impls (ast-num-children (->Impl* comp))]
[former-deployed (->deployed-on former-impl)] [former-deployed (->deployed-on former-impl)]
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
[first-new-mode (car (->* (->Mode* new-impl)))]) [first-new-mode (car (->* (->Mode* new-impl)))])
(rewrite-terminal 'deployedon former-impl #f) (rewrite-terminal 'deployedon former-impl #f)
(rewrite-terminal 'selectedmode former-impl #f) (rewrite-terminal 'selectedmode former-impl #f)
(rewrite-terminal 'selectedimpl comp new-impl) (rewrite-terminal 'selectedimpl comp (->name new-impl))
(rewrite-terminal 'deployedon new-impl former-deployed) (rewrite-terminal 'deployedon new-impl former-deployed)
(rewrite-terminal 'selectedmode new-impl first-new-mode) ; use first mode (rewrite-terminal 'selectedmode new-impl first-new-mode) ; use first mode
new-impl)) new-impl))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment