diff --git a/src/store.js b/src/store.js index 20117e6..3f023dc 100644 --- a/src/store.js +++ b/src/store.js @@ -47,8 +47,6 @@ export const LimitCut =(inValue, inLimit)=> export const LimitMap =(inValue, inLimit)=>(inValue-inLimit.Min)/(inLimit.Max-inLimit.Min); - - /** @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"}`)]; @@ -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; - - /** @typedef {{Stim:number, Resp:boolean}} TestFrequencySample */ /** @typedef {{Hz:number, TestL:TestFrequencySample, TestR:TestFrequencySample, UserL?:TestFrequencySample, UserR?:TestFrequencySample}} TestFrequency */ -/** @typedef {{Name:string, Plot:Array}} Test */ +/** @typedef {{Name:string, Plot:Array, Draw?:DrawTest}} Test */ /** @typedef {{Test?:Test, Freq?:TestFrequency, Mark?:TestFrequencySample}} Context */ /** @typedef {{Chan:number, Freq:number, Stim:number, Live:Context, Tests:Array}} State */ /** @type {State} */ @@ -129,44 +125,51 @@ const Update = } }; - -/** @type {(inTest:Test, inChannel:number, inIsUser:boolean)=>Array>} */ +/** @typedef {{X:number, Y:number, Resp:boolean}} DrawPoint */ +/** @typedef {{Points:Array, Paths:Array>}} 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) { - const segments = []; + /** @type {DrawGroup} */ + const output = {Points:[], Paths:[]}; + let plot; - /** @type {Array<{x:number, y:number}>} */ - let segment = []; let valid = false; + /** @type {Array} */ + let segment = []; for(let i=0; i ] } - const pieces = Congtiguous(model, 0, true); - assertEquals(pieces.length, 2); - assertEquals(pieces[0].length, 2); - assertEquals(pieces[1].length, 3); + const {Points, Paths} = Congtiguous(model, 0, true); + assertEquals(Points.length, 6); + assertEquals(Paths.length, 2); + assertEquals(Paths[0].length, 2); + assertEquals(Paths[1].length, 3); }); }); \ No newline at end of file