Features/bottombar redux #97
@ -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>
|
||||||
);
|
);
|
||||||
|
@ -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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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
|
return (
|
||||||
voltageValue: number
|
<div className={"Channel" + this.props.channelNumber} style={{color: this.props.verticalWidget.channelColorsList[this.props.channelNumber-1]}}>
|
||||||
voltageUnit: string
|
<label>
|
||||||
measurementType: string
|
CH{this.props.channelNumber}:
|
||||||
channelClass: string
|
{" "}
|
||||||
channelColor: string
|
{this.props.verticalWidget.timePerDivision[this.props.channelNumber-1].value},
|
||||||
};
|
{" "}
|
||||||
|
{this.props.verticalWidget.verticalOffset[this.props.channelNumber-1].value}
|
||||||
function Channel(props: IChannelProps) {
|
{this.props.verticalWidget.verticalOffset[this.props.channelNumber-1].unit},
|
||||||
return (
|
{" "}
|
||||||
<div className={props.channelClass} style={{color:props.channelColor}}>
|
{this.props.verticalWidget.measurementType[this.props.channelNumber-1]}
|
||||||
<label>
|
</label>
|
||||||
CH{props.channelNumber}: {props.voltsPerDiv}V/div, {props.voltageValue}{props.voltageUnit}, {props.measurementType}
|
</div>
|
||||||
</label>
|
)
|
||||||
</div>
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Channel;
|
function mapStateToProps(state: { verticalWidget: any; }) {
|
||||||
|
return {
|
||||||
|
verticalWidget: state.verticalWidget
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(Channel);
|
||||||
|
|
@ -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
|
return(
|
||||||
|
<div className="TimePerDivisionComponent">
|
||||||
|
{this.props.horizontalWidget.horizontalTimeBase.value.toString()}
|
||||||
|
{this.props.horizontalWidget.horizontalTimeBase.unit}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function TimePerDivision(props: ITimePerDivisionProps) {
|
function mapStateToProps(state: { horizontalWidget: any; }) {
|
||||||
return(
|
return {
|
||||||
<div className="TimePerDivisionComponent">
|
horizontalWidget: state.horizontalWidget
|
||||||
{props.timeValue}{props.timeUnit}/div
|
};
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TimePerDivision;
|
export default connect(mapStateToProps)(TimePerDivision);
|
@ -1,15 +1,10 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './../../../css/bottombar/subscomponents/trigger.css';
|
import './../../../css/bottombar/subscomponents/trigger.css';
|
||||||
|
|
||||||
interface ITriggerProps {
|
function Trigger() {
|
||||||
channel: string,
|
|
||||||
mode: string
|
|
||||||
}
|
|
||||||
|
|
||||||
function Trigger(props: ITriggerProps) {
|
|
||||||
return (
|
return (
|
||||||
<div className="TriggerStatus">
|
<div className="TriggerStatus">
|
||||||
Trig:{props.channel}, Mode:{props.mode}
|
Trig:CH1, Mode:RisingEdge
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -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>
|
||||||
|
@ -67,7 +67,7 @@ class VerticalWidget extends React.Component<any, any> {
|
|||||||
className="AdjustValueBlockTimePerDivision"
|
className="AdjustValueBlockTimePerDivision"
|
||||||
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
|
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
|
||||||
>
|
>
|
||||||
{DefaultValues.x1ProbeValues[this.props.verticalWidget.timePerDivisionIndex[this.props.verticalWidget.activeChannel-1]]}
|
{DefaultValues.x1ProbeValues[this.props.verticalWidget.timePerDivision[this.props.verticalWidget.activeChannel-1].index]}
|
||||||
</label>
|
</label>
|
||||||
<button
|
<button
|
||||||
className="PlusButton"
|
className="PlusButton"
|
||||||
@ -86,7 +86,7 @@ class VerticalWidget extends React.Component<any, any> {
|
|||||||
className="AdjustValueBlockVerticalOffset"
|
className="AdjustValueBlockVerticalOffset"
|
||||||
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
|
style={{color: this.props.verticalWidget.channelColorsList[this.props.verticalWidget.activeChannel-1]}}
|
||||||
>
|
>
|
||||||
{this.props.verticalWidget.verticalOffset[this.props.verticalWidget.activeChannel-1].toString()}{"mV"}
|
{this.props.verticalWidget.verticalOffset[this.props.verticalWidget.activeChannel-1].value}{"mV"}
|
||||||
</label>
|
</label>
|
||||||
<button
|
<button
|
||||||
className="PlusButton"
|
className="PlusButton"
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
enum MeasurementType {
|
||||||
|
DC = "DC",
|
||||||
|
AC = "AC"
|
||||||
|
}
|
||||||
|
|
||||||
|
export default MeasurementType;
|
@ -10,16 +10,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;
|
||||||
}
|
}
|
@ -1,44 +1,42 @@
|
|||||||
const initialState = {
|
const initialState = {
|
||||||
value1: 0,
|
horizontalTimeBase: {value: 0, unit: "ns/div"},
|
||||||
value2: 0
|
horizontalOffset: {value: 0, unit: "ms"}
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
return {
|
||||||
return {
|
...state,
|
||||||
value1: state.value1 + 1,
|
horizontalTimeBase: {
|
||||||
value2: state.value2
|
value: state.horizontalTimeBase.value + 1,
|
||||||
|
unit: state.horizontalTimeBase.unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action.payload == 2) {
|
case "horizontal/decreaseTimeBase":
|
||||||
return {
|
return {
|
||||||
value1: state.value1,
|
...state,
|
||||||
value2: state.value2 + 1
|
horizontalTimeBase: {
|
||||||
|
value: state.horizontalTimeBase.value - 1,
|
||||||
|
unit: state.horizontalTimeBase.unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return {
|
case "horizontal/increaseOffset":
|
||||||
value1: state.value1,
|
return {
|
||||||
value2: state.value2
|
...state,
|
||||||
};
|
horizontalOffset: {
|
||||||
case "horizontal/decreaseValue":
|
value: state.horizontalOffset.value + 1,
|
||||||
if (action.payload == 1) {
|
unit: state.horizontalOffset.unit
|
||||||
return {
|
|
||||||
value1: state.value1 - 1,
|
|
||||||
value2: state.value2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action.payload == 2) {
|
case "horizontal/decreaseOffset":
|
||||||
return {
|
return {
|
||||||
value1: state.value1,
|
...state,
|
||||||
value2: state.value2 - 1
|
horizontalOffset: {
|
||||||
|
value: state.horizontalOffset.value - 1,
|
||||||
|
unit: state.horizontalOffset.unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else return {
|
|
||||||
value1: state.value1,
|
|
||||||
value2: state.value2
|
|
||||||
};
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,32 @@
|
|||||||
import DefaultValues from '../../configuration/defaultValues';
|
import DefaultValues from '../../configuration/defaultValues';
|
||||||
|
import MeasurementType from '../../configuration/enums/measurementType';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
activeChannel: 1,
|
activeChannel: 1,
|
||||||
channelColorsList: ["#EBFF00", "#00FF19", "#0075FF", "#FF0000"],
|
channelColorsList: [
|
||||||
timePerDivision: [DefaultValues.x1ProbeValues[6], DefaultValues.x1ProbeValues[6], DefaultValues.x1ProbeValues[6], DefaultValues.x1ProbeValues[6]],
|
"#EBFF00",
|
||||||
timePerDivisionIndex: [6, 6, 6, 6],
|
"#00FF19",
|
||||||
verticalOffset: [0, 0, 0, 0]
|
"#0075FF",
|
||||||
|
"#FF0000"
|
||||||
|
],
|
||||||
|
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: "mV"},
|
||||||
|
{value: 0, unit: "mV"},
|
||||||
|
{value: 0, unit: "mV"},
|
||||||
|
{value: 0, unit: "mV"}
|
||||||
|
],
|
||||||
|
measurementType: [
|
||||||
|
MeasurementType.DC,
|
||||||
|
MeasurementType.DC,
|
||||||
|
MeasurementType.DC,
|
||||||
|
MeasurementType.DC
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function(state = initialState, action: {type: any, payload: any}) {
|
export default function(state = initialState, action: {type: any, payload: any}) {
|
||||||
@ -33,12 +54,12 @@ export default function(state = initialState, action: {type: any, payload: any})
|
|||||||
return { ...state }
|
return { ...state }
|
||||||
// Decrease vertical offset
|
// Decrease vertical offset
|
||||||
case "vertical/increaseTimePerDivision":
|
case "vertical/increaseTimePerDivision":
|
||||||
if (state.timePerDivisionIndex[state.activeChannel - 1] >= 12) {
|
if (state.timePerDivision[state.activeChannel - 1].index >= 12) {
|
||||||
return { ...state }
|
return { ...state }
|
||||||
};
|
};
|
||||||
// Increase time per division
|
// Increase time per division
|
||||||
case "vertical/decreaseTimePerDivision":
|
case "vertical/decreaseTimePerDivision":
|
||||||
if (state.timePerDivisionIndex[state.activeChannel - 1] == 0) {
|
if (state.timePerDivision[state.activeChannel - 1].index == 0) {
|
||||||
return { ...state }
|
return { ...state }
|
||||||
};
|
};
|
||||||
// Decrease time per division
|
// Decrease time per division
|
||||||
|
Loading…
Reference in New Issue
Block a user