changeset 1577:e8161fdda8ad

paint shows deviceattrs from graph Ignore-this: bf4b4b7c1f51af0a4f6b64f4800c1d3c
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 29 May 2017 20:48:22 +0000
parents ef7ddef3acb5
children 519480f2e51c
files light9/web/paint/paint-elements.coffee light9/web/paint/paint-elements.html light9/web/paint/paint-report-elements.html show/dance2017/deviceClass.n3
diffstat 4 files changed, 54 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/paint/paint-elements.coffee	Mon May 29 08:31:26 2017 +0000
+++ b/light9/web/paint/paint-elements.coffee	Mon May 29 20:48:22 2017 +0000
@@ -118,6 +118,7 @@
 Polymer
   is: "light9-simulation"
   properties: {
+    graph: { type: Object }
     layers: { type: Object }
     solution: { type: Object }
   }
@@ -129,6 +130,35 @@
   onLayers: (layers) ->
     log('upd', layers)
 
+
+Polymer
+  is: "light9-device-settings",
+  properties: {
+    graph: { type: Object }
+    subj: {type: String, notify: true},
+    label: {type: String, notify: true},
+    attrs: {type: Array, notify: true},
+  },
+  observers: [
+    'onSubj(graph, subj)'
+  ]
+  ready: ->
+    @label = "aura2"
+    @attrs = [
+        {attr: 'rx', val: .03},
+        {attr: 'color', val: '#ffe897'},
+    ]
+  onSubj: (graph, @subj) ->
+    graph.runHandler(@loadAttrs.bind(@), 'loadAttrs #{subj}')
+  loadAttrs: ->
+    U = (x) -> @graph.Uri(x)
+    @attrs = []
+    for s in @graph.objects(U(@subj), U(':setting'))
+      attr = @graph.uriValue(s, U(':deviceAttr'))
+      attrLabel = @graph.stringValue(attr, U('rdfs:label'))
+      @push('attrs', {attr: attrLabel, val: @graph.floatValue(s, U(':value'))})
+    
+
     
 Polymer
   is: "light9-paint"
--- a/light9/web/paint/paint-elements.html	Mon May 29 08:31:26 2017 +0000
+++ b/light9/web/paint/paint-elements.html	Mon May 29 20:48:22 2017 +0000
@@ -5,6 +5,7 @@
 <link rel="import" href="/lib/paper-radio-group/paper-radio-group.html">
 <link rel="import" href="/lib/paper-radio-button/paper-radio-button.html">
 <link rel="import" href="paint-report-elements.html">
+<link rel="import" href="../rdfdb-synced-graph.html">
 
 
 <dom-module id="light9-paint-canvas">
@@ -92,12 +93,19 @@
 
 <dom-module id="light9-paint">
   <template>
+    <rdfdb-synced-graph graph="{{graph}}"></rdfdb-synced-graph>
+
     <light9-paint-canvas id="canvas" bg="bg2.jpg" painting="{{painting}}"></light9-paint-canvas>
 
     <iron-ajax id="solve" method="POST" url="../paintServer/solve" last-response="{{solve}}"></iron-ajax>
     
-    <light9-simulation solution="{{solve}}" layers="{{layers}}"></light9-simulation>
+    <light9-simulation graph="{{graph}}" solution="{{solve}}" layers="{{layers}}"></light9-simulation>
   </template>
 </dom-module>
 
+<script src="/lib/N3.js-pull61/browser/n3-browser.js"></script>
+<script src="/lib/shortcut/index.js"></script>
+<script src="/lib/underscore/underscore-min.js"></script>
+<script src="/lib/async/dist/async.js"></script>
+
 <script src="paint-elements.js"></script>
--- a/light9/web/paint/paint-report-elements.html	Mon May 29 08:31:26 2017 +0000
+++ b/light9/web/paint/paint-report-elements.html	Mon May 29 20:48:22 2017 +0000
@@ -25,7 +25,7 @@
 
         <div>Error: {{solution.bestMatch.dist}}</div>
         
-        <light9-device-settings></light9-device-settings>
+        <light9-device-settings graph="{{graph}}" subj="{{solution.bestMatch.uri}}"></light9-device-settings>
       </div>
 
       <!-- existing effect best match? -->
@@ -102,7 +102,7 @@
          font-weight: bold;
      }
     </style>
-    <h3>{{label}}</h3>
+    <h3><a href="{{subj}}">{{label}}</a></h3>
     <table class="borders">
       <tr>
         <th>device attr</th>
@@ -116,25 +116,7 @@
       </template>
 
   </template>
-  <script>
-   Polymer({
-       is: "light9-device-settings",
-       properties: {
-           label: {type: String, notify: true},
-           attrs: {type: Array, notify: true},
-
-       },
-       ready: function() {
-
-           this.label = "aura2";
-           this.attrs = [
-               {attr: 'rx', val: .03},
-               {attr: 'color', val: '#ffe897'},
-           ];
-           
-       }
-   });
-  </script>
+ 
 </dom-module>
 
 <dom-module id="light9-capture-image">
--- a/show/dance2017/deviceClass.n3	Mon May 29 08:31:26 2017 +0000
+++ b/show/dance2017/deviceClass.n3	Mon May 29 20:48:22 2017 +0000
@@ -1,21 +1,21 @@
 @prefix : <http://light9.bigasterisk.com/> .
 @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
-:color              a :DeviceAttr; :dataType :color .
-:rx                 a :DeviceAttr; :dataType :angle .
-:ry                 a :DeviceAttr; :dataType :angle .
-:uv                 a :DeviceAttr; :dataType :scalar .
-:brightness         a :DeviceAttr; :dataType :scalar .
-:zoom               a :DeviceAttr; :dataType :scalar ;
+:color              a :DeviceAttr; rdfs:label "color"; :dataType :color .
+:rx                 a :DeviceAttr; rdfs:label "rx"; :dataType :angle .
+:ry                 a :DeviceAttr; rdfs:label "ry"; :dataType :angle .
+:uv                 a :DeviceAttr; rdfs:label "uv"; :dataType :scalar .
+:brightness         a :DeviceAttr; rdfs:label "brightness"; :dataType :scalar .
+:zoom               a :DeviceAttr; rdfs:label "zoom"; :dataType :scalar ;
   rdfs:comment "maybe make this a separate 'wide to narrow' type" .
-:focus              a :DeviceAttr; :dataType :scalar .
-:iris               a :DeviceAttr; :dataType :scalar .
-:prism              a :DeviceAttr; :dataType :scalar .
-:strobe             a :DeviceAttr; :dataType :scalar;
+:focus              a :DeviceAttr; rdfs:label "focus"; :dataType :scalar .
+:iris               a :DeviceAttr; rdfs:label "iris"; :dataType :scalar .
+:prism              a :DeviceAttr; rdfs:label "prism"; :dataType :scalar .
+:strobe             a :DeviceAttr; rdfs:label "strobe"; :dataType :scalar;
   rdfs:comment "0=none, 1=fastest" .
-:goboSpeed          a :DeviceAttr; :dataType :scalar ;
+:goboSpeed          a :DeviceAttr; rdfs:label "goboSpeed"; :dataType :scalar ;
   rdfs:comment "0=stopped, 1=rotate the fastest".
-:quantumGoboChoice  a :DeviceAttr; :dataType :choice;
+:quantumGoboChoice  a :DeviceAttr; rdfs:label "quantumGoboChoice"; :dataType :choice;
   :choice :open, :spider, :windmill, :limbo, :brush, :whirlpool, :stars .