Beispiel #1
0
        /// <summary>
        /// Dumps all request data (outputs\parameters\records)
        /// </summary>
        private void DumpAllData(CQG.CQGTimedBars myBars, KaiTrade.Interfaces.ITSSet mySet)
        {
            try
            {
                int exitingItemCount = mySet.Items.Count;
                // Clears all records
                mySet.Items.Clear();

                if (myBars.Count == 0)
                {
                    return;
                }

                KaiTrade.Interfaces.ITSItem[] bars = new KaiTrade.Interfaces.ITSItem[myBars.Count];
                for (int i = 0; i < myBars.Count; i++)
                {
                    // get a new TS item
                    bars[i] = mySet.GetNewItem();
                    CopyBar(bars[i], mySet, myBars[i], i);
                    bars[i].SourceActionType = KaiTrade.Interfaces.TSItemSourceActionType.barAdded;
                    bars[i].ItemType = KaiTrade.Interfaces.TSItemType.time;
                    if (i >= exitingItemCount)
                    {
                        bars[i].DriverChangedData = true;
                    }
                    else if (i >= myBars.Count - 2)
                    {
                        bars[i].DriverChangedData = true;
                    }
                    else
                    {
                        bars[i].DriverChangedData = false;
                    }

                    //this.BarUpdateClients(my
                    mySet.AddItem(bars[i]);
                    if (wireLog.IsInfoEnabled)
                    {
                        wireLog.Info("TBADD:" + bars[i].ToTabSeparated());
                    }
                }

                // Will enable all bar clients of the driver to handle the bars
                this.BarUpdateClients(mySet.RequestID, bars);

            }
            catch (Exception myE)
            {
                log.Error("DumpAllData", myE);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fired when CQGTimedBar item is updated.
        /// </summary>
        /// <param name="cqg_timed_bars">
        /// Reference to changed CQGTimedBars
        /// </param>
        /// <param name="index_">
        /// Specifies the updated CQGTimedBar index.
        /// </param>
        private void CEL_TimedBarsUpdated(CQG.CQGTimedBars cqg_timed_bars, int index_)
        {
            try
            {
                lock (m_BarToken1)
                {
                    try
                    {
                        // try get the set
                        KaiTrade.Interfaces.ITSSet mySet;
                        //return;
                        if (m_TSSets.ContainsKey(cqg_timed_bars.Id))
                        {
                            mySet = m_TSSets[cqg_timed_bars.Id];
                            if (!mySet.ReportAll)
                            {
                                // they only want added bars - so exit
                                return;
                            }
                            KaiTrade.Interfaces.ITSItem[] bars = new KaiTrade.Interfaces.ITSItem[1];
                            bars[0] = mySet.GetNewItem();

                            CopyBar(bars[0], mySet, cqg_timed_bars[index_], index_);
                            bars[0].SourceActionType = KaiTrade.Interfaces.TSItemSourceActionType.barUpdated;
                            bars[0].DriverChangedData = true;
                            mySet.ReplaceItem(bars[0], index_);

                            BarUpdateClients(mySet.RequestID, bars);
                            //mySet.Changed = true;
                        }
                    }
                    catch (Exception myE)
                    {
                        log.Error("CEL_TimedBarsUpdated", myE);
                    }
                }
            }
            catch
            {
            }
        }