svghmi/gen_index_xhtml.xslt
changeset 3510 0d7f9c555ae2
parent 3507 e87a2daace80
child 3517 dacf329abdd9
equal deleted inserted replaced
3509:b5ca17732b1e 3510:0d7f9c555ae2
  5667 </xsl:text>
  5667 </xsl:text>
  5668     <xsl:text>         var syms = symbols.split(" ");
  5668     <xsl:text>         var syms = symbols.split(" ");
  5669 </xsl:text>
  5669 </xsl:text>
  5670     <xsl:text>         this.shift |= this.caps;
  5670     <xsl:text>         this.shift |= this.caps;
  5671 </xsl:text>
  5671 </xsl:text>
       
  5672     <xsl:text>         if(this.virgin)
       
  5673 </xsl:text>
       
  5674     <xsl:text>             this.editstr = ""; 
       
  5675 </xsl:text>
  5672     <xsl:text>         this.editstr += syms[this.shift?syms.length-1:0];
  5676     <xsl:text>         this.editstr += syms[this.shift?syms.length-1:0];
  5673 </xsl:text>
  5677 </xsl:text>
  5674     <xsl:text>         this.shift = false;
  5678     <xsl:text>         this.shift = false;
  5675 </xsl:text>
  5679 </xsl:text>
  5676     <xsl:text>         this.update();
  5680     <xsl:text>         this.update();
  5803 </xsl:text>
  5807 </xsl:text>
  5804     <xsl:text>         this.editstr = String(initial);
  5808     <xsl:text>         this.editstr = String(initial);
  5805 </xsl:text>
  5809 </xsl:text>
  5806     <xsl:text>         this.result_callback_obj = callback_obj;
  5810     <xsl:text>         this.result_callback_obj = callback_obj;
  5807 </xsl:text>
  5811 </xsl:text>
  5808     <xsl:text>         this.Info_elt.textContent = info;
  5812     <xsl:text>         if(this.Info_elt)
       
  5813 </xsl:text>
       
  5814     <xsl:text>             this.Info_elt.textContent = info;
  5809 </xsl:text>
  5815 </xsl:text>
  5810     <xsl:text>         this.shift = false;
  5816     <xsl:text>         this.shift = false;
  5811 </xsl:text>
  5817 </xsl:text>
  5812     <xsl:text>         this.caps = false;
  5818     <xsl:text>         this.caps = false;
  5813 </xsl:text>
  5819 </xsl:text>
  5815 </xsl:text>
  5821 </xsl:text>
  5816     <xsl:text>
  5822     <xsl:text>
  5817 </xsl:text>
  5823 </xsl:text>
  5818     <xsl:text>         this.update();
  5824     <xsl:text>         this.update();
  5819 </xsl:text>
  5825 </xsl:text>
       
  5826     <xsl:text>         this.virgin = true;
       
  5827 </xsl:text>
  5820     <xsl:text>     }
  5828     <xsl:text>     }
  5821 </xsl:text>
  5829 </xsl:text>
  5822     <xsl:text>
  5830     <xsl:text>
  5823 </xsl:text>
  5831 </xsl:text>
  5824     <xsl:text>     update() {
  5832     <xsl:text>     update() {
  5825 </xsl:text>
  5833 </xsl:text>
  5826     <xsl:text>         if(this.editstr != this._editstr){
  5834     <xsl:text>         if(this.editstr != this._editstr){
       
  5835 </xsl:text>
       
  5836     <xsl:text>             this.virgin = false;
  5827 </xsl:text>
  5837 </xsl:text>
  5828     <xsl:text>             this._editstr = this.editstr;
  5838     <xsl:text>             this._editstr = this.editstr;
  5829 </xsl:text>
  5839 </xsl:text>
  5830     <xsl:text>             this.Value_elt.textContent = this.editstr;
  5840     <xsl:text>             this.Value_elt.textContent = this.editstr;
  5831 </xsl:text>
  5841 </xsl:text>
  5855   <xsl:template match="widget[@type='Keypad']" mode="widget_defs">
  5865   <xsl:template match="widget[@type='Keypad']" mode="widget_defs">
  5856     <xsl:param name="hmi_element"/>
  5866     <xsl:param name="hmi_element"/>
  5857     <xsl:call-template name="defs_by_labels">
  5867     <xsl:call-template name="defs_by_labels">
  5858       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5868       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5859       <xsl:with-param name="labels">
  5869       <xsl:with-param name="labels">
  5860         <xsl:text>Esc Enter BackSpace Keys Info Value</xsl:text>
  5870         <xsl:text>Esc Enter BackSpace Keys Value</xsl:text>
  5861       </xsl:with-param>
  5871       </xsl:with-param>
  5862     </xsl:call-template>
  5872     </xsl:call-template>
  5863     <xsl:call-template name="defs_by_labels">
  5873     <xsl:call-template name="defs_by_labels">
  5864       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5874       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5865       <xsl:with-param name="labels">
  5875       <xsl:with-param name="labels">
  5866         <xsl:text>Sign Space NumDot</xsl:text>
  5876         <xsl:text>Sign Space NumDot Info</xsl:text>
  5867       </xsl:with-param>
  5877       </xsl:with-param>
  5868       <xsl:with-param name="mandatory" select="'no'"/>
  5878       <xsl:with-param name="mandatory" select="'no'"/>
  5869     </xsl:call-template>
  5879     </xsl:call-template>
  5870     <xsl:call-template name="defs_by_labels">
  5880     <xsl:call-template name="defs_by_labels">
  5871       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5881       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  5909     <xsl:text>    coordinates: [</xsl:text>
  5919     <xsl:text>    coordinates: [</xsl:text>
  5910     <xsl:value-of select="$g/@x"/>
  5920     <xsl:value-of select="$g/@x"/>
  5911     <xsl:text>, </xsl:text>
  5921     <xsl:text>, </xsl:text>
  5912     <xsl:value-of select="$g/@y"/>
  5922     <xsl:value-of select="$g/@y"/>
  5913     <xsl:text>],
  5923     <xsl:text>],
       
  5924 </xsl:text>
       
  5925     <xsl:text>    virgin: false,
  5914 </xsl:text>
  5926 </xsl:text>
  5915   </xsl:template>
  5927   </xsl:template>
  5916   <xsl:template match="widget[@type='List']" mode="widget_desc">
  5928   <xsl:template match="widget[@type='List']" mode="widget_desc">
  5917     <type>
  5929     <type>
  5918       <xsl:value-of select="@type"/>
  5930       <xsl:value-of select="@type"/>
  8042 </xsl:text>
  8054 </xsl:text>
  8043     <xsl:text>        }
  8055     <xsl:text>        }
  8044 </xsl:text>
  8056 </xsl:text>
  8045     <xsl:text>
  8057     <xsl:text>
  8046 </xsl:text>
  8058 </xsl:text>
  8047     <xsl:text>        this.curves_data = this.curves.map(_unused =&gt; []);
  8059     <xsl:text>        this.curves_data = [];
  8048 </xsl:text>
  8060 </xsl:text>
  8049     <xsl:text>    }
  8061     <xsl:text>    }
  8050 </xsl:text>
  8062 </xsl:text>
  8051     <xsl:text>
  8063     <xsl:text>
  8052 </xsl:text>
  8064 </xsl:text>
  8064 </xsl:text>
  8076 </xsl:text>
  8065     <xsl:text>        // TODO: replace with separate recording
  8077     <xsl:text>        // TODO: replace with separate recording
  8066 </xsl:text>
  8078 </xsl:text>
  8067     <xsl:text>
  8079     <xsl:text>
  8068 </xsl:text>
  8080 </xsl:text>
       
  8081     <xsl:text>        if(this.curves_data[index] === undefined){
       
  8082 </xsl:text>
       
  8083     <xsl:text>            this.curves_data[index] = [];
       
  8084 </xsl:text>
       
  8085     <xsl:text>        }
       
  8086 </xsl:text>
  8069     <xsl:text>        this.curves_data[index].push([time, value]);
  8087     <xsl:text>        this.curves_data[index].push([time, value]);
  8070 </xsl:text>
  8088 </xsl:text>
  8071     <xsl:text>        let data_length = this.curves_data[index].length;
  8089     <xsl:text>        let data_length = this.curves_data[index].length;
  8072 </xsl:text>
  8090 </xsl:text>
  8073     <xsl:text>        let ymin_damaged = false;
  8091     <xsl:text>        let ymin_damaged = false;
  8269     <xsl:text>
  8287     <xsl:text>
  8270 </xsl:text>
  8288 </xsl:text>
  8271     <xsl:text>}
  8289     <xsl:text>}
  8272 </xsl:text>
  8290 </xsl:text>
  8273   </xsl:template>
  8291   </xsl:template>
       
  8292   <func:function name="func:check_curves_label_consistency">
       
  8293     <xsl:param name="curve_elts"/>
       
  8294     <xsl:param name="number_to_check"/>
       
  8295     <xsl:variable name="res">
       
  8296       <xsl:choose>
       
  8297         <xsl:when test="$curve_elts[@inkscape:label = concat('curve_', string($number_to_check))]">
       
  8298           <xsl:if test="$number_to_check &gt; 0">
       
  8299             <xsl:value-of select="func:check_curves_label_consistency($curve_elts, $number_to_check - 1)"/>
       
  8300           </xsl:if>
       
  8301         </xsl:when>
       
  8302         <xsl:otherwise>
       
  8303           <xsl:value-of select="concat('missing curve_', string($number_to_check))"/>
       
  8304         </xsl:otherwise>
       
  8305       </xsl:choose>
       
  8306     </xsl:variable>
       
  8307     <func:result select="$res"/>
       
  8308   </func:function>
  8274   <xsl:template match="widget[@type='XYGraph']" mode="widget_defs">
  8309   <xsl:template match="widget[@type='XYGraph']" mode="widget_defs">
  8275     <xsl:param name="hmi_element"/>
  8310     <xsl:param name="hmi_element"/>
  8276     <xsl:call-template name="defs_by_labels">
  8311     <xsl:call-template name="defs_by_labels">
  8277       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  8312       <xsl:with-param name="hmi_element" select="$hmi_element"/>
  8278       <xsl:with-param name="labels">
  8313       <xsl:with-param name="labels">
  8285         <xsl:text>/y_interval_minor_mark /y_axis_line /y_interval_major_mark /y_axis_label</xsl:text>
  8320         <xsl:text>/y_interval_minor_mark /y_axis_line /y_interval_major_mark /y_axis_label</xsl:text>
  8286       </xsl:with-param>
  8321       </xsl:with-param>
  8287     </xsl:call-template>
  8322     </xsl:call-template>
  8288     <xsl:text>    init_specific() {
  8323     <xsl:text>    init_specific() {
  8289 </xsl:text>
  8324 </xsl:text>
  8290     <xsl:for-each select="$hmi_element/*[regexp:test(@inkscape:label,'^curve_[0-9]+$')]">
  8325     <xsl:variable name="curves" select="$hmi_element/*[regexp:test(@inkscape:label,'^curve_[0-9]+$')]"/>
       
  8326     <xsl:variable name="curves_error" select="func:check_curves_label_consistency($curves,count($curves)-1)"/>
       
  8327     <xsl:if test="string-length($curves_error)">
       
  8328       <xsl:message terminate="yes">
       
  8329         <xsl:text>XYGraph id="</xsl:text>
       
  8330         <xsl:value-of select="@id"/>
       
  8331         <xsl:text>", label="</xsl:text>
       
  8332         <xsl:value-of select="@inkscape:label"/>
       
  8333         <xsl:text>" : </xsl:text>
       
  8334         <xsl:value-of select="$curves_error"/>
       
  8335       </xsl:message>
       
  8336     </xsl:if>
       
  8337     <xsl:for-each select="$curves">
  8291       <xsl:variable name="label" select="@inkscape:label"/>
  8338       <xsl:variable name="label" select="@inkscape:label"/>
  8292       <xsl:variable name="id" select="@id"/>
  8339       <xsl:variable name="_id" select="@id"/>
  8293       <xsl:if test="$hmi_element/*[not($id = @id) and @inkscape:label=$label]">
  8340       <xsl:variable name="curve_num" select="substring(@inkscape:label, 7)"/>
  8294         <xsl:message terminate="yes">
       
  8295           <xsl:text>XYGraph id="</xsl:text>
       
  8296           <xsl:value-of select="$id"/>
       
  8297           <xsl:text>", label="</xsl:text>
       
  8298           <xsl:value-of select="$label"/>
       
  8299           <xsl:text>" : elements with data_n label must be unique.</xsl:text>
       
  8300         </xsl:message>
       
  8301       </xsl:if>
       
  8302       <xsl:text>        this.curves[</xsl:text>
  8341       <xsl:text>        this.curves[</xsl:text>
  8303       <xsl:value-of select="substring(@inkscape:label, 7)"/>
  8342       <xsl:value-of select="$curve_num"/>
  8304       <xsl:text>] = id("</xsl:text>
  8343       <xsl:text>] = id("</xsl:text>
  8305       <xsl:value-of select="@id"/>
  8344       <xsl:value-of select="@id"/>
  8306       <xsl:text>"); /* </xsl:text>
  8345       <xsl:text>"); /* </xsl:text>
  8307       <xsl:value-of select="@inkscape:label"/>
  8346       <xsl:value-of select="@inkscape:label"/>
  8308       <xsl:text> */
  8347       <xsl:text> */