svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2856 1b529ba018ad
parent 2854 c7d5f46cc306
child 2857 a5c781b2f8f9
equal deleted inserted replaced
2855:525211a54b14 2856:1b529ba018ad
   421 </xsl:text>
   421 </xsl:text>
   422     <xsl:text>var hmi_widgets = {
   422     <xsl:text>var hmi_widgets = {
   423 </xsl:text>
   423 </xsl:text>
   424     <xsl:for-each select="$hmi_elements">
   424     <xsl:for-each select="$hmi_elements">
   425       <xsl:variable name="widget" select="func:parselabel(@inkscape:label)/widget"/>
   425       <xsl:variable name="widget" select="func:parselabel(@inkscape:label)/widget"/>
       
   426       <xsl:variable name="eltid" select="@id"/>
   426       <xsl:text>  "</xsl:text>
   427       <xsl:text>  "</xsl:text>
   427       <xsl:value-of select="@id"/>
   428       <xsl:value-of select="@id"/>
   428       <xsl:text>": {
   429       <xsl:text>": {
   429 </xsl:text>
   430 </xsl:text>
   430       <xsl:text>    type: "</xsl:text>
   431       <xsl:text>    type: "</xsl:text>
   451         <xsl:variable name="hmipath" select="@value"/>
   452         <xsl:variable name="hmipath" select="@value"/>
   452         <xsl:variable name="hmitree_match" select="$indexed_hmitree/*[@hmipath = $hmipath]"/>
   453         <xsl:variable name="hmitree_match" select="$indexed_hmitree/*[@hmipath = $hmipath]"/>
   453         <xsl:choose>
   454         <xsl:choose>
   454           <xsl:when test="count($hmitree_match) = 0">
   455           <xsl:when test="count($hmitree_match) = 0">
   455             <xsl:message terminate="no">
   456             <xsl:message terminate="no">
   456               <xsl:text>No match for path "</xsl:text>
   457               <xsl:text>Widget </xsl:text>
       
   458               <xsl:value-of select="$widget/@type"/>
       
   459               <xsl:text> id="</xsl:text>
       
   460               <xsl:value-of select="$eltid"/>
       
   461               <xsl:text>" : No match for path "</xsl:text>
   457               <xsl:value-of select="$hmipath"/>
   462               <xsl:value-of select="$hmipath"/>
   458               <xsl:text>" in HMI tree</xsl:text>
   463               <xsl:text>" in HMI tree</xsl:text>
   459             </xsl:message>
   464             </xsl:message>
   460           </xsl:when>
   465           </xsl:when>
   461           <xsl:otherwise>
   466           <xsl:otherwise>
  1293     <xsl:text>    frequency: 10,
  1298     <xsl:text>    frequency: 10,
  1294 </xsl:text>
  1299 </xsl:text>
  1295     <xsl:call-template name="defs_by_labels">
  1300     <xsl:call-template name="defs_by_labels">
  1296       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1301       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  1297       <xsl:with-param name="labels">
  1302       <xsl:with-param name="labels">
  1298         <xsl:text>value min max needle range</xsl:text>
  1303         <xsl:text>needle range</xsl:text>
  1299       </xsl:with-param>
  1304       </xsl:with-param>
  1300     </xsl:call-template>
  1305     </xsl:call-template>
       
  1306     <xsl:call-template name="defs_by_labels">
       
  1307       <xsl:with-param name="hmi_element" select="$hmi_element"/>
       
  1308       <xsl:with-param name="labels">
       
  1309         <xsl:text>value min max</xsl:text>
       
  1310       </xsl:with-param>
       
  1311       <xsl:with-param name="mandatory" select="'no'"/>
       
  1312     </xsl:call-template>
  1301     <xsl:text>    dispatch: function(value) {
  1313     <xsl:text>    dispatch: function(value) {
  1302 </xsl:text>
  1314 </xsl:text>
  1303     <xsl:text>        this.value_elt.textContent = String(value);
  1315     <xsl:text>        if(this.value_elt)
       
  1316 </xsl:text>
       
  1317     <xsl:text>            this.value_elt.textContent = String(value);
  1304 </xsl:text>
  1318 </xsl:text>
  1305     <xsl:text>        let [min,max,totallength] = this.range;
  1319     <xsl:text>        let [min,max,totallength] = this.range;
  1306 </xsl:text>
  1320 </xsl:text>
  1307     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
  1321     <xsl:text>        let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
  1308 </xsl:text>
  1322 </xsl:text>
  1316 </xsl:text>
  1330 </xsl:text>
  1317     <xsl:text>    range: undefined,
  1331     <xsl:text>    range: undefined,
  1318 </xsl:text>
  1332 </xsl:text>
  1319     <xsl:text>    init: function() {
  1333     <xsl:text>    init: function() {
  1320 </xsl:text>
  1334 </xsl:text>
  1321     <xsl:text>        this.range = [Number(this.min_elt.textContent), Number(this.max_elt.textContent), this.range_elt.getTotalLength()]
  1335     <xsl:text>        let min = this.min_elt ? Number(this.min_elt.textContent) : 0;
       
  1336 </xsl:text>
       
  1337     <xsl:text>        let max = this.max_elt ? Number(this.max_elt.textContent) : 100;
       
  1338 </xsl:text>
       
  1339     <xsl:text>        this.range = [min, max, this.range_elt.getTotalLength()]
  1322 </xsl:text>
  1340 </xsl:text>
  1323     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  1341     <xsl:text>        this.origin = this.needle_elt.getPointAtLength(0);
  1324 </xsl:text>
  1342 </xsl:text>
  1325     <xsl:text>    },
  1343     <xsl:text>    },
  1326 </xsl:text>
  1344 </xsl:text>