@flexem/fc-gui 3.0.0-alpha.152 → 3.0.0-alpha.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/@flexem/fc-gui.umd.js +280 -229
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +4 -4
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/config/gui-feature-config.d.ts +3 -0
- package/config/gui-feature-config.js +3 -0
- package/config/gui-feature-config.metadata.json +1 -0
- package/config/index.d.ts +1 -0
- package/config/index.js +1 -0
- package/config/index.metadata.json +1 -1
- package/elements/base/readable-element.js +2 -1
- package/elements/base/readable-element.metadata.json +1 -1
- package/elements/character-display/character-display-element.js +2 -1
- package/elements/character-display/character-display-element.metadata.json +1 -1
- package/elements/switch-indicator-light/bit-indicator-light-operator.js +6 -2
- package/elements/switch-indicator-light/bit-indicator-light-operator.metadata.json +1 -1
- package/elements/switch-indicator-light/switch-indicator-light-element.js +2 -1
- package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
- package/elements/switch-indicator-light/word-indicator-light-operator.js +6 -2
- package/elements/switch-indicator-light/word-indicator-light-operator.metadata.json +1 -1
- package/gui/gui-view.js +3 -1
- package/gui/gui-view.metadata.json +1 -1
- package/package.json +1 -1
- package/remote/communication/variable/remote-variable-communicator.d.ts +3 -1
- package/remote/communication/variable/remote-variable-communicator.js +42 -13
- package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"GuiFeatureConfig":{"__symbolic":"class","statics":{"isOfflineDisplayEnabled":false}}}}]
|
package/config/index.d.ts
CHANGED
package/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"},{"from":"./alarm"}]}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./gui-feature-config","export":["GuiFeatureConfig"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"},{"from":"./alarm"}]}]
|
|
@@ -3,6 +3,7 @@ import { VariableState } from '../../communication';
|
|
|
3
3
|
import { ConditionalEnableElement } from './conditional-enable-element';
|
|
4
4
|
import { forEach } from 'lodash';
|
|
5
5
|
import { VariableUtil } from '../../utils/variable-util';
|
|
6
|
+
import { GuiFeatureConfig } from '../../config';
|
|
6
7
|
export class ReadableElement extends ConditionalEnableElement {
|
|
7
8
|
constructor(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId) {
|
|
8
9
|
super(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId);
|
|
@@ -112,7 +113,7 @@ export class ReadableElement extends ConditionalEnableElement {
|
|
|
112
113
|
return;
|
|
113
114
|
}
|
|
114
115
|
// 处理普通变量
|
|
115
|
-
if (this.state === State.Normal || this.state === State.Disable || this.state === State.Offline
|
|
116
|
+
if (this.state === State.Normal || this.state === State.Disable || (GuiFeatureConfig.isOfflineDisplayEnabled && this.state === State.Offline)
|
|
116
117
|
|| value.variableName === this.minVariableName
|
|
117
118
|
|| value.variableName === this.maxVariableName) {
|
|
118
119
|
this.updateVariableValue(value.value, value.variableName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"ReadableElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./conditional-enable-element","name":"ConditionalEnableElement","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"ReadableElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"./conditional-enable-element","name":"ConditionalEnableElement","line":10,"character":46},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":14,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":14,"character":57},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":14,"character":98},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":15,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":15,"character":52},{"__symbolic":"reference","name":"string"}]}],"init":[{"__symbolic":"method"}],"getVariableName":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"reportStateChanged":[{"__symbolic":"method"}],"reportValueChanged":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GraphType } from '../../config';
|
|
2
|
+
import { GuiFeatureConfig } from '../../config';
|
|
2
3
|
import { LOGGER_SERVICE_TOKEN } from '../../logger';
|
|
3
4
|
import { AlertModalComponent } from '../../modal/alert/alert-modal.component';
|
|
4
5
|
import { ConfirmOperationModalComponent } from '../../modal/confirm-operation/confirm-operation-modal.component';
|
|
@@ -67,7 +68,7 @@ export class CharacterDisplayElement extends ReadableElement {
|
|
|
67
68
|
}
|
|
68
69
|
changeStates() {
|
|
69
70
|
super.changeStates();
|
|
70
|
-
if (this.state === State.Normal || this.state === State.Disable || this.state === State.Offline) {
|
|
71
|
+
if (this.state === State.Normal || this.state === State.Disable || (GuiFeatureConfig.isOfflineDisplayEnabled && this.state === State.Offline)) {
|
|
71
72
|
this.updateDisplayValue(this.displayValue);
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"CharacterDisplayElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"CharacterDisplayElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":20,"character":45},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":29,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":29,"character":48},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":30,"character":39},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":31,"character":30},{"__symbolic":"reference","module":"../../config","name":"GraphStore","line":32,"character":37},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":33,"character":27},{"__symbolic":"reference","module":"../../service","name":"OperationRecordService","line":34,"character":49},{"__symbolic":"reference","module":"../../security","name":"SecurityChecker","line":35,"character":42},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":36,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":37,"character":22},{"__symbolic":"reference","name":"string"}]}],"updateVariableValue":[{"__symbolic":"method"}],"changeStates":[{"__symbolic":"method"}],"updateDisplayValue":[{"__symbolic":"method"}],"getVariableValueText":[{"__symbolic":"method"}],"characterDisplayText":[{"__symbolic":"method"}],"initElement":[{"__symbolic":"method"}],"initVariableText":[{"__symbolic":"method"}],"initClickEvent":[{"__symbolic":"method"}],"checkElementPassword":[{"__symbolic":"method"}],"doWriteCharacterValue":[{"__symbolic":"method"}],"recordOperation":[{"__symbolic":"method"}],"changeGraph":[{"__symbolic":"method"}]}}}}]
|
|
@@ -6,6 +6,7 @@ import { CurrentStateIdValue } from './current-stateId-value';
|
|
|
6
6
|
import { Binary } from '../../model/shared/binary';
|
|
7
7
|
import { VariableUtil } from '../../utils/variable-util';
|
|
8
8
|
import { VariableDefinition } from '../../communication/variable/variable-definition';
|
|
9
|
+
import { GuiFeatureConfig } from '../../config';
|
|
9
10
|
export class BitIndicatorLightOperator {
|
|
10
11
|
constructor(settings, states, variableCommunicator, variableStore) {
|
|
11
12
|
this.settings = settings;
|
|
@@ -48,8 +49,11 @@ export class BitIndicatorLightOperator {
|
|
|
48
49
|
if (variableStete.state === VariableStateEnum.Normal) {
|
|
49
50
|
this.requestCurrentSateIdValue(this.variableCommunicator, appId);
|
|
50
51
|
}
|
|
52
|
+
else if (GuiFeatureConfig.isOfflineDisplayEnabled && variableStete.state === VariableStateEnum.Offline && !this.valueSubscription) {
|
|
53
|
+
this.requestCurrentSateIdValue(this.variableCommunicator, appId);
|
|
54
|
+
}
|
|
51
55
|
else {
|
|
52
|
-
this.currentStateIdChanged.emit(new CurrentStateIdValue(new VariableState(this.variableName, variableStete.state)));
|
|
56
|
+
this.currentStateIdChanged.emit(new CurrentStateIdValue(new VariableState(this.variableName, variableStete.state), this.currentStateId));
|
|
53
57
|
}
|
|
54
58
|
});
|
|
55
59
|
}
|
|
@@ -59,7 +63,7 @@ export class BitIndicatorLightOperator {
|
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
this.valueSubscription = variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
|
|
62
|
-
if (value.state === VariableStateEnum.DataNormal || value.state === VariableStateEnum.Offline) {
|
|
66
|
+
if (value.state === VariableStateEnum.DataNormal || (GuiFeatureConfig.isOfflineDisplayEnabled && value.state === VariableStateEnum.Offline)) {
|
|
63
67
|
if (this.settings.isBitwiseIndex) {
|
|
64
68
|
const maxBitIndex = 31;
|
|
65
69
|
this.binary = new Binary(value.value, maxBitIndex + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"BitIndicatorLightOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"BitIndicatorLightSettings","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"BitIndicatorLightOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"BitIndicatorLightSettings","line":28,"character":43},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../model","name":"SwitchIndicatorState","line":29,"character":16}]},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":30,"character":47},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":31,"character":40}]}],"requestData":[{"__symbolic":"method"}],"requestCurrentSateIdValue":[{"__symbolic":"method"}]}}}}]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LOGGER_SERVICE_TOKEN } from '../../logger';
|
|
2
2
|
import * as d3 from 'd3-selection';
|
|
3
3
|
import { isUndefined } from 'lodash';
|
|
4
|
+
import { GuiFeatureConfig } from '../../config';
|
|
4
5
|
import { IndicatorLightType, SwitchType, State, BitSwitchOperation } from '../../model';
|
|
5
6
|
import { VariableState } from '../../communication';
|
|
6
7
|
import { ConditionalEnableElement } from '../base/conditional-enable-element';
|
|
@@ -218,7 +219,7 @@ export class SwitchIndicatorLightElement extends ConditionalEnableElement {
|
|
|
218
219
|
}
|
|
219
220
|
currentStateIdChange(statusIdValue) {
|
|
220
221
|
this.updateElementStates([statusIdValue.state]);
|
|
221
|
-
if (this.state === State.Unbind || this.state === State.Offline) {
|
|
222
|
+
if (this.state === State.Unbind || (GuiFeatureConfig.isOfflineDisplayEnabled && this.state === State.Offline)) {
|
|
222
223
|
if (!isUndefined(statusIdValue.value)) {
|
|
223
224
|
this.switchToState(statusIdValue.value);
|
|
224
225
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"SwitchIndicatorLightElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-enable-element","name":"ConditionalEnableElement","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"SwitchIndicatorLightElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-enable-element","name":"ConditionalEnableElement","line":34,"character":49},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":53,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":54,"character":18},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":55,"character":39},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":56,"character":30},{"__symbolic":"reference","module":"../../config","name":"GraphStore","line":57,"character":37},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":58,"character":27},{"__symbolic":"reference","module":"../../service","name":"OperationRecordService","line":59,"character":49},{"__symbolic":"reference","module":"../../security","name":"SecurityChecker","line":60,"character":42},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":61,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":62,"character":22},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../../service","name":"TextLibraryService","line":64,"character":46},{"__symbolic":"reference","module":"../../service","name":"LanguageService","line":65,"character":43},{"__symbolic":"reference","module":"../../gui/gui-context","name":"GuiContext","line":66,"character":38}]}],"handleMouseUp":[{"__symbolic":"method"}],"initOnDocMouseUpEvent":[{"__symbolic":"method"}],"checkElementPassword":[{"__symbolic":"method"}],"doSwitchOperator":[{"__symbolic":"method"}],"writeValue":[{"__symbolic":"method"}],"initSwitchOperator":[{"__symbolic":"method"}],"initIndictorLightOperator":[{"__symbolic":"method"}],"currentStateIdChange":[{"__symbolic":"method"}],"switchToState":[{"__symbolic":"method"}],"initGraphAndText":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"checkState":[{"__symbolic":"method"}]}}}}]
|
|
@@ -5,6 +5,7 @@ import { VariableStateEnum, VariableState } from '../../communication';
|
|
|
5
5
|
import { CurrentStateIdValue } from './current-stateId-value';
|
|
6
6
|
import { VariableUtil } from '../../utils/variable-util';
|
|
7
7
|
import { VariableDefinition } from '../../communication/variable/variable-definition';
|
|
8
|
+
import { GuiFeatureConfig } from '../../config';
|
|
8
9
|
export class WordIndicatorLightOperator {
|
|
9
10
|
constructor(settings, states, variableCommunicator, variableStore) {
|
|
10
11
|
this.settings = settings;
|
|
@@ -26,8 +27,11 @@ export class WordIndicatorLightOperator {
|
|
|
26
27
|
if (variableValue.state === VariableStateEnum.Normal) {
|
|
27
28
|
this.requestCurrentSateIdValue(this.variableCommunicator, appId);
|
|
28
29
|
}
|
|
30
|
+
else if (GuiFeatureConfig.isOfflineDisplayEnabled && variableValue.state === VariableStateEnum.Offline && !this.valueSubscription) {
|
|
31
|
+
this.requestCurrentSateIdValue(this.variableCommunicator, appId);
|
|
32
|
+
}
|
|
29
33
|
else {
|
|
30
|
-
this.currentStateIdChanged.emit(new CurrentStateIdValue(new VariableState(this.variableName, variableValue.state)));
|
|
34
|
+
this.currentStateIdChanged.emit(new CurrentStateIdValue(new VariableState(this.variableName, variableValue.state), this.currentStateId));
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
37
|
}
|
|
@@ -41,7 +45,7 @@ export class WordIndicatorLightOperator {
|
|
|
41
45
|
}
|
|
42
46
|
// TODO 检查状态id是从0-n连续编号的。
|
|
43
47
|
this.valueSubscription = variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
|
|
44
|
-
if (value.state === VariableStateEnum.DataNormal || value.state === VariableStateEnum.Offline) {
|
|
48
|
+
if (value.state === VariableStateEnum.DataNormal || (GuiFeatureConfig.isOfflineDisplayEnabled && value.state === VariableStateEnum.Offline)) {
|
|
45
49
|
let stateId = 0;
|
|
46
50
|
for (let index = 0; index < this.sortedStates.length - 1; index++) {
|
|
47
51
|
const element = this.sortedStates[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"WordIndicatorLightOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"WordIndicatorLightSettings","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"WordIndicatorLightOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"WordIndicatorLightSettings","line":25,"character":43},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../model","name":"SwitchIndicatorState","line":26,"character":16}]},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":27,"character":47},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":28,"character":40}]}],"requestData":[{"__symbolic":"method"}],"requestCurrentSateIdValue":[{"__symbolic":"method"}]}}}}]
|
package/gui/gui-view.js
CHANGED
|
@@ -9,6 +9,7 @@ import { ViewPopupBackdropType, ViewPopupLocationType } from '../model';
|
|
|
9
9
|
import { ViewResizeMode, DisplayMode, GlobalSettings } from '../settings';
|
|
10
10
|
import { ConfigIsEmptyError } from '../shared';
|
|
11
11
|
import { Guid } from '../utils/guid';
|
|
12
|
+
import { GuiFeatureConfig } from '../config';
|
|
12
13
|
export class GuiView {
|
|
13
14
|
constructor(injector, bsModalService, context, parentView) {
|
|
14
15
|
this.injector = injector;
|
|
@@ -115,7 +116,8 @@ export class GuiView {
|
|
|
115
116
|
this.mainElement.reportVariableStates(states);
|
|
116
117
|
const normalVariableNames = [];
|
|
117
118
|
each(states, v => {
|
|
118
|
-
if ((v.state === VariableStateEnum.Normal || v.state === VariableStateEnum.Offline)
|
|
119
|
+
if ((v.state === VariableStateEnum.Normal || (GuiFeatureConfig.isOfflineDisplayEnabled && v.state === VariableStateEnum.Offline))
|
|
120
|
+
&& normalVariableNames.indexOf(v.variableName) === -1) {
|
|
119
121
|
normalVariableNames.push(v.variableName);
|
|
120
122
|
}
|
|
121
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"GuiView":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"GuiView":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":51,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":52,"character":41},{"__symbolic":"reference","module":"./gui-context","name":"GuiContext","line":53,"character":34},{"__symbolic":"reference","name":"GuiView"}]}],"resize":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}],"loadElementState":[{"__symbolic":"method"}],"popView":[{"__symbolic":"method"}],"closeView":[{"__symbolic":"method"}],"moveView":[{"__symbolic":"method"}],"showMusk":[{"__symbolic":"method"}],"showShadow":[{"__symbolic":"method"}],"hideMusk":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"normalOpenedVariableNames":[{"__symbolic":"method"}]}}}}]
|
package/package.json
CHANGED
|
@@ -28,7 +28,9 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
|
|
|
28
28
|
private doVirtualDeviceStatesChanged;
|
|
29
29
|
private doVariableStatesChanged;
|
|
30
30
|
/**
|
|
31
|
-
* 预填充离线变量值缓存,由 GuiContext
|
|
31
|
+
* 预填充离线变量值缓存,由 GuiContext 在组态加载时一次性调用。
|
|
32
|
+
* 若状态推送早于接口返回,变量已在 Offline 状态,则直接推送;
|
|
33
|
+
* 否则缓存等待状态事件到来时推送。
|
|
32
34
|
*/
|
|
33
35
|
setOfflineValueCache(variableName: string, value: any): void;
|
|
34
36
|
subscribeVariableStates(variableNames: string[]): Observable<VariableState[]>;
|
|
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
|
|
|
3
3
|
import { map } from 'rxjs/operators';
|
|
4
4
|
import { VariableStateEnum } from '../../../communication';
|
|
5
5
|
import { StringifyingMap } from '../../../core';
|
|
6
|
+
import { GuiFeatureConfig } from '../../../config';
|
|
6
7
|
export class RemoteVariableCommunicator {
|
|
7
8
|
constructor(remoteVariableProtocol, logger) {
|
|
8
9
|
this.remoteVariableProtocol = remoteVariableProtocol;
|
|
@@ -94,18 +95,20 @@ export class RemoteVariableCommunicator {
|
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
// 离线时从预加载缓存取值推送给值订阅者
|
|
97
|
-
if (state.state === VariableStateEnum.Offline && this.offlineValueCache.has(variableName)) {
|
|
98
|
+
if (GuiFeatureConfig.isOfflineDisplayEnabled && state.state === VariableStateEnum.Offline && this.offlineValueCache.has(variableName)) {
|
|
98
99
|
const cachedValue = this.offlineValueCache.get(variableName);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
if (cachedValue !== null) {
|
|
101
|
+
const variableValue = {
|
|
102
|
+
variableName,
|
|
103
|
+
value: cachedValue,
|
|
104
|
+
state: VariableStateEnum.Offline
|
|
105
|
+
};
|
|
106
|
+
this.variableValueCache.set(variableName, variableValue);
|
|
107
|
+
if (this.observers.has(variableName)) {
|
|
108
|
+
each(this.observers.get(variableName), ob => {
|
|
109
|
+
ob.next([variableValue]);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
// 无论什么状态,推送后清除缓存,防止后续再次离线时用旧值
|
|
@@ -114,10 +117,36 @@ export class RemoteVariableCommunicator {
|
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
|
-
* 预填充离线变量值缓存,由 GuiContext
|
|
120
|
+
* 预填充离线变量值缓存,由 GuiContext 在组态加载时一次性调用。
|
|
121
|
+
* 若状态推送早于接口返回,变量已在 Offline 状态,则直接推送;
|
|
122
|
+
* 否则缓存等待状态事件到来时推送。
|
|
118
123
|
*/
|
|
119
124
|
setOfflineValueCache(variableName, value) {
|
|
120
|
-
|
|
125
|
+
if (!GuiFeatureConfig.isOfflineDisplayEnabled) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (value === null || value === undefined) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const cachedState = this.variableStateCache.get(variableName);
|
|
132
|
+
if (cachedState && cachedState.state === VariableStateEnum.Offline) {
|
|
133
|
+
// 状态已推送过,直接补推值给订阅者
|
|
134
|
+
const variableValue = {
|
|
135
|
+
variableName,
|
|
136
|
+
value,
|
|
137
|
+
state: VariableStateEnum.Offline
|
|
138
|
+
};
|
|
139
|
+
this.variableValueCache.set(variableName, variableValue);
|
|
140
|
+
if (this.observers.has(variableName)) {
|
|
141
|
+
each(this.observers.get(variableName), ob => {
|
|
142
|
+
ob.next([variableValue]);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// 状态还未推送,先缓存,等待状态事件
|
|
148
|
+
this.offlineValueCache.set(variableName, value);
|
|
149
|
+
}
|
|
121
150
|
}
|
|
122
151
|
subscribeVariableStates(variableNames) {
|
|
123
152
|
return new Observable(observer => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"RemoteVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./remote-variable-protocol","name":"RemoteVariableProtocol","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"RemoteVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./remote-variable-protocol","name":"RemoteVariableProtocol","line":38,"character":57},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":38,"character":106}]}],"doAlarmChanged":[{"__symbolic":"method"}],"doVariableValuesChanged":[{"__symbolic":"method"}],"doVirtualDeviceStatesChanged":[{"__symbolic":"method"}],"doVariableStatesChanged":[{"__symbolic":"method"}],"setOfflineValueCache":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"requestVirtualDeviceState":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"openVariable":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"registerSystemVariableHandler":[{"__symbolic":"method"}],"notifySystemVariableChange":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
|