Skip to content

Commit 4e00e0a

Browse files
authored
Merge pull request #152 from HyperloopUPV-H8/control-station/first-version
Control station first functional version
2 parents b79759f + d542709 commit 4e00e0a

213 files changed

Lines changed: 4022 additions & 4292 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build control station
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
paths:
8+
- control-station/**
9+
- common-front/**
10+
11+
jobs:
12+
build-control-station:
13+
name: 'Build control station'
14+
runs-on: ubuntu-latest
15+
16+
env:
17+
FRONTEND_DIR: ./control-station
18+
COMMON_DIR: ./common-front
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
sparse-checkout: |
24+
control-station
25+
common-front
26+
27+
- name: 'Install common front dependencies'
28+
working-directory: '${{env.COMMON_DIR}}'
29+
run: npm install
30+
31+
- name: 'Build common front'
32+
working-directory: '${{env.COMMON_DIR}}'
33+
run: npm run build
34+
35+
- name: 'Install control station dependencies'
36+
working-directory: '${{env.FRONTEND_DIR}}'
37+
run: npm install
38+
39+
- name: 'Build control station'
40+
working-directory: '${{env.FRONTEND_DIR}}'
41+
run: npm run build
42+
43+
- name: 'Upload build'
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: control-station
47+
path: '${{env.FRONTEND_DIR}}/static/*'
48+
retention-days: 3
49+
compression-level: 9

backend/cmd/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ files = "/"
1414
boards = ["VCU"]
1515

1616
[excel.download]
17-
id="1NyNaAOw_6iWtnCpEg73AtSSFx1fMdhPRmmdOhjgjCZI"
17+
id = "1NyNaAOw_6iWtnCpEg73AtSSFx1fMdhPRmmdOhjgjCZI"
1818
name = "ade.xlsx"
1919
path = "."
2020

backend/internal/excel/utils/units.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func ParseUnits(literal string, globalUnits map[string]Operations) (Units, error
3434
ops, ok := globalUnits[parts[0]]
3535

3636
if !ok {
37-
return Units{}, fmt.Errorf("units \"%s\" not found in global", parts[0])
37+
return Units{Name: parts[0], Operations: make(Operations, 0)}, fmt.Errorf("units \"%s\" not found in global", parts[0])
3838
}
3939

4040
return Units{
@@ -44,13 +44,13 @@ func ParseUnits(literal string, globalUnits map[string]Operations) (Units, error
4444
}
4545

4646
if len(parts) != 2 {
47-
return Units{}, fmt.Errorf("units %v can only have 2 parts", parts)
47+
return Units{Name: parts[0], Operations: make(Operations, 0)}, fmt.Errorf("units %v can only have 2 parts", parts)
4848
}
4949

5050
operations, err := NewOperations(parts[1])
5151

5252
if err != nil {
53-
return Units{}, err
53+
return Units{Name: parts[0], Operations: make(Operations, 0)}, err
5454
}
5555

5656
return Units{

backend/internal/pod_data/measurement.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,7 @@ func getMeasurements(adeMeasurements []ade.Measurement, globalUnits map[string]u
3535

3636
func getMeasurement(adeMeas ade.Measurement, globalUnits map[string]utils.Operations) (Measurement, error) {
3737
if isNumeric(adeMeas.Type) {
38-
m, err := getNumericMeasurement(adeMeas, globalUnits)
39-
40-
if err != nil {
41-
return nil, err
42-
}
43-
return m, nil
38+
return getNumericMeasurement(adeMeas, globalUnits)
4439
} else if adeMeas.Type == "bool" {
4540
return getBooleanMeasurement(adeMeas), nil
4641
} else if strings.HasPrefix(adeMeas.Type, "enum") {

backend/pkg/http/handlers.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ import (
55
"encoding/json"
66
"io"
77
"net/http"
8+
"sync"
89
"time"
910
)
1011

1112
type handleData struct {
1213
name string
1314
modTime time.Time
1415
data io.ReadSeeker
16+
dataMx *sync.Mutex
1517
}
1618

1719
func HandleData(name string, data io.ReadSeeker) *handleData {
1820
return &handleData{
1921
name: name,
2022
modTime: time.Now(),
2123
data: data,
24+
dataMx: new(sync.Mutex),
2225
}
2326
}
2427

@@ -39,6 +42,8 @@ func (handle *handleData) ServeHTTP(writer http.ResponseWriter, request *http.Re
3942
writer.Header().Set("Cache-Control", "no-cache")
4043
writer.Header().Set("Pragma", "no-cache")
4144
writer.Header().Set("Access-Control-Allow-Origin", "*")
45+
handle.dataMx.Lock()
46+
defer handle.dataMx.Unlock()
4247
http.ServeContent(writer, request, handle.name, handle.modTime, handle.data)
4348
}
4449

common-front/lib/adapters/PodData.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export type MeasurementAdapter =
2727

2828
export type NumericMeasurementAdapter = Omit<NumericMeasurement, 'value'>;
2929
export type BooleanMeasurementAdapter = Omit<BooleanMeasurement, 'value'>;
30-
export type EnumMeasurementAdapter = Omit<EnumMeasurement, 'value'>;
30+
export type EnumMeasurementAdapter = { options: string[] } & Omit<
31+
EnumMeasurement,
32+
'value'
33+
>;
3134

3235
export function createPodDataFromAdapter(adapter: PodDataAdapter): PodData {
3336
const boards: Board[] = Object.values(adapter.boards).map(
@@ -117,7 +120,7 @@ export function getEnumMeasurement(
117120
id: id,
118121
name: adapter.name,
119122
type: 'enum',
120-
value: 'Default',
123+
value: adapter.options[0],
121124
};
122125
}
123126

common-front/lib/components/Caret/Caret.module.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.caretWrapper {
2-
width: min-content;
3-
height: min-content;
42
display: flex;
53
justify-content: center;
64
align-items: center;

common-front/lib/components/Caret/Caret.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import styles from "./Caret.module.scss";
2-
import { BsFillCaretRightFill } from "react-icons/bs";
1+
import styles from './Caret.module.scss';
2+
import { BsFillCaretRightFill } from 'react-icons/bs';
33
type Props = {
44
isOpen: boolean;
55
onClick?: () => void;
66
className?: string;
77
};
88

9-
export const Caret = ({ isOpen, onClick, className = "" }: Props) => {
9+
export const Caret = ({ isOpen, onClick, className = '' }: Props) => {
1010
return (
1111
<div
12-
className={`${styles.caretWrapper} ${className}`}
12+
className={`${className} ${styles.caretWrapper}`}
1313
onClick={onClick}
14-
style={{ transform: isOpen ? "rotate(90deg)" : "" }}
14+
style={{ transform: isOpen ? 'rotate(90deg)' : '' }}
1515
>
1616
{<BsFillCaretRightFill />}
1717
</div>

common-front/lib/components/ColorfulChart/ColorfulChart.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
import styles from "./ColorfulChart.module.scss";
2-
import { Legend } from "./Legend/Legend";
3-
import { Title } from "./Title/Title";
4-
import { LinesChart } from "../LinesChart/LinesChart";
5-
import { LineDescription } from "../LinesChart/types";
6-
import { useMemo } from "react";
1+
import styles from './ColorfulChart.module.scss';
2+
import { Legend } from './Legend/Legend';
3+
import { Title } from './Title/Title';
4+
import { LinesChart } from '../LinesChart/LinesChart';
5+
import { LineDescription } from '../LinesChart/types';
6+
import { useMemo } from 'react';
77

8-
const palette = ["#EE8735", "#51C6EB", "#7BEE35", "#e469ca"];
8+
const palette = ['#EE8735', '#51C6EB', '#7BEE35', '#e469ca'];
99

1010
type Props = {
1111
className?: string;
12-
title: string;
12+
title?: string;
1313
items: LineDescription[];
1414
length: number;
1515
height?: string;
16+
showLegend?: boolean;
17+
showTitle?: boolean;
1618
};
1719

1820
export const ColorfulChart = ({
19-
className = "",
20-
title,
21+
className = '',
22+
title = '',
2123
items,
2224
length,
23-
height = "8rem",
25+
height = '8rem',
26+
showLegend = false,
27+
showTitle = false,
2428
}: Props) => {
2529
const itemsWithPalette = useMemo(
2630
() =>
@@ -33,7 +37,7 @@ export const ColorfulChart = ({
3337

3438
return (
3539
<div className={`${styles.colorfulChart} ${className}`}>
36-
<Title title={title} />
40+
{showTitle && <Title title={title} />}
3741
<div className={styles.body}>
3842
<LinesChart
3943
height={height}
@@ -42,7 +46,7 @@ export const ColorfulChart = ({
4246
items={itemsWithPalette}
4347
length={length}
4448
/>
45-
<Legend items={itemsWithPalette} />
49+
{showLegend && <Legend items={itemsWithPalette} />}
4650
</div>
4751
</div>
4852
);

common-front/lib/components/ColorfulChart/Legend/Legend.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import styles from "./Legend.module.scss";
2-
import { LegendItem } from "./LegendItem/LegendItem";
3-
import { LineDescription } from "../../LinesChart/types";
1+
import styles from './Legend.module.scss';
2+
import { LegendItem } from './LegendItem/LegendItem';
3+
import { LineDescription } from '../../LinesChart/types';
44

55
type Props = {
66
items: LineDescription[];
@@ -14,8 +14,8 @@ export const Legend = ({ items }: Props) => {
1414
<LegendItem
1515
key={item.id}
1616
name={item.name}
17-
units={"A"}
18-
value={item.getUpdate()}
17+
units={'A'}
18+
getValue={item.getUpdate}
1919
color={item.color}
2020
/>
2121
);

0 commit comments

Comments
 (0)