-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.js
More file actions
160 lines (142 loc) · 4.52 KB
/
Copy pathlog.js
File metadata and controls
160 lines (142 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function logCfgUpd(j) {
try {
vS("logInt", j.Interval);
vS("logCap", j.LimitCap);
vS("logSep", j.Sep);
cS("logEn", j.Enable);
cS("logOvw", j.Overwrite);
} catch (e) {
console.log(e);
}
}
async function logCfgGet() {
let rq = {Cmd:"LogCfgGet", SessionId:sIdG()};
return await rqp(rq, logCfgUpd);
}
async function logCfgSet() {
let rq = {Cmd:"LogCfgSet", SessionId:sIdG(),
"Interval":vG("logInt"),
"LimitCap":vG("logCap"),
"Sep":vG("logSep"),
"Enable":cG("logEn")};
return await rqp(rq, null);
}
function logStateUpd(j) {
try {
hS("logStSvc", j.SvcState);
hS("logStMod", j.ModState);
hS("logStRst", j.Reset);
} catch(e) {
console.log(e);
}
}
async function logStateGet() {
let rq = {Cmd:"LogStateGet", SessionId:sIdG()};
return await rqp(rq, logStateUpd);
}
// LOG - VALUE
function logValueCfgSetArray(id) {
var t = [];
for (var i = 0; i < id.length; i++) {
var o = {};
o["Nr"] = id[i];
o["Enable"] = cG("logE" + id[i]);
o["Name"] = vG("logN" + id[i]);
o["ValueId"] = vIdGetIdByIdx(siG("logV" + id[i]));
o["Format"] = fmtGetIdByIdx(siG("logF" + id[i]));
t.push(o);
}
return t;
}
async function logValueCfgSetAll() {
let rq = {Cmd:"LogValueCfgSet", SessionId:sIdG()};
return new Promise(async(res,rej) => {
rq["Values"] = logValueCfgSetArray([0,1,2,3]);
await rqp(rq, null)
.then(async() => {
rq["Values"] = logValueCfgSetArray([4,5,6,7]);
await rqp(rq, null)})
.then(async() => {
rq["Values"] = logValueCfgSetArray([8,9,10,11]);
await rqp(rq, null)})
.then(async() => {
rq["Values"] = logValueCfgSetArray([12,13,14,15]);
await rqp(rq, null)})
.then(() => {
res();})
.catch((m) => {
rej(m);
})
});
}
function logValueCfgUpd(j) {
try {
for (var i = 0; i < j.Values.length; i++) {
var v = j.Values[i];
cS("logE" + v.Nr, v.Enable);
vS("logN" + v.Nr, v.Name);
siS("logV" + v.Nr, vIdGetIdxById(v.ValueId));
siS("logF" + v.Nr, fmtGetIdxById(v.Format));
}
} catch(e) {
console.log(e);
}
}
async function logValueCfgGet(v) {
let rq = {Cmd:"LogValueCfgGet", SessionId:sIdG(), Values:v};
return await rqp(rq, logValueCfgUpd);
}
function logValueAdd(id) {
var html;
html = '<div class="box-full-sub"><h3>Value ' + id + '</h3></div>' +
'<div class="box-topic">' +
'<div class="box-14">' +
'<p><label for="logE' + id + '">Enable</label><input id="logE' + id + '" type="checkbox"></p>' +
'</div>' +
'<div class="box-14">' +
'<p><label for="logN' + id + '">Name</label><input id="logN' + id + '" type="text"></p>' +
'</div>' +
'<div class="box-14">' +
'<p><label for="logV' + id + '">Value Id</label><select id="logV' + id + '"> ' + vIdStrGet() + '</select></p>' +
'</div>' +
'<div class="box-14">' +
'<p><label for="logF' + id + '">Format</label><select id="logF' + id + '">' + fmtStrGet() + '</select></p>' +
'</div>' +
'</div>';
return html;
}
async function logInit() {
return new Promise(async(res, rej) => {
try {
for (id = 0; id < 16; id++) {
document.getElementById("log-ent").innerHTML += logValueAdd(id);
}
btnEvAdd("logBtCfg", async() => {
await logCfgSet().then(() => {
}).catch((m) => {
alert(m);
})
});
btnEvAdd("logBtVal", async() => {
await logValueCfgSetAll().then(() => {
}).catch((m) => {
alert(m);
})
});
} catch (e) {
console.log(e);
res();
}
await logCfgGet()
.then(async() => {await logStateGet()})
.then(async() => {await logValueCfgGet([0,1,2,3,4])})
.then(async() => {await logValueCfgGet([5,6,7,8,9])})
.then(async() => {await logValueCfgGet([10,11,12,13,14])})
.then(async() => {await logValueCfgGet([15])})
.then(() => {
res();
}).catch((m) => {
rej(m);
})
});
}