public async Task <IEnumerable <JwtToken> > GetActiveByDeviceAsync(TrackingDevice device) { var tokens = await this.FindBy(t => t.TrackingDevice.Id == device.Id && t.IsActive) .ToListAsync(); return(tokens.Select(t => this.ObjectMapper.Map <JwtToken>(t))); }
public void UpdatePluggedInDevice() { using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_USBControllerDevice")) { ManagementObjectCollection devices = searcher.Get(); foreach (ManagementBaseObject device in devices) { try { string dependent = (string)device.GetPropertyValue("Dependent"); string devId = dependent.Substring(dependent.IndexOf("DeviceID=\"")); if (devId.Contains("02B0") || devId.Contains("02BB") || devId.Contains("02AE")) { pluggedInDevice = TrackingDevice.Xbox360Kinect; } if (devId.Contains("02C4")) { pluggedInDevice = TrackingDevice.XboxOneKinect; } } catch (ManagementException) { } } devices.Dispose(); } }
public async Task <string> GetLongLivedDeviceToken(TrackingDevice device, bool regenerateToken) { // Get stored token if available if (!regenerateToken) { var jwtTokens = await this.repository.GetActiveByDeviceAsync(device); if (jwtTokens.Any()) { return(this.TokenFromClaims(jwtTokens.First().Claims)); } } var jwtToken = new JwtToken { TrackingDeviceId = device.Id, IsActive = true }; var claims = new Claim[] { new Claim(ClaimTypes.Name, device.Name), new Claim(JwtRegisteredClaimNames.Sub, device.Id), new Claim(JwtRegisteredClaimNames.Jti, jwtToken.Id.ToString()), new Claim(JwtRegisteredClaimNames.Iss, JwtAuthConstants.Issuer), new Claim(JwtRegisteredClaimNames.Aud, JwtAuthConstants.DeviceAudience), new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddYears(10)).ToUnixTimeSeconds()}"), new Claim(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}") }; jwtToken.Claims = claims; await this.repository.DisableTokensByDeviceAsync(device); await this.repository.AddAsync(jwtToken); return(this.TokenFromClaims(jwtToken.Claims)); }
public SensorBone(TrackingDevice tracker, uint actorId, Side side, SideBone sideBoneId) { this.tracker = tracker; this.actorId = actorId; this.boneId = Bone.None; this.side = side; this.sideBoneId = sideBoneId; }
public async Task <IActionResult> Post([FromBody] TrackingDevice device, [FromQuery] string nonce = null) { TrackingDevice response = await this.deviceService.AddOrUpdateDeviceAsync(device); await this.deviceAdditionHubContext.Clients.All.InvokeAsync("DeviceAdded", nonce); return(Json(await this.tokenService.GetLongLivedDeviceToken(response, false))); }
public SensorBone(TrackingDevice tracker, uint actorId, Bone boneId) { this.tracker = tracker; this.actorId = actorId; this.side = Side.AnySide; this.boneId = boneId; this.sideBoneId = SideBone.None; }
private void Button_Install_Click(object sender, RoutedEventArgs e) { if (this.ListBox_devices.SelectedItem == null) { MessageBox.Show("No device selected!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrWhiteSpace(TextBox_installLocation.Text)) { MessageBox.Show("No install location selected!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string installLocation; try { installLocation = Path.GetFullPath(Environment.ExpandEnvironmentVariables(TextBox_installLocation.Text)); } catch (Exception) { MessageBox.Show("Invalid install location!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (installLocation != @"C:\K2EX" && // Ignore legacy installations Directory.Exists(installLocation) && // Folder exists !Utils.IsDirectoryEmpty(installLocation) && // Foler isn't empty !File.Exists(Path.Combine(installLocation, "installerSettings.xml"))) // Folder isn't installed by this installer { MessageBox.Show("The directory you want to install KinectToVR to must be empty!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } TrackingDevice device = TrackingDevice.None; switch (((Device)this.ListBox_devices.SelectedItem).Name) { case "kinect_v2": device = TrackingDevice.XboxOneKinect; break; case "kinect_v1": device = TrackingDevice.Xbox360Kinect; break; case "psmove": device = TrackingDevice.PlayStationMove; break; } App.state.trackingDevice = device; App.state.allowAnalytics = CheckBox_analytics.IsChecked == true; App.state.installationPath = installLocation; ((MainWindow)Application.Current.MainWindow).GoToTab(2); }
public async Task DisableTokensByDeviceAsync(TrackingDevice device) { var activeTokens = await this.FindBy(t => t.TrackingDevice.Id == device.Id && t.IsActive) .ToListAsync(); foreach (var token in activeTokens) { token.IsActive = false; } await this.Db.SaveChangesAsync(); }
public Analytics() { trackingDevice = App.state.trackingDevice; installerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); windowsReleaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString(); windowsBuild = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild", "").ToString(); language = CultureInfo.CurrentUICulture.Name; try { var steamVrSettings = JsonConvert.DeserializeObject <dynamic>(File.ReadAllText(App.state.steamVrSettingsPath)); headsetManufacturer = steamVrSettings["LastKnown"]["HMDManufacturer"]; headsetModel = steamVrSettings["LastKnown"]["HMDModel"]; } catch (Exception) { } }
private void Button_Install_Click(object sender, RoutedEventArgs e) { if (this.ListBox_devices.SelectedItem == null) { MessageBox.Show("No device selected!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrWhiteSpace(TextBox_installLocation.Text)) { MessageBox.Show("No install location selected!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string installLocation; try { installLocation = Path.GetFullPath(Environment.ExpandEnvironmentVariables(TextBox_installLocation.Text)); } catch (Exception) { MessageBox.Show("Invalid install location!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } TrackingDevice device = TrackingDevice.None; switch (((Device)this.ListBox_devices.SelectedItem).Name) { case "kinect_v2": device = TrackingDevice.XboxOneKinect; break; case "kinect_v1": device = TrackingDevice.Xbox360Kinect; break; case "psmove": device = TrackingDevice.PlayStationMove; break; } App.state.trackingDevice = device; App.state.allowAnalytics = CheckBox_analytics.IsChecked == true; App.state.installationPath = installLocation; ((MainWindow)Application.Current.MainWindow).GoToTab(2); }
public void UpdatePluggedInDevice() { try { using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_USBControllerDevice")) { ManagementObjectCollection devices = searcher.Get(); foreach (ManagementBaseObject device in devices) { string dependent = (string)device.GetPropertyValue("Dependent"); string devId = dependent.Substring(dependent.IndexOf("DeviceID=\"")); if ( devId.Contains("02B0") || // kinect 360 main devId.Contains("02BB") || // kinect 360 audio devId.Contains("02AE") || // kinect 360 camera devId.Contains("02C2") || // kinect v1 main devId.Contains("02BE") || // kinect v1 audio devId.Contains("02BF") || // kinect v1 camera devId.Contains("02C3")) // kinect v1 security { pluggedInDevice = TrackingDevice.Xbox360Kinect; } if (devId.Contains("02C4") || // kinect one main devId.Contains("02D8") || // kinect v2 main devId.Contains("02D9")) // kinect v2 hub { pluggedInDevice = TrackingDevice.XboxOneKinect; } } devices.Dispose(); } } catch (Exception e) { Logger.Log($"Failed to detect a Kinect! Continuing anyway..."); } }
public TrackerTransform(TrackingDevice tracker) { this.tracker = tracker; }
static void Main(string[] args) { TrackingDevice trackingDevice = new TrackingDevice(); Console.WriteLine("Initialize Tracking Device..."); trackingDevice.Initialize("C:\\default.g4c"); if (!trackingDevice.Connect()) { Console.WriteLine("Initialize Tracking Device...failed"); Console.ReadKey(); return; } Thread.Sleep(2000); var sensorCount = trackingDevice.GetActiveSensorCount(); var hubIDs = trackingDevice.GetActiveHubs(); if (hubIDs.Length > 0) { var sensorMap = trackingDevice.GetHubSensorMap(hubIDs[0]); } hubIDs.ToList().ForEach(hub => Console.WriteLine("active hub: " + hub)); Console.WriteLine("G4 Device Information:"); Console.WriteLine(trackingDevice.GetTrackerInformation()); int count = 100; while (count-- > 0) { var frames = trackingDevice.ReadSinglePNOFrame(); foreach (var frame in frames) { Console.WriteLine( $"[{frame.frameNumber} {frame.hubID} {frame.sensorID} | Position: {frame.x} {frame.y} {frame.z} | Rotation: {frame.r1} {frame.r2} {frame.r3}]"); } Thread.Sleep(25); } //Tip Offset trackingDevice.SetTipOffset(0, 1, 0, 0, 10); var message = trackingDevice.GetLastResultString(); Console.WriteLine(message); count = 100; while (count-- > 0) { var frames = trackingDevice.ReadSinglePNOFrame(); foreach (var frame in frames) { Console.WriteLine( $"[{frame.frameNumber} {frame.hubID} {frame.sensorID} | Position: {frame.x} {frame.y} {frame.z} | Rotation: {frame.r1} {frame.r2} {frame.r3}]"); } Thread.Sleep(25); } trackingDevice.Disconnect(); Console.ReadKey(); }
/// <returns>'True' if any information was sent, 'false' otherwise.</returns> private bool _DeployRoutes( IEnumerable <TrackingDevice> devices, IEnumerable <Route> routes, DateTime plannedDate) { Debug.Assert(devices != null); Debug.Assert(routes != null); plannedDate = plannedDate.Date; var newStops = new List <DM.Stop>(); var updatedStops = new List <DM.Stop>(); var deployedRoutes = new List <Route>(); var deployedStops = new List <Stop>(); // Get all non deleted stops for current routes for planned date. var existingStops = _trackingService.GetNotDeletedStops(devices.Select(x => x.ServerId), plannedDate); foreach (var route in routes) { // check if route has associated device MobileDevice device = TrackingHelper.GetDeviceByRoute(route); if (device == null) { continue; } // check if device belongs to devices with tracking id TrackingDevice td = _FindDevice(devices, device); if (td == null) { continue; } // Get all stops for current route. var currentDateStops = existingStops.Where(stop => stop.DeviceID == td.ServerId); // Get id's of non deleted stops. var stopsToDelete = currentDateStops. Where(stop => stop.Deleted == DM.DeletionStatus.NotDeleted). ToDictionary(stop => stop.ObjectID); // Get version number for sended stops. var version = _GetNewVersion(currentDateStops); // Prepare stops to be deployed. var sortedStops = CommonHelpers.GetSortedStops(route); var trackingStops = _CreateTrackingStops( td.ServerId, version, plannedDate, sortedStops); trackingStops = trackingStops.ToList(); // Add stop to either new stops or updated stops collection. foreach (var item in trackingStops.ToIndexed()) { var trackingStop = item.Value; var existingStop = stopsToDelete.Remove(trackingStop.ObjectID); var stopsToDeploy = existingStop ? updatedStops : newStops; stopsToDeploy.Add(trackingStop); if (!existingStop) { deployedStops.Add(sortedStops[item.Index]); } } // Deletes from tracking service stops which were deleted locally. // When stop is moved to other route we treat it as a deletion from an old route // and adding to the new one. foreach (var stopToDelete in stopsToDelete.Values) { stopToDelete.Deleted = DM.DeletionStatus.Deleted; updatedStops.Add(stopToDelete); } // We need a list of both new and updated stops in order to apply common properties // like arrival delays. var allStops = new List <DM.Stop>(trackingStops); TrackingHelper.ApplyArrivalDelayToStops( _solver.SolverSettings.ArriveDepartDelay, allStops); deployedRoutes.Add(route); } // We must sent route settings, barriers only if we have stops to update. if (newStops.Count > 0 || updatedStops.Count > 0) { // Update route settings. var routeSettings = _SerializeRouteSettings(); _trackingService.UpdateRouteSettings(plannedDate, routeSettings); _UpdateRouteTable(routes, devices, plannedDate); // Update barriers for planned date. _UpdateBarriers(plannedDate); _trackingService.UpdateStops(newStops, updatedStops); return(true); } else { return(false); } }
public async Task DisableDeviceTokens(TrackingDevice device) { await this.repository.DisableTokensByDeviceAsync(device); }
public async Task <TrackingDevice> Put(string id, [FromBody] TrackingDevice device) { return(await this.deviceService.UpdateAsync(id, device)); }
//private float lastTime = 0; public ControllerState(TrackingDevice tracker, uint actorId, Side side) { this.tracker = tracker; this.actorId = actorId; this.side = side; }