// // #endregion//Properties #region Public Methods // ***************************************************************** // **** Public Methods **** // ***************************************************************** /// <summary> /// Any thread can push onto this queue. /// </summary> /// <param name="e"></param> public void Add(EventArgs e) { if (ResubmissionReady == null) { Exception ex = new Exception("Cannot add to queue with no subscribers to ResubmissionReady event."); throw ex; } if (e == null) { Exception ex = new Exception("Cannot add a null EventArg to queue."); throw ex; } m_InQueue.Enqueue(e); if (Log != null) { Log.NewEntry(LogLevel.Minor, "EventWaitQueue: Adding {0} to queue.", e); } } // Add()
}//end Stop(). // #endregion//public methods #region Private Methods // ***************************************************************** // **** Private Methods **** // ***************************************************************** // /// <summary> /// This overrides the empty HubBase method and logs the important statistics. /// </summary> protected override void DiagnosticReport() { Log.NewEntry(LogLevel.Minor , "Base Load={0:0.0}% EventFreq={1:0.0} hz EventsWaiting={2:0.0}% SleepSkipped={3:0.0}% EventArrivalRate={4:0.0} " //, "Base Load={0:##0.0}% EventFreq={1:##0.0} hz EventsWaiting={2:##0.0}% SleepSkipped={3:##0.0}% EventArrivalRate={4:####0.0} " , HubWorkLoad * 100.0 , HubEventFrequency , HubEventWaitingFraction * 100.0 , HubSleepSkippedFraction * 100.0 , HubEventClusterAverageSize); }// Diagnotic report
}//SetConfirmMode() // #endregion//Private Methods #region Event Handlers // ***************************************************************** // **** Event Handlers **** // ***************************************************************** // // private void buttonSubmitFill_Click(object sender, EventArgs e) { if (m_IsConfirmMode) { // The user has confirmed to send this. // Read numbers again bool isGoodToSendOrder = true; int qty = 0; if (!Int32.TryParse(textBoxQty.Text, out qty)) { isGoodToSendOrder = false; } double price = 0; if (!Double.TryParse(textBoxPrice.Text, out price)) { isGoodToSendOrder = false; } if (isGoodToSendOrder) { // Submit fill now Misty.Lib.OrderHubs.Fill aFill = Misty.Lib.OrderHubs.Fill.Create(); aFill.Price = price; aFill.Qty = qty; aFill.LocalTime = Log.GetTime(); /* * //Misty.Lib.Products.InstrumentBase instrBase = null; * TradingTechnologies.TTAPI.InstrumentDetails details; * if (m_CurrentInstrument != m_EmptyInstrument && m_Market.TryGetInstrumentDetails(m_CurrentInstrument, out details) && details != null && details.Key != null) * { // TODO: Somewhere around here a null exception was thrown. * if ( Log != null) * Log.NewEntry(Misty.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0} or ForeignKey is null", m_CurrentInstrument); * TradingTechnologies.TTAPI.InstrumentKey instrKey = (TradingTechnologies.TTAPI.InstrumentKey)details.Key; * Ambre.TTServices.Fills.FillEventArgs fillEventArgs = new Ambre.TTServices.Fills.FillEventArgs(instrKey, Ambre.TTServices.Fills.FillType.UserAdjustment, aFill); * m_FillHub.HubEventEnqueue(fillEventArgs); * } * else if (Log != null) * Log.NewEntry(Misty.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument); */ // New version. TradingTechnologies.TTAPI.InstrumentKey instrumentKey; if (m_CurrentInstrument != m_EmptyInstrument && m_FillHub.TryGetInstrumentKey(m_CurrentInstrument, out instrumentKey)) { // TODO: Somewhere around here a null exception was thrown. if (Log != null) { Log.NewEntry(Misty.Lib.Hubs.LogLevel.Major, "FormAddFills.SubmitFill_Click: Submitting fill request {0}.", m_CurrentInstrument); } Ambre.TTServices.Fills.FillEventArgs fillEventArgs = new Ambre.TTServices.Fills.FillEventArgs(instrumentKey, Ambre.TTServices.Fills.FillType.UserAdjustment, aFill); m_FillHub.HubEventEnqueue(fillEventArgs); } else if (Log != null) { Log.NewEntry(Misty.Lib.Hubs.LogLevel.Warning, "FormAddFills.SubmitFill_Click: Failed {0} or ForeignKey is null", m_CurrentInstrument); } // REset the colors textBoxQty.Text = string.Empty; // protection against user's adding fill twice. SetConfirmMode(buttonSubmitFill, false, 0); // reset colors and text on button } } else { bool isGood = true; int qty = 0; if (Int32.TryParse(textBoxQty.Text, out qty)) { textBoxQty.Text = string.Format("{0:+0;-0;0}", qty); } else { textBoxQty.Text = "0"; isGood = false; } double price = 0; if (Double.TryParse(textBoxPrice.Text, out price)) { textBoxPrice.Text = string.Format("{0}", price); } else { textBoxPrice.Text = ""; isGood = false; } // Set SetConfirmMode(buttonSubmitFill, isGood, qty); // set colors to "confirm" mode. } }