draw groups started
This commit is contained in:
parent
5138e25d1a
commit
c4c60c0a59
49
src/store.js
49
src/store.js
@ -47,8 +47,6 @@ export const LimitCut =(inValue, inLimit)=>
|
|||||||
export const LimitMap =(inValue, inLimit)=>(inValue-inLimit.Min)/(inLimit.Max-inLimit.Min);
|
export const LimitMap =(inValue, inLimit)=>(inValue-inLimit.Min)/(inLimit.Max-inLimit.Min);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @type {(freq:TestFrequency, chan:number, user:boolean)=>TestFrequencySample|undefined} */
|
/** @type {(freq:TestFrequency, chan:number, user:boolean)=>TestFrequencySample|undefined} */
|
||||||
export const MarkGet =(freq, chan, user)=> freq[/** @type {"UserL"|"UserR"|"TestL"|"TestR"} */ (`${user ? "User" : "Test"}${chan ? "R" : "L"}`)];
|
export const MarkGet =(freq, chan, user)=> freq[/** @type {"UserL"|"UserR"|"TestL"|"TestR"} */ (`${user ? "User" : "Test"}${chan ? "R" : "L"}`)];
|
||||||
|
|
||||||
@ -56,11 +54,9 @@ export const MarkGet =(freq, chan, user)=> freq[/** @type {"UserL"|"UserR"|"Test
|
|||||||
export const MarkSet =(freq, chan, mark)=> freq[ chan ? "UserR" : "UserL" ] = mark;
|
export const MarkSet =(freq, chan, mark)=> freq[ chan ? "UserR" : "UserL" ] = mark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** @typedef {{Stim:number, Resp:boolean}} TestFrequencySample */
|
/** @typedef {{Stim:number, Resp:boolean}} TestFrequencySample */
|
||||||
/** @typedef {{Hz:number, TestL:TestFrequencySample, TestR:TestFrequencySample, UserL?:TestFrequencySample, UserR?:TestFrequencySample}} TestFrequency */
|
/** @typedef {{Hz:number, TestL:TestFrequencySample, TestR:TestFrequencySample, UserL?:TestFrequencySample, UserR?:TestFrequencySample}} TestFrequency */
|
||||||
/** @typedef {{Name:string, Plot:Array<TestFrequency>}} Test */
|
/** @typedef {{Name:string, Plot:Array<TestFrequency>, Draw?:DrawTest}} Test */
|
||||||
/** @typedef {{Test?:Test, Freq?:TestFrequency, Mark?:TestFrequencySample}} Context */
|
/** @typedef {{Test?:Test, Freq?:TestFrequency, Mark?:TestFrequencySample}} Context */
|
||||||
/** @typedef {{Chan:number, Freq:number, Stim:number, Live:Context, Tests:Array<Test>}} State */
|
/** @typedef {{Chan:number, Freq:number, Stim:number, Live:Context, Tests:Array<Test>}} State */
|
||||||
/** @type {State} */
|
/** @type {State} */
|
||||||
@ -129,44 +125,51 @@ const Update =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @typedef {{X:number, Y:number, Resp:boolean}} DrawPoint */
|
||||||
/** @type {(inTest:Test, inChannel:number, inIsUser:boolean)=>Array<Array<{x:number, y:number}>>} */
|
/** @typedef {{Points:Array<DrawPoint>, Paths:Array<Array<DrawPoint>>}} DrawGroup */
|
||||||
|
/** @typedef {{Left:DrawGroup, Right:DrawGroup}} DrawChart */
|
||||||
|
/** @typedef {{User:DrawGroup, Test:DrawGroup}} DrawTest */
|
||||||
|
/** @type {(inTest:Test, inChannel:number, inIsUser:boolean)=>DrawGroup} */
|
||||||
export function Congtiguous(inTest, inChannel, inIsUser)
|
export function Congtiguous(inTest, inChannel, inIsUser)
|
||||||
{
|
{
|
||||||
const segments = [];
|
/** @type {DrawGroup} */
|
||||||
|
const output = {Points:[], Paths:[]};
|
||||||
|
|
||||||
let plot;
|
let plot;
|
||||||
/** @type {Array<{x:number, y:number}>} */
|
|
||||||
let segment = [];
|
|
||||||
let valid = false;
|
let valid = false;
|
||||||
|
/** @type {Array<DrawPoint>} */
|
||||||
|
let segment = [];
|
||||||
for(let i=0; i<inTest.Plot.length; i++)
|
for(let i=0; i<inTest.Plot.length; i++)
|
||||||
{
|
{
|
||||||
plot = inTest.Plot[i];
|
plot = inTest.Plot[i];
|
||||||
const mark = MarkGet(plot, inChannel, inIsUser);
|
const mark = MarkGet(plot, inChannel, inIsUser);
|
||||||
if(mark?.Resp)
|
if(mark)
|
||||||
|
{
|
||||||
|
const lookup = ColumnLookup(plot.Hz);
|
||||||
|
if(lookup)
|
||||||
|
{
|
||||||
|
/** @type {DrawPoint} */
|
||||||
|
const point = { X: lookup[1]*100, Y: LimitMap(mark?.Stim, ToneLimit.Stim)*100, Resp: mark.Resp};
|
||||||
|
output.Points.push(point);
|
||||||
|
|
||||||
|
if(mark.Resp)
|
||||||
{
|
{
|
||||||
if(!valid)
|
if(!valid)
|
||||||
{
|
{
|
||||||
segment = [];
|
segment = [];
|
||||||
segments.push(segment);
|
output.Paths.push(segment);
|
||||||
}
|
}
|
||||||
valid = true;
|
valid = true;
|
||||||
const lookup = ColumnLookup(plot.Hz);
|
segment.push(point);
|
||||||
if(lookup)
|
|
||||||
{
|
|
||||||
segment.push(
|
|
||||||
{
|
|
||||||
x: lookup[1]*100,
|
|
||||||
y: LimitMap(mark.Stim, ToneLimit.Stim)*100
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return segments;
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,10 +129,11 @@ Deno.test("Store", async(t)=>
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const pieces = Congtiguous(model, 0, true);
|
const {Points, Paths} = Congtiguous(model, 0, true);
|
||||||
assertEquals(pieces.length, 2);
|
assertEquals(Points.length, 6);
|
||||||
assertEquals(pieces[0].length, 2);
|
assertEquals(Paths.length, 2);
|
||||||
assertEquals(pieces[1].length, 3);
|
assertEquals(Paths[0].length, 2);
|
||||||
|
assertEquals(Paths[1].length, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user