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

Request.target is now a real terminal.

parent 4401c24e
No related branches found
No related tags found
No related merge requests found
......@@ -16,4 +16,4 @@
(define (do-it . args)
(let ([ast (create-system 10 0 3 4 5)])
(display-ast ast 'remote-unit 'remote-container))))
(display-ast ast 'remote-unit 'remote-container 'remote-impls))))
......@@ -139,7 +139,7 @@
(define (create-request target-property)
(let* ([make-req (lambda (propname maxVal digits offset) (:ReqClause mquat-spec (:PropertyRef mquat-spec propname) comp-min-eq (rand maxVal digits offset)))]
[target (<<- target-property)])
[target (->name (<<- target-property))])
(debug "create-request: target-property = " target-property)
(:Request
mquat-spec
......
......@@ -17,7 +17,7 @@
->ResourceType* ; HWRoot
->container? ; ResourceType
->status ->ProvClause* ; Resource
->MetaParameter* ->target ->Constraints ->objective ; Request
->MetaParameter* ->Constraints ->objective ; Request
->unit ->kind ->direction ->agg ; Property
:Root :RealProperty :PropertyRef
:SWRoot :Comp :Impl :Mode :ReqClause :ProvClause
......@@ -43,7 +43,6 @@
(define (->container? n) (ast-child 'container n))
(define (->ProvClause* n) (ast-child 'ProvClause* n))
(define (->MetaParameter* n) (ast-child 'MetaParameter* n))
(define (->target n) (ast-child 'target n))
(define (->Constraints n) (ast-child 'Constraints n))
(define (->objective n) (ast-child 'objective n))
(define (->ReturnType n) (ast-child 'ReturnType n))
......@@ -91,6 +90,7 @@
(ast-rule 'ResourceType->name-container-Property*)
; typename points to a ResourceType
(ast-rule 'Resource->name-typename-status-Resource*<SubResources-ProvClause*)
; target points to a Comp
(ast-rule 'Request->MetaParameter*-target-ReqClause*<Constraints-objective)
(ast-rule 'MetaParameter->name-value)
(ast-rule 'Property->)
......
......@@ -9,7 +9,7 @@
(export add-basic-ags
=objective-val =objective-name =clauses-met?
=mode-to-use =selected? =deployed? =hw?
=req-comp-map =req-comp-min =req-comp-all =real =type
=req-comp-map =req-comp-min =req-comp-all =real =target =type
=eval =eval-on =value-of =actual-value =value-attr =maximum
<=request <=impl <=comp
=search-prov-clause =search-req-clause =search-pe =provided-clause
......@@ -45,6 +45,9 @@
(define (=real n) (att-value 'real n))
(define (<=root n) (att-value 'get-root n))
(define (=selected? n) (att-value 'selected? n))
(define =target
(case-lambda [(n name) (att-value 'target n name)]
[(n) (att-value 'target n)]))
(define =type
(case-lambda [(n name) (att-value 'type n name)]
[(n) (att-value 'type n)]))
......@@ -152,14 +155,14 @@
; =every-comp: Returns a list containing every component, that may be needed for the request
(ag-rule
every-comp
(Root (lambda (n) (=every-comp (->target (<=request n)))))
(Root (lambda (n) (=every-comp (=target (<=request n)))))
(Comp (lambda (n) (cons n (fold-left (lambda (result c) (append (=every-comp c) result))
(list) (=req-comp-all n))))))
; =every-impl: Returns a list containing every implementation, that may be needed for the request
(ag-rule
every-impl
(Root (lambda (n) (=every-impl (->target (<=request n)))))
(Root (lambda (n) (=every-impl (=target (<=request n)))))
(Comp (lambda (n) (append (->* (->Impl* n)) (fold-left (lambda (result c) (append (=every-impl c) result))
(list) (=req-comp-all n))))))
......@@ -319,12 +322,21 @@
; =selected?: Returns #t, if the Implementation is selected by its component
(ag-rule selected? (Impl (lambda (n) (eq? (->selected-impl (<<- n)) n))))
; =remote-container: 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)))))
; =remote-unit: Returns the unit of the RealProperty the PropertyRef is pointing to
; [DEBUGGING] Returns the unit of the RealProperty the PropertyRef is pointing to
(ag-rule remote-unit (PropertyRef (lambda (n) (->unit (=real n)))))
; [DEBUGGING] Returns the names of all implements of the Component the Request is pointing to
(ag-rule remote-impls (Request (lambda (n) (map ->name (->* (->Impl* (=target n)))))))
; =target: Resolves the component of a Request
(ag-rule
target
(Request (lambda (n) (=target (<=root n) (ast-child 'target n))))
(Root (lambda (n compname) (ast-find-child (lambda (i c) (string=? compname (->name c))) (->Comp* (->SWRoot n))))))
; =type: Resolves the type of a Resource
(ag-rule
type
......
......@@ -92,7 +92,7 @@
(:Root mquat-spec
(:HWRoot mquat-spec (list Cubieboard) (list cubie1 cubie2) (list))
(:SWRoot mquat-spec (list comp1 comp2) (list energy))
(:Request mquat-spec (list (make-mp-size 50)) comp1
(:Request mquat-spec (list (make-mp-size 50)) (->name comp1)
(list (:ReqClause mquat-spec (make-ref rt-C1) comp-max-eq (lambda _ 0.3))) #f) #f)))
(define comp1 (ast-child 1 (->Comp* (->SWRoot the-example-ast))))
......
......@@ -293,7 +293,7 @@
; 11 remove some modes
(define (run-complex-test id-s specs)
(define (new-request-comp ast)
(let ([req-comp-nr (ast-child-index (->target (<=request ast)))]
(let ([req-comp-nr (ast-child-index (=target (<=request ast)))]
[new-comp-nr (+ 1 (ast-num-children (->Comp* (->SWRoot ast))))])
;params of add-mode: ast comp-nr impl-nr mode-nr req-comp-nr load-f energy-f prov-f prev-f
(add-mode ast new-comp-nr 1 1 ;comp-nr impl-nr mode-nr
......
......@@ -177,7 +177,7 @@
(list "-" (=ilp-binvar n) "=" 0)
(=every-container n))))))
(ag-rule request-target? (Comp (lambda (n) (eq? (->target (<=request n)) n))))
(ag-rule request-target? (Comp (lambda (n) (eq? (=target (<=request n)) n))))
(ag-rule
ilp-objective
......@@ -222,9 +222,9 @@
(lambda (n)
(att-value-compute 'ilp-nego-sw)
(cons (cons "request_target: " (fold-left (lambda (result impl) (cons* "+" (=ilp-binvar impl) result))
(list "=" 1) (->* (->Impl* (->target n)))))
(list "=" 1) (->* (->Impl* (=target n)))))
(make-constraints
(=ilp-nego-reqc (->target n) 'ProvClause comp-eq) ;provs
(=ilp-nego-reqc (=target n) 'ProvClause comp-eq) ;provs
(=ilp-nego-reqc n comp-max-eq) ;max-reqs
(=ilp-nego-reqc n comp-min-eq) #t))))) ;min-reqs,request?
(ag-rule
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment