Exemplo n.º 1
0
 public abstract void InternalBladeCallback(object sender, BladeEventArgs e);
Exemplo n.º 2
0
 public BladeEventWithTime(DateTime arivalTime, object sender, BladeEventArgs e)
 {
     _ArrivalTime = arivalTime;
     _EventArgs   = e;
     _Sender      = sender;
 }
Exemplo n.º 3
0
 //[OneWay]
 public void BladeCallback(object sender, BladeEventArgs e)
 {
     InternalBladeCallback(sender, e);
 }
Exemplo n.º 4
0
 public BladeEventWithTime()
 {
     _ArrivalTime = DateTime.Now;
     _EventArgs   = new BladeEventArgs();
     _Sender      = new object();
 }
        /// <summary>
        /// This function pulls items out and sends to remote clients.
        /// Actually it calls the callback function in each client via proxy.
        /// </summary>
        private void doBladeEvents()
        {
            // TODO : Deal the event send from SendBladeEventCallback
            while (!_Exit)
            {
                //doBladeEventsGoing = true;
                List <BladeEventStruct> bladeEventArgList = new List <BladeEventStruct>();
                try
                {
                    // Use ReaderWriterLock
                    while (!_Exit)
                    {
                        try
                        {
                            _BladeEventQueueLock.AcquireWriterLock(20);
                            break;
                        }
                        catch (ApplicationException)
                        {
                            // Timeout
                            if (_Exit)
                            {
                                return;
                            }
                            continue;
                        }
                    }

                    if (_Exit)
                    {
                        continue;
                    }
                    if (_BladeEventQueue.Count == 0 || _TesterState.PauseEvents)
                    {
                        // Do not send event
                        Thread.Sleep(5);
                        continue;
                    }

                    while (_BladeEventQueue.Count > 0)
                    {
                        BladeEventStruct anEventStruct = _BladeEventQueue.Dequeue();
                        BladeEventArgs   anEventArg    = anEventStruct.EE;

                        bladeEventArgList.Add(anEventStruct);
                    }
                }
                finally
                {
                    if (_BladeEventQueueLock.IsWriterLockHeld)
                    {
                        // Release access right
                        _BladeEventQueueLock.ReleaseWriterLock();
                    }
                }
                if (_Exit)
                {
                    return;
                }
                foreach (BladeEventStruct anEventStruct in bladeEventArgList)
                {
                    BladeEventArgs anEventArg             = anEventStruct.EE;
                    List <ITesterObjectCallback> sentList = new List <ITesterObjectCallback>();

                    for (int i = 0; _CallbackProxyList != null && i < _CallbackProxyList.Count; i++)
                    {
                        ITesterObjectCallback callback = _CallbackProxyList.Get(i);
                        if (!sentList.Contains(callback))
                        {
                            sentList.Add(callback);
                            try
                            {
                                callback.BladeEventCallback(anEventArg);
                            }
                            catch (Exception e)
                            {
                                try
                                {
                                    StaticServerTalker.MessageString        = "Client callback proxy failed. ";
                                    StaticServerTalker.MessageStringContent = "Client callback proxy failed. " + Environment.NewLine + makeUpExceptionString(e).ToString();
                                }
                                catch { }
                                _CallbackProxyList.Remove(i);
                                sentList.Remove(callback);
                                i--;
                            }
                        }
                    }
                    if (_Exit)
                    {
                        break;
                    }
                }
            }
        }
        // TODO : The event of sequence.
        //private void SendSequenceStartedEvent(object sender, StartedEventArgs e)
        //{ }

        //private void SendSequenceAbortingEvent(object sender, StatusEventArgs e)
        //{ }

        //private void SendSequenceCompletedEvent(object sender, StatusEventArgs e)
        //{ }

        //private void SendSequenceUpdateEvent(object sender, StatusEventArgs e)
        //{ }

        //private void SendTestStartedEvent(object sender, StatusEventArgs e)
        //{ }

        //private void SendTestCompletedEvent(object sender, CompletedEventArgs e)
        //{ }

        //private void SendProgramClosingEvent(object sender, StatusEventArgs e)
        //{ }


        /// <summary>
        /// Puts items in the queue.
        /// It called by all send event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendBladeEventCallback(object sender, BladeEventArgs e)
        {
            lock (_BladeEventLockObj)
            {
                e.Consecutive = _ConsecutiveCount++;
                if (_ConsecutiveCount < 0)
                {
                    _ConsecutiveCount = 0;
                }
            }

            if (e.Text.ToLower().IndexOf("Event::varToEvent".ToLower()) == 0)
            {
            }
            else if (e.Text.ToLower().Contains("Event::PowerEvent::PCBPower1".ToLower()))
            {
            }
            else if (e.Text.ToLower().Contains("Event::PowerEvent::PCBPower0".ToLower()))
            {
            }
            else if (e.Text.ToLower().Contains("Event::MEMSOpenEvent::MEMSOpen".ToLower()))
            {
            }
            else if (e.Text.ToLower().Contains("Event::MEMSCloseEvent::MEMSClose".ToLower()))
            {
            }
            else if (e.Text.ToLower().Contains("Event::GetBladeValue::MEMSState".ToLower()))
            {
            }
            else if (e.Text.ToLower().Contains("Event::LoadActuator::".ToLower()))
            {
            }
            if (_BladeEventQueue != null && _BladeEventQueueLock != null)
            {
                try
                {
                    try
                    {
                        _BladeEventQueueLock.AcquireWriterLock(TimeSpan.FromMilliseconds((2000)));
                    }
                    catch (System.Exception ex)
                    {
                        // TODO : Do it anyway?
                    }
                    _BladeEventQueue.Enqueue(new BladeEventStruct(sender, e));
                    // Send to host (BladeRunner)
                    try
                    {
                        StaticServerTalker.BladeEvent(new object[] { sender, e });
                    }
                    catch (System.Exception ex)
                    {
                        // TODO : Do nothing?
                    }
                }
                catch (System.Exception ex)
                {
                    // TODO : do nothing?
                }
                finally
                {
                    if (_BladeEventQueueLock.IsWriterLockHeld)
                    {
                        _BladeEventQueueLock.ReleaseWriterLock();
                    }
                }
            }
        }
 public BladeEventStruct(object sender, BladeEventArgs e)
 {
     Sender = sender;
     EE     = e;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Puts items in the queue
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SendBladeEventCallback(object sender, BladeEventArgs e)
 {
 }