/// <summary>
        ///  Send ordered event to whom ever has subscribed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _SendOrderedOutputEvent(object sender, BladeEventArgs e)
        {
            BladeEventHandler handler = OrderedBladeEvent;

            if (handler != null)
            {
                handler(sender, e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Receives BladeRunner BladeEvent callback from host and dispatches to correct callback function
        /// in TesterObject (client).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void unshuffleEvents_OrderedBladeEvent(object sender, BladeEventArgs e)
        {
            switch (e.EventType)
            {
            case BladeEventType.Bunny:
                //remoteConnectLib.OnBunnyEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.ProgramClosing:
                //remoteConnectLib.OnProgramClosingEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.SequenceAborting:
                //remoteConnectLib.OnSequenceAbortingEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.SequenceCompleted:
                //remoteConnectLib.OnSequenceCompleteEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.SequenceStarted:
                //remoteConnectLib.OnSequenceStartedEvent(sender, e.ToSequenceStartedBladeEventArgs().ToStartedEventArgs());
                break;

            case BladeEventType.SequenceUpdate:
                //remoteConnectLib.OnSequenceUpdateEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.TestCompleted:
                //remoteConnectLib.OnTestCompleteEvent(sender, e.ToCompletedEventBladeArgs().ToCompletedEventArgs());
                break;

            case BladeEventType.TestStarted:
                //remoteConnectLib.OnTestStartedEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;

            case BladeEventType.Status:
                remoteConnectLib.OnStatusEvent(sender, e.ToStatusEventBladeArgs().ToStatusEventArgs());
                break;
            }
        }
        /// <summary>
        /// Push one item into our queue
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void AddOneToQueue(object sender, BladeEventArgs e)
        {
            if (e == null)
            {
                return;
            }

            // Try to get a lock
            try
            {
                try
                {
                    _ReaderWriterLock.AcquireWriterLock(5000);
                }
                catch
                {
                    // Do it anyway
                }

                // If items there then insert in order.
                if (_EventQueue.Count > 0)
                {
                    EventOrderLog.Info("Add another event e.con:{0} e.text:{1} e.type:{2} queue.count:{3}, nowServing:{4}", e.Consecutive, e.Text, e.Type, _EventQueue.Count, _NowServing);
                    // Start at end and iterate back until we find a place to insert.
                    for (int index = _EventQueue.Count - 1; index >= 0; index--)
                    {
                        try
                        {
                            // Is this one null
                            if (_EventQueue[index] == null)
                            {
                                _EventQueue[index] = new BladeEventWithTime(DateTime.Now, sender, e);
                            }
                            // Is this a good spot?
                            else if (e.Consecutive > _EventQueue[index].EventArgs.Consecutive)
                            {
                                // Insert here.
                                _EventQueue.Insert(index + 1, new BladeEventWithTime(DateTime.Now, sender, e));
                                break;
                            }
                            // did we run out of items
                            else if (index == 0)
                            {
                                // Insert at top.
                                _EventQueue.Insert(0, new BladeEventWithTime(DateTime.Now, sender, e));
                                break;
                            }
                        }
                        catch
                        {
                            // skip
                        }
                    }
                }
                else
                {
                    EventOrderLog.Info("Add new event e.con:{0} e.text:{1} e.type:{2} queue.count:{3}, nowServing:{4}", e.Consecutive, e.Text, e.Type, _EventQueue.Count, _NowServing);
                    // else nothing there just add.
                    _EventQueue.Add(new BladeEventWithTime(DateTime.Now, sender, e));
                    // If needed Init the count.
                    if (_NowServing < 0)
                    {
                        Interlocked.Exchange(ref _NowServing, e.Consecutive);
                    }
                }
            }
            finally
            {
                try
                {
                    // Release lock
                    _ReaderWriterLock.ReleaseLock();
                }
                catch
                {
                    // ignored
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This function calls the event dispatch function on a worker thread.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void InternalBladeCallback(object sender, BladeEventArgs e)
        {
            voidObjectBladeEventArgs bladeEventDelegate = new voidObjectBladeEventArgs(unshuffleEvents.AddOneToQueue);

            bladeEventDelegate.BeginInvoke(sender, e, new AsyncCallback(delegate(IAsyncResult ar) { bladeEventDelegate.EndInvoke(ar); }), bladeEventDelegate);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Calls the callback decision func in RemoteConnectLib.
 /// RemoteConnectLib splits out the events from TesterObject and sends them to the correct
 ///  callback function in TesterClient.
 /// </summary>
 /// <param name="e"></param>
 public void BladeEventCallback(BladeEventArgs e)
 {
     _RemoteConnectLib.BladeEvent.InternalBladeCallback(this, e);
 }