• Creato un nuovo file CSS per gli stili del chiosco (kiosk) con variabili, stili per le schede (card) e animazioni. • Aggiunto un file HTML per l'interfaccia della mappa utilizzando Mapbox, inclusi gli stili e il JavaScript per le funzionalità della mappa. • Introdotto un file JSON per i riferimenti ai sensori, definendo percorsi ed elementi per i dati di temperatura, vento, onde, posizione, batteria, motore e sistema. Co-authored-by: Copilot <copilot@github.com>
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
const skFlow = require('../../config/skFlow');
|
|
const { liveMarkup } = require('../utility/live');
|
|
|
|
const logsPaths = [
|
|
"navigation.position",
|
|
"navigation.headingTrue",
|
|
"navigation.speedOverGround",
|
|
"propulsion.p1.temperature"
|
|
];
|
|
|
|
module.exports = {
|
|
command: 'data',
|
|
handler: (bot, msg) => {
|
|
const chatId = msg.chat.id;
|
|
let text = '';
|
|
|
|
// Telemetria
|
|
const logs = skFlow.getFrom(logsPaths);
|
|
text += '*Telemetria di Bordo*\n\n';
|
|
if (logs && Object.keys(logs).length > 0) {
|
|
for (const [path, value] of Object.entries(logs)) {
|
|
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
text += `*${path}*: ${displayValue}\n`;
|
|
}
|
|
} else {
|
|
text += 'Nessun dato disponibile.\n';
|
|
}
|
|
|
|
// Meteo
|
|
const weather = skFlow.getWithFilter('meb.forecast');
|
|
text += '\n*Dati Meteo*\n\n';
|
|
if (weather && Object.keys(weather).length > 0) {
|
|
for (const [path, value] of Object.entries(weather)) {
|
|
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
text += `*${path}*: ${displayValue}\n`;
|
|
}
|
|
} else {
|
|
text += 'Nessun dato disponibile.\n';
|
|
}
|
|
|
|
// Mare
|
|
const marine = skFlow.getWithFilter('meb.marine');
|
|
text += '\n*Dati Meteo del mare*\n\n';
|
|
if (marine && Object.keys(marine).length > 0) {
|
|
for (const [path, value] of Object.entries(marine)) {
|
|
const displayValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
text += `*${path}*: ${displayValue}\n`;
|
|
}
|
|
} else {
|
|
text += 'Nessun dato disponibile.\n';
|
|
}
|
|
|
|
bot.sendMessage(chatId, text, {
|
|
parse_mode: 'Markdown',
|
|
reply_to_message_id: msg.message_id,
|
|
reply_markup: liveMarkup(msg.message_id, 'data')
|
|
});
|
|
}
|
|
};
|