protected override bool StartTest() { bool retValue = true; var conditioningPressure = COND_PRESSURE.Calculate(); try { DeviceManager.Execute(CPARDevice.CreateDelayedRampProgram(0, DELTA_COND_PRESSURE, conditioningPressure, DELTA_PRESSURE, PRESSURE_LIMIT)); DeviceManager.Execute(CPARDevice.CreateConditioningProgram(1, DELTA_COND_PRESSURE, conditioningPressure, DELTA_PRESSURE, PRESSURE_LIMIT)); StartDevice(GetStopCriterion()); result = new ConditionedPainResult() { Name = Name, ID = ID, Index = Index, Conditioned = true, NominalConditioningPressure = conditioningPressure, VAS_PDT = VAS_PDT }; initializing = true; retValue = true; } catch (Exception e) { Log.Debug(e.Message); } return(retValue); }
protected override bool StartTest() { bool retValue = false; try { var program01 = CPARDevice.CreateRampProgram(PrimaryChannel, DELTA_PRESSURE, PRESSURE_LIMIT); var program02 = SECOND_CUFF ? CPARDevice.CreateRampProgram(SecondaryChannel, DELTA_PRESSURE, PRESSURE_LIMIT) : CPARDevice.CreateEmptyProgram(SecondaryChannel); DeviceManager.Execute(program01); DeviceManager.Execute(program02); StartDevice(GetStopCriterion()); result = new StimulusResponseResult() { Name = Name, ID = ID, Index = Index, Conditioned = false, VAS_PDT = VAS_PDT }; initializing = true; retValue = true; } catch (Exception e) { Log.Debug(e.Message); } return(retValue); }
protected override bool StartTest() { bool retValue = false; var stimulatingPressure = Pressure.Calculate(); try { DeviceManager.Execute(CPARDevice.CreateStaticProgram(PrimaryChannel, StimulusDuration, stimulatingPressure)); DeviceManager.Execute(SECOND_CUFF ? CPARDevice.CreateStaticProgram(SecondaryChannel, StimulusDuration, stimulatingPressure) : CPARDevice.CreateEmptyProgram(SecondaryChannel)); StartDevice(StartStimulation.StopCriterion.STOP_CRITERION_ON_BUTTON); Log.Debug("STATIC TS STARTED [Pressure: {0}, Duration: {1}, Both Cuffs: {2}", stimulatingPressure, StimulusDuration, SECOND_CUFF); result = new StaticTemporalSummationResult() { NominalStimulatingPressure = stimulatingPressure }; initializing = true; retValue = true; } catch (Exception e) { Log.Debug(e.Message); } return(retValue); }
protected override bool StartTest() { bool retValue = false; var stimulatingPressure = P_STIMULATE.Calculate(); try { DeviceManager.Execute(CPARDevice.CreatePulseProgram(0, NO_OF_STIMULI, T_ON, T_OFF, stimulatingPressure, P_STATIC)); DeviceManager.Execute(SECOND_CUFF ? CPARDevice.CreatePulseProgram(1, NO_OF_STIMULI, T_ON, T_OFF, stimulatingPressure, P_STATIC) : CPARDevice.CreateEmptyProgram(1)); StartDevice(StartStimulation.StopCriterion.STOP_CRITERION_ON_BUTTON); Log.Debug("TS STARTED [NO: {0}, T_ON: {1}, T_OFF: {2}", NO_OF_STIMULI, T_ON, T_OFF); result = new TemporalSummationResult(NO_OF_STIMULI) { Name = Name, ID = ID, Index = Index, Conditioned = false, T_OFF = T_OFF, T_ON = T_ON, NominalStimulatingPressure = stimulatingPressure }; initializing = true; retValue = true; } catch (Exception e) { Log.Debug(e.Message); } return(retValue); }
public MainWindow() { InitializeComponent(); device = new CPARDevice { Location = Location.Parse("COM18") }; }
private TC(string port) { device = new CPARDevice() { Location = Location.Parse(port) }; device.Open(); watch = new Stopwatch(); }
private void Add(Series series, double[] y) { for (int i = 0; i < y.Length; ++i) { series.Points.Add(new DataPoint() { XValue = CPARDevice.CountToTime(i), YValues = new double[] { y[i] } }); } }
private void Add(Series series, double y) { double time = CPARDevice.CountToTime(series.Points.Count); series.Points.Add(new DataPoint() { XValue = time, YValues = new double[] { y } }); if (time > chartArea.AxisX.Maximum) { chartArea.AxisX.Maximum = time; } }
private void Stimulate() { if (result != null) { if (currentStimulus < result.Responses.Length) { var r = result.Responses[currentStimulus]; DeviceManager.Execute(CPARDevice.CreatePulseProgram(0, 1, r.T_ON, r.T_OFF, r.Pressure, P_STATIC)); DeviceManager.Execute(SECOND_CUFF ? CPARDevice.CreatePulseProgram(1, 1, r.T_ON, r.T_OFF, r.Pressure, P_STATIC) : CPARDevice.CreateEmptyProgram(1)); ForceStartDevice(ForceStartStimulation.StopCriterion.STOP_CRITERION_ON_BUTTON); Log.Debug("TS STARTED [NO: {0}, T_ON: {1}, T_OFF: {2}", currentStimulus, r.T_ON, r.T_OFF); initializing = true; } } }
protected override void Process(StatusMessage msg) { if (msg.Condition == StatusMessage.StopCondition.STOPCOND_NO_CONDITION || initializing) { var force = SECOND_CUFF ? (msg.ActualPressure01 + msg.ActualPressure02) / 2 : PrimaryChannel == 0 ? msg.ActualPressure01 : msg.ActualPressure02; result.Add(force, 0, msg.VasScore); Visualizer.Update(force, 0, msg.VasScore); if (msg.Condition == StatusMessage.StopCondition.STOPCOND_NO_CONDITION) { initializing = false; } } else if ((msg.Condition == StatusMessage.StopCondition.STOPCOND_STIMULATION_COMPLETED || msg.Condition == StatusMessage.StopCondition.STOPCOND_STOP_BUTTON_PRESSED) && !initializing) { var force = SECOND_CUFF ? (msg.ActualPressure01 + msg.ActualPressure02) / 2 : PrimaryChannel == 0 ? msg.ActualPressure01 : msg.ActualPressure02; result.Add(force, 0, msg.VasScore); Visualizer.Update(force, 0, msg.VasScore); if (result.AbortCount > 0) { if (CPARDevice.CountToTime(result.Length - result.AbortCount) >= TailDuration) { Pending(); } } else { result.AbortCount = result.Length; } } else { Abort(); } }
private void Stimulate() { if (state == StartleState.READY) { if (probeNumber < Probes.Length) { var probe = Probes[probeNumber]; try { double Tdelay = probe.T_DELAY; if (result.Probes[probeNumber].IsStartle) { var program01 = CPARDevice.CreateStartleProbe(0, stimulatingPressure, startlePressure, probe.T_ON, probe.T_DELAY, probe.T_STARTLE, probe.T_RESPONSE); var program02 = SECOND_CUFF ? CPARDevice.CreateStartleProbe(1, stimulatingPressure, startlePressure, probe.T_ON, probe.T_DELAY, probe.T_STARTLE, probe.T_RESPONSE) : CPARDevice.CreateEmptyProgram(1); DeviceManager.Execute(program01); DeviceManager.Execute(program02); Log.Status("STARTLE PROBE: Tdelay {0}, Pressure: {1:0.0}kPa/{2:0.0}kPa", Tdelay, stimulatingPressure, startlePressure); } else { var program01 = CPARDevice.CreateNormalProbe(0, stimulatingPressure, probe.T_ON, probe.T_RESPONSE); var program02 = SECOND_CUFF ? CPARDevice.CreateNormalProbe(1, stimulatingPressure, probe.T_ON, probe.T_RESPONSE) : CPARDevice.CreateEmptyProgram(1); DeviceManager.Execute(program01); DeviceManager.Execute(program02); Log.Status("NORMAL PROBE Pressure: {0:0.0}kPa", stimulatingPressure); } StartDevice(Communication.Functions.StartStimulation.StopCriterion.STOP_CRITERION_ON_BUTTON); state = StartleState.STIMULATING; count = 0; } catch (Exception e) { Log.Debug(e.Message); } } else { Log.Debug("Attempted to start a probe that does not exists, ending test"); Pending(); } } else { Log.Debug("StartleTest: Attempted to start a stimulation while not in the READY state [State = {0}]", state.ToString()); } }