private void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e) { var reference = e.FrameReference.AcquireFrame(); // Color using (var frame = reference.ColorFrameReference.AcquireFrame()) { if (frame != null) { if (monitor != null) { monitor.viewer.Image = frame.ToBitmap(); } } } using (var frame = reference.BodyFrameReference.AcquireFrame()) { if (frame != null) { var bodies = frame.Bodies(); _playersController?.Update(bodies); foreach (Body body in bodies) { monitor?.viewer.DrawBody(body); } var currentBody = bodies.FirstOrDefault(y => y.IsTracked); if (currentBody != null) { { foreach (KeyValuePair <JointType, Joint> joint in currentBody.Joints) { SensorDetails sensorDetails = sensors.First(t => t.SensorName == joint.Key.ToString()); SensorReadingPackage package = readings.FirstOrDefault(x => x.Id == sensorDetails.Id); if (package == null) { package = new SensorReadingPackage { Id = sensorDetails.Id, }; readings.Add(package); } package.Position = new PositionalReading() { X = joint.Value.Position.X, Y = joint.Value.Position.Y, Z = joint.Value.Position.Z }; } } } } } }
private Point GetPoint(List <SensorReadingPackage> readings, List <SensorDetails> sensors, JointType jointType) { SensorDetails sd = sensors.First(p => p.SensorName == jointType.ToString()); SensorReadingPackage temp = readings.First(x => x.Id == sd.Id); return(new Point(temp.Position.X, temp.Position.Y)); }
public List <DataPoint> GetLastValues(string stationId) { using (var context = new WeatherStationDbContext(_nameOrConnectionString)) { return(SensorDetails .GetSensorTypeValues() .Select(sensorType => TryGetLatestDataPointForStationIdAndSensorType(context, stationId, sensorType)) .Where(dp => dp != null) .ToList()); } }
private List <string> CreateChartHtmlList(string stationId, DateTimeRange dateTimeRange) { if (stationId == null) { return(new List <string>()); } return(SensorDetails .GetSensorTypeValues() .Select(sensorType => GetChartHtmlForStationSensor(stationId, _repository, sensorType, dateTimeRange)) .Where(x => x != null) .ToList()); }
public JsonResult <StationDataPoints> GetStationDataPoints(string stationId, int lastHours = 24) { var dateTimeRange = StationController.CreateDateTimeRange(lastHours.ToString()); var sensorValuesList = SensorDetails.GetSensorTypeValues() .SelectMany(type => _repository.GetDataPoints(stationId, type, dateTimeRange)) .GroupBy(dp => dp.SensorType) .Select(ToSensorValues) .ToList() ; return(ToJson(new StationDataPoints { StationId = stationId, SensorValues = sensorValuesList })); }
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e) { Skeleton[] skeletons = new Skeleton[0]; using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) { if (skeletonFrame != null) { skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength]; skeletonFrame.CopySkeletonDataTo(skeletons); } } var temp = skeletons.FirstOrDefault(x => x.TrackingState == SkeletonTrackingState.Tracked); if (temp != null) { foreach (Joint joint in temp.Joints) { SensorDetails sensorDetails = sensors.First(t => t.SensorName == joint.JointType.ToString()); SensorReadingPackage package = readings.FirstOrDefault(x => x.Id == sensorDetails.Id); if (package == null) { package = new SensorReadingPackage { Id = sensorDetails.Id, }; readings.Add(package); } package.Position = new PositionalReading() { X = joint.Position.X, Y = joint.Position.Y, Z = joint.Position.Z }; } kinectMonitor?.DoSimpleDraw(readings, sensors); } }