예제 #1
0
        // Get Recent data
        // Notify the new
        public void RefreshTimeline(string deviceKey, MySqlCommand cmd)
        {
            DBDataCommonListerner listener = this.dataListeners[deviceKey];

            if (listener == null)
            {
                return;
            }

            var result = this.Refresh(deviceKey, true, this.FetchCount, DateTime.MinValue, DateTime.MinValue, cmd);

            if (result == null)
            {
                return;
            }

            result.Sort(DBDataProvider.DateTimeCompare);

            listener.OnDataArrivalBegin(DataArrivalConfig.TimeRecent);
            foreach (var data in result)
            {
                listener.OnDataArrival(DataArrivalConfig.TimeRecent, data);
            }
            listener.OnDataArrivalEnd(DataArrivalConfig.TimeRecent);
        }
예제 #2
0
        /*
         *      public override void Refresh()
         *      {
         *  bool show = false;
         *  foreach (var item in this.deviceKeyList)
         *  {
         *      if (show)
         *      {
         *          continue;
         *      }
         *      show = true;
         *      string deviceKey = item.ToLower();
         *      if (!this.dataListeners.ContainsKey(deviceKey))
         *      {
         *          continue;
         *      }
         *      this.Refresh(deviceKey);
         *  }
         *      }
         */

        // Get DataArrivalConfig.TimeRecent Data.
        public override void RefreshTimeline(string deviceKey)
        {
            DBDataCommonListerner listener = this.dataListeners[deviceKey];

            if (listener != null)
            {
                // int count = MaxCountFetchRecent;
                Config      cfg   = Config.Instance();
                ConfigEntry entry = cfg[deviceKey];

                listener.OnDataArrivalBegin(DataArrivalConfig.TimeRecent);

                string line = lists[this.index];

                if (line.Length > 0)
                {
                    Dictionary <string, object> data = new Dictionary <string, object>(10);
                    data.Clear();
                    ParseLine(line, entry, data);
                    listener.OnDataArrival(DataArrivalConfig.TimeRecent, data);
                    this.index++;
                }
                listener.OnDataArrivalEnd(DataArrivalConfig.TimeRecent);
            }
        }
예제 #3
0
 public DataListener GetDataListener(string deviceKey)
 {
     deviceKey = deviceKey.ToLower();
     this.deviceKeyList.Add(deviceKey);
     if (this.dataListeners.ContainsKey(deviceKey))
     {
         return(this.dataListeners[deviceKey]);
     }
     else
     {
         DBDataCommonListerner listener = new DBDataCommonListerner(deviceKey);
         this.dataListeners.Add(deviceKey, listener);
         return(listener);
     }
 }
예제 #4
0
 public override DataListener GetDataListener(string deviceKey)
 {
     deviceKey = deviceKey.ToLower();
     this.deviceKeyList.Add(deviceKey);
     if (this.dataListeners.ContainsKey(deviceKey))
     {
         return this.dataListeners[deviceKey];
     }
     else
     {
         DBDataCommonListerner listener = new DBDataCommonListerner(deviceKey);
         this.dataListeners.Add(deviceKey, listener);
         return listener;
     }
 }
예제 #5
0
        // For Panels.
        // Get Latest data,
        // No Notify.
        public void RefreshTimeNow(MySqlCommand cmd)
        {
            this.latestData.Clear();
            foreach (var item in this.allDeviceKeys)
            {
                string deviceKey = item.ToLower();
                // Would use listener to notify, panel would get the lastest data.
                var data = this.RefreshTimeNow(deviceKey, cmd);
                if (data != null)
                {
                    this.latestData.Add(deviceKey, data);

                    if (this.dataListeners.ContainsKey(deviceKey))
                    {
                        DBDataCommonListerner listener = this.dataListeners[deviceKey];
                        if (listener != null)
                        {
                            listener.OnDataArrival(DataArrivalConfig.TimeNew, data);
                        }
                    }
                }
            }
        }