diff --git a/Software/waveview/src/components/bottombar/subcomponents/channel.tsx b/Software/waveview/src/components/bottombar/subcomponents/channel.tsx index 69fea62..17d093d 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/channel.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/channel.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import './../../../css/bottombar/subscomponents/channel.css'; +import './../../../css/bottombar/subcomponents/channel.css'; class Channel extends React.Component { render() { diff --git a/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx b/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx index 13181e5..8f906e3 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/timeperdivision.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import './../../../css/bottombar/subscomponents/timeperdivision.css'; +import './../../../css/bottombar/subcomponents/timeperdivision.css'; class TimePerDivision extends React.Component { render() { diff --git a/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx b/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx index 4d6786a..576624c 100644 --- a/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx +++ b/Software/waveview/src/components/bottombar/subcomponents/trigger.tsx @@ -1,12 +1,12 @@ import React from 'react'; import { connect } from 'react-redux'; -import './../../../css/bottombar/subscomponents/trigger.css'; +import './../../../css/bottombar/subcomponents/trigger.css'; class Trigger extends React.Component { render() { return (
- Trig:CH{this.props.triggerWidget.triggerChannel}, Mode:{this.props.triggerWidget.triggerType} + Trig:CH{this.props.triggerWidget.triggerChannel}, Mode: {this.props.triggerWidget.triggerType[this.props.triggerWidget.triggerChannel-1]}
) } diff --git a/Software/waveview/src/components/sidebar/sidebar.tsx b/Software/waveview/src/components/sidebar/sidebar.tsx index 3fd9995..ce87634 100644 --- a/Software/waveview/src/components/sidebar/sidebar.tsx +++ b/Software/waveview/src/components/sidebar/sidebar.tsx @@ -6,6 +6,7 @@ import './../../css/sidebar/sidebar.css'; import HorizontalWidget from './widgets/horizontalWidget'; import VerticalWidget from './widgets/verticalWidget'; import MeasurementsWidget from './widgets/measurementsWidget'; +import TriggerWidget from './widgets/triggerWidget'; class SideBar extends React.Component { @@ -18,6 +19,7 @@ class SideBar extends React.Component { + ) } diff --git a/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx new file mode 100644 index 0000000..9b58790 --- /dev/null +++ b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx @@ -0,0 +1,151 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import './../../../css/sidebar/widgets/triggerWidget.css'; +import VoltageUnit from '../../../configuration/enums/voltageUnit'; + +class TriggerWidget extends React.Component { + + // Trigger Channel + increaseChannel = () => { + this.props.dispatch({type: 'trigger/increaseChannel'}); + } + + decreaseChannel = () => { + this.props.dispatch({type: 'trigger/decreaseChannel'}); + } + + // Trigger Type + changeTriggerType = () => { + this.props.dispatch({type: 'trigger/changeTriggerType'}); + } + + // Trigger Level + increaseTriggerLevel = () => { + this.props.dispatch({type: 'trigger/increaseTriggerLevelValue'}); + } + + decreaseTriggerLevel = () => { + this.props.dispatch({type: 'trigger/decreaseTriggerLevelValue'}); + } + + // Trigger Level Unit + changeTriggerLevelUnit = (voltageUnit: VoltageUnit) => { + this.props.dispatch({type: 'trigger/changeTriggerLevelUnit', payload: voltageUnit}) + } + + render() { + return ( +
+
+ Trigger +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + + +
+ +
+ ) + } +} + +function mapStateToProps(state: { triggerWidget: any; }) { + return { + triggerWidget: state.triggerWidget + }; +} + +export default connect(mapStateToProps)(TriggerWidget); diff --git a/Software/waveview/src/css/bottombar/subscomponents/channel.css b/Software/waveview/src/css/bottombar/subcomponents/channel.css similarity index 100% rename from Software/waveview/src/css/bottombar/subscomponents/channel.css rename to Software/waveview/src/css/bottombar/subcomponents/channel.css diff --git a/Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css b/Software/waveview/src/css/bottombar/subcomponents/timeperdivision.css similarity index 100% rename from Software/waveview/src/css/bottombar/subscomponents/timeperdivision.css rename to Software/waveview/src/css/bottombar/subcomponents/timeperdivision.css diff --git a/Software/waveview/src/css/bottombar/subscomponents/trigger.css b/Software/waveview/src/css/bottombar/subcomponents/trigger.css similarity index 100% rename from Software/waveview/src/css/bottombar/subscomponents/trigger.css rename to Software/waveview/src/css/bottombar/subcomponents/trigger.css diff --git a/Software/waveview/src/css/sidebar/widgets/triggerWidget.css b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css new file mode 100644 index 0000000..ff22e51 --- /dev/null +++ b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css @@ -0,0 +1,67 @@ +.TriggerWidget { + text-align: center; + display: flex; + flex-direction: column; + user-select: none; +} + +.WidgetTitle { + background-color: #4B4B4B; + color: black; + margin: 10px; +} + +.AdjustChannelBlockValue { + padding-left: 2vw; + padding-right: 2vw; +} + +.TriggerWidgetAdjustTriggerType { + margin-top: 1vh; +} + +.TriggerWidgetAdjustTriggerLevelValue { + margin-top: 1vh; +} + +.TriggerWidgetAdjustTriggerLevelUnit { + margin-top: 1vh; + position: relative; +} + +.NanoVoltButton { + margin-right: 1vw; +} + +.NanoVoltButtonText { + user-select: none; +} + +.MicroVoltButton { + margin-right: 1vw; + margin-left: 1vw; +} + +.MicroVoltButtonText { + user-select: none; +} + +.MilliVoltButton { + margin-right: 1vw; + margin-left: 1vw; +} + +.MilliVoltButtonText { + user-select: none; +} + +.VoltButton { + margin-right: 1vw; + margin-left: 1vw; +} + +.VoltButtonText { + user-select: none; +} + + diff --git a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx index 76f3d6e..a512aad 100644 --- a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -1,15 +1,86 @@ import TriggerType from '../../configuration/enums/triggerType'; +import DefaultChannelColor from '../../configuration/enums/defaultChannelColor'; +import VoltageUnit from '../../configuration/enums/voltageUnit'; const initialState = { triggerChannel: 1, - triggerType: TriggerType.RisingEdge, - triggerLevel: 0 + channelColorsList: [ + DefaultChannelColor.Channel1, + DefaultChannelColor.Channel2, + DefaultChannelColor.Channel3, + DefaultChannelColor.Channel4 + ], + triggerType: [ + TriggerType.RisingEdge, + TriggerType.RisingEdge, + TriggerType.RisingEdge, + TriggerType.RisingEdge + ], + triggerLevel: [ + {value: 0.0, unit: VoltageUnit.MilliVolt}, + {value: 0.0, unit: VoltageUnit.MilliVolt}, + {value: 0.0, unit: VoltageUnit.MilliVolt}, + {value: 0.0, unit: VoltageUnit.MilliVolt} + ] }; export default function(state = initialState, action: {type: any, payload: any}) { + var channelIndex = state.triggerChannel - 1; + var tmp; + switch(action.type) { - case "trigger/test": - return { ...state }; + case "trigger/increaseChannel": + if (state.triggerChannel >= 4) { + return { ...state } + } + return { + ...state, + triggerChannel: state.triggerChannel + 1 + }; + case "trigger/decreaseChannel": + if (state.triggerChannel == 1) { + return { ...state } + } + return { + ...state, + triggerChannel: state.triggerChannel - 1 + }; + case "trigger/changeTriggerType": + tmp = state.triggerType; + + if (state.triggerType[channelIndex] == TriggerType.RisingEdge) { + tmp[channelIndex] = TriggerType.FallingEdge; + return { + ...state, + triggerType: tmp + } + } + tmp[channelIndex] = TriggerType.RisingEdge; + return { + ...state, + triggerType: tmp + } + case "trigger/increaseTriggerLevelValue": + tmp = state.triggerLevel; + tmp[channelIndex].value = Number((state.triggerLevel[channelIndex].value + 0.1).toFixed(1)); + return { + ...state, + triggerLevel: tmp + }; + case "trigger/decreaseTriggerLevelValue": + tmp = state.triggerLevel; + tmp[channelIndex].value = Number((state.triggerLevel[channelIndex].value - 0.1).toFixed(1)); + return { + ...state, + triggerLevel: tmp + }; + case "trigger/changeTriggerLevelUnit": + tmp = state.triggerLevel; + tmp[channelIndex].unit = action.payload; + return { + ...state, + triggerLevel: tmp + } default: return state; }