1 <?xml version="1.0"?> |
1 <?xml version="1.0"?> |
2 <xsl:stylesheet xmlns:ns="beremiz" xmlns:definitions="definitions" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:func="http://exslt.org/functions" xmlns:epilogue="epilogue" xmlns:preamble="preamble" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:str="http://exslt.org/strings" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:exsl="http://exslt.org/common" xmlns:declarations="declarations" xmlns:debug="debug" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions" extension-element-prefixes="ns func exsl regexp str dyn" version="1.0"> |
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns:regexp="http://exslt.org/regular-expressions" xmlns:str="http://exslt.org/strings" xmlns:func="http://exslt.org/functions" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:debug="debug" xmlns:preamble="preamble" xmlns:declarations="declarations" xmlns:definitions="definitions" xmlns:epilogue="epilogue" xmlns:ns="beremiz" version="1.0" extension-element-prefixes="ns func exsl regexp str dyn" exclude-result-prefixes="ns func exsl regexp str dyn debug preamble epilogue declarations definitions"> |
3 <xsl:output method="xml" cdata-section-elements="xhtml:script"/> |
3 <xsl:output cdata-section-elements="xhtml:script" method="xml"/> |
4 <xsl:variable name="svg" select="/svg:svg"/> |
4 <xsl:variable name="svg" select="/svg:svg"/> |
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
5 <xsl:variable name="hmi_elements" select="//svg:*[starts-with(@inkscape:label, 'HMI:')]"/> |
6 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
6 <xsl:variable name="hmitree" select="ns:GetHMITree()"/> |
7 <xsl:variable name="_categories"> |
7 <xsl:variable name="_categories"> |
8 <noindex> |
8 <noindex> |
1157 </xsl:text> |
1157 </xsl:text> |
1158 <xsl:text> frequency = 5; |
1158 <xsl:text> frequency = 5; |
1159 </xsl:text> |
1159 </xsl:text> |
1160 <xsl:text> init() { |
1160 <xsl:text> init() { |
1161 </xsl:text> |
1161 </xsl:text> |
|
1162 <xsl:text> // TODO : use attributes to allow interaction through svg:use |
|
1163 </xsl:text> |
|
1164 <xsl:text> // TODO : deal with dragging |
|
1165 </xsl:text> |
1162 <xsl:text> this.element.addEventListener( |
1166 <xsl:text> this.element.addEventListener( |
1163 </xsl:text> |
1167 </xsl:text> |
1164 <xsl:text> "mousedown", |
1168 <xsl:text> "mousedown", |
1165 </xsl:text> |
1169 </xsl:text> |
1166 <xsl:text> evt => { |
1170 <xsl:text> evt => { |
2698 <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text> |
2702 <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text> |
2699 </xsl:comment> |
2703 </xsl:comment> |
2700 <xsl:comment> |
2704 <xsl:comment> |
2701 <xsl:apply-templates select="document('')/*/debug:*"/> |
2705 <xsl:apply-templates select="document('')/*/debug:*"/> |
2702 </xsl:comment> |
2706 </xsl:comment> |
2703 <html xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/1999/xhtml"> |
2707 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
2704 <head/> |
2708 <head/> |
2705 <body style="margin:0;overflow:hidden;"> |
2709 <body style="margin:0;overflow:hidden;"> |
2706 <xsl:copy-of select="$result_svg"/> |
2710 <xsl:copy-of select="$result_svg"/> |
2707 <script> |
2711 <script> |
2708 <xsl:text> |
2712 <xsl:text> |
3233 </xsl:text> |
3237 </xsl:text> |
3234 <xsl:text>} |
3238 <xsl:text>} |
3235 </xsl:text> |
3239 </xsl:text> |
3236 <xsl:text> |
3240 <xsl:text> |
3237 </xsl:text> |
3241 </xsl:text> |
|
3242 <xsl:text>quotes = {"'":null, '"':null}; |
|
3243 </xsl:text> |
|
3244 <xsl:text> |
|
3245 </xsl:text> |
3238 <xsl:text>function change_hmi_value(index, opstr) { |
3246 <xsl:text>function change_hmi_value(index, opstr) { |
3239 </xsl:text> |
3247 </xsl:text> |
3240 <xsl:text> let op = opstr[0]; |
3248 <xsl:text> let op = opstr[0]; |
3241 </xsl:text> |
3249 </xsl:text> |
3242 <xsl:text> let given_val = opstr.slice(1); |
3250 <xsl:text> let given_val; |
3243 </xsl:text> |
3251 </xsl:text> |
3244 <xsl:text> let old_val = cache[index] |
3252 <xsl:text> if(opstr.length < 2) |
|
3253 </xsl:text> |
|
3254 <xsl:text> return undefined; // TODO raise |
|
3255 </xsl:text> |
|
3256 <xsl:text> if(opstr[1] in quotes){ |
|
3257 </xsl:text> |
|
3258 <xsl:text> if(opstr.length < 3) |
|
3259 </xsl:text> |
|
3260 <xsl:text> return undefined; // TODO raise |
|
3261 </xsl:text> |
|
3262 <xsl:text> if(opstr[opstr.length-1] == opstr[1]){ |
|
3263 </xsl:text> |
|
3264 <xsl:text> given_val = opstr.slice(2,opstr.length-1); |
|
3265 </xsl:text> |
|
3266 <xsl:text> } |
|
3267 </xsl:text> |
|
3268 <xsl:text> } else { |
|
3269 </xsl:text> |
|
3270 <xsl:text> given_val = Number(opstr.slice(1)); |
|
3271 </xsl:text> |
|
3272 <xsl:text> } |
|
3273 </xsl:text> |
|
3274 <xsl:text> console.log(opstr, given_val); |
|
3275 </xsl:text> |
|
3276 <xsl:text> let old_val = cache[index]; |
3245 </xsl:text> |
3277 </xsl:text> |
3246 <xsl:text> let new_val; |
3278 <xsl:text> let new_val; |
3247 </xsl:text> |
3279 </xsl:text> |
3248 <xsl:text> switch(op){ |
3280 <xsl:text> switch(op){ |
3249 </xsl:text> |
3281 </xsl:text> |
3250 <xsl:text> case "=": |
3282 <xsl:text> case "=": |
3251 </xsl:text> |
3283 </xsl:text> |
3252 <xsl:text> eval("new_val"+opstr); |
3284 <xsl:text> new_val = given_val; |
3253 </xsl:text> |
3285 </xsl:text> |
3254 <xsl:text> break; |
3286 <xsl:text> break; |
3255 </xsl:text> |
3287 </xsl:text> |
3256 <xsl:text> case "+": |
3288 <xsl:text> case "+": |
3257 </xsl:text> |
3289 </xsl:text> |
|
3290 <xsl:text> new_val = old_val + given_val; |
|
3291 </xsl:text> |
|
3292 <xsl:text> break; |
|
3293 </xsl:text> |
3258 <xsl:text> case "-": |
3294 <xsl:text> case "-": |
3259 </xsl:text> |
3295 </xsl:text> |
|
3296 <xsl:text> new_val = old_val - given_val; |
|
3297 </xsl:text> |
|
3298 <xsl:text> break; |
|
3299 </xsl:text> |
3260 <xsl:text> case "*": |
3300 <xsl:text> case "*": |
3261 </xsl:text> |
3301 </xsl:text> |
|
3302 <xsl:text> new_val = old_val * given_val; |
|
3303 </xsl:text> |
|
3304 <xsl:text> break; |
|
3305 </xsl:text> |
3262 <xsl:text> case "/": |
3306 <xsl:text> case "/": |
3263 </xsl:text> |
3307 </xsl:text> |
3264 <xsl:text> if(old_val != undefined) |
3308 <xsl:text> new_val = old_val / given_val; |
3265 </xsl:text> |
|
3266 <xsl:text> new_val = eval("old_val"+opstr); |
|
3267 </xsl:text> |
3309 </xsl:text> |
3268 <xsl:text> break; |
3310 <xsl:text> break; |
3269 </xsl:text> |
3311 </xsl:text> |
3270 <xsl:text> } |
3312 <xsl:text> } |
3271 </xsl:text> |
3313 </xsl:text> |
3272 <xsl:text> if(new_val != undefined && old_val != new_val) |
3314 <xsl:text> if(new_val != undefined && old_val != new_val) |
3273 </xsl:text> |
3315 </xsl:text> |
3274 <xsl:text> send_hmi_value(index, new_val); |
3316 <xsl:text> send_hmi_value(index, new_val); |
|
3317 </xsl:text> |
|
3318 <xsl:text> // TODO else raise |
3275 </xsl:text> |
3319 </xsl:text> |
3276 <xsl:text> return new_val; |
3320 <xsl:text> return new_val; |
3277 </xsl:text> |
3321 </xsl:text> |
3278 <xsl:text>} |
3322 <xsl:text>} |
3279 </xsl:text> |
3323 </xsl:text> |