Example #1
0
 public void TgInput(object sender, SNetTdSignalSecF8EventArg ea)
 {
     if (!this.IsEnalbed)
     {
         return;
     }
     this.OnDataChange(ea);
 }
Example #2
0
        /// <summary>
        /// 單一型, 直接執行
        /// 最後都會執行這段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ea"></param>
        public void TgInput(object sender, SNetTdSignalSecF8EventArg ea)
        {
            if (!this.IsEnalbed)
            {
                return;
            }
            this.Purge();//先Purge, 避免Exception造成沒有Purge

            var tSignalSet = this.TSignalSet;
            var newSignals = ea.TSignal;
            var time       = newSignals.Time.HasValue ? newSignals.Time.Value : DateTime.Now;


            tSignalSet.Add(time, newSignals.Signals);
            var evtea = new SNetTdSignalSecSetF8EventArg()
            {
                Sender        = this,
                Time          = time,
                TSignalSource = tSignalSet,
                PrevTime      = this.PrevTime,
            };

            if (this.IsTriggeredPerSecond)
            {
                if (this.PrevTime.HasValue && this.PrevTime != time)
                {
                    var prevTime = this.PrevTime.HasValue ? this.PrevTime.Value : DateTime.Now;
                    if (this.TSignalSet.ContainKey(prevTime))
                    {
                        var prevSignal = this.TSignalSet.Get(prevTime);
                        evtea.TSignalNew.Add(time, newSignals.Signals);
                        this.OnDataChange(evtea);
                    }
                }
            }
            else
            {
                evtea.TSignalNew.Add(time, newSignals.Signals);
                this.OnDataChange(evtea);
            }


            this.PrevTime = time;
        }