private void DisplayParameter(int id) { grdControl.Children.Clear(); SensorLocator locator = new SensorLocator(); //_sensor.State.Vol = _model.Rows[id].Values[_sensor.Model.Port - 1]; DTCDev.Models.DeviceSender.DISP.DevicePresenter.Sensor nSens = new DTCDev.Models.DeviceSender.DISP.DevicePresenter.Sensor { Model = new DTCDev.Models.DeviceSender.DeviceSensorsModel { id = _sensor.Model.id, IsAnalog = _sensor.Model.IsAnalog, IsInput = _sensor.Model.IsInput, Max = _sensor.Model.Max, Min = _sensor.Model.Min, Name = _sensor.Model.Name, NormalMax = _sensor.Model.NormalMax, NormalMin = _sensor.Model.NormalMin, Port = _sensor.Model.Port, PrType = _sensor.Model.PrType }, State = new DTCDev.Models.DeviceSender.SensorState { id = 0, Vol = _model.Rows[id].Values[_sensor.Model.Port - 1] } }; UserControl control = locator.GetSensor(SensorsTypeEnum.SensorsMode.HIST, nSens); if (control != null) { grdControl.Children.Add(control); } }
public ControllerLineHistoryRow(DTCDev.Models.DeviceSender.DISP.DevicePresenter.Sensor sensor, LinesDataModel model) { InitializeComponent(); _model = model; _sensor = sensor; if (_model != null) { if (_model.Rows.Count() > 0) { DisplayParameter(0); } DisplayGraph(); } }
private void CreateGraph() { if (_currentWidth < 1) { return; } OBDSensorStatData sst = new OBDSensorStatData(); _sensor = sst.GetOBDSensorModel(_obdCode); sst = null; PreCalc(); cnvData.Children.Clear(); cnvData.Width = _currentWidth; double step = _currentWidth / (24 * 60 * 60); int secondsInStep = 86400; double sStep = _currentWidth; while (sStep > 1) { secondsInStep = secondsInStep / 2; sStep = sStep / 2; } int currentSecond = 0; while (currentSecond < 86400) { List <DataModel> temp = _displayParams.Where(p => p.Seconds >= currentSecond && p.Seconds < currentSecond + secondsInStep).ToList(); if (temp.Count() < 1) { AddBorder(step, currentSecond, secondsInStep, 0); } else { int vol = temp.Sum(p => p.Item.Vol) / temp.Count(); AddBorder(step, currentSecond, secondsInStep, vol); } currentSecond += secondsInStep; } }