Example #1
0
        public void NextStep(int optProg = -1)
        {
            StepChangeRequest?.Invoke(this, new EventArgs());

            int pFrom = CurrentIndex;

            if (optProg < 0 || optProg >= Current.Progressions.Count)       // Default Progression
            {
                CurrentIndex = Current.ProgressTo >= 0
                    ? Current.ProgressTo
                    : System.Math.Min(CurrentIndex + 1, Steps.Count - 1);
            }
            else                                                            // Optional Progression
            {
                CurrentIndex = Current.Progressions [optProg].DestinationIndex;
            }

            if (pFrom != CurrentIndex)                                      // If the actual step Index changed
            {
                Current.ProgressFrom = pFrom;
                CopyDeviceStatus(Steps [pFrom].Patient, Current.Patient);
                Steps [pFrom].Patient.Deactivate();                         // Additional unlinking of events and timers!
            }

            // Init step regardless of whether step Index changed; step may have been deactivated by StepChangeRequest()
            SetTimer();
            Current.Patient.Activate();

            // Trigger events for loading current Patient, and trigger propagation to devices
            StepChanged?.Invoke(this, new EventArgs());
            Current.Patient.OnPatientEvent(Patient.PatientEventTypes.Vitals_Change);
        }
Example #2
0
        public void UnsubscribeEvents()
        {
            if (StepChangeRequest != null)
            {
                foreach (Delegate d in StepChangeRequest?.GetInvocationList())
                {
                    StepChangeRequest -= (EventHandler <EventArgs>)d;
                }
            }

            if (StepChanged != null)
            {
                foreach (Delegate d in StepChanged?.GetInvocationList())
                {
                    StepChanged -= (EventHandler <EventArgs>)d;
                }
            }
        }
Example #3
0
        public void SetStep(int incIndex)
        {
            StepChangeRequest?.Invoke(this, new EventArgs());

            int pFrom = CurrentIndex;

            CurrentIndex = II.Math.Clamp(incIndex, 0, Steps.Count - 1);

            if (pFrom != CurrentIndex)                                      // If the actual step Index changed
            {
                CopyDeviceStatus(Steps [pFrom].Patient, Current.Patient);
                Steps [pFrom].Patient.Deactivate();                         // Additional unlinking of events and timers!
            }

            // Init step regardless of whether step Index changed; step may have been deactivated by StepChangeRequest()
            SetTimer();
            Current.Patient.Activate();

            // Trigger events for loading current Patient, and trigger propagation to devices
            StepChanged?.Invoke(this, new EventArgs());
            Current.Patient.OnPatientEvent(Patient.PatientEventTypes.Vitals_Change);
        }