Commit 81f5e52d authored by Stu Fisher's avatar Stu Fisher

allow changing options during acq, add min/max options

parent 19060a86
Pipeline #17694 passed with stages
in 1 minute and 39 seconds
import config from '../config'
import { setImgDisplay } from './options'
//////////////////////////////////////////BUTTON////////////////////////////////////////////////////////
export function linearClicked(){
return { type: 'LINEAR_CLICKED'}
return (dispatch,getState) => {
dispatch({ type: 'LINEAR_CLICKED'})
const state = getState()
dispatch(setOptions({ lut_method: state.video.selectedLut}))
}
}
export function logarithmicClicked(){
return { type: 'LOGARITHMIC_CLICKED'}
return (dispatch,getState) => {
dispatch({ type: 'LOGARITHMIC_CLICKED'})
const state = getState()
dispatch(setOptions({ lut_method: state.video.selectedLut}))
}
}
export function updateBackground(){
......@@ -97,14 +107,55 @@ export function liveChecked() {
}
export function autoscaleChecked(){
return { type:"AUTOSCALE_CHECKED"}
return (dispatch,getState) => {
dispatch({ type:"AUTOSCALE_CHECKED"})
const state = getState()
dispatch(setOptions({ autoscale: state.video.autoscaleCheckedBool}))
}
}
export function temperatureChecked(){
return { type:"TEMPERATURE_CHECKED"}
return (dispatch,getState) => {
dispatch({ type:"TEMPERATURE_CHECKED"})
const state = getState()
dispatch(setOptions({ color_map: state.video.temperatureCheckedBool}))
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
export function setLockCrosshair(state) {
return { type:"LOCK_CROSSHAIR", state}
}
export function setOptions(options) {
return (dispatch,getState) => {
const state = getState()
fetch(config.base_url+'/'+state.bpmState.client_id+'/api/set_options', {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify(options)
})
.then((response) => {
if(!response.ok){
throw Error(response.statusText);
}
return response;
}) .then(() => {
if (!state.options.liveCheckedBool) {
dispatch(setImgDisplay())
}
})
}
}
export function updateMin(value) {
return { type: "UPDATE_MIN", value }
}
export function updateMax(value) {
return { type: "UPDATE_MAX", value }
}
import React from 'react';
import { Container,Row,Col,Dropdown,Button,DropdownButton,ButtonGroup,FormCheck,DropdownItem,OverlayTrigger,Tooltip,SplitButton } from 'react-bootstrap';
import { Container,Row,Col,Dropdown,Button,DropdownButton,ButtonGroup,FormCheck,DropdownItem,OverlayTrigger,Tooltip,SplitButton,Form } from 'react-bootstrap';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {linearClicked,logarithmicClicked,autoscaleChecked,temperatureChecked,updateBackground,setRoi,setRotation,setFlip, setCrosshair, setLockCrosshair} from '../actions/video.js'
import {linearClicked,logarithmicClicked,autoscaleChecked,temperatureChecked,updateBackground,setRoi,setRotation,setFlip, setCrosshair, setLockCrosshair, setOptions,updateMin,updateMax} from '../actions/video.js'
import {resetRoi, getStatus, profileSize, updateDimensions,setBeamMark,setBeamMarkDone } from '../actions/canvas.js'
import {setImgDisplay,setLiveChecked} from '../actions/options.js'
import Canvas from '../components/canvas.js'
......@@ -16,6 +16,9 @@ class Video extends React.Component {
this.resetCROSSHAIR = this.resetCROSSHAIR.bind(this);
this.rotation = this.rotation.bind(this);
this.graph = this.graph.bind(this);
this.updateMin = this.updateMin.bind(this);
this.updateMax = this.updateMax.bind(this);
this.saveMinMax = this.saveMinMax.bind(this);
this.graph_profilX = undefined;
this.graph_profilY = undefined;
......@@ -34,6 +37,7 @@ class Video extends React.Component {
) {
this.graph(prevProps);
}
}
resetCROSSHAIR() {
......@@ -161,6 +165,18 @@ class Video extends React.Component {
this.props.setLockCrosshair(!this.props.lockCrosshair)
}
updateMin(e) {
this.props.updateMin(parseInt(e.target.value))
}
updateMax(e) {
this.props.updateMax(parseInt(e.target.value))
}
saveMinMax() {
this.props.setOptions({ min_max: this.props.min_max })
}
render() {
const crosshair = (
<Tooltip id="tooltip">Click here to set/lock crosshair data: X={this.props.beam_markX} Y={this.props.beam_markY}</Tooltip>
......@@ -218,6 +234,22 @@ class Video extends React.Component {
<FormCheck type="checkbox" onChange={this.props.autoscaleChecked} label="Autoscale" id="autoscale-check" checked={this.props.autoscaleCheckedBool} />
<FormCheck type="checkbox" onChange={this.props.temperatureChecked} label="Temperature color" id="temp-check" checked={this.props.temperatureCheckedBool} />
</Container>
<Dropdown.Divider />
<Container>
<Form.Group as={Row}>
<Form.Label column sm={3}>Min: </Form.Label>
<Col sm={9}>
<Form.Control type="number" value={this.props.min_max[0]} onChange={this.updateMin} />
</Col>
</Form.Group>
<Form.Group as={Row}>
<Form.Label column sm={3}>Min: </Form.Label>
<Col sm={9}>
<Form.Control type="number" value={this.props.min_max[1]} onChange={this.updateMax} />
</Col>
</Form.Group>
<Button onClick={this.saveMinMax}>Save</Button>
</Container>
</DropdownButton>
</OverlayTrigger>
......@@ -291,6 +323,7 @@ function mapStateToProps(state) {
calib_y: state.options.calib_y,
temperatureCheckedBool: state.video.temperatureCheckedBool,
autoscaleCheckedBool: state.video.autoscaleCheckedBool,
min_max: state.video.min_max
};
}
......@@ -314,6 +347,9 @@ function mapDispatchToProps(dispatch) {
setBeamMarkDone:bindActionCreators(setBeamMarkDone,dispatch),
setLiveChecked:bindActionCreators(setLiveChecked,dispatch),
setLockCrosshair:bindActionCreators(setLockCrosshair,dispatch),
setOptions:bindActionCreators(setOptions,dispatch),
updateMin:bindActionCreators(updateMin,dispatch),
updateMax:bindActionCreators(updateMax,dispatch),
};
}
......
......@@ -10,6 +10,7 @@ const initialState = {
activeROIServer:false,
rotation: 0,
flip: [false, false],
min_max: [0, 65536],
};
......@@ -23,9 +24,9 @@ export default function video(state = initialState, action) {
const crosshair = action.status.beam_mark_x && action.status.beam_mark_y;
if(action.status.background===true){
alert('A background is already set, you can reset it by clicking on the \'Bkgnd\' button')
return Object.assign({}, state, {backgroundstate: 0, activeBkgnd:true, activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair})
return Object.assign({}, state, {backgroundstate: 0, activeBkgnd:true, activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max})
} else {
return Object.assign({}, state, { activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair})
return Object.assign({}, state, { activeROIServer: action.status.roi, rotation: action.status.rotation, flip: action.status.flip, selectedLut: action.status.lut_method, temperatureCheckedBool: action.status.color_map, autoscaleCheckedBool: action.status.autoscale, activeCrosshair: crosshair, min_max: action.status.min_max})
}
}
......@@ -104,6 +105,16 @@ export default function video(state = initialState, action) {
return Object.assign({}, state, {lockCrosshair: action.state})
}
case 'UPDATE_MIN':
{
return Object.assign({}, state, {min_max: [action.value, state.min_max[1]]})
}
case 'UPDATE_MAX':
{
return Object.assign({}, state, {min_max: [state.min_max[0], action.value]})
}
default:
return state
}
......
......@@ -224,6 +224,7 @@ class BVWebserver:
"acq_rate": self.getAcqRate(camera),
"color_map": 1 if self.cameras_running[camera][1].color_map else 0,
"autoscale": 1 if self.cameras_running[camera][1].autoscale else 0,
"min_max": self.cameras_running[camera][1].min_max.tolist(),
"lut_method": 'Logarithmic' if self.cameras_running[camera][1].lut_method == 'LOG' else 'Linear',
"calib_x": self.cameras_running[camera][1].calibration[0],
"calib_y": self.cameras_running[camera][1].calibration[1],
......@@ -261,6 +262,29 @@ class BVWebserver:
print ("Could not set flip")
def set_options(self, camera):
if "color_map" in bottle.request.json:
self.cameras_running[camera][1].color_map = bool(int(bottle.request.json["color_map"]))
return { "message": "color_map updated"}
if "autoscale" in bottle.request.json:
self.cameras_running[camera][1].autoscale = bool(int(bottle.request.json["autoscale"]))
return { "message": "autoscale updated"}
if "lut_method" in bottle.request.json:
if bottle.request.json["lut_method"] == "Logarithmic":
self.cameras_running[camera][1].lut_method = "LOG"
else:
self.cameras_running[camera][1].lut_method = "LINEAR"
return { "message": "lut_method updated"}
if "min_max" in bottle.request.json:
mm = bottle.request.json["min_max"]
self.cameras_running[camera][1].min_max = [int(mm[0]), int(mm[1])]
return { "message": "min_max updated"}
def imgdisplay(self,camera):
if not self.checkstatus(camera):
return bottle.HTTPResponse(status=400, body={"message": "camera/bpm not running"})
......@@ -268,14 +292,6 @@ class BVWebserver:
if self.getAcqStatus(camera) != 'Ready':
return bottle.HTTPResponse(status=400, body={ "message": "cant modify parameters while an acquisition is in progres" })
self.cameras_running[camera][1].color_map = bool(int(bottle.request.query.color_map))
self.cameras_running[camera][1].autoscale = bool(int(bottle.request.query.autoscale))
if bottle.request.query.lut_method == "Logarithmic":
self.cameras_running[camera][1].lut_method = "LOG"
else:
self.cameras_running[camera][1].lut_method = "LINEAR"
self.cameras_running[camera][1].calibration = ([float(bottle.request.query.calib_x), float(bottle.request.query.calib_y)])
self.setExposuretime(float(bottle.request.query.exp_t), camera)
self.setAcqRate(float(bottle.request.query.acq_rate), camera)
......@@ -446,6 +462,7 @@ class BVWebserver:
self.app.route('/<camera>/api/set_roi', callback=self.setroi)
self.app.route('/<camera>/api/set_rotation', callback=self.set_rotation)
self.app.route('/<camera>/api/set_flip', callback=self.set_flip)
self.app.route('/<camera>/api/set_options', callback=self.set_options, method="POST")
self.app.route('/<camera>/api/img_display_config', callback=self.imgdisplay)
self.app.route('/<camera>/api/img_display', callback=self.getimgdisplay)
self.app.route('/<camera>/api/stop', callback=self.stop_acq)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment