diff --git a/src/model/channels.ts b/src/model/channels.ts index 5150ff4..b35cafc 100644 --- a/src/model/channels.ts +++ b/src/model/channels.ts @@ -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 { [key: string]: JsonSerializable; diff --git a/src/model/messages/baro-data.ts b/src/model/messages/baro-data.ts new file mode 100644 index 0000000..c4b0690 --- /dev/null +++ b/src/model/messages/baro-data.ts @@ -0,0 +1,22 @@ +import { DataMessage } from '../channels'; +import { JsonSerializable } from '@wuespace/telestion-client-types'; + +export interface PressureData extends Record { + pressure: number; +} + +export interface TemperatureData extends Record { + temperature: number; +} + +export interface AltitudeData extends Record { + altitude: number; +} + +export interface BaroDataData extends Record { + press: PressureData; + temp: TemperatureData; + alt: AltitudeData; +} + +export type BaroDataMessage = DataMessage; diff --git a/src/model/sample-graph-definitions.ts b/src/model/sample-graph-definitions.ts index 4e74efc..8788077 100644 --- a/src/model/sample-graph-definitions.ts +++ b/src/model/sample-graph-definitions.ts @@ -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, @@ -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, diff --git a/src/model/sample-user-config.ts b/src/model/sample-user-config.ts index b24f9be..0566c75 100644 --- a/src/model/sample-user-config.ts +++ b/src/model/sample-user-config.ts @@ -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'; @@ -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, diff --git a/src/plugins/mock-server-plugin.ts b/src/plugins/mock-server-plugin.ts index 9cd74d8..87c8f35 100644 --- a/src/plugins/mock-server-plugin.ts +++ b/src/plugins/mock-server-plugin.ts @@ -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 ( @@ -111,6 +118,29 @@ export function onReady() { connection.write(bare2); // stringify entire message! console.log('<--- Message sent -', bare2); + const baroDataState: DataMessage = { + 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',