Esempio n. 1
0
        /// <summary>
        /// 该函数为对外接口,负责接收新到的tuple
        /// </summary>
        /// <param name="newTuple"></param>
        public void ReceiveNewTupe(ITuple newTuple)
        {
            newTuple.ArrivalStep = currentStep;
            newTuple.DepartStep  = ComputeDepartStep();
            newTuple.IsOutlier   = false;

            if (SendingEventToOutside)
            {
                Event anEvent = new Event(GetType().ToString(), EventType.NewTupleArrive);
                anEvent.AddAttribute(EventAttributeType.Tuple, newTuple);
                EventDistributor.GetInstance().SendEvent(anEvent);
            }
            //目前一步一个tuple,故可以如此赋值
            CODTuple newCODTuple = new CODTuple(newTuple);

            if (ShouldWindowSlide())
            {
                SlideWindow();
            }

            //Arrive函数是否要在窗口弹出之前执行呢?我觉得是在之后,因为窗口的定义为”总是维护最近的n个object“
            //而arrive应当是以window之内作为执行范围的,若在窗口弹出前执行,岂不是Arrive的执行范围变成了n+1? 所以我将Arrive放在这里
            Arrive(newCODTuple, currentStep);

            AddTupleIntoWindow(newCODTuple);
            currentStep++;
        }
Esempio n. 2
0
        /*public void TestInit()
         * {
         *  DataFilePath = System.Environment.CurrentDirectory + "\\InputData\\covtype.data";
         *  Dimension = 55;
         *  _delimiter = new char[] { ',' };
         * }*/

        public ITuple GetNextTuple()
        {
            if (fileReader != null)
            {
                try
                {
                    string line = fileReader.ReadLine();
                    if (line == null)
                    {
                        //End of file, send the eof event
                        Event EofEvent = new Event(GetType().ToString(), EventType.NoMoreTuple);
                        EventDistributor.GetInstance().SendEvent(EofEvent);
                        fileReader.Close();
                        return(null);
                    }
                    else
                    {
                        return(CovertTuple(line.Trim()));
                    }
                }
                catch (Exception e)
                {
                    ExceptionUtil.SendErrorEventAndLog(GetType().ToString(), e.Message);
                    throw e;
                }
            }
            else
            {
                ExceptionUtil.SendErrorEventAndLog(GetType().ToString(), "fileReader is null");
                return(null);
            }
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            algorithmHandler = new AlgorithmMgr();

            EventType[] acceptedEventTypeList = { EventType.NoMoreTuple, EventType.Error, EventType.OldTupleDepart };
            EventDistributor.GetInstance().SubcribeListenerWithFullAcceptedTypeList(this, acceptedEventTypeList);
        }
        public static void SendErrorEventAndLog(string sendDestription, string errorMsg)
        {
            Event errorEvent = new Event(sendDestription, EventType.Error);

            errorEvent.AddAttribute(EventAttributeType.Message, errorMsg);
            EventDistributor.GetInstance().SendEvent(errorEvent);

            Logger.GetInstance().Error(sendDestription, errorMsg);
        }
Esempio n. 5
0
 public void RemoveFromOutlier(ITuple tuple)
 {
     tuple.IsOutlier = false;
     if (SendingEventToOutside)
     {
         Event e = new Event("an tuple become inlier", EventType.OutlierBecomeInlier);
         e.AddAttribute(EventAttributeType.TupleID, tuple.ID);
         EventDistributor.GetInstance().SendEvent(e);
     }
 }
Esempio n. 6
0
 public void AddToOutlier(ITuple tuple)
 {
     tuple.IsOutlier = true;
     if (SendingEventToOutside)
     {
         Event e = new Event("an tuple become outlier", EventType.InlierBecomeOutlier);
         e.AddAttribute(EventAttributeType.TupleID, tuple.ID);
         EventDistributor.GetInstance().SendEvent(e);
     }
     outliers.Add(tuple.ID);
 }
        public _2D_DisplayField()
        {
            InitializeComponent();
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
            SetStyle(ControlStyles.DoubleBuffer, true);         // 双缓冲\

            dataPoints = new Dictionary <int, ITuple>();

            panelGraphics = pl_Canvas.CreateGraphics();

            EventType[] acceptedEventTypeList = { EventType.NewTupleArrive, EventType.InlierBecomeOutlier, EventType.OutlierBecomeInlier, EventType.OldTupleDepart, EventType.NoMoreTuple };

            EventDistributor.GetInstance().SubcribeListenerWithFullAcceptedTypeList(this, acceptedEventTypeList);

            RefreshDataPointsTimer.Start();
        }
Esempio n. 8
0
        public void SlideWindow()
        {
            for (int i = 0; i < _slideSpan; i++)
            {
                CODTuple oldTuple = window.Dequeue();
                if (SendingEventToOutside)
                {
                    Event anEvent = new Event("Object Depart", EventType.OldTupleDepart);
                    anEvent.AddAttribute(EventAttributeType.TupleID, oldTuple.tuple.ID);
                    anEvent.AddAttribute(EventAttributeType.Tuple, oldTuple.tuple);
                    EventDistributor.GetInstance().SendEvent(anEvent);
                }
                //Departure(oldTuple, currentStep);
                DepartureNotIncludingSafeInlier(oldTuple, currentStep);
                //DepartureWithNotConsiderSlideSpan(oldTuple, currentStep);
            }

            if (SendingEventToOutside)
            {
                Event e = new Event("window has just Slided", EventType.WindowSlide);
                EventDistributor.GetInstance().SendEvent(e);
            }
        }