@flexem/fc-gui 3.0.0-alpha.9 → 3.0.0-alpha.90

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.
Files changed (123) hide show
  1. package/CHANGELOG.md +381 -0
  2. package/bundles/@flexem/fc-gui.umd.js +17578 -16210
  3. package/bundles/@flexem/fc-gui.umd.js.map +1 -1
  4. package/bundles/@flexem/fc-gui.umd.min.js +5 -5
  5. package/bundles/@flexem/fc-gui.umd.min.js.map +1 -1
  6. package/communication/variable/variable-communicator.d.ts +1 -0
  7. package/config/alarm/alarm.store.d.ts +6 -0
  8. package/config/alarm/alarm.store.js +0 -0
  9. package/config/alarm/alarm.store.metadata.json +1 -0
  10. package/config/alarm/get-alarms-args.d.ts +9 -0
  11. package/config/alarm/get-alarms-args.js +9 -0
  12. package/config/alarm/get-alarms-args.metadata.json +1 -0
  13. package/config/alarm/index.d.ts +2 -0
  14. package/config/alarm/index.js +1 -0
  15. package/config/alarm/index.metadata.json +1 -0
  16. package/config/config-store.d.ts +2 -0
  17. package/config/index.d.ts +1 -0
  18. package/config/index.js +1 -0
  19. package/config/index.metadata.json +1 -1
  20. package/elements/air-quality/air-quality-element.d.ts +31 -0
  21. package/elements/air-quality/air-quality-element.js +194 -0
  22. package/elements/air-quality/air-quality-element.metadata.json +1 -0
  23. package/elements/alarm/alarm-element.d.ts +44 -0
  24. package/elements/alarm/alarm-element.js +382 -0
  25. package/elements/alarm/alarm-element.metadata.json +1 -0
  26. package/elements/bar-graph-element.d.ts +7 -1
  27. package/elements/bar-graph-element.js +70 -4
  28. package/elements/bar-graph-element.metadata.json +1 -1
  29. package/elements/base/readable-element.d.ts +6 -1
  30. package/elements/base/readable-element.js +31 -2
  31. package/elements/base/readable-element.metadata.json +1 -1
  32. package/elements/historical-curve/historical-curve.element.js +116 -13
  33. package/elements/historical-curve/historical-curve.element.metadata.json +1 -1
  34. package/elements/main-element.js +25 -4
  35. package/elements/main-element.metadata.json +1 -1
  36. package/elements/meter-element.d.ts +7 -1
  37. package/elements/meter-element.js +76 -7
  38. package/elements/meter-element.metadata.json +1 -1
  39. package/elements/numerical-display/numerical-display-element.d.ts +8 -2
  40. package/elements/numerical-display/numerical-display-element.js +55 -11
  41. package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
  42. package/elements/per-view-variable-communicator.d.ts +2 -0
  43. package/elements/per-view-variable-communicator.js +8 -0
  44. package/elements/per-view-variable-communicator.metadata.json +1 -1
  45. package/elements/ring-graph/ring-graph-element.d.ts +10 -1
  46. package/elements/ring-graph/ring-graph-element.js +106 -3
  47. package/elements/ring-graph/ring-graph-element.metadata.json +1 -1
  48. package/elements/shared/graph/graph-state-element.js +0 -3
  49. package/elements/shared/text/text-element.js +13 -2
  50. package/elements/shared/text/text-state-element.js +1 -1
  51. package/elements/switch-indicator-light/bit-switch-operator.d.ts +1 -0
  52. package/elements/switch-indicator-light/bit-switch-operator.js +19 -0
  53. package/elements/switch-indicator-light/bit-switch-operator.metadata.json +1 -1
  54. package/elements/switch-indicator-light/switch-indicator-light-element.d.ts +8 -0
  55. package/elements/switch-indicator-light/switch-indicator-light-element.js +93 -23
  56. package/elements/switch-indicator-light/switch-indicator-light-element.metadata.json +1 -1
  57. package/elements/switch-indicator-light/switch-operator.d.ts +1 -0
  58. package/elements/switch-indicator-light/word-switch-operator.d.ts +1 -0
  59. package/elements/switch-indicator-light/word-switch-operator.js +6 -0
  60. package/elements/switch-indicator-light/word-switch-operator.metadata.json +1 -1
  61. package/elements/video/video-element.d.ts +4 -0
  62. package/elements/video/video-element.js +69 -20
  63. package/elements/video/video-element.metadata.json +1 -1
  64. package/elements/view-operation/view-operation.element.js +8 -0
  65. package/elements/weather/weater-element.js +0 -1
  66. package/gui/gui-context.d.ts +2 -1
  67. package/gui/gui-host.d.ts +1 -1
  68. package/gui/gui.component.d.ts +3 -0
  69. package/gui/gui.component.js +15 -2
  70. package/gui/gui.component.metadata.json +1 -1
  71. package/localization/localization.service.d.ts +7 -0
  72. package/localization/localization.service.js +8 -1
  73. package/localization/localization.service.metadata.json +1 -1
  74. package/localization/localization.service.zh_CN.js +8 -1
  75. package/localization/localization.service.zh_CN.metadata.json +1 -1
  76. package/modal/write-value/write-value-modal-args.d.ts +4 -1
  77. package/modal/write-value/write-value-modal-args.js +3 -1
  78. package/modal/write-value/write-value-modal-args.metadata.json +1 -1
  79. package/modal/write-value/write-value-modal.component.d.ts +9 -7
  80. package/modal/write-value/write-value-modal.component.html +9 -4
  81. package/modal/write-value/write-value-modal.component.js +39 -22
  82. package/modal/write-value/write-value-modal.component.metadata.json +1 -1
  83. package/model/air-quality/air-quality-info.d.ts +23 -0
  84. package/model/air-quality/air-quality-info.js +4 -0
  85. package/model/air-quality/air-quality-info.metadata.json +1 -0
  86. package/model/air-quality/air-quality.model.d.ts +7 -0
  87. package/model/air-quality/air-quality.model.js +0 -0
  88. package/model/air-quality/air-quality.model.metadata.json +1 -0
  89. package/model/alarm/alarm.model.d.ts +13 -0
  90. package/model/alarm/alarm.model.js +0 -0
  91. package/model/alarm/alarm.model.metadata.json +1 -0
  92. package/model/bar-graph/bar-graph.d.ts +4 -0
  93. package/model/base/readable-model.d.ts +4 -0
  94. package/model/historical-curve/historical-curve-axis-settings.d.ts +10 -0
  95. package/model/historical-curve/historical-curve-axis-settings.js +5 -0
  96. package/model/historical-curve/historical-curve-axis-settings.metadata.json +1 -1
  97. package/model/meter/meter.d.ts +4 -0
  98. package/model/numerical-display/numerical-display.d.ts +1 -0
  99. package/model/ring-graph/ring-graph.model.d.ts +8 -0
  100. package/model/switch-indicator-light/bit-switch-operation.d.ts +2 -1
  101. package/model/switch-indicator-light/bit-switch-operation.js +1 -0
  102. package/model/switch-indicator-light/bit-switch-operation.metadata.json +1 -1
  103. package/package.json +1 -1
  104. package/remote/communication/variable/remote-variable-communicator.d.ts +4 -0
  105. package/remote/communication/variable/remote-variable-communicator.js +23 -1
  106. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  107. package/remote/communication/variable/remote-variable-protocol.d.ts +3 -0
  108. package/service/index.d.ts +1 -0
  109. package/service/index.metadata.json +1 -1
  110. package/service/released-variable/index.d.ts +1 -0
  111. package/service/released-variable/index.js +0 -0
  112. package/service/released-variable/index.metadata.json +1 -0
  113. package/service/released-variable/released-variable.service.d.ts +4 -0
  114. package/service/released-variable/released-variable.service.js +0 -0
  115. package/service/released-variable/released-variable.service.metadata.json +1 -0
  116. package/service/weather.service.d.ts +1 -0
  117. package/shared/gui-consts.d.ts +2 -0
  118. package/shared/gui-consts.js +2 -0
  119. package/shared/gui-consts.metadata.json +1 -1
  120. package/utils/data-type/data-type.service.d.ts +4 -7
  121. package/utils/data-type/data-type.service.js +29 -17
  122. package/utils/data-type/fbox-data-type.service.js +40 -0
  123. package/utils/numerical-operation.service.js +2 -2
@@ -6,6 +6,7 @@ export class PerViewVariableCommunicator {
6
6
  this.observers = new Map();
7
7
  this.variableValuesChangedSubscriptions = new Array();
8
8
  this.variableStatesChangedSubscription = new Array();
9
+ this.alarmSubscription = new Array();
9
10
  this._rawVariableCommunicator = variableCommunicator;
10
11
  }
11
12
  openVariable(variableName, appId) {
@@ -38,8 +39,15 @@ export class PerViewVariableCommunicator {
38
39
  this.variableStatesChangedSubscription.push(subscription);
39
40
  });
40
41
  }
42
+ subscribeUserDeviceAlarms(appId = '') {
43
+ return new Observable(subscriber => {
44
+ const subscription = this._rawVariableCommunicator.subscribeUserDeviceAlarms(appId).subscribe(values => subscriber.next(values), error => subscriber.error(error), () => subscriber.complete());
45
+ this.alarmSubscription.push(subscription);
46
+ });
47
+ }
41
48
  dispose() {
42
49
  forEach(this.variableValuesChangedSubscriptions, s => s.unsubscribe());
43
50
  forEach(this.variableStatesChangedSubscription, s => s.unsubscribe());
51
+ forEach(this.alarmSubscription, s => s.unsubscribe());
44
52
  }
45
53
  }
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"PerViewVariableCommunicator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":14,"character":38}]}],"openVariable":[{"__symbolic":"method"}],"openVariables":[{"__symbolic":"method"}],"write":[{"__symbolic":"method"}],"writeWordByBit":[{"__symbolic":"method"}],"subscribeVariableState":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__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"}],"subscribeVariableState":[{"__symbolic":"method"}],"subscribeVariableStates":[{"__symbolic":"method"}],"subscribeUserDeviceAlarms":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}]}}}}]
@@ -5,13 +5,22 @@ import { ReadableElement } from '../base/readable-element';
5
5
  import { VariableStore } from '../../config';
6
6
  import { PermissionChecker } from '../../service';
7
7
  export declare class RingGraphElement extends ReadableElement {
8
+ private static DEFAULT_MIN_VALUE;
9
+ private static DEFAULT_MAX_VALUE;
8
10
  protected readonly model: RingGraphModel;
9
11
  private _barElement$;
10
12
  private _textElement$;
13
+ private valueObj;
14
+ private isNeedUpdateScale;
11
15
  get readVariableName(): string;
16
+ get minVariableName(): string;
17
+ get maxVariableName(): string;
12
18
  constructor(element: HTMLElement, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, localization: Localization, signalRAppId: string);
13
19
  private initFrameNode;
14
- protected updateVariableValue(value: number): void;
20
+ init(variableName: string): void;
21
+ private updateValueObj;
22
+ private updateScale;
23
+ protected updateVariableValue(value: number, variableName: any): void;
15
24
  private updateBar;
16
25
  private getBarColor;
17
26
  private drawClockWiseArc;
@@ -4,31 +4,132 @@ import { RotationDirectionType } from '../../model/shared/rotation/rotation-dire
4
4
  import { calculatePercent, degreesToRadians } from '../shared/math-utils';
5
5
  import { VariableUtil } from '../../utils/variable-util';
6
6
  import { VariableDefinition } from '../../communication/variable/variable-definition';
7
+ import { forEach } from 'lodash';
8
+ import { VariableState } from '../../communication';
9
+ import { VariableValueType } from '../../model/shared/condition/variable-value-type';
7
10
  export class RingGraphElement extends ReadableElement {
8
11
  constructor(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId) {
9
12
  super(element, permissionChecker, variableCommunicator, variableStore, localization, signalRAppId);
13
+ this.valueObj = {};
14
+ this.isNeedUpdateScale = false;
15
+ if ((this.model.minValueType === VariableValueType.Constant && this.model.maxValueType === VariableValueType.Variable)
16
+ || this.model.maxValueType === VariableValueType.Constant && this.model.minValueType === VariableValueType.Variable) {
17
+ this.isNeedUpdateScale = true;
18
+ this.updateScale();
19
+ this.isNeedUpdateScale = false;
20
+ }
10
21
  const el$ = $(element);
11
22
  this._barElement$ = el$.find('path[data-id="barArc"]');
12
23
  this._textElement$ = el$.find('text[data-id="pText"]');
13
24
  setTimeout(() => {
14
25
  this.initFrameNode();
15
26
  this.changeStates();
16
- }, 0);
27
+ });
17
28
  }
18
29
  get readVariableName() {
19
30
  if (!this.model.variableId) {
20
31
  return '';
21
32
  }
33
+ if (!this.model.variableId.variableName || !this.model.variableId.variableName.name) {
34
+ return undefined;
35
+ }
22
36
  const variable = new VariableDefinition(this.model.variableId.variableName.name, this.model.variableId.variableName.groupName, this.model.variableId.dataSourceCode, this.model.variableId.variableName.variableVersion);
23
37
  return VariableUtil.getConvertedVariableName(this.variableStore, variable);
24
38
  }
39
+ get minVariableName() {
40
+ if (!this.model.minValueType) {
41
+ return undefined;
42
+ }
43
+ if (!this.model.minVariable || !this.model.minVariable.name) {
44
+ return undefined;
45
+ }
46
+ const variable = new VariableDefinition(this.model.minVariable.name, this.model.minVariable.groupName, this.model.minVariable.dataSourceCode, this.model.minVariable.variableVersion);
47
+ return VariableUtil.getConvertedVariableName(this.variableStore, variable);
48
+ }
49
+ get maxVariableName() {
50
+ if (!this.model.maxValueType) {
51
+ return undefined;
52
+ }
53
+ if (!this.model.maxVariable || !this.model.maxVariable.name) {
54
+ return undefined;
55
+ }
56
+ const variable = new VariableDefinition(this.model.maxVariable.name, this.model.maxVariable.groupName, this.model.maxVariable.dataSourceCode, this.model.maxVariable.variableVersion);
57
+ return VariableUtil.getConvertedVariableName(this.variableStore, variable);
58
+ }
25
59
  initFrameNode() {
26
60
  const arcPath = Snap(this.$element[0]);
27
61
  const b = arcPath.getBBox(true);
28
62
  this.rootElement.append('rect').attr('id', 'StateFrame').attr('width', b.width).attr('height', b.height).attr('fill', 'transparent');
29
63
  }
30
- updateVariableValue(value) {
31
- const percent = calculatePercent(this.model.min, this.model.max, value);
64
+ init(variableName) {
65
+ if (variableName) {
66
+ let hasVariable = false;
67
+ forEach(this.elementStates, elementState => {
68
+ if (elementState.variableName === variableName) {
69
+ hasVariable = true;
70
+ }
71
+ });
72
+ if (!hasVariable && variableName === this.readVariableName) {
73
+ this.elementStates.push(new VariableState(variableName, undefined));
74
+ }
75
+ }
76
+ }
77
+ updateValueObj(value, variableName) {
78
+ var _a, _b, _c;
79
+ if (((_a = this.model.variableId) === null || _a === void 0 ? void 0 : _a.variableName.name) === variableName) {
80
+ this.isNeedUpdateScale = false;
81
+ this.valueObj.value = value;
82
+ }
83
+ if (((_b = this.model.minVariable) === null || _b === void 0 ? void 0 : _b.name) === variableName) {
84
+ this.isNeedUpdateScale = true;
85
+ this.valueObj.min = value;
86
+ }
87
+ if (((_c = this.model.maxVariable) === null || _c === void 0 ? void 0 : _c.name) === variableName) {
88
+ this.isNeedUpdateScale = true;
89
+ this.valueObj.max = value;
90
+ }
91
+ }
92
+ updateScale() {
93
+ if (!this.isNeedUpdateScale) {
94
+ return;
95
+ }
96
+ const textElements = this.$element.find('g:first > text');
97
+ let min = this.model.minValueType ? this.valueObj.min : this.model.min;
98
+ let max = this.model.maxValueType ? this.valueObj.max : this.model.max;
99
+ min = Number(min);
100
+ max = Number(max);
101
+ if (isNaN(min) || isNaN(max)) {
102
+ min = RingGraphElement.DEFAULT_MIN_VALUE;
103
+ max = RingGraphElement.DEFAULT_MAX_VALUE;
104
+ }
105
+ const avgSacle = ((max - min) / this.model.masterDivisionNumber).toFixed(5);
106
+ for (let i = 0; i < textElements.length; i++) {
107
+ const text = textElements[i];
108
+ if (!text.innerHTML) {
109
+ continue;
110
+ }
111
+ let sacleValue = ((Number(avgSacle) * i) + min).toFixed(0);
112
+ // 整数位和小数位格式化;
113
+ if (this.model.fractionDigits > 0) {
114
+ sacleValue = (sacleValue / Math.pow(10, this.model.fractionDigits)).toFixed(this.model.fractionDigits);
115
+ }
116
+ if (!isNaN(sacleValue)) {
117
+ text.innerHTML = sacleValue;
118
+ }
119
+ }
120
+ }
121
+ updateVariableValue(value, variableName) {
122
+ this.updateValueObj(value, variableName);
123
+ this.updateScale();
124
+ let min = this.model.minValueType ? this.valueObj.min : this.model.min;
125
+ let max = this.model.maxValueType ? this.valueObj.max : this.model.max;
126
+ min = Number(min);
127
+ max = Number(max);
128
+ if (isNaN(min) || isNaN(max)) {
129
+ min = RingGraphElement.DEFAULT_MIN_VALUE;
130
+ max = RingGraphElement.DEFAULT_MAX_VALUE;
131
+ }
132
+ const percent = calculatePercent(min, max, this.valueObj.value || 0);
32
133
  this.updateBar(percent);
33
134
  this._barElement$.attr('fill', this.getBarColor(value));
34
135
  if (this.model.showPercentage) {
@@ -87,3 +188,5 @@ export class RingGraphElement extends ReadableElement {
87
188
  arcPath.arc(outer, outer, inner, endRadians, startRadians);
88
189
  }
89
190
  }
191
+ RingGraphElement.DEFAULT_MIN_VALUE = 0;
192
+ RingGraphElement.DEFAULT_MAX_VALUE = 100;
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"RingGraphElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":13,"character":38},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":27,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":27,"character":57},{"__symbolic":"reference","module":"../../communication/variable/variable-communicator","name":"VariableCommunicator","line":28,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":29,"character":23},{"__symbolic":"reference","module":"../../localization/localization.service","name":"Localization","line":30,"character":22},{"__symbolic":"reference","name":"string"}]}],"initFrameNode":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"updateBar":[{"__symbolic":"method"}],"getBarColor":[{"__symbolic":"method"}],"drawClockWiseArc":[{"__symbolic":"method"}],"drawAntiClockWiseArc":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"RingGraphElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":16,"character":38},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":60,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":60,"character":57},{"__symbolic":"reference","module":"../../communication/variable/variable-communicator","name":"VariableCommunicator","line":61,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":62,"character":23},{"__symbolic":"reference","module":"../../localization/localization.service","name":"Localization","line":63,"character":22},{"__symbolic":"reference","name":"string"}]}],"initFrameNode":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"updateValueObj":[{"__symbolic":"method"}],"updateScale":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"updateBar":[{"__symbolic":"method"}],"getBarColor":[{"__symbolic":"method"}],"drawClockWiseArc":[{"__symbolic":"method"}],"drawAntiClockWiseArc":[{"__symbolic":"method"}]},"statics":{"DEFAULT_MIN_VALUE":0,"DEFAULT_MAX_VALUE":100}}}}]
@@ -62,9 +62,6 @@ export class GraphStateElement {
62
62
  }
63
63
  }
64
64
  getImageElement() {
65
- if (this.imageElement && /iPhone|iPod/i.test(navigator.userAgent)) {
66
- this.removeImageElement();
67
- }
68
65
  if (!this.imageElement) {
69
66
  this.imageElement = document.createElementNS('http://www.w3.org/2000/svg', 'image');
70
67
  this.imageElement.setAttribute('width', this.width + '');
@@ -19,7 +19,7 @@ export class TextElementModal {
19
19
  return textElement;
20
20
  }
21
21
  createNewForeignObjectText(content, font, width, height, isVariableText) {
22
- if (font) {
22
+ if (font && !font.fontFamily.includes(',msyh')) {
23
23
  font.fontFamily += ',msyh';
24
24
  }
25
25
  const bodyDiv = document.createElement('div');
@@ -36,7 +36,7 @@ export class TextElementModal {
36
36
  for (let index = 0; index < textArray.length; index++) {
37
37
  const textDiv = document.createElement('div');
38
38
  textDiv.className = 'text-list';
39
- textDiv.innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
39
+ const innerHTML = textArray[index] ? textArray[index] : '&nbsp;';
40
40
  let fontString = '';
41
41
  if (font.isItalic) {
42
42
  fontString += 'italic ';
@@ -45,12 +45,23 @@ export class TextElementModal {
45
45
  fontString += 'bold ';
46
46
  }
47
47
  let lineHeight = 0;
48
+ // chrome支持可显示最小字体大小为12px, 更小字体通过缩放实现
49
+ const minFontSize = 12;
48
50
  lineHeight = parseInt(font.fontSize, 10) + 5;
49
51
  fontString += font.fontSize + '/' + lineHeight.toString() + 'px ' + font.fontFamily;
50
52
  textDiv.style.cssText = `color: ${font.color};word-break: break-all;font: ${fontString};`;
51
53
  if (font.isUnderline) {
52
54
  textDiv.style.textDecoration = 'underline';
53
55
  }
56
+ const spanText = document.createElement('span');
57
+ spanText.style.cssText = `
58
+ display: contents;
59
+ transform: scale(${parseInt(font.fontSize, 10) > minFontSize ? 1 : parseInt(font.fontSize, 10) / minFontSize});
60
+ width: 100%;
61
+ height: 100%;
62
+ `;
63
+ spanText.innerHTML = innerHTML;
64
+ textDiv.appendChild(spanText);
54
65
  fragment.appendChild(textDiv);
55
66
  }
56
67
  bodyDiv.appendChild(fragment);
@@ -49,7 +49,7 @@ export class TextStateElement {
49
49
  return this.textElement;
50
50
  }
51
51
  createNewForeignObjectText(content, font) {
52
- if (font) {
52
+ if (font && !font.fontFamily.includes(',msyh')) {
53
53
  font.fontFamily += ',msyh';
54
54
  }
55
55
  const bodyDiv = document.createElement('div');
@@ -15,4 +15,5 @@ export declare class BitSwitchOperator implements SwitchOperator {
15
15
  constructor(settings: BitSwitchSettings, variableCommunicator: VariableCommunicator, variableStore: VariableStore, signalRAppId: string);
16
16
  canExecute(): boolean;
17
17
  execute(): Promise<VariableOptionModel>;
18
+ writeValue(value: any): Promise<VariableOptionModel>;
18
19
  }
@@ -72,6 +72,8 @@ export class BitSwitchOperator {
72
72
  }
73
73
  }
74
74
  break;
75
+ case BitSwitchOperation.Restoration:
76
+ break;
75
77
  default:
76
78
  throw new Error(`Unknown BitSwitchOperation:${settings.operation}`);
77
79
  }
@@ -85,4 +87,21 @@ export class BitSwitchOperator {
85
87
  newValue: newValue
86
88
  });
87
89
  }
90
+ writeValue(value) {
91
+ if (this.settings.isBitwiseIndex) {
92
+ this.variableCommunicator.writeWordByBit(this.variableName, this.settings.bitIndex, value).subscribe();
93
+ }
94
+ else {
95
+ this.variableCommunicator.write(this.variableName, value).subscribe();
96
+ }
97
+ let originValue;
98
+ if (this.currentValue && this.currentValue.value !== undefined) {
99
+ originValue = this.currentValue.value;
100
+ }
101
+ return Promise.resolve({
102
+ variableName: this.variableName,
103
+ originValue: originValue,
104
+ newValue: value
105
+ });
106
+ }
88
107
  }
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"BitSwitchOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"BitSwitchSettings","line":21,"character":43},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":21,"character":101},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":22,"character":40},{"__symbolic":"reference","name":"string"}]}],"canExecute":[{"__symbolic":"method"}],"execute":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"BitSwitchOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"BitSwitchSettings","line":21,"character":43},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":21,"character":101},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":22,"character":40},{"__symbolic":"reference","name":"string"}]}],"canExecute":[{"__symbolic":"method"}],"execute":[{"__symbolic":"method"}],"writeValue":[{"__symbolic":"method"}]}}}}]
@@ -19,9 +19,17 @@ export declare class SwitchIndicatorLightElement extends ConditionalEnableElemen
19
19
  private graphStateElement?;
20
20
  private textStateElement;
21
21
  private isMobileMode;
22
+ private isBitRestoration;
23
+ private isVerifiedForRestoration;
24
+ private restorationTimer;
25
+ private isWriteRestorationDownValue;
26
+ private onDocMouseUp;
22
27
  constructor(element: HTMLElement, injector: Injector, modalService: BsModalService, variableCommunicator: VariableCommunicator, graphStore: GraphStore, permissionChecker: PermissionChecker, operationRecordService: OperationRecordService, securityChecker: SecurityChecker, variableStore: VariableStore, localization: Localization, signalRAppId: string);
28
+ handleMouseUp(): void;
29
+ private initOnDocMouseUpEvent;
23
30
  private checkElementPassword;
24
31
  private doSwitchOperator;
32
+ private writeValue;
25
33
  private initSwitchOperator;
26
34
  private initIndictorLightOperator;
27
35
  private currentStateIdChange;
@@ -1,7 +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 { IndicatorLightType, SwitchType, State } from '../../model';
4
+ import { IndicatorLightType, SwitchType, State, BitSwitchOperation } from '../../model';
5
5
  import { VariableState } from '../../communication';
6
6
  import { ConditionalEnableElement } from '../base/conditional-enable-element';
7
7
  import { GraphStateElement } from '../shared/graph/graph-state-element';
@@ -23,13 +23,17 @@ export class SwitchIndicatorLightElement extends ConditionalEnableElement {
23
23
  this.graphStore = graphStore;
24
24
  this.operationRecordService = operationRecordService;
25
25
  this.securityChecker = securityChecker;
26
+ this.isBitRestoration = false; // 是否是 位设定且执行设置是复位
27
+ this.isVerifiedForRestoration = false; // 位设定且执行设置是复位情况下,是否已经完成了验证
28
+ this.isWriteRestorationDownValue = false;
26
29
  this.logger = injector.get(LOGGER_SERVICE_TOKEN);
27
30
  this.isMobileMode = DisplayMode.Mobile === injector.get(GlobalSettings).displayMode;
28
31
  this.checkState();
29
32
  if (this.model.useSwitch) {
30
33
  this.initSwitchOperator();
31
34
  this.rootElement.style('cursor', 'hand');
32
- this.rootElement.on('mousedown', () => {
35
+ const isMobile = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
36
+ this.rootElement.on(this.isMobileMode && isMobile ? 'touchstart' : 'mousedown', () => {
33
37
  if (!this.isInitialized) {
34
38
  return;
35
39
  }
@@ -43,31 +47,39 @@ export class SwitchIndicatorLightElement extends ConditionalEnableElement {
43
47
  return;
44
48
  }
45
49
  if (this.switchOperator.canExecute()) {
46
- if (this.model.useSecurity) {
47
- const modalRef = this.modalService.show(ConfirmOperationModalComponent, { backdrop: 'static', class: 'gui-modal-dialog-position', animated: false });
48
- const onClosedSub = modalRef.content.onClosed.subscribe(result => {
49
- modalRef.hide();
50
- onClosedSub.unsubscribe();
51
- if (result) {
52
- this.checkElementPassword();
50
+ if (!this.isBitRestoration || !this.isVerifiedForRestoration) {
51
+ if (this.model.useSecurity) {
52
+ const modalRef = this.modalService.show(ConfirmOperationModalComponent, { backdrop: 'static', class: 'gui-modal-dialog-position', animated: false });
53
+ const onClosedSub = modalRef.content.onClosed.subscribe(result => {
54
+ modalRef.hide();
55
+ onClosedSub.unsubscribe();
56
+ if (result) {
57
+ this.checkElementPassword(true);
58
+ }
59
+ });
60
+ }
61
+ else {
62
+ this.checkElementPassword(false);
63
+ if (!this.model.useIndicatorLight && !this.isMobileMode) {
64
+ this.switchToState(1);
53
65
  }
54
- });
66
+ }
55
67
  }
56
68
  else {
57
- this.checkElementPassword();
58
- if (!this.model.useIndicatorLight && !this.isMobileMode) {
59
- this.switchToState(1);
60
- }
69
+ document.addEventListener(this.isMobileMode ? 'touchend' : 'mouseup', this.onDocMouseUp);
70
+ this.restorationTimer = setTimeout(() => {
71
+ this.writeValue(1);
72
+ this.isWriteRestorationDownValue = true;
73
+ }, 1000);
61
74
  }
62
75
  d3.event.preventDefault();
63
76
  }
64
77
  });
65
- if (!this.model.useIndicatorLight && !this.isMobileMode) {
66
- this.rootElement.on('mouseup', () => {
67
- this.switchToState(0);
68
- d3.event.preventDefault();
69
- });
70
- }
78
+ this.rootElement.on(this.isMobileMode && isMobile ? 'touchend' : 'mouseup', () => {
79
+ this.handleMouseUp();
80
+ d3.event.stopPropagation();
81
+ });
82
+ this.initOnDocMouseUpEvent();
71
83
  }
72
84
  this.initGraphAndText();
73
85
  if (this.model.useIndicatorLight) {
@@ -77,19 +89,62 @@ export class SwitchIndicatorLightElement extends ConditionalEnableElement {
77
89
  this.switchToState(0);
78
90
  }
79
91
  }
80
- checkElementPassword() {
92
+ handleMouseUp() {
93
+ if (this.restorationTimer) {
94
+ clearTimeout(this.restorationTimer);
95
+ this.restorationTimer = undefined;
96
+ }
97
+ if (this.isBitRestoration && this.isWriteRestorationDownValue) {
98
+ this.writeValue(0);
99
+ }
100
+ document.removeEventListener(this.isMobileMode ? 'touchend' : 'mouseup', this.onDocMouseUp);
101
+ this.isVerifiedForRestoration = false;
102
+ this.isWriteRestorationDownValue = false;
103
+ if (!this.model.useIndicatorLight && !this.isMobileMode) {
104
+ this.switchToState(0);
105
+ if (d3.event) {
106
+ d3.event.preventDefault();
107
+ }
108
+ }
109
+ }
110
+ initOnDocMouseUpEvent() {
111
+ this.onDocMouseUp = () => {
112
+ this.handleMouseUp();
113
+ };
114
+ }
115
+ checkElementPassword(afterConfirm) {
81
116
  if (this.model.enablePassword) {
82
117
  const modalRef = this.modalService.show(VerifyPasswordModalComponent, { initialState: { securityChecker: this.securityChecker }, backdrop: 'static', class: 'gui-modal-dialog-position', animated: false });
83
118
  const onClosedSub = modalRef.content.onClosed.subscribe(result => {
84
119
  modalRef.hide();
85
120
  onClosedSub.unsubscribe();
86
121
  if (result) {
87
- this.doSwitchOperator();
122
+ if (!this.isBitRestoration) {
123
+ this.doSwitchOperator();
124
+ }
125
+ else {
126
+ this.isVerifiedForRestoration = true;
127
+ }
88
128
  }
89
129
  });
90
130
  }
91
131
  else {
92
- this.doSwitchOperator();
132
+ if (!this.isBitRestoration) {
133
+ this.doSwitchOperator();
134
+ }
135
+ else {
136
+ if (afterConfirm) {
137
+ this.isVerifiedForRestoration = true;
138
+ }
139
+ else {
140
+ this.isVerifiedForRestoration = true;
141
+ document.addEventListener(this.isMobileMode ? 'touchend' : 'mouseup', this.onDocMouseUp);
142
+ this.restorationTimer = setTimeout(() => {
143
+ this.writeValue(1);
144
+ this.isWriteRestorationDownValue = true;
145
+ }, 1000);
146
+ }
147
+ }
93
148
  }
94
149
  }
95
150
  doSwitchOperator() {
@@ -106,12 +161,27 @@ export class SwitchIndicatorLightElement extends ConditionalEnableElement {
106
161
  throw new Error('Failure of the operation record:switchOperator');
107
162
  });
108
163
  }
164
+ writeValue(value) {
165
+ this.switchOperator.writeValue(value).then(args => {
166
+ if (this.model.isRecordOperation || this.model.isRecordOperation === undefined) {
167
+ if (args.newValue !== undefined || args.originValue !== undefined) {
168
+ this.operationRecordService.record({
169
+ variableOptionModel: args,
170
+ operationDescription: this.model.operationDescription
171
+ });
172
+ }
173
+ }
174
+ }).catch(() => {
175
+ throw new Error('Failure of the operation record:switchOperator');
176
+ });
177
+ }
109
178
  initSwitchOperator() {
110
179
  const settings = this.model.switchSettings;
111
180
  switch (settings.type) {
112
181
  case SwitchType.Bit:
113
182
  this.switchOperator =
114
183
  new BitSwitchOperator(settings.settings, this.variableCommunicator, this.variableStore, this.signalRAppId);
184
+ this.isBitRestoration = settings.settings.operation === BitSwitchOperation.Restoration;
115
185
  break;
116
186
  case SwitchType.Word:
117
187
  this.switchOperator =
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"SwitchIndicatorLightElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-enable-element","name":"ConditionalEnableElement","line":32,"character":49},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":44,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":45,"character":18},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":46,"character":39},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":47,"character":30},{"__symbolic":"reference","module":"../../config","name":"GraphStore","line":48,"character":37},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":49,"character":27},{"__symbolic":"reference","module":"../../service","name":"OperationRecordService","line":50,"character":49},{"__symbolic":"reference","module":"../../security","name":"SecurityChecker","line":51,"character":42},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":52,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":53,"character":22},{"__symbolic":"reference","name":"string"}]}],"checkElementPassword":[{"__symbolic":"method"}],"doSwitchOperator":[{"__symbolic":"method"}],"initSwitchOperator":[{"__symbolic":"method"}],"initIndictorLightOperator":[{"__symbolic":"method"}],"currentStateIdChange":[{"__symbolic":"method"}],"switchToState":[{"__symbolic":"method"}],"initGraphAndText":[{"__symbolic":"method"}],"checkState":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"SwitchIndicatorLightElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-enable-element","name":"ConditionalEnableElement","line":32,"character":49},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":50,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":51,"character":18},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":52,"character":39},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":53,"character":30},{"__symbolic":"reference","module":"../../config","name":"GraphStore","line":54,"character":37},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":55,"character":27},{"__symbolic":"reference","module":"../../service","name":"OperationRecordService","line":56,"character":49},{"__symbolic":"reference","module":"../../security","name":"SecurityChecker","line":57,"character":42},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":58,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":59,"character":22},{"__symbolic":"reference","name":"string"}]}],"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"}],"checkState":[{"__symbolic":"method"}]}}}}]
@@ -2,4 +2,5 @@ import { VariableOptionModel } from '../../service';
2
2
  export interface SwitchOperator {
3
3
  canExecute(): boolean;
4
4
  execute(): Promise<VariableOptionModel>;
5
+ writeValue(value: number): Promise<VariableOptionModel>;
5
6
  }
@@ -14,4 +14,5 @@ export declare class WordSwitchOperator implements SwitchOperator {
14
14
  constructor(settings: WordSwitchSettings, variableCommunicator: VariableCommunicator, variableStore: VariableStore, signalRAppId: string);
15
15
  canExecute(): boolean;
16
16
  execute(): Promise<VariableOptionModel>;
17
+ writeValue(value: any): Promise<VariableOptionModel>;
17
18
  }
@@ -66,4 +66,10 @@ export class WordSwitchOperator {
66
66
  newValue: newValue
67
67
  });
68
68
  }
69
+ // 此方法为 位设定添加的,字设定目前不会用到,为了解决接口error,添加一个空实现
70
+ writeValue(value) {
71
+ return Promise.resolve({
72
+ newValue: value
73
+ });
74
+ }
69
75
  }
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"WordSwitchOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"WordSwitchSettings","line":20,"character":43},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":20,"character":102},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":21,"character":40},{"__symbolic":"reference","name":"string"}]}],"canExecute":[{"__symbolic":"method"}],"execute":[{"__symbolic":"method"}]}}}}]
1
+ [{"__symbolic":"module","version":4,"metadata":{"WordSwitchOperator":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"../../model","name":"WordSwitchSettings","line":20,"character":43},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":20,"character":102},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":21,"character":40},{"__symbolic":"reference","name":"string"}]}],"canExecute":[{"__symbolic":"method"}],"execute":[{"__symbolic":"method"}],"writeValue":[{"__symbolic":"method"}]}}}}]
@@ -16,6 +16,9 @@ export declare class VideoElement extends ConditionalDisplayElement {
16
16
  private videoId;
17
17
  private isShow;
18
18
  private videoPlayer;
19
+ private refreshTimer;
20
+ private isFullscreen;
21
+ private videoUrl;
19
22
  constructor(element: HTMLElement, injector: Injector, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, videoService: VideoService, guiSize: Size, svgRootClass: string, signalRAppId: string);
20
23
  dispose(): void;
21
24
  hide(): void;
@@ -24,4 +27,5 @@ export declare class VideoElement extends ConditionalDisplayElement {
24
27
  private initVideo;
25
28
  private addVideoAddressToolTip;
26
29
  private setAndroidVideo;
30
+ private setIosVideo;
27
31
  }