public AutoFanControlModel(ILifetimeScope scope, IUIDispatcher dispatcher, FanControlOptions options) : base(scope, dispatcher) { Options = RegisterProperty <FanControlOptions>(nameof(Options)).WithDefaultValue(options); Error = RegisterProperty <bool>(nameof(Error)); Reason = RegisterProperty <string>(nameof(Reason)); Power = RegisterProperty <int>(nameof(Power)); State = RegisterProperty <State>(nameof(State)); Pidout = RegisterProperty <double>(nameof(Pidout)); PidSetValue = RegisterProperty <int>(nameof(PidSetValue)); Pt1000 = RegisterProperty <int>(nameof(Pt1000)); FanRunning = RegisterProperty <bool>(nameof(FanRunning)).WithDefaultValue(false); Context.ActorOf("Fan-Control", Core.FanControl.FanControl.New(options)); Receive <TrackingEvent>(obs => obs.SubscribeWithStatus(evt => { Error += evt.Error; Reason += evt.Reason; Power += evt.Power; State += evt.State; Pidout += evt.Pidout; PidSetValue += evt.PidSetValue; Pt1000 += evt.Pt1000; })); Receive <FanStatusChange>(obs => obs.SubscribeWithStatus(evt => FanRunning += evt.Running)); }
public FanControl(FanControlOptions options) { var parent = Context.Parent; var messageBus = new MessageBus(); messageBus.Subscribe(new ClockComponent(options)); messageBus.Subscribe(new DataFetchComponent(options)); messageBus.Subscribe(new TrackingEventDeliveryComponent(e => { parent.Tell(e); return(Task.CompletedTask); })); messageBus.Subscribe(new PowerComponent()); messageBus.Subscribe(new CoolDownComponent()); messageBus.Subscribe(new GoStandByComponent(options)); messageBus.Subscribe(new StartUpCoolingComponent(options)); messageBus.Subscribe(new StandByCoolingComponent(options)); messageBus.Subscribe(new FanControlComponent(options, e => { parent.Tell(new FanStatusChange(e)); return(Task.CompletedTask); })); Receive <ClockEvent>(async msg => await messageBus.Publish(msg)); }
public FanControl(FanControlOptions options) { MessageBus.Subscribe(new ClockComponent(options)); MessageBus.Subscribe(new DataFetchComponent(options)); MessageBus.Subscribe(new TrackingEventDeliveryComponent(e => DataRecieved?.Invoke(e) ?? Task.CompletedTask)); MessageBus.Subscribe(new PowerComponent()); MessageBus.Subscribe(new CoolDownComponent()); MessageBus.Subscribe(new GoStandByComponent(options)); MessageBus.Subscribe(new StartUpCoolingComponent(options)); MessageBus.Subscribe(new StandByCoolingComponent(options)); MessageBus.Subscribe(new FanControlComponent(options, e => FanStatus?.Invoke(e))); }
public ClockComponent(FanControlOptions options) { _options = options; _timer = new Timer(Invoke); }
public FanControlComponent(FanControlOptions options, Func <bool, Task> statusChange) { _timer = new Timer(StopFan); _options = options; _statusChange = statusChange; }
public StandByCoolingComponent(FanControlOptions options) { _options = options; }
public StartUpCoolingComponent(FanControlOptions options) => _options = options;
public DataFetchComponent(FanControlOptions options) => _options = options;
public GoStandByComponent(FanControlOptions options) { _options = options; }
public ClockComponent(FanControlOptions options) { _options = options; ActorApplication.Application.ActorSystem.RegisterOnTermination(() => _timer.Change(-1, -1)); _timer = new Timer(Invoke); }