Esempio n. 1
0
        public void Run()
        {
            this.thread = new Thread(() =>
            {
                Console.WriteLine($"{DateTime.Now} Data simulator thread started");
                if (!IsConnected)
                {
                    Connect();
                }

                var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 16, null)
                {
                    Name      = "Data Simulator Start Queue",
                    IsSynched = true
                };
                q.Enqueue(new OnQueueOpened(q));
                q.Enqueue(new OnSimulatorStart(DateTime1, DateTime2, 0));
                q.Enqueue(new OnQueueClosed(q));
                this.framework.EventBus.DataPipe.Add(q);

                this.running = true;
                this.exit    = false;
                while (!this.exit)
                {
                    LinkedListNode <DataSeriesObject> lastNode = null;
                    var node = this.emitters.First;
                    while (node != null)
                    {
                        var emitter = node.Data;
                        if (!emitter.Done)
                        {
                            if (emitter.Enqueue())
                            {
                                this.objCount++;
                            }
                            lastNode = node;
                        }
                        else
                        {
                            if (lastNode == null)
                            {
                                this.emitters.First = node.Next;
                            }
                            else
                            {
                                lastNode.Next = node.Next;
                            }
                            this.emitters.Count--;
                            emitter.dataQueue.Enqueue(new OnQueueClosed(emitter.dataQueue));
                        }
                        node = node.Next;
                    }
                }
                this.exit    = false;
                this.running = false;

                Console.WriteLine($"{DateTime.Now} Data simulator thread stopped");
            })
            {
                Name         = "Data Simulator Thread",
                IsBackground = true
            };
            this.thread.Start();
        }
Esempio n. 2
0
 public DataSeriesObject(IDataSeries series, DateTime dateTime1, DateTime dateTime2, EventQueue dataQueue, DataProcessor processor)
 {
     this.queue     = new EventQueue(EventQueueId.All, EventQueueType.Master, EventQueuePriority.Normal, 128, null);
     this.series    = series;
     this.dataQueue = dataQueue;
     this.processor = processor ?? new DataProcessor();
     this.index1    = dateTime1 == DateTime.MinValue || dateTime1 < series.DateTime1 ? 0 : series.GetIndex(dateTime1, SearchOption.Next);
     this.index2    = dateTime2 == DateTime.MaxValue || dateTime2 > series.DateTime2 ? series.Count - 1 : series.GetIndex(dateTime2, SearchOption.Prev);
     this.current   = this.index1;
     this.delta     = (int)Math.Ceiling((this.index2 - this.index1 + 1) / 100.0);
     this.count     = this.delta;
     this.percent   = 0;
 }
Esempio n. 3
0
 public OnQueueClosed(EventQueue queue)
 {
     this.queue = queue;
     DateTime   = DateTime.MinValue;
 }