public void ControllerInvokesEventEmitterAndReturnsCreated()
        {
            CommandEventConverter converter         = new CommandEventConverter();
            FakeEventEmitter      emitter           = new FakeEventEmitter();
            FakeTeamServiceClient teamServiceClient = new FakeTeamServiceClient();

            LocationReportsController controller = new LocationReportsController(converter, emitter, teamServiceClient);

            LocationReport report = new LocationReport
            {
                Latitude  = 10.0,
                Longitude = 10.0,
                Origin    = "TESTS",
                MemberID  = Guid.NewGuid(),
                ReportID  = Guid.NewGuid()
            };

            var result = controller.PostLocationReport(report.MemberID, report);

            Assert.True(emitter.MemberLocationRecordedEvents.Count == 1);
            Assert.Equal(emitter.MemberLocationRecordedEvents[0].Latitude, report.Latitude);
            Assert.Equal(emitter.MemberLocationRecordedEvents[0].Longitude, report.Longitude);
            Assert.Equal(emitter.MemberLocationRecordedEvents[0].Origin, report.Origin);
            Assert.Equal(emitter.MemberLocationRecordedEvents[0].MemberID, report.MemberID);
            Assert.Equal(emitter.MemberLocationRecordedEvents[0].ReportID, report.ReportID);

            Assert.Equal(emitter.MemberLocationRecordedEvents[0].TeamID, teamServiceClient.FixedID);

            Assert.Equal(201, (result as ObjectResult).StatusCode.Value);
        }
예제 #2
0
        public Program()
        {
            try
            {
                reader.Connect(SolutionConstants.ReaderHostname);

                Console.WriteLine("WAM with Location: " + SolutionConstants.ReaderHostname);

                for (int i = 0; i < INTERATIONS; i++)
                {
                    // WAM Role
                    Console.WriteLine("Running WAM. Please wait " + WAM_ROLE_DURATION / 1000 + " Sec." + " Session=" + WAM_SESSION + " Target=" + WAM_SEARCH_MODE);
                    SetupWamMode();
                    System.Threading.Thread.Sleep(WAM_ROLE_DURATION);
                    ShutdownWamMode();
                    Console.WriteLine("WAM Results:  TagsRead=" + WamTags.Count);
                    foreach (var item in WamTags)
                    {
                        Tag tag = item.Value;
                        Console.WriteLine(item.Key + "  Ant=" + tag.AntennaPortNumber + "\tRSSI=" + tag.PeakRssiInDbm);
                    }
                    Console.WriteLine();
                    WamTags.Clear();

                    // Location Role
                    Console.WriteLine("Running Location. Please wait " + LOCATION_ROLE_DURATION / 1000 + " sec.");
                    SetupLocationMode();
                    System.Threading.Thread.Sleep(LOCATION_ROLE_DURATION);
                    ShutdownLocationMode();
                    Console.WriteLine("Location Results: " + LocTags.Count + " Tags Read");
                    foreach (var item in LocTags)
                    {
                        LocationReport tag = item.Value;
                        Console.WriteLine(item.Key + "\tReadCount=" + tag.ConfidenceFactors.ReadCount + "\tX=" + tag.LocationXCm + "\tY=" + tag.LocationYCm);
                    }
                    LocTags.Clear();
                    Console.WriteLine();
                    // Wait for tag percistance to complete before starting WAM again
                    if ((i < INTERATIONS - 1) && (WAM_SESSION == 2 || WAM_SESSION == 3))
                    {
                        Console.WriteLine("Wait " + SESSION_2_OR_3_PERSISTENCE / 1000 + " Sec. for tag percistance to complete before starting WAM again");
                        System.Threading.Thread.Sleep(SESSION_2_OR_3_PERSISTENCE);
                    }
                }
                // Apply the default settings before exiting.
                reader.ApplyDefaultSettings();
                // Disconnect from the reader.
                reader.Disconnect();
            }
            catch (OctaneSdkException e)
            {
                // Handle Octane SDK errors.
                Console.WriteLine("Octane SDK exception: {0}", e.Message);
            }
            catch (Exception e)
            {
                // Handle other .NET errors.
                Console.WriteLine("Exception : {0}", e.Message);
            }
        }
예제 #3
0
        // This event handler will be called when a location report is ready.
        void OnLocationReported(ImpinjReader reader, LocationReport report)
        {
            string EpcStr = report.Epc.ToHexString();

            // Compute confidence. Make sure that the first cycle report came in before computing the Weighted averages.
            if (!CycleLengths.ContainsKey(reader.Address) || CycleLengths[reader.Address] == 0)
            {
                return;
            }

            // If first time
            if (!TagReadInfo.ContainsKey(EpcStr))
            {
                TagReadInfo.Add(EpcStr, new TagReadInfo());
            }

            double Mult = Math.Floor((double)COMPUTE_WINDOW_SEC * 1000000 / CycleLengths[reader.Address]);

            if (Mult == 0)
            {
                Mult = 1;
            }
            double Confidence = report.ConfidenceFactors.ReadCount / Mult;

            Console.WriteLine(reader.Address + "  " + EpcStr + " x=" + report.LocationXCm + " y=" + report.LocationYCm + " conf=" + Confidence);
            // Weighted X
            double WgtX = Confidence * report.LocationXCm;

            TagReadInfo[EpcStr].WeightedX += WgtX;

            // Weighted Y
            double WgtY = Confidence * report.LocationYCm;

            TagReadInfo[EpcStr].WeightedY += WgtY;

            // TagReadCounts
            TagReadInfo[EpcStr].Confidence += Confidence;

            // Pick a reader to key off the Averaging calculation
            // Let's use the last one.
            if (reader.Address.Equals(xArrays[xArrays.Length - 1].Hostname))
            {
                Console.Write("Weighted: " + EpcStr);
                if (TagReadInfo[EpcStr].Confidence != 0)
                {
                    Console.Write(" x=" + Math.Floor(TagReadInfo[EpcStr].WeightedX / TagReadInfo[EpcStr].Confidence));
                    Console.WriteLine(" y=" + Math.Floor(TagReadInfo[EpcStr].WeightedY / TagReadInfo[EpcStr].Confidence));
                }
                else
                {
                    Console.WriteLine("Invalid Read. Confidence is 0");
                }
                // Reinitialize variables
                TagReadInfo[EpcStr].WeightedX  = 0;
                TagReadInfo[EpcStr].WeightedY  = 0;
                TagReadInfo[EpcStr].Confidence = 0;
            }
        }
예제 #4
0
        public ActionResult PostLocationReport(Guid memberId, [FromBody] LocationReport locationReport)
        {
            MemberLocationRecordedEvent locationRecordedEvent = converter.CommandToEvent(locationReport);

            locationRecordedEvent.TeamID = teamServiceClient.GetTeamForMember(locationReport.MemberID);
            eventEmitter.EmitLocationRecordedEvent(locationRecordedEvent);

            return(this.Created($"/api/members/{memberId}/locationreports/{locationReport.ReportID}", locationReport));
        }
        public async Task <IActionResult> Post(Guid memberId, [FromBody] LocationReport locationReport)
        {
            var locationRecordedEvent = _commandEventConverter.CommandToEvent(locationReport);

            locationRecordedEvent.TeamId = await _teamServiceClient.GetTeamForMemberAsync(locationReport.MemberId);

            _eventEmitter.EmitLocationRecordedEvent(locationRecordedEvent);

            return(this.Created($"/api/members/{memberId}/locationreposts/{locationReport.Id}", locationReport));
        }
예제 #6
0
 // This event handler will be called when a location report is ready.
 static void OnLocationReported(ImpinjReader reader, LocationReport report)
 {
     // Print out the report details
     Console.WriteLine("Location report");
     Console.WriteLine("   Type = {0}", report.ReportType);
     Console.WriteLine("   EPC = {0}", report.Epc);
     Console.WriteLine("   X = {0} cm", report.LocationXCm);
     Console.WriteLine("   Y = {0} cm", report.LocationYCm);
     Console.WriteLine("   Timestamp = {0} ({1})", report.Timestamp, report.Timestamp.LocalDateTime);
     Console.WriteLine("   Read count = {0}", report.ConfidenceFactors.ReadCount);
 }
예제 #7
0
        private void OnLocationReported(ImpinjReader reader, LocationReport report)
        {
            List <LocationReport> list = new List <LocationReport>();

            list.Add(report);
            Action action = delegate()
            {
                UpdateListBox(list);
            };

            Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
        }
        public IActionResult LocationReport(string earTag)
        {
            var locations = _storage.LocationRead(earTag);
            var cow       = _storage.ReadCow(earTag);

            var dto = new LocationReport
            {
                Name      = cow.Name,
                Locations = locations
            };

            return(Ok(dto));
        }
예제 #9
0
        // Location Reports
        void OnLocationReported(ImpinjReader reader, LocationReport report)
        {
            string EpcStr = report.Epc.ToHexString();

            // Collect tags read from the last location report
            if (LocTags.ContainsKey(EpcStr))
            {
                LocTags.Remove(EpcStr);
            }
            LocTags.Add(EpcStr, report);
            // Comment out next line to see L every time a tag is reported
            // Console.Write("L");
        }
예제 #10
0
        public IActionResult LocationReport(string earTag)
        {
            var cowName  = _masterDataService.GetCowName(earTag);   //Her brewak point-> husk
            var location = _storage.LocationRead(earTag);

            var dto = new LocationReport
            {
                Name      = cowName,
                Latitude  = location.Latitude,
                Longitude = location.Longitude
            };

            return(Ok(dto));
        }
예제 #11
0
        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);
        }
예제 #12
0
        public void AugmentsCommandWithTimestamp()
        {
            long           startTime = DateTime.Now.ToUniversalTime().Ticks;
            LocationReport command   = new LocationReport {
                Latitude  = 10.0,
                Longitude = 30.0,
                Origin    = "TESTS",
                MemberID  = Guid.NewGuid()
            };
            CommandEventConverter       converter     = new CommandEventConverter();
            MemberLocationRecordedEvent recordedEvent = converter.CommandToEvent(command);

            Assert.Equal(command.Latitude, recordedEvent.Latitude);
            Assert.Equal(command.Longitude, recordedEvent.Longitude);
            Assert.Equal(command.Origin, recordedEvent.Origin);
            Assert.True(recordedEvent.RecordedTime >= startTime);
        }
        public async Task RetrieveLocationReportListAsyncTest()
        {
            var locationReportSearchParameters = new LocationReportSearchParameters
            {
                BoardingStatus = "1",
                ClearanceStatus = "1",
                AgeFrom = "21",
                FirstName = "trott",
                LastName = "ryan",
                MovementActivityEndDate = "2015-07-10 12:12:12:120",
                MovementActivityStartDate = "2015-07-10 12:12:12:120",
                AgeTo = "42",
                DepartmentIds = "23",
                GangwayLocation = "DK1 AFT Por",
                PersonTypeId = "23",
                Gender = "M",
                VoyageId = "3",
                MaxResults = 50,
                OrderBy = "DepartmentIds",
                PageNumber = 2,
                Parts = "$all",
            };

            var locationReports = new LocationReport { Age = "48", Birthdate = DateTime.Now, BookingNo = "33333444", Contact = "67676788", Nationality = "Indian", PersonId = "4", FirstName = "Ryan", Gender = "M", LastName = "Trott", MiddleName = "henry", Stateroom = "3" };

            locationReports.IdentificationManifests.Add(new IdentificationManifest { CrewmemberId = "1", DocumentType = "2", GuestId = "2", Number = "22", PersonId = "1", PersonTypeId = "1", VisitorId = "1" });

            locationReports.MovementManifests.Add(new MovementManifest { VisitorId = "1", PersonTypeId = "1", PersonId = "2", GuestId = "2", CrewmemberId = "1", EventDate = DateTime.Now, Location = "MIAMI", Port = "aghj" });
            this.locationReport.Items.Add(locationReports);

            this.locationReportRepository.Setup(mockItem => mockItem.ListLocationReportAsync(It.IsNotNull<LocationReportSearchParameters>())).Returns(Task.FromResult(this.locationReport));
            var alert = await this.locationReportData.ListAsync(locationReportSearchParameters);
            var searchQueryString = locationReportSearchParameters.ToQueryString();
            Assert.IsNotNull(alert);
            Assert.IsTrue(searchQueryString.Contains("DepartmentIds"));
            Assert.IsNotNull(alert);
        }
예제 #14
0
 public void SendLocation(LocationReport rep)
 {
     rep.Timestamp = DateTime.Now;
     rep.ID        = Context.ConnectionId;
     Clients.locationUpdate(rep);
 }