22 |
22 |
23 // Open WebSocket to relative "/ws" address |
23 // Open WebSocket to relative "/ws" address |
24 var has_watchdog = window.location.hash == "#watchdog"; |
24 var has_watchdog = window.location.hash == "#watchdog"; |
25 |
25 |
26 const dvgetters = { |
26 const dvgetters = { |
27 INT: (dv,offset) => [dv.getInt16(offset, true), 2], |
27 SINT: (dv,offset) => [dv.getInt8(offset, true), 1], |
28 BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], |
28 INT: (dv,offset) => [dv.getInt16(offset, true), 2], |
29 NODE: (dv,offset) => [dv.getInt8(offset, true), 1], |
29 DINT: (dv,offset) => [dv.getInt32(offset, true), 4], |
30 REAL: (dv,offset) => [dv.getFloat32(offset, true), 4], |
30 LINT: (dv,offset) => [dv.getBigInt64(offset, true), 8], |
|
31 USINT: (dv,offset) => [dv.getUint8(offset, true), 1], |
|
32 UINT: (dv,offset) => [dv.getUint16(offset, true), 2], |
|
33 UDINT: (dv,offset) => [dv.getUint32(offset, true), 4], |
|
34 ULINT: (dv,offset) => [dv.getBigUint64(offset, true), 8], |
|
35 BOOL: (dv,offset) => [dv.getInt8(offset, true), 1], |
|
36 NODE: (dv,offset) => [dv.getInt8(offset, true), 1], |
|
37 REAL: (dv,offset) => [dv.getFloat32(offset, true), 4], |
31 STRING: (dv, offset) => { |
38 STRING: (dv, offset) => { |
32 const size = dv.getInt8(offset); |
39 const size = dv.getInt8(offset); |
33 return [ |
40 return [ |
34 String.fromCharCode.apply(null, new Uint8Array( |
41 String.fromCharCode.apply(null, new Uint8Array( |
35 dv.buffer, /* original buffer */ |
42 dv.buffer, /* original buffer */ |
140 ws.send(new Blob([hmi_hash_u8].concat(data))); |
147 ws.send(new Blob([hmi_hash_u8].concat(data))); |
141 }; |
148 }; |
142 }; |
149 }; |
143 |
150 |
144 const typedarray_types = { |
151 const typedarray_types = { |
|
152 SINT: (number) => new Int8Array([number]), |
145 INT: (number) => new Int16Array([number]), |
153 INT: (number) => new Int16Array([number]), |
|
154 DINT: (number) => new Int32Array([number]), |
|
155 LINT: (number) => new Int64Array([number]), |
|
156 USINT: (number) => new Uint8Array([number]), |
|
157 UINT: (number) => new Uint16Array([number]), |
|
158 UDINT: (number) => new Uint32Array([number]), |
|
159 ULINT: (number) => new Uint64Array([number]), |
146 BOOL: (truth) => new Int8Array([truth]), |
160 BOOL: (truth) => new Int8Array([truth]), |
147 NODE: (truth) => new Int8Array([truth]), |
161 NODE: (truth) => new Int8Array([truth]), |
148 REAL: (number) => new Float32Array([number]), |
162 REAL: (number) => new Float32Array([number]), |
149 STRING: (str) => { |
163 STRING: (str) => { |
150 // beremiz default string max size is 128 |
164 // beremiz default string max size is 128 |