Commit pirate JS files
This commit is contained in:
95
js/CodecHeartbeat.js
Normal file
95
js/CodecHeartbeat.js
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
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 { WsprCodecMaker } from '/pro/codec/WsprCodec.js';
|
||||
import { WSPR } from '/js/WSPR.js';
|
||||
|
||||
|
||||
export class CodecHeartbeat
|
||||
extends WsprCodecMaker
|
||||
{
|
||||
static HDR_TYPE = 1;
|
||||
static HDR_TELEMETRY_TYPE = 0;
|
||||
static HDR_RESERVED = 0;
|
||||
|
||||
static GPS_LOCK_TYPE_NO_LOCK = 0;
|
||||
static GPS_LOCK_TYPE_TIME_LOCK = 1;
|
||||
static GPS_LOCK_TYPE_LOCATION_LOCK = 2;
|
||||
static TX_FREQ_LOW_OFFSET_HZ = 1400;
|
||||
|
||||
constructor()
|
||||
{
|
||||
super();
|
||||
|
||||
this.SetCodecDefFragment("Heartbeat", `
|
||||
{ "name": "TxFreqHz", "unit": "Idx", "lowValue": 0, "highValue": 200, "stepSize": 1 },
|
||||
{ "name": "Uptime", "unit": "Minutes", "lowValue": 0, "highValue": 1440, "stepSize": 10 },
|
||||
{ "name": "GpsLockType", "unit": "Enum", "lowValue": 0, "highValue": 2, "stepSize": 1 },
|
||||
{ "name": "GpsTryLock", "unit": "Seconds", "lowValue": 0, "highValue": 1200, "stepSize": 5 },
|
||||
{ "name": "GpsSatsInView", "unit": "Count", "lowValue": 0, "highValue": 50, "stepSize": 2 },
|
||||
`);
|
||||
}
|
||||
|
||||
GetHdrTypeValue()
|
||||
{
|
||||
return CodecHeartbeat.HDR_TYPE;
|
||||
}
|
||||
|
||||
GetHdrTelemetryTypeValue()
|
||||
{
|
||||
return CodecHeartbeat.HDR_TELEMETRY_TYPE;
|
||||
}
|
||||
|
||||
GetHdrReservedValue()
|
||||
{
|
||||
return CodecHeartbeat.HDR_RESERVED;
|
||||
}
|
||||
|
||||
GetGpsLockTypeNoLockValue()
|
||||
{
|
||||
return CodecHeartbeat.GPS_LOCK_TYPE_NO_LOCK;
|
||||
}
|
||||
|
||||
GetGpsLockTypeTimeLockValue()
|
||||
{
|
||||
return CodecHeartbeat.GPS_LOCK_TYPE_TIME_LOCK;
|
||||
}
|
||||
|
||||
GetGpsLockTypeLocationLockValue()
|
||||
{
|
||||
return CodecHeartbeat.GPS_LOCK_TYPE_LOCATION_LOCK;
|
||||
}
|
||||
|
||||
GetTxFreqLowOffsetHz()
|
||||
{
|
||||
return CodecHeartbeat.TX_FREQ_LOW_OFFSET_HZ;
|
||||
}
|
||||
|
||||
GetReferenceTxFreqHzFromBand(band)
|
||||
{
|
||||
let dialFreqHz = WSPR.GetDialFreqFromBandStr(band);
|
||||
|
||||
return dialFreqHz + this.GetTxFreqLowOffsetHz();
|
||||
}
|
||||
|
||||
DecodeTxFreqHzFromBand(band, txFreqHzIdx)
|
||||
{
|
||||
txFreqHzIdx = Number(txFreqHzIdx);
|
||||
if (isNaN(txFreqHzIdx))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.GetReferenceTxFreqHzFromBand(band) + txFreqHzIdx;
|
||||
}
|
||||
|
||||
IsCodecHeartbeat(codec)
|
||||
{
|
||||
return codec?.GetHdrTypeEnum?.() == this.GetHdrTypeValue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user