mirror of
https://github.com/EEVengers/ThunderScope.git
synced 2025-04-08 06:25:30 +00:00
Fill graph with data if C sends small packets
This commit is contained in:
parent
d0fa8d1184
commit
f69668ef4c
Software/waveview/src
components/graph
redux
util
@ -16,7 +16,7 @@ import TestPoints from '../../util/testpoints';
|
||||
class Graph extends React.Component<any, any> {
|
||||
static instanceList: Graph[] = [];
|
||||
timerID: number = 0;
|
||||
generator: TestPoints = new TestPoints(50, 50);
|
||||
generator: TestPoints = new TestPoints(500, 50);
|
||||
|
||||
componentDidMount() {
|
||||
Graph.instanceList.push(this);
|
||||
@ -51,8 +51,8 @@ class Graph extends React.Component<any, any> {
|
||||
</p>
|
||||
</div>
|
||||
<FlexibleXYPlot
|
||||
yDomain={this.generator.y.getDomain()}
|
||||
xDomain={this.generator.x.getDomain()}
|
||||
yDomain={this.props.graph.yDomain}
|
||||
xDomain={this.props.graph.xDomain}
|
||||
margin={{right:0, bottom:0}}
|
||||
>
|
||||
<HorizontalGridLines
|
||||
|
@ -3,9 +3,11 @@ import GraphStatus from "../../configuration/enums/graphStatus";
|
||||
const GraphInitialState = {
|
||||
currentStatus: GraphStatus.On,
|
||||
singleMode: false,
|
||||
xDomain: [0,0],
|
||||
yDomain: [0,0],
|
||||
tickCount: 0
|
||||
xDomain: [0,1000],
|
||||
yDomain: [-128,128],
|
||||
tickCount: 0,
|
||||
voltageDivisions: 10, //TODO: change graph to 8, make this 8
|
||||
timeDivisons: 10
|
||||
};
|
||||
|
||||
export default GraphInitialState;
|
@ -21,6 +21,16 @@ export default function(state = GraphInitialState, action: {type: any, payload:
|
||||
...state,
|
||||
tickCount: state.tickCount + 1
|
||||
}
|
||||
case "graph/xDomain":
|
||||
return {
|
||||
...state,
|
||||
xDomain: action.payload
|
||||
}
|
||||
case "graph/yDomain":
|
||||
return {
|
||||
...state,
|
||||
yDomain: action.payload
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -1,30 +1,16 @@
|
||||
import CMD from '../configuration/enums/cmd';
|
||||
import { PlumberArgs, Plumber, SetMathOp } from './plumber';
|
||||
|
||||
class Range {
|
||||
dataMin: number = 0;
|
||||
dataMax: number = 0;
|
||||
|
||||
constructor(min: number, max: number){
|
||||
this.dataMin = min;
|
||||
this.dataMax = max;
|
||||
}
|
||||
|
||||
getDomain() {
|
||||
return [this.dataMin, this.dataMax];
|
||||
}
|
||||
}
|
||||
import store from '../redux/store';
|
||||
import { LineSeriesPoint } from 'react-vis';
|
||||
|
||||
class TestPoints {
|
||||
x: Range;
|
||||
y: Range;
|
||||
scope_data: any[][] = []; //[ch-1] for channel, [5] for math
|
||||
scope_data: LineSeriesPoint[][] = []; //[ch-1] for channel, [5] for math
|
||||
scope_data_max_idx = 5;
|
||||
|
||||
chCount: number = 4;
|
||||
doMath: Boolean = true;
|
||||
lastX: number = 0;
|
||||
|
||||
rampArgs: PlumberArgs;
|
||||
setChArgs: PlumberArgs;
|
||||
setFileArgs: PlumberArgs;
|
||||
setMathArgs: PlumberArgs;
|
||||
@ -33,33 +19,13 @@ class TestPoints {
|
||||
setMathDone: Boolean = false;
|
||||
|
||||
constructor(xRange: number, yRange: number) {
|
||||
this.x = new Range(0, xRange);
|
||||
this.y = new Range(-yRange, yRange);
|
||||
store.dispatch({type: "graph/xDomain", payload: [0, xRange]});
|
||||
store.dispatch({type: "graph/yDomain", payload: [-yRange, yRange]})
|
||||
|
||||
for(var j = 0; j < this.scope_data_max_idx; j++) {
|
||||
this.scope_data[j] = [];
|
||||
for(var i = 0; i < 1; i++) {
|
||||
this.scope_data[j][i] = {x: i, y: 0};
|
||||
}
|
||||
this.scope_data[j] = [{x: 0, y: 0}];
|
||||
}
|
||||
|
||||
this.rampArgs = {
|
||||
headCheck: () => true,
|
||||
bodyCheck: (a, bytesRead, body) => {
|
||||
var chMax = this.effectiveChCount();
|
||||
var perChannel = Math.floor(body.length/chMax);
|
||||
for(var channel = 0; channel < chMax; channel++) {
|
||||
for(var i = 0; i < perChannel; i++) {
|
||||
this.scope_data[channel][i] = {x: i, y: body[channel*perChannel + i]};
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
cmd: CMD.CMD_GetData1,
|
||||
id: 0x1F2C,
|
||||
writeData: [0, 0]
|
||||
};
|
||||
|
||||
this.setChArgs = {
|
||||
headCheck: () => {
|
||||
this.setChDone = true;
|
||||
@ -102,7 +68,30 @@ class TestPoints {
|
||||
|
||||
update() {
|
||||
if(this.setChDone && this.setFileDone && this.setMathDone) {
|
||||
Plumber.getInstance().cycle(this.rampArgs);
|
||||
let state = store.getState();
|
||||
let xLimit = state.graph.xDomain[1];
|
||||
let args: PlumberArgs = {
|
||||
headCheck: () => true,
|
||||
bodyCheck: (a, bytesRead, body) => {
|
||||
var chMax = this.effectiveChCount();
|
||||
var perChannel = Math.floor(body.length/chMax);
|
||||
let xOffset = (this.lastX < xLimit) ? this.lastX : 0;
|
||||
for(var channel = 0; channel < chMax; channel++) {
|
||||
for(var i = 0; i < perChannel; i++) {
|
||||
let x = xOffset + i;
|
||||
let y = body[channel*perChannel + i];
|
||||
this.scope_data[channel][x] = {x: x, y: y};
|
||||
}
|
||||
}
|
||||
this.lastX = xOffset + perChannel;
|
||||
return true;
|
||||
},
|
||||
cmd: CMD.CMD_GetData1,
|
||||
id: 0,
|
||||
writeData: [0, 0]
|
||||
};
|
||||
|
||||
Plumber.getInstance().cycle(args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +101,6 @@ class TestPoints {
|
||||
|
||||
getData() {
|
||||
var chMax = this.effectiveChCount();
|
||||
console.log(this.scope_data);
|
||||
return this.scope_data.slice(0, chMax);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user