/// <summary> /// Reads the contents of the TollInput.txt data file to an IEnumerable source. /// </summary> /// <returns>Toll data.</returns> public static IEnumerable <IntervalEvent <TollReading> > CreateTollDataSource() { foreach (string line in File.ReadLines(@"Data\TollInput.txt")) { string[] fields = line.Split(','); yield return(IntervalEvent.CreateInsert( DateTime.Parse(fields[0], CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal), DateTime.Parse(fields[1], CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal), new TollReading { TollId = fields[2], LicensePlate = fields[3], State = fields[4], Make = fields[5], Model = fields[6], VehicleType = int.Parse(fields[7], CultureInfo.InvariantCulture), VehicleWeight = string.IsNullOrWhiteSpace(fields[8]) ? default(float) : float.Parse(fields[8], CultureInfo.InvariantCulture), Toll = float.Parse(fields[9], CultureInfo.InvariantCulture), Tag = fields[10], })); } }
public IntervalEvent <TPayloadType> GetIntervalEvent() { if (this.EventKind == EventKind.Insert) { return(IntervalEvent <TPayloadType> .CreateInsert(this.Start, this.End, Payload)); } return(IntervalEvent <TPayloadType> .CreateCti(Start)); }
protected override void PopulateEvent(out IntervalEvent <T> typedEvent) { typedEvent = IntervalEvent.CreateInsert(DateTime.Now, DateTime.Now + TimeSpan.FromMilliseconds( Math.Max( EventInterval - (this.Rnd.Next(EventIntervalDiff * 2) - EventIntervalDiff), 1)), new T()); }
/// <summary> /// Defines a stream of TollReadings used throughout examples. A simulated data array /// is wrapped into the Enumerable source which is then converted to a stream. /// </summary> /// <param name="app">StreamInsight application object.</param> /// <returns>Returns stream of simulated TollReadings used in examples.</returns> static IQStreamable <TollReading> GetTollReadings(this Application app) { return(app.DefineEnumerable(() => // Simulated readings data defined as an array. // IntervalEvent objects are constructed directly to avoid copying. new[] { IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 01, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 03, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "JNB 7001", State = "NY", Make = "Honda", Model = "CRV", VehicleType = 1, VehicleWeight = 0, Toll = 7.0f, Tag = "" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 02, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 03, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "YXZ 1001", State = "NY", Make = "Toyota", Model = "Camry", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "123456789" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 02, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 04, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "ABC 1004", State = "CT", Make = "Ford", Model = "Taurus", VehicleType = 1, VehicleWeight = 0, Toll = 5.0f, Tag = "456789123" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 03, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 07, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "XYZ 1003", State = "CT", Make = "Toyota", Model = "Corolla", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 03, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 08, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "BNJ 1007", State = "NY", Make = "Honda", Model = "CRV", VehicleType = 1, VehicleWeight = 0, Toll = 5.0f, Tag = "789123456" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 05, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 07, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "CDE 1007", State = "NJ", Make = "Toyota", Model = "4x4", VehicleType = 1, VehicleWeight = 0, Toll = 6.0f, Tag = "321987654" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 06, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 09, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "BAC 1005", State = "NY", Make = "Toyota", Model = "Camry", VehicleType = 1, VehicleWeight = 0, Toll = 5.5f, Tag = "567891234" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 07, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "ZYX 1002", State = "NY", Make = "Honda", Model = "Accord", VehicleType = 1, VehicleWeight = 0, Toll = 6.0f, Tag = "234567891" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 07, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "ZXY 1001", State = "PA", Make = "Toyota", Model = "Camry", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "987654321" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 08, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "CBA 1008", State = "PA", Make = "Ford", Model = "Mustang", VehicleType = 1, VehicleWeight = 0, Toll = 4.5f, Tag = "891234567" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 09, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 11, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "DCB 1004", State = "NY", Make = "Volvo", Model = "S80", VehicleType = 1, VehicleWeight = 0, Toll = 5.5f, Tag = "654321987" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 09, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 16, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "CDB 1003", State = "PA", Make = "Volvo", Model = "C30", VehicleType = 1, VehicleWeight = 0, Toll = 5.0f, Tag = "765432198" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 09, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "YZX 1009", State = "NY", Make = "Volvo", Model = "V70", VehicleType = 1, VehicleWeight = 0, Toll = 4.5f, Tag = "912345678" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 12, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "BCD 1002", State = "NY", Make = "Toyota", Model = "Rav4", VehicleType = 1, VehicleWeight = 0, Toll = 5.5f, Tag = "876543219" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 10, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 14, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "CBD 1005", State = "NY", Make = "Toyota", Model = "Camry", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "543219876" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 11, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 13, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "NJB 1006", State = "CT", Make = "Ford", Model = "Focus", VehicleType = 1, VehicleWeight = 0, Toll = 4.5f, Tag = "678912345" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 12, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 15, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "PAC 1209", State = "NJ", Make = "Chevy", Model = "Malibu", VehicleType = 1, VehicleWeight = 0, Toll = 6.0f, Tag = "219876543" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 15, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 22, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "BAC 1005", State = "PA", Make = "Peterbilt", Model = "389", VehicleType = 2, VehicleWeight = 2.675f, Toll = 15.5f, Tag = "567891234" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 15, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 18, 0, DateTimeKind.Utc), new TollReading { TollId = "3", LicensePlate = "EDC 3109", State = "NJ", Make = "Ford", Model = "Focus", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "198765432" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 18, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 20, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "DEC 1008", State = "NY", Make = "Toyota", Model = "Corolla", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 20, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 22, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "DBC 1006", State = "NY", Make = "Honda", Model = "Civic", VehicleType = 1, VehicleWeight = 0, Toll = 5.0f, Tag = "432198765" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 20, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 23, 0, DateTimeKind.Utc), new TollReading { TollId = "2", LicensePlate = "APC 2019", State = "NJ", Make = "Honda", Model = "Civic", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "345678912" }), IntervalEvent.CreateInsert(new DateTime(2009, 06, 25, 12, 22, 0, DateTimeKind.Utc), new DateTime(2009, 06, 25, 12, 25, 0, DateTimeKind.Utc), new TollReading { TollId = "1", LicensePlate = "EDC 1019", State = "NJ", Make = "Honda", Model = "Accord", VehicleType = 1, VehicleWeight = 0, Toll = 4.0f, Tag = "" }), }) // Predefined AdvanceTimeSettings.IncreasingStartTime is used to insert CTIs after each event, which occurs later than the previous one. .ToIntervalStreamable(e => e, AdvanceTimeSettings.IncreasingStartTime)); }