Example #1
0
        /// <summary>
        /// Example of cross join and projections
        /// </summary>
        /// <param name="ericSEKStream"></param>
        /// <param name="ericUSDStream"></param>
        /// <param name="USDSEKStream"></param>
        private static void crossJoinProjectionExample(IEnumerable <StockQuote> ericSEKObservable, IEnumerable <StockQuote> ericUSDObservable, IEnumerable <StockQuote> USDSEKObservable, Application application)
        {
            var ericUSDStream = ericUSDObservable.ToPointStream(application, e => PointEvent <StockQuote> .CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);
            var ericSEKStream = ericSEKObservable.ToPointStream(application, e => PointEvent <StockQuote> .CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);
            var USDSEKStream  = USDSEKObservable.ToPointStream(application, e => PointEvent <StockQuote> .CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);

            var ericRecalcCepStream = from eUSD in ericUSDStream
                                      from eXch in USDSEKStream
                                      where eUSD.FieldID == "Close"
                                      select new StockQuote()
            {
                StockID   = "ERIC-Recalc",
                FieldID   = "Close",
                Value     = eUSD.Value * eXch.Value,                       // Convert ERIC USD quote to SEK
                TimeStamp = eUSD.TimeStamp
            };

            var ericCompareCepStream = from eRecalc in ericRecalcCepStream
                                       from eSEK in ericSEKStream
                                       where eSEK.FieldID == "Close"
                                       select new StockQuote()
            {
                StockID   = "ERIC-Compare",
                FieldID   = "Diff",
                Value     = eSEK.Value - eRecalc.Value,
                TimeStamp = eRecalc.TimeStamp
            };

            runQuery(ericCompareCepStream);
        }
Example #2
0
 private void widget_PointX(object sender, PointEvent e)
 {
     this.UpDateData(delegate
     {
         this._propertyItem.SetValue(this._propertyItem.Instance, (int)e.PointX, null);
     });
 }
Example #3
0
    public void AddPoints(PointEvent pe)
    {
        switch (pe)
        {
        case PointEvent.chunkHit:
            currentScore += pointsChunkHit;
            break;

        case PointEvent.chunkDestroyed:
            currentScore += pointsChunkDestroyed;
            break;

        case PointEvent.asteroidSplit:
            currentScore += pointsAsteroidSplit;
            break;
        }

        scoreText.text = currentScore.ToString();
        scoreText.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f);

        // check if enough points for new life
        if (currentScore >= nextLifeAt)
        {
            nextLifeAt += newLifeEvery;
            pc.AddLife();
            livesText.text = pc.currentLives.ToString();
        }
    }
        public static List <PointEvent <YahooQuote> > GetPointEvents(string[] symbols)
        {
            string symbolList = String.Join("%2C", symbols.Select(w => "%22" + w + "%22").ToArray());
            string url        = string.Format(BASE_URL, symbolList);
            List <PointEvent <YahooQuote> > Quotes = new List <PointEvent <YahooQuote> >();

            try {
                XDocument doc = XDocument.Load(url);
                while (doc.Root.Element("results").IsEmpty)
                {
                    doc = XDocument.Load(url);
                }
                XElement results = doc.Root.Element("results");
                foreach (string symbol in symbols)
                {
                    YahooQuote quote = new YahooQuote(symbol);
                    quote = ParseQuote(symbol, results);
                    Quotes.Add(PointEvent <YahooQuote> .CreateInsert(quote.LastUpdate, quote));
                    Quotes.Add(PointEvent <YahooQuote> .CreateCti(quote.LastUpdate));
                }
            } catch (Exception e) {
                Console.WriteLine("GetPointEventException: {0}", e.Message);
            }

            return(Quotes);
        }
Example #5
0
        /// <summary>
        /// Main driver to dequeue events and output them to the CSV file.
        /// </summary>
        private void ConsumeEvents()
        {
            PointEvent currentEvent = default(PointEvent);

            try
            {
                while (true)
                {
                    if (AdapterState.Stopping == AdapterState)
                    {
                        this.streamWriter.Flush();
                        this.streamWriter.Close();

                        Stopped();

                        return;
                    }

                    if (DequeueOperationResult.Empty == Dequeue(out currentEvent))
                    {
                        Ready();
                        return;
                    }

                    this.streamWriter.WriteLine(TextFileWriterCommon.CreateLineFromEvent(currentEvent, this.bindtimeEventType, this.delimiter));

                    // Every received event needs to be released.
                    ReleaseEvent(ref currentEvent);
                }
            }
            catch (AdapterException e)
            {
                this.consoleTracer.WriteLine("ConsumeEvents - " + e.Message + e.StackTrace);
            }
        }
Example #6
0
        private static string CreateLineFromEvent(UntypedEvent evt, CepEventType eventType, string[] delimiter, Dictionary <int, int> order, CultureInfo culture)
        {
            StringBuilder builder       = new StringBuilder();
            PointEvent    pointEvent    = evt as PointEvent;
            IntervalEvent intervalEvent = evt as IntervalEvent;
            EdgeEvent     edgeEvent     = evt as EdgeEvent;

            if (EventKind.Cti == evt.EventKind)
            {
                builder
                .Append("CTI")
                .Append(delimiter[0]);

                if (null != pointEvent)
                {
                    builder.Append(pointEvent.StartTime.ToString());
                }
                else if (null != intervalEvent)
                {
                    builder.Append(intervalEvent.StartTime.ToString());
                }
                else
                {
                    builder.Append(edgeEvent.StartTime.ToString());
                }
            }
            else
            {
                builder
                .Append("INSERT")
                .Append(delimiter[0]);

                if (null != pointEvent)
                {
                    builder.Append(pointEvent.StartTime.ToString());
                }
                else if (null != intervalEvent)
                {
                    builder
                    .Append(intervalEvent.StartTime.ToString())
                    .Append(delimiter[0])
                    .Append(intervalEvent.EndTime.ToString())
                    .Append(delimiter[0]);
                }
                else
                {
                    builder
                    .Append(edgeEvent.EdgeType.ToString())
                    .Append(delimiter[0])
                    .Append(edgeEvent.StartTime.ToString())
                    .Append(delimiter[0])
                    .Append((EdgeType.End == edgeEvent.EdgeType) ? edgeEvent.EndTime.ToString() : string.Empty)
                    .Append(delimiter[0]);
                }

                SerializePayload(evt, eventType, delimiter, order, culture, ref builder);
            }

            return(builder.ToString());
        }
Example #7
0
 private void PointImage_ImageStatusChanged(object sender, PointEvent e)
 {
     if (this.ImageStatusChanged != null)
     {
         this.ImageStatusChanged(sender, e);
     }
 }
Example #8
0
 private void widget_PointX(object sender, PointEvent e)
 {
     this.UpDateData(delegate
     {
         this._propertyItem.SetValue(this._propertyItem.Instance, Convert.ToSingle(e.PointX), null);
     });
 }
Example #9
0
        static void Main(string[] args)
        {
            while (inputQuote.FirstOrDefault().LastTradePrice == null)
            {
                Fetch(inputQuote);
            }


            using (Server server = Server.Create("default")) {
                Application application = server.CreateApplication("app");

                IQStreamable <YahooQuote> inputStream = null;

                inputStream = application.DefineObservable(() => ToObservableInterval(inputQuote, TimeSpan.FromMilliseconds(1000), Scheduler.ThreadPool)).ToPointStreamable(
                    r => PointEvent <YahooQuote> .CreateInsert(DateTimeOffset.Now, r),
                    AdvanceTimeSettings.StrictlyIncreasingStartTime);

                var myQuery = from evt in inputStream
                              select evt;

                foreach (var outputSample in myQuery.ToEnumerable())
                {
                    Console.WriteLine(outputSample);
                }

                Console.WriteLine("Done. Press ENTER to terminate.");
                Console.ReadLine();
            }
        }
Example #10
0
        public void begin(Application myApp, int capacity, string processName)
        {
            string conn_string = this.CONNECTION_STRING;
            string sql_query   = this.SQL_QUERY;

            System.Reactive.Linq.IQbservable <T> qSource2 = myApp.DefineObservable <T>(() => new ObservablePoller <T>(conn_string, sql_query, 5000));
            var streamable = qSource2.ToPointStreamable(x => PointEvent.CreateInsert(DateTime.Now, x), AdvanceTimeSettings.IncreasingStartTime);

            requestHolder             = new RequestManager.RequestHolder(this.TABLENAME, capacity);
            requestHolder.rowBody     = new RequestManager.RowBody();
            requestHolder.rowBody.Row = new List <RequestManager.RowElement>();

            // DEFINE a simple observer SINK (writes the value to the server console)
            string hbase_row_key = this.HBASE_ROW_KEY.Clone().ToString();
            var    mySink2       = myApp.DefineObserver(() => Observer.Create <T>(x => Sink <T>(x, hbase_row_key)));


            // Compose a QUERY over the source (able to filter out results here if desired)

            var myQuery2 = from e in streamable
                           select e;

            // BIND the query to the sink and RUN it
            using (IDisposable proc = myQuery2.Bind <T>(mySink2).Run(processName))
            {
                Console.WriteLine("----------------------------------------------------------------");
                Console.WriteLine("MyStreamInsightServer is running, press Enter to stop the server");
                Console.WriteLine("----------------------------------------------------------------");
                Console.WriteLine(" ");
                Console.ReadLine();
            }
            Console.ReadLine();
        }
Example #11
0
        static void Main(string[] args)
        {
            string port         = "8088";
            string wcfSourceURL = String.Format(@"http://*****:*****@"http://localhost:{0}/StreamInsight/wcf/Sink/", port);

            using (var server = Server.Create("Default"))
            {
                string AppName = "TestApp";

                if (server.Applications.ContainsKey(AppName))
                {
                    server.Applications[AppName].Delete();
                }
                var app = server.CreateApplication(AppName);

                //WCF Artifacts
                var observableWcfSource = app.DefineObservable(() => new WcfObservable(wcfSourceURL));
                var observableWcfSink   = app.DefineObserver(() => new WcfObserver(wcfSinkURL));
                var r     = new Random(0);
                var query = from x in observableWcfSource.ToPointStreamable(i => PointEvent.CreateInsert <int>(i.T, i.I), AdvanceTimeSettings.IncreasingStartTime).TumblingWindow(TimeSpan.FromMilliseconds(1000))
                            let avgCpu = x.Avg(e => e)
                                         select new OutputEvent {
                    O = (byte)avgCpu, Color = (byte)(avgCpu > 70 ? 2 : avgCpu > 45 ? 1 : 0)
                };

                Console.WriteLine("StreamInsight application using wcf artifacts (WcfObservable)");
                using (query.Bind(observableWcfSink).Run())
                {
                    Console.WriteLine("Sending events...");
                    Console.WriteLine("Press <Enter> to exit.");
                    Console.ReadLine();
                }
            }
        }
 static Task ReceivedWeaponEvent(PointEvent pointEvent)
 {
     try
     {
         if (Function.Call <bool>(Hash.HAS_ENTITY_CLEAR_LOS_TO_ENTITY_IN_FRONT, Game.PlayerPed.Handle, playerList[pointEvent.SourceServerId].Character.Handle))
         {
             if (pointEvent.SerializedArguments == "lower") // May serialize these later from an enum or something just to make everything look nicer, but this is not that bad
             {
                 //BaseScript.TriggerEvent("Chat.Message", "", "#AAAAAA", "The weapon was lowered.");
             }
             else if (pointEvent.SerializedArguments == "raise")
             {
                 //BaseScript.TriggerEvent("Chat.Message", "", "#AA4444", "Somebody nearby raised a weapon!");
             }
             else if (pointEvent.SerializedArguments == "manipulate")
             {
                 //BaseScript.TriggerEvent("Chat.Message", "", "#EE5555", "Somebody nearby is manipulating a weapon!");
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error($"ReceivedWeaponEvent: {ex.Message}");
     }
     return(Task.FromResult(0));
 }
        static void SendWeaponEvent(string weaponEvent)
        {
            const float weaponEventAoe = 25f;
            PointEvent  pointEvent     = new PointEvent("Weapons.ManipulationEvent", CitizenFX.Core.Game.PlayerPed.Position.ToArray(), weaponEventAoe, weaponEvent, Game.Player.ServerId, false);

            BaseScript.TriggerServerEvent("TriggerEventNearPoint", Helpers.MsgPack.Serialize(pointEvent));
        }
Example #14
0
 private void PrepareToStop(PointEvent <T> currEvent, DequeueOperationResult result)
 {
     if (result == DequeueOperationResult.Success)
     {
         ReleaseEvent(ref currEvent);
     }
 }
 public PointEvent <TPayloadType> GetPointEvent()
 {
     if (this.EventKind == EventKind.Insert)
     {
         return(PointEvent <TPayloadType> .CreateInsert(this.Start, Payload));
     }
     return(PointEvent <TPayloadType> .CreateCti(Start));
 }
Example #16
0
        /// <summary>
        /// Main loop
        /// </summary>
        private void ProduceEvents()
        {
            var currEvent = default(PointEvent <StockQuote>);

            EnqueueCtiEvent(DateTimeOffset.Now);
            try
            {
                // Loop until stop signal
                while (AdapterState != AdapterState.Stopping)
                {
                    if (pendingEvent != null)
                    {
                        currEvent    = pendingEvent;
                        pendingEvent = null;
                    }
                    else
                    {
                        try
                        {
                            // Read from source
                            var str   = screenScraper.Scrape();
                            var value = double.Parse(str, QuoteFormatProvider);

                            // Produce INSERT event
                            currEvent           = CreateInsertEvent();
                            currEvent.StartTime = DateTimeOffset.Now;
                            currEvent.Payload   = new StockQuote {
                                StockID = _config.StockName, Value = value
                            };
                            pendingEvent = null;
                            //PrintEvent(currEvent);
                            Enqueue(ref currEvent);

                            // Also send an CTI event
                            EnqueueCtiEvent(DateTimeOffset.Now.AddTicks(2));
                        }
                        catch
                        {
                            // Error handling should go here
                        }
                        Thread.Sleep(_config.Interval);
                    }
                }

                if (pendingEvent != null)
                {
                    currEvent    = pendingEvent;
                    pendingEvent = null;
                }

                PrepareToStop(currEvent);
                Stopped();
            }
            catch (AdapterException e)
            {
                Console.WriteLine("AdvantIQ.ExampleAdapters.Input.YahooFinanceTypedPointInput.ProduceEvents - " + e.Message + e.StackTrace);
            }
        }
Example #17
0
        static void RunQuery(NorthwindEntities northwind, Application application)
        {
            // Issue OData queries to determine start and end times for orders.
            // So that the sources behave like temporal streams, we order by the
            // corresponding dates.
            var ordersWithRegions =
                from o in northwind.Orders
                where o.ShipRegion != null
                select o;

            var orderStartTimes =
                from o in ordersWithRegions
                where o.OrderDate != null
                orderby o.OrderDate
                select new { StartTime = (DateTime)o.OrderDate, o.OrderID, o.ShipRegion };

            var orderEndTimes =
                from o in ordersWithRegions
                where o.ShippedDate != null
                orderby o.ShippedDate
                select new { EndTime = (DateTime)o.ShippedDate, o.OrderID };

            // Map OData queries to StreamInsight inputs
            var startStream = orderStartTimes.ToPointStream(application, s =>
                                                            PointEvent.CreateInsert(s.StartTime, s), AdvanceTimeSettings.IncreasingStartTime);

            var endStream = orderEndTimes.ToPointStream(application, e =>
                                                        PointEvent.CreateInsert(e.EndTime, e), AdvanceTimeSettings.IncreasingStartTime);

            // Use clip to synthesize events lasting from the start of each order to the end
            // of each order.
            var clippedStream = startStream
                                .AlterEventDuration(e => TimeSpan.MaxValue)
                                .ClipEventDuration(endStream, (s, e) => s.OrderID == e.OrderID);

            // Count the number of coincident orders per region
            var counts = from o in clippedStream
                         group o by o.ShipRegion into g
                         from win in g.SnapshotWindow(SnapshotWindowOutputPolicy.Clip)
                         select new { ShipRegion = g.Key, Count = win.Count() };

            // Display output whenever there are more than 2 active orders in a region.
            const int threshold = 2;
            var       query     = from c in counts
                                  where c.Count > threshold
                                  select c;

            // Map the query to an IEnumerable sink
            var sink = from i in query.ToIntervalEnumerable()
                       where i.EventKind == EventKind.Insert
                       select new { i.StartTime, i.EndTime, i.Payload.Count, i.Payload.ShipRegion };

            foreach (var r in sink)
            {
                Console.WriteLine(r);
            }
        }
Example #18
0
 public static void ConsoleWritePointNoCTI <T>(PointEvent <T> e)
 {
     // Exclude EventKind.Cti
     if (e.EventKind == EventKind.Insert)
     {
         Console.WriteLine("INSERT <{0}> {1}",
                           e.StartTime.DateTime, e.Payload.ToString());
     }
 }
Example #19
0
 private void PrepareToStop(PointEvent <SensorData> currEvent)
 {
     //EnqueueCtiEvent(DateTime.Now);
     if (currEvent != null)
     {
         // Do this to avoid memory leaks
         ReleaseEvent(ref currEvent);
     }
 }
Example #20
0
        /// <summary>
        /// Example of utilising a user defined function for filtering
        /// </summary>
        /// <param name="ericUSDStream"></param>
        /// <param name="outputConfig"></param>
        /// <param name="adapterStopSignal"></param>
        private static void userFilterExample(IEnumerable <StockQuote> enumerable, Application application)
        {
            var cepStream = enumerable.ToPointStream(application, e => PointEvent <StockQuote> .CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);

            var filteredCepStream = from e in cepStream
                                    where UserDefinedFilter(e.FieldID)
                                    select e;

            runQuery(filteredCepStream);
        }
Example #21
0
 private void widget_PointX(object sender, PointEvent e)
 {
     this.UpDateData((System.Action)(() =>
     {
         foreach (object instance in this._propertyItem.InstanceList)
         {
             this._propertyItem.SetValue(this._propertyItem.Instance, (object)new ScaleValue((float)e.PointX, (instance as NodeObject).AnchorPoint.ScaleY, 0.1, -99999999.0, 99999999.0), (object[])null);
         }
     }));
 }
Example #22
0
        /// <summary>
        /// When the timer fires, check for the state of the adapter; if running
        /// raise a new simulated event
        /// </summary>
        /// <param name="state"></param>
        private void RaiseEvent(object state)
        {
            // Ensure that the adapter is in the running state.  If we're
            // shutting down, kill the timer and signal Stopped()
            if (AdapterState.Stopping == AdapterState)
            {
                myTimer.Dispose();
                Stopped();
            }
            if (AdapterState.Running != AdapterState)
            {
                return;
            }

            // Allocate a point event to hold the data for the incoming message.
            // If the event could not be allocated, exit the function
            lock (lockObj)
            {
                PointEvent <TPayload> currEvent = CreateInsertEvent();
                if (currEvent == null)
                {
                    return;
                }
                currEvent.StartTime = DateTime.Now;

                // Create a payload object, and fill with values if we have a
                // an initializer defined
                currEvent.Payload = (TPayload)Activator.CreateInstance(typeof(TPayload));
                if (init != null)
                {
                    init.FillValues(currEvent.Payload);
                }

                if (trace.ShouldLog(TraceEventType.Verbose))
                {
                    trace.LogMsg(TraceEventType.Verbose, "INSERT - {0}",
                                 currEvent.FormatEventForDisplay(false));
                }

                // If the event cannot be enqueued, release the memory and signal that
                // the adapter is ready to process more events (via. Ready())
                if (EnqueueOperationResult.Full == Enqueue(ref currEvent))
                {
                    ReleaseEvent(ref currEvent);
                    Ready();
                }
            }

            // The next event will be raised at now + event period ms, plus a
            // random offset
            int nextEventInterval = config.EventPeriod +
                                    rand.Next(config.EventPeriodRandomOffset);

            myTimer.Change(nextEventInterval, nextEventInterval);
        }
Example #23
0
 //use for sink creation if sink consists of PointEvents
 static void ConsoleWritePoint <TPayload>(PointEvent <TPayload> e)
 {
     if (e.EventKind == EventKind.Insert)
     {
         Console.WriteLine("INSERT <{0}> {1}", e.StartTime.ToLocalTime().ToString("MM/dd/yyyy HH:mm:ss.fff"), e.Payload.ToString());
     }
     else
     {
         Console.WriteLine("CTI    {0}", e.StartTime.ToLocalTime().ToString("MM/dd/yyyy HH:mm:ss.fff"));
     }
 }
Example #24
0
 // Format a line to write to the output: we'll write both CTIs and Inserts.
 private static string FormatOutputLine(PointEvent <XYPayload> evt)
 {
     if (evt.EventKind == EventKind.Insert)
     {
         return(string.Format("{0},{1}", evt.StartTime, evt.Payload));
     }
     else
     {
         return(evt.StartTime.ToString());
     }
 }
 private void widget_PointX(object sender, PointEvent e)
 {
     this.UpDateData(delegate
     {
         foreach (object current in this._propertyItem.InstanceList)
         {
             NodeObject nodeObject = current as NodeObject;
             this._propertyItem.SetValue(this._propertyItem.Instance, new ScaleValue((float)e.PointX, nodeObject.AnchorPoint.ScaleY, 0.1, -99999999.0, 99999999.0), null);
         }
     });
 }
Example #26
0
 static void ConsoleWritePoint <TPayload>(PointEvent <TPayload> e)
 {
     if (e.EventKind == EventKind.Insert)
     {
         Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "INSERT <{0}> {1}", e.StartTime.DateTime, e.Payload.ToString()));
     }
     else
     {
         Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "CTI    <{0}>", e.StartTime.DateTime));
     }
 }
Example #27
0
        private void On(PointEvent gameEvent)
        {
            if (!(CurrentState.State == MatchState.PlayingGame || CurrentState.State == MatchState.PlayingTiebreak))
            {
                throw new InvalidOperationException("Not Expected");
            }

            AddPointStats(gameEvent);

            AddPoint(gameEvent.PlayerPoint);
        }
Example #28
0
        /// <summary>
        /// Main worker thread function responsible for dequeueing events and
        /// posting them to the output stream.
        /// </summary>
        private void ConsumeEvents()
        {
            PointEvent currentEvent = default(PointEvent);

            try
            {
                while (true)
                {
                    if (AdapterState.Stopping == AdapterState)
                    {
                        Stopped();
                        return;
                    }

                    // Dequeue the event. If the dequeue fails, then the adapter state is suspended
                    // or stopping. Assume the former and call Ready() to indicate
                    // readiness to be resumed, and exit the thread.
                    if (DequeueOperationResult.Empty == Dequeue(out currentEvent))
                    {
                        Ready();
                        return;
                    }

                    string writeMsg = String.Empty;

                    if (currentEvent.EventKind == EventKind.Insert)
                    {
                        writeMsg = currentEvent.FormatEventForDisplay(eventType,
                                                                      !config.SingleLine);
                    }
                    else if (currentEvent.EventKind == EventKind.Cti)
                    {
                        writeMsg = String.Format("CTI - {0}",
                                                 currentEvent.StartTime.ToString("hh:mm:ss.fff"));
                    }

                    if (config.Target == TraceTarget.Console)
                    {
                        Console.WriteLine(writeMsg);
                    }
                    else if (config.Target == TraceTarget.Debug)
                    {
                        Debug.Write(writeMsg);
                    }

                    // Every received event needs to be released.
                    ReleaseEvent(ref currentEvent);
                }
            }
            catch (Exception e)
            {
                trace.LogException(e, "Error in console adapter dequeue");
            }
        }
Example #29
0
        /// <summary>
        /// Example of filter function
        /// </summary>
        /// <param name="cepStream"></param>
        /// <param name="outputConfig"></param>
        /// <param name="adapterStopSignal"></param>
        private static void filterExample(IEnumerable <StockQuote> enumerable, Application application)
        {
            // Convert enumerable to CEP Stream for using in the query
            var cepStream = enumerable.ToPointStream(application, e => PointEvent <StockQuote> .CreateInsert(new DateTimeOffset(e.TimeStamp, TimeSpan.Zero), e), AdvanceTimeSettings.IncreasingStartTime);

            // Return only "Close" values using a where-clause
            var filteredCepStream = from e in cepStream
                                    where e.FieldID == "Close"
                                    select e;

            runQuery(filteredCepStream);
        }
        /// <summary>
        /// Checks whether an AFA arc is triggered by a given incoming event and current register value.
        /// </summary>
        /// <param name="inputEvent">The input event.</param>
        /// <param name="fromState">The AFA from-state.</param>
        /// <param name="toState">The AFA to-state.</param>
        /// <param name="oldRegister">The old register value</param>
        /// <param name="newRegister">Output the new register value</param>
        /// <returns>Whether or not the transition was successful.</returns>
        internal bool TryApplyTransition(PointEvent <TInput> inputEvent, int fromState, int toState, TRegister oldRegister, out TRegister newRegister)
        {
            TransitionDelegate <TInput, TRegister> arc;

            if (this._transitionInfo.ContainsKey(fromState) && this._transitionInfo[fromState].TryGetValue(toState, out arc))
            {
                return(arc(inputEvent, oldRegister, out newRegister));
            }

            newRegister = default(TRegister);
            return(false);
        }
        /// <summary>
        /// Creates a string from a point event.
        /// </summary>
        /// <param name="evt">The point event to serialize.</param>
        /// <param name="eventType">CEP event type.</param>
        /// <param name="delimiter">Delimiter between event fields.</param>
        /// <returns>Serialized event.</returns>
        public static string CreateLineFromEvent(PointEvent evt, CepEventType eventType, char delimiter)
        {
            StringBuilder builder = new StringBuilder();

            if (EventKind.Cti == evt.EventKind)
            {
                builder
                    .Append("CTI")
                    .Append(delimiter)
                    .Append(evt.StartTime.ToString());
            }
            else
            {
                builder
                    .Append("INSERT")
                    .Append(delimiter)
                    .Append(evt.StartTime.ToString())
                    .Append(delimiter);

                SerializePayload(evt, eventType, delimiter, ref builder);
            }

            return builder.ToString();
        }
        /// <summary>
        /// Build a CSV line for output from the given event.
        /// </summary>
        /// <param name="evt">The event to output.</param>
        /// <returns>A string representing the CSV form of the event.</returns>
        private string BuildOutputLine(PointEvent evt)
        {
            StringBuilder line = new StringBuilder();
            line.Append(evt.StartTime);

            foreach (var i in this.fieldOrdinals)
            {
                line.Append(',');
                line.Append(evt.GetField(i));
            }

            return line.ToString();
        }
Example #33
0
 /**
  * Adds a tuple to the list.
  * @param tuple tuple
  * @param termList list of terms
  * @param termTuples list of tuples per term
  * @param keepTuples keeps tuples in a list
  * @param coocs list of coocs per term
  * @param keepCoocs keeps coocs in a list
  */
 public void addTuple( PointEvent<TwitterDataTerm> tuple,  ISet<String> termList,
        Dictionary<String, ISet<PointEvent<TwitterDataTerm>>> termTuples,  bool keepTuples,
        Dictionary<String, Dictionary<String, int>> coocs,  bool keepCoocs) {
    this.tuples.Add(tuple);
    this.addTerms(tuple, termList, termTuples, keepTuples, coocs, keepCoocs);
 }
        public string CreateString(PointEvent currEvent)
        {

            if (EventKind.Cti == currEvent.EventKind)
            {
                return currEvent.StartTime.ToString();
            }
            else
            {
                return currEvent.GetField(1).ToString();
            }

        }
 private void PrepareToStop(PointEvent currEvent, DequeueOperationResult result)
 {
     if (DequeueOperationResult.Success == result)
     {
         ReleaseEvent(ref currEvent);
     }
 }
Example #36
0
 /**
  * Adds all terms of tuple to list.
  * @param tuple tuple
  * @param termList list of terms
  * @param termTuples list of tuples per term
  * @param keepTuples keeps tuples in a list
  * @param coocs list of coocs per term
  * @param keepCoocs keeps coocs in a list
  */
 private void addTerms( PointEvent<TwitterDataTerm> tuple,  ISet<String> termList,
        Dictionary<String, ISet<PointEvent<TwitterDataTerm>>> termTuples,  bool keepTuples,
        Dictionary<String, Dictionary<String, int>> coocs,  bool keepCoocs) {
     List<String> content = this.removeDuplicates(tuple.Payload.TwitterData.TWEET_CONTENT); // WROOOOOOOOOONG FIND_ME
    foreach (String str in content) {
       if (this.termCounts.ContainsKey(str)) {
           int value = this.termCounts[str];
          this.termCounts[str] = value + 1;
       } else {
          this.termCounts[str] = 1;
          termList.Add(str);
       }
       if (keepTuples) {
          this.addTuples(tuple, str, termTuples);
       }
       if (keepCoocs) {
          this.addCoocs(content, str, coocs);
       }
    }
 }
Example #37
0
 /**
  * Adds tuples to term.
  * @param tuple tuple
  * @param str term
  * @param termTuples list of tuples per term
  */
 private void addTuples( PointEvent<TwitterDataTerm> tuple,  String str,  Dictionary<String, ISet<PointEvent<TwitterDataTerm>>> termTuples) {
    ISet<PointEvent<TwitterDataTerm>> tuples = termTuples.get(str);
    if (tuples == null) { tuples = new HashSet<PointEvent<TwitterDataTerm>>(); }
    tuples.add(tuple);
    termTuples.put(str, tuples);
 }