Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: show task details in system info view #1299

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/WebApi_sysstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
root["chipcores"] = ESP.getChipCores();
root["flashsize"] = ESP.getFlashChipSize();

JsonArray taskDetails = root["task_details"].to<JsonArray>();
static std::array<char const*, 12> constexpr task_names = {
"IDLE0", "IDLE1", "wifi", "tiT", "loopTask", "async_tcp", "mqttclient",
"HUAWEI_CAN_0", "PM:SDM", "PM:HTTP+JSON", "PM:SML", "PM:HTTP+SML"
};
for (char const* task_name : task_names) {
TaskHandle_t const handle = xTaskGetHandle(task_name);
if (!handle) { continue; }
JsonObject task = taskDetails.add<JsonObject>();
task["name"] = task_name;
task["stack_watermark"] = uxTaskGetStackHighWaterMark(handle);
task["priority"] = uxTaskPriorityGet(handle);
}

String reason;
reason = ResetReason::get_reset_reason_verbose(0);
root["resetreason_0"] = reason;
Expand Down
40 changes: 40 additions & 0 deletions webapp/src/components/TaskDetails.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<CardElement :text="$t('taskdetails.TaskDetails')" textVariant="text-bg-primary">
<div class="table-responsive">
<table class="table table-hover table-condensed">
<tbody>
<tr>
<th>{{ $t('taskdetails.Name') }}</th>
<th>{{ $t('taskdetails.StackFree') }}</th>
<th>{{ $t('taskdetails.Priority') }}</th>
</tr>
<tr v-for="task in taskDetails" v-bind:key="task.name">
<td>{{ $te(taskLangToken(task.name)) ? $t(taskLangToken(task.name)) : task.name }}</td>
<td>{{ $n(task.stack_watermark, 'byte') }}</td>
<td>{{ task.priority }}</td>
</tr>
</tbody>
</table>
</div>
</CardElement>
</template>

<script lang="ts">
import CardElement from '@/components/CardElement.vue';
import type { TaskDetail } from '@/types/SystemStatus';
import { defineComponent, type PropType } from 'vue';

export default defineComponent({
components: {
CardElement,
},
props: {
taskDetails: { type: Array as PropType<TaskDetail[]>, required: true },
},
methods: {
taskLangToken(rawTask: string) {
return 'taskdetails.Task_' + rawTask.replace(/[^A-Za-z0-9]/g, '').toLowerCase();
},
},
});
</script>
18 changes: 18 additions & 0 deletions webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@
"MaxUsage": "Maximale Speichernutzung seit Start",
"Fragmentation": "Grad der Fragmentierung"
},
"taskdetails": {
"TaskDetails": "Detailinformationen zu Tasks",
"Name": "Name",
"StackFree": "Stack Frei",
"Priority": "Priorität",
"Task_idle0": "Leerlauf (CPU-Kern 0)",
"Task_idle1": "Leerlauf (CPU-Kern 1)",
"Task_wifi": "Wi-Fi",
"Task_tit": "TCP/IP",
"Task_looptask": "Arduino Hauptschleife (loop)",
"Task_asynctcp": "Async TCP",
"Task_mqttclient": "MQTT Client",
"Task_huaweican0": "AC Ladegerät CAN",
"Task_pmsdm": "Stromzähler (SDM)",
"Task_pmhttpjson": "Stromzähler (HTTP+JSON)",
"Task_pmsml": "Stromzähler (Serial SML)",
"Task_pmhttpsml": "Stromzähler (HTTP+SML)"
},
"radioinfo": {
"RadioInformation": "Funkmodulinformationen",
"Status": "{module} Status",
Expand Down
18 changes: 18 additions & 0 deletions webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@
"MaxUsage": "Maximum usage since start",
"Fragmentation": "Level of fragmentation"
},
"taskdetails": {
"TaskDetails": "Task Details",
"Name": "Name",
"StackFree": "Stack Free",
"Priority": "Priority",
"Task_idle0": "Idle (CPU Core 0)",
"Task_idle1": "Idle (CPU Core 1)",
"Task_wifi": "Wi-Fi",
"Task_tit": "TCP/IP",
"Task_looptask": "Arduino Main Loop",
"Task_asynctcp": "Async TCP",
"Task_mqttclient": "MQTT Client",
"Task_huaweican0": "AC Charger CAN",
"Task_pmsdm": "PowerMeter (SDM)",
"Task_pmhttpjson": "PowerMeter (HTTP+JSON)",
"Task_pmsml": "PowerMeter (Serial SML)",
"Task_pmhttpsml": "PowerMeter (HTTP+SML)"
},
"radioinfo": {
"RadioInformation": "Radio Information",
"Status": "{module} Status",
Expand Down
8 changes: 8 additions & 0 deletions webapp/src/types/SystemStatus.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
export interface TaskDetail {
name: string;
stack_watermark: number;
priority: number;
}

export interface SystemStatus {
// HardwareInfo
chipmodel: string;
Expand All @@ -6,6 +12,8 @@ export interface SystemStatus {
cpufreq: number;
cputemp: number;
flashsize: number;
// TaskDetails
task_details: TaskDetail[];
// FirmwareInfo
hostname: string;
sdkversion: string;
Expand Down
4 changes: 4 additions & 0 deletions webapp/src/views/SystemInfoView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<div class="mt-5"></div>
<HeapDetails :systemStatus="systemDataList" />
<div class="mt-5"></div>
<TaskDetails :taskDetails="systemDataList.task_details" />
<div class="mt-5"></div>
<RadioInfo :systemStatus="systemDataList" />
<div class="mt-5"></div>
</BasePage>
Expand All @@ -19,6 +21,7 @@ import FirmwareInfo from '@/components/FirmwareInfo.vue';
import HardwareInfo from '@/components/HardwareInfo.vue';
import MemoryInfo from '@/components/MemoryInfo.vue';
import HeapDetails from '@/components/HeapDetails.vue';
import TaskDetails from '@/components/TaskDetails.vue';
import RadioInfo from '@/components/RadioInfo.vue';
import type { SystemStatus } from '@/types/SystemStatus';
import { authHeader, handleResponse } from '@/utils/authentication';
Expand All @@ -31,6 +34,7 @@ export default defineComponent({
HardwareInfo,
MemoryInfo,
HeapDetails,
TaskDetails,
RadioInfo,
},
data() {
Expand Down