Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
feat(dashboard): Add BaroData graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Mar 2, 2021
1 parent e451b92 commit 45a2a60
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/model/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const Amplitude =
MONGODB_NEW + '/de.jvpichowski.rocketsound.messages.sound.Amplitude';
export const Spectrum =
MONGODB_NEW + '/de.jvpichowski.rocketsound.messages.sound.Spectrum';
export const BaroData =
MONGODB_NEW + '/de.jvpichowski.rocketsound.messages.base.BaroData';

export interface DataMessage<T extends JsonSerializable> {
[key: string]: JsonSerializable;
Expand Down
22 changes: 22 additions & 0 deletions src/model/messages/baro-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DataMessage } from '../channels';
import { JsonSerializable } from '@wuespace/telestion-client-types';

export interface PressureData extends Record<string, JsonSerializable> {
pressure: number;
}

export interface TemperatureData extends Record<string, JsonSerializable> {
temperature: number;
}

export interface AltitudeData extends Record<string, JsonSerializable> {
altitude: number;
}

export interface BaroDataData extends Record<string, JsonSerializable> {
press: PressureData;
temp: TemperatureData;
alt: AltitudeData;
}

export type BaroDataMessage = DataMessage<BaroDataData>;
62 changes: 61 additions & 1 deletion src/model/sample-graph-definitions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphWidgetProps } from '../widgets/graph-widget';
import { NineDOF } from './channels';
import { BaroData, NineDOF } from './channels';

export const accLineGraph: GraphWidgetProps = {
isArea: false,
Expand Down Expand Up @@ -91,6 +91,66 @@ export const magLineGraph: GraphWidgetProps = {
]
};

export const altitudeGraph: GraphWidgetProps = {
isArea: false,
isCartesianGrid: true,
isHoldOnHover: true,
isTooltip: true,
maxDataSamples: 60,
connections: [
{
channel: BaroData,
descriptors: [
{
key: 'result[0].alt.altitude',
title: 'Altitude',
color: 'purple-500'
}
]
}
]
};

export const pressureGraph: GraphWidgetProps = {
isArea: false,
isCartesianGrid: true,
isHoldOnHover: true,
isTooltip: true,
maxDataSamples: 60,
connections: [
{
channel: BaroData,
descriptors: [
{
key: 'result[0].press.pressure',
title: 'Pressure',
color: 'seafoam-500'
}
]
}
]
};

export const temperatureGraph: GraphWidgetProps = {
isArea: false,
isCartesianGrid: true,
isHoldOnHover: true,
isTooltip: true,
maxDataSamples: 60,
connections: [
{
channel: BaroData,
descriptors: [
{
key: 'result[0].temp.temperature',
title: 'Temperature',
color: 'celery-500'
}
]
}
]
};

export const detailsGraph: GraphWidgetProps = {
isArea: true,
isCartesianGrid: true,
Expand Down
32 changes: 28 additions & 4 deletions src/model/sample-user-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { UserConfig } from '@wuespace/telestion-client-types';

import {
accLineGraph,
altitudeGraph,
detailsGraph,
gyroLineGraph,
magLineGraph
magLineGraph,
pressureGraph,
temperatureGraph
} from './sample-graph-definitions';
import { Amplitude } from './channels';
import { WaveformWidgetProps } from '../widgets/waveform-widget';
Expand Down Expand Up @@ -122,11 +125,32 @@ export const userConfig: UserConfig = {
},
{
widgetName: 'graphWidget',
width: 6,
width: 2,
height: 4,
title: 'Details',
initialProps: detailsGraph
title: 'Altitude',
initialProps: altitudeGraph
},
{
widgetName: 'graphWidget',
width: 2,
height: 4,
title: 'Pressure',
initialProps: pressureGraph
},
{
widgetName: 'graphWidget',
width: 2,
height: 4,
title: 'Temperature',
initialProps: temperatureGraph
},
// {
// widgetName: 'graphWidget',
// width: 6,
// height: 4,
// title: 'Details',
// initialProps: detailsGraph
// },
{
widgetName: 'stateWidget',
width: 2,
Expand Down
32 changes: 31 additions & 1 deletion src/plugins/mock-server-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import http from 'http';
import sockjs from 'sockjs';
import { Amplitude, FlightState, NineDOF, Spectrum } from '../model/channels';
import {
Amplitude,
BaroData,
DataMessage,
FlightState,
Spectrum
} from '../model/channels';
import { SpectrumMessage } from '../model/messages/spectrum';

import { AmplitudeMessage, FlightStateMessage } from '../model/messages';
import { BaroDataData } from '../model/messages/baro-data';

export function onReady() {
if (
Expand Down Expand Up @@ -111,6 +118,29 @@ export function onReady() {
connection.write(bare2); // stringify entire message!
console.log('<--- Message sent -', bare2);

const baroDataState: DataMessage<BaroDataData> = {
result: [
{
alt: { altitude: 5 },
press: { pressure: 3 },
temp: { temperature: 100 }
}
],
className: 'a',
dataType: 'a'
};

const message4 = {
type: 'rec',
address: BaroData,
body: baroDataState
};

const bare4 = JSON.stringify(message4);

connection.write(bare4); // stringify entire message!
console.log('<--- Message sent -', bare4);

const spectrumMessage: SpectrumMessage = {
dataType: 'abc',
className: 'abc',
Expand Down

0 comments on commit 45a2a60

Please sign in to comment.