Add support for per-station timeoutLength/lowVoltage
This commit is contained in:
parent
2feabd4d87
commit
e14904e59b
@ -24,11 +24,12 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import parseDuration from 'parse-duration';
|
||||
|
||||
const props = defineProps({
|
||||
callsign: String,
|
||||
tactical: String,
|
||||
timeoutLength: Number,
|
||||
timeoutLength: String,
|
||||
lowVoltage: Number,
|
||||
finishedReplay: Boolean,
|
||||
messages: Array,
|
||||
@ -48,6 +49,10 @@ function formatTime(time, isDuration = false) {
|
||||
);
|
||||
}
|
||||
|
||||
const timeoutLengthMs = computed(() => {
|
||||
return parseDuration(props.timeoutLength);
|
||||
});
|
||||
|
||||
function prettyDuration(duration) {
|
||||
let date = new Date(duration);
|
||||
return [
|
||||
@ -74,7 +79,8 @@ const timedOut = computed(() => {
|
||||
return false;
|
||||
} else {
|
||||
return (
|
||||
props.now.getTime() - stationStatus.value.lastHeard > props.timeoutLength
|
||||
props.now.getTime() - stationStatus.value.lastHeard >
|
||||
timeoutLengthMs.value
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -131,12 +137,12 @@ watch(timedOut, (newVal) => {
|
||||
if (newVal) {
|
||||
notify(
|
||||
`${tacticalAndOrCall.value} has not been heard for over ${prettyDuration(
|
||||
props.timeoutLength
|
||||
timeoutLengthMs.value
|
||||
)}!`,
|
||||
`Last Heard: ${formatTime(
|
||||
stationStatus.value.lastHeard
|
||||
)} (${prettyDuration(
|
||||
props.now.value - stationStatus.value.lastHeard
|
||||
props.now.getTime() - stationStatus.value.lastHeard
|
||||
)} ago!)`
|
||||
);
|
||||
}
|
||||
|
@ -21,12 +21,10 @@
|
||||
</tr>
|
||||
|
||||
<StationRow
|
||||
v-for="(tactical, callsign) in trackedStations"
|
||||
v-for="(stationProps, callsign) in trackedStations"
|
||||
:key="callsign"
|
||||
:callsign="callsign"
|
||||
:tactical="tactical"
|
||||
:lowVoltage="config.lowVoltage"
|
||||
:timeoutLength="parseDuration(config.timeoutLength)"
|
||||
v-bind="{ ...config.default, ...stationProps }"
|
||||
:finishedReplay="finishedReplay"
|
||||
:messages="messagesFromStation[callsign] || []"
|
||||
:now="now"
|
||||
@ -39,7 +37,6 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import APRSParser from 'aprs-parser/lib/APRSParser';
|
||||
import parseDuration from 'parse-duration';
|
||||
|
||||
import StationRow from './StationRow.vue';
|
||||
import config from './status_config.yaml';
|
||||
@ -50,9 +47,25 @@ const finishedReplay = ref(false);
|
||||
const messages = ref([]);
|
||||
const messagesFromStation = ref({});
|
||||
const now = ref(new Date());
|
||||
const trackedStations = ref(config.trackedStations);
|
||||
const trackedStations = ref(normalizeConfigStations());
|
||||
const canNotify = ref(Notification.permission === 'granted');
|
||||
|
||||
function normalizeConfigStations() {
|
||||
return [...Object.entries(config.trackedStations)]
|
||||
.map(([callsign, tacticalOrProps]) => {
|
||||
if (typeof tacticalOrProps === 'string') {
|
||||
return [callsign, { tactical: tacticalOrProps }];
|
||||
} else {
|
||||
return [callsign, tacticalOrProps];
|
||||
}
|
||||
})
|
||||
.reduce((acc, [callsign, props]) => {
|
||||
console.log(callsign, props);
|
||||
acc[callsign] = props;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// Connect to websocket aprs stream
|
||||
connectToStream();
|
||||
@ -103,7 +116,7 @@ function handleMessage(packet) {
|
||||
message.data.text.split(';').map((tac_assoc) => {
|
||||
let [call, tac] = tac_assoc.split('=', 2);
|
||||
if (tac) {
|
||||
trackedStations.value[call] = tac;
|
||||
trackedStations.value[call].tactical = tac;
|
||||
} else {
|
||||
delete trackedStations.value[call];
|
||||
}
|
||||
|
@ -1,18 +1,31 @@
|
||||
timeoutLength: 10 minutes
|
||||
lowVoltage: 11.9
|
||||
|
||||
TACTICAL_whitelist:
|
||||
- KC1GDW-7
|
||||
- W1FN
|
||||
|
||||
default:
|
||||
timeoutLength: 10 minutes
|
||||
lowVoltage: 11.9
|
||||
|
||||
trackedStations:
|
||||
# Digis/iGates
|
||||
W1FN-1: Moose Mt
|
||||
W1FN-5: Hanover
|
||||
W1FN-9: Bath
|
||||
N1GMC-1: Dame Hill Rd, Orford
|
||||
N1GMC-2: Sunday Mt, Orford
|
||||
KB1FDA-1: Corinth
|
||||
W1FN-1:
|
||||
tactical: Moose Mt
|
||||
timeoutLength: 25 minutes
|
||||
W1FN-5:
|
||||
tactical: Hanover
|
||||
timeoutLength: 25 minutes
|
||||
W1FN-9:
|
||||
tactical: Bath
|
||||
timeoutLength: 25 minutes
|
||||
N1GMC-1:
|
||||
tactical: Dame Hill Rd, Orford
|
||||
timeoutLength: 25 minutes
|
||||
N1GMC-2:
|
||||
tactical: Sunday Mt, Orford
|
||||
timeoutLength: 25 minutes
|
||||
KB1FDA-1:
|
||||
tactical: Corinth
|
||||
timeoutLength: 25 minutes
|
||||
|
||||
# Vehicles
|
||||
K1EHZ-10: Recovery
|
||||
|
Loading…
Reference in New Issue
Block a user