UI: Add help for Scada system

This commit is contained in:
Artem Dzhereleiko 2024-09-25 11:56:26 +03:00
parent bb96c12662
commit 677aaa386e
3 changed files with 95 additions and 14 deletions

View File

@ -10,9 +10,9 @@ A JavaScript function used to render SCADA symbol state.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>ctx:</b> <code>ScadaSymbolContext</code> - Context of the SCADA symbol. <li><b>ctx:</b> <code>ScadaSymbolContext</code> - <a href="${siteBaseUrl}/docs${docPlatformPrefix}/user-guide/scada/scada-symbols-dev-guide/#scadasymbolcontext" target="_blank">Context</a> of the SCADA symbol.
</li> </li>
<li><b>svg:</b> <code><a href="https://svgjs.dev/docs/3.2/container-elements/#svg-svg">SVG.Svg</a></code> - A root svg node. Instance of <a href="https://svgjs.dev/docs/3.2/container-elements/#svg-svg">SVG.Svg</a>. <li><b>svg:</b> <code><a href="https://svgjs.dev/docs/3.2/container-elements/#svg-svg">SVG.Svg</a></code> - A root svg node. Instance of <a href="https://svgjs.dev/docs/3.2/container-elements/#svg-svg" target="_blank">SVG.Svg</a>.
</li> </li>
</ul> </ul>
@ -20,8 +20,36 @@ A JavaScript function used to render SCADA symbol state.
##### Examples ##### Examples
<br> * Change colors for many tags on the value of the “active, value, minValue, maxValue”
TODO ```javascript
var levelUpButton = ctx.tags.levelUpButton;
var levelDownButton = ctx.tags.levelDownButton;
var levelArrowUp = ctx.tags.levelArrowUp;
var levelArrowDown = ctx.tags.levelArrowDown;
var active = ctx.values.active;
var value = ctx.values.value;
var minValue = ctx.properties.minValue;
var maxValue = ctx.properties.maxValue;
var levelUpEnabled = active && value < maxValue;
var levelDownEnabled = active && value > minValue;
if (levelUpEnabled) {
ctx.api.enable(levelUpButton);
levelArrowUp[0].attr({fill: '#647484'});
} else {
ctx.api.disable(levelUpButton);
levelArrowUp[0].attr({fill: '#777'});
}
if (levelDownEnabled) {
ctx.api.enable(levelDownButton);
levelArrowDown[0].attr({fill: '#647484'});
} else {
ctx.api.disable(levelDownButton);
levelArrowDown[0].attr({fill: '#777'});
}
{:copy-code}
```

View File

@ -10,11 +10,11 @@ A JavaScript function invoked when user clicks on SVG element with specific tag.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>ctx:</b> <code>ScadaSymbolContext</code> - Context of the SCADA symbol. <li><b>ctx:</b> <code>ScadaSymbolContext</code> - <a href="${siteBaseUrl}/docs${docPlatformPrefix}/user-guide/scada/scada-symbols-dev-guide/#scadasymbolcontext" target="_blank">Context</a> of the SCADA symbol.
</li> </li>
<li><b>element:</b> <code>Element</code> - SVG element.<br> <li><b>element:</b> <code>Element</code> - SVG element.<br>
See <a href="https://svgjs.dev/docs/3.2/manipulating/">Manipulating</a> section to manipulate the element.<br> See <a href="https://svgjs.dev/docs/3.2/manipulating/" target="_blank">Manipulating</a> section to manipulate the element.<br>
See <a href="https://svgjs.dev/docs/3.2/animating/">Animating</a> section to animate the element. See <a href="https://svgjs.dev/docs/3.2/animating/" target="_blank">Animating</a> section to animate the element.
</li> </li>
<li><b>event:</b> <code>Event</code> - DOM event. <li><b>event:</b> <code>Event</code> - DOM event.
</li> </li>
@ -24,6 +24,19 @@ A JavaScript function invoked when user clicks on SVG element with specific tag.
##### Examples ##### Examples
<br> * Set new value action
TODO ```javascript
var active = ctx.values.active;
var action = active ? 'inactive' : 'active';
ctx.api.callAction(event, action, undefined, {
next: () => {
ctx.api.setValue('activate', !active);
},
error: () => {
ctx.api.setValue('activate', active);
}
});
{:copy-code}
```

View File

@ -10,11 +10,11 @@ A JavaScript function used to render SCADA symbol element with specific tag.
**Parameters:** **Parameters:**
<ul> <ul>
<li><b>ctx:</b> <code>ScadaSymbolContext</code> - Context of the SCADA symbol. <li><b>ctx:</b> <code>ScadaSymbolContext</code> - <a href="${siteBaseUrl}/docs${docPlatformPrefix}/user-guide/scada/scada-symbols-dev-guide/#scadasymbolcontext" target="_blank">Context</a> of the SCADA symbol.
</li> </li>
<li><b>element:</b> <code>Element</code> - SVG element.<br> <li><b>element:</b> <code>Element</code> - SVG element.<br>
See <a href="https://svgjs.dev/docs/3.2/manipulating/">Manipulating</a> section to manipulate the element.<br> See <a href="https://svgjs.dev/docs/3.2/manipulating/" target="_blank">Manipulating</a> section to manipulate the element.<br>
See <a href="https://svgjs.dev/docs/3.2/animating/">Animating</a> section to animate the element. See <a href="https://svgjs.dev/docs/3.2/animating/" target="_blank">Animating</a> section to animate the element.
</li> </li>
</ul> </ul>
@ -22,6 +22,46 @@ A JavaScript function used to render SCADA symbol element with specific tag.
##### Examples ##### Examples
<br> * Change the background of the element based on the value of the “active”
TODO ```javascript
if(ctx.values.active){
element.attr({fill: ctx.properties.activeColor});
} else {
element.attr({fill: ctx.properties.inactiveColor});
}
{:copy-code}
```
* Enable and disable the “On” button based on the state of the "active" (avoid or prevent click action)
```javascript
if (ctx.values.active) {
ctx.api.disable(element);
} else {
ctx.api.enable(element);
}
{:copy-code}
```
* Smooth infinite rotation animation based on the value of the “active” with speed based on the value of the “speed”
```javascript
var on = ctx.values.active;
var speed = ctx.values.speed ? ctx.values.speed / 60 : 1;
var animation = ctx.api.cssAnimation(element);
if (on) {
if (!animation) {
animation = ctx.api.cssAnimate(element, 2000)
.rotate(360).loop().speed(speed);
} else {
animation.speed(speed).play();
}
} else {
if (animation) {
animation.pause();
}
}
{:copy-code}
```