private void Update(ITick tick)
 {
     foreach (var go in _gameObjectFactory.GameObjects.Values)
     {
         go.Update(tick);
     }
 }
Beispiel #2
0
        public override void OnMouseClick(Point point, ThreadScroll scroll)
        {
            EventNode  node  = null;
            EventFrame frame = null;
            int        level = FindNode(point, scroll, out frame, out node);

            if (EventNodeSelected != null)
            {
                ITick tick = scroll.PixelToTime(point.X);
                if (frame == null)
                {
                    frame = FindFrame(tick);
                }
                if (frame != null)
                {
                    EventNodeSelected(this, frame, node);
                }
            }
        }
        public bool CheckIfDetached(ITick tick)
        {
            switch (tick.Priority)
            {
            case TickPriority.High:
            {
                var containsInTickers = _highPriorityTicks.Contains(tick);
                if (!containsInTickers)
                {
                    return(false);
                }

                _highPriorityTicks.Remove(tick);
                break;
            }

            case TickPriority.Normal:
            {
                var containsInTickers = _normalPriorityTicks.Contains(tick);
                if (!containsInTickers)
                {
                    return(false);
                }

                _normalPriorityTicks.Remove(tick);
                break;
            }

            case TickPriority.Low:
            {
                var containsInTickers = _lowPriorityTicks.Contains(tick);
                if (!containsInTickers)
                {
                    return(false);
                }

                _lowPriorityTicks.Remove(tick);
                break;
            }
            }

            return(true);
        }
Beispiel #4
0
        public int FindNode(Point point, ThreadScroll scroll, out EventFrame eventFrame, out EventNode eventNode)
        {
            ITick tick = scroll.PixelToTime(point.X);

            int index = Data.Utils.BinarySearchExactIndex(EventData.Events, tick.Start);

            EventFrame resultFrame = null;
            EventNode  resultNode  = null;
            int        resultLevel = -1;

            if (index >= 0)
            {
                EventFrame frame = EventData.Events[index];

                int desiredLevel = (int)(point.Y / RenderParams.BaseHeight);

                frame.CategoriesTree.ForEachChild((node, level) =>
                {
                    if (level > desiredLevel || resultFrame != null)
                    {
                        return(false);
                    }

                    if (level == desiredLevel)
                    {
                        EventNode evNode = (node as EventNode);
                        if (evNode.Entry.Intersect(tick.Start))
                        {
                            resultFrame = frame;
                            resultNode  = evNode;
                            resultLevel = level;
                            return(false);
                        }
                    }

                    return(true);
                });
            }

            eventFrame = resultFrame;
            eventNode  = resultNode;
            return(resultLevel);
        }
Beispiel #5
0
    public void OnUpdate(float dt)
    {
        while (_needDeleteTicks.Count > 0)
        {
            tickItem = _needDeleteTicks[0];
            _needDeleteTicks.RemoveAt(0);
            _activeTicks.Remove(tickItem);
        }
        while (_needActiveTicks.Count > 0)
        {
            tickItem = _needActiveTicks[0];
            _needActiveTicks.RemoveAt(0);
            _activeTicks.Add(tickItem);
        }
        int count = _activeTicks.Count;

        for (int i = 0; i < count; i++)
        {
            _activeTicks[i].OnTick(dt);
        }
    }
Beispiel #6
0
        static void cService_onComplementCompleted(object sender, Events.QuoteComplementCompletedEvent e)
        {
            //cService.onComplementCompleted -= cService_onComplementCompleted;
            System.Console.WriteLine("c " + e.SymbolId);
            IQuote cQuote = cService.Storage.GetQuote(e.SymbolId);

            System.Console.WriteLine(cQuote);
            System.Console.WriteLine("symbol:{0} name:{1}", cQuote.SymbolId, cQuote.SymbolName);

            double dVolume = 0;
            int    iCount  = cQuote.TickCount;

            for (int i = iCount - 1; i >= 0; i--)
            {
                ITick cTick = cQuote.GetTick(i);
                System.Console.WriteLine("{0} {1,8:0.00} {2,8:0.00} {3,8:0.00} {4,10} {5, 10} {6, 10}", cTick.Time.ToString("HHmmss"), cTick.Bid.Price, cTick.Ask.Price, cTick.Price, cTick.Single, cTick.Volume, cTick.Volume - dVolume);
                if (cTick.Volume > dVolume)
                {
                    dVolume = cTick.Volume;
                }
            }
        }
Beispiel #7
0
        public override void OnMouseMove(Point point, ThreadScroll scroll)
        {
            ITick tick = scroll.PixelToTime(point.X);

            int index = Data.Utils.BinarySearchClosestIndex(Timestamps, tick.Start);

            if (0 <= index && index + 1 < Timestamps.Count)
            {
                double leftPx  = scroll.TimeToPixel(Timestamps[index]);
                double rightPx = scroll.TimeToPixel(Timestamps[index + 1]);

                Rect rect = new Rect(leftPx, Offset + RenderParams.BaseMargin, rightPx - leftPx, Height - RenderParams.BaseMargin);

                List <double> values = new List <double>();
                for (int entryIndex = 0; entryIndex < Entries.Count; ++entryIndex)
                {
                    values.Add(Entries[entryIndex].Values[index]);
                }

                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("NumCores [{0}]: ", values.Sum());
                for (int i = 0; i < values.Count; ++i)
                {
                    if (i != 0)
                    {
                        builder.Append("+");
                    }
                    builder.Append(values[i]);
                    //builder.AppendFormat("{0}({1})", values[i], entries[i].Name);
                }

                ChartHover?.Invoke(point, rect, builder.ToString());
            }
            else
            {
                ChartHover?.Invoke(point, new Rect(), null);
            }
        }
 public void UnRegistTick(ITick iTick)
 {
     _iTicks.Remove(iTick);
 }
 public void RegistTick(ITick iTick)
 {
     _iTicks.Add(iTick);
 }
Beispiel #10
0
 private IEnumerator RemoveTickableBlockRoutine(ITick tickable)
 {
     yield return new WaitForEndOfFrame();
     _tickableBlock.Remove(tickable);
 }
Beispiel #11
0
        public override void OnMouseHover(Point point, ThreadScroll scroll, List <object> dataContext)
        {
            EventNode  node  = null;
            EventFrame frame = null;

            ITick tick = scroll.PixelToTime(point.X);

            if (FindNode(point, scroll, out frame, out node) != -1)
            {
                dataContext.Add(node);
            }

            // show current sync info
            if (EventData.Sync != null && EventData.Sync != null)
            {
                int index = Data.Utils.BinarySearchClosestIndex(EventData.Sync, tick.Start);
                if (index != -1)
                {
                    bool         insideWaitInterval = false;
                    WaitInterval interval           = new WaitInterval()
                    {
                        Start = EventData.Sync[index].Finish, Reason = EventData.Sync[index].Reason
                    };
                    if (index + 1 < EventData.Sync.Count)
                    {
                        if (EventData.Sync[index].Finish < tick.Start && tick.Start < EventData.Sync[index + 1].Start)
                        {
                            UInt64 threadId = EventData.Sync[index].NewThreadId;

                            ThreadDescription threadDesc = null;
                            Group.Board.ThreadDescriptions.TryGetValue(threadId, out threadDesc);

                            interval.newThreadDesc = threadDesc;
                            interval.newThreadId   = threadId;

                            interval.Finish = EventData.Sync[index + 1].Start;
                            dataContext.Add(interval);
                            insideWaitInterval = true;
                        }
                    }

                    if (!insideWaitInterval)
                    {
                        interval.Reason = SyncReason.SyncReasonActive;
                        interval.Start  = EventData.Sync[index].Start;
                        interval.Finish = EventData.Sync[index].Finish;
                        interval.core   = (byte)EventData.Sync[index].Core;
                        dataContext.Add(interval);
                    }
                }
            }

            if (node != null)
            {
                // build all intervals inside selected node
                int from = Data.Utils.BinarySearchClosestIndex(frame.Synchronization, node.Entry.Start);
                int to   = Data.Utils.BinarySearchClosestIndex(frame.Synchronization, node.Entry.Finish);

                if (from >= 0 && to >= from)
                {
                    IntPair[] waitInfo = new IntPair[(int)SyncReason.SyncReasonCount];

                    for (int index = from; index <= to; ++index)
                    {
                        SyncReason reason      = frame.Synchronization[index].Reason;
                        int        reasonIndex = (int)reason;

                        long idleStart  = frame.Synchronization[index].Finish;
                        long idleFinish = (index + 1 < frame.Synchronization.Count) ? frame.Synchronization[index + 1].Start : frame.Finish;

                        if (idleStart > node.Entry.Finish)
                        {
                            continue;
                        }

                        long idleStartClamped  = Math.Max(idleStart, node.Entry.Start);
                        long idleFinishClamped = Math.Min(idleFinish, node.Entry.Finish);
                        long durationInTicks   = idleFinishClamped - idleStartClamped;
                        waitInfo[reasonIndex].duration += durationInTicks;
                        waitInfo[reasonIndex].count++;
                    }

                    NodeWaitIntervalList intervals = new NodeWaitIntervalList();

                    for (int i = 0; i < waitInfo.Length; i++)
                    {
                        if (waitInfo[i].count > 0)
                        {
                            NodeWaitInterval interval = new NodeWaitInterval()
                            {
                                Start = 0, Finish = waitInfo[i].duration, Reason = (SyncReason)i, NodeInterval = node.Entry, Count = waitInfo[i].count
                            };
                            intervals.Add(interval);
                        }
                    }

                    intervals.Sort((a, b) =>
                    {
                        return(Comparer <long> .Default.Compare(b.Finish, a.Finish));
                    });

                    if (intervals.Count > 0)
                    {
                        dataContext.Add(intervals);
                    }
                }
            }             // FindNode

            if (EventData.Callstacks != null && scroll.DrawCallstacks != 0)
            {
                int startIndex = Data.Utils.BinarySearchClosestIndex(EventData.Callstacks, tick.Start);

                for (int i = startIndex; (i <= startIndex + 1) && (i < EventData.Callstacks.Count) && (i != -1); ++i)
                {
                    double pixelPos = scroll.TimeToPixel(EventData.Callstacks[i]);
                    if (Math.Abs(pixelPos - point.X) < CallstackMarkerRadius * 1.2 && (EventData.Callstacks[i].Reason & scroll.DrawCallstacks) != 0)
                    {
                        dataContext.Add(EventData.Callstacks[i]);
                        break;
                    }
                }
            }
        }
Beispiel #12
0
 public void AddTick(ITick tick)
 {
     _ticks += tick.Update;
 }
Beispiel #13
0
        public double TimeToUnit(ITick tick)
        {
            double durationTicks = TimeSlice.Finish - TimeSlice.Start;

            return((tick.Start - TimeSlice.Start) / durationTicks);
        }
Beispiel #14
0
		internal void Merge(ITick tick) {
			double dVolume = tick.Volume;
			if (dVolume > __dOVolume) {
				double dPrice = tick.Price;
				DateTime cBaseTime = tick.Time;
				double dSingle = dVolume - __dOVolume;  //重新計算準確的單量(即時系統送來的單量並不準確, 所以以總量為標準依據)
				if (__cTimeQueue != null) {
					bool bNewBars = Resolution.GetNearestPeriod(__cTimeQueue, ref cBaseTime);
					MergeSeries(this, cBaseTime, dPrice, dPrice, dPrice, dPrice, dSingle, bNewBars, true);
				} else {
					MergeSeries(this, cBaseTime, dPrice, dPrice, dPrice, dPrice, dSingle, false, true);
				}
				
				__dOVolume = dVolume;
				__cUpdateTime = tick.Time;
			}
		}
Beispiel #15
0
		internal void MergeTick(ITick tick) {
			lock (__cIndexs) {
				int iCount = __cSeries.Count;
				Parallel.For(0, iCount, (i) => {
					SeriesSymbolData cSeries = __cSeries[i];
					if (cSeries.Initialized) {
						cSeries.Merge(tick);
					}
				});
			}
		}
Beispiel #16
0
 public static void AddTick(ITick obj)
 {
     Toolbox.Get <UpdateManager>().Ticks.Add(obj);
 }
Beispiel #17
0
 public void StartUpdating(ITick tick)
 {
     this.tick = tick;
     isInit    = true;
 }
Beispiel #18
0
 /// <summary>
 /// Removes all existance of a Tick
 /// </summary>
 /// <param name="t">Tick</param>
 public void RemoveTick(ITick t)
 {
     _ticks = _ticks.Where((value) => value != t).ToArray();
 }
Beispiel #19
0
 /// <summary>
 /// Adds a Tick
 /// </summary>
 /// <param name="t">Tick</param>
 public void AddTick(ITick t)
 {
     _ticks = _ticks.Concat(new ITick[] {t}).ToArray();
 }
Beispiel #20
0
 /// <summary>
 /// Tells if it contains a Tick
 /// </summary>
 /// <param name="t">Tick</param>
 /// <returns>True if contains that tick</returns>
 public bool ContainsTick(ITick t)
 {
     return _ticks.Contains(t);
 }
Beispiel #21
0
 public void AddTickableBlock(ITick tickable)
 {
     StartCoroutine(AddTickableBlockRoutine(tickable));
 }
Beispiel #22
0
 public void RemoveFromTickList(ITick paramTick)
 {
     if (tickList.Contains(paramTick))
         tickList.Remove(paramTick);
 }
Beispiel #23
0
 public bool IsActive(ITick tick)
 {
     return(_activeTicks.Contains(tick));
 }
Beispiel #24
0
    /// <summary>
    /// 加入tick对象
    /// </summary>
    /// <param name="tk"></param>
    public static void AddTick(ITick tk)
    {
        if (tk == null)
        {
            Debug.Log("Warning: Don't add the null object to tick object list");
            return;
        }

        if (instance.tickList.Exists(t => t == tk))
        {
            Debug.Log("Warning: Don't add the same tick object twice.");
            return;
        }

        instance.tickList.Add(tk);
    }
Beispiel #25
0
 private void Row_EventNodeSelected(ThreadRow row, EventFrame frame, EventNode node, ITick tick)
 {
     RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, frame, node, tick));
 }
Beispiel #26
0
    /// <summary>
    /// 移除tick对象
    /// </summary>
    /// <param name="tk"></param>
    public static void RemoveTick(ITick tk)
    {
        if (instance.tickList == null || instance.tickList.Count <= 0)
        {
            Debug.LogWarning("The TickList has error:: null or 0");
            return;
        }

        if (!instance.tickList.Remove(tk))
        {
            Debug.Log("Warning: Remove tick object error. May be the tick object is not in list.");
        }
    }
Beispiel #27
0
 public void RemoveTick(ITick tick)
 {
     _ticks -= tick.Update;
 }
Beispiel #28
0
 public void RemoveTask(ITick task)
 {
     Assert.IsTrue(_asyncTasks.Contains(task), "task not exist");
     _asyncTasks.Remove(task);
 }
Beispiel #29
0
 public void AddToTickList(ITick paramTick)
 {
     if (!tickList.Contains(paramTick))
         tickList.Add(paramTick);
 }
Beispiel #30
0
 public FocusFrameEventArgs(RoutedEvent routedEvent, Data.Frame frame, Data.EventNode node = null, ITick tick = null)
     : base(routedEvent)
 {
     Frame = frame;
     Node  = node;
     Tick  = tick;
 }
Beispiel #31
0
 public void AddTask(ITick task)
 {
     Assert.IsFalse(_asyncTasks.Contains(task), "task already exist");
     _asyncTasks.Add(task);
 }
Beispiel #32
0
 public void RemoveTickableBlock(ITick tickable)
 {
     StartCoroutine(RemoveTickableBlockRoutine(tickable));
 }
Beispiel #33
0
 private void RemoveFromDictionary(ConcurrentDictionary <int, ITick> dictionary, ITick tick)
 {
     _tickers.TryRemove(tick.TickId, out _);
 }
Beispiel #34
0
        private static void cService_onQuote(object sender, Events.QuoteEvent e)
        {
            ITick cTick = e.Quote.GetTick(0);

            System.Console.WriteLine("{0} {1,8:0.00} {2,10} {3, 10}", cTick.Time.ToString("HHmmss"), cTick.Price, cTick.Single, cTick.Volume);
        }