Exemplo n.º 1
0
        private Dictionary <int, MonitorFrequency> findMonitorFrequenceInMinSecByMessageId(ICollection <IoTDevice> iotDevices)
        {
            Dictionary <int, MonitorFrequency> dictionary = new Dictionary <int, MonitorFrequency>();

            foreach (IoTDevice iotDevice in iotDevices)
            {
                foreach (Equipment equipment in iotDevice.Equipment)
                {
                    foreach (EquipmentClassMessageCatalog ecmc in equipment.EquipmentClass.EquipmentClassMessageCatalog)
                    {
                        if (dictionary.ContainsKey(ecmc.MessageCatalogID) == false)
                        {
                            MonitorFrequency mf = new MonitorFrequency();
                            mf.timeInMilliSecond = ecmc.MessageCatalog.MonitorFrequenceInMinSec;
                            mf.lastFeedInTime    = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                            dictionary.Add(ecmc.MessageCatalogID, mf);
                        }
                    }
                }
            }

            showMonitorFrequenceInMinSecByMessageId(dictionary);

            return(dictionary);
        }
Exemplo n.º 2
0
 private void showMonitorFrequenceInMinSecByMessageId(Dictionary <int, MonitorFrequency> d)
 {
     foreach (KeyValuePair <int, MonitorFrequency> item in d)
     {
         MonitorFrequency mf = item.Value;
         _consoleLog.Info("*** MessageCatalogID:{0} MonitorFrequenceInMilliSec: {1} ---", item.Key, mf.timeInMilliSecond);
         _consoleLog.BlobLogInfo("*** MessageCatalogID:{0} MonitorFrequenceInMilliSec: {1} ---", item.Key, mf.timeInMilliSecond);
     }
 }
Exemplo n.º 3
0
        private bool validateFeedInMessageTimeWindows(int messageCatalogId)
        {
            bool ret = false;
            Dictionary <int, MonitorFrequency> d = _epfm.MonitorFrequenceInMinSecByMessageId;

            if (d.ContainsKey(messageCatalogId))
            {
                MonitorFrequency mf             = d[messageCatalogId];
                DateTime         nextFeedInTime = mf.lastFeedInTime.AddMilliseconds(mf.timeInMilliSecond);
                DateTime         now            = DateTime.UtcNow;
                if (now >= nextFeedInTime)
                {
                    /* Feed In*/
                    mf.lastFeedInTime = now;
                    ret = true;
                }
            }

            return(ret);
        }