-
Notifications
You must be signed in to change notification settings - Fork 0
/
TelemetryView.js
127 lines (119 loc) · 6.05 KB
/
TelemetryView.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*******************************************************************************
* Copyright (c) 2019 Dortmund University of Applied Sciences and Arts and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Dortmund University of Applied Sciences and Arts - initial API and implementation
*******************************************************************************/
import React, { Component } from 'react';
import SockJsClient from 'react-stomp';
import { withStyles } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid';
import { Subscribe } from 'unstated'
import { compose } from 'recompose';
import FormRow from '../../components/FormRow/FormRow';
import TelemetryContainer from '../../containers/TelemetryContainer'
import './TelemetryView.css';
const styles = theme => ({
root: {
flexGrow: 1,
},
paper: {
padding: theme.spacing.unit,
textAlign: 'center',
color: theme.palette.text.secondary,
},
});
//TODO: Couldn't be tested because rover software does not connect to hono to send telemetry data
class Telemetry extends Component {
render() {
const { classes, roverID } = this.props;
//will cause problems if the database does not contain the following infomation: core0, core1, core2, core3, ! See the implemented data to see which data shouldn't be missed !
return (
<Subscribe to={[TelemetryContainer]}>
{telemetryContainer => (
<div>
<SockJsClient url='http://localhost:8081/gs-guide-websocket'
topics={['/topic/' + roverID + '/telemetry']}
onMessage={telemetryContainer.handleTelemetryUpdate}
ref={(client) => { this.clientRef = client }} />
{Object.keys(telemetryContainer.state.telemetryTelegram).length > 0 && telemetryContainer.state.telemetryTelegram.cores != null ? ( //testing just one object, but this is not 100% safe. Check for more when nessassary
<div className="main" >
<Grid container spacing={8}>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes} name1="Timestamp" value1={telemetryContainer.state.telemetryTelegram.timestamp} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Core 0" value1={telemetryContainer.state.telemetryTelegram.cores.core0}
name2="Core 1" value2={telemetryContainer.state.telemetryTelegram.cores.core1}
name3="Core 2" value3={telemetryContainer.state.telemetryTelegram.cores.core2}
name4="Core 3" value4={telemetryContainer.state.telemetryTelegram.cores.core3}
/>
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Ultrasonic Front"
name2="Ultrasonic Rear"
value1={telemetryContainer.state.telemetryTelegram.ultrasonic.front}
value2={telemetryContainer.state.telemetryTelegram.ultrasonic.rear} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Infrared Front Left"
name2="Infrared Front Right"
name3="Infrared Rear Left"
name4="Infrared Rear Right"
value1={telemetryContainer.state.telemetryTelegram.infrared.frontLeft}
value2={telemetryContainer.state.telemetryTelegram.infrared.frontRight}
value3={telemetryContainer.state.telemetryTelegram.infrared.rearLeft}
value4={telemetryContainer.state.telemetryTelegram.infrared.rearRight} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Accelerometer X"
name2="Accelerometer Y"
name3="Accelerometer Z"
value1={telemetryContainer.state.telemetryTelegram.gy521.accelerometer.x}
value2={telemetryContainer.state.telemetryTelegram.gy521.accelerometer.y}
value3={telemetryContainer.state.telemetryTelegram.gy521.accelerometer.z} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Angle X"
name2="Angle Y"
name3="Angle Z"
value1={telemetryContainer.state.telemetryTelegram.gy521.angle.x}
value2={telemetryContainer.state.telemetryTelegram.gy521.angle.y}
value3={telemetryContainer.state.telemetryTelegram.gy521.angle.z} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes}
name1="Gyroscope X"
name2="Gyroscope Y"
name3="Gyroscope Z"
value1={telemetryContainer.state.telemetryTelegram.gy521.gyroscope.x}
value2={telemetryContainer.state.telemetryTelegram.gy521.gyroscope.y}
value3={telemetryContainer.state.telemetryTelegram.gy521.gyroscope.z} />
</Grid>
<Grid container item xs={12} spacing={8}>
<FormRow classes={classes} name1="Bearing" value1={telemetryContainer.state.telemetryTelegram.hmc5883l.bearing} />
</Grid>
</Grid>
</div >)
: (<div>Lädt</div>)}
</div>
)}
</Subscribe>
);
}
}
export default compose(
withStyles(styles)
)(Telemetry);