From 222be888c38ad19b0a85ea3a6a9e40643bc3831a Mon Sep 17 00:00:00 2001 From: Jason Bonnell Date: Tue, 2 Feb 2021 18:50:34 -0500 Subject: [PATCH 1/4] initial setup, need to fix reducer to work though --- .../src/components/sidebar/sidebar.tsx | 2 + .../sidebar/widgets/triggerWidget.tsx | 53 +++++++++++++++++++ .../src/css/sidebar/widgets/triggerWidget.css | 17 ++++++ .../redux/reducers/triggerWidgetReducer.tsx | 25 ++++++++- 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx create mode 100644 Software/waveview/src/css/sidebar/widgets/triggerWidget.css 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..bafe6b9 --- /dev/null +++ b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { connect } from 'react-redux'; +import './../../../css/sidebar/widgets/triggerWidget.css'; + +class TriggerWidget extends React.Component { + + // Trigger Channel + increaseChannel = () => { + this.props.dispatch({type: 'trigger/increaseChannel'}); + } + + decreaseChannel = () => { + this.props.dispatch({type: 'trigger/decreaseChannel'}); + } + + render() { + return ( +
+
+ Trigger +
+ +
+ + + +
+ +
+ ) + } +} + +function mapStateToProps(state: { triggerWidget: any; }) { + return { + triggerWidget: state.triggerWidget + }; +} + +export default connect(mapStateToProps)(TriggerWidget); 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..00177f1 --- /dev/null +++ b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css @@ -0,0 +1,17 @@ +.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; +} \ No newline at end of file diff --git a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx index 76f3d6e..ef012fd 100644 --- a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -1,15 +1,36 @@ import TriggerType from '../../configuration/enums/triggerType'; +import DefaultChannelColor from '../../configuration/enums/defaultChannelColor'; const initialState = { triggerChannel: 1, + channelColorsList: [ + DefaultChannelColor.Channel1, + DefaultChannelColor.Channel2, + DefaultChannelColor.Channel3, + DefaultChannelColor.Channel4 + ], triggerType: TriggerType.RisingEdge, triggerLevel: 0 }; export default function(state = initialState, action: {type: any, payload: any}) { switch(action.type) { - case "trigger/test": - return { ...state }; + case "trigger/increaseChannel": + if (state.triggerChannel >= 4) { + return { ...state } + } + return { + ...state, + activeChannel: state.triggerChannel + 1 + }; + case "trigger/decreaseChannel": + if (state.triggerChannel == 1) { + return { ...state } + } + return { + ...state, + activeChannel: state.triggerChannel - 1 + }; default: return state; } -- 2.45.2 From 33c535e36b2bd9d8d061067dbae6c657f631c98e Mon Sep 17 00:00:00 2001 From: Jason Bonnell Date: Tue, 2 Feb 2021 18:51:54 -0500 Subject: [PATCH 2/4] fixed typo --- Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx index ef012fd..0b04881 100644 --- a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -21,7 +21,7 @@ export default function(state = initialState, action: {type: any, payload: any}) } return { ...state, - activeChannel: state.triggerChannel + 1 + triggerChannel: state.triggerChannel + 1 }; case "trigger/decreaseChannel": if (state.triggerChannel == 1) { @@ -29,7 +29,7 @@ export default function(state = initialState, action: {type: any, payload: any}) } return { ...state, - activeChannel: state.triggerChannel - 1 + triggerChannel: state.triggerChannel - 1 }; default: return state; -- 2.45.2 From 2d65121f225d885f6d10e26201751f7e4edfb526 Mon Sep 17 00:00:00 2001 From: Jason Bonnell Date: Tue, 2 Feb 2021 19:00:43 -0500 Subject: [PATCH 3/4] added basic trigger level and type logic --- .../sidebar/widgets/triggerWidget.tsx | 52 +++++++++++++++++++ .../src/css/sidebar/widgets/triggerWidget.css | 10 +++- .../redux/reducers/triggerWidgetReducer.tsx | 21 ++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx index bafe6b9..4cc508d 100644 --- a/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx +++ b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx @@ -13,6 +13,20 @@ class TriggerWidget extends React.Component { this.props.dispatch({type: 'trigger/decreaseChannel'}); } + // Trigger Type + changeTriggerType = () => { + this.props.dispatch({type: 'trigger/changeTriggerType'}); + } + + // Trigger Level + increaseTriggerLevel = () => { + this.props.dispatch({type: 'trigger/increaseTriggerLevel'}); + } + + decreaseTriggerLevel = () => { + this.props.dispatch({type: 'trigger/decreaseTriggerLevel'}); + } + render() { return (
@@ -38,6 +52,44 @@ class TriggerWidget extends React.Component { +
+ +
+ + + +
+ +
+ + + +
) diff --git a/Software/waveview/src/css/sidebar/widgets/triggerWidget.css b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css index 00177f1..c1e2396 100644 --- a/Software/waveview/src/css/sidebar/widgets/triggerWidget.css +++ b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css @@ -14,4 +14,12 @@ .AdjustChannelBlockValue { padding-left: 2vw; padding-right: 2vw; -} \ No newline at end of file +} + +.TriggerWidgetAdjustTriggerType { + margin-top: 1vh; +} + +.TriggerWidgetAdjustTriggerLevel { + margin-top: 1vh; +} diff --git a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx index 0b04881..120d86e 100644 --- a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -31,6 +31,27 @@ export default function(state = initialState, action: {type: any, payload: any}) ...state, triggerChannel: state.triggerChannel - 1 }; + case "trigger/changeTriggerType": + if (state.triggerType == TriggerType.RisingEdge) { + return { + ...state, + triggerType: TriggerType.FallingEdge + } + } + return { + ...state, + triggerType: TriggerType.RisingEdge + } + case "trigger/increaseTriggerLevel": + return { + ...state, + triggerLevel: state.triggerLevel + 1 + }; + case "trigger/decreaseTriggerLevel": + return { + ...state, + triggerLevel: state.triggerLevel - 1 + }; default: return state; } -- 2.45.2 From 4cfe66b6423095f74113192294f095ca5dca71b8 Mon Sep 17 00:00:00 2001 From: Jason Bonnell Date: Sun, 7 Feb 2021 13:25:59 -0500 Subject: [PATCH 4/4] finalized trigger widget work --- .../bottombar/subcomponents/channel.tsx | 2 +- .../subcomponents/timeperdivision.tsx | 2 +- .../bottombar/subcomponents/trigger.tsx | 4 +- .../sidebar/widgets/triggerWidget.tsx | 56 +++++++++++++++++-- .../channel.css | 0 .../timeperdivision.css | 0 .../trigger.css | 0 .../src/css/sidebar/widgets/triggerWidget.css | 44 ++++++++++++++- .../redux/reducers/triggerWidgetReducer.tsx | 47 +++++++++++++--- 9 files changed, 136 insertions(+), 19 deletions(-) rename Software/waveview/src/css/bottombar/{subscomponents => subcomponents}/channel.css (100%) rename Software/waveview/src/css/bottombar/{subscomponents => subcomponents}/timeperdivision.css (100%) rename Software/waveview/src/css/bottombar/{subscomponents => subcomponents}/trigger.css (100%) 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/widgets/triggerWidget.tsx b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx index 4cc508d..9b58790 100644 --- a/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx +++ b/Software/waveview/src/components/sidebar/widgets/triggerWidget.tsx @@ -1,6 +1,7 @@ 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 { @@ -20,11 +21,16 @@ class TriggerWidget extends React.Component { // Trigger Level increaseTriggerLevel = () => { - this.props.dispatch({type: 'trigger/increaseTriggerLevel'}); + this.props.dispatch({type: 'trigger/increaseTriggerLevelValue'}); } decreaseTriggerLevel = () => { - this.props.dispatch({type: 'trigger/decreaseTriggerLevel'}); + this.props.dispatch({type: 'trigger/decreaseTriggerLevelValue'}); + } + + // Trigger Level Unit + changeTriggerLevelUnit = (voltageUnit: VoltageUnit) => { + this.props.dispatch({type: 'trigger/changeTriggerLevelUnit', payload: voltageUnit}) } render() { @@ -63,7 +69,7 @@ class TriggerWidget extends React.Component { className="AdjustChannelBlockValue" style={{color: this.props.triggerWidget.channelColorsList[this.props.triggerWidget.triggerChannel-1]}} > - {this.props.triggerWidget.triggerType.toString()} + {this.props.triggerWidget.triggerType[this.props.triggerWidget.triggerChannel-1].toString()} -
+
+ +
+ + + + +
) 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 index c1e2396..ff22e51 100644 --- a/Software/waveview/src/css/sidebar/widgets/triggerWidget.css +++ b/Software/waveview/src/css/sidebar/widgets/triggerWidget.css @@ -20,6 +20,48 @@ margin-top: 1vh; } -.TriggerWidgetAdjustTriggerLevel { +.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 120d86e..a512aad 100644 --- a/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx +++ b/Software/waveview/src/redux/reducers/triggerWidgetReducer.tsx @@ -1,5 +1,6 @@ import TriggerType from '../../configuration/enums/triggerType'; import DefaultChannelColor from '../../configuration/enums/defaultChannelColor'; +import VoltageUnit from '../../configuration/enums/voltageUnit'; const initialState = { triggerChannel: 1, @@ -9,11 +10,24 @@ const initialState = { DefaultChannelColor.Channel3, DefaultChannelColor.Channel4 ], - triggerType: TriggerType.RisingEdge, - triggerLevel: 0 + 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/increaseChannel": if (state.triggerChannel >= 4) { @@ -32,26 +46,41 @@ export default function(state = initialState, action: {type: any, payload: any}) triggerChannel: state.triggerChannel - 1 }; case "trigger/changeTriggerType": - if (state.triggerType == TriggerType.RisingEdge) { + tmp = state.triggerType; + + if (state.triggerType[channelIndex] == TriggerType.RisingEdge) { + tmp[channelIndex] = TriggerType.FallingEdge; return { ...state, - triggerType: TriggerType.FallingEdge + triggerType: tmp } } + tmp[channelIndex] = TriggerType.RisingEdge; return { ...state, - triggerType: TriggerType.RisingEdge + triggerType: tmp } - case "trigger/increaseTriggerLevel": + case "trigger/increaseTriggerLevelValue": + tmp = state.triggerLevel; + tmp[channelIndex].value = Number((state.triggerLevel[channelIndex].value + 0.1).toFixed(1)); return { ...state, - triggerLevel: state.triggerLevel + 1 + triggerLevel: tmp }; - case "trigger/decreaseTriggerLevel": + case "trigger/decreaseTriggerLevelValue": + tmp = state.triggerLevel; + tmp[channelIndex].value = Number((state.triggerLevel[channelIndex].value - 0.1).toFixed(1)); return { ...state, - triggerLevel: state.triggerLevel - 1 + triggerLevel: tmp }; + case "trigger/changeTriggerLevelUnit": + tmp = state.triggerLevel; + tmp[channelIndex].unit = action.payload; + return { + ...state, + triggerLevel: tmp + } default: return state; } -- 2.45.2