protected override void Initialize() { PlotModel = new PlotModel(); PlotModel.Series.Add(new LineSeries()); var plc = plcProvider.GetHardware(); plc.CreateNotification <double>(setting.DoubleSignalName) .ObserveOnDispatcher() .Do(d => { var plotModelSeries = PlotModel.Series[0] as LineSeries; plotModelSeries?.Points.Add(new DataPoint(plotModelSeries.Points.Count, d)); if (plotModelSeries?.Points.Count > 100) { plotModelSeries?.Points.RemoveAt(0); } PlotModel.InvalidatePlot(true); }) .Subscribe() .AddDisposableTo(Disposables) ; Logger?.Debug("Initialized Graph view"); }
private void CreateEventSources(List <ErrorCodeSetting> errorCodeSettings) { foreach (var codeSetting in errorCodeSettings) { var plc = string.IsNullOrEmpty(codeSetting.PlcName) ? plcProvider.GetHardware() : plcProvider.GetHardware(codeSetting.PlcName); plc.CreateNotification(codeSetting.ErrorCodeAddress) .FirstAsync() .Where(value => value != null) .Select(value => CreateEvent(value, codeSetting)) .Do(SetActualEvent) .Subscribe() .AddDisposableTo(disposables) ; plc.CreateNotification(codeSetting.ErrorCodeAddress) .Skip(1) .DistinctUntilChanged() .Where(value => value != null) .Do(value => HandleNewErrorCode(value, codeSetting)) .Subscribe() .AddDisposableTo(disposables) ; } lastEventSubject.AddDisposableTo(disposables); activeEventSubject.AddDisposableTo(disposables); }