private void RunAssertionHowToUse(EPServiceProvider epService) { string eplFragment = "select Items.where(i => i.location.x = 0 and i.location.y = 0) as zeroloc from LocationReport"; EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); var listener = new SupportUpdateListener(); stmtFragment.Events += listener.Update; epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = listener.AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); stmtFragment.Dispose(); eplFragment = "select Items.Where(i => i.location.x = 0).where(i => i.location.y = 0) as zeroloc from LocationReport"; stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); stmtFragment.Events += listener.Update; epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); items = listener.AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); stmtFragment.Dispose(); }
/// <summary> /// Generate stn general report across all years. /// </summary> private void LocationsGeneralReport() { string description = $"Location General Report"; this.ProgressEvent?.Invoke($"Started {description}"); ReportCounterManager <LocationCounter> result = LocationReportFactory.RunStnGeneralReport(); this.locationGeneralReportResults.Invoke(result); this.ProgressEvent?.Invoke($"Completed {description}"); }
public void TestProperties() { String epl = "select items.where(p => distance(0, 0, p.Location.X, p.Location.Y) < 20) as centeritems " + "from LocationReport"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = _listener.AssertOneGetNewAndReset().Get("centeritems").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); }
public override void Run(EPServiceProvider epService) { /// <summary>Regular algorithm to find separated luggage and new owner.</summary> var theEvent = LocationReportFactory.MakeLarge(); var separatedLuggage = LocationReportFactory.FindSeparatedLuggage(theEvent); foreach (var item in separatedLuggage) { //Log.Info("Luggage that are separated (dist>20): " + item); var newOwner = LocationReportFactory.FindPotentialNewOwner(theEvent, item); //Log.Info("Found new owner " + newOwner); } var eplFragment = "" + "expression lostLuggage {" + " lr => lr.items.where(l => l.type='L' and " + " lr.items.anyof(p => p.type='P' and p.assetId=l.assetIdPassenger and LRUtil.Distance(l.location.x, l.location.y, p.location.x, p.location.y) > 20))" + "}" + "expression passengers {" + " lr => lr.items.where(l => l.type='P')" + "}" + "" + "expression nearestOwner {" + " lr => lostLuggage(lr).toMap(key => key.assetId, " + " value => passengers(lr).minBy(p => LRUtil.Distance(value.location.x, value.location.y, p.location.x, p.location.y)))" + "}" + "" + "select lostLuggage(lr) as val1, nearestOwner(lr) as val2 from LocationReport lr"; var stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); var listener = new SupportUpdateListener(); stmtFragment.Events += listener.Update; var bean = LocationReportFactory.MakeLarge(); epService.EPRuntime.SendEvent(bean); var val1 = listener.AssertOneGetNew().Get("val1").UnwrapIntoArray <Item>(); Assert.AreEqual(3, val1.Length); Assert.AreEqual("L00000", val1[0].AssetId); Assert.AreEqual("L00007", val1[1].AssetId); Assert.AreEqual("L00008", val1[2].AssetId); var val2 = listener.AssertOneGetNewAndReset().Get("val2").UnwrapDictionary(); Assert.AreEqual(3, val2.Count); Assert.AreEqual("P00008", ((Item)val2.Get("L00000")).AssetId); Assert.AreEqual("P00001", ((Item)val2.Get("L00007")).AssetId); Assert.AreEqual("P00001", ((Item)val2.Get("L00008")).AssetId); }
public void Run(RegressionEnvironment env) { string epl = "@Name('s0') select Items.where(p => distance(0, 0, p.Location.X, p.Location.Y) < 20) as centeritems " + "from LocationReport"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(LocationReportFactory.MakeSmall()); Item[] items = env.Listener("s0").AssertOneGetNewAndReset().Get("centeritems").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); env.UndeployAll(); }
public void TestMissingLuggage() { // Regular algorithm to find separated luggage and new owner. LocationReport theEvent = LocationReportFactory.MakeLarge(); IList <Item> separatedLuggage = LocationReportFactory.FindSeparatedLuggage(theEvent); foreach (Item item in separatedLuggage) { //log.info("Luggage that are separated (dist>20): " + item); Item newOwner = LocationReportFactory.FindPotentialNewOwner(theEvent, item); //log.info("Found new owner " + newOwner); } string eplFragment = "" + "expression lostLuggage {" + " lr => lr.items.where(l => l.type='L' and " + " lr.items.anyof(p => p.type='P' and p.assetId=l.assetIdPassenger and LRUtil.Distance(l.location.x, l.location.y, p.location.x, p.location.y) > 20))" + "}" + "expression passengers {" + " lr => lr.items.where(l => l.type='P')" + "}" + "" + "expression nearestOwner {" + " lr => lostLuggage(lr).toMap(key => key.assetId, " + " value => passengers(lr).minBy(p => LRUtil.Distance(value.location.x, value.location.y, p.location.x, p.location.y)))" + "}" + "" + "select lostLuggage(lr) as val1, nearestOwner(lr) as val2 from LocationReport lr"; EPStatement stmtFragment = epService.EPAdministrator.CreateEPL(eplFragment); stmtFragment.AddListener(listener); LocationReport bean = LocationReportFactory.MakeLarge(); epService.EPRuntime.SendEvent(bean); Item[] val1 = ItemArray(listener.AssertOneGetNew().Get("val1").Unwrap <Item>()); Assert.AreEqual(3, val1.Length); Assert.AreEqual("L00000", val1[0].AssetId); Assert.AreEqual("L00007", val1[1].AssetId); Assert.AreEqual("L00008", val1[2].AssetId); var val2 = (IDictionary <object, object>)listener.AssertOneGetNewAndReset().Get("val2"); Assert.AreEqual(3, val2.Count); Assert.AreEqual("P00008", ((Item)val2.Get("L00000")).AssetId); Assert.AreEqual("P00001", ((Item)val2.Get("L00007")).AssetId); Assert.AreEqual("P00001", ((Item)val2.Get("L00008")).AssetId); }
private void RunAssertionProperties(EPServiceProvider epService) { string epl = "select Items.where(p => Distance(0, 0, p.location.x, p.location.y) < 20) as centeritems " + "from LocationReport"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = listener.AssertOneGetNewAndReset().Get("centeritems").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); stmt.Dispose(); }
public void TestDeclared() { String epl = "expression passengers {\n" + " lr => lr.items.where(l => l.type='P')\n" + "}\n" + "select passengers(lr) as p," + "passengers(lr).where(x => assetId = 'P01') as p2 from LocationReport lr"; EPStatement stmt = _epService.EPAdministrator.CreateEPL(epl); stmt.Events += _listener.Update; _epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = _listener.AssertOneGetNewAndReset().Get("p").UnwrapIntoArray <Item>(); Assert.AreEqual(2, items.Length); Assert.AreEqual("P00002", items[0].AssetId); Assert.AreEqual("P00020", items[1].AssetId); }
/// <summary> /// Generate stn general report across all stn. /// </summary> private void SingleLocationGeneralReport() { string description = $"Location Report for {this.StnCollection[this.StnIndex]}"; this.ProgressEvent?.Invoke($"Started {description}"); ReportCounterManager <LocationCounter> results = LocationReportFactory.RunSingleStnGeneralReport( this.StnCollection[this.StnIndex], this.FullList); this.singleLocationGeneralReportResults.Invoke( results, this.StnCollection[this.StnIndex]); this.ProgressEvent?.Invoke($"Completed {description}"); }
/// <summary> /// Generate stn general report across all years. /// </summary> private void LocationsSingleYearReport() { string description = $"Location Report for {this.YearsCollection[this.YearsIndex]}"; this.ProgressEvent?.Invoke($"Started {description}"); ReportCounterManager <LocationCounter> results = LocationReportFactory.RunStnAnnualReport( this.YearsCollection[this.YearsIndex], this.FullList); this.locationYearReportResults.Invoke( results, this.YearsCollection[this.YearsIndex]); this.ProgressEvent?.Invoke($"Completed {description}"); }
public void Run(RegressionEnvironment env) { string epl = "@Name('s0') expression passengers {\n" + " lr => lr.Items.where(l => l.Type='P')\n" + "}\n" + "select passengers(lr) as p," + "passengers(lr).where(x => AssetId = 'P01') as p2 from LocationReport lr"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(LocationReportFactory.MakeSmall()); Item[] items = env.Listener("s0").AssertOneGetNewAndReset().Get("p").UnwrapIntoArray <Item>(); Assert.AreEqual(2, items.Length); Assert.AreEqual("P00002", items[0].AssetId); Assert.AreEqual("P00020", items[1].AssetId); env.UndeployAll(); }
private void RunAssertionDeclared(EPServiceProvider epService) { string epl = "expression passengers {\n" + " lr => lr.items.where(l => l.type='P')\n" + "}\n" + "select passengers(lr) as p," + "passengers(lr).where(x => assetId = 'P01') as p2 from LocationReport lr"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = listener.AssertOneGetNewAndReset().Get("p").UnwrapIntoArray <Item>(); Assert.AreEqual(2, items.Length); Assert.AreEqual("P00002", items[0].AssetId); Assert.AreEqual("P00020", items[1].AssetId); stmt.Dispose(); }
public void Run(RegressionEnvironment env) { // Regular algorithm to find separated luggage and new owner. var epl = "@Name('s0') " + "expression lostLuggage {" + " lr => lr.Items.where(l -> l.Type='L' and " + " lr.Items.anyof(p -> p.Type='P' and p.AssetId=l.AssetIdPassenger and LRUtil.Distance(l.Location.X, l.Location.Y, p.Location.X, p.Location.Y) > 20))" + "}" + "expression passengers {" + " lr => lr.Items.where(l -> l.Type='P')" + "}" + "" + "expression nearestOwner {" + " lr => lostLuggage(lr).toMap(key -> key.AssetId, " + " value => passengers(lr).minBy(p -> LRUtil.Distance(value.Location.X, value.Location.Y, p.Location.X, p.Location.Y)))" + "}" + "" + "select lostLuggage(lr) as val1, nearestOwner(lr) as val2 from LocationReport lr"; env.CompileDeploy(epl).AddListener("s0"); var bean = LocationReportFactory.MakeLarge(); env.SendEventBean(bean); var val1 = env.Listener("s0").AssertOneGetNew().Get("val1").UnwrapIntoArray<Item>(); Assert.AreEqual(3, val1.Length); Assert.AreEqual("L00000", val1[0].AssetId); Assert.AreEqual("L00007", val1[1].AssetId); Assert.AreEqual("L00008", val1[2].AssetId); var val2Event = env.Listener("s0").AssertOneGetNewAndReset(); var val2Result = val2Event.Get("val2"); var val2 = val2Result.AsObjectDictionary(); Assert.AreEqual(3, val2.Count); Assert.AreEqual("P00008", ((Item) val2.Get("L00000")).AssetId); Assert.AreEqual("P00001", ((Item) val2.Get("L00007")).AssetId); Assert.AreEqual("P00001", ((Item) val2.Get("L00008")).AssetId); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { string eplFragment = "@Name('s0') select Items.where(i => i.Location.X = 0 and i.Location.Y = 0) as zeroloc from LocationReport"; env.CompileDeploy(eplFragment).AddListener("s0"); env.SendEventBean(LocationReportFactory.MakeSmall()); Item[] items = env.Listener("s0").AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); env.UndeployAll(); eplFragment = "@Name('s0') select Items.where(i => i.Location.X = 0).where(i => i.Location.Y = 0) as zeroloc from LocationReport"; env.CompileDeploy(eplFragment).AddListener("s0"); env.SendEventBean(LocationReportFactory.MakeSmall()); items = env.Listener("s0").AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); env.UndeployAll(); }
public void TestHowToUse() { String eplFragment = "select items.where(i => i.Location.X = 0 and i.Location.Y = 0) as zeroloc from LocationReport"; EPStatement stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment); stmtFragment.Events += _listener.Update; _epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); Item[] items = _listener.AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); stmtFragment.Dispose(); eplFragment = "select items.where(i => i.Location.X = 0).where(i => i.Location.Y = 0) as zeroloc from LocationReport"; stmtFragment = _epService.EPAdministrator.CreateEPL(eplFragment); stmtFragment.Events += _listener.Update; _epService.EPRuntime.SendEvent(LocationReportFactory.MakeSmall()); items = _listener.AssertOneGetNewAndReset().Get("zeroloc").UnwrapIntoArray <Item>(); Assert.AreEqual(1, items.Length); Assert.AreEqual("P00020", items[0].AssetId); }