@flexem/fc-gui 3.0.0-alpha.117 → 3.0.0-alpha.119

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.
@@ -6,5 +6,6 @@ export declare class VariableValue {
6
6
  readonly timeStamp?: string;
7
7
  systemName?: string;
8
8
  customStatus?: string;
9
- constructor(variableName: string, state: VariableStateEnum, value?: any, timeStamp?: string, systemName?: string, customStatus?: string);
9
+ virtualDeviceId?: number;
10
+ constructor(variableName: string, state: VariableStateEnum, value?: any, timeStamp?: string, systemName?: string, customStatus?: string, virtualDeviceId?: number);
10
11
  }
@@ -1,10 +1,11 @@
1
1
  export class VariableValue {
2
- constructor(variableName, state, value, timeStamp, systemName, customStatus) {
2
+ constructor(variableName, state, value, timeStamp, systemName, customStatus, virtualDeviceId) {
3
3
  this.variableName = variableName;
4
4
  this.state = state;
5
5
  this.value = value;
6
6
  this.timeStamp = timeStamp;
7
7
  this.systemName = systemName;
8
8
  this.customStatus = customStatus;
9
+ this.virtualDeviceId = virtualDeviceId;
9
10
  }
10
11
  }
@@ -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"},{"__symbolic":"reference","name":"string"},{"__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"},{"__symbolic":"reference","name":"number"}]}]}}}}]
@@ -74,14 +74,14 @@ export class ReadableElement extends ConditionalEnableElement {
74
74
  reportValueChanged(value) {
75
75
  var _a, _b, _c, _d;
76
76
  forEach(this.elementStates, elementState => {
77
- if (elementState.variableName === value.variableName || elementState.variableName === value.systemName) {
77
+ if (elementState.variableName === value.variableName) {
78
78
  elementState.state = value.state;
79
79
  this.changeStates();
80
80
  }
81
81
  });
82
- if (this.state === State.Normal || this.state === State.Disable
82
+ if (value.systemName !== '设备状态' && (this.state === State.Normal || this.state === State.Disable
83
83
  || value.variableName === this.minVariableName
84
- || value.variableName === this.maxVariableName) {
84
+ || value.variableName === this.maxVariableName)) {
85
85
  this.updateVariableValue(value.value, value.variableName);
86
86
  }
87
87
  if (value.systemName === '设备状态') {
@@ -1,3 +1,5 @@
1
+ /// <reference types="jquery" />
2
+ /// <reference types="jqueryui" />
1
3
  import { PermissionChecker } from '../../service';
2
4
  import { Localization } from '../../localization';
3
5
  import { VariableCommunicator, VariableState } from '../../communication';
@@ -9,7 +11,7 @@ export declare abstract class StateControlElement extends ConditionalDynamicDisp
9
11
  isEnable: boolean;
10
12
  elementStates: VariableState[];
11
13
  state: State;
12
- private currentRect;
14
+ currentRect: JQuery;
13
15
  preState: State;
14
16
  constructor(element: HTMLElement, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, localization: Localization, signalRAppId: string);
15
17
  initState(): void;
@@ -37,6 +37,7 @@ export declare class MainElement {
37
37
  initElementState(): void;
38
38
  getVariableNames(): Array<string>;
39
39
  reportVariableStates(states: VariableState[]): void;
40
+ getVirtualDeviceIdFromRect(rectElement: any): any;
40
41
  reportVariableValues(values: VariableValue[]): void;
41
42
  dispose(): void;
42
43
  private checkIsLoaded;
@@ -257,15 +257,39 @@ export class MainElement {
257
257
  });
258
258
  });
259
259
  }
260
+ getVirtualDeviceIdFromRect(rectElement) {
261
+ let current = rectElement;
262
+ while (current) {
263
+ if (current.tagName === 'FC-GUI') {
264
+ const virtualDeviceId = current.getAttribute('data-virtual-device-id');
265
+ return virtualDeviceId || null;
266
+ }
267
+ current = current.parentElement;
268
+ }
269
+ return null;
270
+ }
260
271
  reportVariableValues(values) {
261
272
  this.checkIsLoaded();
262
273
  each(values, value => {
263
274
  each(this.elements, e => {
275
+ var _a;
264
276
  if (e instanceof ReadableElement) {
265
277
  if ((value.variableName && (e.readVariableName === value.variableName ||
266
- e.minVariableName === value.variableName || e.maxVariableName === value.variableName)) || e.readVariableName === value.systemName) {
278
+ e.minVariableName === value.variableName || e.maxVariableName === value.variableName))) {
267
279
  e.reportValueChanged(value);
268
280
  }
281
+ if (e.readVariableName === value.systemName) {
282
+ const rect = (_a = e.currentRect) === null || _a === void 0 ? void 0 : _a[0];
283
+ const deviceId = this.getVirtualDeviceIdFromRect(rect);
284
+ if (deviceId) {
285
+ if (+deviceId === value.virtualDeviceId) {
286
+ e.reportValueChanged(value);
287
+ }
288
+ }
289
+ else {
290
+ e.reportValueChanged(value);
291
+ }
292
+ }
269
293
  }
270
294
  });
271
295
  });
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"MainElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":55,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":56,"character":41},{"__symbolic":"reference","module":"../gui/gui-context","name":"GuiContext","line":57,"character":34},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":58,"character":47},{"__symbolic":"reference","module":"../view/popup-view.service","name":"PopupViewService","line":59,"character":43},null]}],"load":[{"__symbolic":"method"}],"uniformStretch":[{"__symbolic":"method"}],"changeVideoStyle":[{"__symbolic":"method"}],"horizontalStretch":[{"__symbolic":"method"}],"initElementState":[{"__symbolic":"method"}],"getVariableNames":[{"__symbolic":"method"}],"reportVariableStates":[{"__symbolic":"method"}],"reportVariableValues":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"checkIsLoaded":[{"__symbolic":"method"}],"initBackground":[{"__symbolic":"method"}],"getImageEl":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"MainElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":55,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":56,"character":41},{"__symbolic":"reference","module":"../gui/gui-context","name":"GuiContext","line":57,"character":34},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":58,"character":47},{"__symbolic":"reference","module":"../view/popup-view.service","name":"PopupViewService","line":59,"character":43},null]}],"load":[{"__symbolic":"method"}],"uniformStretch":[{"__symbolic":"method"}],"changeVideoStyle":[{"__symbolic":"method"}],"horizontalStretch":[{"__symbolic":"method"}],"initElementState":[{"__symbolic":"method"}],"getVariableNames":[{"__symbolic":"method"}],"reportVariableStates":[{"__symbolic":"method"}],"getVirtualDeviceIdFromRect":[{"__symbolic":"method"}],"reportVariableValues":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"checkIsLoaded":[{"__symbolic":"method"}],"initBackground":[{"__symbolic":"method"}],"getImageEl":[{"__symbolic":"method"}]}}}}]
@@ -16,7 +16,6 @@ export declare class TextStateElement {
16
16
  constructor(textStates: TextState[], width: number, height: number, logger: LoggerService, version?: number, faultFlickers?: IndicatorLightFaultFlicker[]);
17
17
  switchToState(stateId: number): void;
18
18
  private getforeignObjectElement;
19
- private createNewForeignObjectText;
20
19
  private removeForeignObjectlement;
21
20
  private doFaultFlicker;
22
21
  private clearFlickerInterval;
@@ -1,5 +1,4 @@
1
1
  import { Flicker } from '../../../model';
2
- import { isNil } from 'lodash';
3
2
  export class TextStateElement {
4
3
  constructor(textStates, width, height, logger, version, faultFlickers) {
5
4
  this.textStates = textStates;
@@ -23,7 +22,7 @@ export class TextStateElement {
23
22
  return;
24
23
  }
25
24
  const content = textState.text.content;
26
- if (content === '') {
25
+ if (content === '' || content == null) {
27
26
  this.removeForeignObjectlement();
28
27
  return;
29
28
  }
@@ -33,72 +32,51 @@ export class TextStateElement {
33
32
  this.logger.debug('The font is undefined.');
34
33
  return;
35
34
  }
36
- const foreignObjectElement = this.getforeignObjectElement();
37
- foreignObjectElement.innerHTML = '';
38
- const text = this.createNewForeignObjectText(content, font);
39
- foreignObjectElement.appendChild(text);
40
- this.doFaultFlicker(foreignObjectElement, stateId);
35
+ const textElement = this.getforeignObjectElement();
36
+ // 清空旧内容
37
+ textElement.textContent = '';
38
+ // 设置 text-anchor 和 dominant-baseline
39
+ textElement.setAttribute('text-anchor', 'middle');
40
+ textElement.setAttribute('dominant-baseline', 'middle');
41
+ textElement.setAttribute('pointer-events', 'auto');
42
+ // 拆分换行
43
+ const lines = content.split('\n');
44
+ const fontSize = parseInt(font.fontSize, 10);
45
+ const lineHeight = fontSize + 4;
46
+ // 总高度 = 行数 * 行高
47
+ const totalHeight = lines.length * lineHeight;
48
+ // 调整文本整体垂直居中(通过 dy)
49
+ const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
50
+ // 添加每行文本
51
+ for (let i = 0; i < lines.length; i++) {
52
+ const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
53
+ tspan.setAttribute('x', (this.width / 2).toString());
54
+ tspan.setAttribute('y', startY + i * lineHeight + 'px');
55
+ tspan.textContent = lines[i].replace(/ /g, '\u00A0');
56
+ tspan.setAttribute('font-size', font.fontSize);
57
+ tspan.setAttribute('fill', font.color);
58
+ tspan.setAttribute('font-family', font.fontFamily);
59
+ tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
60
+ tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
61
+ tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
62
+ tspan.setAttribute('text-anchor', 'middle');
63
+ tspan.setAttribute('dominant-baseline', 'middle');
64
+ textElement.appendChild(tspan);
65
+ }
66
+ this.doFaultFlicker(textElement, stateId);
41
67
  }
42
68
  getforeignObjectElement() {
43
69
  if (!this.textElement) {
44
- this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
45
- this.textElement.setAttribute('width', this.width.toString());
46
- this.textElement.setAttribute('height', this.height.toString());
70
+ this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
71
+ this.textElement.setAttribute('x', (this.width / 2).toString());
72
+ this.textElement.setAttribute('y', (this.height / 2).toString());
73
+ this.textElement.setAttribute('text-anchor', 'middle');
74
+ this.textElement.setAttribute('dominant-baseline', 'middle');
75
+ this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
47
76
  this._element.appendChild(this.textElement);
48
77
  }
49
78
  return this.textElement;
50
79
  }
51
- createNewForeignObjectText(content, font) {
52
- if (font && !font.fontFamily.includes(',msyh')) {
53
- font.fontFamily += ',msyh';
54
- }
55
- const bodyDiv = document.createElement('div');
56
- bodyDiv.style.textAlign = font.textAlign ? font.textAlign : 'center';
57
- bodyDiv.style.userSelect = 'none';
58
- bodyDiv.style.display = 'table-cell';
59
- bodyDiv.style.verticalAlign = 'middle';
60
- if (isNil(content)) {
61
- content = '';
62
- }
63
- let textArray = content.toString().split('\n');
64
- textArray = textArray.map(item => {
65
- return item.toString().replace(/\s/g, '&nbsp;');
66
- });
67
- const fragment = document.createDocumentFragment();
68
- for (let index = 0; index < textArray.length; index++) {
69
- const textDiv = document.createElement('div');
70
- textDiv.innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
71
- let fontString = '';
72
- if (font.isItalic) {
73
- fontString += 'italic ';
74
- }
75
- if (font.isBold) {
76
- fontString += 'bold ';
77
- }
78
- textDiv.style.wordBreak = 'break-word';
79
- textDiv.style.color = font.color;
80
- let lineHeight = 0;
81
- lineHeight = parseInt(font.fontSize, 10) + 5;
82
- fontString += font.fontSize + 'px/' + lineHeight + 'px ' + font.fontFamily;
83
- textDiv.style.font = fontString;
84
- if (font.isUnderline) {
85
- textDiv.style.textDecoration = 'underline';
86
- }
87
- fragment.appendChild(textDiv);
88
- }
89
- bodyDiv.appendChild(fragment);
90
- const contentDiv = document.createElement('div');
91
- contentDiv.style.display = 'table';
92
- contentDiv.style.width = '100%';
93
- contentDiv.style.height = '100%';
94
- contentDiv.appendChild(bodyDiv);
95
- const containerDiv = document.createElement('div');
96
- containerDiv.style.overflow = 'hidden';
97
- containerDiv.style.width = this.width.toString() + 'px';
98
- containerDiv.style.height = this.height.toString() + 'px';
99
- containerDiv.appendChild(contentDiv);
100
- return containerDiv;
101
- }
102
80
  removeForeignObjectlement() {
103
81
  if (this.textElement) {
104
82
  this._element.removeChild(this.textElement);
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"TextStateElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"./text-state.model","name":"TextState","line":18,"character":45}]},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":21,"character":33},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../../model/switch-indicator-light/indicator-light-fault-flicker","name":"IndicatorLightFaultFlicker","line":23,"character":41}]}]}],"switchToState":[{"__symbolic":"method"}],"getforeignObjectElement":[{"__symbolic":"method"}],"createNewForeignObjectText":[{"__symbolic":"method"}],"removeForeignObjectlement":[{"__symbolic":"method"}],"doFaultFlicker":[{"__symbolic":"method"}],"clearFlickerInterval":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"TextStateElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"./text-state.model","name":"TextState","line":17,"character":45}]},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","module":"../../../logger","name":"LoggerService","line":20,"character":33},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"../../../model/switch-indicator-light/indicator-light-fault-flicker","name":"IndicatorLightFaultFlicker","line":22,"character":41}]}]}],"switchToState":[{"__symbolic":"method"}],"getforeignObjectElement":[{"__symbolic":"method"}],"removeForeignObjectlement":[{"__symbolic":"method"}],"doFaultFlicker":[{"__symbolic":"method"}],"clearFlickerInterval":[{"__symbolic":"method"}]}}}}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.117",
3
+ "version": "3.0.0-alpha.119",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",