Commit pirate JS files
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
Copyright (c) 2023-forever Douglas Malnati. All rights reserved.
|
||||
|
||||
See the /faq/tos page for details.
|
||||
|
||||
(If this generated header is stamped on a file which is a 3rd party file or under a different license or copyright, then ignore this copyright statement and use that file's terms.)
|
||||
*/
|
||||
|
||||
import { CodecExpandedBasicTelemetry } from './CodecExpandedBasicTelemetry.js';
|
||||
|
||||
|
||||
export class ColumnBuilderExpandedBasicTelemetry
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
this.codecExpandedBasicTelemetry = new CodecExpandedBasicTelemetry();
|
||||
}
|
||||
|
||||
MatchWindow(slotMsgList)
|
||||
{
|
||||
return this.HasAnyExpandedBasicTelemetry(slotMsgList);
|
||||
}
|
||||
|
||||
GetColNameList()
|
||||
{
|
||||
return [
|
||||
"EbtGpsValid",
|
||||
"EbtLatitudeIdx",
|
||||
"EbtLongitudeIdx",
|
||||
"EbtTempF",
|
||||
"EbtTempC",
|
||||
"EbtVoltage",
|
||||
"EbtAltFt",
|
||||
"EbtAltM",
|
||||
];
|
||||
}
|
||||
|
||||
GetColMetaDataList()
|
||||
{
|
||||
return [
|
||||
{ rangeMin: 0, rangeMax: 1 },
|
||||
{ rangeMin: 0, rangeMax: 15 },
|
||||
{ rangeMin: 0, rangeMax: 35 },
|
||||
{ rangeMin: -60, rangeMax: 70 },
|
||||
{ rangeMin: -51, rangeMax: 21 },
|
||||
{ rangeMin: 1.8, rangeMax: 7.0 },
|
||||
{ rangeMin: 0, rangeMax: 120000 },
|
||||
{ rangeMin: 0, rangeMax: 36576 },
|
||||
];
|
||||
}
|
||||
|
||||
GetValListForWindow(slotMsgList)
|
||||
{
|
||||
let decoded = this.GetLatestExpandedBasicTelemetry(slotMsgList);
|
||||
if (!decoded)
|
||||
{
|
||||
return new Array(this.GetColNameList().length).fill(null);
|
||||
}
|
||||
|
||||
return [
|
||||
decoded.gpsValid,
|
||||
decoded.latitudeIdx,
|
||||
decoded.longitudeIdx,
|
||||
decoded.tempF,
|
||||
decoded.tempC,
|
||||
decoded.voltage,
|
||||
decoded.altFt,
|
||||
decoded.altM,
|
||||
];
|
||||
}
|
||||
|
||||
GetLatestExpandedBasicTelemetry(slotMsgList)
|
||||
{
|
||||
if (!Array.isArray(slotMsgList) || slotMsgList.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (let slot = slotMsgList.length - 1; slot >= 1; --slot)
|
||||
{
|
||||
let decoded = this.DecodeExpandedBasicTelemetryMsg(slotMsgList[slot]);
|
||||
if (decoded)
|
||||
{
|
||||
return decoded;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
HasAnyExpandedBasicTelemetry(slotMsgList)
|
||||
{
|
||||
if (!Array.isArray(slotMsgList) || slotMsgList.length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (let slot = slotMsgList.length - 1; slot >= 1; --slot)
|
||||
{
|
||||
if (this.IsExpandedBasicTelemetryMsg(slotMsgList[slot]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
IsExpandedBasicTelemetryMsg(msg)
|
||||
{
|
||||
if (!msg?.IsTelemetryExtended?.())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
let codec = msg.GetCodec?.();
|
||||
|
||||
return this.codecExpandedBasicTelemetry.IsCodecExpandedBasicTelemetry(codec);
|
||||
}
|
||||
|
||||
DecodeExpandedBasicTelemetryMsg(msg)
|
||||
{
|
||||
if (!this.IsExpandedBasicTelemetryMsg(msg))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
let codec = msg.GetCodec?.();
|
||||
|
||||
let tempF = codec.GetTempF();
|
||||
let tempC = Math.round((tempF - 32) * 5 / 9);
|
||||
let voltage = codec.GetVoltageV();
|
||||
let gpsValid = codec.GetGpsValidBool();
|
||||
let altFt = codec.GetAltitudeFt();
|
||||
let altM = Math.round(altFt / 3.28084);
|
||||
let latitudeIdx = codec.GetLatitudeIdx();
|
||||
let longitudeIdx = codec.GetLongitudeIdx();
|
||||
|
||||
return {
|
||||
tempF,
|
||||
tempC,
|
||||
voltage,
|
||||
gpsValid,
|
||||
latitudeIdx,
|
||||
longitudeIdx,
|
||||
altFt,
|
||||
altM,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user