@flexem/fc-gui 3.0.0-alpha.61 → 3.0.0-alpha.63

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 (41) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/bundles/@flexem/fc-gui.umd.js +16992 -16615
  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/alarm/alarm-element.d.ts +37 -0
  21. package/elements/alarm/alarm-element.js +302 -0
  22. package/elements/alarm/alarm-element.metadata.json +1 -0
  23. package/elements/alarm/alarm-state-enum.d.ts +4 -0
  24. package/elements/alarm/alarm-state-enum.js +5 -0
  25. package/elements/alarm/alarm-state-enum.metadata.json +1 -0
  26. package/elements/main-element.js +4 -0
  27. package/elements/main-element.metadata.json +1 -1
  28. package/elements/per-view-variable-communicator.d.ts +2 -0
  29. package/elements/per-view-variable-communicator.js +8 -0
  30. package/elements/per-view-variable-communicator.metadata.json +1 -1
  31. package/model/alarm/alarm.model.d.ts +13 -0
  32. package/model/alarm/alarm.model.js +0 -0
  33. package/model/alarm/alarm.model.metadata.json +1 -0
  34. package/package.json +1 -1
  35. package/remote/communication/variable/remote-variable-communicator.d.ts +4 -0
  36. package/remote/communication/variable/remote-variable-communicator.js +22 -0
  37. package/remote/communication/variable/remote-variable-communicator.metadata.json +1 -1
  38. package/remote/communication/variable/remote-variable-protocol.d.ts +3 -0
  39. package/shared/gui-consts.d.ts +1 -0
  40. package/shared/gui-consts.js +2 -1
  41. package/shared/gui-consts.metadata.json +1 -1
@@ -8,5 +8,6 @@ export interface VariableCommunicator {
8
8
  writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
9
9
  subscribeVariableState(variableName: string): Observable<VariableState>;
10
10
  subscribeVariableStates(variableNames: Array<string>): Observable<Array<VariableState>>;
11
+ subscribeUserDeviceAlarms(appId: string): any;
11
12
  dispose(): any;
12
13
  }
@@ -0,0 +1,6 @@
1
+ import { Observable } from 'rxjs';
2
+ import { GetAlarmsArgs } from './get-alarms-args';
3
+ export interface AlarmsStore {
4
+ getHistoryAlarms(input: GetAlarmsArgs): Observable<any>;
5
+ getCurrentAlarms(input: GetAlarmsArgs): Observable<any>;
6
+ }
File without changes
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmsStore":{"__symbolic":"interface"}}}]
@@ -0,0 +1,9 @@
1
+ import * as moment from 'moment';
2
+ export declare class GetAlarmsArgs {
3
+ readonly alarmNames: string[];
4
+ readonly triggeredStartTime: moment.Moment;
5
+ readonly triggeredEndTime: moment.Moment;
6
+ readonly maxResultCount: number;
7
+ readonly skipCount: number;
8
+ constructor(alarmNames: string[], triggeredStartTime: moment.Moment, triggeredEndTime: moment.Moment, maxResultCount: number, skipCount: number);
9
+ }
@@ -0,0 +1,9 @@
1
+ export class GetAlarmsArgs {
2
+ constructor(alarmNames, triggeredStartTime, triggeredEndTime, maxResultCount, skipCount) {
3
+ this.alarmNames = alarmNames;
4
+ this.triggeredStartTime = triggeredStartTime;
5
+ this.triggeredEndTime = triggeredEndTime;
6
+ this.maxResultCount = maxResultCount;
7
+ this.skipCount = skipCount;
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"GetAlarmsArgs":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"string"}]},{"__symbolic":"reference","module":"moment","name":"Moment","line":5,"character":37},{"__symbolic":"reference","module":"moment","name":"Moment","line":6,"character":35},{"__symbolic":"reference","name":"number"},{"__symbolic":"reference","name":"number"}]}]}}}}]
@@ -0,0 +1,2 @@
1
+ export { AlarmsStore } from './alarm.store';
2
+ export { GetAlarmsArgs } from './get-alarms-args';
@@ -0,0 +1 @@
1
+ export { GetAlarmsArgs } from './get-alarms-args';
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./alarm.store","export":["AlarmsStore"]},{"from":"./get-alarms-args","export":["GetAlarmsArgs"]}]}]
@@ -3,6 +3,7 @@ import { ViewStore } from './view/view-store';
3
3
  import { ImageStore } from './image/image-store';
4
4
  import { HistoryDataStore } from './history-data/history-data.store';
5
5
  import { VariableStore } from './variable/variable-store';
6
+ import { AlarmsStore } from './alarm';
6
7
  /**
7
8
  * 配置仓储
8
9
  */
@@ -11,5 +12,6 @@ export interface ConfigStore {
11
12
  readonly graphStore: GraphStore;
12
13
  readonly imageStore: ImageStore;
13
14
  readonly historyDataStore: HistoryDataStore;
15
+ readonly alarmsStore: AlarmsStore;
14
16
  readonly variableStore: VariableStore;
15
17
  }
package/config/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export { ViewModel } from './view/view.model';
8
8
  export { ImageStore } from './image/image-store';
9
9
  export * from './history-data';
10
10
  export * from './variable';
11
+ export * from './alarm';
package/config/index.js CHANGED
@@ -4,3 +4,4 @@ export { GraphType } from './graph/graph-type';
4
4
  export { ViewModel } from './view/view.model';
5
5
  export * from './history-data';
6
6
  export * from './variable';
7
+ export * from './alarm';
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"}]}]
1
+ [{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./config-store","export":["ConfigStore"]},{"from":"./graph/graph","export":["Graph"]},{"from":"./graph/graph-result","export":["GraphResult"]},{"from":"./graph/graph-type","export":["GraphType"]},{"from":"./graph/graph-store","export":["GraphStore"]},{"from":"./view/view-store","export":["ViewStore"]},{"from":"./view/view.model","export":["ViewModel"]},{"from":"./image/image-store","export":["ImageStore"]},{"from":"./history-data"},{"from":"./variable"},{"from":"./alarm"}]}]
@@ -0,0 +1,37 @@
1
+ import { Injector } from '@angular/core';
2
+ import { PermissionChecker } from '../../service';
3
+ import { VariableCommunicator } from '../../communication';
4
+ import { ConditionalDisplayElement } from '../base/conditional-display-element';
5
+ import { AlarmModel } from '../../model/alarm/alarm.model';
6
+ import { AlarmsStore, VariableStore } from '../../config';
7
+ export declare class AlarmElement extends ConditionalDisplayElement {
8
+ private readonly alarmsStore;
9
+ readonly model: AlarmModel;
10
+ private readonly logger;
11
+ readonly variableCommunicator: VariableCommunicator;
12
+ private readonly localization;
13
+ private readonly timePeriods;
14
+ private element;
15
+ private refreshIntervalId;
16
+ private readonly displayOption;
17
+ private startTime;
18
+ private endTime;
19
+ private currentTimePeriod;
20
+ private alarmList;
21
+ private currentAlarmList;
22
+ private page;
23
+ private totalCount;
24
+ private pageSize;
25
+ constructor(element: HTMLElement, injector: Injector, permissionChecker: PermissionChecker, variableCommunicator: VariableCommunicator, variableStore: VariableStore, alarmsStore: AlarmsStore, signalRAppId: string);
26
+ dispose(): void;
27
+ private getValidTimePeriods;
28
+ private init;
29
+ private renderElement;
30
+ private renderOperationArea;
31
+ private updateTimeRange;
32
+ private updateQueryTimeRange;
33
+ private loadFirstPage;
34
+ private loadNextPage;
35
+ private loadPreviousPage;
36
+ private loadLastPage;
37
+ }
@@ -0,0 +1,302 @@
1
+ import * as d3 from 'd3';
2
+ import { ConditionalDisplayElement } from '../base/conditional-display-element';
3
+ import { GetAlarmsArgs } from '../../config';
4
+ import * as moment from 'moment';
5
+ import { LOGGER_SERVICE_TOKEN } from '../../logger';
6
+ import { LOCALIZATION } from '../../localization';
7
+ import { find, isNil, pull, remove } from 'lodash';
8
+ import { AlarmState } from './alarm-state-enum';
9
+ export class AlarmElement extends ConditionalDisplayElement {
10
+ constructor(element, injector, permissionChecker, variableCommunicator, variableStore, alarmsStore, signalRAppId) {
11
+ super(element, permissionChecker, variableCommunicator, variableStore, signalRAppId);
12
+ this.alarmsStore = alarmsStore;
13
+ this.displayOption = {
14
+ dataLimit: 500,
15
+ dataZoomHeight: 32,
16
+ marginLeft: 1,
17
+ marginRight: 20,
18
+ mobileMinWidth: 450,
19
+ operationAreaHeight: 32,
20
+ operationAreaMarginTop: 10,
21
+ operationSelectFontSize: '16px',
22
+ operationButtonWidth: 24,
23
+ operationButtonHeight: 24,
24
+ operationButtonMargin: 4
25
+ };
26
+ this.alarmList = [];
27
+ this.currentAlarmList = [];
28
+ this.page = 0;
29
+ this.totalCount = 0;
30
+ this.pageSize = 5;
31
+ this.logger = injector.get(LOGGER_SERVICE_TOKEN);
32
+ this.localization = injector.get(LOCALIZATION);
33
+ this.variableCommunicator = variableCommunicator;
34
+ this.timePeriods = this.getValidTimePeriods();
35
+ this.currentTimePeriod = this.model.filterSetting.refreshCycle;
36
+ this.pageSize = this.model.generalSetting.pageSize;
37
+ this.currentTimePeriod = this.model.filterSetting.displayPeriod;
38
+ this.updateQueryTimeRange();
39
+ if (this.model.filterSetting.alarmType) {
40
+ this.refreshIntervalId = setInterval(() => {
41
+ this.loadFirstPage();
42
+ this.logger.debug(`[GUI]Refresh Alarm Table:${d3.time.format('%x %X')(new Date())}`);
43
+ }, this.model.filterSetting.refreshCycle * 60 * 1000);
44
+ }
45
+ else {
46
+ variableCommunicator.subscribeUserDeviceAlarms(signalRAppId).subscribe(alarmWithAppId => {
47
+ if (alarmWithAppId.appId !== this.signalRAppId) {
48
+ return;
49
+ }
50
+ const alarm = alarmWithAppId.alarm;
51
+ if (!find(this.model.filterSetting.detailsData, alarmName => alarmName === alarm.name)) {
52
+ return;
53
+ }
54
+ const currentAlarm = this.currentAlarmList.find(re => re.name === alarm.name);
55
+ if (alarm.state === AlarmState.AlarmStateTriggered.valueOf()) {
56
+ if (!isNil(currentAlarm)) {
57
+ return;
58
+ }
59
+ pull(this.currentAlarmList, this.currentAlarmList.find(record => alarm.name === record.name));
60
+ this.currentAlarmList.unshift(alarm);
61
+ this.totalCount += 1;
62
+ }
63
+ else {
64
+ if (isNil(currentAlarm)) {
65
+ return;
66
+ }
67
+ remove(this.currentAlarmList, currentAlarm);
68
+ this.totalCount -= 1;
69
+ }
70
+ this.alarmList = [];
71
+ this.currentAlarmList.forEach(item => {
72
+ this.alarmList.push([
73
+ item.name,
74
+ item.message,
75
+ item.alarmLevel,
76
+ moment(item.triggeredTime).format('YYYY-MM-DD HH:mm:ss')
77
+ ]);
78
+ });
79
+ this.renderElement();
80
+ });
81
+ }
82
+ this.init();
83
+ }
84
+ dispose() {
85
+ clearInterval(this.refreshIntervalId);
86
+ if (this.element) {
87
+ this.element.tooltip.hidden(true);
88
+ }
89
+ this.logger.debug(`[GUI]Dispose Alarm Table Refresh Interval:${d3.time.format('%x %X')(new Date())}`);
90
+ }
91
+ getValidTimePeriods() {
92
+ const timePeriods = new Array();
93
+ timePeriods.push({ key: 6, name: this.localization.lastThirtyMinutes });
94
+ timePeriods.push({ key: 1, name: this.localization.lastOneHour });
95
+ timePeriods.push({ key: 7, name: this.localization.lastEightHour });
96
+ timePeriods.push({ key: 2, name: this.localization.lastTwentyFourHours });
97
+ timePeriods.push({ key: 3, name: this.localization.lastSevenDays });
98
+ timePeriods.push({ key: 4, name: this.localization.lastThirtyDays });
99
+ timePeriods.push({ key: 5, name: this.localization.lastOneYear });
100
+ return timePeriods;
101
+ }
102
+ init() {
103
+ if (this.model.filterSetting.alarmType) {
104
+ const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, this.startTime, this.endTime, this.pageSize, this.page * this.pageSize);
105
+ this.alarmsStore.getHistoryAlarms(input).subscribe(result => {
106
+ this.totalCount = result.totalCount;
107
+ this.alarmList = result.items.map(item => [
108
+ item.name,
109
+ item.message,
110
+ item.alarmLevel,
111
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
112
+ ]);
113
+ this.renderElement();
114
+ });
115
+ }
116
+ else {
117
+ const input = new GetAlarmsArgs(this.model.filterSetting.detailsData, undefined, undefined, this.pageSize, this.page * this.pageSize);
118
+ this.alarmsStore.getCurrentAlarms(input).subscribe(result => {
119
+ this.totalCount = result.totalCount;
120
+ this.currentAlarmList = result.items;
121
+ this.alarmList = this.currentAlarmList.map(item => [
122
+ item.name,
123
+ item.message,
124
+ item.alarmLevel,
125
+ item.triggeredTime.format('YYYY-MM-DD HH:mm:ss')
126
+ ]);
127
+ this.renderElement();
128
+ });
129
+ }
130
+ }
131
+ renderElement() {
132
+ this.rootElement.selectAll('*').remove();
133
+ const elementHeight = this.model.size.height;
134
+ this.element = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
135
+ this.element.setAttribute('width', this.model.size.width.toString());
136
+ this.element.setAttribute('height', elementHeight.toString());
137
+ const table = document.createElement('table');
138
+ table.style.cssText = `border: 2px solid ${this.model.generalSetting.stroke};
139
+ height: ${elementHeight - 39}`;
140
+ let tr = document.createElement('tr');
141
+ let fontString = '';
142
+ if (this.model.generalSetting.headerFont.isItalic) {
143
+ fontString += 'italic ';
144
+ }
145
+ if (this.model.generalSetting.headerFont.isBold) {
146
+ fontString += 'bold ';
147
+ }
148
+ fontString += this.model.generalSetting.headerFont.fontSize + ' ' + this.model.generalSetting.headerFont.fontFamily;
149
+ tr.style.cssText = `height: ${this.model.heights[0]}px;
150
+ background: ${this.model.generalSetting.headerFillColor};
151
+ color: ${this.model.generalSetting.headerFont.color};
152
+ font: ${fontString};
153
+ text-align: ${this.model.generalSetting.headerFont.textAlign};
154
+ ${this.model.generalSetting.headerFont.isUnderline ? 'text-decoration: underline' : ''};
155
+ vertical-align: middle;`;
156
+ for (let i = 0; i < 4; i++) {
157
+ const th = document.createElement('th');
158
+ th.innerHTML = this.model.columLables[i];
159
+ th.style.cssText = `width: ${this.model.widths[i] / this.model.size.width * 100}%;
160
+ border-style: solid;
161
+ border-color: ${this.model.generalSetting.splitLine};
162
+ border-left-width: ${!i || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
163
+ tr.appendChild(th);
164
+ }
165
+ table.appendChild(tr);
166
+ const levelColors = ['#3695FF', '#FFE900', '#FFA800', '#E84F4F'];
167
+ for (let i = 0; i < this.pageSize; i++) {
168
+ tr = document.createElement('tr');
169
+ tr.style.cssText = `height: ${this.model.heights[i + 1]}px;
170
+ background: ${this.model.generalSetting.tableFillColor};
171
+ font: ${this.model.generalSetting.fontStyle};
172
+ color: ${this.model.generalSetting.fontColor};
173
+ text-align: ${this.model.generalSetting.textAlign};
174
+ vertical-align: middle;`;
175
+ for (let j = 0; j < 4; j++) {
176
+ const td = document.createElement('td');
177
+ td.style.cssText = `border-style: solid;
178
+ border-color: ${this.model.generalSetting.splitLine};
179
+ border-top-width: ${this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;
180
+ border-left-width: ${!j || this.model.generalSetting.isHiddenColumnSplitLine ? 0 : 1}px;`;
181
+ if (this.alarmList[i]) {
182
+ if (j !== 2) {
183
+ td.innerHTML = this.alarmList[i][j];
184
+ td.style.cssText += `${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
185
+ }
186
+ else {
187
+ const alarmLevel = document.createElement('div');
188
+ let alarmHeight = parseInt(this.model.generalSetting.fontSize) + 15;
189
+ if (alarmHeight > this.model.heights[i + 1])
190
+ alarmHeight = this.model.heights[i + 1];
191
+ let margin = '0 15px';
192
+ if (this.model.generalSetting.textAlign === 'left') {
193
+ margin = '0 30px 0 0';
194
+ }
195
+ else if (this.model.generalSetting.textAlign === 'right') {
196
+ margin = '0 0 0 30px';
197
+ }
198
+ alarmLevel.style.cssText = `margin: ${margin};
199
+ border-radius: 5px;
200
+ background: ${levelColors[this.alarmList[i][j]]};
201
+ color: #ffffff;
202
+ width: ${this.model.widths[j] - 30}px;
203
+ height: ${alarmHeight}px;
204
+ max-height: ${this.model.heights[i + 1]}px;
205
+ display: flex;
206
+ justify-content: center;
207
+ align-items: center;
208
+ ${this.model.generalSetting.isUnderline ? 'text-decoration: underline' : ''};`;
209
+ alarmLevel.innerHTML = this.model.levelText[this.alarmList[i][j]];
210
+ td.appendChild(alarmLevel);
211
+ }
212
+ }
213
+ tr.appendChild(td);
214
+ }
215
+ table.appendChild(tr);
216
+ }
217
+ this.element.appendChild(table);
218
+ this.$element.append(this.element);
219
+ this.renderOperationArea(this.model.size.width, elementHeight - 39);
220
+ }
221
+ renderOperationArea(chartWidth, chartHeight) {
222
+ const operationArea = this.rootElement.append('g').attr('transform', `translate(0,${chartHeight + this.displayOption.operationAreaMarginTop})`)
223
+ .append('foreignObject').attr('width', chartWidth).attr('height', this.displayOption.operationAreaHeight).attr('fill', 'none')
224
+ .append('xhtml:div').style('height', (this.displayOption.operationAreaHeight - 4) + 'px').style('overflow', 'hidden').style('margin-top', '4px');
225
+ if (this.model.filterSetting.alarmType) {
226
+ const selectElement = operationArea.append('select').style('margin-left', this.displayOption.marginLeft + 'px')
227
+ .style('font-size', this.displayOption.operationSelectFontSize).on('change', () => {
228
+ const displayTimePeriod = this.rootElement.select('select').property('value');
229
+ this.updateTimeRange(displayTimePeriod);
230
+ this.init();
231
+ });
232
+ const options = selectElement.selectAll('option').data(this.timePeriods).enter().append('option');
233
+ options.text(d => d.name).attr('value', d => d.key).property('selected', d => d.key === Number(this.currentTimePeriod));
234
+ }
235
+ const buttonWidth = this.displayOption.operationButtonWidth + 'px', buttonHeight = this.displayOption.operationButtonHeight + 'px';
236
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
237
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/last_page.svg)')
238
+ .on('click', () => { this.loadLastPage(); });
239
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
240
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/next_page.svg)')
241
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
242
+ .on('click', () => { this.loadNextPage(); });
243
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
244
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/previous_page.svg)')
245
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
246
+ .on('click', () => { this.loadPreviousPage(); });
247
+ operationArea.append('button').style('width', buttonWidth).style('height', buttonHeight).style('border', 'none')
248
+ .style('float', 'right').style('background', 'white').style('background-image', 'url(assets/img/first_page.svg)')
249
+ .style('margin', `0 ${this.displayOption.operationButtonMargin}px 0 0`)
250
+ .on('click', () => { this.loadFirstPage(); });
251
+ }
252
+ updateTimeRange(timePeriodType) {
253
+ this.currentTimePeriod = +timePeriodType;
254
+ this.updateQueryTimeRange();
255
+ }
256
+ updateQueryTimeRange() {
257
+ this.endTime = moment();
258
+ switch (this.currentTimePeriod) {
259
+ case 1:
260
+ this.startTime = moment().subtract(1, 'hours');
261
+ break;
262
+ case 3:
263
+ this.startTime = moment().subtract(7, 'days');
264
+ break;
265
+ case 4:
266
+ this.startTime = moment().subtract(30, 'days');
267
+ break;
268
+ case 5:
269
+ this.startTime = moment().subtract(1, 'years');
270
+ break;
271
+ case 6:
272
+ this.startTime = moment().subtract(30, 'minutes');
273
+ break;
274
+ case 7:
275
+ this.startTime = moment().subtract(8, 'hours');
276
+ break;
277
+ default:
278
+ this.startTime = moment().subtract(1, 'days');
279
+ }
280
+ }
281
+ loadFirstPage() {
282
+ this.page = 0;
283
+ this.init();
284
+ }
285
+ loadNextPage() {
286
+ const last_page = Math.ceil(this.totalCount / this.pageSize) - 1;
287
+ if (this.page < last_page) {
288
+ this.page++;
289
+ }
290
+ this.init();
291
+ }
292
+ loadPreviousPage() {
293
+ if (this.page > 0) {
294
+ this.page--;
295
+ }
296
+ this.init();
297
+ }
298
+ loadLastPage() {
299
+ this.page = Math.ceil(this.totalCount / this.pageSize) - 1;
300
+ this.init();
301
+ }
302
+ }
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmElement":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../base/conditional-display-element","name":"ConditionalDisplayElement","line":17,"character":34},"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"error","message":"Could not resolve type","line":48,"character":25,"context":{"typeName":"HTMLElement"}},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":49,"character":18},{"__symbolic":"reference","module":"../../service","name":"PermissionChecker","line":50,"character":27},{"__symbolic":"reference","module":"../../communication","name":"VariableCommunicator","line":51,"character":30},{"__symbolic":"reference","module":"../../config","name":"VariableStore","line":52,"character":23},{"__symbolic":"reference","module":"../../config","name":"AlarmsStore","line":53,"character":38},{"__symbolic":"reference","name":"string"}]}],"dispose":[{"__symbolic":"method"}],"getValidTimePeriods":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"renderElement":[{"__symbolic":"method"}],"renderOperationArea":[{"__symbolic":"method"}],"updateTimeRange":[{"__symbolic":"method"}],"updateQueryTimeRange":[{"__symbolic":"method"}],"loadFirstPage":[{"__symbolic":"method"}],"loadNextPage":[{"__symbolic":"method"}],"loadPreviousPage":[{"__symbolic":"method"}],"loadLastPage":[{"__symbolic":"method"}]}}}}]
@@ -0,0 +1,4 @@
1
+ export declare enum AlarmState {
2
+ AlarmStateTriggered = 1,
3
+ AlarmStateRecovered = 0
4
+ }
@@ -0,0 +1,5 @@
1
+ export var AlarmState;
2
+ (function (AlarmState) {
3
+ AlarmState[AlarmState["AlarmStateTriggered"] = 1] = "AlarmStateTriggered";
4
+ AlarmState[AlarmState["AlarmStateRecovered"] = 0] = "AlarmStateRecovered";
5
+ })(AlarmState || (AlarmState = {}));
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmState":{"AlarmStateTriggered":1,"AlarmStateRecovered":0}}}]
@@ -28,6 +28,7 @@ import { HyperlinkElement } from './static-elements/hyperlink-element';
28
28
  import { VideoElement } from './video/video-element';
29
29
  import { WeatherElement } from './weather/weater-element';
30
30
  import { AirQualityElement } from './air-quality/air-quality-element';
31
+ import { AlarmElement } from './alarm/alarm-element';
31
32
  export class MainElement {
32
33
  constructor(injector, bsModalService, context, variableCommunicator, popupViewService, signalRAppId) {
33
34
  this.injector = injector;
@@ -129,6 +130,9 @@ export class MainElement {
129
130
  case GuiConsts.components.airQualityKey:
130
131
  this.elements.push(new AirQualityElement(element, this.injector, this.context.permissionChecker, this.variableCommunicator, this.context.configStore.variableStore, this.context.weatherService, this.signalRAppId));
131
132
  break;
133
+ case GuiConsts.components.alarmKey:
134
+ this.elements.push(new AlarmElement(element, this.injector, this.context.permissionChecker, this.variableCommunicator, this.context.configStore.variableStore, this.context.configStore.alarmsStore, this.signalRAppId));
135
+ break;
132
136
  }
133
137
  });
134
138
  this.initBackground();
@@ -1 +1 @@
1
- [{"__symbolic":"module","version":4,"metadata":{"MainElement":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":54,"character":43},{"__symbolic":"reference","module":"ngx-bootstrap/modal","name":"BsModalService","line":55,"character":41},{"__symbolic":"reference","module":"../gui/gui-context","name":"GuiContext","line":56,"character":34},{"__symbolic":"reference","module":"../communication","name":"VariableCommunicator","line":57,"character":47},{"__symbolic":"reference","module":"../view/popup-view.service","name":"PopupViewService","line":58,"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"}],"reportVariableValues":[{"__symbolic":"method"}],"dispose":[{"__symbolic":"method"}],"checkIsLoaded":[{"__symbolic":"method"}],"initBackground":[{"__symbolic":"method"}],"getImageEl":[{"__symbolic":"method"}]}}}}]
@@ -6,6 +6,7 @@ export declare class PerViewVariableCommunicator implements VariableCommunicator
6
6
  private observers;
7
7
  private variableValuesChangedSubscriptions;
8
8
  private variableStatesChangedSubscription;
9
+ private alarmSubscription;
9
10
  constructor(variableCommunicator: VariableCommunicator);
10
11
  openVariable(variableName: string, appId: string): Observable<VariableValue>;
11
12
  openVariables(variableNames: Array<string>, appId?: string): Observable<Array<VariableValue>>;
@@ -13,5 +14,6 @@ export declare class PerViewVariableCommunicator implements VariableCommunicator
13
14
  writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
14
15
  subscribeVariableState(variableName: string): Observable<VariableState>;
15
16
  subscribeVariableStates(variableNames: string[]): Observable<Array<VariableState>>;
17
+ subscribeUserDeviceAlarms(appId?: string): Observable<VariableState[]>;
16
18
  dispose(): void;
17
19
  }
@@ -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"}]}}}}]
@@ -0,0 +1,13 @@
1
+ import { ConditionalDisplayModel } from '../base/conditional-display-model';
2
+ import { Point, Size } from '../shared';
3
+ export interface AlarmModel extends ConditionalDisplayModel {
4
+ readonly version: number;
5
+ readonly size: Size;
6
+ readonly location: Point;
7
+ readonly generalSetting?: any;
8
+ readonly filterSetting?: any;
9
+ readonly widths: number[];
10
+ readonly heights: number[];
11
+ readonly columLables: string[];
12
+ readonly levelText: string[];
13
+ }
File without changes
@@ -0,0 +1 @@
1
+ [{"__symbolic":"module","version":4,"metadata":{"AlarmModel":{"__symbolic":"interface"}}}]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "main": "bundles/fc-gui.umd.js",
3
- "version": "3.0.0-alpha.61",
3
+ "version": "3.0.0-alpha.63",
4
4
  "module": "public_api.js",
5
5
  "typings": "public_api.d.ts",
6
6
  "license": "UNLICENSED",
@@ -17,7 +17,10 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
17
17
  private variableStateCache;
18
18
  private variableStatesToBeOpened;
19
19
  private variableStatesToBeClosed;
20
+ private alarmObservers;
21
+ private alarmChangedSubscription;
20
22
  constructor(remoteVariableProtocol: RemoteVariableProtocol, logger: LoggerService);
23
+ private doAlarmChanged;
21
24
  private doVariableValuesChanged;
22
25
  private doVariableStatesChanged;
23
26
  subscribeVariableStates(variableNames: string[]): Observable<VariableState[]>;
@@ -26,5 +29,6 @@ export declare class RemoteVariableCommunicator implements VariableCommunicator
26
29
  openVariable(variableName: string, appId?: string): Observable<VariableValue>;
27
30
  write(variableName: string, value: any): Observable<VariableValue>;
28
31
  writeWordByBit(variableName: string, index: number, value: number): Observable<VariableValue>;
32
+ subscribeUserDeviceAlarms(appId?: string): Observable<any[]>;
29
33
  dispose(): void;
30
34
  }
@@ -10,6 +10,7 @@ export class RemoteVariableCommunicator {
10
10
  this.appIdVariablesMap = new Map();
11
11
  this.variableStateObservers = new Map();
12
12
  this.variableStateCache = new Map();
13
+ this.alarmObservers = [];
13
14
  this.variableValueCache = new StringifyingMap(k => JSON.stringify(k));
14
15
  this.connectedSubscription = this.remoteVariableProtocol.connected.subscribe(() => {
15
16
  const variableNamesToStart = [];
@@ -23,6 +24,17 @@ export class RemoteVariableCommunicator {
23
24
  });
24
25
  this.doVariableStatesChanged();
25
26
  this.doVariableValuesChanged();
27
+ this.doAlarmChanged();
28
+ }
29
+ doAlarmChanged() {
30
+ if (this.alarmChangedSubscription !== undefined) {
31
+ this.alarmChangedSubscription.unsubscribe();
32
+ }
33
+ this.alarmChangedSubscription = this.remoteVariableProtocol.historyAlarmChanged.subscribe((alarmWithAppId) => {
34
+ each(this.alarmObservers, ob => {
35
+ ob.next(alarmWithAppId);
36
+ });
37
+ });
26
38
  }
27
39
  doVariableValuesChanged() {
28
40
  if (this.variableValuesChangedSubscription !== undefined) {
@@ -203,11 +215,21 @@ export class RemoteVariableCommunicator {
203
215
  observer.next(new VariableValue(variable, VariableStateEnum.DataNormal, value))*/
204
216
  });
205
217
  }
218
+ subscribeUserDeviceAlarms(appId = '') {
219
+ return new Observable(observer => {
220
+ this.alarmObservers.push(observer);
221
+ this.remoteVariableProtocol.subscribeUserDeviceAlarms(appId);
222
+ return () => {
223
+ this.remoteVariableProtocol.unSubscribeUserDeviceAlarms(appId);
224
+ };
225
+ });
226
+ }
206
227
  dispose() {
207
228
  // TODO调用所有的ob.complete()。
208
229
  this.connectedSubscription.unsubscribe();
209
230
  this.variableStatesChangedSubscription.unsubscribe();
210
231
  this.variableValuesChangedSubscription.unsubscribe();
232
+ this.alarmChangedSubscription.unsubscribe();
211
233
  if (this.logger && this.logger.isDebugEnabled()) {
212
234
  this.logger.debug('[VariableCommunicator] RemoteVariableCommunicator disposed.');
213
235
  }