diff -r d000a91d1e95 -r 8a9d4c794cba svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Mon May 03 00:14:11 2021 +0200 +++ b/svghmi/gen_index_xhtml.xslt Mon May 03 00:14:38 2021 +0200 @@ -136,6 +136,7 @@ + @@ -181,22 +182,29 @@ - - + + + + + + + + + - + + + + - - - - + Widget id: @@ -258,9 +266,9 @@ @ - : + , - : + , @@ -677,7 +685,7 @@ } - + } @@ -708,7 +716,7 @@ - + @@ -1870,8 +1878,10 @@ - - class AnimateWidget extends Widget{ + + class + AnimateWidget + extends Widget{ frequency = 5; @@ -1954,98 +1964,98 @@ } - + + class + AnimateRotationWidget + extends Widget{ + + frequency = 5; + + speed = 0; + + widget_center = undefined; + + + + dispatch(value) { + + this.speed = value / 5; + + + + //reconfigure animation + + this.request_animate(); + + } + + + + animate(){ + + // change animation properties + + for(let child of this.element.children){ + + if(child.nodeName == "animateTransform"){ + + if(this.speed > 0){ + + child.setAttribute("dur", this.speed+"s"); + + child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); + + child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]); + + } + + else if(this.speed < 0){ + + child.setAttribute("dur", (-1)*this.speed+"s"); + + child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]); + + child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); + + } + + else{ + + child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); + + child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); + + } + + } + + } + + } + + + + init() { + + let widget_pos = this.element.getBBox(); + + this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)]; + + } + + } + + + - - - - - class AnimateRotationWidget extends Widget{ - - frequency = 5; - - speed = 0; - - widget_center = undefined; - - - - dispatch(value) { - - this.speed = value / 5; - - - - //reconfigure animation - - this.request_animate(); - - } - - - - animate(){ - - // change animation properties - - for(let child of this.element.children){ - - if(child.nodeName == "animateTransform"){ - - if(this.speed > 0){ - - child.setAttribute("dur", this.speed+"s"); - - child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); - - child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]); - - } - - else if(this.speed < 0){ - - child.setAttribute("dur", (-1)*this.speed+"s"); - - child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]); - - child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); - - } - - else{ - - child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]); - - child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]); - - } - - } - - } - - } - - - - init() { - - let widget_pos = this.element.getBBox(); - - this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)]; - - } - - } - - - - - class BackWidget extends Widget{ + + class + BackWidget + extends Widget{ on_click(evt) { @@ -2218,10 +2228,12 @@ ); - + + class + ButtonWidget + extends Widget{ + - class ButtonWidget extends Widget{ - frequency = 5; display = "inactive"; @@ -2287,7 +2299,8 @@ } - + + @@ -2297,8 +2310,10 @@ - - class CircularBarWidget extends Widget{ + + class + CircularBarWidget + extends Widget{ frequency = 10; @@ -2395,7 +2410,8 @@ } - + + @@ -2411,8 +2427,10 @@ - - class CircularSliderWidget extends Widget{ + + class + CircularSliderWidget + extends Widget{ frequency = 5; @@ -2867,7 +2885,8 @@ } - + + @@ -2885,8 +2904,10 @@ - - class CustomHtmlWidget extends Widget{ + + class + CustomHtmlWidget + extends Widget{ frequency = 5; @@ -2927,7 +2948,8 @@ } - + + @@ -2935,11 +2957,11 @@ container code - - - - - class DisplayWidget extends Widget{ + + + class + DisplayWidget + extends Widget{ frequency = 5; @@ -2954,7 +2976,8 @@ } - + + @@ -3507,14 +3530,10 @@ - - function numb_event(e) { - - e.stopPropagation(); - - } - - class DropDownWidget extends Widget{ + + class + DropDownWidget + extends Widget{ dispatch(value) { @@ -3742,9 +3761,9 @@ // Stop hogging all click events - svg_root.removeEventListener("pointerdown", numb_event, true); - - svg_root.removeEventListener("pointerup", numb_event, true); + svg_root.removeEventListener("pointerdown", this.numb_event, true); + + svg_root.removeEventListener("pointerup", this.numb_event, true); svg_root.removeEventListener("click", this.bound_close_on_click_elsewhere, true); @@ -3978,6 +3997,12 @@ } + numb_event(e) { + + e.stopPropagation(); + + } + open(){ let length = this.content.length; @@ -4032,9 +4057,9 @@ // disable interaction with background - svg_root.addEventListener("pointerdown", numb_event, true); - - svg_root.addEventListener("pointerup", numb_event, true); + svg_root.addEventListener("pointerdown", this.numb_event, true); + + svg_root.addEventListener("pointerup", this.numb_event, true); svg_root.addEventListener("click", this.bound_close_on_click_elsewhere, true); @@ -4162,10 +4187,11 @@ } - } - - - + } + + + + @@ -4193,7 +4219,8 @@ , - + + @@ -4307,8 +4334,10 @@ item_offset: 0, - - class ForEachWidget extends Widget{ + + class + ForEachWidget + extends Widget{ @@ -4443,73 +4472,97 @@ } - - class InputWidget extends Widget{ - - on_op_click(opstr) { - - this.change_hmi_value(0, opstr); - - } - - edit_callback(new_val) { - - this.apply_hmi_value(0, new_val); - - } - - - - is_inhibited = false; - - alert(msg){ - - this.is_inhibited = true; - - this.display = msg; - - setTimeout(() => this.stopalert(), 1000); - - this.request_animate(); - - } - - - - stopalert(){ - - this.is_inhibited = false; - - this.display = this.last_value; - - this.request_animate(); - - } - - - - overshot(new_val, max) { - - this.alert("max"); - - } - - - - undershot(new_val, min) { - - this.alert("min"); - - } - - - - - - } - - - + + + + + + Input widget takes one variable path, and displays current value in + + optional "value" labeled sub-element. Click on optional "edit" labeled + + element opens keypad to edit value. Operation on current value is + + performed when click on sub-elements with label starting with '=', '+' + + or '-' sign. Value after sign is used as operand. + + + + Input field with predefined operation buttons + + + optional printf-like format + + + single variable to edit + + + + class + InputWidget + extends Widget{ + + on_op_click(opstr) { + + this.change_hmi_value(0, opstr); + + } + + edit_callback(new_val) { + + this.apply_hmi_value(0, new_val); + + } + + + + is_inhibited = false; + + alert(msg){ + + this.is_inhibited = true; + + this.display = msg; + + setTimeout(() => this.stopalert(), 1000); + + this.request_animate(); + + } + + + + stopalert(){ + + this.is_inhibited = false; + + this.display = this.last_value; + + this.request_animate(); + + } + + + + overshot(new_val, max) { + + this.alert("max"); + + } + + + + undershot(new_val, min) { + + this.alert("min"); + + } + + } + + + @@ -4598,8 +4651,10 @@ }, - - class JsonTableWidget extends Widget{ + + class + JsonTableWidget + extends Widget{ // arbitrary defaults to avoid missing entries in query @@ -5018,7 +5073,8 @@ } - + + @@ -5064,10 +5120,10 @@ } - - class JumpWidget extends Widget{ - - + + class + JumpWidget + extends Widget{ activable = false; @@ -5177,10 +5233,11 @@ } - } - - - + } + + + + @@ -5229,7 +5286,8 @@ }, - + + @@ -5331,10 +5389,10 @@ - - class KeypadWidget extends Widget{ - - + + class + KeypadWidget + extends Widget{ on_key_click(symbols) { @@ -5525,7 +5583,8 @@ } - + + @@ -5586,7 +5645,8 @@ ], - + + items: { @@ -5601,7 +5661,8 @@ }, - + + styles: { @@ -5617,8 +5678,10 @@ }, - - class MeterWidget extends Widget{ + + class + MetterWidget + extends Widget{ frequency = 10; @@ -5672,12 +5735,11 @@ } - - } - + + @@ -5693,8 +5755,10 @@ - - class MultiStateWidget extends Widget{ + + class + MultiStateWidget + extends Widget{ frequency = 5; @@ -5775,7 +5839,8 @@ } - + + choices: [ @@ -5806,8 +5871,10 @@ ], - - class ScrollBarWidget extends Widget{ + + class + ScrollBarWidget + extends Widget{ frequency = 10; @@ -5984,7 +6051,8 @@ } - + + @@ -6016,7 +6084,11 @@ }, - + + class + SliderWidget + extends Widget{ + class SliderWidget extends Widget{ frequency = 5; @@ -6687,8 +6759,11 @@ } - - + } + + + + @@ -6703,11 +6778,11 @@ - - - - - class SwitchWidget extends Widget{ + + + class + SwitchWidget + extends Widget{ frequency = 5; @@ -6732,7 +6807,8 @@ } - + + choices: [ @@ -6766,8 +6842,10 @@ ], - - class ToggleButtonWidget extends Widget{ + + class + ToggleButtonWidget + extends Widget{ frequency = 5; @@ -6846,7 +6924,8 @@ } - + +