Browse Source

UI: SCADA symbols - ability to set default behavior settings.

pull/11391/head
Igor Kulikov 2 years ago
parent
commit
e59a9ced27
  1. 144
      application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg
  2. 189
      application/src/main/data/json/system/scada_symbols/level_and_fan.svg
  3. 144
      application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg
  4. 144
      application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg
  5. 144
      application/src/main/data/json/system/scada_symbols/vertical-pipe.svg
  6. 131
      ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts
  7. 64
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html
  8. 74
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts
  9. 30
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts
  10. 2
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html
  11. 22
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts
  12. 4
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html
  13. 8
      ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts
  14. 2
      ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html
  15. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

144
application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid", "id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}", "name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}", "hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}", "stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flow", "id": "flow",
"name": "{i18n:scada.symbol.flow-presence}", "name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}", "hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}", "stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowDirection", "id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}", "name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}", "hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}", "trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}", "falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}", "stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowAnimationSpeed", "id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}", "name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": null, "stateLabel": null,
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "leak", "id": "leak",
"name": "{i18n:scada.symbol.leak}", "name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}", "hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}", "stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
} }
], ],
"properties": [ "properties": [

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 30 KiB

189
application/src/main/data/json/system/scada_symbols/level_and_fan.svg

@ -77,74 +77,225 @@
"id": "level", "id": "level",
"name": "Level", "name": "Level",
"hint": null, "hint": null,
"group": null,
"type": "value", "type": "value",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"defaultValue": 10,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": null, "stateLabel": null,
"valueToDataType": null, "defaultGetValueSettings": {
"constantValue": null, "action": "GET_TIME_SERIES",
"valueToDataFunction": null "defaultValue": null,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "level"
},
"getTimeSeries": {
"key": "level"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "disabled", "id": "disabled",
"name": "{i18n:widgets.rpc-state.disabled-state}", "name": "{i18n:widgets.rpc-state.disabled-state}",
"hint": "{i18n:widgets.rpc-state.disabled-state-hint}", "hint": "{i18n:widgets.rpc-state.disabled-state-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "", "trueLabel": "",
"falseLabel": "", "falseLabel": "",
"stateLabel": "{i18n:widgets.rpc-state.disabled}", "stateLabel": "{i18n:widgets.rpc-state.disabled}",
"valueToDataType": null, "defaultGetValueSettings": {
"constantValue": null, "action": "DO_NOTHING",
"valueToDataFunction": null "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "on", "id": "on",
"name": "On/Off state", "name": "On/Off state",
"hint": null, "hint": null,
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:widgets.rpc-state.on}", "trueLabel": "{i18n:widgets.rpc-state.on}",
"falseLabel": "{i18n:widgets.rpc-state.off}", "falseLabel": "{i18n:widgets.rpc-state.off}",
"stateLabel": "{i18n:widgets.rpc-state.on}", "stateLabel": "{i18n:widgets.rpc-state.on}",
"valueToDataType": null, "defaultGetValueSettings": {
"constantValue": null, "action": "DO_NOTHING",
"valueToDataFunction": null "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "onUpdateState", "id": "onUpdateState",
"name": "{i18n:widgets.rpc-state.turn-on}", "name": "{i18n:widgets.rpc-state.turn-on}",
"hint": "{i18n:widgets.rpc-state.turn-on-hint}", "hint": "{i18n:widgets.rpc-state.turn-on-hint}",
"group": null,
"type": "action", "type": "action",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"valueToDataType": "CONSTANT", "trueLabel": null,
"constantValue": true "falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "SET_ATTRIBUTE",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "state"
},
"valueToData": {
"type": "CONSTANT",
"constantValue": true,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
}, },
{ {
"id": "offUpdateState", "id": "offUpdateState",
"name": "{i18n:widgets.rpc-state.turn-off}", "name": "{i18n:widgets.rpc-state.turn-off}",
"hint": "{i18n:widgets.rpc-state.turn-off-hint}", "hint": "{i18n:widgets.rpc-state.turn-off-hint}",
"group": null,
"type": "action", "type": "action",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"valueToDataType": "CONSTANT", "trueLabel": null,
"constantValue": false "falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "SET_ATTRIBUTE",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "state"
},
"valueToData": {
"type": "CONSTANT",
"constantValue": false,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
}, },
{ {
"id": "levelUpdateState", "id": "levelUpdateState",
"name": "Update level", "name": "Update level",
"hint": null,
"group": null,
"type": "action", "type": "action",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"valueToDataType": "VALUE", "trueLabel": null,
"constantValue": 0 "falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": {
"action": "ADD_TIME_SERIES",
"executeRpc": {
"method": "setState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"setAttribute": {
"scope": "SERVER_SCOPE",
"key": "state"
},
"putTimeSeries": {
"key": "level"
},
"valueToData": {
"type": "VALUE",
"constantValue": false,
"valueToDataFunction": "/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;"
}
},
"defaultWidgetActionSettings": null
}, },
{ {
"id": "levelValueClick", "id": "levelValueClick",
"name": "On level value click", "name": "On level value click",
"type": "widgetAction" "hint": null,
"group": null,
"type": "widgetAction",
"valueType": null,
"trueLabel": null,
"falseLabel": null,
"stateLabel": null,
"defaultGetValueSettings": null,
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": {
"type": "doNothing",
"openInSeparateDialog": false,
"openInPopover": false
}
} }
], ],
"properties": [ "properties": [

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 22 KiB

144
application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid", "id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}", "name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}", "hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}", "stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flow", "id": "flow",
"name": "{i18n:scada.symbol.flow-presence}", "name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}", "hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}", "stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowDirection", "id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}", "name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}", "hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}", "trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}", "falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}", "stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowAnimationSpeed", "id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}", "name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": null, "stateLabel": null,
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "leak", "id": "leak",
"name": "{i18n:scada.symbol.leak}", "name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}", "hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}", "stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
} }
], ],
"properties": [ "properties": [

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 45 KiB

144
application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid", "id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}", "name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}", "hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}", "stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flow", "id": "flow",
"name": "{i18n:scada.symbol.flow-presence}", "name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}", "hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}", "stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowDirection", "id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}", "name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}", "hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}", "trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}", "falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}", "stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowAnimationSpeed", "id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}", "name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": null, "stateLabel": null,
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "leak", "id": "leak",
"name": "{i18n:scada.symbol.leak}", "name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}", "hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}", "stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
} }
], ],
"properties": [ "properties": [

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 38 KiB

144
application/src/main/data/json/system/scada_symbols/vertical-pipe.svg

@ -30,71 +30,175 @@
"id": "fluid", "id": "fluid",
"name": "{i18n:scada.symbol.fluid-presence}", "name": "{i18n:scada.symbol.fluid-presence}",
"hint": "{i18n:scada.symbol.fluid-presence-hint}", "hint": "{i18n:scada.symbol.fluid-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.fluid-present}", "stateLabel": "{i18n:scada.symbol.fluid-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flow", "id": "flow",
"name": "{i18n:scada.symbol.flow-presence}", "name": "{i18n:scada.symbol.flow-presence}",
"hint": "{i18n:scada.symbol.flow-presence-hint}", "hint": "{i18n:scada.symbol.flow-presence-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": "{i18n:scada.symbol.present}", "trueLabel": "{i18n:scada.symbol.present}",
"falseLabel": "{i18n:scada.symbol.absent}", "falseLabel": "{i18n:scada.symbol.absent}",
"stateLabel": "{i18n:scada.symbol.flow-present}", "stateLabel": "{i18n:scada.symbol.flow-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowDirection", "id": "flowDirection",
"name": "{i18n:scada.symbol.flow-direction}", "name": "{i18n:scada.symbol.flow-direction}",
"hint": "{i18n:scada.symbol.flow-direction-hint}", "hint": "{i18n:scada.symbol.flow-direction-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": true,
"trueLabel": "{i18n:scada.symbol.forward}", "trueLabel": "{i18n:scada.symbol.forward}",
"falseLabel": "{i18n:scada.symbol.reverse}", "falseLabel": "{i18n:scada.symbol.reverse}",
"stateLabel": "{i18n:scada.symbol.forward}", "stateLabel": "{i18n:scada.symbol.forward}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": true,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "flowAnimationSpeed", "id": "flowAnimationSpeed",
"name": "{i18n:scada.symbol.flow-animation-speed}", "name": "{i18n:scada.symbol.flow-animation-speed}",
"hint": "{i18n:scada.symbol.flow-animation-speed-hint}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "DOUBLE", "valueType": "DOUBLE",
"defaultValue": 1,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": null, "stateLabel": null,
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": 1,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;"
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
}, },
{ {
"id": "leak", "id": "leak",
"name": "{i18n:scada.symbol.leak}", "name": "{i18n:scada.symbol.leak}",
"hint": "{i18n:scada.symbol.leak-hint}", "hint": "{i18n:scada.symbol.leak-hint}",
"group": null,
"type": "value", "type": "value",
"valueType": "BOOLEAN", "valueType": "BOOLEAN",
"defaultValue": false,
"trueLabel": null, "trueLabel": null,
"falseLabel": null, "falseLabel": null,
"stateLabel": "{i18n:scada.symbol.leak-present}", "stateLabel": "{i18n:scada.symbol.leak-present}",
"valueToDataType": "CONSTANT", "defaultGetValueSettings": {
"constantValue": false, "action": "DO_NOTHING",
"valueToDataFunction": "" "defaultValue": false,
"executeRpc": {
"method": "getState",
"requestTimeout": 5000,
"requestPersistent": false,
"persistentPollingInterval": 1000
},
"getAttribute": {
"scope": null,
"key": "state"
},
"getTimeSeries": {
"key": "state"
},
"dataToValue": {
"type": "NONE",
"dataToValueFunction": "/* Should return boolean value */\nreturn data;",
"compareToValue": true
}
},
"defaultSetValueSettings": null,
"defaultWidgetActionSettings": null
} }
], ],
"properties": [ "properties": [

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 30 KiB

131
ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts

@ -112,7 +112,7 @@ export interface ScadaSymbolBehaviorBase {
export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase { export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase {
valueType: ValueType; valueType: ValueType;
defaultValue: any; defaultGetValueSettings?: GetValueSettings<any>;
trueLabel?: string; trueLabel?: string;
falseLabel?: string; falseLabel?: string;
stateLabel?: string; stateLabel?: string;
@ -120,9 +120,8 @@ export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase {
export interface ScadaSymbolBehaviorAction extends ScadaSymbolBehaviorBase { export interface ScadaSymbolBehaviorAction extends ScadaSymbolBehaviorBase {
valueType: ValueType; valueType: ValueType;
valueToDataType: ValueToDataType; defaultSetValueSettings?: SetValueSettings;
constantValue: any; defaultWidgetActionSettings?: WidgetAction;
valueToDataFunction: string;
} }
export type ScadaSymbolBehavior = ScadaSymbolBehaviorValue & ScadaSymbolBehaviorAction; export type ScadaSymbolBehavior = ScadaSymbolBehaviorValue & ScadaSymbolBehaviorAction;
@ -312,30 +311,47 @@ export const scadaSymbolContentData = (svgContent: string): ScadaSymbolContentDa
return result; return result;
}; };
const defaultGetValueSettings = (get: ScadaSymbolBehaviorValue): GetValueSettings<any> => ({ const defaultValueForValueType = (valueType: ValueType): any => {
action: GetValueAction.DO_NOTHING, if (!valueType) {
defaultValue: get.defaultValue, return null;
executeRpc: { }
switch (valueType) {
case ValueType.STRING:
return '';
case ValueType.INTEGER:
case ValueType.DOUBLE:
return 0;
case ValueType.BOOLEAN:
return false;
case ValueType.JSON:
return {};
}
};
export const defaultGetValueSettings = (valueType: ValueType): GetValueSettings<any> => ({
action: GetValueAction.DO_NOTHING,
defaultValue: defaultValueForValueType(valueType),
executeRpc: {
method: 'getState', method: 'getState',
requestTimeout: 5000, requestTimeout: 5000,
requestPersistent: false, requestPersistent: false,
persistentPollingInterval: 1000 persistentPollingInterval: 1000
}, },
getAttribute: { getAttribute: {
key: 'state', key: 'state',
scope: null scope: null
}, },
getTimeSeries: { getTimeSeries: {
key: 'state' key: 'state'
}, },
dataToValue: { dataToValue: {
type: DataToValueType.NONE, type: DataToValueType.NONE,
compareToValue: true, compareToValue: true,
dataToValueFunction: '/* Should return boolean value */\nreturn data;' dataToValueFunction: '/* Should return boolean value */\nreturn data;'
} }
}); });
const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettings => ({ export const defaultSetValueSettings = (valueType: ValueType): SetValueSettings => ({
action: SetValueAction.EXECUTE_RPC, action: SetValueAction.EXECUTE_RPC,
executeRpc: { executeRpc: {
method: 'setState', method: 'setState',
@ -351,20 +367,49 @@ const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettin
key: 'state' key: 'state'
}, },
valueToData: { valueToData: {
type: set.valueToDataType, type: valueType !== ValueType.BOOLEAN ? ValueToDataType.VALUE : ValueToDataType.CONSTANT,
constantValue: set.constantValue, constantValue: false,
valueToDataFunction: set.valueToDataFunction ? set.valueToDataFunction : valueToDataFunction:
'/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;' '/* Convert input boolean value to RPC parameters or attribute/time-series value */\nreturn value;'
} }
}); });
const defaultWidgetActionSettings = (widgetAction: ScadaSymbolBehavior): WidgetAction => ({ export const defaultWidgetActionSettings: WidgetAction = {
type: WidgetActionType.doNothing, type: WidgetActionType.doNothing,
targetDashboardStateId: null, targetDashboardStateId: null,
openRightLayout: false, openRightLayout: false,
setEntityId: false, setEntityId: false,
stateEntityParamName: null stateEntityParamName: null
}); };
export const updateBehaviorDefaultSettings = (behavior: ScadaSymbolBehavior): ScadaSymbolBehavior => {
if (behavior.type) {
switch (behavior.type) {
case ScadaSymbolBehaviorType.value:
delete behavior.defaultSetValueSettings;
delete behavior.defaultWidgetActionSettings;
if (!behavior.defaultGetValueSettings) {
behavior.defaultGetValueSettings = mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(behavior.valueType));
}
break;
case ScadaSymbolBehaviorType.action:
delete behavior.defaultGetValueSettings;
delete behavior.defaultWidgetActionSettings;
if (!behavior.defaultSetValueSettings) {
behavior.defaultSetValueSettings = mergeDeep({} as SetValueSettings, defaultSetValueSettings(behavior.valueType));
}
break;
case ScadaSymbolBehaviorType.widgetAction:
delete behavior.defaultGetValueSettings;
delete behavior.defaultSetValueSettings;
if (!behavior.defaultWidgetActionSettings) {
behavior.defaultWidgetActionSettings = mergeDeep({} as WidgetAction, defaultWidgetActionSettings);
}
break;
}
}
return behavior;
};
export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata): ScadaSymbolObjectSettings => { export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata): ScadaSymbolObjectSettings => {
const settings: ScadaSymbolObjectSettings = { const settings: ScadaSymbolObjectSettings = {
@ -373,11 +418,17 @@ export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata):
}; };
for (const behavior of metadata.behavior) { for (const behavior of metadata.behavior) {
if (behavior.type === ScadaSymbolBehaviorType.value) { if (behavior.type === ScadaSymbolBehaviorType.value) {
settings.behavior[behavior.id] = defaultGetValueSettings(behavior as ScadaSymbolBehaviorValue); settings.behavior[behavior.id] =
mergeDeep({} as GetValueSettings<any>,
defaultGetValueSettings(behavior.valueType), (behavior as ScadaSymbolBehaviorValue).defaultGetValueSettings || {});
} else if (behavior.type === ScadaSymbolBehaviorType.action) { } else if (behavior.type === ScadaSymbolBehaviorType.action) {
settings.behavior[behavior.id] = defaultSetValueSettings(behavior as ScadaSymbolBehaviorAction); settings.behavior[behavior.id] =
mergeDeep({} as SetValueSettings,
defaultSetValueSettings(behavior.valueType), (behavior as ScadaSymbolBehaviorAction).defaultSetValueSettings || {});
} else if (behavior.type === ScadaSymbolBehaviorType.widgetAction) { } else if (behavior.type === ScadaSymbolBehaviorType.widgetAction) {
settings.behavior[behavior.id] = defaultWidgetActionSettings(behavior); settings.behavior[behavior.id] =
mergeDeep({} as WidgetAction,
defaultWidgetActionSettings, (behavior as ScadaSymbolBehaviorAction).defaultWidgetActionSettings || {});
} }
} }
for (const property of metadata.properties) { for (const property of metadata.properties) {
@ -733,17 +784,7 @@ export class ScadaSymbolObject {
private normalizeValue(value: any, type: ValueType): any { private normalizeValue(value: any, type: ValueType): any {
if (isUndefinedOrNull(value)) { if (isUndefinedOrNull(value)) {
switch (type) { return defaultValueForValueType(type);
case ValueType.STRING:
return '';
case ValueType.INTEGER:
case ValueType.DOUBLE:
return 0;
case ValueType.BOOLEAN:
return false;
case ValueType.JSON:
return {};
}
} else { } else {
return value; return value;
} }

64
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html

@ -70,11 +70,6 @@
</mat-form-field> </mat-form-field>
</div> </div>
<ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.value"> <ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.value">
<div class="tb-form-row ">
<div class="fixed-title-width" translate>scada.behavior.default-value</div>
<tb-value-input fxFlex [valueType]="behaviorFormGroup.get('valueType').value"
formControlName="defaultValue"></tb-value-input>
</div>
<ng-container *ngIf="behaviorFormGroup.get('valueType').value === ValueType.BOOLEAN"> <ng-container *ngIf="behaviorFormGroup.get('valueType').value === ValueType.BOOLEAN">
<div class="tb-form-row"> <div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.true-label</div> <div class="fixed-title-width" translate>scada.behavior.true-label</div>
@ -95,34 +90,41 @@
</mat-form-field> </mat-form-field>
</div> </div>
</ng-container> </ng-container>
<div class="tb-form-row">
<div class="fixed-title-width" translate>scada.behavior.default-settings</div>
<tb-get-value-action-settings fxFlex
panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
[valueType]="behaviorFormGroup.get('valueType').value"
[trueLabel]="behaviorFormGroup.get('trueLabel').value | customTranslate"
[falseLabel]="behaviorFormGroup.get('falseLabel').value | customTranslate"
[stateLabel]="behaviorFormGroup.get('stateLabel').value | customTranslate"
[aliasController]="aliasController"
[widgetType]="widgetType.rpc"
formControlName="defaultGetValueSettings">
</tb-get-value-action-settings>
</div>
</ng-container> </ng-container>
<ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.action"> <ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.action">
<div class="tb-form-panel stroked"> <div class="tb-form-row">
<div class="tb-form-row no-padding no-border column-xs"> <div class="fixed-title-width" translate>scada.behavior.default-settings</div>
<div class="fixed-title-width">{{ 'scada.behavior.default-payload' | translate }}</div> <tb-set-value-action-settings fxFlex
<tb-toggle-select fxFlex formControlName="valueToDataType"> panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
<tb-toggle-option *ngIf="behaviorFormGroup.get('valueType').value !== ValueType.BOOLEAN" [value]="ValueToDataType.VALUE">{{ 'widgets.value-action.converter-value' | translate }}</tb-toggle-option> [valueType]="behaviorFormGroup.get('valueType').value"
<tb-toggle-option *ngIf="behaviorFormGroup.get('valueType').value === ValueType.BOOLEAN" [value]="ValueToDataType.CONSTANT">{{ 'widgets.value-action.converter-constant' | translate }}</tb-toggle-option> [aliasController]="aliasController"
<tb-toggle-option [value]="ValueToDataType.FUNCTION">{{ 'widgets.value-action.converter-function' | translate }}</tb-toggle-option> [widgetType]="widgetType.rpc"
<tb-toggle-option [value]="ValueToDataType.NONE">{{ 'widgets.value-action.converter-none' | translate }}</tb-toggle-option> formControlName="defaultSetValueSettings">
</tb-toggle-select> </tb-set-value-action-settings>
</div> </div>
<tb-value-input *ngIf="behaviorFormGroup.get('valueToDataType').value === ValueToDataType.CONSTANT" </ng-container>
fxFlex <ng-container *ngIf="behaviorFormGroup.get('type').value === ScadaSymbolBehaviorType.widgetAction">
[layout]="{ <div class="tb-form-row">
layout: 'row', <div class="fixed-title-width" translate>scada.behavior.default-settings</div>
breakpoints: {xs: 'column'} <tb-widget-action-settings fxFlex
}" panelTitle="{{ behaviorFormGroup.get('name').value | customTranslate }}"
formControlName="constantValue"> [callbacks]="callbacks"
</tb-value-input> [widgetType]="widgetType.rpc"
<tb-js-func *ngIf="behaviorFormGroup.get('valueToDataType').value === ValueToDataType.FUNCTION" formControlName="defaultWidgetActionSettings">
formControlName="valueToDataFunction" </tb-widget-action-settings>
required
[globalVariables]="functionScopeVariables"
[functionArgs]="['value']"
functionTitle="{{ 'widgets.value-action.convert-value-function' | translate }}"
helpId="widget/lib/rpc/convert_value_fn">
</tb-js-func>
</div> </div>
</ng-container> </ng-container>
</div> </div>

74
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts

@ -19,14 +19,19 @@ import { TbPopoverComponent } from '@shared/components/popover.component';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import { merge } from 'rxjs'; import { merge } from 'rxjs';
import { import {
defaultGetValueSettings, defaultSetValueSettings, defaultWidgetActionSettings,
ScadaSymbolBehavior, ScadaSymbolBehavior,
ScadaSymbolBehaviorType, ScadaSymbolBehaviorType,
scadaSymbolBehaviorTypes, scadaSymbolBehaviorTypes,
scadaSymbolBehaviorTypeTranslations scadaSymbolBehaviorTypeTranslations
} from '@app/modules/home/components/widget/lib/scada/scada-symbol.models'; } from '@app/modules/home/components/widget/lib/scada/scada-symbol.models';
import { ValueType, valueTypesMap } from '@shared/models/constants'; import { ValueType, valueTypesMap } from '@shared/models/constants';
import { ValueToDataType } from '@shared/models/action-widget-settings.models'; import { GetValueSettings, SetValueSettings, ValueToDataType } from '@shared/models/action-widget-settings.models';
import { WidgetService } from '@core/http/widget.service'; import { WidgetService } from '@core/http/widget.service';
import { mergeDeep } from '@core/utils';
import { WidgetAction, widgetType } from '@shared/models/widget.models';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({ @Component({
selector: 'tb-scada-symbol-behavior-panel', selector: 'tb-scada-symbol-behavior-panel',
@ -36,6 +41,8 @@ import { WidgetService } from '@core/http/widget.service';
}) })
export class ScadaSymbolBehaviorPanelComponent implements OnInit { export class ScadaSymbolBehaviorPanelComponent implements OnInit {
widgetType = widgetType;
ScadaSymbolBehaviorType = ScadaSymbolBehaviorType; ScadaSymbolBehaviorType = ScadaSymbolBehaviorType;
ValueType = ValueType; ValueType = ValueType;
@ -55,6 +62,12 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
@Input() @Input()
behavior: ScadaSymbolBehavior; behavior: ScadaSymbolBehavior;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input() @Input()
disabled: boolean; disabled: boolean;
@ -84,21 +97,19 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
group: [this.behavior.group, []], group: [this.behavior.group, []],
type: [this.behavior.type, [Validators.required]], type: [this.behavior.type, [Validators.required]],
valueType: [this.behavior.valueType, [Validators.required]], valueType: [this.behavior.valueType, [Validators.required]],
defaultValue: [this.behavior.defaultValue, [Validators.required]],
trueLabel: [this.behavior.trueLabel, []], trueLabel: [this.behavior.trueLabel, []],
falseLabel: [this.behavior.falseLabel, []], falseLabel: [this.behavior.falseLabel, []],
stateLabel: [this.behavior.stateLabel, []], stateLabel: [this.behavior.stateLabel, []],
valueToDataType: [this.behavior.valueToDataType, [Validators.required]], defaultGetValueSettings: [this.behavior.defaultGetValueSettings, [Validators.required]],
constantValue: [this.behavior.constantValue, [Validators.required]], defaultSetValueSettings: [this.behavior.defaultSetValueSettings, [Validators.required]],
valueToDataFunction: [this.behavior.valueToDataFunction, [Validators.required]] defaultWidgetActionSettings: [this.behavior.defaultWidgetActionSettings, [Validators.required]]
} }
); );
if (this.disabled) { if (this.disabled) {
this.behaviorFormGroup.disable({emitEvent: false}); this.behaviorFormGroup.disable({emitEvent: false});
} else { } else {
merge(this.behaviorFormGroup.get('type').valueChanges, merge(this.behaviorFormGroup.get('type').valueChanges,
this.behaviorFormGroup.get('valueType').valueChanges, this.behaviorFormGroup.get('valueType').valueChanges).subscribe(() => {
this.behaviorFormGroup.get('valueToDataType').valueChanges).subscribe(() => {
this.updateValidators(); this.updateValidators();
}); });
this.updateValidators(); this.updateValidators();
@ -117,7 +128,9 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
private updateValidators() { private updateValidators() {
const type: ScadaSymbolBehaviorType = this.behaviorFormGroup.get('type').value; const type: ScadaSymbolBehaviorType = this.behaviorFormGroup.get('type').value;
const valueType: ValueType = this.behaviorFormGroup.get('valueType').value; const valueType: ValueType = this.behaviorFormGroup.get('valueType').value;
let valueToDataType: ValueToDataType = this.behaviorFormGroup.get('valueToDataType').value; let defaultGetValueSettingsValue = this.behaviorFormGroup.get('defaultGetValueSettings').value;
let defaultSetValueSettingsValue = this.behaviorFormGroup.get('defaultSetValueSettings').value;
let defaultWidgetActionSettingsValue = this.behaviorFormGroup.get('defaultWidgetActionSettings').value;
this.behaviorFormGroup.disable({emitEvent: false}); this.behaviorFormGroup.disable({emitEvent: false});
this.behaviorFormGroup.get('id').enable({emitEvent: false}); this.behaviorFormGroup.get('id').enable({emitEvent: false});
this.behaviorFormGroup.get('name').enable({emitEvent: false}); this.behaviorFormGroup.get('name').enable({emitEvent: false});
@ -127,30 +140,49 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit {
switch (type) { switch (type) {
case ScadaSymbolBehaviorType.value: case ScadaSymbolBehaviorType.value:
this.behaviorFormGroup.get('valueType').enable({emitEvent: false}); this.behaviorFormGroup.get('valueType').enable({emitEvent: false});
this.behaviorFormGroup.get('defaultValue').enable({emitEvent: false}); this.behaviorFormGroup.get('defaultGetValueSettings').enable({emitEvent: false});
if (valueType === ValueType.BOOLEAN) { if (valueType === ValueType.BOOLEAN) {
this.behaviorFormGroup.get('trueLabel').enable({emitEvent: false}); this.behaviorFormGroup.get('trueLabel').enable({emitEvent: false});
this.behaviorFormGroup.get('falseLabel').enable({emitEvent: false}); this.behaviorFormGroup.get('falseLabel').enable({emitEvent: false});
this.behaviorFormGroup.get('stateLabel').enable({emitEvent: false}); this.behaviorFormGroup.get('stateLabel').enable({emitEvent: false});
} }
if (!defaultGetValueSettingsValue) {
defaultGetValueSettingsValue = mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(valueType));
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(defaultGetValueSettingsValue, {emitEvent: true});
}
if (defaultSetValueSettingsValue) {
this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultWidgetActionSettingsValue) {
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(null, {emitEvent: true});
}
break; break;
case ScadaSymbolBehaviorType.action: case ScadaSymbolBehaviorType.action:
if (valueType === ValueType.BOOLEAN && valueToDataType === ValueToDataType.VALUE) {
this.behaviorFormGroup.patchValue({valueToDataType: ValueToDataType.CONSTANT}, {emitEvent: false});
valueToDataType = ValueToDataType.CONSTANT;
} else if (valueType !== ValueType.BOOLEAN && valueToDataType === ValueToDataType.CONSTANT) {
this.behaviorFormGroup.patchValue({valueToDataType: ValueToDataType.VALUE}, {emitEvent: false});
valueToDataType = ValueToDataType.VALUE;
}
this.behaviorFormGroup.get('valueType').enable({emitEvent: false}); this.behaviorFormGroup.get('valueType').enable({emitEvent: false});
this.behaviorFormGroup.get('valueToDataType').enable({emitEvent: false}); this.behaviorFormGroup.get('defaultSetValueSettings').enable({emitEvent: false});
if (valueToDataType === ValueToDataType.CONSTANT) { if (!defaultSetValueSettingsValue) {
this.behaviorFormGroup.get('constantValue').enable({emitEvent: false}); defaultSetValueSettingsValue = mergeDeep({} as SetValueSettings, defaultSetValueSettings(valueType));
} else if (valueToDataType === ValueToDataType.FUNCTION) { this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(defaultSetValueSettingsValue, {emitEvent: true});
this.behaviorFormGroup.get('valueToDataFunction').enable({emitEvent: false}); }
if (defaultGetValueSettingsValue) {
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultWidgetActionSettingsValue) {
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(null, {emitEvent: true});
} }
break; break;
case ScadaSymbolBehaviorType.widgetAction: case ScadaSymbolBehaviorType.widgetAction:
this.behaviorFormGroup.get('defaultWidgetActionSettings').enable({emitEvent: false});
if (!defaultWidgetActionSettingsValue) {
defaultWidgetActionSettingsValue = mergeDeep({} as WidgetAction, defaultWidgetActionSettings);
this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(defaultWidgetActionSettingsValue, {emitEvent: true});
}
if (defaultGetValueSettingsValue) {
this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(null, {emitEvent: true});
}
if (defaultSetValueSettingsValue) {
this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(null, {emitEvent: true});
}
break; break;
} }
} }

30
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts

@ -43,7 +43,7 @@ import {
ScadaSymbolBehavior, ScadaSymbolBehavior,
ScadaSymbolBehaviorType, ScadaSymbolBehaviorType,
scadaSymbolBehaviorTypes, scadaSymbolBehaviorTypes,
scadaSymbolBehaviorTypeTranslations scadaSymbolBehaviorTypeTranslations, updateBehaviorDefaultSettings
} from '@home/components/widget/lib/scada/scada-symbol.models'; } from '@home/components/widget/lib/scada/scada-symbol.models';
import { deepClone, isUndefinedOrNull } from '@core/utils'; import { deepClone, isUndefinedOrNull } from '@core/utils';
import { MatButton } from '@angular/material/button'; import { MatButton } from '@angular/material/button';
@ -55,6 +55,8 @@ import { ValueToDataType } from '@shared/models/action-widget-settings.models';
import { import {
ScadaSymbolBehaviorsComponent ScadaSymbolBehaviorsComponent
} from '@home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component'; } from '@home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => { export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => {
if (!behavior.id || !behavior.name || !behavior.type) { if (!behavior.id || !behavior.name || !behavior.type) {
@ -62,20 +64,20 @@ export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => {
} }
switch (behavior.type) { switch (behavior.type) {
case ScadaSymbolBehaviorType.value: case ScadaSymbolBehaviorType.value:
if (!behavior.valueType || isUndefinedOrNull(behavior.defaultValue)) { if (!behavior.valueType || !behavior.defaultGetValueSettings) {
return false; return false;
} }
break; break;
case ScadaSymbolBehaviorType.action: case ScadaSymbolBehaviorType.action:
if (!behavior.valueToDataType) { if (!behavior.defaultSetValueSettings) {
return false; return false;
} }
if (behavior.valueToDataType === ValueToDataType.CONSTANT if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.CONSTANT
&& isUndefinedOrNull(behavior.constantValue)) { && isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.constantValue)) {
return false; return false;
} }
if (behavior.valueToDataType === ValueToDataType.FUNCTION if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.FUNCTION
&& isUndefinedOrNull(behavior.valueToDataFunction)) { && isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.valueToDataFunction)) {
return false; return false;
} }
break; break;
@ -120,6 +122,12 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
@Input() @Input()
index: number; index: number;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Output() @Output()
behaviorRemoved = new EventEmitter(); behaviorRemoved = new EventEmitter();
@ -190,6 +198,8 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
const ctx: any = { const ctx: any = {
isAdd: add, isAdd: add,
disabled: this.disabled, disabled: this.disabled,
aliasController: this.aliasController,
callbacks: this.callbacks,
behavior: deepClone(this.modelValue) behavior: deepClone(this.modelValue)
}; };
const scadaSymbolBehaviorPanelPopover = this.popoverService.displayPopover(trigger, this.renderer, const scadaSymbolBehaviorPanelPopover = this.popoverService.displayPopover(trigger, this.renderer,
@ -265,13 +275,15 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On
} }
private onTypeChanged(newType: ScadaSymbolBehaviorType) { private onTypeChanged(newType: ScadaSymbolBehaviorType) {
const prevType = this.modelValue.type; const prevModel = deepClone(this.modelValue);
this.modelValue = {...this.modelValue, ...{type: newType}}; this.modelValue = {...this.modelValue, ...{type: newType}};
this.modelValue = updateBehaviorDefaultSettings(this.modelValue);
if (!behaviorValid(this.modelValue)) { if (!behaviorValid(this.modelValue)) {
this.editBehavior(null, this.editButton, false, () => { this.editBehavior(null, this.editButton, false, () => {
this.modelValue = prevModel;
this.behaviorRowFormGroup.patchValue( this.behaviorRowFormGroup.patchValue(
{ {
type: prevType type: prevModel.type
}, {emitEvent: true} }, {emitEvent: true}
); );
}); });

2
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html

@ -33,6 +33,8 @@
<tb-scada-symbol-metadata-behavior-row fxFlex <tb-scada-symbol-metadata-behavior-row fxFlex
[index]="$index" [index]="$index"
[formControl]="behaviorControl" [formControl]="behaviorControl"
[aliasController]="aliasController"
[callbacks]="callbacks"
(behaviorRemoved)="removeBehavior($index)"> (behaviorRemoved)="removeBehavior($index)">
</tb-scada-symbol-metadata-behavior-row> </tb-scada-symbol-metadata-behavior-row>
<div class="tb-form-table-row-cell-buttons"> <div class="tb-form-table-row-cell-buttons">

22
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts

@ -35,15 +35,22 @@ import {
UntypedFormGroup, UntypedFormGroup,
Validator Validator
} from '@angular/forms'; } from '@angular/forms';
import { ScadaSymbolBehavior, ScadaSymbolBehaviorType } from '@home/components/widget/lib/scada/scada-symbol.models'; import {
defaultGetValueSettings,
ScadaSymbolBehavior,
ScadaSymbolBehaviorType
} from '@home/components/widget/lib/scada/scada-symbol.models';
import { ValueType } from '@shared/models/constants'; import { ValueType } from '@shared/models/constants';
import { CdkDragDrop } from '@angular/cdk/drag-drop'; import { CdkDragDrop } from '@angular/cdk/drag-drop';
import { import {
behaviorValid, behaviorValid,
ScadaSymbolBehaviorRowComponent ScadaSymbolBehaviorRowComponent
} from '@home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component'; } from '@home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component';
import { ValueToDataType } from '@shared/models/action-widget-settings.models'; import { GetValueSettings, ValueToDataType } from '@shared/models/action-widget-settings.models';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { mergeDeep } from '@core/utils';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({ @Component({
selector: 'tb-scada-symbol-metadata-behaviors', selector: 'tb-scada-symbol-metadata-behaviors',
@ -71,6 +78,12 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn
@ViewChildren(ScadaSymbolBehaviorRowComponent) @ViewChildren(ScadaSymbolBehaviorRowComponent)
behaviorRows: QueryList<ScadaSymbolBehaviorRowComponent>; behaviorRows: QueryList<ScadaSymbolBehaviorRowComponent>;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input() @Input()
disabled: boolean; disabled: boolean;
@ -181,10 +194,7 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn
name: '', name: '',
type: ScadaSymbolBehaviorType.value, type: ScadaSymbolBehaviorType.value,
valueType: ValueType.BOOLEAN, valueType: ValueType.BOOLEAN,
defaultValue: false, defaultGetValueSettings: mergeDeep({} as GetValueSettings<any>, defaultGetValueSettings(ValueType.BOOLEAN))
valueToDataType: ValueToDataType.CONSTANT,
constantValue: false,
valueToDataFunction: ''
}; };
const behaviorsArray = this.behaviorsFormGroup.get('behaviors') as UntypedFormArray; const behaviorsArray = this.behaviorsFormGroup.get('behaviors') as UntypedFormArray;
const behaviorControl = this.fb.control(behavior, []); const behaviorControl = this.fb.control(behavior, []);

4
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html

@ -101,7 +101,9 @@
</div> </div>
<div [fxShow]="selectedOption === 'behavior'" class="mat-content overflow-hidden"> <div [fxShow]="selectedOption === 'behavior'" class="mat-content overflow-hidden">
<tb-scada-symbol-metadata-behaviors <tb-scada-symbol-metadata-behaviors
formControlName="behavior"> formControlName="behavior"
[aliasController]="aliasController"
[callbacks]="callbacks">
</tb-scada-symbol-metadata-behaviors> </tb-scada-symbol-metadata-behaviors>
</div> </div>
<div [fxShow]="selectedOption === 'properties'" class="mat-content overflow-hidden"> <div [fxShow]="selectedOption === 'properties'" class="mat-content overflow-hidden">

8
ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts

@ -53,6 +53,8 @@ import {
scadaSymbolGeneralStateRenderPropertiesHighlightRules scadaSymbolGeneralStateRenderPropertiesHighlightRules
} from '@home/pages/scada-symbol/scada-symbol-editor.models'; } from '@home/pages/scada-symbol/scada-symbol-editor.models';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { IAliasController } from '@core/api/widget-api.models';
import { WidgetActionCallbacks } from '@home/components/widget/action/manage-widget-actions.component.models';
@Component({ @Component({
selector: 'tb-scada-symbol-metadata', selector: 'tb-scada-symbol-metadata',
@ -77,6 +79,12 @@ export class ScadaSymbolMetadataComponent extends PageComponent implements OnIni
@ViewChild('symbolMetadataTags') @ViewChild('symbolMetadataTags')
symbolMetadataTags: ScadaSymbolMetadataTagsComponent; symbolMetadataTags: ScadaSymbolMetadataTagsComponent;
@Input()
aliasController: IAliasController;
@Input()
callbacks: WidgetActionCallbacks;
@Input() @Input()
disabled: boolean; disabled: boolean;

2
ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html

@ -80,6 +80,8 @@
<tb-scada-symbol-metadata <tb-scada-symbol-metadata
#symbolMetadata #symbolMetadata
[tags]="tags" [tags]="tags"
[aliasController]="aliasController"
[callbacks]="widgetActionCallbacks"
formControlName="metadata"> formControlName="metadata">
<div class="tb-scada-symbol-metadata-header-prefix"> <div class="tb-scada-symbol-metadata-header-prefix">
<button fxHide.gt-sm <button fxHide.gt-sm

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -3622,7 +3622,8 @@
"false-label": "False label", "false-label": "False label",
"state-label": "State label", "state-label": "State label",
"default-payload": "Default payload", "default-payload": "Default payload",
"not-unique-behavior-ids-error": "Behavior Ids must be unique!" "not-unique-behavior-ids-error": "Behavior Ids must be unique!",
"default-settings": "Default settings"
}, },
"property": { "property": {
"property": "Property", "property": "Property",

Loading…
Cancel
Save