override internal bool OnStatus(Status stat) { bool no_errors = base.OnStatus(stat); if (stat.HasBeenReset) { Active = false; monitor.Activation(false); // TODO is TimeSpan(0) the best for this notification? Could calculate duration, but how much time between reset (deactivation) and now? ThermalProgress.Raise(this, new ThermalProgressArgs(_lastTemperature, new TimeSpan(0), ThermalState.Aborted)); no_errors = false; } if (no_errors) { bool is_controlling = Controlling(stat); #if DEBUG // Currently, transitioning state is not examined or used in public interface. // examine the controlling and transitioning status for consistency with assumptions behind this code bool is_transitioning = Transitioning(stat); // if (is_controlling && is_transitioning) { logger.Debug("Heater {0} reports 'controlling' and 'transitioning' ({1:X})", Name, (byte)stat); } #endif if (monitor.StatusUpdate(is_controlling)) { ThermalProgress.Raise(this, new ThermalProgressArgs(_lastTemperature, monitor.TimeActive, monitor.State)); } } _last_status = stat; return(no_errors); }
public void Activate(int mode) { logger.Debug("E: {0} Activating: {1}", Name, mode.ToString()); // command uses hardcoded "0" instead of DefaultChannel() -- activation always applies via // channel 0, even if the heater in question is a resistive on channel 1. // (see: ResistiveHeater.ActivationValue()) Issue(iCmd(HActivate, "0", mode.ToString(), (ival) => // iVal is ignored in handler, assumes command successful { NActive = mode; if (monitor.Activation(true)) { ThermalProgress.Raise(this, new ThermalProgressArgs(_lastTemperature, monitor.TimeActive, Controlling(_last_status), Transitioning(_last_status))); } }), true); }
public void Activate(bool active) { logger.Trace("E: {0} Activating: {1}", Name, active); // command uses hardcoded "0" instead of DefaultChannel() -- activation always applies via // channel 0, even if the heater in question is a resistive on channel 1. // (see: ResistiveHeater.ActivationValue()) Issue(iCmd(HActivate, "0", ActivationValue(active), (ival) => // iVal is ignored in handler, assumes command successful { if (Active != active) { Active = active; if (monitor.Activation(active)) { ThermalProgress.Raise(this, new ThermalProgressArgs(_lastTemperature, monitor.TimeActive, monitor.State)); } } })); }