104 lines
4.3 KiB
TypeScript
104 lines
4.3 KiB
TypeScript
import React, {Component} from 'react';
|
|
|
|
import Paper from '@mui/material/Paper';
|
|
import {Grid, Table, TableBody, TableCell, TableContainer, TableRow,} from "@mui/material";
|
|
import {DefaultService, detector_status} from "../openapi";
|
|
import powerchip = detector_status.powerchip;
|
|
import state = detector_status.state;
|
|
|
|
type MyProps = {}
|
|
|
|
type MyState = {
|
|
s: detector_status,
|
|
connection_error: boolean
|
|
}
|
|
|
|
class DetectorStatus extends Component<MyProps, MyState> {
|
|
interval : NodeJS.Timer | undefined;
|
|
state : MyState = {
|
|
s: {
|
|
state: state.IDLE,
|
|
powerchip: powerchip.OFF,
|
|
server_version: "Detector off",
|
|
number_of_triggers_left: 0,
|
|
fpga_temp_degC: [0,0,0,0,0,1],
|
|
high_voltage_V: [1,0,0,0,-1]
|
|
},
|
|
connection_error: true
|
|
}
|
|
|
|
getValues() {
|
|
DefaultService.getDetectorStatus()
|
|
.then(data => this.setState({
|
|
s: data,
|
|
connection_error: false
|
|
}))
|
|
.catch(error => {
|
|
this.setState({
|
|
s: {
|
|
state: state.IDLE,
|
|
powerchip: powerchip.OFF,
|
|
server_version: "Detector off",
|
|
number_of_triggers_left: 0,
|
|
fpga_temp_degC: [30,29,35,40,32],
|
|
high_voltage_V: [120,120,110,115]
|
|
},
|
|
connection_error: true
|
|
});
|
|
});
|
|
}
|
|
componentDidMount() {
|
|
this.getValues();
|
|
this.interval = setInterval(() => this.getValues(), 1000);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
clearInterval(this.interval);
|
|
}
|
|
|
|
render() {
|
|
return <Paper style={{textAlign: 'center'}} sx={{ height: 800, width: '100%' }}>
|
|
<Grid container spacing={0}>
|
|
<Grid item xs={1}/>
|
|
<Grid item xs={10}>
|
|
<br/><strong>Detector status</strong><br/><br/>
|
|
|
|
<TableContainer component={Paper} style={{marginLeft: "auto", marginRight: "auto"}}>
|
|
<Table size="small" aria-label="simple table">
|
|
<TableBody>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> Detector state: </TableCell>
|
|
<TableCell align="right">{(this.state.s.state.toString())}</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> Detector ASIC power: </TableCell>
|
|
<TableCell align="right">{this.state.s.powerchip.toString()}</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> Triggers remaining: </TableCell>
|
|
<TableCell align="right">{this.state.s.number_of_triggers_left}</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> FPGA temperature: </TableCell>
|
|
<TableCell align="right">{Math.min(...this.state.s.fpga_temp_degC)} - {Math.max(...this.state.s.fpga_temp_degC)}°C</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> High voltage: </TableCell>
|
|
<TableCell align="right">{Math.min(...this.state.s.high_voltage_V)} - {Math.max(...this.state.s.high_voltage_V)} V</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableCell component="th" scope="row"> Detector server version: </TableCell>
|
|
<TableCell align="right">{this.state.s.server_version} </TableCell>
|
|
</TableRow>
|
|
</TableBody>
|
|
</Table>
|
|
</TableContainer>
|
|
<br/>
|
|
</Grid>
|
|
<Grid item xs={1}/>
|
|
</Grid>
|
|
</Paper>
|
|
}
|
|
}
|
|
|
|
export default DetectorStatus; |