예제 #1
0
        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;
        }
예제 #2
0
파일: Attribute.cs 프로젝트: suvendu77/IIOT
 private async Task SendAlarm(LimitAlarmDesc limitAlarmDesc, DataQualityTimestamp dtq)
 {
     if (limitAlarmDesc == null)
     {
         return;
     }
     ILimitAlarm alarmProcessor = GetlimitAlarmActorPoxy("AlarmProcessor");
     await alarmProcessor.ProcessEventAsync(this.context, limitAlarmDesc, dtq);
 }
예제 #3
0
파일: Attribute.cs 프로젝트: suvendu77/IIOT
        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);
            }
        }
예제 #4
0
파일: Attribute.cs 프로젝트: suvendu77/IIOT
        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);
        }
예제 #5
0
파일: Attribute.cs 프로젝트: suvendu77/IIOT
 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);
 }
예제 #6
0
 public Task ProcessEventAsync(DataQualityTimestamp payload)
 {
     throw new NotImplementedException();
 }
예제 #7
0
 public async Task StoreData(string key, DataQualityTimestamp value)
 {
     var strValue = JsonConvert.SerializeObject(value);
     await cache.StringSetAsync(key, strValue);
 }
예제 #8
0
 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);
     });
 }