Skip to content

Commit

Permalink
IISIM 2.2.0: Release, p QoL and Debugging; IIDT 1.0.5 (p2)
Browse files Browse the repository at this point in the history
- Not all changes were staged for last commit
- This is the remainder of the changes meant for last commit!
  • Loading branch information
tanjera committed Jul 15, 2022
1 parent 452cfb9 commit 1ec5cfd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
9 changes: 6 additions & 3 deletions II Library/Classes/Patient.cs
Expand Up @@ -9,6 +9,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -965,9 +966,9 @@ private async Task StartPacemaker ()
await OnPatientEvent (PatientEventTypes.Pacermaker_Spike);

if (Pacemaker_Energy >= Pacemaker_Threshold)
await timerPacemaker_Spike.ResetAuto (40); // Adds an interval between the spike and the QRS complex
await timerPacemaker_Spike.ResetAuto (40); // Adds an interval between the spike and the QRS complex

await StartPacemaker (); // In case pacemaker was paused... updates .Interval
await StartPacemaker (); // In case pacemaker was paused... updates .Interval
}

private async Task OnPacemaker_Spike () {
Expand All @@ -978,7 +979,9 @@ private async Task StartPacemaker ()
Cardiac_Rhythm.AberrantBeat = true;
await OnCardiac_Ventricular_Electric ();
Cardiac_Rhythm.AberrantBeat = false;
await timerCardiac_Baseline.ResetAuto ();

await OnPatientEvent (PatientEventTypes.Cardiac_Baseline); // Triggers drawing isoelectric lines (important for a-fib/flutter)
await timerCardiac_Baseline.ResetAuto (); // Resets heart's intrinsic timer, allows pacemaker overdrive modeling
}
}

Expand Down
13 changes: 12 additions & 1 deletion II Library/Classes/Rhythms.cs
Expand Up @@ -10,6 +10,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;

using II.Waveform;

Expand Down Expand Up @@ -67,7 +68,17 @@ public enum Values {

public bool CanBe_Paced {
get {
return HasPulse_Ventricular;
switch (Value) {
// This is unrealistic, but fits the modeling
case Values.Ventricular_Tachycardia_Monomorphic_Pulsed:
case Values.Ventricular_Tachycardia_Monomorphic_Pulseless:
return true;

case Values.CPR_Artifact:
return false;

default: return HasPulse_Ventricular;
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion II Library/Classes/Timer.cs
Expand Up @@ -2,7 +2,6 @@
using System.Threading.Tasks;

namespace II {

public class Timer {
private int _Interval = 0;
private bool _Locked = false;
Expand Down Expand Up @@ -81,6 +80,11 @@ public async Task Reset (int interval)
public async Task ResetAuto (float interval)
=> await ResetAuto ((int)interval);

public Task Trigger () {
Tick?.Invoke (this, new EventArgs ());
return Task.CompletedTask;
}

public void Process () {
if (!Running)
return;
Expand Down
6 changes: 3 additions & 3 deletions II Library/Classes/Waveform.Draw.cs
Expand Up @@ -16,7 +16,6 @@
using II.Drawing;

namespace II.Waveform {

public static class Draw {
public const int ResolutionTime = 10; // Tracing resolution milliseconds per drawing point
public const int RefreshTime = 17; // Tracing draw refresh time in milliseconds (60 fps = ~17ms)
Expand Down Expand Up @@ -228,11 +227,12 @@ private static void DampenAmplitude_PulsusAlternans (Patient _P, ref double _Amp
if (_P is null || _L is null)
return new ();

int Flutters = (int)System.Math.Ceiling (_P.GetHR_Seconds / 0.16d);
int Flutters = (int)Math.Clamp (System.Math.Ceiling (60 / _P.GetHR_Seconds * 4), 3, 6);
double lengthFlutter = _P.GetHR_Seconds / Flutters;

List<PointD> thisBeat = new ();
for (int i = 1; i < Flutters; i++)
thisBeat = Plotting.Concatenate (thisBeat, ECG_P (_P, _L, 0.16d, .08d, 0d, Plotting.Last (thisBeat)));
thisBeat = Plotting.Concatenate (thisBeat, ECG_P (_P, _L, lengthFlutter, .08d, 0d, Plotting.Last (thisBeat)));
return thisBeat;
}

Expand Down
22 changes: 6 additions & 16 deletions II Simulator/Windows/WindowMain.axaml.cs
Expand Up @@ -179,6 +179,7 @@ private enum ParameterStatuses {
this.FindControl<Label> ("lblParametersReset").Content = Instance.Language.Localize ("BUTTON:ResetParameters");

this.FindControl<CheckBox> ("chkAutoApplyChanges").IsChecked = Instance.Settings.AutoApplyChanges;
this.FindControl<Button> ("btnParametersReset").IsEnabled = !Instance.Settings.AutoApplyChanges;

List<ComboBoxItem> cardiacRhythms = new (),
respiratoryRhythms = new (),
Expand Down Expand Up @@ -300,26 +301,13 @@ private enum ParameterStatuses {
}

private async Task InitPatient () {
if (Instance?.Scenario != null)
if (Instance?.Scenario is not null)
Instance.Patient = Instance.Scenario.Patient;

await InitPatientEvents ();
await InitStep ();
}

private async Task RefreshPatient () {
if (Instance is null)
return;

await UnloadPatientEvents ();

if (Instance?.Patient != null)
await Instance.Patient.Dispose ();
Instance.Patient = new Patient ();

await InitPatient ();
}

private Task InitPatientEvents () {
if (Instance?.Patient is null)
return Task.CompletedTask;
Expand Down Expand Up @@ -1126,8 +1114,9 @@ private void OnStepChangeRequest (object? sender, EventArgs e)
Instance.Language.Localize ("PE:ProgressionSeconds"));
}

private async Task ResetPatientParameters () {
await RefreshPatient ();
private Task ResetPatientParameters () {
ForceUpdateFields (Instance?.Patient);
return Task.CompletedTask;
}

private async Task ApplyPatientParameters () {
Expand Down Expand Up @@ -1344,6 +1333,7 @@ private void OnClosed (object sender, EventArgs e)
return;

Instance.Settings.AutoApplyChanges = this.FindControl<CheckBox> ("chkAutoApplyChanges").IsChecked ?? true;
this.FindControl<Button> ("btnParametersReset").IsEnabled = !Instance.Settings.AutoApplyChanges;
Instance.Settings.Save ();

_ = SetParameterStatus (Instance.Settings.AutoApplyChanges);
Expand Down

0 comments on commit 1ec5cfd

Please sign in to comment.