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
|
|
||||||
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);
|
||||||
|
|
@ -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);
|
@ -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 {
|
||||||
value1: state.value1 + 1,
|
...state,
|
||||||
value2: state.value2
|
horizontalTimeBase: {
|
||||||
|
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,
|
|
||||||
value2: state.value2
|
|
||||||
};
|
|
||||||
case "horizontal/decreaseValue":
|
|
||||||
if (action.payload == 1) {
|
|
||||||
return {
|
return {
|
||||||
value1: state.value1 - 1,
|
...state,
|
||||||
value2: state.value2
|
horizontalOffset: {
|
||||||
|
value: state.horizontalOffset.value + 1,
|
||||||
|
unit: state.horizontalOffset.unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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