@flexem/fc-gui 3.0.0-alpha.159 → 3.0.0-alpha.160
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 +95 -9
- 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/elements/main-element.js +16 -0
- package/elements/numerical-display/numerical-display-element.d.ts +6 -0
- package/elements/numerical-display/numerical-display-element.js +44 -1
- package/elements/numerical-display/numerical-display-element.metadata.json +1 -1
- package/modal/write-value/write-value-modal.component.js +7 -4
- package/model/numerical-display/numerical-operation.d.ts +10 -2
- package/package.json +1 -1
- package/utils/numerical-operation.service.js +28 -4
package/elements/main-element.js
CHANGED
|
@@ -244,6 +244,17 @@ export class MainElement {
|
|
|
244
244
|
if (variableName && !variableNames.find(v => isEqual(variableName, v))) {
|
|
245
245
|
variableNames.push(element.readVariableName);
|
|
246
246
|
}
|
|
247
|
+
// 数值显示元件:上下限变量类型时,将上下限变量名也加入订阅
|
|
248
|
+
if (element instanceof NumericalDisplayElement) {
|
|
249
|
+
const upperLimitVarName = element.upperLimitVariableName;
|
|
250
|
+
if (upperLimitVarName && !variableNames.find(v => isEqual(upperLimitVarName, v))) {
|
|
251
|
+
variableNames.push(upperLimitVarName);
|
|
252
|
+
}
|
|
253
|
+
const lowerLimitVarName = element.lowerLimitVariableName;
|
|
254
|
+
if (lowerLimitVarName && !variableNames.find(v => isEqual(lowerLimitVarName, v))) {
|
|
255
|
+
variableNames.push(lowerLimitVarName);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
247
258
|
}
|
|
248
259
|
});
|
|
249
260
|
return variableNames;
|
|
@@ -282,6 +293,11 @@ export class MainElement {
|
|
|
282
293
|
e.minVariableName === value.variableName || e.maxVariableName === value.variableName))) {
|
|
283
294
|
e.reportValueChanged(value);
|
|
284
295
|
}
|
|
296
|
+
// 数值显示元件:上下限变量推送分发
|
|
297
|
+
if (e instanceof NumericalDisplayElement && value.variableName && (e.upperLimitVariableName === value.variableName ||
|
|
298
|
+
e.lowerLimitVariableName === value.variableName)) {
|
|
299
|
+
e.reportValueChanged(value);
|
|
300
|
+
}
|
|
285
301
|
if (e.readVariableName === value.systemName) {
|
|
286
302
|
const rect = (_a = e.currentRect) === null || _a === void 0 ? void 0 : _a[0];
|
|
287
303
|
const deviceId = this.getVirtualDeviceIdFromRect(rect);
|
|
@@ -29,6 +29,12 @@ export declare class NumericalDisplayElement extends ReadableElement {
|
|
|
29
29
|
private showValue;
|
|
30
30
|
private numericalOperation;
|
|
31
31
|
private restorationTimer;
|
|
32
|
+
private _resolvedUpperLimitValue;
|
|
33
|
+
private _resolvedLowerLimitValue;
|
|
34
|
+
/** 当数值上限配置为变量类型时,返回变量名;否则返回 undefined */
|
|
35
|
+
get upperLimitVariableName(): string | undefined;
|
|
36
|
+
/** 当数值下限配置为变量类型时,返回变量名;否则返回 undefined */
|
|
37
|
+
get lowerLimitVariableName(): string | undefined;
|
|
32
38
|
get writeVariableName(): string;
|
|
33
39
|
constructor(element: HTMLElement, injector: Injector, modalService: BsModalService, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, graphStore: GraphStore, operationRecordService: OperationRecordService, releasedVariableService: ReleasedVariableService, securityChecker: SecurityChecker, variableStore: VariableStore, localization: Localization, signalRAppId: string, guiContext?: GuiContext);
|
|
34
40
|
dispose(): void;
|
|
@@ -28,6 +28,9 @@ export class NumericalDisplayElement extends ReadableElement {
|
|
|
28
28
|
this.guiContext = guiContext;
|
|
29
29
|
this.displayText = '';
|
|
30
30
|
this.enableDataParsed = false;
|
|
31
|
+
// 上下限变量的实时缓存值(仅当上下限配置为变量类型时使用)
|
|
32
|
+
this._resolvedUpperLimitValue = undefined;
|
|
33
|
+
this._resolvedLowerLimitValue = undefined;
|
|
31
34
|
this.logger = injector.get(LOGGER_SERVICE_TOKEN);
|
|
32
35
|
this.dataTypeService = injector.get(DataTypeService);
|
|
33
36
|
this.fractionDigitService = injector.get(FractionDigitService);
|
|
@@ -47,6 +50,22 @@ export class NumericalDisplayElement extends ReadableElement {
|
|
|
47
50
|
}
|
|
48
51
|
this.initElement();
|
|
49
52
|
}
|
|
53
|
+
/** 当数值上限配置为变量类型时,返回变量名;否则返回 undefined */
|
|
54
|
+
get upperLimitVariableName() {
|
|
55
|
+
const upper = this.model.numericalUpperLimit;
|
|
56
|
+
if (upper && typeof upper === 'object' && upper.type === 1 && upper.variableName) {
|
|
57
|
+
return upper.variableName;
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
/** 当数值下限配置为变量类型时,返回变量名;否则返回 undefined */
|
|
62
|
+
get lowerLimitVariableName() {
|
|
63
|
+
const lower = this.model.numericalLowerLimit;
|
|
64
|
+
if (lower && typeof lower === 'object' && lower.type === 1 && lower.variableName) {
|
|
65
|
+
return lower.variableName;
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
50
69
|
get writeVariableName() {
|
|
51
70
|
return this.readVariableName;
|
|
52
71
|
}
|
|
@@ -64,6 +83,17 @@ export class NumericalDisplayElement extends ReadableElement {
|
|
|
64
83
|
*/
|
|
65
84
|
reportValueChanged(value) {
|
|
66
85
|
var _a, _b, _c;
|
|
86
|
+
// 拦截上下限变量推送,更新缓存值
|
|
87
|
+
if (this.upperLimitVariableName && value.variableName === this.upperLimitVariableName) {
|
|
88
|
+
const num = Number(value.value);
|
|
89
|
+
this._resolvedUpperLimitValue = (value.value != null && !isNaN(num)) ? num : undefined;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (this.lowerLimitVariableName && value.variableName === this.lowerLimitVariableName) {
|
|
93
|
+
const num = Number(value.value);
|
|
94
|
+
this._resolvedLowerLimitValue = (value.value != null && !isNaN(num)) ? num : undefined;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
67
97
|
// 处理系统变量"当前语种ID"
|
|
68
98
|
if (value.variableName === '当前语种ID') {
|
|
69
99
|
let displayValue = value.value;
|
|
@@ -200,7 +230,20 @@ export class NumericalDisplayElement extends ReadableElement {
|
|
|
200
230
|
if (null == this.writeVariableName) {
|
|
201
231
|
return;
|
|
202
232
|
}
|
|
203
|
-
|
|
233
|
+
// 获取数值操作配置,上下限变量类型已在 reportValueChanged 中实时更新到缓存
|
|
234
|
+
const numericalOperation = this.numericalOperationService.getNumericalOperations(this.model);
|
|
235
|
+
// 用缓存的实时值替换变量类型上下限
|
|
236
|
+
if (typeof numericalOperation.numericalUpperLimit === 'object' && numericalOperation.numericalUpperLimit.type === 1) {
|
|
237
|
+
numericalOperation.numericalUpperLimit = this._resolvedUpperLimitValue != null
|
|
238
|
+
? this._resolvedUpperLimitValue
|
|
239
|
+
: (this.dataTypeService.getMaxValue(this.model.version || 0, this.model.dataType || 0, this.model.fBoxDataType || 0) || 0);
|
|
240
|
+
}
|
|
241
|
+
if (typeof numericalOperation.numericalLowerLimit === 'object' && numericalOperation.numericalLowerLimit.type === 1) {
|
|
242
|
+
numericalOperation.numericalLowerLimit = this._resolvedLowerLimitValue != null
|
|
243
|
+
? this._resolvedLowerLimitValue
|
|
244
|
+
: (this.dataTypeService.getMinValue(this.model.version || 0, this.model.dataType || 0, this.model.fBoxDataType || 0) || 0);
|
|
245
|
+
}
|
|
246
|
+
const args = new WriteValueModalArgs(this.writeVariableName, this.model.dataType, this.model.fBoxDataType, this.model.integerDigits, this.model.fractionDigits, numericalOperation, this.model.version, this.enableDataParsed, this.releasedVariableService, this.guiContext);
|
|
204
247
|
this.writeValueMmodalRef = this.modalService.show(WriteValueModalComponent, {
|
|
205
248
|
initialState: { args: args }, backdrop: 'static', class: 'gui-modal-dialog-position', animated: false
|
|
206
249
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"NumericalDisplayElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":29,"character":45},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"NumericalDisplayElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/readable-element","name":"ReadableElement","line":29,"character":45},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":73,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":74,"character":18},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":75,"character":39},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":76,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":77,"character":30},{"__symbolic":"reference","module":"../../config","name":"GraphStore","line":78,"character":37},{"__symbolic":"reference","module":"../../service","name":"OperationRecordService","line":79,"character":49},{"__symbolic":"reference","module":"../../service","name":"ReleasedVariableService","line":80,"character":50},{"__symbolic":"reference","module":"../../security","name":"SecurityChecker","line":81,"character":42},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":82,"character":23},{"__symbolic":"reference","module":"../../localization","name":"Localization","line":83,"character":22},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","module":"../../gui/gui-context","name":"GuiContext","line":85,"character":38}]}],"dispose":[{"__symbolic":"method"}],"reportValueChanged":[{"__symbolic":"method"}],"initElement":[{"__symbolic":"method"}],"checkElementPassword":[{"__symbolic":"method"}],"initVariableText":[{"__symbolic":"method"}],"initGraphAndText":[{"__symbolic":"method"}],"doWriteValue":[{"__symbolic":"method"}],"recordOperation":[{"__symbolic":"method"}],"changeStates":[{"__symbolic":"method"}],"updateVariableValue":[{"__symbolic":"method"}],"updateDisplayText":[{"__symbolic":"method"}],"rebuildTextElement":[{"__symbolic":"method"}],"formatNumericalDisplayText":[{"__symbolic":"method"}],"formatFloatDisplayText":[{"__symbolic":"method"}],"isNumeric":[{"__symbolic":"method"}],"formatDisplayTextUnit":[{"__symbolic":"method"}]}}}}]
|
|
@@ -70,17 +70,20 @@ let WriteValueModalComponent = class WriteValueModalComponent {
|
|
|
70
70
|
this.writeValueRangeText = this.getWriteValueRangeText();
|
|
71
71
|
}
|
|
72
72
|
setValueRangeAccordToDataParsed(option) {
|
|
73
|
+
// 上下限已在 numerical-display-element.ts 中解析为数值,直接使用
|
|
74
|
+
const resolvedUpperLimit = Number(this.numericalOperation.numericalUpperLimit);
|
|
75
|
+
const resolvedLowerLimit = Number(this.numericalOperation.numericalLowerLimit);
|
|
73
76
|
if (this.dataTypeService.isFloat(option.version, this.dataType) || this.enableNumericalOperation) {
|
|
74
77
|
this.maxValueLimit = this.dataTypeService.getMaxValue(option.version, this.dataType, this.fBoxDataType);
|
|
75
78
|
this.minValueLimit = this.dataTypeService.getMinValue(option.version, this.dataType, this.fBoxDataType);
|
|
76
|
-
this.numericalLowerLimit =
|
|
77
|
-
this.numericalUpperLimit =
|
|
79
|
+
this.numericalLowerLimit = resolvedLowerLimit;
|
|
80
|
+
this.numericalUpperLimit = resolvedUpperLimit;
|
|
78
81
|
}
|
|
79
82
|
else {
|
|
80
83
|
this.maxValueLimit = +this.fractionDigitService.movePoint(this.dataTypeService.getMaxValue(option.version, this.dataType, this.fBoxDataType), -this.fractionDigits);
|
|
81
84
|
this.minValueLimit = +this.fractionDigitService.movePoint(this.dataTypeService.getMinValue(option.version, this.dataType, this.fBoxDataType), -this.fractionDigits);
|
|
82
|
-
this.numericalLowerLimit = +this.fractionDigitService.movePoint(
|
|
83
|
-
this.numericalUpperLimit = +this.fractionDigitService.movePoint(
|
|
85
|
+
this.numericalLowerLimit = +this.fractionDigitService.movePoint(resolvedLowerLimit, -this.fractionDigits);
|
|
86
|
+
this.numericalUpperLimit = +this.fractionDigitService.movePoint(resolvedUpperLimit, -this.fractionDigits);
|
|
84
87
|
}
|
|
85
88
|
const minValue = this.numericalOperationService.getWriteMinValue(this.minValueLimit, this.numericalOperation);
|
|
86
89
|
const maxValue = this.numericalOperationService.getWriteMaxValue(this.maxValueLimit, this.numericalOperation);
|
|
@@ -2,8 +2,16 @@ import { NumericalOperationType } from '../../utils/numerical-operation-type';
|
|
|
2
2
|
import { ProportionalConversion } from './proportional-conversion';
|
|
3
3
|
import { Zoom } from './zoom';
|
|
4
4
|
export interface NumericalOperation {
|
|
5
|
-
numericalUpperLimit: number
|
|
6
|
-
|
|
5
|
+
numericalUpperLimit: number | {
|
|
6
|
+
type: number;
|
|
7
|
+
variableName: string;
|
|
8
|
+
variableVersion?: number;
|
|
9
|
+
};
|
|
10
|
+
numericalLowerLimit: number | {
|
|
11
|
+
type: number;
|
|
12
|
+
variableName: string;
|
|
13
|
+
variableVersion?: number;
|
|
14
|
+
};
|
|
7
15
|
enableNumericalOperation: boolean;
|
|
8
16
|
type: NumericalOperationType;
|
|
9
17
|
proportionalConversion: ProportionalConversion;
|
package/package.json
CHANGED
|
@@ -43,10 +43,34 @@ let NumericalOperationService = class NumericalOperationService {
|
|
|
43
43
|
}
|
|
44
44
|
getNumericalOperations(model) {
|
|
45
45
|
const numericalOperation = {};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
// 处理上限:兼容老结构(number)和新结构(变量对象)
|
|
47
|
+
if (model.numericalUpperLimit || model.numericalUpperLimit === 0) {
|
|
48
|
+
if (typeof model.numericalUpperLimit === 'object' && model.numericalUpperLimit.type === 1) {
|
|
49
|
+
// 新结构:变量类型,保留原对象
|
|
50
|
+
numericalOperation.numericalUpperLimit = model.numericalUpperLimit;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// 老结构:数字类型
|
|
54
|
+
numericalOperation.numericalUpperLimit = +model.numericalUpperLimit;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
numericalOperation.numericalUpperLimit = this.dataTypeService.getMaxValue(model.version, model.dataType, model.fBoxDataType, model.integerDigits, model.fractionDigits);
|
|
59
|
+
}
|
|
60
|
+
// 处理下限:兼容老结构(number)和新结构(变量对象)
|
|
61
|
+
if (model.numericalLowerLimit || model.numericalLowerLimit === 0) {
|
|
62
|
+
if (typeof model.numericalLowerLimit === 'object' && model.numericalLowerLimit.type === 1) {
|
|
63
|
+
// 新结构:变量类型,保留原对象
|
|
64
|
+
numericalOperation.numericalLowerLimit = model.numericalLowerLimit;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// 老结构:数字类型
|
|
68
|
+
numericalOperation.numericalLowerLimit = +model.numericalLowerLimit;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
numericalOperation.numericalLowerLimit = this.dataTypeService.getMinValue(model.version, model.dataType, model.fBoxDataType, model.integerDigits, model.fractionDigits);
|
|
73
|
+
}
|
|
50
74
|
numericalOperation.enableNumericalOperation = model.enableNumericalOperation;
|
|
51
75
|
if (model.enableNumericalOperation) {
|
|
52
76
|
numericalOperation.type = model.numericalOperationSetting.type;
|