From a353585d4750cd5532a2da951041329d641996f9 Mon Sep 17 00:00:00 2001 From: Sergey Savelyev Date: Thu, 5 Dec 2024 20:10:31 -0800 Subject: [PATCH] more lines --- examples/simple_producer/src/main.rs | 75 ++++++++++++++++ frontend/src/assets/main.scss | 7 ++ frontend/src/assets/variables.scss | 59 +++++++++---- frontend/src/components/GraphAxis.vue | 4 +- frontend/src/components/SvgGraph.vue | 76 +++++++++++++--- frontend/src/components/TelemetryLine.vue | 102 ++++++++++++---------- frontend/src/graph/graph.ts | 3 +- frontend/src/views/HomeView.vue | 18 +++- frontend/vite.config.ts | 7 ++ 9 files changed, 269 insertions(+), 82 deletions(-) diff --git a/examples/simple_producer/src/main.rs b/examples/simple_producer/src/main.rs index 294c001..6f07eef 100644 --- a/examples/simple_producer/src/main.rs +++ b/examples/simple_producer/src/main.rs @@ -122,6 +122,21 @@ async fn main() -> Result<(), Box> { let sin_tlm_handle = tlm.register("simple_producer/sin".into(), TelemetryDataType::Float32).await?; let cos_tlm_handle = tlm.register("simple_producer/cos".into(), TelemetryDataType::Float64).await?; + let sin2_tlm_handle = tlm.register("simple_producer/sin2".into(), TelemetryDataType::Float32).await?; + let cos2_tlm_handle = tlm.register("simple_producer/cos2".into(), TelemetryDataType::Float64).await?; + + let sin3_tlm_handle = tlm.register("simple_producer/sin3".into(), TelemetryDataType::Float32).await?; + let cos3_tlm_handle = tlm.register("simple_producer/cos3".into(), TelemetryDataType::Float64).await?; + + let sin4_tlm_handle = tlm.register("simple_producer/sin4".into(), TelemetryDataType::Float32).await?; + let cos4_tlm_handle = tlm.register("simple_producer/cos4".into(), TelemetryDataType::Float64).await?; + + let sin5_tlm_handle = tlm.register("simple_producer/sin5".into(), TelemetryDataType::Float32).await?; + let cos5_tlm_handle = tlm.register("simple_producer/cos5".into(), TelemetryDataType::Float64).await?; + + let sin6_tlm_handle = tlm.register("simple_producer/sin6".into(), TelemetryDataType::Float32).await?; + let cos6_tlm_handle = tlm.register("simple_producer/cos6".into(), TelemetryDataType::Float64).await?; + let cancellation_token = CancellationToken::new(); { let cancellation_token = cancellation_token.clone(); @@ -149,6 +164,66 @@ async fn main() -> Result<(), Box> { ), chrono::Utc::now(), ).await?; + sin2_tlm_handle.publish( + Value::Float32( + (f32::TAU() * (index as f32) / (500.0_f32)).sin() + ), + chrono::Utc::now(), + ).await?; + cos2_tlm_handle.publish( + Value::Float64( + (f64::TAU() * (index as f64) / (500.0_f64)).cos() + ), + chrono::Utc::now(), + ).await?; + sin3_tlm_handle.publish( + Value::Float32( + (f32::TAU() * (index as f32) / (333.0_f32)).sin() + ), + chrono::Utc::now(), + ).await?; + cos3_tlm_handle.publish( + Value::Float64( + (f64::TAU() * (index as f64) / (333.0_f64)).cos() + ), + chrono::Utc::now(), + ).await?; + sin4_tlm_handle.publish( + Value::Float32( + (f32::TAU() * (index as f32) / (250.0_f32)).sin() + ), + chrono::Utc::now(), + ).await?; + cos4_tlm_handle.publish( + Value::Float64( + (f64::TAU() * (index as f64) / (250.0_f64)).cos() + ), + chrono::Utc::now(), + ).await?; + sin5_tlm_handle.publish( + Value::Float32( + (f32::TAU() * (index as f32) / (200.0_f32)).sin() + ), + chrono::Utc::now(), + ).await?; + cos5_tlm_handle.publish( + Value::Float64( + (f64::TAU() * (index as f64) / (200.0_f64)).cos() + ), + chrono::Utc::now(), + ).await?; + sin6_tlm_handle.publish( + Value::Float32( + (f32::TAU() * (index as f32) / (166.0_f32)).sin() + ), + chrono::Utc::now(), + ).await?; + cos6_tlm_handle.publish( + Value::Float64( + (f64::TAU() * (index as f64) / (166.0_f64)).cos() + ), + chrono::Utc::now(), + ).await?; } Ok(()) diff --git a/frontend/src/assets/main.scss b/frontend/src/assets/main.scss index e349e28..a77d7a3 100644 --- a/frontend/src/assets/main.scss +++ b/frontend/src/assets/main.scss @@ -1,4 +1,5 @@ @use '@/assets/variables'; +@use 'sass:list'; body { color: variables.$text-color; @@ -18,3 +19,9 @@ body { polyline { stroke-width: 1px; } + +@for $i from 1 through list.length(variables.$colors) { + .indexed-color.color-#{$i - 1} { + #{--indexed-color}: list.nth(variables.$colors, $i); + } +} diff --git a/frontend/src/assets/variables.scss b/frontend/src/assets/variables.scss index d3af187..80439a2 100644 --- a/frontend/src/assets/variables.scss +++ b/frontend/src/assets/variables.scss @@ -1,19 +1,48 @@ -$white-1: oklch(90% 0 0); -$white-2: oklch(80% 0 0); -$gray-1: oklch(70% 0 0); -$gray-2: oklch(60% 0 0); -$gray-3: oklch(50% 0 0); -$gray-4: oklch(40% 0 0); -$gray-5: oklch(30% 0 0); -$black-1: oklch(20% 0 0); -$black-2: oklch(10% 0 0); +$gray-1: oklch(90% 0 0); +$gray-2: oklch(80% 0 0); +$gray-3: oklch(70% 0 0); +$gray-4: oklch(60% 0 0); +$gray-5: oklch(50% 0 0); +$gray-6: oklch(40% 0 0); +$gray-7: oklch(30% 0 0); +$gray-8: oklch(20% 0 0); +$gray-9: oklch(10% 0 0); -$text-color: $white-1; -$background-color: $gray-5; +$red-1: oklch(75% 0.4 030); +$orange-1: oklch(75% 0.4 090); +$green-1: oklch(75% 0.4 150); +$cyan-1: oklch(75% 0.4 210); +$blue-1: oklch(75% 0.4 270); +$magenta-1: oklch(75% 0.4 330); -$time-tick: $white-1; -$grid-line: $white-1; -$major-tick: $gray-2; -$minor-tick: $gray-3; +$red-2: oklch(75% 0.2 030); +$orange-2: oklch(75% 0.2 090); +$green-2: oklch(75% 0.2 150); +$cyan-2: oklch(75% 0.2 210); +$blue-2: oklch(75% 0.2 270); +$magenta-2: oklch(75% 0.2 330); + +$text-color: $gray-1; +$background-color: $gray-7; + +$time-tick: $gray-1; +$grid-line: $gray-1; +$major-tick: $gray-4; +$minor-tick: $gray-5; $text-font: Helvetica, sans-serif; + +$colors: ( + $red-1, + $green-1, + $blue-1, + $orange-1, + $cyan-1, + $magenta-1, + $red-2, + $green-2, + $blue-2, + $orange-2, + $cyan-2, + $magenta-2 +); diff --git a/frontend/src/components/GraphAxis.vue b/frontend/src/components/GraphAxis.vue index 6d0ef8e..9b588cb 100644 --- a/frontend/src/components/GraphAxis.vue +++ b/frontend/src/components/GraphAxis.vue @@ -267,9 +267,7 @@ const lines = computed(() => { - - - + diff --git a/frontend/src/graph/graph.ts b/frontend/src/graph/graph.ts index b73823e..26d6960 100644 --- a/frontend/src/graph/graph.ts +++ b/frontend/src/graph/graph.ts @@ -1,4 +1,4 @@ -import type { MaybeRefOrGetter } from 'vue'; +import type { MaybeRefOrGetter, Ref } from 'vue'; export const GRAPH_DATA = Symbol(); @@ -9,4 +9,5 @@ export interface GraphData { width: MaybeRefOrGetter; height: MaybeRefOrGetter; x_map: (x: number) => number; + lines: Ref; } diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index e231b91..6af2e12 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -18,11 +18,23 @@ provide(WEBSOCKET_SYMBOL, websocket); :border_left_right="128" > - - + + + + + + + + + + + + - + diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index e7ef5fb..71744b1 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -25,5 +25,12 @@ export default defineConfig({ rewriteWsOrigin: true, } } + }, + css: { + preprocessorOptions: { + scss: { + api: 'modern-compiler' + } + } } })