Features/bottombar redux #97

Merged
A-Nilfgaardian merged 7 commits from features/bottombar-redux into master 2021-01-20 14:34:28 +00:00
27 changed files with 396 additions and 243 deletions

View File

@ -19,14 +19,6 @@ class App extends React.Component {
color: string, color: string,
className:string className:string
}[]; }[];
triggerInformation: {
channel: string,
mode: string
};
timePerDivisionInformation: {
timeValue: number,
timeUnit: string
}
constructor(props: any) { constructor(props: any) {
super(props); super(props);
@ -41,14 +33,6 @@ class App extends React.Component {
{color: "#0075FF", className: "Channel3"}, {color: "#0075FF", className: "Channel3"},
{color: "#FF0000", className: "Channel4"} {color: "#FF0000", className: "Channel4"}
] ]
this.triggerInformation = {
channel: "CH1",
mode: "RisingEdge"
}
this.timePerDivisionInformation = {
timeValue: 10,
timeUnit: "ns"
}
} }
componentDidMount() { componentDidMount() {
@ -83,11 +67,7 @@ class App extends React.Component {
dataSeries={this.generatorList.map((gen, idx) => gen.getData())} dataSeries={this.generatorList.map((gen, idx) => gen.getData())}
colorSeries={this.channelList.map((c, i) => c.color)} colorSeries={this.channelList.map((c, i) => c.color)}
/> />
<BottomBar <BottomBar />
channelList={this.channelList}
triggerInformation={this.triggerInformation}
timePerDivisionInformation={this.timePerDivisionInformation}
/>
<Sidebar /> <Sidebar />
</div> </div>
); );

View File

@ -4,48 +4,15 @@ import TimePerDivision from './subcomponents/timeperdivision';
import Trigger from './subcomponents/trigger'; import Trigger from './subcomponents/trigger';
import './../../css/bottombar/bottombar.css'; import './../../css/bottombar/bottombar.css';
interface IBottomBarProps { function BottomBar() {
channelList: {
color: string,
className: string
}[]
triggerInformation: {
channel: string,
mode: string
};
timePerDivisionInformation: {
timeValue: number,
timeUnit: string
}
}
function BottomBar(props: IBottomBarProps) {
return ( return (
<div className="BottomBarComponent"> <div className="BottomBarComponent">
{ <Channel channelNumber={1}/>
props.channelList.map((c, i) => { <Channel channelNumber={2}/>
return ( <Channel channelNumber={3}/>
<Channel <Channel channelNumber={4}/>
channelNumber={i+1} <TimePerDivision />
voltsPerDiv={1} <Trigger />
voltageValue={5}
voltageUnit="mV"
measurementType="DC"
channelClass={c.className}
channelColor={c.color}
/>
)
})
}
<TimePerDivision
timeValue={props.timePerDivisionInformation.timeValue}
timeUnit={props.timePerDivisionInformation.timeUnit}
/>
<Trigger
channel={props.triggerInformation.channel}
mode={props.triggerInformation.mode}
/>
</div> </div>
) )
} }

View File

@ -1,25 +1,31 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import './../../../css/bottombar/subscomponents/channel.css'; import './../../../css/bottombar/subscomponents/channel.css';
interface IChannelProps { class Channel extends React.Component<any, any> {
channelNumber: number render() {
voltsPerDiv: number
voltageValue: number
voltageUnit: string
measurementType: string
channelClass: string
channelColor: string
};
function Channel(props: IChannelProps) {
return ( return (
<div className={props.channelClass} style={{color:props.channelColor}}> <div className={"Channel" + this.props.channelNumber} style={{color: this.props.verticalWidget.channelColorsList[this.props.channelNumber-1]}}>
<label> <label>
CH{props.channelNumber}: {props.voltsPerDiv}V/div, {props.voltageValue}{props.voltageUnit}, {props.measurementType} CH{this.props.channelNumber}:
{" "}
{this.props.verticalWidget.timePerDivision[this.props.channelNumber-1].value},
{" "}
{this.props.verticalWidget.verticalOffset[this.props.channelNumber-1].value}
{this.props.verticalWidget.verticalOffset[this.props.channelNumber-1].unit},
{" "}
{this.props.verticalWidget.measurementType[this.props.channelNumber-1]}
</label> </label>
</div> </div>
) )
}
} }
export default Channel; function mapStateToProps(state: { verticalWidget: any; }) {
return {
verticalWidget: state.verticalWidget
};
}
export default connect(mapStateToProps)(Channel);

View File

@ -1,17 +1,22 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import './../../../css/bottombar/subscomponents/timeperdivision.css'; import './../../../css/bottombar/subscomponents/timeperdivision.css';
interface ITimePerDivisionProps { class TimePerDivision extends React.Component<any, any> {
timeValue: number, render() {
timeUnit: string
}
function TimePerDivision(props: ITimePerDivisionProps) {
return( return(
<div className="TimePerDivisionComponent"> <div className="TimePerDivisionComponent">
{props.timeValue}{props.timeUnit}/div {this.props.horizontalWidget.horizontalTimeBase.value.toString()}
{this.props.horizontalWidget.horizontalTimeBase.unit}
</div> </div>
) )
}
} }
export default TimePerDivision; function mapStateToProps(state: { horizontalWidget: any; }) {
return {
horizontalWidget: state.horizontalWidget
};
}
export default connect(mapStateToProps)(TimePerDivision);

View File

@ -1,17 +1,21 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux';
import './../../../css/bottombar/subscomponents/trigger.css'; import './../../../css/bottombar/subscomponents/trigger.css';
interface ITriggerProps { class Trigger extends React.Component<any, any> {
channel: string, render() {
mode: string
}
function Trigger(props: ITriggerProps) {
return ( return (
<div className="TriggerStatus"> <div className="TriggerStatus">
Trig:{props.channel}, Mode:{props.mode} Trig:CH{this.props.triggerWidget.triggerChannel}, Mode:{this.props.triggerWidget.triggerType}
</div> </div>
) )
}
} }
export default Trigger; function mapStateToProps(state: { triggerWidget: any; }) {
return {
triggerWidget: state.triggerWidget
};
}
export default connect(mapStateToProps)(Trigger);

View File

@ -4,12 +4,22 @@ import './../../../css/sidebar/widgets/horizontalWidget.css';
class HorizontalWidget extends React.Component<any, any> { class HorizontalWidget extends React.Component<any, any> {
incrementValue = (value: any) => { // Horizontal Time Base
this.props.dispatch({ type: 'horizontal/increaseValue', payload: value}); incrementTimeBase = () => {
this.props.dispatch({ type: 'horizontal/increaseTimeBase'});
} }
decrementValue = (value: any) => { decrementTimeBase = () => {
this.props.dispatch({ type: 'horizontal/decreaseValue' , payload: value}); this.props.dispatch({ type: 'horizontal/decreaseTimeBase'});
}
// Horizontal Offset
incrementOffset = () => {
this.props.dispatch({ type: 'horizontal/increaseOffset'});
}
decrementOffset = () => {
this.props.dispatch({ type: 'horizontal/decreaseOffset'});
} }
render() { render() {
@ -19,40 +29,40 @@ class HorizontalWidget extends React.Component<any, any> {
Horizontal Horizontal
</div> </div>
<div className="HorizontalWidgetAdjustBlock-Value1"> <div className="HorizontalWidgetAdjustBlock-HorizontalTimeBase">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementValue(1)}> onClick={() => this.decrementTimeBase()}>
- -
</button> </button>
<label <label
className="AdjustValueBlockValue1" className="AdjustValueBlockHorizontalTimeBase"
style={{color: "white"}} style={{color: "white"}}
> >
{this.props.horizontalWidget.value1.toString()}{"ns/div"} {this.props.horizontalWidget.horizontalTimeBase.value.toString()}{this.props.horizontalWidget.horizontalTimeBase.unit}
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementValue(1)}> onClick={() => this.incrementTimeBase()}>
+ +
</button> </button>
</div> </div>
<div className="HorizontalWidgetAdjustBlock-Value2"> <div className="HorizontalWidgetAdjustBlock-HorizontalOffset">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementValue(2)}> onClick={() => this.decrementOffset()}>
- -
</button> </button>
<label <label
className="AdjustValueBlockValue2" className="AdjustValueBlockHorizontalOffset"
style={{color: "white"}} style={{color: "white"}}
> >
{this.props.horizontalWidget.value2.toString()}{"ms"} {this.props.horizontalWidget.horizontalOffset.value.toString()}{this.props.horizontalWidget.horizontalOffset.unit}
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementValue(2)}> onClick={() => this.incrementOffset()}>
+ +
</button> </button>
</div> </div>

View File

@ -1,16 +1,10 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import DefaultValues from '../../../configuration/defaultValues';
import './../../../css/sidebar/widgets/verticalWidget.css'; import './../../../css/sidebar/widgets/verticalWidget.css';
class VerticalWidget extends React.Component<any, any> { class VerticalWidget extends React.Component<any, any> {
incrementValue = (value: any) => { // Active Channel
this.props.dispatch({ type: 'vertical/increaseValue', payload: value});
}
decrementValue = (value: any) => {
this.props.dispatch({ type: 'vertical/decreaseValue' , payload: value});
}
increaseChannel = () => { increaseChannel = () => {
this.props.dispatch({type: 'vertical/increaseChannel'}); this.props.dispatch({type: 'vertical/increaseChannel'});
} }
@ -19,6 +13,24 @@ class VerticalWidget extends React.Component<any, any> {
this.props.dispatch({type: 'vertical/decreaseChannel'}); 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() { render() {
return ( return (
<div className="VerticalWidget"> <div className="VerticalWidget">
@ -29,56 +41,56 @@ class VerticalWidget extends React.Component<any, any> {
<div className="VerticalWidgetAdjustChannelBlock"> <div className="VerticalWidgetAdjustChannelBlock">
<button <button
className="MinusButton" className="MinusButton"
onClick={this.decreaseChannel}> onClick={() => this.decreaseChannel()}>
- -
</button> </button>
<label <label
className="AdjustChannelBlockValue" className="AdjustChannelBlockValue"
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.channel-1]}} style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
> >
CH{this.props.verticalWidget.channel.toString()} CH{this.props.verticalWidget.activeChannel.toString()}
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={this.increaseChannel}> onClick={() => this.increaseChannel()}>
+ +
</button> </button>
</div> </div>
<div className="VerticalWidgetAdjustBlock-Value1"> <div className="VerticalWidgetAdjustBlock-TimePerDivision">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementValue(1)}> onClick={() => this.decrementTimePerDivision()}>
- -
</button> </button>
<label <label
className="AdjustValueBlockValue1" className="AdjustValueBlockTimePerDivision"
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.channel-1]}} style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
> >
{this.props.verticalWidget.value1.toString()}{"V/div"} {DefaultValues.x1ProbeValues[this.props.verticalWidget.timePerDivision[this.props.verticalWidget.activeChannel-1].index]}
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementValue(1)}> onClick={() => this.incrementTimePerDivision()}>
+ +
</button> </button>
</div> </div>
<div className="VerticalWidgetAdjustBlock-Value2"> <div className="VerticalWidgetAdjustBlock-VerticalOffset">
<button <button
className="MinusButton" className="MinusButton"
onClick={() => this.decrementValue(2)}> onClick={() => this.decrementVerticalOffset()}>
- -
</button> </button>
<label <label
className="AdjustValueBlockValue2" className="AdjustValueBlockVerticalOffset"
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.channel-1]}} style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
> >
{this.props.verticalWidget.value2.toString()}{"mV"} {this.props.verticalWidget.verticalOffset[this.props.verticalWidget.activeChannel-1].value}{"mV"}
</label> </label>
<button <button
className="PlusButton" className="PlusButton"
onClick={() => this.incrementValue(2)}> onClick={() => this.incrementVerticalOffset()}>
+ +
</button> </button>
</div> </div>

View File

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

View File

@ -0,0 +1,8 @@
enum DefaultChannelColor {
Channel1 = "#EBFF00",
Channel2 = "#00FF19",
Channel3 = "#0075FF",
Channel4 = "#FF0000"
};
export default DefaultChannelColor;

View File

@ -0,0 +1,6 @@
enum MeasurementType {
DC = "DC",
AC = "AC"
}
export default MeasurementType;

View File

@ -0,0 +1,8 @@
enum TimeUnit {
NanoSecond = "ns",
MicroSecond = "µs",
MilliSecond = "ms",
Second = "s"
}
export default TimeUnit;

View File

@ -0,0 +1,6 @@
enum TriggerType {
RisingEdge = "RisingEdge",
FallingEdge = "FallingEdge"
}
export default TriggerType;

View File

@ -0,0 +1,8 @@
enum VoltageUnit {
NanoVolt = "nV",
MicroVolt = "µV",
MilliVolt = "mV",
Volt = "V"
}
export default VoltageUnit;

View File

@ -11,6 +11,7 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }
.Channel2 { .Channel2 {
@ -21,6 +22,7 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }
.Channel3 { .Channel3 {
@ -31,6 +33,7 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }
.Channel4 { .Channel4 {
@ -41,4 +44,5 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }

View File

@ -12,4 +12,5 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }

View File

@ -12,4 +12,5 @@
height: 2vh; height: 2vh;
background: #4b4b4b; background: #4b4b4b;
z-index: 1000; z-index: 1000;
user-select: none;
} }

View File

@ -20,5 +20,6 @@
color: yellow; color: yellow;
margin-top: 54vh; margin-top: 54vh;
margin-bottom: 0; margin-bottom: 0;
user-select: none;
} }

View File

@ -1,10 +1,12 @@
.Search { .Search {
text-align: center; text-align: center;
display: flex; display: flex;
user-select: none;
} }
.Searchbar { .Searchbar {
position: relative; position: relative;
user-select: none;
top: 10px; top: 10px;
width: 15vw; width: 15vw;
height: 2vh; height: 2vh;

View File

@ -8,6 +8,7 @@
background: #EBFF00; background: #EBFF00;
z-index: 100; z-index: 100;
border: none; border: none;
user-select: none;
} }
.SingleButtonText { .SingleButtonText {
@ -16,4 +17,5 @@
display: flex; display: flex;
position: relative; position: relative;
left: 2vw; left: 2vw;
user-select: none;
} }

View File

@ -8,6 +8,7 @@
background: #FF0000; background: #FF0000;
z-index: 100; z-index: 100;
border: none; border: none;
user-select: none;
} }
.StopButtonText { .StopButtonText {
@ -16,4 +17,5 @@
display: flex; display: flex;
position: relative; position: relative;
left: 2vw; left: 2vw;
user-select: none;
} }

View File

@ -2,6 +2,7 @@
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
user-select: none;
} }
.WidgetTitle { .WidgetTitle {
@ -10,16 +11,16 @@
margin: 10px; margin: 10px;
} }
.AdjustValueBlockValue1 { .AdjustValueBlockHorizontalTimeBase {
padding-left: 2vw; padding-left: 2vw;
padding-right: 2vw; padding-right: 2vw;
} }
.HorizontalWidgetAdjustBlock-Value2 { .HorizontalWidgetAdjustBlock-HorizontalOffset {
margin-top: 1vh; margin-top: 1vh;
} }
.AdjustValueBlockValue2 { .AdjustValueBlockHorizontalOffset {
padding-left: 2vw; padding-left: 2vw;
padding-right: 2vw; padding-right: 2vw;
} }

View File

@ -1,3 +1,7 @@
.MeasurementsWidget {
user-select: none;
}
.MeasurementsWidgetDisplayValueBlock-Value2 { .MeasurementsWidgetDisplayValueBlock-Value2 {
margin-top: 1vh; margin-top: 1vh;
} }

View File

@ -2,6 +2,7 @@
text-align: center; text-align: center;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
user-select: none;
} }
.WidgetTitle { .WidgetTitle {
@ -15,20 +16,20 @@
padding-right: 2vw; padding-right: 2vw;
} }
.VerticalWidgetAdjustBlock-Value1 { .VerticalWidgetAdjustBlock-TimePerDivision {
margin-top: 1vh; margin-top: 1vh;
} }
.AdjustValueBlockValue1 { .AdjustValueBlockTimePerDivision {
padding-left: 2vw; padding-left: 2vw;
padding-right: 2vw; padding-right: 2vw;
} }
.VerticalWidgetAdjustBlock-Value2 { .VerticalWidgetAdjustBlock-VerticalOffset {
margin-top: 1vh; margin-top: 1vh;
} }
.AdjustValueBlockValue2 { .AdjustValueBlockVerticalOffset {
padding-left: 2vw; padding-left: 2vw;
padding-right: 2vw; padding-right: 2vw;
} }

View File

@ -1,44 +1,57 @@
import DefaultValues from '../../configuration/defaultValues';
import TimeUnit from '../../configuration/enums/timeUnit';
const initialState = { const initialState = {
value1: 0, horizontalTimeBase: {
value2: 0 value: DefaultValues.horizontalTimeBases[15],
index: 15
},
horizontalOffset: {
value: 0,
unit: TimeUnit.MilliSecond
}
}; };
export default function(state = initialState, action: {type: any, payload: any}) { export default function(state = initialState, action: {type: any, payload: any}) {
switch(action.type) { switch(action.type) {
case "horizontal/increaseValue": case "horizontal/increaseTimeBase":
if (action.payload == 1) { if (state.horizontalTimeBase.index >= 30) {
return { ...state };
}
return { return {
value1: state.value1 + 1, ...state,
value2: state.value2 horizontalTimeBase: {
value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index + 1],
index: state.horizontalTimeBase.index + 1
} }
} }
else if (action.payload == 2) { case "horizontal/decreaseTimeBase":
if (state.horizontalTimeBase.index === 0) {
return { ...state };
}
return { return {
value1: state.value1, ...state,
value2: state.value2 + 1 horizontalTimeBase: {
value: DefaultValues.horizontalTimeBases[state.horizontalTimeBase.index - 1],
index: state.horizontalTimeBase.index - 1
} }
} }
else return { case "horizontal/increaseOffset":
value1: state.value1,
value2: state.value2
};
case "horizontal/decreaseValue":
if (action.payload == 1) {
return { return {
value1: state.value1 - 1, ...state,
value2: state.value2 horizontalOffset: {
...state.horizontalOffset,
value: state.horizontalOffset.value + 1
} }
} }
else if (action.payload == 2) { case "horizontal/decreaseOffset":
return { return {
value1: state.value1, ...state,
value2: state.value2 - 1 horizontalOffset: {
...state.horizontalOffset,
value: state.horizontalOffset.value - 1
} }
} }
else return {
value1: state.value1,
value2: state.value2
};
default: default:
return state; return state;
} }

View File

@ -2,11 +2,13 @@ import { combineReducers } from 'redux';
import horizontalWidgetReducer from './horizontalWidgetReducer'; import horizontalWidgetReducer from './horizontalWidgetReducer';
import verticalWidgetReducer from './verticalWidgetReducer'; import verticalWidgetReducer from './verticalWidgetReducer';
import measurementsWidgetReducer from './measurementsWidgetReducer'; import measurementsWidgetReducer from './measurementsWidgetReducer';
import triggerWidgetReducer from './triggerWidgetReducer';
export default combineReducers( export default combineReducers(
{ {
horizontalWidget: horizontalWidgetReducer, horizontalWidget: horizontalWidgetReducer,
verticalWidget: verticalWidgetReducer, verticalWidget: verticalWidgetReducer,
measurementsWidget: measurementsWidgetReducer measurementsWidget: measurementsWidgetReducer,
triggerWidget: triggerWidgetReducer
} }
); );

Some files were not shown because too many files have changed in this diff Show More