Skip to content

Commit cb3818c

Browse files
authored
Merge pull request #142 from HyperloopUPV-H8/develop
Merge logger fix
2 parents 57521f4 + 02e2ea2 commit cb3818c

12 files changed

Lines changed: 128 additions & 30 deletions

File tree

backend/pkg/logger/logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
const (
1313
Name = "loggerHandler"
1414
HandlerName = "logger"
15-
TimestampFormat = "01-Jan-2006_15-04-05.000"
15+
TimestampFormat = "02-Jan-2006_15-04-05.000"
1616
)
1717

1818
// Logger is a struct that implements the abstraction.Logger interface

control-station/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
type="image/svg+xml"
88
href="/vite.svg"
99
/>
10+
<link rel="preconnect" href="https://fonts.googleapis.com">
11+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
12+
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
1013
<meta
1114
name="viewport"
1215
content="width=device-width, initial-scale=1.0"

control-station/package-lock.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.background {
2+
position: relative;
3+
height: 3rem;
4+
width: 100%;
5+
background-color: #000;
6+
overflow: hidden;
7+
}
8+
9+
.infoContainer {
10+
position: absolute;
11+
padding: 0rem 2rem;
12+
width: 100%;
13+
height: 100%;
14+
display: flex;
15+
justify-content: space-between;
16+
align-items: center;
17+
}
18+
19+
.bar {
20+
position: absolute;
21+
top: -25%;
22+
left: -2%;
23+
filter: blur(10px);
24+
background-color: red;
25+
width: 40%;
26+
height: 150%;
27+
transition: width 0.1s ease-in-out;
28+
}
29+
30+
.title {
31+
opacity: .8;
32+
font-size: 24px;
33+
font-style: italic;
34+
font-weight: 300;
35+
}
36+
37+
.value {
38+
opacity: .8;
39+
font-size: 32px;
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { NumericMeasurement, useMeasurementsStore } from "common";
2+
import styles from "./BarIndicator.module.scss";
3+
import { getPercentFromRange, getState, stateToColor, stateToColorBackground } from "state";
4+
5+
interface Props {
6+
icon?: string;
7+
title: string;
8+
measurement: NumericMeasurement;
9+
}
10+
11+
export const BarIndicator = ({icon, title, measurement}: Props) => {
12+
13+
const state = getState(measurement);
14+
const percentage = getPercentFromRange(measurement.value.last, measurement.safeRange[0]!!, measurement.safeRange[1]!!)
15+
16+
return (
17+
<div
18+
className={styles.background}
19+
style={{backgroundColor: stateToColorBackground[state]}}
20+
>
21+
<div
22+
className={styles.bar}
23+
style={{width: percentage + "%", backgroundColor: stateToColor[state]}}
24+
></div>
25+
26+
<div className={styles.infoContainer}>
27+
<div>
28+
<div className={styles.icon}>{icon}</div>
29+
<div className={styles.title}>{title}</div>
30+
</div>
31+
<div>
32+
<div className={styles.value}>{measurement.value.last}</div>
33+
<div className={styles.unit}>{measurement.units}</div>
34+
</div>
35+
</div>
36+
</div>
37+
)
38+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.backgroundArc {
2-
stroke: rgba(0, 0, 0, 0.049);
2+
stroke: #c4d7e5a1;
33
}
44

55
.radialShadowArc {
@@ -9,16 +9,16 @@
99
.rainbowArc {
1010
background: conic-gradient(
1111
from 220deg,
12-
#7295ef,
13-
60deg,
14-
#7aefcc,
15-
130deg,
16-
#efe84a,
17-
190deg,
18-
#ffab2c,
19-
240deg,
20-
#ff1e1e,
21-
330deg,
22-
#7295ef
12+
#91e473,
13+
40deg,
14+
#9BF37C,
15+
80deg,
16+
#F4E55E,
17+
120deg,
18+
#F4E55E,
19+
220deg,
20+
#F3785C,
21+
310deg,
22+
#F3785C
2323
);
2424
}

control-station/src/components/GaugeTag/Gauge/Gauge.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ export const Gauge = ({
4545
radius={radius}
4646
strokeWidth={strokeWidth}
4747
></BackgroundArc>
48-
49-
{/* <BackgroundArc
50-
sweep={sweep}
51-
className={styles.radialShadowArc}
52-
percentage={percentage}
53-
radius={radius}
54-
strokeWidth={strokeWidth}
55-
></BackgroundArc> */}
5648
</svg>
5749
);
5850
};

control-station/src/components/GaugeTag/GaugeTag.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
@use "../../styles/colors";
2+
13
.gaugeTagWrapper {
24
display: grid;
35
grid-template-columns: min-content;
46
justify-items: center;
57
align-items: center;
68
margin-bottom: -1.87em;
9+
background-color: map-get($map: colors.$key-colors, $key: lightskyblue);
10+
padding: 1rem;
11+
border-radius: 100%;
712
}
813

914
.gauge {
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use "../../../styles/fonts.scss";
2+
13
.textData {
24
display: flex;
35
flex-direction: column;
@@ -10,19 +12,22 @@
1012

1113
.name {
1214
font-weight: inherit;
13-
font-size: 0.7em;
14-
font-weight: 400;
15+
font-family: map-get($map: fonts.$font-families, $key: roboto);
16+
font-size: map-get($map: fonts.$font-sizes, $key: x-small);
17+
font-weight: map-get($map: fonts.$font-weights, $key: light);
18+
font-style: italic;
1519
}
1620

1721
.value {
18-
font-family: var(--font-mono);
22+
font-family: map-get($map: fonts.$font-families, $key: roboto);
1923
font-size: 1.8em;
20-
font-weight: 600;
24+
font-weight: map-get($map: fonts.$font-weights, $key: bold);
2125
}
2226

2327
.units {
2428
font-weight: inherit;
25-
font-size: 1em;
26-
font-weight: 400;
29+
font-family: map-get($map: fonts.$font-families, $key: roboto);
30+
font-size: map-get($map: fonts.$font-sizes, $key: small);
31+
font-weight: map-get($map: fonts.$font-weights, $key: normal);
2732
}
2833
}

control-station/src/state.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export const stateToColor = {
1919
fault: "hsl(356, 90%, 61%)",
2020
};
2121

22+
export const stateToColorBackground = {
23+
stable: "hsl(92, 82%, 86%)",
24+
warning: "hsl(52, 90%, 86%)",
25+
fault: "hsl(356, 90%, 86%)",
26+
};
27+
2228
export function getState(meas: Measurement): State {
2329
if (isNumericMeasurement(meas)) {
2430
return getStateFromRange(
@@ -63,3 +69,8 @@ export function getStateFromRange(
6369

6470
return "fault";
6571
}
72+
73+
export function getPercentFromRange(value: number, min: number, max: number): number {
74+
const normValue = Math.max(Math.min(value, max), min);
75+
return ((normValue - min) / (max - min)) * 100;
76+
}

0 commit comments

Comments
 (0)