diff --git a/frontend_ui/src/App.tsx b/frontend_ui/src/App.tsx index 5773aa18..3beaa8e3 100644 --- a/frontend_ui/src/App.tsx +++ b/frontend_ui/src/App.tsx @@ -9,6 +9,7 @@ import Calibration from "./components/Calibration"; import StatusBar from "./components/StatusBar"; import DataProcessingPlots from "./components/DataProcessingPlots"; import DetectorSelection from "./components/DetectorSelection"; +import BkgEstimatePlot from "./components/BkgEstimatePlot"; const jfjoch_theme = createTheme({ palette: { @@ -34,6 +35,11 @@ class App extends Component { alignItems="center" spacing={3} sx={{width: "95%"}}> + + + + + diff --git a/frontend_ui/src/components/BkgEstimatePlot.tsx b/frontend_ui/src/components/BkgEstimatePlot.tsx new file mode 100644 index 00000000..25a2b3f8 --- /dev/null +++ b/frontend_ui/src/components/BkgEstimatePlot.tsx @@ -0,0 +1,40 @@ +/* + * Copyright (2019-2023) Paul Scherrer Institute + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import Paper from "@mui/material/Paper"; +import DataProcessingPlot from "./DataProcessingPlot"; +import React, {Component} from "react"; +import {handleErrors} from "./handleErrors"; +import PlotWrapper from "./PlotWrapper"; +import {Box} from "@mui/material"; + +type MyProps = { + addr: string; +}; + + +class BkgEstimatePlot extends Component { + addr: string; + + constructor(props: MyProps) { + super(props); + this.addr = props.addr; + } + + render() { + return + +
+
Background estimate
+
+ +
+
+
+ } +} + +export default BkgEstimatePlot; \ No newline at end of file diff --git a/frontend_ui/src/components/DataProcessingPlot.tsx b/frontend_ui/src/components/DataProcessingPlot.tsx new file mode 100644 index 00000000..69ce01b2 --- /dev/null +++ b/frontend_ui/src/components/DataProcessingPlot.tsx @@ -0,0 +1,73 @@ +import React, {Component} from 'react'; + +import PlotWrapper from "./PlotWrapper"; +import {handleErrors} from "./handleErrors"; + +type MyProps = { + addr: string; + type: string; + xlabel: string; + ylabel: string; + binning: number; +}; + +type Plot = { + x: number[], + y: number[] +} + +type MyState = { + plot : Plot, + connection_error: boolean +} + +class DataProcessingPlot extends Component { + addr: string; + interval: undefined | NodeJS.Timer; + + state: MyState = { + plot: { + x: [0,100,200,300,400,500], + y: [0.1, 0.3,0.5, 0.2, 0.0, 0.1] + }, + connection_error: true + } + + constructor(props: MyProps) { + super(props); + this.addr = props.addr; + } + + getValues() { + fetch(this.addr + 'data_processing/plots', { + method: "POST", + body: JSON.stringify({type: this.props.type, binning: this.props.binning}) + }).then(handleErrors) + .then(res => res.json()) + .then(data => this.setState({plot: data, connection_error: false})) + .catch(error => { + console.log(error); + this.setState({connection_error: true}); + }); + } + componentDidMount() { + this.getValues(); + this.interval = setInterval(() => this.getValues(), 500); + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + render() { + if (this.state.plot !== undefined) + return + else + return
; + + } +} + +export default DataProcessingPlot; + diff --git a/frontend_ui/src/components/DataProcessingPlots.tsx b/frontend_ui/src/components/DataProcessingPlots.tsx index d8a46320..25834a53 100644 --- a/frontend_ui/src/components/DataProcessingPlots.tsx +++ b/frontend_ui/src/components/DataProcessingPlots.tsx @@ -1,27 +1,18 @@ import React, {Component} from 'react'; import Paper from '@mui/material/Paper'; -import PlotWrapper from "./PlotWrapper"; import {Box, Tab, Tabs} from "@mui/material"; -import {handleErrors} from "./handleErrors"; +import DataProcessingPlot from "./DataProcessingPlot"; type MyProps = { addr: string; }; -type Plot = { - x: number[], - y: number[] -} - type MyState = { - plots : { - indexingRate: Plot | undefined, - bkgEstimate: Plot | undefined, - spotCount: Plot | undefined, - radialIntProfile: Plot | undefined - }, - tab: number, + type: string, + xlabel: string, + ylabel: string, + tab : number, connection_error: boolean } @@ -30,24 +21,9 @@ class DataProcessingPlots extends Component { interval: undefined | NodeJS.Timer; state: MyState = { - plots : { - indexingRate: { - x: [0,100,200,300,400,500], - y: [0.1, 0.3,0.5, 0.2, 0.0, 0.1] - }, - bkgEstimate: { - x: [0,100,200,300,400,500], - y: [50.1, 35.0, 20.4, 11.5, 7.1, 9.6] - }, - spotCount: { - x: [0,100,200,300,400,500], - y: [12,13,45,11,5,47] - }, - radialIntProfile: { - x: [0,100,200,300,400,500], - y: [12,13,45,11,5,47] - } - }, + type: "INDEXING_RATE", + xlabel: "Indexing rate", + ylabel: "Photon count", tab: 1, connection_error: true } @@ -57,71 +33,34 @@ class DataProcessingPlots extends Component { this.addr = props.addr; } - getValues() { - fetch(this.addr + 'data_processing/plots') - .then(handleErrors) - .then(res => res.json()) - .then(data => this.setState({plots: data, connection_error: false})) - .catch(error => { - console.log(error); - this.setState({connection_error: true}); - }); - } - componentDidMount() { - this.getValues(); - this.interval = setInterval(() => this.getValues(), 1000); - } - - componentWillUnmount() { - clearInterval(this.interval); - } - tabsOnChange = (event: React.SyntheticEvent, value: number) => { this.setState({tab: value}); - } - - selectPlot() { - switch (this.state.tab) { + switch (value) { case 1: - if (this.state.plots.indexingRate !== undefined) - return ; - else return
+ this.setState({type: "INDEXING_RATE", xlabel: "Image number", ylabel: "Indexing rate"}); + break; case 2: - if (this.state.plots.bkgEstimate !== undefined) - return ; - else return
+ this.setState({type: "SPOT_COUNT", xlabel: "Image number", ylabel: "Spot count" }); + break; case 3: - if (this.state.plots.spotCount !== undefined) - return ; - else return
- case 4: - if (this.state.plots.radialIntProfile !== undefined) - return ; - else return
- default: - return
+ this.setState({type: "RAD_INT", xlabel: "Q [A^-1]", ylabel: "Photon count"}); + break; } } + render() { return - - - - + + - - {this.selectPlot()} + - } } diff --git a/python/jfjoch_grpc2http.py b/python/jfjoch_grpc2http.py index ce56980d..af77db06 100644 --- a/python/jfjoch_grpc2http.py +++ b/python/jfjoch_grpc2http.py @@ -185,7 +185,7 @@ async def get_settings(data: str = Body(...)): raise HTTPException(status_code=400, detail=e.details()) -@app.put("/detector/measurement_statistics") +@app.get("/detector/measurement_statistics") async def get_meas_stats(): try: stub = jfjoch_pb2_grpc.gRPC_JFJochBrokerStub(channel)