@denevads/dnv-smo 1.0.14 → 1.0.15

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/dist/smo.js CHANGED
@@ -1,590 +1,605 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
4
- var rxjs_1 = require("rxjs");
5
- var SMO = /** @class */ (function () {
6
- function SMO() {
7
- this.vars = {};
8
- this.id = "";
9
- this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
10
- this.initOnMessage();
11
- this.smoCallBacks = new smoCallBacks(this);
12
- this.utils = new Utils(this, this.smoCallBacks);
13
- this.events = new SmoEvents(this);
14
- this.init();
15
- }
16
- SMO.prototype.init = function () {
17
- var _this = this;
18
- var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
19
- return decodeURIComponent(s.replace(pl, " "));
20
- }, query = window.location.search.substring(1);
21
- while (match = search.exec(query)) {
22
- this.vars[decode(match[1])] = decode(match[2]);
23
- }
24
- if (this.vars.idSmo) {
25
- this.id = this.vars.idSmo;
26
- if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
27
- this.smoCallBacks.onSmoLoad();
28
- return;
29
- }
30
- if (this.vars["url"] != undefined) {
31
- this.smoCallBacks.getFile(this.vars["url"]);
32
- this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
33
- _this.smoCallBacks.getFile(_this.vars["url"]);
34
- });
35
- return;
36
- }
37
- if (this.vars["LocalData"] != undefined) {
38
- this.smoCallBacks.getLocalData(this.vars["LocalData"]);
39
- this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
40
- _this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
41
- });
42
- return;
43
- }
44
- return;
45
- }
46
- console.warn("No idSmo found in URL");
47
- };
48
- SMO.prototype.initOnMessage = function () {
49
- var selft = this;
50
- window.onmessage = function (e) {
51
- if (e.data.target) {
52
- var targets = e.data.target.split('.');
53
- var func = targets[targets.length - 1];
54
- if (func == SMO_EVENT_TYPE.start) {
55
- selft.start();
56
- return;
57
- }
58
- if (func == SMO_EVENT_TYPE.setDatasource) {
59
- selft.setDatasource(e.data.objData);
60
- return;
61
- }
62
- if (func == SMO_EVENT_TYPE.getVariable) {
63
- selft.getVariable(e.data.objData);
64
- return;
65
- }
66
- if (func == SMO_EVENT_TYPE.setCurrentStream) {
67
- selft.setCurrentStream(e.data.objData);
68
- return;
69
- }
70
- if (func == SMO_EVENT_TYPE.infoCurrentLocation) {
71
- selft.infoCurrentLocation(e.data.objData);
72
- return;
73
- }
74
- if (func == SMO_EVENT_TYPE.setSalidaData) {
75
- selft.setSalidaData(e.data.objData);
76
- return;
77
- }
78
- if (func == SMO_EVENT_TYPE.updatefromsalida) {
79
- selft.updatefromsalida(e.data.objdata);
80
- return;
81
- }
82
- if (func == SMO_EVENT_TYPE.getRecursos) {
83
- selft.getRecursos(e.data.objData);
84
- }
85
- if (func == SMO_EVENT_TYPE.getRecursosDefault) {
86
- selft.getRecursosDefault(e.data.objData);
87
- }
88
- if (func == SMO_EVENT_TYPE.getRecursosRelleno) {
89
- selft.getRecursosRelleno(e.data.objData);
90
- return;
91
- }
92
- if (func == SMO_EVENT_TYPE.getVariableStorage) {
93
- selft.getVariableStorage(e.data.objData);
94
- return;
95
- }
96
- if (func == SMO_EVENT_TYPE.checkHealth) {
97
- selft.checkHealth(e.data.objData);
98
- return;
99
- }
100
- console.warn("message not implemented!!" + func);
101
- }
102
- };
103
- };
104
- SMO.prototype.start = function () {
105
- this.events.start.next({});
106
- };
107
- SMO.prototype.setDatasource = function (datasource) {
108
- this.events.setDatasource.next(datasource);
109
- this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
110
- };
111
- SMO.prototype.getVariable = function (variable) {
112
- this.events.getVariable.next(variable);
113
- };
114
- SMO.prototype.setCurrentStream = function (stream) {
115
- this.events.setCurrentStream.next(stream);
116
- };
117
- SMO.prototype.infoCurrentLocation = function (location) {
118
- this.events.infoCurrentLocation.next(location);
119
- };
120
- SMO.prototype.setSalidaData = function (data) {
121
- this.events.setSalidaData.next(data);
122
- };
123
- SMO.prototype.updatefromsalida = function (data) {
124
- this.events.updatefromsalida.next(data);
125
- };
126
- SMO.prototype.getRecursos = function (data) {
127
- this.events.getRecursos.next(data);
128
- };
129
- SMO.prototype.getRecursosDefault = function (data) {
130
- this.events.getRecursosDefault.next(data);
131
- };
132
- SMO.prototype.getRecursosRelleno = function (data) {
133
- this.events.getRecursosRelleno.next(data);
134
- };
135
- SMO.prototype.getVariableStorage = function (variable) {
136
- this.events.getVariableStorage.next(variable);
137
- };
138
- SMO.prototype.checkHealth = function (variable) {
139
- this.events.checkHealth.next(variable);
140
- };
141
- return SMO;
142
- }());
143
- exports.SMO = SMO;
144
- var SmoEvents = /** @class */ (function () {
145
- function SmoEvents(smo) {
146
- this.start = new rxjs_1.Subject();
147
- this.setDatasource = new rxjs_1.Subject();
148
- this.setDatasourceJson = new rxjs_1.Subject();
149
- this.getVariable = new rxjs_1.Subject();
150
- this.setCurrentStream = new rxjs_1.Subject();
151
- this.infoCurrentLocation = new rxjs_1.Subject();
152
- this.setSalidaData = new rxjs_1.Subject();
153
- this.updatefromsalida = new rxjs_1.Subject();
154
- this.getRecursos = new rxjs_1.Subject();
155
- this.getRecursosDefault = new rxjs_1.Subject();
156
- this.getRecursosRelleno = new rxjs_1.Subject();
157
- this.getVariableStorage = new rxjs_1.Subject();
158
- this.checkHealth = new rxjs_1.Subject();
159
- }
160
- return SmoEvents;
161
- }());
162
- var smoCallBacks = /** @class */ (function () {
163
- function smoCallBacks(_smo) {
164
- this.smo = _smo;
165
- }
166
- smoCallBacks.prototype.onSmoLoad = function () {
167
- window.parent.postMessage({
168
- target: "Dnv.smoCallbacks.onSmoLoad",
169
- objData: undefined,
170
- idSmo: this.smo.id
171
- }, "*");
172
- };
173
- smoCallBacks.prototype.onSmoReady = function () {
174
- window.parent.postMessage({
175
- target: "Dnv.smoCallbacks.onSmoReady",
176
- objData: undefined,
177
- idSmo: this.smo.id
178
- }, "*");
179
- };
180
- smoCallBacks.prototype.smoLog = function (msn, level) {
181
- if (level == undefined) {
182
- level = LogLevel.Info;
183
- }
184
- //level = Dnv.LogLevel.Debug...
185
- if (level == LogLevel.Debug) {
186
- console.debug(msn);
187
- }
188
- if (level == LogLevel.Info) {
189
- console.log(msn);
190
- }
191
- if (level == LogLevel.Warning) {
192
- console.warn(msn);
193
- }
194
- if (level == LogLevel.Error) {
195
- console.error(msn);
196
- }
197
- if (window.parent != window) {
198
- window.parent.postMessage({
199
- target: "Dnv.smoCallbacks.smoLog",
200
- objData: {
201
- level: level,
202
- txt: msn
203
- },
204
- idSmo: this.smo.id
205
- }, "*");
206
- }
207
- };
208
- smoCallBacks.prototype.smoAlarma = function (msn, level) {
209
- window.parent.postMessage({
210
- target: "Dnv.smoCallbacks.smoAlarma",
211
- objData: {
212
- level: level,
213
- txt: msn
214
- },
215
- idSmo: this.smo.id
216
- }, "*");
217
- };
218
- smoCallBacks.prototype.smoLogStash = function (msn) {
219
- window.parent.postMessage({
220
- target: "Dnv.smoCallbacks.smoLogStash",
221
- objData: {
222
- txt: msn
223
- },
224
- idSmo: this.smo.id
225
- }, "*");
226
- };
227
- smoCallBacks.prototype.smoLogNowShowing = function (msn) {
228
- window.parent.postMessage({
229
- target: "Dnv.smoCallbacks.smoNowShowing",
230
- objData: msn,
231
- idSmo: this.smo.id
232
- }, "*");
233
- };
234
- smoCallBacks.prototype.reiniciarDispositivo = function (msn) {
235
- //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
236
- window.parent.postMessage({
237
- target: "Dnv.smoCallbacks.reiniciarDispositivo",
238
- objData: {
239
- txt: msn // Razón del reinicio
240
- },
241
- idSmo: this.smo.id
242
- }, "*");
243
- };
244
- smoCallBacks.prototype.urlNext = function () {
245
- //Permite avanzar plantilla. Solo si Reloj Maestro activado.
246
- window.parent.postMessage({
247
- target: "Dnv.smoCallbacks.urlNext",
248
- objData: undefined,
249
- idSmo: this.smo.id
250
- }, "*");
251
- };
252
- smoCallBacks.prototype.exitInteractivity = function () {
253
- //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
254
- window.parent.postMessage({
255
- target: "Dnv.smoCallbacks.exitInteractivity",
256
- objData: undefined,
257
- idSmo: this.smo.id
258
- }, "*");
259
- };
260
- smoCallBacks.prototype.showBrowser = function () {
261
- /* DEPRECATED NOT IMPLEMENTED */
262
- };
263
- smoCallBacks.prototype.closeBrowser = function () {
264
- /* DEPRECATED NOT IMPLEMENTED */
265
- };
266
- smoCallBacks.prototype.urlNextDirectamente = function () {
267
- /* NOT IMPLEMENTED */
268
- };
269
- smoCallBacks.prototype.setVariable = function (variable, valor) {
270
- window.parent.postMessage({
271
- target: "Dnv.smoCallbacks.setVariable",
272
- objData: {
273
- variable: variable,
274
- valor: valor
275
- },
276
- idSmo: this.smo.id
277
- }, "*");
278
- };
279
- smoCallBacks.prototype.getVariable = function (variable) {
280
- window.parent.postMessage({
281
- target: "Dnv.smoCallbacks.getVariable",
282
- objData: {
283
- variable: variable
284
- },
285
- idSmo: this.smo.id
286
- }, "*");
287
- /* MIRAR SMO.getVariable */
288
- };
289
- smoCallBacks.prototype.getFile = function (file) {
290
- parent.postMessage({
291
- target: "Dnv.smoCallbacks.getFile",
292
- objData: file,
293
- idSmo: this.smo.id
294
- }, "*");
295
- };
296
- smoCallBacks.prototype.setLocalData = function (variable, valor) {
297
- parent.postMessage({
298
- target: "Dnv.smoCallbacks.setLocalData",
299
- objData: {
300
- nameData: variable,
301
- data: valor
302
- },
303
- idSmo: this.smo.id
304
- }, "*");
305
- };
306
- smoCallBacks.prototype.getLocalData = function (variable) {
307
- parent.postMessage({
308
- target: "Dnv.smoCallbacks.getLocalData",
309
- objData: variable,
310
- idSmo: this.smo.id
311
- }, "*");
312
- /* MIRAR SMO.setDatasource */
313
- };
314
- smoCallBacks.prototype.getCurrentStream = function () {
315
- parent.postMessage({
316
- target: "Dnv.smoCallbacks.getCurrentStream",
317
- objData: undefined,
318
- idSmo: this.smo.id
319
- }, "*");
320
- /* MIRAR SMO.setCurrentStream' */
321
- };
322
- smoCallBacks.prototype.finAviso = function (id) {
323
- parent.postMessage({
324
- target: "Dnv.smoCallbacks.finAviso",
325
- objData: id,
326
- idSmo: this.smo.id
327
- }, "*");
328
- };
329
- smoCallBacks.prototype.refreshDatasource = function (codigo) {
330
- parent.postMessage({
331
- target: "Dnv.smoCallbacks.refreshDatasource",
332
- objData: codigo,
333
- idSmo: this.smo.id
334
- }, "*");
335
- };
336
- smoCallBacks.prototype.getLocation = function () {
337
- parent.postMessage({
338
- target: "Dnv.smoCallbacks.getLocation",
339
- objData: undefined,
340
- idSmo: this.smo.id
341
- }, "*");
342
- /* MIRAR SMO.infoCurrentLocation */
343
- };
344
- smoCallBacks.prototype.getSalidaData = function (data) {
345
- parent.postMessage({
346
- target: "Dnv.smoCallbacks.getSalidaData",
347
- objData: data,
348
- idSmo: this.smo.id
349
- }, "*");
350
- /* MIRAR SMO.setSalidaData */
351
- };
352
- smoCallBacks.prototype.ejecutaFuncion = function (data) {
353
- /*data ={
354
- funcion: "", // Nombre de la función que se debe ejecutar
355
- params: "" // Parámetros que debemos enviarle a la funcion. sin separadores ni nada, un string y se usa como tal. Solo esta implementada en un caso y se usa como tal sin parsear ni nada
356
- } */
357
- parent.postMessage({
358
- target: "Dnv.smoCallbacks.ejecutaFuncion",
359
- objData: data,
360
- idSmo: this.smo.id
361
- }, "*");
362
- };
363
- smoCallBacks.prototype.addObserver = function (data) {
364
- /*data ="fruta"
365
- */
366
- parent.postMessage({
367
- target: "Dnv.smoCallbacks.addObserver",
368
- objData: data,
369
- idSmo: this.smo.id
370
- }, "*");
371
- };
372
- smoCallBacks.prototype.notify = function (data) {
373
- /*data ={
374
- destino: "fruta",
375
- value: "{'fruta':'manzana', 'color':'roja'}"
376
- } */
377
- parent.postMessage({
378
- target: "Dnv.smoCallbacks.notify",
379
- objData: data,
380
- idSmo: this.smo.id
381
- }, "*");
382
- };
383
- smoCallBacks.prototype.playOnceChannelByTrigger = function (trigger) {
384
- parent.postMessage({
385
- target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
386
- objData: { triggerCanal: trigger },
387
- idSmo: this.smo.id
388
- }, "*");
389
- };
390
- smoCallBacks.prototype.stopPlayOnceChannelByTrigger = function () {
391
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
392
- };
393
- smoCallBacks.prototype.playOnceChannel = function (codigoCanal) {
394
- parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
395
- };
396
- smoCallBacks.prototype.stopPlayChannel = function () {
397
- parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
398
- };
399
- smoCallBacks.prototype.editWrapperStyle = function (obj) {
400
- /*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true,duracionTransition: "1s", transitionTiming: "lineal", css: string} */
401
- parent.postMessage({
402
- target: "Dnv.smoCallbacks.editWrapperStyle",
403
- objData: obj,
404
- idSmo: this.smo.id
405
- }, "*");
406
- };
407
- smoCallBacks.prototype.getRecursos = function () {
408
- parent.postMessage({
409
- target: "Dnv.smoCallbacks.getRecursos",
410
- idSmo: this.smo.id
411
- }, "*");
412
- };
413
- smoCallBacks.prototype.getRecursosDefault = function () {
414
- parent.postMessage({
415
- target: "Dnv.smoCallbacks.getRecursosDefault",
416
- idSmo: this.smo.id
417
- }, "*");
418
- };
419
- smoCallBacks.prototype.getRecursosRelleno = function () {
420
- parent.postMessage({
421
- target: "Dnv.smoCallbacks.getRecursosRelleno",
422
- idSmo: this.smo.id
423
- }, "*");
424
- };
425
- smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
426
- window.parent.postMessage({
427
- target: "Dnv.smoCallbacks.setVariableStorage",
428
- objData: {
429
- variable: variable,
430
- valor: valor
431
- },
432
- idSmo: this.smo.id
433
- }, "*");
434
- };
435
- smoCallBacks.prototype.getVariableStorage = function (variable) {
436
- window.parent.postMessage({
437
- target: "Dnv.smoCallbacks.getVariableStorage",
438
- objData: {
439
- variable: variable
440
- },
441
- idSmo: this.smo.id
442
- }, "*");
443
- /* MIRAR SMO.getVariable */
444
- };
445
- smoCallBacks.prototype.printTextLine = function (txt) {
446
- window.parent.postMessage({
447
- target: "Dnv.smoCallbacks.printTextLine",
448
- objData: {
449
- txt: txt
450
- },
451
- idSmo: this.smo.id
452
- }, "*");
453
- };
454
- smoCallBacks.prototype.printBarcode = function (code, width, height) {
455
- window.parent.postMessage({
456
- target: "Dnv.smoCallbacks.printBarcode",
457
- objData: {
458
- code: code,
459
- width: width,
460
- height: height
461
- },
462
- idSmo: this.smo.id
463
- }, "*");
464
- };
465
- smoCallBacks.prototype.cutPaper = function (percent) {
466
- window.parent.postMessage({
467
- target: "Dnv.smoCallbacks.cutPaper",
468
- objData: {
469
- percent: percent
470
- },
471
- idSmo: this.smo.id
472
- }, "*");
473
- };
474
- smoCallBacks.prototype.checkHealth = function () {
475
- window.parent.postMessage({
476
- target: "Dnv.smoCallbacks.checkHealth",
477
- idSmo: this.smo.id
478
- }, "*");
479
- };
480
- smoCallBacks.prototype.printImage = function (image) {
481
- window.parent.postMessage({
482
- target: "Dnv.smoCallbacks.printImage",
483
- objData: {
484
- image: image
485
- },
486
- idSmo: this.smo.id
487
- }, "*");
488
- };
489
- return smoCallBacks;
490
- }());
491
- var Utils = /** @class */ (function () {
492
- function Utils(_smo, _smoCallBacks) {
493
- this.smo = _smo;
494
- this.smoCallBacks = _smoCallBacks;
495
- }
496
- // Funciones para XML to JSON
497
- Utils.prototype.xmlToJSON = function (xml) {
498
- var getxml = new DOMParser();
499
- var xmlDoc = getxml.parseFromString(xml, "text/xml");
500
- // gets the JSON string
501
- var json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
502
- // sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
503
- return json_str;
504
- };
505
- Utils.prototype.jsonToStr = function (js_obj) {
506
- var rejsn = JSON.stringify(js_obj, undefined, 2).replace(/(\\t|\\r|\\n)/g, '').replace(/"",[\n\t\r\s]+""[,]*/g, '').replace(/(\n[\t\s\r]*\n)/g, '').replace(/[\s\t]{2,}""[,]{0,1}/g, '').replace(/"[\s\t]{1,}"[,]{0,1}/g, '').replace(/\[[\t\s]*\]/g, '""');
507
- return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
508
- };
509
- Utils.prototype.setJsonObj = function (xml) {
510
- var js_obj = {};
511
- if (xml.nodeType == 1) { // Element
512
- if (xml.attributes.length > 0) {
513
- js_obj["@attributes"] = {};
514
- for (var j = 0; j < xml.attributes.length; j++) {
515
- var attribute = xml.attributes.item(j);
516
- js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
517
- }
518
- }
519
- }
520
- else if (xml.nodeType == 3) { // Text
521
- js_obj = xml.nodeValue;
522
- }
523
- else if (xml.nodeType == 4) { // CDATA
524
- js_obj = xml.nodeValue;
525
- }
526
- if (xml.hasChildNodes()) {
527
- for (var i = 0; i < xml.childNodes.length; i++) {
528
- var item = xml.childNodes.item(i);
529
- var nodeName = item.nodeName;
530
- if (typeof (js_obj[nodeName]) == "undefined") {
531
- js_obj[nodeName] = this.setJsonObj(item);
532
- }
533
- else {
534
- if (typeof (js_obj[nodeName].push) == "undefined") {
535
- var old = js_obj[nodeName];
536
- js_obj[nodeName] = [];
537
- js_obj[nodeName].push(old);
538
- }
539
- js_obj[nodeName].push(this.setJsonObj(item));
540
- }
541
- }
542
- }
543
- return js_obj;
544
- };
545
- Utils.prototype.dataToJSON = function (data) {
546
- try {
547
- var parser = new DOMParser();
548
- var xmlDoc = parser.parseFromString(data.xml, "text/xml");
549
- var dataForJSON = xmlDoc.getElementsByTagName("item")[0].innerHTML;
550
- dataForJSON = dataForJSON.replace(/{'/g, '{"').replace(/'}/g, '"}').replace(/:'/g, ':"').replace(/':/g, '":').replace(/,'/g, ',"').replace(/',/g, '",').replace(/\['/g, '["').replace(/'\]/g, '"]').replace(/(\r\n|\n|\r)/gm, "");
551
- return JSON.parse(dataForJSON);
552
- }
553
- catch (error) {
554
- return {};
555
- }
556
- };
557
- return Utils;
558
- }());
559
- var SMO_EVENT_TYPE;
560
- (function (SMO_EVENT_TYPE) {
561
- SMO_EVENT_TYPE["start"] = "start";
562
- SMO_EVENT_TYPE["setDatasource"] = "setDatasource";
563
- SMO_EVENT_TYPE["getVariable"] = "getVariable";
564
- SMO_EVENT_TYPE["setCurrentStream"] = "setCurrentStream";
565
- SMO_EVENT_TYPE["infoCurrentLocation"] = "infoCurrentLocation";
566
- SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
567
- SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
568
- SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
569
- SMO_EVENT_TYPE["getRecursos"] = "getRecursos";
570
- SMO_EVENT_TYPE["getRecursosDefault"] = "getRecursosDefault";
571
- SMO_EVENT_TYPE["getRecursosRelleno"] = "getRecursosRelleno";
572
- SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
573
- SMO_EVENT_TYPE["checkHealth"] = "checkHealth";
574
- })(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
575
- var LogLevel;
576
- (function (LogLevel) {
577
- LogLevel[LogLevel["Debug"] = 0] = "Debug";
578
- LogLevel[LogLevel["Info"] = 1] = "Info";
579
- LogLevel[LogLevel["Warning"] = 2] = "Warning";
580
- LogLevel[LogLevel["Error"] = 3] = "Error";
581
- })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
582
- var AlarmaLevel;
583
- (function (AlarmaLevel) {
584
- AlarmaLevel[AlarmaLevel["Ok_off"] = 0] = "Ok_off";
585
- AlarmaLevel[AlarmaLevel["Ok"] = 1] = "Ok";
586
- AlarmaLevel[AlarmaLevel["Scanning"] = 2] = "Scanning";
587
- AlarmaLevel[AlarmaLevel["Timeout"] = 3] = "Timeout";
588
- AlarmaLevel[AlarmaLevel["Warning"] = 4] = "Warning";
589
- AlarmaLevel[AlarmaLevel["Error"] = 5] = "Error";
590
- })(AlarmaLevel = exports.AlarmaLevel || (exports.AlarmaLevel = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlarmaLevel = exports.LogLevel = exports.SMO_EVENT_TYPE = exports.SMO = void 0;
4
+ var rxjs_1 = require("rxjs");
5
+ var SMO = /** @class */ (function () {
6
+ function SMO() {
7
+ this.vars = {};
8
+ this.id = "";
9
+ this.intervalDataSource$ = (0, rxjs_1.interval)(5 * 60 * 1000);
10
+ this.initOnMessage();
11
+ this.smoCallBacks = new smoCallBacks(this);
12
+ this.utils = new Utils(this, this.smoCallBacks);
13
+ this.events = new SmoEvents(this);
14
+ this.init();
15
+ }
16
+ SMO.prototype.init = function () {
17
+ var _this = this;
18
+ var match, pl = /\+/g, search = /([^&=]+)=?([^&]*)/g, decode = function (s) {
19
+ return decodeURIComponent(s.replace(pl, " "));
20
+ }, query = window.location.search.substring(1);
21
+ while (match = search.exec(query)) {
22
+ this.vars[decode(match[1])] = decode(match[2]);
23
+ }
24
+ if (this.vars.idSmo) {
25
+ this.id = this.vars.idSmo;
26
+ if (this.vars["LowPower"] == "true" && (this.vars["url"] != undefined || this.vars["LocalData"] != undefined)) {
27
+ this.smoCallBacks.onSmoLoad();
28
+ return;
29
+ }
30
+ if (this.vars["url"] != undefined) {
31
+ this.smoCallBacks.getFile(this.vars["url"]);
32
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
33
+ _this.smoCallBacks.getFile(_this.vars["url"]);
34
+ });
35
+ return;
36
+ }
37
+ if (this.vars["LocalData"] != undefined) {
38
+ this.smoCallBacks.getLocalData(this.vars["LocalData"]);
39
+ this.intervalsubscriptionDataSource = this.intervalDataSource$.subscribe(function () {
40
+ _this.smoCallBacks.getLocalData(_this.vars["LocalData"]);
41
+ });
42
+ return;
43
+ }
44
+ return;
45
+ }
46
+ console.warn("No idSmo found in URL");
47
+ };
48
+ SMO.prototype.initOnMessage = function () {
49
+ var selft = this;
50
+ window.onmessage = function (e) {
51
+ if (e.data.target) {
52
+ var targets = e.data.target.split('.');
53
+ var func = targets[targets.length - 1];
54
+ if (func == SMO_EVENT_TYPE.start) {
55
+ selft.start();
56
+ return;
57
+ }
58
+ if (func == SMO_EVENT_TYPE.setDatasource) {
59
+ selft.setDatasource(e.data.objData);
60
+ return;
61
+ }
62
+ if (func == SMO_EVENT_TYPE.getVariable) {
63
+ selft.getVariable(e.data.objData);
64
+ return;
65
+ }
66
+ if (func == SMO_EVENT_TYPE.setCurrentStream) {
67
+ selft.setCurrentStream(e.data.objData);
68
+ return;
69
+ }
70
+ if (func == SMO_EVENT_TYPE.infoCurrentLocation) {
71
+ selft.infoCurrentLocation(e.data.objData);
72
+ return;
73
+ }
74
+ if (func == SMO_EVENT_TYPE.setSalidaData) {
75
+ selft.setSalidaData(e.data.objData);
76
+ return;
77
+ }
78
+ if (func == SMO_EVENT_TYPE.updatefromsalida) {
79
+ selft.updatefromsalida(e.data.objdata);
80
+ return;
81
+ }
82
+ if (func == SMO_EVENT_TYPE.getRecursos) {
83
+ selft.getRecursos(e.data.objData);
84
+ }
85
+ if (func == SMO_EVENT_TYPE.getRecursosDefault) {
86
+ selft.getRecursosDefault(e.data.objData);
87
+ }
88
+ if (func == SMO_EVENT_TYPE.getRecursosRelleno) {
89
+ selft.getRecursosRelleno(e.data.objData);
90
+ return;
91
+ }
92
+ if (func == SMO_EVENT_TYPE.getVariableStorage) {
93
+ selft.getVariableStorage(e.data.objData);
94
+ return;
95
+ }
96
+ if (func == SMO_EVENT_TYPE.checkHealth) {
97
+ selft.checkHealth(e.data.objData);
98
+ return;
99
+ }
100
+ if (func == SMO_EVENT_TYPE.checkHealthPrinter) {
101
+ selft.checkHealthPrinter(e.data.objData);
102
+ return;
103
+ }
104
+ console.warn("message not implemented!!" + func);
105
+ }
106
+ };
107
+ };
108
+ SMO.prototype.start = function () {
109
+ this.events.start.next({});
110
+ };
111
+ SMO.prototype.setDatasource = function (datasource) {
112
+ this.events.setDatasource.next(datasource);
113
+ this.events.setDatasourceJson.next(this.utils.xmlToJSON(datasource.xml));
114
+ };
115
+ SMO.prototype.getVariable = function (variable) {
116
+ this.events.getVariable.next(variable);
117
+ };
118
+ SMO.prototype.setCurrentStream = function (stream) {
119
+ this.events.setCurrentStream.next(stream);
120
+ };
121
+ SMO.prototype.infoCurrentLocation = function (location) {
122
+ this.events.infoCurrentLocation.next(location);
123
+ };
124
+ SMO.prototype.setSalidaData = function (data) {
125
+ this.events.setSalidaData.next(data);
126
+ };
127
+ SMO.prototype.updatefromsalida = function (data) {
128
+ this.events.updatefromsalida.next(data);
129
+ };
130
+ SMO.prototype.getRecursos = function (data) {
131
+ this.events.getRecursos.next(data);
132
+ };
133
+ SMO.prototype.getRecursosDefault = function (data) {
134
+ this.events.getRecursosDefault.next(data);
135
+ };
136
+ SMO.prototype.getRecursosRelleno = function (data) {
137
+ this.events.getRecursosRelleno.next(data);
138
+ };
139
+ SMO.prototype.getVariableStorage = function (variable) {
140
+ this.events.getVariableStorage.next(variable);
141
+ };
142
+ SMO.prototype.checkHealth = function (json) {
143
+ this.events.checkHealth.next(json);
144
+ };
145
+ SMO.prototype.checkHealthPrinter = function (json) {
146
+ this.events.checkHealthPrinter.next(json);
147
+ };
148
+ return SMO;
149
+ }());
150
+ exports.SMO = SMO;
151
+ var SmoEvents = /** @class */ (function () {
152
+ function SmoEvents(smo) {
153
+ this.start = new rxjs_1.Subject();
154
+ this.setDatasource = new rxjs_1.Subject();
155
+ this.setDatasourceJson = new rxjs_1.Subject();
156
+ this.getVariable = new rxjs_1.Subject();
157
+ this.setCurrentStream = new rxjs_1.Subject();
158
+ this.infoCurrentLocation = new rxjs_1.Subject();
159
+ this.setSalidaData = new rxjs_1.Subject();
160
+ this.updatefromsalida = new rxjs_1.Subject();
161
+ this.getRecursos = new rxjs_1.Subject();
162
+ this.getRecursosDefault = new rxjs_1.Subject();
163
+ this.getRecursosRelleno = new rxjs_1.Subject();
164
+ this.getVariableStorage = new rxjs_1.Subject();
165
+ this.checkHealth = new rxjs_1.Subject();
166
+ this.checkHealthPrinter = new rxjs_1.Subject();
167
+ }
168
+ return SmoEvents;
169
+ }());
170
+ var smoCallBacks = /** @class */ (function () {
171
+ function smoCallBacks(_smo) {
172
+ this.smo = _smo;
173
+ }
174
+ smoCallBacks.prototype.onSmoLoad = function () {
175
+ window.parent.postMessage({
176
+ target: "Dnv.smoCallbacks.onSmoLoad",
177
+ objData: undefined,
178
+ idSmo: this.smo.id
179
+ }, "*");
180
+ };
181
+ smoCallBacks.prototype.onSmoReady = function () {
182
+ window.parent.postMessage({
183
+ target: "Dnv.smoCallbacks.onSmoReady",
184
+ objData: undefined,
185
+ idSmo: this.smo.id
186
+ }, "*");
187
+ };
188
+ smoCallBacks.prototype.smoLog = function (msn, level) {
189
+ if (level == undefined) {
190
+ level = LogLevel.Info;
191
+ }
192
+ //level = Dnv.LogLevel.Debug...
193
+ if (level == LogLevel.Debug) {
194
+ console.debug(msn);
195
+ }
196
+ if (level == LogLevel.Info) {
197
+ console.log(msn);
198
+ }
199
+ if (level == LogLevel.Warning) {
200
+ console.warn(msn);
201
+ }
202
+ if (level == LogLevel.Error) {
203
+ console.error(msn);
204
+ }
205
+ if (window.parent != window) {
206
+ window.parent.postMessage({
207
+ target: "Dnv.smoCallbacks.smoLog",
208
+ objData: {
209
+ level: level,
210
+ txt: msn
211
+ },
212
+ idSmo: this.smo.id
213
+ }, "*");
214
+ }
215
+ };
216
+ smoCallBacks.prototype.smoAlarma = function (msn, level) {
217
+ window.parent.postMessage({
218
+ target: "Dnv.smoCallbacks.smoAlarma",
219
+ objData: {
220
+ level: level,
221
+ txt: msn
222
+ },
223
+ idSmo: this.smo.id
224
+ }, "*");
225
+ };
226
+ smoCallBacks.prototype.smoLogStash = function (msn) {
227
+ window.parent.postMessage({
228
+ target: "Dnv.smoCallbacks.smoLogStash",
229
+ objData: {
230
+ txt: msn
231
+ },
232
+ idSmo: this.smo.id
233
+ }, "*");
234
+ };
235
+ smoCallBacks.prototype.smoLogNowShowing = function (msn) {
236
+ window.parent.postMessage({
237
+ target: "Dnv.smoCallbacks.smoNowShowing",
238
+ objData: msn,
239
+ idSmo: this.smo.id
240
+ }, "*");
241
+ };
242
+ smoCallBacks.prototype.reiniciarDispositivo = function (msn) {
243
+ //Permite reiniciar el player, proporcionando una razón para el reinicio. Solo Player HTML5
244
+ window.parent.postMessage({
245
+ target: "Dnv.smoCallbacks.reiniciarDispositivo",
246
+ objData: {
247
+ txt: msn // Razón del reinicio
248
+ },
249
+ idSmo: this.smo.id
250
+ }, "*");
251
+ };
252
+ smoCallBacks.prototype.urlNext = function () {
253
+ //Permite avanzar plantilla. Solo si Reloj Maestro activado.
254
+ window.parent.postMessage({
255
+ target: "Dnv.smoCallbacks.urlNext",
256
+ objData: undefined,
257
+ idSmo: this.smo.id
258
+ }, "*");
259
+ };
260
+ smoCallBacks.prototype.exitInteractivity = function () {
261
+ //Para canales interactivos, vuelve al canal de reposo. Solo Android y Player PC.
262
+ window.parent.postMessage({
263
+ target: "Dnv.smoCallbacks.exitInteractivity",
264
+ objData: undefined,
265
+ idSmo: this.smo.id
266
+ }, "*");
267
+ };
268
+ smoCallBacks.prototype.showBrowser = function () {
269
+ /* DEPRECATED NOT IMPLEMENTED */
270
+ };
271
+ smoCallBacks.prototype.closeBrowser = function () {
272
+ /* DEPRECATED NOT IMPLEMENTED */
273
+ };
274
+ smoCallBacks.prototype.urlNextDirectamente = function () {
275
+ /* NOT IMPLEMENTED */
276
+ };
277
+ smoCallBacks.prototype.setVariable = function (variable, valor) {
278
+ window.parent.postMessage({
279
+ target: "Dnv.smoCallbacks.setVariable",
280
+ objData: {
281
+ variable: variable,
282
+ valor: valor
283
+ },
284
+ idSmo: this.smo.id
285
+ }, "*");
286
+ };
287
+ smoCallBacks.prototype.getVariable = function (variable) {
288
+ window.parent.postMessage({
289
+ target: "Dnv.smoCallbacks.getVariable",
290
+ objData: {
291
+ variable: variable
292
+ },
293
+ idSmo: this.smo.id
294
+ }, "*");
295
+ /* MIRAR SMO.getVariable */
296
+ };
297
+ smoCallBacks.prototype.getFile = function (file) {
298
+ parent.postMessage({
299
+ target: "Dnv.smoCallbacks.getFile",
300
+ objData: file,
301
+ idSmo: this.smo.id
302
+ }, "*");
303
+ };
304
+ smoCallBacks.prototype.setLocalData = function (variable, valor) {
305
+ parent.postMessage({
306
+ target: "Dnv.smoCallbacks.setLocalData",
307
+ objData: {
308
+ nameData: variable,
309
+ data: valor
310
+ },
311
+ idSmo: this.smo.id
312
+ }, "*");
313
+ };
314
+ smoCallBacks.prototype.getLocalData = function (variable) {
315
+ parent.postMessage({
316
+ target: "Dnv.smoCallbacks.getLocalData",
317
+ objData: variable,
318
+ idSmo: this.smo.id
319
+ }, "*");
320
+ /* MIRAR SMO.setDatasource */
321
+ };
322
+ smoCallBacks.prototype.getCurrentStream = function () {
323
+ parent.postMessage({
324
+ target: "Dnv.smoCallbacks.getCurrentStream",
325
+ objData: undefined,
326
+ idSmo: this.smo.id
327
+ }, "*");
328
+ /* MIRAR SMO.setCurrentStream' */
329
+ };
330
+ smoCallBacks.prototype.finAviso = function (id) {
331
+ parent.postMessage({
332
+ target: "Dnv.smoCallbacks.finAviso",
333
+ objData: id,
334
+ idSmo: this.smo.id
335
+ }, "*");
336
+ };
337
+ smoCallBacks.prototype.refreshDatasource = function (codigo) {
338
+ parent.postMessage({
339
+ target: "Dnv.smoCallbacks.refreshDatasource",
340
+ objData: codigo,
341
+ idSmo: this.smo.id
342
+ }, "*");
343
+ };
344
+ smoCallBacks.prototype.getLocation = function () {
345
+ parent.postMessage({
346
+ target: "Dnv.smoCallbacks.getLocation",
347
+ objData: undefined,
348
+ idSmo: this.smo.id
349
+ }, "*");
350
+ /* MIRAR SMO.infoCurrentLocation */
351
+ };
352
+ smoCallBacks.prototype.getSalidaData = function (data) {
353
+ parent.postMessage({
354
+ target: "Dnv.smoCallbacks.getSalidaData",
355
+ objData: data,
356
+ idSmo: this.smo.id
357
+ }, "*");
358
+ /* MIRAR SMO.setSalidaData */
359
+ };
360
+ smoCallBacks.prototype.ejecutaFuncion = function (data) {
361
+ /*data ={
362
+ funcion: "", // Nombre de la función que se debe ejecutar
363
+ params: "" // Parámetros que debemos enviarle a la funcion. sin separadores ni nada, un string y se usa como tal. Solo esta implementada en un caso y se usa como tal sin parsear ni nada
364
+ } */
365
+ parent.postMessage({
366
+ target: "Dnv.smoCallbacks.ejecutaFuncion",
367
+ objData: data,
368
+ idSmo: this.smo.id
369
+ }, "*");
370
+ };
371
+ smoCallBacks.prototype.addObserver = function (data) {
372
+ /*data ="fruta"
373
+ */
374
+ parent.postMessage({
375
+ target: "Dnv.smoCallbacks.addObserver",
376
+ objData: data,
377
+ idSmo: this.smo.id
378
+ }, "*");
379
+ };
380
+ smoCallBacks.prototype.notify = function (data) {
381
+ /*data ={
382
+ destino: "fruta",
383
+ value: "{'fruta':'manzana', 'color':'roja'}"
384
+ } */
385
+ parent.postMessage({
386
+ target: "Dnv.smoCallbacks.notify",
387
+ objData: data,
388
+ idSmo: this.smo.id
389
+ }, "*");
390
+ };
391
+ smoCallBacks.prototype.playOnceChannelByTrigger = function (trigger) {
392
+ parent.postMessage({
393
+ target: "Dnv.smoCallbacks.playOnceChannelByTrigger",
394
+ objData: { triggerCanal: trigger },
395
+ idSmo: this.smo.id
396
+ }, "*");
397
+ };
398
+ smoCallBacks.prototype.stopPlayOnceChannelByTrigger = function () {
399
+ parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannelByTrigger", objData: {}, idSmo: this.smo.id }, "*");
400
+ };
401
+ smoCallBacks.prototype.playOnceChannel = function (codigoCanal) {
402
+ parent.postMessage({ target: "Dnv.smoCallbacks.playOnceChannel", objData: { codigoCanal: codigoCanal, params: "PLAYONCE_CHANNEL|" + codigoCanal }, idSmo: this.smo.id }, "*");
403
+ };
404
+ smoCallBacks.prototype.stopPlayChannel = function () {
405
+ parent.postMessage({ target: "Dnv.smoCallbacks.stopPlayOnceChannel", objData: {}, idSmo: this.smo.id }, "*");
406
+ };
407
+ smoCallBacks.prototype.editWrapperStyle = function (obj) {
408
+ /*{"posX": "0px","posY": "0px","alto": "0px","ancho": "0px","overflow": "hidden","scale": 0.1,"zindex": 0.1,"opacidad": 0.1,"isMaestro": true,duracionTransition: "1s", transitionTiming: "lineal", css: string} */
409
+ parent.postMessage({
410
+ target: "Dnv.smoCallbacks.editWrapperStyle",
411
+ objData: obj,
412
+ idSmo: this.smo.id
413
+ }, "*");
414
+ };
415
+ smoCallBacks.prototype.getRecursos = function () {
416
+ parent.postMessage({
417
+ target: "Dnv.smoCallbacks.getRecursos",
418
+ idSmo: this.smo.id
419
+ }, "*");
420
+ };
421
+ smoCallBacks.prototype.getRecursosDefault = function () {
422
+ parent.postMessage({
423
+ target: "Dnv.smoCallbacks.getRecursosDefault",
424
+ idSmo: this.smo.id
425
+ }, "*");
426
+ };
427
+ smoCallBacks.prototype.getRecursosRelleno = function () {
428
+ parent.postMessage({
429
+ target: "Dnv.smoCallbacks.getRecursosRelleno",
430
+ idSmo: this.smo.id
431
+ }, "*");
432
+ };
433
+ smoCallBacks.prototype.setVariableStorage = function (variable, valor) {
434
+ window.parent.postMessage({
435
+ target: "Dnv.smoCallbacks.setVariableStorage",
436
+ objData: {
437
+ variable: variable,
438
+ valor: valor
439
+ },
440
+ idSmo: this.smo.id
441
+ }, "*");
442
+ };
443
+ smoCallBacks.prototype.getVariableStorage = function (variable) {
444
+ window.parent.postMessage({
445
+ target: "Dnv.smoCallbacks.getVariableStorage",
446
+ objData: {
447
+ variable: variable
448
+ },
449
+ idSmo: this.smo.id
450
+ }, "*");
451
+ /* MIRAR SMO.getVariable */
452
+ };
453
+ smoCallBacks.prototype.printTextLine = function (txt) {
454
+ window.parent.postMessage({
455
+ target: "Dnv.smoCallbacks.printTextLine",
456
+ objData: {
457
+ txt: txt
458
+ },
459
+ idSmo: this.smo.id
460
+ }, "*");
461
+ };
462
+ smoCallBacks.prototype.printBarcode = function (code, width, height) {
463
+ window.parent.postMessage({
464
+ target: "Dnv.smoCallbacks.printBarcode",
465
+ objData: {
466
+ code: code,
467
+ width: width,
468
+ height: height
469
+ },
470
+ idSmo: this.smo.id
471
+ }, "*");
472
+ };
473
+ smoCallBacks.prototype.cutPaper = function (percent) {
474
+ window.parent.postMessage({
475
+ target: "Dnv.smoCallbacks.cutPaper",
476
+ objData: {
477
+ percent: percent
478
+ },
479
+ idSmo: this.smo.id
480
+ }, "*");
481
+ };
482
+ smoCallBacks.prototype.checkHealth = function () {
483
+ window.parent.postMessage({
484
+ target: "Dnv.smoCallbacks.checkHealth",
485
+ idSmo: this.smo.id
486
+ }, "*");
487
+ };
488
+ smoCallBacks.prototype.checkHealthPrinter = function () {
489
+ window.parent.postMessage({
490
+ target: "Dnv.smoCallbacks.checkHealthPrinter",
491
+ idSmo: this.smo.id
492
+ }, "*");
493
+ };
494
+ smoCallBacks.prototype.printImage = function (image) {
495
+ window.parent.postMessage({
496
+ target: "Dnv.smoCallbacks.printImage",
497
+ objData: {
498
+ image: image
499
+ },
500
+ idSmo: this.smo.id
501
+ }, "*");
502
+ };
503
+ return smoCallBacks;
504
+ }());
505
+ var Utils = /** @class */ (function () {
506
+ function Utils(_smo, _smoCallBacks) {
507
+ this.smo = _smo;
508
+ this.smoCallBacks = _smoCallBacks;
509
+ }
510
+ // Funciones para XML to JSON
511
+ Utils.prototype.xmlToJSON = function (xml) {
512
+ var getxml = new DOMParser();
513
+ var xmlDoc = getxml.parseFromString(xml, "text/xml");
514
+ // gets the JSON string
515
+ var json_str = this.jsonToStr(this.setJsonObj(xmlDoc));
516
+ // sets and returns the JSON object, if "rstr" undefined (not passed), else, returns JSON string
517
+ return json_str;
518
+ };
519
+ Utils.prototype.jsonToStr = function (js_obj) {
520
+ var rejsn = JSON.stringify(js_obj, undefined, 2).replace(/(\\t|\\r|\\n)/g, '').replace(/"",[\n\t\r\s]+""[,]*/g, '').replace(/(\n[\t\s\r]*\n)/g, '').replace(/[\s\t]{2,}""[,]{0,1}/g, '').replace(/"[\s\t]{1,}"[,]{0,1}/g, '').replace(/\[[\t\s]*\]/g, '""');
521
+ return (rejsn.indexOf('"parsererror": {') == -1) ? rejsn : 'Invalid XML format';
522
+ };
523
+ Utils.prototype.setJsonObj = function (xml) {
524
+ var js_obj = {};
525
+ if (xml.nodeType == 1) { // Element
526
+ if (xml.attributes.length > 0) {
527
+ js_obj["@attributes"] = {};
528
+ for (var j = 0; j < xml.attributes.length; j++) {
529
+ var attribute = xml.attributes.item(j);
530
+ js_obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
531
+ }
532
+ }
533
+ }
534
+ else if (xml.nodeType == 3) { // Text
535
+ js_obj = xml.nodeValue;
536
+ }
537
+ else if (xml.nodeType == 4) { // CDATA
538
+ js_obj = xml.nodeValue;
539
+ }
540
+ if (xml.hasChildNodes()) {
541
+ for (var i = 0; i < xml.childNodes.length; i++) {
542
+ var item = xml.childNodes.item(i);
543
+ var nodeName = item.nodeName;
544
+ if (typeof (js_obj[nodeName]) == "undefined") {
545
+ js_obj[nodeName] = this.setJsonObj(item);
546
+ }
547
+ else {
548
+ if (typeof (js_obj[nodeName].push) == "undefined") {
549
+ var old = js_obj[nodeName];
550
+ js_obj[nodeName] = [];
551
+ js_obj[nodeName].push(old);
552
+ }
553
+ js_obj[nodeName].push(this.setJsonObj(item));
554
+ }
555
+ }
556
+ }
557
+ return js_obj;
558
+ };
559
+ Utils.prototype.dataToJSON = function (data) {
560
+ try {
561
+ var parser = new DOMParser();
562
+ var xmlDoc = parser.parseFromString(data.xml, "text/xml");
563
+ var dataForJSON = xmlDoc.getElementsByTagName("item")[0].innerHTML;
564
+ dataForJSON = dataForJSON.replace(/{'/g, '{"').replace(/'}/g, '"}').replace(/:'/g, ':"').replace(/':/g, '":').replace(/,'/g, ',"').replace(/',/g, '",').replace(/\['/g, '["').replace(/'\]/g, '"]').replace(/(\r\n|\n|\r)/gm, "");
565
+ return JSON.parse(dataForJSON);
566
+ }
567
+ catch (error) {
568
+ return {};
569
+ }
570
+ };
571
+ return Utils;
572
+ }());
573
+ var SMO_EVENT_TYPE;
574
+ (function (SMO_EVENT_TYPE) {
575
+ SMO_EVENT_TYPE["start"] = "start";
576
+ SMO_EVENT_TYPE["setDatasource"] = "setDatasource";
577
+ SMO_EVENT_TYPE["getVariable"] = "getVariable";
578
+ SMO_EVENT_TYPE["setCurrentStream"] = "setCurrentStream";
579
+ SMO_EVENT_TYPE["infoCurrentLocation"] = "infoCurrentLocation";
580
+ SMO_EVENT_TYPE["setSalidaData"] = "setSalidaData";
581
+ SMO_EVENT_TYPE["updatefromsalida"] = "updatefromsalida";
582
+ SMO_EVENT_TYPE["setDatasourceJson"] = "setDatasourceJson";
583
+ SMO_EVENT_TYPE["getRecursos"] = "getRecursos";
584
+ SMO_EVENT_TYPE["getRecursosDefault"] = "getRecursosDefault";
585
+ SMO_EVENT_TYPE["getRecursosRelleno"] = "getRecursosRelleno";
586
+ SMO_EVENT_TYPE["getVariableStorage"] = "getVariableStorage";
587
+ SMO_EVENT_TYPE["checkHealth"] = "checkHealth";
588
+ SMO_EVENT_TYPE["checkHealthPrinter"] = "checkHealthPrinter";
589
+ })(SMO_EVENT_TYPE = exports.SMO_EVENT_TYPE || (exports.SMO_EVENT_TYPE = {}));
590
+ var LogLevel;
591
+ (function (LogLevel) {
592
+ LogLevel[LogLevel["Debug"] = 0] = "Debug";
593
+ LogLevel[LogLevel["Info"] = 1] = "Info";
594
+ LogLevel[LogLevel["Warning"] = 2] = "Warning";
595
+ LogLevel[LogLevel["Error"] = 3] = "Error";
596
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
597
+ var AlarmaLevel;
598
+ (function (AlarmaLevel) {
599
+ AlarmaLevel[AlarmaLevel["Ok_off"] = 0] = "Ok_off";
600
+ AlarmaLevel[AlarmaLevel["Ok"] = 1] = "Ok";
601
+ AlarmaLevel[AlarmaLevel["Scanning"] = 2] = "Scanning";
602
+ AlarmaLevel[AlarmaLevel["Timeout"] = 3] = "Timeout";
603
+ AlarmaLevel[AlarmaLevel["Warning"] = 4] = "Warning";
604
+ AlarmaLevel[AlarmaLevel["Error"] = 5] = "Error";
605
+ })(AlarmaLevel = exports.AlarmaLevel || (exports.AlarmaLevel = {}));