mirror of
https://github.com/EEVengers/ThunderScope.git
synced 2025-04-08 06:25:30 +00:00
Change getMin/getMax to get for all selected channel
This commit is contained in:
parent
e41f5fe865
commit
6ec2593016
Software/waveview
@ -34,8 +34,8 @@ Prepend the name with `CMD_` to find it in the Electron and C++ code.
|
||||
Cmd | DataSize | Name | Description
|
||||
-----|-----------------|---------------|------------------------
|
||||
0x01 | 2 (useless) | GetData1 |
|
||||
0x05 | 2 | GetMin | Data has ch 1,2,3 or 4
|
||||
0x06 | 2 | GetMax | Data has ch 1,2,3 or 4
|
||||
0x05 | 4 | GetMin | Data: `[ch1, ch2, ch3, ch4]`, each 1 or 0
|
||||
0x06 | 4 | GetMax | Data: `[ch1, ch2, ch3, ch4]`, each 1 or 0
|
||||
0x11 | 2 | SetFile | Number mapped to filename by C++
|
||||
0x1F | 2 (useless) | RampDemo |
|
||||
0x21 | 2 (useless) | GetWindowSize |
|
||||
@ -63,8 +63,8 @@ Note that the encoding used by the protocol might not be same as the encoding us
|
||||
Cmd | DataSize | Name | Description
|
||||
-----|-----------------|---------------|------------------------
|
||||
0x01 | ch * windowSize | GetData1 | Data for all ch
|
||||
0x05 | 16 | GetMin | Data has x and y as uint64 and int64
|
||||
0x06 | 16 | GetMax | Data has x and y as uint64 and int64
|
||||
0x05 | 64 | GetMin | Data has `[x1, x2...]` and `[y1, y2..]` as uint64 and int64
|
||||
0x06 | 64 | GetMax | Data has `[x1, x2...]` and `[y1, y2..]` as uint64 and int64
|
||||
0x11 | 0 | SetFile | Set testdata filename
|
||||
0x1F | 4096 | RampDemo | 4 ch, simple waves
|
||||
0x21 | 4 | GetWindowSize | Data has window size as uint32
|
||||
|
@ -107,27 +107,29 @@ void controller::controllerLoop()
|
||||
break;
|
||||
case CMD_GetMin: {
|
||||
INFO << "Packet command: GetMin";
|
||||
const int incomingPacketSize = 2;
|
||||
int ch = 1;
|
||||
if(currentPacket->dataSize != incomingPacketSize) {
|
||||
const int maxCh = 4;
|
||||
const int incomingDataSize = maxCh;
|
||||
//calloc to ensure zero
|
||||
int8_t* outgoingData = (int8_t*) calloc(2*maxCh, sizeof(uint64_t));
|
||||
if(currentPacket->dataSize != incomingDataSize) {
|
||||
ERROR << "Unexpected size for GetMin packet";
|
||||
}
|
||||
else {
|
||||
ch = currentPacket->data[0];
|
||||
uint64_t* outgoingU = (uint64_t*) outgoingData;
|
||||
int64_t* outgoingS = (int64_t*) outgoingData;
|
||||
for(int ch = 0; ch < incomingDataSize; ch++) {
|
||||
if(currentPacket->data[ch]) {
|
||||
int8_t val;
|
||||
uint64_t pos;
|
||||
getMin(ch + 1, &val, &pos);
|
||||
outgoingU[ch] = pos;
|
||||
outgoingS[ch + maxCh] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
int8_t val;
|
||||
uint64_t pos;
|
||||
getMin(ch, &val, &pos);
|
||||
|
||||
const int outgoingPacketSize = 2*sizeof(uint64_t);
|
||||
uint64_t* outgoingU = (uint64_t*) malloc(outgoingPacketSize);
|
||||
int64_t* outgoingS = (int64_t*) outgoingU;
|
||||
outgoingU[0] = pos;
|
||||
outgoingS[1] = val;
|
||||
|
||||
EVPacket* tempPacket = (EVPacket*) malloc(sizeof(EVPacket));
|
||||
tempPacket->data = (int8_t*)outgoingU;
|
||||
tempPacket->dataSize = outgoingPacketSize;
|
||||
tempPacket->data = outgoingData;
|
||||
tempPacket->dataSize = 2*maxCh*sizeof(uint64_t);
|
||||
tempPacket->packetID = 0;
|
||||
tempPacket->command = CMD_GetMin;
|
||||
controllerQueue_tx.push(tempPacket);
|
||||
@ -135,31 +137,31 @@ void controller::controllerLoop()
|
||||
break;
|
||||
case CMD_GetMax: {
|
||||
INFO << "Packet command: GetMax";
|
||||
const int incomingPacketSize = 2;
|
||||
int ch = 1;
|
||||
if(currentPacket->dataSize != incomingPacketSize) {
|
||||
ERROR << "Unexpected size for GetMax packet";
|
||||
const int maxCh = 4;
|
||||
const int incomingDataSize = maxCh;
|
||||
//calloc to ensure zero
|
||||
int8_t* outgoingData = (int8_t*) calloc(2*maxCh, sizeof(uint64_t));
|
||||
if(currentPacket->dataSize != incomingDataSize) {
|
||||
ERROR << "Unexpected size for GetMin packet";
|
||||
}
|
||||
else {
|
||||
ch = currentPacket->data[0];
|
||||
uint64_t* outgoingU = (uint64_t*) outgoingData;
|
||||
int64_t* outgoingS = (int64_t*) outgoingData;
|
||||
for(int ch = 0; ch < incomingDataSize; ch++) {
|
||||
if(currentPacket->data[ch]) {
|
||||
int8_t val;
|
||||
uint64_t pos;
|
||||
getMax(ch + 1, &val, &pos);
|
||||
outgoingU[ch] = pos;
|
||||
outgoingS[ch + maxCh] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
int8_t val;
|
||||
uint64_t pos;
|
||||
getMax(ch, &val, &pos);
|
||||
|
||||
INFO << "val: " << convert_int(val) << ", pos: " << convert_int(pos);
|
||||
|
||||
const int outgoingPacketSize = 2*sizeof(uint64_t);
|
||||
uint64_t* outgoingU = (uint64_t*) malloc(outgoingPacketSize);
|
||||
int64_t* outgoingS = (int64_t*) outgoingU;
|
||||
outgoingU[0] = pos;
|
||||
outgoingS[1] = val;
|
||||
|
||||
EVPacket* tempPacket = (EVPacket*) malloc(sizeof(EVPacket));
|
||||
tempPacket->data = (int8_t*)outgoingU;
|
||||
tempPacket->dataSize = outgoingPacketSize;
|
||||
tempPacket->data = outgoingData;
|
||||
tempPacket->dataSize = 2*maxCh*sizeof(uint64_t);
|
||||
tempPacket->packetID = 0;
|
||||
tempPacket->command = CMD_GetMax;
|
||||
tempPacket->command = CMD_GetMin;
|
||||
controllerQueue_tx.push(tempPacket);
|
||||
}
|
||||
break;
|
||||
|
@ -38,6 +38,12 @@ export enum SetMathOp {
|
||||
SetMath_Minus = 2,
|
||||
}
|
||||
|
||||
export interface MaxMinResult {
|
||||
ch: number,
|
||||
x: number,
|
||||
y: number
|
||||
}
|
||||
|
||||
export interface PlumberArgs {
|
||||
headCheck: (args: PlumberArgs, head: Uint16Array) => boolean;
|
||||
bodyCheck: (args: PlumberArgs, bytesRead: number, body: Int8Array) => boolean;
|
||||
@ -137,9 +143,16 @@ export class Plumber {
|
||||
return [lhsChan, rhsChan, op, 0];
|
||||
}
|
||||
|
||||
public decodeGetMinMax(a: Int8Array) {
|
||||
var a64u = new BigUint64Array(a.buffer);
|
||||
var a64s = new BigInt64Array(a.buffer);
|
||||
return {x: Number(a64u[0]), y: Number(a64s[1])};
|
||||
public decodeGetMinMax(args: PlumberArgs, a: Int8Array) {
|
||||
let maxCh = 4;
|
||||
let a64u = new BigUint64Array(a.buffer);
|
||||
let a64s = new BigInt64Array(a.buffer);
|
||||
var res: MaxMinResult[] = [];
|
||||
for(var i = 0; i < args.writeData.length; i++) {
|
||||
if(args.writeData[i] != 0) {
|
||||
res.push({ch: i + 1, x: Number(a64u[i]), y: Number(a64s[i + maxCh])});
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
@ -56,23 +56,23 @@ class TestConf {
|
||||
this.getMinArgs = {
|
||||
headCheck: () => true,
|
||||
bodyCheck: (args, bytesRead, body) => {
|
||||
console.log(Plumber.getInstance().decodeGetMinMax(body));
|
||||
console.log(Plumber.getInstance().decodeGetMinMax(args, body));
|
||||
return true;
|
||||
},
|
||||
cmd: CMD.CMD_GetMin,
|
||||
id: 0,
|
||||
writeData: [3, 0]
|
||||
writeData: [1, 0, 1, 1]
|
||||
}
|
||||
|
||||
this.getMaxArgs = {
|
||||
headCheck: () => true,
|
||||
bodyCheck: (args, bytesRead, body) => {
|
||||
console.log(Plumber.getInstance().decodeGetMinMax(body));
|
||||
console.log(Plumber.getInstance().decodeGetMinMax(args, body));
|
||||
return true;
|
||||
},
|
||||
cmd: CMD.CMD_GetMax,
|
||||
id: 0,
|
||||
writeData: [3, 0]
|
||||
writeData: [1, 1, 1, 1]
|
||||
}
|
||||
|
||||
}
|
||||
@ -84,7 +84,7 @@ class TestConf {
|
||||
else {
|
||||
Plumber.getInstance().cycle(this.setWinArgs);
|
||||
}*/
|
||||
Plumber.getInstance().cycle(this.getMaxArgs);
|
||||
Plumber.getInstance().cycle(this.getMinArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user