Public
Edited
Aug 2, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
h1 = dataim.hex[0].split(/(.{6})(.{6})(.{6})(.{4})/).filter((d) => d.length)
Insert cell
parseInt(h1[3], 16)
Insert cell
Insert cell
SBE37Hex15(dataim.hex[0])
Insert cell
SBE37DateTime(SBE37Hex15(dataim.hex[0]).value.dt)
Insert cell
function SBE37Temperature(count, coef) {
}
Insert cell
{
const a = 631380;
const ab = new ArrayBuffer(4);
const v = new DataView(ab);
v.setInt32(0, a);
console.log(ab.slice(1));
console.log(ab);
return ab;
}
Insert cell
function writeSBE37raw(tc, cf, pc, ptv, dts) {
// temp count, conductivity frequency, pressure count, pressure temp value, date time seconds
const result = new ArrayBuffer(16);
const view = new DataView(result);

// temporal
const ab = new ArrayBuffer(8);
const abv = new DataView(ab);

// temp count
abv.setUint32(0, tc, true);
view.setUint8(0, abv.getUint8(1, true));
view.setUint8(1, abv.getUint8(2, true));
view.setUint8(2, abv.getUint8(3, true));

// conductivty frequency
const cfInt = ~~(cf * 256);
abv.setUint32(0, cfInt, true);
view.setUint8(3, abv.getUint8(1, true));
view.setUint8(4, abv.getUint8(2, true));
view.setUint8(5, abv.getUint8(3, true));

// pressure count
abv.setUint32(0, pc, true);
view.setUint8(6, abv.getUint8(1, true));
view.setUint8(7, abv.getUint8(2, true));
view.setUint8(8, abv.getUint8(3, true));

// pressure temp value
view.setUint16(9, ptv, true);

// date time at 11
view.setUint32(11, dts, true)
console.log(result);

return result;
}
Insert cell
function abHex(ab) {
const len = ab.length;
const r = [];
for (let i = 0; i < len; i++) {
const v = ab.slice(i, 1)[0];
r.push(v.toString(16));
}

return r.join(" ");
}
Insert cell
oo = writeSBE37raw(600000, 5012.123, 501234, 1570, 770825395)

Insert cell
Insert cell
{
/*
const ptBits = (ta[b++] << 8) | ta[b++];
// -- Maybe they are using AD590 temperature
// -- Pressure sensor temperature: 12-bit number is binary
// representation of temperature, ranging from 0 to 4095
// (2500 corresponds to approximately 22 ºC,
// typical room temperature)
// I guess : Celsius = f * M + B
result['psT'] = ptBits >>> 4;
*/

// const psTC = c.psT * sensors.f2.coef.AD590M + sensors.f2.coef.AD590B;

// t = PTEMPA0 + PTEMPA1 * compensation_voltage + PTEMPA2 * compensation_voltage**2
const v = 2100; //parseInt(h1[3], 16);
// 13107

return ptempa0 + ptempa1 * v + ptempa2 * Math.pow(v, 2);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
new Date((seconds + parseInt(h1[4], 16)) * 1000)
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more