@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.
@@ -21868,13 +21868,14 @@ var variable_communicator = __webpack_require__(262);
21868
21868
 
21869
21869
  // CONCATENATED MODULE: ./.tmp/communication/variable/variable-value.ts
21870
21870
  class VariableValue {
21871
- constructor(variableName, state, value, timeStamp, systemName, customStatus) {
21871
+ constructor(variableName, state, value, timeStamp, systemName, customStatus, virtualDeviceId) {
21872
21872
  this.variableName = variableName;
21873
21873
  this.state = state;
21874
21874
  this.value = value;
21875
21875
  this.timeStamp = timeStamp;
21876
21876
  this.systemName = systemName;
21877
21877
  this.customStatus = customStatus;
21878
+ this.virtualDeviceId = virtualDeviceId;
21878
21879
  }
21879
21880
  }
21880
21881
 
@@ -35318,14 +35319,14 @@ class readable_element_ReadableElement extends conditional_enable_element_Condit
35318
35319
  reportValueChanged(value) {
35319
35320
  var _a, _b, _c, _d;
35320
35321
  Object(lodash["forEach"])(this.elementStates, elementState => {
35321
- if (elementState.variableName === value.variableName || elementState.variableName === value.systemName) {
35322
+ if (elementState.variableName === value.variableName) {
35322
35323
  elementState.state = value.state;
35323
35324
  this.changeStates();
35324
35325
  }
35325
35326
  });
35326
- if (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable
35327
+ if (value.systemName !== '设备状态' && (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable
35327
35328
  || value.variableName === this.minVariableName
35328
- || value.variableName === this.maxVariableName) {
35329
+ || value.variableName === this.maxVariableName)) {
35329
35330
  this.updateVariableValue(value.value, value.variableName);
35330
35331
  }
35331
35332
  if (value.systemName === '设备状态') {
@@ -38894,7 +38895,6 @@ class text_element_TextElement extends conditional_dynamic_display_element_Condi
38894
38895
 
38895
38896
  // CONCATENATED MODULE: ./.tmp/elements/shared/text/text-state-element.ts
38896
38897
 
38897
-
38898
38898
  class text_state_element_TextStateElement {
38899
38899
  constructor(textStates, width, height, logger, version, faultFlickers) {
38900
38900
  this.textStates = textStates;
@@ -38918,7 +38918,7 @@ class text_state_element_TextStateElement {
38918
38918
  return;
38919
38919
  }
38920
38920
  const content = textState.text.content;
38921
- if (content === '') {
38921
+ if (content === '' || content == null) {
38922
38922
  this.removeForeignObjectlement();
38923
38923
  return;
38924
38924
  }
@@ -38928,72 +38928,51 @@ class text_state_element_TextStateElement {
38928
38928
  this.logger.debug('The font is undefined.');
38929
38929
  return;
38930
38930
  }
38931
- const foreignObjectElement = this.getforeignObjectElement();
38932
- foreignObjectElement.innerHTML = '';
38933
- const text = this.createNewForeignObjectText(content, font);
38934
- foreignObjectElement.appendChild(text);
38935
- this.doFaultFlicker(foreignObjectElement, stateId);
38931
+ const textElement = this.getforeignObjectElement();
38932
+ // 清空旧内容
38933
+ textElement.textContent = '';
38934
+ // 设置 text-anchor 和 dominant-baseline
38935
+ textElement.setAttribute('text-anchor', 'middle');
38936
+ textElement.setAttribute('dominant-baseline', 'middle');
38937
+ textElement.setAttribute('pointer-events', 'auto');
38938
+ // 拆分换行
38939
+ const lines = content.split('\n');
38940
+ const fontSize = parseInt(font.fontSize, 10);
38941
+ const lineHeight = fontSize + 4;
38942
+ // 总高度 = 行数 * 行高
38943
+ const totalHeight = lines.length * lineHeight;
38944
+ // 调整文本整体垂直居中(通过 dy)
38945
+ const startY = (this.height / 2) - (totalHeight / 2) + (lineHeight / 2);
38946
+ // 添加每行文本
38947
+ for (let i = 0; i < lines.length; i++) {
38948
+ const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');
38949
+ tspan.setAttribute('x', (this.width / 2).toString());
38950
+ tspan.setAttribute('y', startY + i * lineHeight + 'px');
38951
+ tspan.textContent = lines[i].replace(/ /g, '\u00A0');
38952
+ tspan.setAttribute('font-size', font.fontSize);
38953
+ tspan.setAttribute('fill', font.color);
38954
+ tspan.setAttribute('font-family', font.fontFamily);
38955
+ tspan.setAttribute('font-weight', font.isBold ? 'bold' : 'normal');
38956
+ tspan.setAttribute('font-style', font.isItalic ? 'italic' : 'normal');
38957
+ tspan.setAttribute('text-decoration', font.isUnderline ? 'underline' : 'none');
38958
+ tspan.setAttribute('text-anchor', 'middle');
38959
+ tspan.setAttribute('dominant-baseline', 'middle');
38960
+ textElement.appendChild(tspan);
38961
+ }
38962
+ this.doFaultFlicker(textElement, stateId);
38936
38963
  }
38937
38964
  getforeignObjectElement() {
38938
38965
  if (!this.textElement) {
38939
- this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
38940
- this.textElement.setAttribute('width', this.width.toString());
38941
- this.textElement.setAttribute('height', this.height.toString());
38966
+ this.textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
38967
+ this.textElement.setAttribute('x', (this.width / 2).toString());
38968
+ this.textElement.setAttribute('y', (this.height / 2).toString());
38969
+ this.textElement.setAttribute('text-anchor', 'middle');
38970
+ this.textElement.setAttribute('dominant-baseline', 'middle');
38971
+ this.textElement.setAttribute('pointer-events', 'auto'); // 确保能接收事件
38942
38972
  this._element.appendChild(this.textElement);
38943
38973
  }
38944
38974
  return this.textElement;
38945
38975
  }
38946
- createNewForeignObjectText(content, font) {
38947
- if (font && !font.fontFamily.includes(',msyh')) {
38948
- font.fontFamily += ',msyh';
38949
- }
38950
- const bodyDiv = document.createElement('div');
38951
- bodyDiv.style.textAlign = font.textAlign ? font.textAlign : 'center';
38952
- bodyDiv.style.userSelect = 'none';
38953
- bodyDiv.style.display = 'table-cell';
38954
- bodyDiv.style.verticalAlign = 'middle';
38955
- if (Object(lodash["isNil"])(content)) {
38956
- content = '';
38957
- }
38958
- let textArray = content.toString().split('\n');
38959
- textArray = textArray.map(item => {
38960
- return item.toString().replace(/\s/g, '&nbsp;');
38961
- });
38962
- const fragment = document.createDocumentFragment();
38963
- for (let index = 0; index < textArray.length; index++) {
38964
- const textDiv = document.createElement('div');
38965
- textDiv.innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
38966
- let fontString = '';
38967
- if (font.isItalic) {
38968
- fontString += 'italic ';
38969
- }
38970
- if (font.isBold) {
38971
- fontString += 'bold ';
38972
- }
38973
- textDiv.style.wordBreak = 'break-word';
38974
- textDiv.style.color = font.color;
38975
- let lineHeight = 0;
38976
- lineHeight = parseInt(font.fontSize, 10) + 5;
38977
- fontString += font.fontSize + 'px/' + lineHeight + 'px ' + font.fontFamily;
38978
- textDiv.style.font = fontString;
38979
- if (font.isUnderline) {
38980
- textDiv.style.textDecoration = 'underline';
38981
- }
38982
- fragment.appendChild(textDiv);
38983
- }
38984
- bodyDiv.appendChild(fragment);
38985
- const contentDiv = document.createElement('div');
38986
- contentDiv.style.display = 'table';
38987
- contentDiv.style.width = '100%';
38988
- contentDiv.style.height = '100%';
38989
- contentDiv.appendChild(bodyDiv);
38990
- const containerDiv = document.createElement('div');
38991
- containerDiv.style.overflow = 'hidden';
38992
- containerDiv.style.width = this.width.toString() + 'px';
38993
- containerDiv.style.height = this.height.toString() + 'px';
38994
- containerDiv.appendChild(contentDiv);
38995
- return containerDiv;
38996
- }
38997
38976
  removeForeignObjectlement() {
38998
38977
  if (this.textElement) {
38999
38978
  this._element.removeChild(this.textElement);
@@ -41612,15 +41591,39 @@ class main_element_MainElement {
41612
41591
  });
41613
41592
  });
41614
41593
  }
41594
+ getVirtualDeviceIdFromRect(rectElement) {
41595
+ let current = rectElement;
41596
+ while (current) {
41597
+ if (current.tagName === 'FC-GUI') {
41598
+ const virtualDeviceId = current.getAttribute('data-virtual-device-id');
41599
+ return virtualDeviceId || null;
41600
+ }
41601
+ current = current.parentElement;
41602
+ }
41603
+ return null;
41604
+ }
41615
41605
  reportVariableValues(values) {
41616
41606
  this.checkIsLoaded();
41617
41607
  Object(lodash["each"])(values, value => {
41618
41608
  Object(lodash["each"])(this.elements, e => {
41609
+ var _a;
41619
41610
  if (e instanceof readable_element_ReadableElement) {
41620
41611
  if ((value.variableName && (e.readVariableName === value.variableName ||
41621
- e.minVariableName === value.variableName || e.maxVariableName === value.variableName)) || e.readVariableName === value.systemName) {
41612
+ e.minVariableName === value.variableName || e.maxVariableName === value.variableName))) {
41622
41613
  e.reportValueChanged(value);
41623
41614
  }
41615
+ if (e.readVariableName === value.systemName) {
41616
+ const rect = (_a = e.currentRect) === null || _a === void 0 ? void 0 : _a[0];
41617
+ const deviceId = this.getVirtualDeviceIdFromRect(rect);
41618
+ if (deviceId) {
41619
+ if (+deviceId === value.virtualDeviceId) {
41620
+ e.reportValueChanged(value);
41621
+ }
41622
+ }
41623
+ else {
41624
+ e.reportValueChanged(value);
41625
+ }
41626
+ }
41624
41627
  }
41625
41628
  });
41626
41629
  });