mirror of
https://github.com/cesanta/mongoose.git
synced 2026-09-30 21:42:42 +07:00
Remove points
This commit is contained in:
+2
-4
@@ -3255,12 +3255,9 @@ static inline size_t mg_print_field(mg_pfn_t fn, void *arg, va_list *ap) {
|
||||
} else if (f->type == MG_VAL_INT) {
|
||||
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
||||
} else if (f->type == MG_VAL_DBL) {
|
||||
n += mg_xprintf(fn, arg, "%g", *(double *) f->value);
|
||||
n += mg_xprintf(fn, arg, "%.2f", *(double *) f->value);
|
||||
} else if (f->type == MG_VAL_STR) {
|
||||
// struct mg_str *s = * (struct mg_str *) f->value;
|
||||
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
||||
// } else if (f->type == MG_VAL_FN) {
|
||||
// n += mg_xprintf(fn, arg, val.fn ? "%M" : "null", val.fn);
|
||||
} else {
|
||||
n += mg_xprintf(fn, arg, "null");
|
||||
}
|
||||
@@ -3313,6 +3310,7 @@ static inline void mg_dash_send_change(struct mg_mgr *mgr, struct mg_dash *dash,
|
||||
const char *name) {
|
||||
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
||||
if (set != NULL) {
|
||||
if (set->sync) set->sync(false);
|
||||
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
||||
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
||||
mg_print_field_set, set);
|
||||
|
||||
+2
-4
@@ -110,12 +110,9 @@ static inline size_t mg_print_field(mg_pfn_t fn, void *arg, va_list *ap) {
|
||||
} else if (f->type == MG_VAL_INT) {
|
||||
n += mg_xprintf(fn, arg, "%d", *(int *) f->value);
|
||||
} else if (f->type == MG_VAL_DBL) {
|
||||
n += mg_xprintf(fn, arg, "%g", *(double *) f->value);
|
||||
n += mg_xprintf(fn, arg, "%.2f", *(double *) f->value);
|
||||
} else if (f->type == MG_VAL_STR) {
|
||||
// struct mg_str *s = * (struct mg_str *) f->value;
|
||||
n += mg_xprintf(fn, arg, "%m", MG_ESC(f->value));
|
||||
// } else if (f->type == MG_VAL_FN) {
|
||||
// n += mg_xprintf(fn, arg, val.fn ? "%M" : "null", val.fn);
|
||||
} else {
|
||||
n += mg_xprintf(fn, arg, "null");
|
||||
}
|
||||
@@ -168,6 +165,7 @@ static inline void mg_dash_send_change(struct mg_mgr *mgr, struct mg_dash *dash,
|
||||
const char *name) {
|
||||
struct mg_field_set *set = mg_dash_find_field_set(dash, mg_str(name));
|
||||
if (set != NULL) {
|
||||
if (set->sync) set->sync(false);
|
||||
mg_dash_broadcast(mgr, "{%m:%m,%m:{%m:%M}}", MG_ESC("method"),
|
||||
MG_ESC("change"), MG_ESC("params"), MG_ESC(set->name),
|
||||
mg_print_field_set, set);
|
||||
|
||||
@@ -32,7 +32,7 @@ static void sync_control(bool is_write) {
|
||||
}
|
||||
|
||||
// Read-only device Metrics
|
||||
static int s_ram = 32, s_cpu = 37, s_humidity = 59;
|
||||
static int s_ram = 32, s_cpu = 7, s_humidity = 59;
|
||||
static double s_temperature = 24.8;
|
||||
|
||||
static struct mg_field fields_metrics[] = {
|
||||
@@ -45,8 +45,9 @@ static struct mg_field fields_metrics[] = {
|
||||
|
||||
static void sync_metrics(bool is_write) {
|
||||
if (is_write) return;
|
||||
// Read values from hardware into the state variables
|
||||
// s_ram = calculate_current_free_ram();
|
||||
s_ram = 25 + (rand() % 16); // Sumulate metric change
|
||||
s_cpu = 7 + (rand() % 21);
|
||||
s_temperature = 14.8 + ((double)rand() / RAND_MAX) * 20.0;
|
||||
}
|
||||
|
||||
// Read-write device settings
|
||||
@@ -127,8 +128,7 @@ void mongoose_poll(void) {
|
||||
{
|
||||
// Send metrics change periodically
|
||||
static uint64_t timer = 0;
|
||||
if (mg_timer_expired(&timer, 30000, mg_now())) {
|
||||
sync_metrics(false);
|
||||
if (mg_timer_expired(&timer, 300, mg_now())) {
|
||||
mg_dash_send_change(&s_mgr, &s_dashboard, "metrics");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Dashboard.init({
|
||||
debug: true,
|
||||
data: {
|
||||
points: [],
|
||||
chart1: {data: ''},
|
||||
controls: {
|
||||
fan: true,
|
||||
relay1: false,
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
--spacing-2: 0.5rem;
|
||||
--spacing-3: 0.75rem;
|
||||
--spacing-4: 1rem;
|
||||
--spacing-5: 1.25rem;
|
||||
--spacing-6: 1.5rem;
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -46,7 +48,7 @@ body {
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--spacing-4);
|
||||
padding: var(--spacing-2) var(--spacing-3);
|
||||
padding: var(--spacing-2) var(--spacing-4);
|
||||
}
|
||||
|
||||
.header-left {
|
||||
@@ -134,7 +136,7 @@ body {
|
||||
.tab-stage {
|
||||
max-width: var(--max-width);
|
||||
margin: 0 auto;
|
||||
padding: 5.5rem var(--spacing-3) var(--spacing-3);
|
||||
padding: 5.5rem var(--spacing-4) var(--spacing-4);
|
||||
}
|
||||
|
||||
.tab-panel {
|
||||
|
||||
Reference in New Issue
Block a user