public void SimulateData() { Random random = new Random(); temperature = random.Next(0, 90); DataQualityTimestamp dtq = new DataQualityTimestamp() { Value = temperature, Status = "Good", Timestamp = DateTime.UtcNow }; attributeDic["Temperature"].dqt = dtq; humidity = random.Next(0, 100); dtq = new DataQualityTimestamp() { Value = humidity, Status = "Good", Timestamp = DateTime.UtcNow }; attributeDic["Humidity"].dqt = dtq; pressure = random.Next(100, 300); dtq = new DataQualityTimestamp() { Value = pressure, Status = "Good", Timestamp = DateTime.UtcNow }; attributeDic["Pressure"].dqt = dtq; }
private async Task SendAlarm(LimitAlarmDesc limitAlarmDesc, DataQualityTimestamp dtq) { if (limitAlarmDesc == null) { return; } ILimitAlarm alarmProcessor = GetlimitAlarmActorPoxy("AlarmProcessor"); await alarmProcessor.ProcessEventAsync(this.context, limitAlarmDesc, dtq); }
private async Task ProcessLimitAlarms(DataQualityTimestamp dtq) { double value = dtq.Value; bool isAlarm = false; LimitAlarmDesc limitAlarmDesc = null; foreach (var limit in this.limitAlarmData.LimitAlarms) { switch (limit.Key) { case AlarmCategoty.Lo: { if (value <= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.Lolo: { if (value <= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.Hi: { if (value >= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; case AlarmCategoty.HiHi: { if (value >= limit.Value.Value) { limitAlarmDesc = limit.Value; isAlarm = true; } } break; } } if (isAlarm) { await SendAlarm(limitAlarmDesc, dtq); } }
private async Task StoreHotData(DataQualityTimestamp dtq) { string nameSpace = this.metadata.NameSpace; if (string.IsNullOrEmpty(HotDataStorePoxyID)) { HotDataStorePoxyID = HashFunction(nameSpace, numberOfStoreHotDataActor).ToString(); } IStoreHotData dataConnection = GetStroreHotDataActorPoxy(HotDataStorePoxyID); await dataConnection.StoreData(nameSpace, dtq); }
public async Task ProcessEventAsync(DataQualityTimestamp dtq) { ActorEventSource.Current.ActorMessage(this, dtq.Value.ToString()); ////processing alarm if (metadata.IsLimitAlarms) { await ProcessLimitAlarms(dtq); } //// storing last value await StoreHotData(dtq); }
public Task ProcessEventAsync(DataQualityTimestamp payload) { throw new NotImplementedException(); }
public async Task StoreData(string key, DataQualityTimestamp value) { var strValue = JsonConvert.SerializeObject(value); await cache.StringSetAsync(key, strValue); }
public async Task ProcessEventAsync(string context, LimitAlarmDesc limitAlarm, DataQualityTimestamp dtq) { await Task.Run(() => { var alarm = new AlarmMessage(context, limitAlarm, dtq); var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(alarm)); channel.BasicPublish(exchange: "", routingKey: "Alarm", basicProperties: null, body: body); }); }