Skip to content

Commit

Permalink
v9.2 release (#204)
Browse files Browse the repository at this point in the history
* DeviceLab sample

* fix GetMrcFileDataAsync
* completes implementation of the mixed reality capture api (issue 71)
* complete implementation of Holographic Perception Simulation Playback API
* implement holographic services API
* increase wrapper version to 0.9.2
* Fix failing MRC test
  • Loading branch information
hpsin authored Dec 1, 2016
1 parent a01ada0 commit 0f7f95c
Show file tree
Hide file tree
Showing 9 changed files with 714 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void GetMrcStatus_HoloLens_1607()

// Check some known things about this response.
MrcProcessStatus processStatus = getTask.Result.Status;
Assert.AreEqual("Running", processStatus.MrcProcess);
Assert.AreEqual(ProcessStatus.Running, processStatus.MrcProcess);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,42 @@ public partial class DevicePortal
/// </summary>
public static readonly string HolographicWebManagementHttpSettingsApi = "api/holographic/os/webmanagement/settings/https";

/// <summary>
/// Enumeration describing the status of a process
/// </summary>
public enum ProcessStatus
{
/// <summary>
/// The process is running
/// </summary>
Running = 0,

/// <summary>
/// The process is stopped
/// </summary>
Stopped
}

/// <summary>
/// Gets the status of the Holographic Services on this HoloLens.
/// </summary>
/// <returns>HolographicServices object describing the state of the Holographic services.</returns>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<HolographicServices> GetHolographicServiceState()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
{
throw new NotSupportedException("This method is only supported on HoloLens.");
}

return await this.GetAsync<HolographicServices>(HolographicServicesApi);
}

/// <summary>
/// Gets the interpupilary distance registered on the device.
/// </summary>
/// <returns>Interpupilary distance, in millimeters.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<float> GetInterPupilaryDistanceAsync()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -50,7 +81,7 @@ public async Task<float> GetInterPupilaryDistanceAsync()
/// </summary>
/// <param name="httpsRequired">Desired value for HTTPS communication</param>
/// <returns>True if WiFi based communication requires a secure connection, false otherwise.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task SetIsHttpsRequiredAsync(bool httpsRequired)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -70,7 +101,7 @@ await this.PostAsync(
/// </summary>
/// <param name="ipd">Interpupilary distance, in millimeters.</param>
/// <returns>Task for tracking the POST call</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task SetInterPupilaryDistanceAsync(float ipd)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -89,7 +120,7 @@ await this.PostAsync(
/// Gets the WiFi http security requirements for communication with the device.
/// </summary>
/// <returns>True if WiFi based communication requires a secure connection, false otherwise.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<bool> GetIsHttpsRequiredAsync()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -103,16 +134,59 @@ public async Task<bool> GetIsHttpsRequiredAsync()

#region Data contract
/// <summary>
/// Object representation for HTTP settings
/// Object reporesentation of the status of the Holographic services
/// </summary>
[DataContract]
public class WebManagementHttpSettings
public class HolographicServices
{
/// <summary>
/// Gets a value indicating whether HTTPS is required
/// Gets the status for the collection of holographic services
/// </summary>
[DataMember(Name = "httpsRequired")]
public bool IsHttpsRequired { get; private set; }
[DataMember(Name = "SoftwareStatus")]
public HolographicSoftwareStatus Status { get; private set; }
}

/// <summary>
/// Object representation of the collection of holographic services.
/// </summary>
[DataContract]
public class HolographicSoftwareStatus
{
/// <summary>
/// Gets the status of dwm.exe
/// </summary>
[DataMember(Name = "dwm.exe")]
public ServiceStatus Dwm { get; private set; }

/// <summary>
/// Gets the status of holoshellapp.exe
/// </summary>
[DataMember(Name = "holoshellapp.exe")]
public ServiceStatus HoloShellApp { get; private set; }

/// <summary>
/// Gets the status of holosi.exe
/// </summary>
[DataMember(Name = "holosi.exe")]
public ServiceStatus HoloSi { get; private set; }

/// <summary>
/// Gets the status of mixedrealitycapture.exe
/// </summary>
[DataMember(Name = "mixedrealitycapture.exe")]
public ServiceStatus MixedRealitytCapture { get; private set; }

/// <summary>
/// Gets the status of sihost.exe
/// </summary>
[DataMember(Name = "sihost.exe")]
public ServiceStatus SiHost { get; private set; }

/// <summary>
/// Gets the status of spectrum.exe
/// </summary>
[DataMember(Name = "spectrum.exe")]
public ServiceStatus Spectrum { get; private set; }
}

/// <summary>
Expand All @@ -136,6 +210,61 @@ public float Ipd
set { this.IpdRaw = (int)(value * 1000); }
}
}

/// <summary>
/// Object representation of the status of a service
/// </summary>
[DataContract]
public class ServiceStatus
{
/// <summary>
/// Gets the raw value returned for the expected service status
/// </summary>
[DataMember(Name = "Expected")]
public string ExpectedRaw { get; private set; }

/// <summary>
/// Gets the raw value returned for the observed service status
/// </summary>
[DataMember(Name = "Observed")]
public string ObservedRaw { get; private set; }

/// <summary>
/// Gets the the expected service status
/// </summary>
public ProcessStatus Expected
{
get
{
return (this.ExpectedRaw == "Running") ? ProcessStatus.Running : ProcessStatus.Stopped;
}
}

/// <summary>
/// Gets the the observed service status
/// </summary>
public ProcessStatus Observed
{
get
{
return (this.ObservedRaw == "Running") ? ProcessStatus.Running : ProcessStatus.Stopped;
}
}
}

/// <summary>
/// Object representation for HTTP settings
/// </summary>
[DataContract]
public class WebManagementHttpSettings
{
/// <summary>
/// Gets a value indicating whether HTTPS is required
/// </summary>
[DataMember(Name = "httpsRequired")]
public bool IsHttpsRequired { get; private set; }
}

#endregion // Data contract
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class DevicePortal
/// <summary>
/// API for controlling the Holographic Perception Simulation control stream.
/// </summary>
public static readonly string HolographicSimulationStreamApi = "api/holographic/simulation/control/Stream";
public static readonly string HolographicSimulationStreamApi = "api/holographic/simulation/control/stream";

/// <summary>
/// Enumeration defining the control modes used by the Holographic Perception Simulation.
Expand All @@ -43,24 +43,86 @@ public enum SimulationControlMode
/// <summary>
/// Simulation mode.
/// </summary>
Simulation,
Simulation
}

/// <summary>
/// Enumeration defining the priority levels for the Holographic Perception Simulation control stream.
/// </summary>
public enum SimulationControlStreamPriority
{
/// <summary>
/// Remote mode.
/// Low priority.
/// </summary>
Remote,
Low = 0,

/// <summary>
/// Legacy mode.
/// Normal priority.
/// </summary>
Legacy
Normal
}

/// <summary>
/// Creates a simulation control stream.
/// </summary>
/// <param name="priority">The control stream priority.</param>
/// <returns>The identifier of the created stream.</returns>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<string> CreatePerceptionSimulationControlStreamAsync(SimulationControlStreamPriority priority)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
{
throw new NotSupportedException("This method is only supported on HoloLens.");
}

if (!(await VerifySimulationControlModeAsync(SimulationControlMode.Simulation)))
{
throw new InvalidOperationException("The simulation control mode on the target HoloLens must be 'Simulation'.");
}

string payload = string.Format(
"priority={0}",
(int)priority);

PerceptionSimulationControlStreamId controlStreamId = await this.GetAsync<PerceptionSimulationControlStreamId>(
HolographicSimulationStreamApi,
payload);

return controlStreamId.StreamId;
}

/// <summary>
/// Deletes a simulation control stream.
/// </summary>
/// <param name="streamId">The identifier of the stream to be deleted.</param>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task DeletePerceptionSimulationControlStreamAsync(string streamId)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
{
throw new NotSupportedException("This method is only supported on HoloLens.");
}

if (!(await VerifySimulationControlModeAsync(SimulationControlMode.Simulation)))
{
throw new InvalidOperationException("The simulation control mode on the target HoloLens must be 'Simulation'.");
}

string payload = string.Format(
"streamId={0}",
streamId);

await this.DeleteAsync(
HolographicSimulationStreamApi,
payload);
}

/// <summary>
/// Gets the perception simulation control mode.
/// </summary>
/// <returns>The simulation control mode.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<SimulationControlMode> GetPerceptionSimulationControlModeAsync()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -76,8 +138,8 @@ public async Task<SimulationControlMode> GetPerceptionSimulationControlModeAsync
/// Sets the perception simulation control mode.
/// </summary>
/// <param name="mode">The simulation control mode.</param>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <returns>Task tracking completion of the REST call.</returns>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task SetPerceptionSimulationControlModeAsync(SimulationControlMode mode)
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand All @@ -91,6 +153,17 @@ public async Task SetPerceptionSimulationControlModeAsync(SimulationControlMode
await this.PostAsync(HolographicSimulationModeApi, payload);
}

/// <summary>
/// Compares the current simulation control mode with the expected mode.
/// </summary>
/// <param name="expectedMode">The simulation control mode that we expect the device to be in.</param>
/// <returns>The simulation control mode.</returns>
private async Task<bool> VerifySimulationControlModeAsync(SimulationControlMode expectedMode)
{
SimulationControlMode simMode = await this.GetPerceptionSimulationControlModeAsync();
return (simMode == expectedMode);
}

#region Data contract
/// <summary>
/// Object representation of Perception Simulation control mode.
Expand All @@ -104,6 +177,19 @@ public class PerceptionSimulationControlMode
[DataMember(Name = "mode")]
public SimulationControlMode Mode { get; private set; }
}

/// <summary>
/// Object representation of the response recevied when creating a Perception Simulation control stream.
/// </summary>
[DataContract]
public class PerceptionSimulationControlStreamId
{
/// <summary>
/// Gets the stream identifier.
/// </summary>
[DataMember(Name = "streamId")]
public string StreamId { get; private set; }
}
#endregion // Data contract
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public partial class DevicePortal
/// Gets the current thermal stage reading from the device.
/// </summary>
/// <returns>ThermalStages enum value.</returns>
/// <remarks>This method is only supported on HoloLens devices.</remarks>
/// <remarks>This method is only supported on HoloLens.</remarks>
public async Task<ThermalStages> GetThermalStageAsync()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
Expand Down
Loading

0 comments on commit 0f7f95c

Please sign in to comment.