diff --git a/application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg b/application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg index 63c8373541..38aab1a12e 100644 --- a/application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg +++ b/application/src/main/data/json/system/scada_symbols/horizontal-pipe.svg @@ -30,71 +30,175 @@ "id": "fluid", "name": "{i18n:scada.symbol.fluid-presence}", "hint": "{i18n:scada.symbol.fluid-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.fluid-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-presence}", "hint": "{i18n:scada.symbol.flow-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.flow-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-direction}", "hint": "{i18n:scada.symbol.flow-direction-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": true, "trueLabel": "{i18n:scada.symbol.forward}", "falseLabel": "{i18n:scada.symbol.reverse}", "stateLabel": "{i18n:scada.symbol.forward}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-animation-speed}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}", + "group": null, "type": "value", "valueType": "DOUBLE", - "defaultValue": 1, "trueLabel": null, "falseLabel": null, "stateLabel": null, - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.leak}", "hint": "{i18n:scada.symbol.leak-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": null, "falseLabel": null, "stateLabel": "{i18n:scada.symbol.leak-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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": [ diff --git a/application/src/main/data/json/system/scada_symbols/level_and_fan.svg b/application/src/main/data/json/system/scada_symbols/level_and_fan.svg index 9757228504..f0ab885768 100644 --- a/application/src/main/data/json/system/scada_symbols/level_and_fan.svg +++ b/application/src/main/data/json/system/scada_symbols/level_and_fan.svg @@ -77,74 +77,225 @@ "id": "level", "name": "Level", "hint": null, + "group": null, "type": "value", "valueType": "DOUBLE", - "defaultValue": 10, "trueLabel": null, "falseLabel": null, "stateLabel": null, - "valueToDataType": null, - "constantValue": null, - "valueToDataFunction": null + "defaultGetValueSettings": { + "action": "GET_TIME_SERIES", + "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", "name": "{i18n:widgets.rpc-state.disabled-state}", "hint": "{i18n:widgets.rpc-state.disabled-state-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "", "falseLabel": "", "stateLabel": "{i18n:widgets.rpc-state.disabled}", - "valueToDataType": null, - "constantValue": null, - "valueToDataFunction": null + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "On/Off state", "hint": null, + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": true, "trueLabel": "{i18n:widgets.rpc-state.on}", "falseLabel": "{i18n:widgets.rpc-state.off}", "stateLabel": "{i18n:widgets.rpc-state.on}", - "valueToDataType": null, - "constantValue": null, - "valueToDataFunction": null + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:widgets.rpc-state.turn-on}", "hint": "{i18n:widgets.rpc-state.turn-on-hint}", + "group": null, "type": "action", "valueType": "BOOLEAN", - "valueToDataType": "CONSTANT", - "constantValue": true + "trueLabel": null, + "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", "name": "{i18n:widgets.rpc-state.turn-off}", "hint": "{i18n:widgets.rpc-state.turn-off-hint}", + "group": null, "type": "action", "valueType": "BOOLEAN", - "valueToDataType": "CONSTANT", - "constantValue": false + "trueLabel": null, + "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", "name": "Update level", + "hint": null, + "group": null, "type": "action", "valueType": "DOUBLE", - "valueToDataType": "VALUE", - "constantValue": 0 + "trueLabel": null, + "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", "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": [ diff --git a/application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg b/application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg index 5ab59e56e5..26552c56ed 100644 --- a/application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg +++ b/application/src/main/data/json/system/scada_symbols/long-horizontal-pipe.svg @@ -30,71 +30,175 @@ "id": "fluid", "name": "{i18n:scada.symbol.fluid-presence}", "hint": "{i18n:scada.symbol.fluid-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.fluid-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-presence}", "hint": "{i18n:scada.symbol.flow-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.flow-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-direction}", "hint": "{i18n:scada.symbol.flow-direction-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": true, "trueLabel": "{i18n:scada.symbol.forward}", "falseLabel": "{i18n:scada.symbol.reverse}", "stateLabel": "{i18n:scada.symbol.forward}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-animation-speed}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}", + "group": null, "type": "value", "valueType": "DOUBLE", - "defaultValue": 1, "trueLabel": null, "falseLabel": null, "stateLabel": null, - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.leak}", "hint": "{i18n:scada.symbol.leak-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": null, "falseLabel": null, "stateLabel": "{i18n:scada.symbol.leak-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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": [ diff --git a/application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg b/application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg index 6ebb0b72cb..85667f89ab 100644 --- a/application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg +++ b/application/src/main/data/json/system/scada_symbols/long-vertical-pipe.svg @@ -30,71 +30,175 @@ "id": "fluid", "name": "{i18n:scada.symbol.fluid-presence}", "hint": "{i18n:scada.symbol.fluid-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.fluid-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-presence}", "hint": "{i18n:scada.symbol.flow-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.flow-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-direction}", "hint": "{i18n:scada.symbol.flow-direction-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": true, "trueLabel": "{i18n:scada.symbol.forward}", "falseLabel": "{i18n:scada.symbol.reverse}", "stateLabel": "{i18n:scada.symbol.forward}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-animation-speed}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}", + "group": null, "type": "value", "valueType": "DOUBLE", - "defaultValue": 1, "trueLabel": null, "falseLabel": null, "stateLabel": null, - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.leak}", "hint": "{i18n:scada.symbol.leak-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": null, "falseLabel": null, "stateLabel": "{i18n:scada.symbol.leak-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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": [ diff --git a/application/src/main/data/json/system/scada_symbols/vertical-pipe.svg b/application/src/main/data/json/system/scada_symbols/vertical-pipe.svg index a836a47394..479fc89f5a 100644 --- a/application/src/main/data/json/system/scada_symbols/vertical-pipe.svg +++ b/application/src/main/data/json/system/scada_symbols/vertical-pipe.svg @@ -30,71 +30,175 @@ "id": "fluid", "name": "{i18n:scada.symbol.fluid-presence}", "hint": "{i18n:scada.symbol.fluid-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.fluid-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-presence}", "hint": "{i18n:scada.symbol.flow-presence-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": "{i18n:scada.symbol.present}", "falseLabel": "{i18n:scada.symbol.absent}", "stateLabel": "{i18n:scada.symbol.flow-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-direction}", "hint": "{i18n:scada.symbol.flow-direction-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": true, "trueLabel": "{i18n:scada.symbol.forward}", "falseLabel": "{i18n:scada.symbol.reverse}", "stateLabel": "{i18n:scada.symbol.forward}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.flow-animation-speed}", "hint": "{i18n:scada.symbol.flow-animation-speed-hint}", + "group": null, "type": "value", "valueType": "DOUBLE", - "defaultValue": 1, "trueLabel": null, "falseLabel": null, "stateLabel": null, - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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", "name": "{i18n:scada.symbol.leak}", "hint": "{i18n:scada.symbol.leak-hint}", + "group": null, "type": "value", "valueType": "BOOLEAN", - "defaultValue": false, "trueLabel": null, "falseLabel": null, "stateLabel": "{i18n:scada.symbol.leak-present}", - "valueToDataType": "CONSTANT", - "constantValue": false, - "valueToDataFunction": "" + "defaultGetValueSettings": { + "action": "DO_NOTHING", + "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": [ diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts b/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts index 38bd5993ff..8beac3fb32 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/scada/scada-symbol.models.ts +++ b/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 { valueType: ValueType; - defaultValue: any; + defaultGetValueSettings?: GetValueSettings; trueLabel?: string; falseLabel?: string; stateLabel?: string; @@ -120,9 +120,8 @@ export interface ScadaSymbolBehaviorValue extends ScadaSymbolBehaviorBase { export interface ScadaSymbolBehaviorAction extends ScadaSymbolBehaviorBase { valueType: ValueType; - valueToDataType: ValueToDataType; - constantValue: any; - valueToDataFunction: string; + defaultSetValueSettings?: SetValueSettings; + defaultWidgetActionSettings?: WidgetAction; } export type ScadaSymbolBehavior = ScadaSymbolBehaviorValue & ScadaSymbolBehaviorAction; @@ -312,30 +311,47 @@ export const scadaSymbolContentData = (svgContent: string): ScadaSymbolContentDa return result; }; -const defaultGetValueSettings = (get: ScadaSymbolBehaviorValue): GetValueSettings => ({ - action: GetValueAction.DO_NOTHING, - defaultValue: get.defaultValue, - executeRpc: { +const defaultValueForValueType = (valueType: ValueType): any => { + if (!valueType) { + return null; + } + 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 => ({ + action: GetValueAction.DO_NOTHING, + defaultValue: defaultValueForValueType(valueType), + executeRpc: { method: 'getState', - requestTimeout: 5000, - requestPersistent: false, - persistentPollingInterval: 1000 - }, - getAttribute: { - key: 'state', - scope: null - }, - getTimeSeries: { - key: 'state' - }, - dataToValue: { - type: DataToValueType.NONE, - compareToValue: true, - dataToValueFunction: '/* Should return boolean value */\nreturn data;' - } - }); + requestTimeout: 5000, + requestPersistent: false, + persistentPollingInterval: 1000 + }, + getAttribute: { + key: 'state', + scope: null + }, + getTimeSeries: { + key: 'state' + }, + dataToValue: { + type: DataToValueType.NONE, + compareToValue: true, + dataToValueFunction: '/* Should return boolean value */\nreturn data;' + } +}); -const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettings => ({ +export const defaultSetValueSettings = (valueType: ValueType): SetValueSettings => ({ action: SetValueAction.EXECUTE_RPC, executeRpc: { method: 'setState', @@ -351,20 +367,49 @@ const defaultSetValueSettings = (set: ScadaSymbolBehaviorAction): SetValueSettin key: 'state' }, valueToData: { - type: set.valueToDataType, - constantValue: set.constantValue, - valueToDataFunction: set.valueToDataFunction ? set.valueToDataFunction : + type: valueType !== ValueType.BOOLEAN ? ValueToDataType.VALUE : ValueToDataType.CONSTANT, + constantValue: false, + valueToDataFunction: '/* 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, targetDashboardStateId: null, openRightLayout: false, setEntityId: false, 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, 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 => { const settings: ScadaSymbolObjectSettings = { @@ -373,11 +418,17 @@ export const defaultScadaSymbolObjectSettings = (metadata: ScadaSymbolMetadata): }; for (const behavior of metadata.behavior) { if (behavior.type === ScadaSymbolBehaviorType.value) { - settings.behavior[behavior.id] = defaultGetValueSettings(behavior as ScadaSymbolBehaviorValue); + settings.behavior[behavior.id] = + mergeDeep({} as GetValueSettings, + defaultGetValueSettings(behavior.valueType), (behavior as ScadaSymbolBehaviorValue).defaultGetValueSettings || {}); } 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) { - settings.behavior[behavior.id] = defaultWidgetActionSettings(behavior); + settings.behavior[behavior.id] = + mergeDeep({} as WidgetAction, + defaultWidgetActionSettings, (behavior as ScadaSymbolBehaviorAction).defaultWidgetActionSettings || {}); } } for (const property of metadata.properties) { @@ -733,17 +784,7 @@ export class ScadaSymbolObject { private normalizeValue(value: any, type: ValueType): any { if (isUndefinedOrNull(value)) { - switch (type) { - case ValueType.STRING: - return ''; - case ValueType.INTEGER: - case ValueType.DOUBLE: - return 0; - case ValueType.BOOLEAN: - return false; - case ValueType.JSON: - return {}; - } + return defaultValueForValueType(type); } else { return value; } diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html index 749b6cf362..96d8788a38 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.html @@ -70,11 +70,6 @@ -
-
scada.behavior.default-value
- -
scada.behavior.true-label
@@ -95,34 +90,41 @@
+
+
scada.behavior.default-settings
+ + +
-
-
-
{{ 'scada.behavior.default-payload' | translate }}
- - {{ 'widgets.value-action.converter-value' | translate }} - {{ 'widgets.value-action.converter-constant' | translate }} - {{ 'widgets.value-action.converter-function' | translate }} - {{ 'widgets.value-action.converter-none' | translate }} - -
- - - - +
+
scada.behavior.default-settings
+ + +
+ + +
+
scada.behavior.default-settings
+ +
diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts index 500cd4a454..f7ce9c7a0e 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-panel.component.ts +++ b/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 { merge } from 'rxjs'; import { + defaultGetValueSettings, defaultSetValueSettings, defaultWidgetActionSettings, ScadaSymbolBehavior, ScadaSymbolBehaviorType, scadaSymbolBehaviorTypes, scadaSymbolBehaviorTypeTranslations } from '@app/modules/home/components/widget/lib/scada/scada-symbol.models'; 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 { 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({ selector: 'tb-scada-symbol-behavior-panel', @@ -36,6 +41,8 @@ import { WidgetService } from '@core/http/widget.service'; }) export class ScadaSymbolBehaviorPanelComponent implements OnInit { + widgetType = widgetType; + ScadaSymbolBehaviorType = ScadaSymbolBehaviorType; ValueType = ValueType; @@ -55,6 +62,12 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit { @Input() behavior: ScadaSymbolBehavior; + @Input() + aliasController: IAliasController; + + @Input() + callbacks: WidgetActionCallbacks; + @Input() disabled: boolean; @@ -84,21 +97,19 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit { group: [this.behavior.group, []], type: [this.behavior.type, [Validators.required]], valueType: [this.behavior.valueType, [Validators.required]], - defaultValue: [this.behavior.defaultValue, [Validators.required]], trueLabel: [this.behavior.trueLabel, []], falseLabel: [this.behavior.falseLabel, []], stateLabel: [this.behavior.stateLabel, []], - valueToDataType: [this.behavior.valueToDataType, [Validators.required]], - constantValue: [this.behavior.constantValue, [Validators.required]], - valueToDataFunction: [this.behavior.valueToDataFunction, [Validators.required]] + defaultGetValueSettings: [this.behavior.defaultGetValueSettings, [Validators.required]], + defaultSetValueSettings: [this.behavior.defaultSetValueSettings, [Validators.required]], + defaultWidgetActionSettings: [this.behavior.defaultWidgetActionSettings, [Validators.required]] } ); if (this.disabled) { this.behaviorFormGroup.disable({emitEvent: false}); } else { merge(this.behaviorFormGroup.get('type').valueChanges, - this.behaviorFormGroup.get('valueType').valueChanges, - this.behaviorFormGroup.get('valueToDataType').valueChanges).subscribe(() => { + this.behaviorFormGroup.get('valueType').valueChanges).subscribe(() => { this.updateValidators(); }); this.updateValidators(); @@ -117,7 +128,9 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit { private updateValidators() { const type: ScadaSymbolBehaviorType = this.behaviorFormGroup.get('type').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.get('id').enable({emitEvent: false}); this.behaviorFormGroup.get('name').enable({emitEvent: false}); @@ -127,30 +140,49 @@ export class ScadaSymbolBehaviorPanelComponent implements OnInit { switch (type) { case ScadaSymbolBehaviorType.value: 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) { this.behaviorFormGroup.get('trueLabel').enable({emitEvent: false}); this.behaviorFormGroup.get('falseLabel').enable({emitEvent: false}); this.behaviorFormGroup.get('stateLabel').enable({emitEvent: false}); } + if (!defaultGetValueSettingsValue) { + defaultGetValueSettingsValue = mergeDeep({} as GetValueSettings, 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; 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('valueToDataType').enable({emitEvent: false}); - if (valueToDataType === ValueToDataType.CONSTANT) { - this.behaviorFormGroup.get('constantValue').enable({emitEvent: false}); - } else if (valueToDataType === ValueToDataType.FUNCTION) { - this.behaviorFormGroup.get('valueToDataFunction').enable({emitEvent: false}); + this.behaviorFormGroup.get('defaultSetValueSettings').enable({emitEvent: false}); + if (!defaultSetValueSettingsValue) { + defaultSetValueSettingsValue = mergeDeep({} as SetValueSettings, defaultSetValueSettings(valueType)); + this.behaviorFormGroup.get('defaultSetValueSettings').patchValue(defaultSetValueSettingsValue, {emitEvent: true}); + } + if (defaultGetValueSettingsValue) { + this.behaviorFormGroup.get('defaultGetValueSettings').patchValue(null, {emitEvent: true}); + } + if (defaultWidgetActionSettingsValue) { + this.behaviorFormGroup.get('defaultWidgetActionSettings').patchValue(null, {emitEvent: true}); } break; 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; } } diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts index b1070d9de9..eb71f4ff9f 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behavior-row.component.ts @@ -43,7 +43,7 @@ import { ScadaSymbolBehavior, ScadaSymbolBehaviorType, scadaSymbolBehaviorTypes, - scadaSymbolBehaviorTypeTranslations + scadaSymbolBehaviorTypeTranslations, updateBehaviorDefaultSettings } from '@home/components/widget/lib/scada/scada-symbol.models'; import { deepClone, isUndefinedOrNull } from '@core/utils'; import { MatButton } from '@angular/material/button'; @@ -55,6 +55,8 @@ import { ValueToDataType } from '@shared/models/action-widget-settings.models'; import { ScadaSymbolBehaviorsComponent } 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 => { if (!behavior.id || !behavior.name || !behavior.type) { @@ -62,20 +64,20 @@ export const behaviorValid = (behavior: ScadaSymbolBehavior): boolean => { } switch (behavior.type) { case ScadaSymbolBehaviorType.value: - if (!behavior.valueType || isUndefinedOrNull(behavior.defaultValue)) { + if (!behavior.valueType || !behavior.defaultGetValueSettings) { return false; } break; case ScadaSymbolBehaviorType.action: - if (!behavior.valueToDataType) { + if (!behavior.defaultSetValueSettings) { return false; } - if (behavior.valueToDataType === ValueToDataType.CONSTANT - && isUndefinedOrNull(behavior.constantValue)) { + if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.CONSTANT + && isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.constantValue)) { return false; } - if (behavior.valueToDataType === ValueToDataType.FUNCTION - && isUndefinedOrNull(behavior.valueToDataFunction)) { + if (behavior.defaultSetValueSettings.valueToData?.type === ValueToDataType.FUNCTION + && isUndefinedOrNull(behavior.defaultSetValueSettings.valueToData?.valueToDataFunction)) { return false; } break; @@ -120,6 +122,12 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On @Input() index: number; + @Input() + aliasController: IAliasController; + + @Input() + callbacks: WidgetActionCallbacks; + @Output() behaviorRemoved = new EventEmitter(); @@ -190,6 +198,8 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On const ctx: any = { isAdd: add, disabled: this.disabled, + aliasController: this.aliasController, + callbacks: this.callbacks, behavior: deepClone(this.modelValue) }; const scadaSymbolBehaviorPanelPopover = this.popoverService.displayPopover(trigger, this.renderer, @@ -265,13 +275,15 @@ export class ScadaSymbolBehaviorRowComponent implements ControlValueAccessor, On } private onTypeChanged(newType: ScadaSymbolBehaviorType) { - const prevType = this.modelValue.type; + const prevModel = deepClone(this.modelValue); this.modelValue = {...this.modelValue, ...{type: newType}}; + this.modelValue = updateBehaviorDefaultSettings(this.modelValue); if (!behaviorValid(this.modelValue)) { this.editBehavior(null, this.editButton, false, () => { + this.modelValue = prevModel; this.behaviorRowFormGroup.patchValue( { - type: prevType + type: prevModel.type }, {emitEvent: true} ); }); diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html index 60dc5fc908..7cefc6af63 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.html @@ -33,6 +33,8 @@
diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts index c53e6031a2..0ad1e59e05 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-behaviors.component.ts @@ -35,15 +35,22 @@ import { UntypedFormGroup, Validator } 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 { CdkDragDrop } from '@angular/cdk/drag-drop'; import { behaviorValid, ScadaSymbolBehaviorRowComponent } 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 { 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({ selector: 'tb-scada-symbol-metadata-behaviors', @@ -71,6 +78,12 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn @ViewChildren(ScadaSymbolBehaviorRowComponent) behaviorRows: QueryList; + @Input() + aliasController: IAliasController; + + @Input() + callbacks: WidgetActionCallbacks; + @Input() disabled: boolean; @@ -181,10 +194,7 @@ export class ScadaSymbolBehaviorsComponent implements ControlValueAccessor, OnIn name: '', type: ScadaSymbolBehaviorType.value, valueType: ValueType.BOOLEAN, - defaultValue: false, - valueToDataType: ValueToDataType.CONSTANT, - constantValue: false, - valueToDataFunction: '' + defaultGetValueSettings: mergeDeep({} as GetValueSettings, defaultGetValueSettings(ValueType.BOOLEAN)) }; const behaviorsArray = this.behaviorsFormGroup.get('behaviors') as UntypedFormArray; const behaviorControl = this.fb.control(behavior, []); diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html index 573ea27af0..37098a982d 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.html @@ -101,7 +101,9 @@
+ formControlName="behavior" + [aliasController]="aliasController" + [callbacks]="callbacks">
diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts index db266f5a08..f5ecaab3d2 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/metadata-components/scada-symbol-metadata.component.ts @@ -53,6 +53,8 @@ import { scadaSymbolGeneralStateRenderPropertiesHighlightRules } from '@home/pages/scada-symbol/scada-symbol-editor.models'; 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({ selector: 'tb-scada-symbol-metadata', @@ -77,6 +79,12 @@ export class ScadaSymbolMetadataComponent extends PageComponent implements OnIni @ViewChild('symbolMetadataTags') symbolMetadataTags: ScadaSymbolMetadataTagsComponent; + @Input() + aliasController: IAliasController; + + @Input() + callbacks: WidgetActionCallbacks; + @Input() disabled: boolean; diff --git a/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html b/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html index 54251bd8ed..6662509fa6 100644 --- a/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html +++ b/ui-ngx/src/app/modules/home/pages/scada-symbol/scada-symbol.component.html @@ -80,6 +80,8 @@