-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created record timer for each page in seconds, using a slider beside the button to pick time #120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ import { catchError, multicast } from "rxjs/operators"; | |
|
||
import { TextContainer, Card, Stack, RangeSlider, Button, ButtonGroup, Modal } from "@shopify/polaris"; | ||
import { saveAs } from 'file-saver'; | ||
import { take } from "rxjs/operators"; | ||
import { Subject } from "rxjs"; | ||
import { take, takeUntil } from "rxjs/operators"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. takeUntil grabs until a timer is done |
||
import { Subject, timer } from "rxjs"; | ||
|
||
import { channelNames } from "muse-js"; | ||
import { Line } from "react-chartjs-2"; | ||
|
@@ -36,7 +36,8 @@ export function getSettings() { | |
sliceFFTHigh: 30, | ||
duration: 1024, | ||
srate: 256, | ||
name: 'Alpha' | ||
name: 'Alpha', | ||
secondsToSave: 10 | ||
} | ||
}; | ||
|
||
|
@@ -247,10 +248,23 @@ export function renderSliders(setData, setSettings, status, Settings) { | |
) | ||
} | ||
|
||
export function renderRecord(recordPopChange, recordPop, status, Settings, recordTwoPopChange, recordTwoPop) { | ||
export function renderRecord(recordPopChange, recordPop, status, Settings, recordTwoPopChange, recordTwoPop, setSettings) { | ||
|
||
function handleSecondsToSaveRangeSliderChange(value) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for new slider |
||
setSettings(prevState => ({...prevState, secondsToSave: value})); | ||
} | ||
|
||
return( | ||
<Card title={'Record ' + Settings.name +' Data'} sectioned> | ||
<Stack> | ||
<RangeSlider | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new slider |
||
disabled={status === generalTranslations.connect} | ||
min={2} | ||
max={180} | ||
label={'Recording Length: ' + Settings.secondsToSave + ' Seconds'} | ||
value={Settings.secondsToSave} | ||
onChange={handleSecondsToSaveRangeSliderChange} | ||
/> | ||
<ButtonGroup> | ||
<Button | ||
onClick={() => { | ||
|
@@ -318,8 +332,7 @@ export function renderRecord(recordPopChange, recordPop, status, Settings, recor | |
|
||
|
||
function saveToCSV(Settings, condition) { | ||
const numSamplesToSave = 50; | ||
console.log('Saving ' + numSamplesToSave + ' samples...'); | ||
console.log('Saving ' + Settings.secondsToSave + ' seconds...'); | ||
var localObservable$ = null; | ||
const dataToSave = []; | ||
|
||
|
@@ -346,9 +359,13 @@ function saveToCSV(Settings, condition) { | |
); | ||
} | ||
}); | ||
|
||
// setup timer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create timer |
||
const timer$ = timer(Settings.secondsToSave * 1000) | ||
|
||
// put selected observable object into local and start taking samples | ||
localObservable$ = window.multicastAlpha$.pipe( | ||
take(numSamplesToSave) | ||
takeUntil(timer$) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. take until timer is over |
||
); | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ import { catchError, multicast } from "rxjs/operators"; | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and same for the rest of the modules |
||
import { TextContainer, Card, Stack, RangeSlider, Button, ButtonGroup, Modal } from "@shopify/polaris"; | ||
import { saveAs } from 'file-saver'; | ||
import { take } from "rxjs/operators"; | ||
import { Subject } from "rxjs"; | ||
import { takeUntil } from "rxjs/operators"; | ||
import { Subject, timer } from "rxjs"; | ||
|
||
import { channelNames } from "muse-js"; | ||
import { Bar } from "react-chartjs-2"; | ||
|
@@ -32,7 +32,8 @@ export function getSettings () { | |
bins: 256, | ||
duration: 1024, | ||
srate: 256, | ||
name: 'Bands' | ||
name: 'Bands', | ||
secondsToSave: 10 | ||
} | ||
}; | ||
|
||
|
@@ -218,10 +219,23 @@ export function renderSliders(setData, setSettings, status, Settings) { | |
) | ||
} | ||
|
||
export function renderRecord(recordPopChange, recordPop, status, Settings) { | ||
export function renderRecord(recordPopChange, recordPop, status, Settings, setSettings) { | ||
|
||
function handleSecondsToSaveRangeSliderChange(value) { | ||
setSettings(prevState => ({...prevState, secondsToSave: value})); | ||
} | ||
|
||
return ( | ||
<Card title={'Record Data'} sectioned> | ||
<Stack> | ||
<RangeSlider | ||
disabled={status === generalTranslations.connect} | ||
min={2} | ||
max={180} | ||
label={'Recording Length: ' + Settings.secondsToSave + ' Seconds'} | ||
value={Settings.secondsToSave} | ||
onChange={handleSecondsToSaveRangeSliderChange} | ||
/> | ||
<ButtonGroup> | ||
<Button | ||
onClick={() => { | ||
|
@@ -257,8 +271,7 @@ export function renderRecord(recordPopChange, recordPop, status, Settings) { | |
|
||
|
||
function saveToCSV(Settings) { | ||
const numSamplesToSave = 50; | ||
console.log('Saving ' + numSamplesToSave + ' samples...'); | ||
console.log('Saving ' + Settings.secondsToSave + ' seconds...'); | ||
var localObservable$ = null; | ||
const dataToSave = []; | ||
|
||
|
@@ -272,9 +285,13 @@ function saveToCSV(Settings) { | |
"beta0,beta1,beta2,beta3,betaAux,", | ||
"delta0,delta1,delta2,delta3,deltaAux\n" | ||
); | ||
|
||
// Create timer | ||
const timer$ = timer(Settings.secondsToSave * 1000); | ||
|
||
// put selected observable object into local and start taking samples | ||
localObservable$ = window.multicastBands$.pipe( | ||
take(numSamplesToSave) | ||
takeUntil(timer$) | ||
); | ||
|
||
// now with header in place subscribe to each epoch and log it | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the record button can modify settings where this is kept