@flexem/fc-gui 3.0.0-alpha.150 → 3.0.0-alpha.152

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.
@@ -35414,7 +35414,7 @@ class readable_element_ReadableElement extends conditional_enable_element_Condit
35414
35414
  return;
35415
35415
  }
35416
35416
  // 处理普通变量
35417
- if (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable
35417
+ if (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable || this.state === _tmp_model["State"].Offline
35418
35418
  || value.variableName === this.minVariableName
35419
35419
  || value.variableName === this.maxVariableName) {
35420
35420
  this.updateVariableValue(value.value, value.variableName);
@@ -35936,7 +35936,7 @@ class character_display_element_CharacterDisplayElement extends readable_element
35936
35936
  }
35937
35937
  changeStates() {
35938
35938
  super.changeStates();
35939
- if (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable) {
35939
+ if (this.state === _tmp_model["State"].Normal || this.state === _tmp_model["State"].Disable || this.state === _tmp_model["State"].Offline) {
35940
35940
  this.updateDisplayValue(this.displayValue);
35941
35941
  }
35942
35942
  else {
@@ -39593,8 +39593,11 @@ class bit_indicator_light_operator_BitIndicatorLightOperator {
39593
39593
  }
39594
39594
  }
39595
39595
  requestCurrentSateIdValue(variableCommunicator, appId = '') {
39596
- variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
39597
- if (value.state === communication["d" /* VariableStateEnum */].DataNormal) {
39596
+ if (this.valueSubscription) {
39597
+ return;
39598
+ }
39599
+ this.valueSubscription = variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
39600
+ if (value.state === communication["d" /* VariableStateEnum */].DataNormal || value.state === communication["d" /* VariableStateEnum */].Offline) {
39598
39601
  if (this.settings.isBitwiseIndex) {
39599
39602
  const maxBitIndex = 31;
39600
39603
  this.binary = new binary["a" /* Binary */](value.value, maxBitIndex + 1);
@@ -39763,9 +39766,12 @@ class word_indicator_light_operator_WordIndicatorLightOperator {
39763
39766
  }
39764
39767
  }
39765
39768
  requestCurrentSateIdValue(variableCommunicator, appId = '') {
39769
+ if (this.valueSubscription) {
39770
+ return;
39771
+ }
39766
39772
  // TODO 检查状态id是从0-n连续编号的。
39767
- variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
39768
- if (value.state === communication["d" /* VariableStateEnum */].DataNormal) {
39773
+ this.valueSubscription = variableCommunicator.openVariable(this.variableName, appId).subscribe(value => {
39774
+ if (value.state === communication["d" /* VariableStateEnum */].DataNormal || value.state === communication["d" /* VariableStateEnum */].Offline) {
39769
39775
  let stateId = 0;
39770
39776
  for (let index = 0; index < this.sortedStates.length - 1; index++) {
39771
39777
  const element = this.sortedStates[index];
@@ -40088,12 +40094,17 @@ class switch_indicator_light_element_SwitchIndicatorLightElement extends conditi
40088
40094
  this.indicatorLightOperator.requestData(this.signalRAppId);
40089
40095
  }
40090
40096
  currentStateIdChange(statusIdValue) {
40091
- if (!Object(lodash["isUndefined"])(statusIdValue.value)) {
40092
- this.switchToState(statusIdValue.value);
40093
- }
40094
40097
  this.updateElementStates([statusIdValue.state]);
40095
40098
  if (this.state === _tmp_model["State"].Unbind || this.state === _tmp_model["State"].Offline) {
40096
- this.switchToState(0);
40099
+ if (!Object(lodash["isUndefined"])(statusIdValue.value)) {
40100
+ this.switchToState(statusIdValue.value);
40101
+ }
40102
+ else {
40103
+ this.switchToState(0);
40104
+ }
40105
+ }
40106
+ else if (!Object(lodash["isUndefined"])(statusIdValue.value)) {
40107
+ this.switchToState(statusIdValue.value);
40097
40108
  }
40098
40109
  }
40099
40110
  switchToState(stateId) {
@@ -43414,7 +43425,10 @@ class per_view_variable_communicator_PerViewVariableCommunicator {
43414
43425
  if (!this.observers.has(variableName)) {
43415
43426
  this.observers.set(variableName, []);
43416
43427
  }
43417
- this.observers.get(variableName).push(subscriber);
43428
+ const obs = this.observers.get(variableName);
43429
+ if (obs) {
43430
+ obs.push(subscriber);
43431
+ }
43418
43432
  });
43419
43433
  const subscription = this._rawVariableCommunicator.openVariables(variableNames, appId).subscribe(values => subscriber.next(values), error => subscriber.error(error), () => subscriber.complete());
43420
43434
  this.variableValuesChangedSubscriptions.push(subscription);
@@ -43440,7 +43454,7 @@ class per_view_variable_communicator_PerViewVariableCommunicator {
43440
43454
  }
43441
43455
  subscribeUserDeviceAlarms(appId = '') {
43442
43456
  return new Observable["a" /* Observable */](subscriber => {
43443
- const subscription = this._rawVariableCommunicator.subscribeUserDeviceAlarms(appId).subscribe(values => subscriber.next(values), error => subscriber.error(error), () => subscriber.complete());
43457
+ const subscription = this._rawVariableCommunicator.subscribeUserDeviceAlarms(appId).subscribe((values) => subscriber.next(values), (error) => subscriber.error(error), () => subscriber.complete());
43444
43458
  this.alarmSubscription.push(subscription);
43445
43459
  });
43446
43460
  }
@@ -43471,6 +43485,8 @@ class gui_view_GuiView {
43471
43485
  this.context = context;
43472
43486
  this.parentView = parentView;
43473
43487
  this.viewId = guid["a" /* Guid */].newGuid().toString('n');
43488
+ this.openVariablesSubscriptions = [];
43489
+ this.openedVariableNamesForValues = new Set();
43474
43490
  this.logger = injector.get(logger["b" /* LOGGER_SERVICE_TOKEN */]);
43475
43491
  this.childViews = new Array();
43476
43492
  if (parentView) {
@@ -43526,6 +43542,9 @@ class gui_view_GuiView {
43526
43542
  if (this.openVariableStatesSubscription) {
43527
43543
  this.openVariableStatesSubscription.unsubscribe();
43528
43544
  }
43545
+ this.openVariablesSubscriptions.forEach(s => s.unsubscribe());
43546
+ this.openVariablesSubscriptions = [];
43547
+ this.openedVariableNamesForValues.clear();
43529
43548
  this.openedVariableNames = this.mainElement.getVariableNames();
43530
43549
  // 分离系统变量和普通变量
43531
43550
  const systemVariables = [];
@@ -43565,7 +43584,7 @@ class gui_view_GuiView {
43565
43584
  this.mainElement.reportVariableStates(states);
43566
43585
  const normalVariableNames = [];
43567
43586
  Object(lodash["each"])(states, v => {
43568
- if (v.state === communication["d" /* VariableStateEnum */].Normal && normalVariableNames.indexOf(v.variableName) === -1) {
43587
+ if ((v.state === communication["d" /* VariableStateEnum */].Normal || v.state === communication["d" /* VariableStateEnum */].Offline) && normalVariableNames.indexOf(v.variableName) === -1) {
43569
43588
  normalVariableNames.push(v.variableName);
43570
43589
  }
43571
43590
  });
@@ -43672,8 +43691,8 @@ class gui_view_GuiView {
43672
43691
  if (this.virtualDeviceStatesChanged) {
43673
43692
  this.virtualDeviceStatesChanged.unsubscribe();
43674
43693
  }
43675
- if (this.openVariablesSubscription) {
43676
- this.openVariablesSubscription.unsubscribe();
43694
+ if (this.openVariablesSubscriptions) {
43695
+ this.openVariablesSubscriptions.forEach(s => s.unsubscribe());
43677
43696
  }
43678
43697
  if (this.perViewVariableCommunicator) {
43679
43698
  this.perViewVariableCommunicator.dispose();
@@ -43687,9 +43706,12 @@ class gui_view_GuiView {
43687
43706
  this.logger.debug('[GUI] View disposed.');
43688
43707
  }
43689
43708
  normalOpenedVariableNames(normalVariableNames) {
43690
- if (normalVariableNames.length > 0) {
43691
- this.openVariablesSubscription = this.perViewVariableCommunicator.openVariables(normalVariableNames, this.signalRAppId)
43709
+ const newVariables = normalVariableNames.filter(v => !this.openedVariableNamesForValues.has(v));
43710
+ if (newVariables.length > 0) {
43711
+ newVariables.forEach(v => this.openedVariableNamesForValues.add(v));
43712
+ const sub = this.perViewVariableCommunicator.openVariables(newVariables, this.signalRAppId)
43692
43713
  .subscribe(variableValues => this.mainElement.reportVariableValues(variableValues));
43714
+ this.openVariablesSubscriptions.push(sub);
43693
43715
  }
43694
43716
  }
43695
43717
  }
@@ -65947,6 +65969,9 @@ class RemoteImageStore {
65947
65969
  // EXTERNAL MODULE: ./node_modules/rxjs/_esm5/internal/Observable.js + 3 modules
65948
65970
  var Observable = __webpack_require__(15);
65949
65971
 
65972
+ // EXTERNAL MODULE: ./.tmp/communication/index.ts + 4 modules
65973
+ var communication = __webpack_require__(4);
65974
+
65950
65975
  // EXTERNAL MODULE: ./.tmp/core/index.ts
65951
65976
  var core = __webpack_require__(43);
65952
65977
 
@@ -65955,6 +65980,7 @@ var core = __webpack_require__(43);
65955
65980
 
65956
65981
 
65957
65982
 
65983
+
65958
65984
  class remote_variable_communicator_RemoteVariableCommunicator {
65959
65985
  constructor(remoteVariableProtocol, logger) {
65960
65986
  this.remoteVariableProtocol = remoteVariableProtocol;
@@ -65966,6 +65992,8 @@ class remote_variable_communicator_RemoteVariableCommunicator {
65966
65992
  this.alarmObservers = [];
65967
65993
  // 系统变量处理器
65968
65994
  this.systemVariableHandlers = new Map();
65995
+ // 预加载的离线变量最新值缓存(组态加载时一次性填充,推送后即删除)
65996
+ this.offlineValueCache = new Map();
65969
65997
  this.variableValueCache = new core["a" /* StringifyingMap */](k => JSON.stringify(k));
65970
65998
  this.connectedSubscription = this.remoteVariableProtocol.connected.subscribe(() => {
65971
65999
  const variableNamesToStart = [];
@@ -66040,13 +66068,35 @@ class remote_variable_communicator_RemoteVariableCommunicator {
66040
66068
  this.variableStateCache.set(variableName, state);
66041
66069
  if (this.variableStateObservers.has(variableName)) {
66042
66070
  Object(lodash["each"])(this.variableStateObservers.get(variableName), ob => {
66043
- // TODO 同一个ob监听多个变量的情况,组合成数组一次推送。
66044
66071
  ob.next([state]);
66045
66072
  });
66046
66073
  }
66074
+ // 离线时从预加载缓存取值推送给值订阅者
66075
+ if (state.state === communication["d" /* VariableStateEnum */].Offline && this.offlineValueCache.has(variableName)) {
66076
+ const cachedValue = this.offlineValueCache.get(variableName);
66077
+ const variableValue = {
66078
+ variableName,
66079
+ value: cachedValue,
66080
+ state: communication["d" /* VariableStateEnum */].Offline
66081
+ };
66082
+ this.variableValueCache.set(variableName, variableValue);
66083
+ if (this.observers.has(variableName)) {
66084
+ Object(lodash["each"])(this.observers.get(variableName), ob => {
66085
+ ob.next([variableValue]);
66086
+ });
66087
+ }
66088
+ }
66089
+ // 无论什么状态,推送后清除缓存,防止后续再次离线时用旧值
66090
+ this.offlineValueCache.delete(variableName);
66047
66091
  });
66048
66092
  });
66049
66093
  }
66094
+ /**
66095
+ * 预填充离线变量值缓存,由 GuiContext 在组态加载时一次性调用
66096
+ */
66097
+ setOfflineValueCache(variableName, value) {
66098
+ this.offlineValueCache.set(variableName, value);
66099
+ }
66050
66100
  subscribeVariableStates(variableNames) {
66051
66101
  return new Observable["a" /* Observable */](observer => {
66052
66102
  let variableNamesToStart = [];