@flexem/fc-gui 3.0.0-alpha.114 → 3.0.0-alpha.115
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 +93 -16
- package/bundles/@flexem/fc-gui.umd.js.map +1 -1
- package/bundles/@flexem/fc-gui.umd.min.js +2 -2
- package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
- package/communication/variable/variable-communicator.d.ts +1 -0
- package/communication/variable/variable-value.d.ts +3 -1
- package/communication/variable/variable-value.js +3 -1
- package/communication/variable/variable-value.metadata.json +1 -1
- package/elements/base/readable-element.js +4 -1
- package/elements/base/state-control-element.js +3 -0
- package/elements/main-element.js +2 -1
- package/elements/per-view-variable-communicator.d.ts +1 -0
- package/elements/per-view-variable-communicator.js +3 -0
- package/elements/per-view-variable-communicator.metadata.json +1 -1
- package/gui/gui-view.d.ts +2 -0
- package/gui/gui-view.js +54 -13
- package/gui/gui-view.metadata.json +1 -1
- package/package.json +1 -1
- package/remote/communication/variable/remote-variable-communicator.d.ts +3 -0
- package/remote/communication/variable/remote-variable-communicator.js +24 -0
- package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
- package/remote/communication/variable/remote-variable-protocol.d.ts +2 -0
|
@@ -6,6 +6,7 @@ export interface VariableCommunicator {
|
|
|
6
6
|
openVariables(variableNames: Array<string>, appId: string): Observable<Array<VariableValue>>;
|
|
7
7
|
write(variableName: string, value: any): Observable<VariableValue>;
|
|
8
8
|
writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
|
|
9
|
+
requestVirtualDeviceState(): Observable<void>;
|
|
9
10
|
subscribeVariableState(variableName: string): Observable<VariableState>;
|
|
10
11
|
subscribeVariableStates(variableNames: Array<string>): Observable<Array<VariableState>>;
|
|
11
12
|
subscribeUserDeviceAlarms(appId: string): any;
|
|
@@ -4,5 +4,7 @@ export declare class VariableValue {
|
|
|
4
4
|
state: VariableStateEnum;
|
|
5
5
|
value?: any;
|
|
6
6
|
readonly timeStamp?: string;
|
|
7
|
-
|
|
7
|
+
systemName?: string;
|
|
8
|
+
customStatus?: string;
|
|
9
|
+
constructor(variableName: string, state: VariableStateEnum, value?: any, timeStamp?: string, systemName?: string, customStatus?: string);
|
|
8
10
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export class VariableValue {
|
|
2
|
-
constructor(variableName, state, value, timeStamp) {
|
|
2
|
+
constructor(variableName, state, value, timeStamp, systemName, customStatus) {
|
|
3
3
|
this.variableName = variableName;
|
|
4
4
|
this.state = state;
|
|
5
5
|
this.value = value;
|
|
6
6
|
this.timeStamp = timeStamp;
|
|
7
|
+
this.systemName = systemName;
|
|
8
|
+
this.customStatus = customStatus;
|
|
7
9
|
}
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"VariableValue":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"./variable-state-enum","name":"VariableStateEnum","line":3,"character":68},{"__symbolic":"reference","name":"any"},{"__symbolic":"reference","name":"string"}]}]}}}}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"VariableValue":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"./variable-state-enum","name":"VariableStateEnum","line":3,"character":68},{"__symbolic":"reference","name":"any"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"}]}]}}}}]
|
|
@@ -73,7 +73,7 @@ export class ReadableElement extends ConditionalEnableElement {
|
|
|
73
73
|
}
|
|
74
74
|
reportValueChanged(value) {
|
|
75
75
|
forEach(this.elementStates, elementState => {
|
|
76
|
-
if (elementState.variableName === value.variableName) {
|
|
76
|
+
if (elementState.variableName === value.variableName || elementState.variableName === value.systemName) {
|
|
77
77
|
elementState.state = value.state;
|
|
78
78
|
this.changeStates();
|
|
79
79
|
}
|
|
@@ -83,5 +83,8 @@ export class ReadableElement extends ConditionalEnableElement {
|
|
|
83
83
|
|| value.variableName === this.maxVariableName) {
|
|
84
84
|
this.updateVariableValue(value.value, value.variableName);
|
|
85
85
|
}
|
|
86
|
+
if (value.systemName === '设备状态') {
|
|
87
|
+
this.updateVariableValue(value.customStatus, '设备状态');
|
|
88
|
+
}
|
|
86
89
|
}
|
|
87
90
|
}
|
|
@@ -139,6 +139,9 @@ export class StateControlElement extends ConditionalDynamicDisplayElement {
|
|
|
139
139
|
if (!this.currentRect.length) {
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
|
+
// 元件绑定设备状态时不需要在右上角显示状态
|
|
143
|
+
if (this.$element[0].dataset.model.includes('设备状态'))
|
|
144
|
+
return;
|
|
142
145
|
const document = this.$element[0].ownerDocument;
|
|
143
146
|
const imgObj = document.createElementNS('http://www.w3.org/2000/svg', 'image');
|
|
144
147
|
if (imgObj) {
|
package/elements/main-element.js
CHANGED
|
@@ -262,7 +262,8 @@ export class MainElement {
|
|
|
262
262
|
each(values, value => {
|
|
263
263
|
each(this.elements, e => {
|
|
264
264
|
if (e instanceof ReadableElement) {
|
|
265
|
-
if (
|
|
265
|
+
if ((value.variableName && (e.readVariableName === value.variableName ||
|
|
266
|
+
e.minVariableName === value.variableName || e.maxVariableName === value.variableName)) || e.readVariableName === value.systemName) {
|
|
266
267
|
e.reportValueChanged(value);
|
|
267
268
|
}
|
|
268
269
|
}
|
|
@@ -12,6 +12,7 @@ export declare class PerViewVariableCommunicator implements VariableCommunicator
|
|
|
12
12
|
openVariables(variableNames: Array<string>, appId?: string): Observable<Array<VariableValue>>;
|
|
13
13
|
write(variableName: string, value: any): Observable<VariableValue>;
|
|
14
14
|
writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
|
|
15
|
+
requestVirtualDeviceState(): Observable<void>;
|
|
15
16
|
subscribeVariableState(variableName: string): Observable<VariableState>;
|
|
16
17
|
subscribeVariableStates(variableNames: string[]): Observable<Array<VariableState>>;
|
|
17
18
|
subscribeUserDeviceAlarms(appId?: string): Observable<VariableState[]>;
|
|
@@ -30,6 +30,9 @@ export class PerViewVariableCommunicator {
|
|
|
30
30
|
writeWordByBit(variableName, index, value) {
|
|
31
31
|
return this._rawVariableCommunicator.writeWordByBit(variableName, index, value);
|
|
32
32
|
}
|
|
33
|
+
requestVirtualDeviceState() {
|
|
34
|
+
return this._rawVariableCommunicator.requestVirtualDeviceState();
|
|
35
|
+
}
|
|
33
36
|
subscribeVariableState(variableName) {
|
|
34
37
|
return this.subscribeVariableStates([variableName]).pipe(map(values => values[0]));
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PerViewVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":15,"character":38}]}],"openVariable":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"PerViewVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":15,"character":38}]}],"openVariable":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"requestVirtualDeviceState":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
|
package/gui/gui-view.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export declare class GuiView implements PopupViewService {
|
|
|
21
21
|
private mainElement;
|
|
22
22
|
private muskElement;
|
|
23
23
|
private openVariableStatesSubscription;
|
|
24
|
+
private requestVirtualDeviceState;
|
|
25
|
+
private virtualDeviceStatesChanged;
|
|
24
26
|
private openVariablesSubscription;
|
|
25
27
|
private openedVariableNames;
|
|
26
28
|
private perViewVariableCommunicator;
|
package/gui/gui-view.js
CHANGED
|
@@ -72,22 +72,57 @@ export class GuiView {
|
|
|
72
72
|
this.openVariableStatesSubscription.unsubscribe();
|
|
73
73
|
}
|
|
74
74
|
this.openedVariableNames = this.mainElement.getVariableNames();
|
|
75
|
-
if (this.openedVariableNames.
|
|
76
|
-
|
|
75
|
+
if (this.openedVariableNames.indexOf('设备状态') !== -1) {
|
|
76
|
+
if (this.requestVirtualDeviceState) {
|
|
77
|
+
this.requestVirtualDeviceState.unsubscribe();
|
|
78
|
+
}
|
|
79
|
+
if (this.requestVirtualDeviceState) {
|
|
80
|
+
this.requestVirtualDeviceState.unsubscribe();
|
|
81
|
+
}
|
|
82
|
+
if (this.openedVariableNames.length === 1) {
|
|
83
|
+
this.normalOpenedVariableNames(['设备状态']);
|
|
84
|
+
this.requestVirtualDeviceState =
|
|
85
|
+
this.perViewVariableCommunicator.requestVirtualDeviceState().subscribe({
|
|
86
|
+
complete: () => { }
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this.openVariableStatesSubscription =
|
|
91
|
+
this.perViewVariableCommunicator.subscribeVariableStates(this.openedVariableNames).subscribe((states) => {
|
|
92
|
+
this.mainElement.reportVariableStates(states);
|
|
93
|
+
const normalVariableNames = [];
|
|
94
|
+
each(states, v => {
|
|
95
|
+
if (v.state === VariableStateEnum.Normal && normalVariableNames.indexOf(v.variableName) === -1) {
|
|
96
|
+
normalVariableNames.push(v.variableName);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
normalVariableNames.push('设备状态');
|
|
100
|
+
this.normalOpenedVariableNames(normalVariableNames);
|
|
101
|
+
this.requestVirtualDeviceState =
|
|
102
|
+
this.perViewVariableCommunicator.requestVirtualDeviceState().subscribe({
|
|
103
|
+
complete: () => { }
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
77
107
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
else {
|
|
109
|
+
if (this.openedVariableNames.length === 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.openVariableStatesSubscription =
|
|
113
|
+
this.perViewVariableCommunicator.subscribeVariableStates(this.openedVariableNames).subscribe((states) => {
|
|
114
|
+
this.mainElement.reportVariableStates(states);
|
|
115
|
+
const normalVariableNames = [];
|
|
116
|
+
each(states, v => {
|
|
117
|
+
if (v.state === VariableStateEnum.Normal && normalVariableNames.indexOf(v.variableName) === -1) {
|
|
118
|
+
normalVariableNames.push(v.variableName);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (normalVariableNames.length > 0) {
|
|
122
|
+
this.normalOpenedVariableNames(normalVariableNames);
|
|
85
123
|
}
|
|
86
124
|
});
|
|
87
|
-
|
|
88
|
-
this.normalOpenedVariableNames(normalVariableNames);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
125
|
+
}
|
|
91
126
|
}
|
|
92
127
|
popView(viewIndex, hostContainerId, el) {
|
|
93
128
|
return this.context.configStore.viewStore.getViewConfig(viewIndex).pipe(map(view => {
|
|
@@ -181,6 +216,12 @@ export class GuiView {
|
|
|
181
216
|
if (this.openVariableStatesSubscription) {
|
|
182
217
|
this.openVariableStatesSubscription.unsubscribe();
|
|
183
218
|
}
|
|
219
|
+
if (this.requestVirtualDeviceState) {
|
|
220
|
+
this.requestVirtualDeviceState.unsubscribe();
|
|
221
|
+
}
|
|
222
|
+
if (this.virtualDeviceStatesChanged) {
|
|
223
|
+
this.virtualDeviceStatesChanged.unsubscribe();
|
|
224
|
+
}
|
|
184
225
|
if (this.openVariablesSubscription) {
|
|
185
226
|
this.openVariablesSubscription.unsubscribe();
|
|
186
227
|
}
|
|
@@ -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":49,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":50,"character":41},{"__symbolic":"reference","module":"./gui-context","name":"GuiContext","line":51,"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
|
@@ -9,6 +9,7 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
|
|
|
9
9
|
private appIdVariablesMap;
|
|
10
10
|
private connectedSubscription;
|
|
11
11
|
private variableValuesChangedSubscription;
|
|
12
|
+
private virtualDeviceStatesChangedSubscription;
|
|
12
13
|
private variablesToBeOpened;
|
|
13
14
|
private variablesToBeClosed;
|
|
14
15
|
private variableValueCache;
|
|
@@ -22,9 +23,11 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
|
|
|
22
23
|
constructor(remoteVariableProtocol: RemoteVariableProtocol, logger: LoggerService);
|
|
23
24
|
private doAlarmChanged;
|
|
24
25
|
private doVariableValuesChanged;
|
|
26
|
+
private doVirtualDeviceStatesChanged;
|
|
25
27
|
private doVariableStatesChanged;
|
|
26
28
|
subscribeVariableStates(variableNames: string[]): Observable<VariableState[]>;
|
|
27
29
|
subscribeVariableState(variableName: string): Observable<VariableState>;
|
|
30
|
+
requestVirtualDeviceState(): Observable<void>;
|
|
28
31
|
openVariables(variableNames: string[], appId?: string): Observable<VariableValue[]>;
|
|
29
32
|
openVariable(variableName: string, appId?: string): Observable<VariableValue>;
|
|
30
33
|
write(variableName: string, value: any): Observable<VariableValue>;
|
|
@@ -24,6 +24,7 @@ export class RemoteVariableCommunicator {
|
|
|
24
24
|
});
|
|
25
25
|
this.doVariableStatesChanged();
|
|
26
26
|
this.doVariableValuesChanged();
|
|
27
|
+
this.doVirtualDeviceStatesChanged();
|
|
27
28
|
this.doAlarmChanged();
|
|
28
29
|
}
|
|
29
30
|
doAlarmChanged() {
|
|
@@ -54,6 +55,25 @@ export class RemoteVariableCommunicator {
|
|
|
54
55
|
});
|
|
55
56
|
});
|
|
56
57
|
}
|
|
58
|
+
doVirtualDeviceStatesChanged() {
|
|
59
|
+
if (this.virtualDeviceStatesChangedSubscription !== undefined) {
|
|
60
|
+
this.virtualDeviceStatesChangedSubscription.unsubscribe();
|
|
61
|
+
}
|
|
62
|
+
this.virtualDeviceStatesChangedSubscription =
|
|
63
|
+
this.remoteVariableProtocol.virtualDeviceStatesChanged.subscribe((deviceStates) => {
|
|
64
|
+
each(deviceStates, deviceState => {
|
|
65
|
+
const variableName = '设备状态';
|
|
66
|
+
this.variableValueCache.set(variableName, deviceState);
|
|
67
|
+
const data = Object.assign(Object.assign({}, deviceState), { systemName: '设备状态' });
|
|
68
|
+
if (this.observers.has(variableName)) {
|
|
69
|
+
each(this.observers.get(variableName), ob => {
|
|
70
|
+
// TODO 同一个ob监听多个变量的情况,组合成数组一次推送。
|
|
71
|
+
ob.next([data]);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
57
77
|
doVariableStatesChanged() {
|
|
58
78
|
if (this.variableStatesChangedSubscription !== undefined) {
|
|
59
79
|
this.variableStatesChangedSubscription.unsubscribe();
|
|
@@ -127,6 +147,9 @@ export class RemoteVariableCommunicator {
|
|
|
127
147
|
subscribeVariableState(variableName) {
|
|
128
148
|
return this.subscribeVariableStates([variableName]).pipe(map(values => values[0]));
|
|
129
149
|
}
|
|
150
|
+
requestVirtualDeviceState() {
|
|
151
|
+
return this.remoteVariableProtocol.requestVirtualDeviceState();
|
|
152
|
+
}
|
|
130
153
|
openVariables(variableNames, appId = '') {
|
|
131
154
|
return new Observable(observer => {
|
|
132
155
|
let variablesToStart = [];
|
|
@@ -229,6 +252,7 @@ export class RemoteVariableCommunicator {
|
|
|
229
252
|
this.connectedSubscription.unsubscribe();
|
|
230
253
|
this.variableStatesChangedSubscription.unsubscribe();
|
|
231
254
|
this.variableValuesChangedSubscription.unsubscribe();
|
|
255
|
+
this.virtualDeviceStatesChangedSubscription.unsubscribe();
|
|
232
256
|
this.alarmChangedSubscription.unsubscribe();
|
|
233
257
|
if (this.logger && this.logger.isDebugEnabled()) {
|
|
234
258
|
this.logger.debug('[VariableCommunicator] RemoteVariableCommunicator disposed.');
|
|
@@ -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":28,"character":57},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":28,"character":106}]}],"doAlarmChanged":[{"__symbolic":"method"}],"doVariableValuesChanged":[{"__symbolic":"method"}],"doVirtualDeviceStatesChanged":[{"__symbolic":"method"}],"doVariableStatesChanged":[{"__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"}],"dispose":[{"__symbolic":"method"}]}}}}]
|
|
@@ -9,6 +9,8 @@ export interface RemoteVariableProtocol {
|
|
|
9
9
|
tryStopVariables(variableNames: string[], appId: string): Observable<void>;
|
|
10
10
|
writeVariable(variableName: string, value: any): Observable<void>;
|
|
11
11
|
writeVariableWordByBit(variableName: string, index: number, value: number): Observable<void>;
|
|
12
|
+
requestVirtualDeviceState(): Observable<void>;
|
|
13
|
+
virtualDeviceStatesChanged: Observable<any>;
|
|
12
14
|
subscribeVariableStates(variableNames: string[]): Observable<void>;
|
|
13
15
|
unsubscribeVariableStates(variableNames: string[]): Observable<void>;
|
|
14
16
|
subscribeVirtualDeviceAlarms(appId: string): any;
|