public bool Start() { while (!stop) { var data = new List <SensorData>(); foreach (var tag in tags) { data.Add(new SensorData( tag, DateTime.Now.Ticks, new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds(), "Good")); } var sensorDataEvent = new SensorDataEvent(data); DomainEvents.Raise(sensorDataEvent); Thread.Sleep(1000); } return(true); }
public void Historian_DataChangedEvent(List <CurrentValue> values) { var sensorData = new List <SensorData>(); foreach (CurrentValue cv in values) { double value; if (double.TryParse(cv.Value.ToString(), out value)) { sensorData.Add(new SensorData(cv.Tagname, value, new DateTimeOffset(cv.Time).ToUnixTimeMilliseconds(), cv.Quality.Status.ToString())); } else { Log.Error($"Tag skipped. Can only publish numeric values: {JsonConvert.SerializeObject(cv)}"); } } if (sensorData.Count > 0) { var sensorDataEvent = new SensorDataEvent(sensorData); DomainEvents.Raise(sensorDataEvent); } }