This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // WithRunningSimulation is a helper function that runs the simulation and executes a callback after a given duration | |
| func WithRunningSimulation(sim *step_sim.Simulation, duration time.Duration, f func()) { | |
| go sim.Run() | |
| defer func() { | |
| sim.SendCommand(step_sim.Exit) | |
| }() | |
| // Let the simulation run for a while | |
| time.Sleep(duration) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // PackAutonomicTone builds a signal that represents autonomic tone | |
| func PackAutonomicTone(sym, paraSym, noise, gain, cardiacBias, vascularBias, respiratoryBias, giBias float64) *signal.Signal { | |
| return signal.New(signal.NewGroup().Add( | |
| NewLevel(sym, common.Sympathetic), | |
| NewLevel(paraSym, common.Parasympathetic), | |
| NewLevel(noise, common.Noise), | |
| NewLevel(gain, common.Gain), | |
| NewBias(cardiacBias, common.Cardiac), | |
| NewBias(vascularBias, common.Vascular), | |
| NewBias(respiratoryBias, common.Respiratory), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // What it checks: run simulation for 100ms and check the ECG, we must see a few R-peaks | |
| func Test_Human(t *testing.T) { | |
| tests := []struct { | |
| name string | |
| assertions func(t *testing.T, sim *step_sim.Simulation) | |
| }{ | |
| { | |
| name: "heart is beating", | |
| assertions: func(t *testing.T, sim *step_sim.Simulation) { |
OlderNewer