diff --git a/Software/waveview/src/App.tsx b/Software/waveview/src/App.tsx index e6e998d..7094a34 100644 --- a/Software/waveview/src/App.tsx +++ b/Software/waveview/src/App.tsx @@ -19,14 +19,6 @@ class App extends React.Component { color: string, className:string }[]; - triggerInformation: { - channel: string, - mode: string - }; - timePerDivisionInformation: { - timeValue: number, - timeUnit: string - } constructor(props: any) { super(props); @@ -41,14 +33,6 @@ class App extends React.Component { {color: "#0075FF", className: "Channel3"}, {color: "#FF0000", className: "Channel4"} ] - this.triggerInformation = { - channel: "CH1", - mode: "RisingEdge" - } - this.timePerDivisionInformation = { - timeValue: 10, - timeUnit: "ns" - } } componentDidMount() { @@ -83,11 +67,7 @@ class App extends React.Component { dataSeries={this.generatorList.map((gen, idx) => gen.getData())} colorSeries={this.channelList.map((c, i) => c.color)} /> - + ); diff --git a/Software/waveview/src/components/bottombar/bottombar.tsx b/Software/waveview/src/components/bottombar/bottombar.tsx index 3128893..7650b72 100644 --- a/Software/waveview/src/components/bottombar/bottombar.tsx +++ b/Software/waveview/src/components/bottombar/bottombar.tsx @@ -4,48 +4,15 @@ import TimePerDivision from './subcomponents/timeperdivision'; import Trigger from './subcomponents/trigger'; import './../../css/bottombar/bottombar.css'; -interface IBottomBarProps { - channelList: { - color: string, - className: string - }[] - triggerInformation: { - channel: string, - mode: string - }; - timePerDivisionInformation: { - timeValue: number, - timeUnit: string - } -} - -function BottomBar(props: IBottomBarProps) { +function BottomBar() { return (
- { - props.channelList.map((c, i) => { - return ( - - ) - }) - } - - - + + + + + +
) } diff --git a/Software/waveview/src/components/bottombar/subcomponents/channel.tsx b/Software/waveview/src/components/bottombar/subcomponents/channel.tsx index 774b96f..69fea62 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/channel.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/channel.tsx @@ -1,25 +1,31 @@ import React from 'react'; +import { connect } from 'react-redux'; import './../../../css/bottombar/subscomponents/channel.css'; -interface IChannelProps { - channelNumber: number - voltsPerDiv: number - voltageValue: number - voltageUnit: string - measurementType: string - channelClass: string - channelColor: string -}; - -function Channel(props: IChannelProps) { - return ( -
- -
- ) +class Channel extends React.Component { + render() { + return ( +
+ +
+ ) + } } - -export default Channel; + +function mapStateToProps(state: { verticalWidget: any; }) { + return { + verticalWidget: state.verticalWidget + }; +} + +export default connect(mapStateToProps)(Channel); \ No newline at end of file diff --git a/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx b/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx index acad0d7..13181e5 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx @@ -1,17 +1,22 @@ import React from 'react'; +import { connect } from 'react-redux'; import './../../../css/bottombar/subscomponents/timeperdivision.css'; -interface ITimePerDivisionProps { - timeValue: number, - timeUnit: string +class TimePerDivision extends React.Component { + render() { + return( +
+ {this.props.horizontalWidget.horizontalTimeBase.value.toString()} + {this.props.horizontalWidget.horizontalTimeBase.unit} +
+ ) + } } -function TimePerDivision(props: ITimePerDivisionProps) { - return( -
- {props.timeValue}{props.timeUnit}/div -
- ) +function mapStateToProps(state: { horizontalWidget: any; }) { + return { + horizontalWidget: state.horizontalWidget + }; } -export default TimePerDivision; \ No newline at end of file +export default connect(mapStateToProps)(TimePerDivision); \ No newline at end of file diff --git a/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx b/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx index bae410d..4d6786a 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx @@ -1,17 +1,21 @@ import React from 'react'; +import { connect } from 'react-redux'; import './../../../css/bottombar/subscomponents/trigger.css'; -interface ITriggerProps { - channel: string, - mode: string +class Trigger extends React.Component { + render() { + return ( +
+ Trig:CH{this.props.triggerWidget.triggerChannel}, Mode:{this.props.triggerWidget.triggerType} +
+ ) + } } -function Trigger(props: ITriggerProps) { - return ( -
- Trig:{props.channel}, Mode:{props.mode} -
- ) +function mapStateToProps(state: { triggerWidget: any; }) { + return { + triggerWidget: state.triggerWidget + }; } -export default Trigger; \ No newline at end of file +export default connect(mapStateToProps)(Trigger); \ No newline at end of file diff --git a/Software/waveview/src/components/sidebar/widgets/horizontalWidget.tsx b/Software/waveview/src/components/sidebar/widgets/horizontalWidget.tsx index 4397cd3..cbcacb0 100644 --- a/Software/waveview/src/components/sidebar/widgets/horizontalWidget.tsx +++ b/Software/waveview/src/components/sidebar/widgets/horizontalWidget.tsx @@ -4,12 +4,22 @@ import './../../../css/sidebar/widgets/horizontalWidget.css'; class HorizontalWidget extends React.Component { - incrementValue = (value: any) => { - this.props.dispatch({ type: 'horizontal/increaseValue', payload: value}); + // Horizontal Time Base + incrementTimeBase = () => { + this.props.dispatch({ type: 'horizontal/increaseTimeBase'}); } - decrementValue = (value: any) => { - this.props.dispatch({ type: 'horizontal/decreaseValue' , payload: value}); + decrementTimeBase = () => { + this.props.dispatch({ type: 'horizontal/decreaseTimeBase'}); + } + + // Horizontal Offset + incrementOffset = () => { + this.props.dispatch({ type: 'horizontal/increaseOffset'}); + } + + decrementOffset = () => { + this.props.dispatch({ type: 'horizontal/decreaseOffset'}); } render() { @@ -19,40 +29,40 @@ class HorizontalWidget extends React.Component { Horizontal -
+
-
+
diff --git a/Software/waveview/src/components/sidebar/widgets/verticalWidget.tsx b/Software/waveview/src/components/sidebar/widgets/verticalWidget.tsx index 3fb9bb8..934c244 100644 --- a/Software/waveview/src/components/sidebar/widgets/verticalWidget.tsx +++ b/Software/waveview/src/components/sidebar/widgets/verticalWidget.tsx @@ -1,17 +1,11 @@ import React from 'react'; import { connect } from 'react-redux'; +import DefaultValues from '../../../configuration/defaultValues'; import './../../../css/sidebar/widgets/verticalWidget.css'; class VerticalWidget extends React.Component { - incrementValue = (value: any) => { - this.props.dispatch({ type: 'vertical/increaseValue', payload: value}); - } - - decrementValue = (value: any) => { - this.props.dispatch({ type: 'vertical/decreaseValue' , payload: value}); - } - - increaseChannel = () => { + // Active Channel + increaseChannel = () => { this.props.dispatch({type: 'vertical/increaseChannel'}); } @@ -19,6 +13,24 @@ class VerticalWidget extends React.Component { this.props.dispatch({type: 'vertical/decreaseChannel'}); } + // Vertical Offset + incrementVerticalOffset = () => { + this.props.dispatch({ type: 'vertical/increaseVerticalOffset'}); + } + + decrementVerticalOffset = () => { + this.props.dispatch({ type: 'vertical/decreaseVerticalOffset'}); + } + + // Time Per Division + incrementTimePerDivision = () => { + this.props.dispatch({type: 'vertical/increaseTimePerDivision'}); + } + + decrementTimePerDivision = () => { + this.props.dispatch({type: 'vertical/decreaseTimePerDivision'}); + } + render() { return (
@@ -29,56 +41,56 @@ class VerticalWidget extends React.Component {
-
+
-
+
diff --git a/Software/waveview/src/configuration/defaultValues.tsx b/Software/waveview/src/configuration/defaultValues.tsx new file mode 100644 index 0000000..52828ad --- /dev/null +++ b/Software/waveview/src/configuration/defaultValues.tsx @@ -0,0 +1,74 @@ +const x1ProbeValues = [ + "10V/div", + "5V/div", + "2V/div", + "1V/div", + "500mV/div", + "200mV/div", + "100mV/div", + "50mV/div", + "20mV/div", + "10mV/div", + "5mV/div", + "2mV/div", + "1mV/div" +]; +const x10ProbeValues = [ + "100V/div", + "50V/div", + "20V/div", + "10V/div", + "5V/div", + "2V/div", + "1V/div", + "500mV/div", + "200mV/div", + "100mV/div", + "50mV/div", + "20mV/div", + "10mV/div" +]; +// 13 different voltages per divison presets +// Start at x1ProbeValues[6] and change accordingly + +const horizontalTimeBases = [ + "1ns/div", + "2ns/div", + "5ns/div", + "10ns/div", + "20ns/div", + "50ns/div", + "100ns/div", + "200ns/div", + "500ns/div", + "1µs/div", + "2µs/div", + "5µs/div", + "10µs/div", + "20µs/div", + "50µs/div", + "100µs/div", + "200µs/div", + "500µs/div", + "1ms/div", + "2ms/div", + "5ms/div", + "10ms/div", + "20ms/div", + "50ms/div", + "100ms/div", + "200ms/div", + "500ms/div", + "1s/div", + "2s/div", + "5s/div", + "10s/div" +]; +// 31 different voltages per division presets +// Start at horizontalTimeBases[15] and change accordingly + +export default { + x1ProbeValues, + x10ProbeValues, + horizontalTimeBases +}; \ No newline at end of file diff --git a/Software/waveview/src/configuration/enums/defaultChannelColor.tsx b/Software/waveview/src/configuration/enums/defaultChannelColor.tsx new file mode 100644 index 0000000..3afbb79 --- /dev/null +++ b/Software/waveview/src/configuration/enums/defaultChannelColor.tsx @@ -0,0 +1,8 @@ +enum DefaultChannelColor { + Channel1 = "#EBFF00", + Channel2 = "#00FF19", + Channel3 = "#0075FF", + Channel4 = "#FF0000" +}; + +export default DefaultChannelColor; \ No newline at end of file diff --git a/Software/waveview/src/configuration/enums/measurementType.tsx b/Software/waveview/src/configuration/enums/measurementType.tsx new file mode 100644 index 0000000..17be23d --- /dev/null +++ b/Software/waveview/src/configuration/enums/measurementType.tsx @@ -0,0 +1,6 @@ +enum MeasurementType { + DC = "DC", + AC = "AC" +} + +export default MeasurementType; \ No newline at end of file diff --git a/Software/waveview/src/configuration/enums/timeUnit.tsx b/Software/waveview/src/configuration/enums/timeUnit.tsx new file mode 100644 index 0000000..be97d3f --- /dev/null +++ b/Software/waveview/src/configuration/enums/timeUnit.tsx @@ -0,0 +1,8 @@ +enum TimeUnit { + NanoSecond = "ns", + MicroSecond = "µs", + MilliSecond = "ms", + Second = "s" +} + +export default TimeUnit; \ No newline at end of file diff --git a/Software/waveview/src/configuration/enums/triggerType.tsx b/Software/waveview/src/configuration/enums/triggerType.tsx new file mode 100644 index 0000000..a00c1da --- /dev/null +++ b/Software/waveview/src/configuration/enums/triggerType.tsx @@ -0,0 +1,6 @@ +enum TriggerType { + RisingEdge = "RisingEdge", + FallingEdge = "FallingEdge" +} + +export default TriggerType; \ No newline at end of file diff --git a/Software/waveview/src/configuration/enums/voltageUnit.tsx b/Software/waveview/src/configuration/enums/voltageUnit.tsx new file mode 100644 index 0000000..ef8b9fa --- /dev/null +++ b/Software/waveview/src/configuration/enums/voltageUnit.tsx @@ -0,0 +1,8 @@ +enum VoltageUnit { + NanoVolt = "nV", + MicroVolt = "µV", + MilliVolt = "mV", + Volt = "V" +} + +export default VoltageUnit; \ No newline at end of file diff --git a/Software/waveview/src/css/bottombar/subscomponents/channel.css b/Software/waveview/src/css/bottombar/subscomponents/channel.css index a3da12f..7ac6890 100644 --- a/Software/waveview/src/css/bottombar/subscomponents/channel.css +++ b/Software/waveview/src/css/bottombar/subscomponents/channel.css @@ -11,6 +11,7 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } .Channel2 { @@ -21,6 +22,7 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } .Channel3 { @@ -31,6 +33,7 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } .Channel4 { @@ -41,4 +44,5 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } \ No newline at end of file diff --git a/Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css b/Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css index f83586b..ea82924 100644 --- a/Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css +++ b/Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css @@ -12,4 +12,5 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } \ No newline at end of file diff --git a/Software/waveview/src/css/bottombar/subscomponents/trigger.css b/Software/waveview/src/css/bottombar/subscomponents/trigger.css index 2a47d2c..58583f6 100644 --- a/Software/waveview/src/css/bottombar/subscomponents/trigger.css +++ b/Software/waveview/src/css/bottombar/subscomponents/trigger.css @@ -12,4 +12,5 @@ height: 2vh; background: #4b4b4b; z-index: 1000; + user-select: none; } \ No newline at end of file diff --git a/Software/waveview/src/css/graph/graph.css b/Software/waveview/src/css/graph/graph.css index 4887ff8..7f878da 100644 --- a/Software/waveview/src/css/graph/graph.css +++ b/Software/waveview/src/css/graph/graph.css @@ -20,5 +20,6 @@ color: yellow; margin-top: 54vh; margin-bottom: 0; + user-select: none; } diff --git a/Software/waveview/src/css/sidebar/core/search.css b/Software/waveview/src/css/sidebar/core/search.css index 173efeb..475c9b8 100644 --- a/Software/waveview/src/css/sidebar/core/search.css +++ b/Software/waveview/src/css/sidebar/core/search.css @@ -1,10 +1,12 @@ .Search { text-align: center; display: flex; + user-select: none; } .Searchbar { position: relative; + user-select: none; top: 10px; width: 15vw; height: 2vh; diff --git a/Software/waveview/src/css/sidebar/core/singleButton.css b/Software/waveview/src/css/sidebar/core/singleButton.css index 195df7c..22c19d1 100644 --- a/Software/waveview/src/css/sidebar/core/singleButton.css +++ b/Software/waveview/src/css/sidebar/core/singleButton.css @@ -8,6 +8,7 @@ background: #EBFF00; z-index: 100; border: none; + user-select: none; } .SingleButtonText { @@ -16,4 +17,5 @@ display: flex; position: relative; left: 2vw; + user-select: none; } \ No newline at end of file diff --git a/Software/waveview/src/css/sidebar/core/stopButton.css b/Software/waveview/src/css/sidebar/core/stopButton.css index 5ec7718..ff2c9ae 100644 --- a/Software/waveview/src/css/sidebar/core/stopButton.css +++ b/Software/waveview/src/css/sidebar/core/stopButton.css @@ -8,6 +8,7 @@ background: #FF0000; z-index: 100; border: none; + user-select: none; } .StopButtonText { @@ -16,4 +17,5 @@ display: flex; position: relative; left: 2vw; + user-select: none; } \ No newline at end of file diff --git a/Software/waveview/src/css/sidebar/widgets/horizontalWidget.css b/Software/waveview/src/css/sidebar/widgets/horizontalWidget.css index 3234af9..a14573a 100644 --- a/Software/waveview/src/css/sidebar/widgets/horizontalWidget.css +++ b/Software/waveview/src/css/sidebar/widgets/horizontalWidget.css @@ -2,6 +2,7 @@ text-align: center; display: flex; flex-direction: column; + user-select: none; } .WidgetTitle { @@ -10,16 +11,16 @@ margin: 10px; } -.AdjustValueBlockValue1 { +.AdjustValueBlockHorizontalTimeBase { padding-left: 2vw; padding-right: 2vw; } -.HorizontalWidgetAdjustBlock-Value2 { +.HorizontalWidgetAdjustBlock-HorizontalOffset { margin-top: 1vh; } -.AdjustValueBlockValue2 { +.AdjustValueBlockHorizontalOffset { padding-left: 2vw; padding-right: 2vw; } \ No newline at end of file diff --git a/Software/waveview/src/css/sidebar/widgets/measurementsWidget.css b/Software/waveview/src/css/sidebar/widgets/measurementsWidget.css index feed992..8fb9f2c 100644 --- a/Software/waveview/src/css/sidebar/widgets/measurementsWidget.css +++ b/Software/waveview/src/css/sidebar/widgets/measurementsWidget.css @@ -1,3 +1,7 @@ +.MeasurementsWidget { + user-select: none; +} + .MeasurementsWidgetDisplayValueBlock-Value2 { margin-top: 1vh; } diff --git a/Software/waveview/src/css/sidebar/widgets/verticalWidget.css b/Software/waveview/src/css/sidebar/widgets/verticalWidget.css index bc74dfc..b678cf2 100644 --- a/Software/waveview/src/css/sidebar/widgets/verticalWidget.css +++ b/Software/waveview/src/css/sidebar/widgets/verticalWidget.css @@ -2,6 +2,7 @@ text-align: center; display: flex; flex-direction: column; + user-select: none; } .WidgetTitle { @@ -15,20 +16,20 @@ padding-right: 2vw; } -.VerticalWidgetAdjustBlock-Value1 { +.VerticalWidgetAdjustBlock-TimePerDivision { margin-top: 1vh; } -.AdjustValueBlockValue1 { +.AdjustValueBlockTimePerDivision { padding-left: 2vw; padding-right: 2vw; } -.VerticalWidgetAdjustBlock-Value2 { +.VerticalWidgetAdjustBlock-VerticalOffset { margin-top: 1vh; } -.AdjustValueBlockValue2 { +.AdjustValueBlockVerticalOffset { padding-left: 2vw; padding-right: 2vw; } \ No newline at end of file diff --git a/Software/waveview/src/redux/reducers/horizontalWidgetReducer.tsx b/Software/waveview/src/redux/reducers/horizontalWidgetReducer.tsx index 109b57d..efc8e52 100644 --- a/Software/waveview/src/redux/reducers/horizontalWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/horizontalWidgetReducer.tsx @@ -1,44 +1,57 @@ +import DefaultValues from '../../configuration/defaultValues'; +import TimeUnit from '../../configuration/enums/timeUnit'; + const initialState = { - value1: 0, - value2: 0 + horizontalTimeBase: { + value: DefaultValues.horizontalTimeBases[15], + index: 15 + }, + horizontalOffset: { + value: 0, + unit: TimeUnit.MilliSecond + } }; export default function(state = initialState, action: {type: any, payload: any}) { switch(action.type) { - case "horizontal/increaseValue": - if (action.payload == 1) { - return { - value1: state.value1 + 1, - value2: state.value2 + case "horizontal/increaseTimeBase": + if (state.horizontalTimeBase.index >= 30) { + return { ...state }; + } + return { + ...state, + horizontalTimeBase: { + value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index + 1], + index: state.horizontalTimeBase.index + 1 } } - else if (action.payload == 2) { - return { - value1: state.value1, - value2: state.value2 + 1 + case "horizontal/decreaseTimeBase": + if (state.horizontalTimeBase.index === 0) { + return { ...state }; + } + return { + ...state, + horizontalTimeBase: { + value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index - 1], + index: state.horizontalTimeBase.index - 1 } } - else return { - value1: state.value1, - value2: state.value2 - }; - case "horizontal/decreaseValue": - if (action.payload == 1) { - return { - value1: state.value1 - 1, - value2: state.value2 + case "horizontal/increaseOffset": + return { + ...state, + horizontalOffset: { + ...state.horizontalOffset, + value: state.horizontalOffset.value + 1 } } - else if (action.payload == 2) { - return { - value1: state.value1, - value2: state.value2 - 1 + case "horizontal/decreaseOffset": + return { + ...state, + horizontalOffset: { + ...state.horizontalOffset, + value: state.horizontalOffset.value - 1 } } - else return { - value1: state.value1, - value2: state.value2 - }; default: return state; } diff --git a/Software/waveview/src/redux/reducers/index.tsx b/Software/waveview/src/redux/reducers/index.tsx index 6beb812..9a0ada9 100644 --- a/Software/waveview/src/redux/reducers/index.tsx +++ b/Software/waveview/src/redux/reducers/index.tsx @@ -2,11 +2,13 @@ import { combineReducers } from 'redux'; import horizontalWidgetReducer from './horizontalWidgetReducer'; import verticalWidgetReducer from './verticalWidgetReducer'; import measurementsWidgetReducer from './measurementsWidgetReducer'; +import triggerWidgetReducer from './triggerWidgetReducer'; export default combineReducers( { horizontalWidget: horizontalWidgetReducer, verticalWidget: verticalWidgetReducer, - measurementsWidget: measurementsWidgetReducer + measurementsWidget: measurementsWidgetReducer, + triggerWidget: triggerWidgetReducer } ); diff --git a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx new file mode 100644 index 0000000..76f3d6e --- /dev/null +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -0,0 +1,16 @@ +import TriggerType from '../../configuration/enums/triggerType'; + +const initialState = { + triggerChannel: 1, + triggerType: TriggerType.RisingEdge, + triggerLevel: 0 +}; + +export default function(state = initialState, action: {type: any, payload: any}) { + switch(action.type) { + case "trigger/test": + return { ...state }; + default: + return state; + } +} \ No newline at end of file diff --git a/Software/waveview/src/redux/reducers/verticalWidgetReducer.tsx b/Software/waveview/src/redux/reducers/verticalWidgetReducer.tsx index fa2a0f6..704ebb4 100644 --- a/Software/waveview/src/redux/reducers/verticalWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/verticalWidgetReducer.tsx @@ -1,88 +1,97 @@ +import DefaultValues from '../../configuration/defaultValues'; +import DefaultChannelColor from '../../configuration/enums/defaultChannelColor'; +import MeasurementType from '../../configuration/enums/measurementType'; +import VoltageUnit from '../../configuration/enums/voltageUnit'; + const initialState = { - channel: 1, - channelColorsList: ["#EBFF00", "#00FF19", "#0075FF", "#FF0000"], - value1: 0, - value2: 0 + activeChannel: 1, + channelColorsList: [ + DefaultChannelColor.Channel1, + DefaultChannelColor.Channel2, + DefaultChannelColor.Channel3, + DefaultChannelColor.Channel4 + ], + timePerDivision: [ + {value: DefaultValues.x1ProbeValues[6], index: 6}, + {value: DefaultValues.x1ProbeValues[6], index: 6}, + {value: DefaultValues.x1ProbeValues[6], index: 6}, + {value: DefaultValues.x1ProbeValues[6], index: 6} + ], + verticalOffset: [ + {value: 0, unit: VoltageUnit.MilliVolt}, + {value: 0, unit: VoltageUnit.MilliVolt}, + {value: 0, unit: VoltageUnit.MilliVolt}, + {value: 0, unit: VoltageUnit.MilliVolt} + ], + measurementType: [ + MeasurementType.DC, + MeasurementType.DC, + MeasurementType.DC, + MeasurementType.DC + ] }; export default function(state = initialState, action: {type: any, payload: any}) { + var channelIndex = state.activeChannel - 1; + var tmp; + switch(action.type) { case "vertical/increaseChannel": - if (state.channel >= 4) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 - } + if (state.activeChannel >= 4) { + return { ...state } } return { - channel: state.channel + 1, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 + ...state, + activeChannel: state.activeChannel + 1 }; case "vertical/decreaseChannel": - if (state.channel == 1) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 - } + if (state.activeChannel === 1) { + return { ...state } } return { - channel: state.channel - 1, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 + ...state, + activeChannel: state.activeChannel - 1 }; - case "vertical/increaseValue": - if (action.payload == 1) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1 + 1, - value2: state.value2 - } + case "vertical/increaseVerticalOffset": + tmp = state.verticalOffset; + + tmp[channelIndex].value = state.verticalOffset[channelIndex].value + 1; + return { + ...state, + verticalOffset: tmp } - else if (action.payload == 2) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 + 1 - } + case "vertical/decreaseVerticalOffset": + tmp = state.verticalOffset; + + tmp[channelIndex].value = state.verticalOffset[channelIndex].value - 1; + return { + ...state, + verticalOffset: tmp } - else return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 + case "vertical/increaseTimePerDivision": + if (state.timePerDivision[state.activeChannel - 1].index === 0) { + return { ...state } }; - case "vertical/decreaseValue": - if (action.payload == 1) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1 - 1, - value2: state.value2 - } + tmp = state.timePerDivision; + + tmp[channelIndex].index = state.timePerDivision[channelIndex].index - 1; + tmp[channelIndex].value = DefaultValues.x1ProbeValues[tmp[channelIndex].index]; + return { + ...state, + timePerDivision: tmp } - else if (action.payload == 2) { - return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 - 1 - } - } - else return { - channel: state.channel, - channelColorsList: state.channelColorsList, - value1: state.value1, - value2: state.value2 + case "vertical/decreaseTimePerDivision": + if (state.timePerDivision[state.activeChannel - 1].index >= 12) { + return { ...state } }; + tmp = state.timePerDivision; + + tmp[channelIndex].index = state.timePerDivision[channelIndex].index + 1; + tmp[channelIndex].value = DefaultValues.x1ProbeValues[tmp[channelIndex].index]; + return { + ...state, + timePerDivision: tmp + } default: return state; }