public void Update(SensorViewModel viewModel) { Status = viewModel.Status; StringValue = viewModel.StringValue; ShortStringValue = viewModel.ShortStringValue; Description = viewModel.Description; Time = viewModel.Time; TransactionType = viewModel.TransactionType; }
public SensorDataViewModel(string path, SensorViewModel sensor) { var time = (DateTime.UtcNow - sensor.Time); UpdateTime = ListHelper.GetTimeAgo(time); Status = ViewHelper.GetStatusHeaderColorClass(sensor.Status); Id = $"{path.Replace(' ', '-')}_{sensor.Name.Replace(' ', '-')}"; Value = sensor.ShortStringValue; }
public SensorViewModel(SensorViewModel model) { Name = model.Name; SensorType = model.SensorType; Status = model.Status; StringValue = model.StringValue; ShortStringValue = model.ShortStringValue; Description = model.Description; Time = model.Time; TransactionType = model.TransactionType; ValidationError = model.ValidationError; }
public SensorDataViewModel(string path, SensorViewModel sensor) { var time = (DateTime.UtcNow - sensor.Time); UpdateTime = ListHelper.GetTimeAgo(time); Status = ViewHelper.GetStatusHeaderColorClass(sensor.Status); int index = path.IndexOf('_'); var encodedPath = path.Substring(index + 1, path.Length - index - 1); var decodedPath = SensorPathHelper.Decode(encodedPath); Id = "sensor_" + SensorPathHelper.Encode($"{decodedPath}/{sensor.Name}"); Value = sensor.ShortStringValue; ValidationError = sensor.ValidationError; }
public SensorViewModel Clone() { var sensor = new SensorViewModel(); sensor.Name = Name; sensor.SensorType = SensorType; sensor.Status = Status; sensor.StringValue = StringValue; sensor.ShortStringValue = ShortStringValue; sensor.Description = Description; sensor.Time = Time; sensor.TransactionType = TransactionType; sensor.ValidationError = ValidationError; return(sensor); }
public void AddSensor(string path, SensorData sensor) { var nodes = sensor.Path.Split(CommonConstants.SensorPathSeparator); if (nodes.Length == 1) { if (Sensors == null) { Sensors = new ConcurrentDictionary <string, SensorViewModel>(); } if (!Sensors.TryGetValue(nodes[0], out var existingSensor)) { Sensors[nodes[0]] = new SensorViewModel(nodes[0], sensor); } else { existingSensor.Update(sensor); } } else { sensor.Path = sensor.Path.Substring(nodes[0].Length + 1, sensor.Path.Length - nodes[0].Length - 1); if (Nodes == null) { Nodes = new ConcurrentDictionary <string, NodeViewModel>(); } Nodes.TryGetValue(nodes[0], out var existingNode); path += $"{CommonConstants.SensorPathSeparator}{nodes[0]}"; if (existingNode == null) { Nodes[nodes[0]] = new NodeViewModel(nodes[0], path, sensor, this); } else { existingNode.AddSensor(path, sensor); } } }