public ViewModel() { Current = this; PrimarySerial.NewMessageReceived += PrimarySerial_NewMessageReceived; if (IsDebugMode) { DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; dt.Tick += delegate { if (IsRandomizerEnabled) { double val = rnd.NextDouble(); if (Calibrator.ActiveCalibrationSub != null) val = val * 10 + (double)Calibrator.ActiveCalibrationSub.ResponsePoint.OD * 150 + 120; Message msg = new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.Biomass, val, Unit.BiomassConcentration)); PrimarySerial.InterpretMessage(msg.Raw); } }; dt.Start(); } //data collection StartTime = DateTime.Now; DataSource = new EnumerableDataSource(SensorDataSet); DataSource.DataToPoint = new Func<object, Point>(dp => new Point(((dp as DataPoint).Time - StartTime).TotalSeconds, (dp as DataPoint).YValue)); }
public void ActivatePlot(DataLogBase.CalculateRuntimeMethodDelegate calculateRuntimeMethod) { IsPlotActivated = true; try { SensorDataSet.Clear(); } catch { } //create the data source DataSource = new EnumerableDataSource(SensorDataSet); DataSource.DataToPoint = new Func<object, Point>(dp => new Point(calculateRuntimeMethod.Invoke((dp as DataPoint).Time), (dp as DataPoint).YValue)); string[] lines = File.ReadAllLines(_FilePath); for (int i = 1; i < lines.Length; i++) { DataPoint dp = new DataPoint(lines[i]); try { SensorDataSet.Add(dp); } catch { //TODO: this feels dirty } } }
public BiomassSensorInformation() { ResponseCurve = new List<BiomassResponseData>(); ODDataSource = new EnumerableDataSource(ResponseDataSet); ODDataSource.DataToPoint = new Func<object, Point>(rd => new Point((rd as BiomassResponseData).Analog, (rd as BiomassResponseData).OD)); CDWDataSource = new EnumerableDataSource(ResponseDataSet); CDWDataSource.DataToPoint = new Func<object, Point>(rd => new Point((rd as BiomassResponseData).Analog, (rd as BiomassResponseData).CDW)); }
public override PointDataSourceBase TryBuild(object data) { IEnumerable sequence = data as IEnumerable; if (sequence != null) { EnumerableDataSource ds = new EnumerableDataSource(sequence); return ds; } return null; }
private ObservableCollection<DataPoint> _SensorDataSet = new ObservableCollection<DataPoint>(); //contains all datapoints #endregion Fields #region Constructors public ViewModel() { Current = this; PrimarySerial.NewMessageReceived += PrimarySerial_NewMessageReceived; if (IsDebugMode) { DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) }; dt.Tick += delegate { if (IsRandomizerEnabled) { double val = rnd.NextDouble(); if (Calibrator.ActiveCalibrationSub != null) val = val * 10 + (double)Calibrator.ActiveCalibrationSub.ResponsePoint.Percent * 150 + 120; switch (Calibrator.CalibrationTarget) { case MCP.Calibration.CalibrationTarget.Oxygen: PrimarySerial.InterpretMessage(new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.O2_Saturation, val, Unit.Analog)).Raw); break; case MCP.Calibration.CalibrationTarget.Carbon_Dioxide: PrimarySerial.InterpretMessage(new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.CO2_Saturation, val, Unit.Analog)).Raw); break; case MCP.Calibration.CalibrationTarget.CHx: PrimarySerial.InterpretMessage(new Message(ParticipantID.Reactor_1, ParticipantID.MCP, MessageType.Data, string.Format("{0}\t{1}\t{2}", DimensionSymbol.CHx_Saturation, val, Unit.Analog)).Raw); break; default: break; } } }; dt.Start(); } //data collection StartTime = DateTime.Now; DataSource = new EnumerableDataSource(SensorDataSet); DataSource.DataToPoint = new Func<object, Point>(rd => new Point(((rd as DataPoint).Time - StartTime).TotalSeconds, (rd as DataPoint).YValue - SensorDataSet.First().YValue)); }
public Subcalibration(int setpoint, int duration, string symbol, string unit) { this.Setpoint = setpoint; this.Duration = duration; this.Symbol = symbol; this.Unit = unit; DataSource = new EnumerableDataSource(SensorDataSet); DataSource.DataToPoint = new Func<object, Point>(rd => new Point(((rd as DataPoint).Time - SensorDataSet.First().Time).TotalSeconds, (rd as DataPoint).YValue - SensorDataSet.First().YValue)); }
public GasSensorInformation() { ResponseCurve = new List<GasSensorResponseData>(); DataSource = new EnumerableDataSource(ResponseDataSet); DataSource.DataToPoint = new Func<object, System.Windows.Point>(rd => new Point((rd as GasSensorResponseData).Analog, (rd as GasSensorResponseData).Percent)); }
private ObservableCollection<PumpResponseData> _ResponseDataSet = new ObservableCollection<PumpResponseData>(); //contains all datapoints #endregion Fields #region Constructors public PumpInformation() { ResponseCurve = new List<PumpResponseData>(); DataSource = new EnumerableDataSource(ResponseDataSet); DataSource.DataToPoint = new Func<object,System.Windows.Point>(rd => new Point((rd as PumpResponseData).Setpoint, (rd as PumpResponseData).Response)); }
/// <summary> /// 柱状图 /// </summary> /// <param name="gvColumn"></param> /// <param name="ColumnScroll"></param> /// <param name="LineScroll"></param> public void Column() { #region 活动范围 //活动范围 if (RangeList.Count > 0) { List<ClusteredBarData> data = new List<ClusteredBarData>(); Color[] colors = new Color[] { Colors.Red, Colors.Blue, Colors.Yellow }; foreach (var item in RangeList) { ClusteredBarData cbd = new ClusteredBarData(); List<BarData> barDatas = new List<BarData>(); string date = Convert.ToDateTime(item.Key).ToString("yyyy/MM/dd"); cbd.X = dateAxis.ConvertToDouble(Convert.ToDateTime(date)); BarData bd = new BarData { YMin =Convert.ToDouble(item.Value2), YMax =Convert.ToDouble(item.Value) }; bd.BrushColor = colors[0]; barDatas.Add(bd); cbd.BarDatas = barDatas; data.Add(cbd); } EnumerableDataSource<ClusteredBarData> value = new EnumerableDataSource<ClusteredBarData>(data); value.SetXMapping(k => k.X); value.SetYMapping(k => k.BarDatas[0].YMax); DataContext = value; } #endregion }