예제 #1
0
 private void Update(ITick tick)
 {
     foreach (var go in _gameObjectFactory.GameObjects.Values)
     {
         go.Update(tick);
     }
 }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
    }
예제 #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;
                }
            }
        }
예제 #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);
            }
        }
예제 #8
0
 public void UnRegistTick(ITick iTick)
 {
     _iTicks.Remove(iTick);
 }
예제 #9
0
 public void RegistTick(ITick iTick)
 {
     _iTicks.Add(iTick);
 }
예제 #10
0
파일: Chunk.cs 프로젝트: Barabicus/BBlocks
 private IEnumerator RemoveTickableBlockRoutine(ITick tickable)
 {
     yield return new WaitForEndOfFrame();
     _tickableBlock.Remove(tickable);
 }
예제 #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;
                    }
                }
            }
        }
예제 #12
0
 public void AddTick(ITick tick)
 {
     _ticks += tick.Update;
 }
예제 #13
0
        public double TimeToUnit(ITick tick)
        {
            double durationTicks = TimeSlice.Finish - TimeSlice.Start;

            return((tick.Start - TimeSlice.Start) / durationTicks);
        }
예제 #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;
			}
		}
예제 #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);
					}
				});
			}
		}
예제 #16
0
 public static void AddTick(ITick obj)
 {
     Toolbox.Get <UpdateManager>().Ticks.Add(obj);
 }
예제 #17
0
 public void StartUpdating(ITick tick)
 {
     this.tick = tick;
     isInit    = true;
 }
예제 #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();
 }
예제 #19
0
 /// <summary>
 /// Adds a Tick
 /// </summary>
 /// <param name="t">Tick</param>
 public void AddTick(ITick t)
 {
     _ticks = _ticks.Concat(new ITick[] {t}).ToArray();
 }
예제 #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);
 }
예제 #21
0
파일: Chunk.cs 프로젝트: Barabicus/BBlocks
 public void AddTickableBlock(ITick tickable)
 {
     StartCoroutine(AddTickableBlockRoutine(tickable));
 }
예제 #22
0
 public void RemoveFromTickList(ITick paramTick)
 {
     if (tickList.Contains(paramTick))
         tickList.Remove(paramTick);
 }
예제 #23
0
 public bool IsActive(ITick tick)
 {
     return(_activeTicks.Contains(tick));
 }
예제 #24
0
파일: Engine.cs 프로젝트: zs9024/Jungle
    /// <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);
    }
예제 #25
0
 private void Row_EventNodeSelected(ThreadRow row, EventFrame frame, EventNode node, ITick tick)
 {
     RaiseEvent(new TimeLine.FocusFrameEventArgs(TimeLine.FocusFrameEvent, frame, node, tick));
 }
예제 #26
0
파일: Engine.cs 프로젝트: zs9024/Jungle
    /// <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.");
        }
    }
예제 #27
0
 public void RemoveTick(ITick tick)
 {
     _ticks -= tick.Update;
 }
예제 #28
0
 public void RemoveTask(ITick task)
 {
     Assert.IsTrue(_asyncTasks.Contains(task), "task not exist");
     _asyncTasks.Remove(task);
 }
예제 #29
0
 public void AddToTickList(ITick paramTick)
 {
     if (!tickList.Contains(paramTick))
         tickList.Add(paramTick);
 }
예제 #30
0
 public FocusFrameEventArgs(RoutedEvent routedEvent, Data.Frame frame, Data.EventNode node = null, ITick tick = null)
     : base(routedEvent)
 {
     Frame = frame;
     Node  = node;
     Tick  = tick;
 }
예제 #31
0
 public void AddTask(ITick task)
 {
     Assert.IsFalse(_asyncTasks.Contains(task), "task already exist");
     _asyncTasks.Add(task);
 }
예제 #32
0
파일: Chunk.cs 프로젝트: Barabicus/BBlocks
 public void RemoveTickableBlock(ITick tickable)
 {
     StartCoroutine(RemoveTickableBlockRoutine(tickable));
 }
예제 #33
0
 private void RemoveFromDictionary(ConcurrentDictionary <int, ITick> dictionary, ITick tick)
 {
     _tickers.TryRemove(tick.TickId, out _);
 }
예제 #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);
        }