-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDL-ISF.Docksters.json
100 lines (100 loc) · 6.83 KB
/
DL-ISF.Docksters.json
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
{
"createdUTC": "2020-05-29T18:06:30.651Z",
"definitionIsPublic": false,
"definitionName": "DL-ISF",
"displayName": "DL-ISF Sapflow Sensor for LoRaWAN®",
"manufacturer": "Decentlab",
"organizationId": "9f014719-4add-4989-ba0f-fc7edc44d893",
"parser": "\n/* https://www.decentlab.com/products/sapflow-sensor-for-lorawan */\n\nvar decentlab_decoder = {\n PROTOCOL_VERSION: 2,\n SENSORS: [\n {length: 16,\n values: [{name: 'sap_flow',\n displayName: 'Sap flow',\n convert: function (x) { return (x[0] * 16 - 50000) / 1000; },\n unit: 'l⋅h⁻¹'},\n {name: 'heat_velocity_outer',\n displayName: 'Heat velocity (outer)',\n convert: function (x) { return (x[1] * 16 - 50000) / 1000; },\n unit: 'cm⋅h⁻¹'},\n {name: 'heat_velocity_inner',\n displayName: 'Heat velocity (inner)',\n convert: function (x) { return (x[2] * 16 - 50000) / 1000; },\n unit: 'cm⋅h⁻¹'},\n {name: 'alpha_outer',\n displayName: 'Alpha (outer)',\n convert: function (x) { return (x[3] * 32 - 1000000) / 100000; }},\n {name: 'alpha_inner',\n displayName: 'Alpha (inner)',\n convert: function (x) { return (x[4] * 32 - 1000000) / 100000; }},\n {name: 'beta_outer',\n displayName: 'Beta (outer)',\n convert: function (x) { return (x[5] * 32 - 1000000) / 100000; }},\n {name: 'beta_inner',\n displayName: 'Beta (inner)',\n convert: function (x) { return (x[6] * 32 - 1000000) / 100000; }},\n {name: 'tmax_outer',\n displayName: 'Tmax (outer)',\n convert: function (x) { return (x[7] * 2) / 1000; },\n unit: 's'},\n {name: 'tmax_inner',\n displayName: 'Tmax (inner)',\n convert: function (x) { return (x[8] * 2) / 1000; },\n unit: 's'},\n {name: 'temperature_outer',\n displayName: 'Temperature (outer)',\n convert: function (x) { return (x[9] - 32768) / 100; },\n unit: '°C'},\n {name: 'max_voltage',\n displayName: 'Max voltage',\n convert: function (x) { return (x[10] - 32768) / 1000; },\n unit: 'V'},\n {name: 'min_voltage',\n displayName: 'Min voltage',\n convert: function (x) { return (x[11] - 32768) / 1000; },\n unit: 'V'},\n {name: 'diagnostic',\n displayName: 'Diagnostic',\n convert: function (x) { return x[12] + x[13] * 65536; }},\n {name: 'upstream_tmax_outer',\n displayName: 'Upstream Tmax (outer)',\n convert: function (x) { return (x[14] * 2) / 1000; },\n unit: 's'},\n {name: 'upstream_tmax_inner',\n displayName: 'Upstream Tmax (inner)',\n convert: function (x) { return (x[15] * 2) / 1000; },\n unit: 's'}]},\n {length: 1,\n values: [{name: 'battery_voltage',\n displayName: 'Battery voltage',\n convert: function (x) { return x[0] / 1000; },\n unit: 'V'}]}\n ],\n\n read_int: function (bytes, pos) {\n return (bytes[pos] << 8) + bytes[pos + 1];\n },\n\n decode: function (msg) {\n var bytes = msg;\n var i, j;\n if (typeof msg === 'string') {\n bytes = [];\n for (i = 0; i < msg.length; i += 2) {\n bytes.push(parseInt(msg.substring(i, i + 2), 16));\n }\n }\n\n var version = bytes[0];\n if (version != this.PROTOCOL_VERSION) {\n return {error: \"protocol version \" + version + \" doesn't match v2\"};\n }\n\n var deviceId = this.read_int(bytes, 1);\n var flags = this.read_int(bytes, 3);\n var result = {'protocol_version': version, 'device_id': deviceId};\n // decode payload\n var pos = 5;\n for (i = 0; i < this.SENSORS.length; i++, flags >>= 1) {\n if ((flags & 1) !== 1)\n continue;\n\n var sensor = this.SENSORS[i];\n var x = [];\n // convert data to 16-bit integer array\n for (j = 0; j < sensor.length; j++) {\n x.push(this.read_int(bytes, pos));\n pos += 2;\n }\n\n // decode sensor values\n for (j = 0; j < sensor.values.length; j++) {\n var value = sensor.values[j];\n if ('convert' in value) {\n result[value.name] = {displayName: value.displayName,\n value: value.convert.bind(this)(x)};\n if ('unit' in value)\n result[value.name]['unit'] = value.unit;\n }\n }\n }\n return result;\n }\n};\n\nfunction parsePayload(payload) {\n var decoded = decentlab_decoder.decode(payload);\n Object.keys(decoded).map(function(key, index) { decoded[key] = decoded[key]['value'];});\n return decoded;\n}",
"sensors": [
{
"name": "sap_flow",
"displayName": "Sap flow /l⋅h⁻¹/",
"type": "float"
},
{
"name": "heat_velocity_outer",
"displayName": "Heat velocity outer /cm⋅h⁻¹/",
"type": "float"
},
{
"name": "heat_velocity_inner",
"displayName": "Heat velocity inner /cm⋅h⁻¹/",
"type": "float"
},
{
"name": "alpha_outer",
"displayName": "Alpha outer",
"type": "int"
},
{
"name": "alpha_inner",
"displayName": "Alpha inner",
"type": "int"
},
{
"name": "beta_outer",
"displayName": "Beta outer",
"type": "int"
},
{
"name": "beta_inner",
"displayName": "Beta inner",
"type": "int"
},
{
"name": "tmax_outer",
"displayName": "Tmax outer /s/",
"type": "float"
},
{
"name": "tmax_inner",
"displayName": "Tmax inner /s/",
"type": "float"
},
{
"name": "temperature_outer",
"displayName": "Temperature outer",
"type": "tempC"
},
{
"name": "max_voltage",
"displayName": "Max voltage",
"type": "volts"
},
{
"name": "min_voltage",
"displayName": "Min voltage",
"type": "volts"
},
{
"name": "diagnostic",
"displayName": "Diagnostic",
"type": "int"
},
{
"name": "upstream_tmax_outer",
"displayName": "Upstream Tmax outer /s/",
"type": "float"
},
{
"name": "upstream_tmax_inner",
"displayName": "Upstream Tmax inner /s/",
"type": "float"
},
{
"displayName": "Battery voltage",
"name": "battery_voltage",
"thresholds": [
{
"name": "Battery voltage is low",
"type": "lessthan",
"warning": "2.2"
}
],
"type": "volts"
}
],
"updatedUTC": "2020-05-29T18:06:30.651Z",
"version": "v1.0"
}