Features/trigger widget #101

Merged
A-Nilfgaardian merged 4 commits from features/trigger-widget into master 2021-02-09 23:58:27 +00:00
9 changed files with 136 additions and 19 deletions
Showing only changes of commit 4cfe66b642 - Show all commits

View File

@ -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<any, any> {
render() {

View File

@ -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<any, any> {
render() {

View File

@ -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<any, any> {
render() {
return (
<div className="TriggerStatus">
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]}
</div>
)
}

View File

@ -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<any, any> {
@ -20,11 +21,16 @@ class TriggerWidget extends React.Component<any, any> {
// 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<any, any> {
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()}
</label>
<button
className="PlusButton"
@ -72,7 +78,7 @@ class TriggerWidget extends React.Component<any, any> {
</button>
</div>
<div className="TriggerWidgetAdjustTriggerLevel">
<div className="TriggerWidgetAdjustTriggerLevelValue">
<button
className="MinusButton"
onClick={() => this.decreaseTriggerLevel()}>
@ -82,7 +88,8 @@ class TriggerWidget extends React.Component<any, any> {
className="AdjustChannelBlockValue"
style={{color: this.props.triggerWidget.channelColorsList[this.props.triggerWidget.triggerChannel-1]}}
>
{this.props.triggerWidget.triggerLevel.toString()}
{this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].value.toString()}
{this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].unit}
</label>
<button
className="PlusButton"
@ -90,6 +97,45 @@ class TriggerWidget extends React.Component<any, any> {
+
</button>
</div>
<div className="TriggerWidgetAdjustTriggerLevelUnit">
<button
className="NanoVoltButton"
onClick={() => this.changeTriggerLevelUnit(VoltageUnit.NanoVolt)}>
<label
className={"NanoVoltButtonText"}
style={{fontWeight: this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].unit == VoltageUnit.NanoVolt ? "bold" : "normal"}}>
{VoltageUnit.NanoVolt}
</label>
</button>
<button
className="MicroVoltButton"
onClick={() => this.changeTriggerLevelUnit(VoltageUnit.MicroVolt)}>
<label
className={"MicroVoltButtonText"}
style={{fontWeight: this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].unit == VoltageUnit.MicroVolt ? "bold" : "normal"}}>
{VoltageUnit.MicroVolt}
</label>
</button>
<button
className="MilliVoltButton"
onClick={() => this.changeTriggerLevelUnit(VoltageUnit.MilliVolt)}>
<label
className={"MilliVoltButtonText"}
style={{fontWeight: this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].unit == VoltageUnit.MilliVolt ? "bold" : "normal"}}>
{VoltageUnit.MilliVolt}
</label>
</button>
<button
className="VoltButton"
onClick={() => this.changeTriggerLevelUnit(VoltageUnit.Volt)}>
<label
className={"VoltButtonText"}
style={{fontWeight: this.props.triggerWidget.triggerLevel[this.props.triggerWidget.triggerChannel-1].unit == VoltageUnit.Volt ? "bold" : "normal"}}>
{VoltageUnit.Volt}
</label>
</button>
</div>
</div>
)

View File

@ -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;
}

View File

@ -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;
}