Loading WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/HoloLens/HoloLens_rs1_release.cs +1 −1 Original line number Diff line number Diff line Loading @@ -193,7 +193,7 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests Assert.AreEqual(TaskStatus.RanToCompletion, getTask.Status); // Check some known things about this response. ProcessStatus processStatus = getTask.Result.Status; MrcProcessStatus processStatus = getTask.Result.Status; Assert.AreEqual("Running", processStatus.MrcProcess); } Loading WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs +2 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Stops listneing for messages from the websocket and closes the connection to the websocket. /// </summary> /// <returns>The task of closing the websocket connection.</returns> #pragma warning disable 1998 private async Task StopListeningForMessagesInternal() { if (this.IsListeningForMessages) Loading @@ -68,6 +69,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } } } #pragma warning restore 1998 /// <summary> /// Connects to the websocket and starts listening for messages from the websocket. Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicPerception.cs +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,11 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </content> public partial class DevicePortal { /// <summary> /// API for running a Perception client. /// </summary> public static readonly string HolographicPerceptionClient = "api/holographic/perception/client"; /// <summary> /// API for getting or setting the Holographic Perception Simulation control mode. /// </summary> Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs +2 −2 Original line number Diff line number Diff line Loading @@ -317,14 +317,14 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the recording status /// </summary> [DataMember(Name = "ProcessStatus")] public ProcessStatus Status { get; private set; } public MrcProcessStatus Status { get; private set; } } /// <summary> /// Object representation of the recording process status /// </summary> [DataContract] public class ProcessStatus public class MrcProcessStatus { /// <summary> /// Gets the process status Loading WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationPlayback.cs +199 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,12 @@ // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Threading.Tasks; namespace Microsoft.Tools.WindowsDevicePortal { /// <content> Loading @@ -14,12 +20,12 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for loading or unloading a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationLoadUnloadRecordingApi = "api/holographic/simulation/playback/session/file"; public static readonly string HolographicSimulationPlaybackSessionFileApi = "api/holographic/simulation/playback/session/file"; /// <summary> /// API for pausing a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationPauseApi = "api/holographic/simulation/playback/session/pause"; public static readonly string HolographicSimulationPlaybackPauseApi = "api/holographic/simulation/playback/session/pause"; /// <summary> /// API for uploading or deleting a Holographic Perception Simulation recording file. Loading @@ -34,7 +40,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for starting playback of a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationPlayApi = "api/holographic/simulation/playback/session/play"; public static readonly string HolographicSimulationPlaybackPlayApi = "api/holographic/simulation/playback/session/play"; /// <summary> /// API for loading or unloading a Holographic Perception Simulation recording. Loading @@ -49,15 +55,203 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for starting playback of a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationStopApi = "api/holographic/simulation/playback/session/stop"; public static readonly string HolographicSimulationPlaybackStopApi = "api/holographic/simulation/playback/session/stop"; /// <summary> /// API for retrieving the types of data in a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationTypesApi = "api/holographic/simulation/playback/session/types"; public static readonly string HolographicSimulationPlaybackDataTypesApi = "api/holographic/simulation/playback/session/types"; /// <summary> /// Enumeration describing the available Holgraphic Simulation playback states. /// </summary> public enum HolographicSimulationPlaybackStates { /// <summary> /// The simulation has been stopped. /// </summary> Stopped = 0, /// <summary> /// The simulation is playing. /// </summary> Playing, /// <summary> /// The simulation has been paused. /// </summary> Paused, /// <summary> /// Playback has completed. /// </summary> Complete, /// <summary> /// Playback is in an unexpected / unknown state. /// </summary> Unexpected = 9999 } /// <summary> /// Deletes the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to delete (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task DeleteHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Delete(HolographicSimulationPlaybackFileApi, payload); } /// <summary> /// Gets the playback state of a Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording (ex: testsession.xef).</param> /// <returns>HolographicSimulationPlaybackStates enum value describing the state of the recording.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<HolographicSimulationPlaybackStates> GetHolographicSimulationPlaybackState(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } HolographicSimulationPlaybackStates playbackState = HolographicSimulationPlaybackStates.Unexpected; string payload = string.Format( "recording={0}", name); Uri uri = Utilities.BuildEndpoint( this.deviceConnection.Connection, HolographicSimulationPlaybackStateApi, payload); using (Stream dataStream = await this.Get(uri)) { if ((dataStream != null) && (dataStream.Length != 0)) { // Try to get the session state. try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationPlaybackSessionState)); HolographicSimulationPlaybackSessionState sessionState = (HolographicSimulationPlaybackSessionState)serializer.ReadObject(dataStream); playbackState = sessionState.State; } catch { // We did not receive the session state, check to see if we received a simulation error. dataStream.Position = 0; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationError)); HolographicSimulationError error = (HolographicSimulationError)serializer.ReadObject(dataStream); throw new InvalidOperationException(error.Reason); } } } return playbackState; } /// <summary> /// Loads the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to load (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task LoadHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Post(HolographicSimulationPlaybackSessionFileApi, payload); } /// <summary> /// Unloads the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to unload (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task UnloadHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Delete(HolographicSimulationPlaybackSessionFileApi, payload); } #region Data contract /// <summary> /// Object representation of the Holographic Simulation playback state /// </summary> [DataContract] public class HolographicSimulationPlaybackSessionState { /// <summary> /// Gets the state value as a string /// </summary> [DataMember(Name = "state")] public string StateRaw { get; private set; } /// <summary> /// Gets the playback session state /// </summary> public HolographicSimulationPlaybackStates State { get { HolographicSimulationPlaybackStates state = HolographicSimulationPlaybackStates.Unexpected; switch (this.StateRaw) { case "stopped": state = HolographicSimulationPlaybackStates.Stopped; break; case "playing": state = HolographicSimulationPlaybackStates.Playing; break; case "paused": state = HolographicSimulationPlaybackStates.Paused; break; case "end": state = HolographicSimulationPlaybackStates.Complete; break; default: state = HolographicSimulationPlaybackStates.Unexpected; break; } return state; } } } #endregion // Data contract } } Loading
WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/HoloLens/HoloLens_rs1_release.cs +1 −1 Original line number Diff line number Diff line Loading @@ -193,7 +193,7 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests Assert.AreEqual(TaskStatus.RanToCompletion, getTask.Status); // Check some known things about this response. ProcessStatus processStatus = getTask.Result.Status; MrcProcessStatus processStatus = getTask.Result.Status; Assert.AreEqual("Running", processStatus.MrcProcess); } Loading
WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs +2 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Stops listneing for messages from the websocket and closes the connection to the websocket. /// </summary> /// <returns>The task of closing the websocket connection.</returns> #pragma warning disable 1998 private async Task StopListeningForMessagesInternal() { if (this.IsListeningForMessages) Loading @@ -68,6 +69,7 @@ namespace Microsoft.Tools.WindowsDevicePortal } } } #pragma warning restore 1998 /// <summary> /// Connects to the websocket and starts listening for messages from the websocket. Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicPerception.cs +5 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,11 @@ namespace Microsoft.Tools.WindowsDevicePortal /// </content> public partial class DevicePortal { /// <summary> /// API for running a Perception client. /// </summary> public static readonly string HolographicPerceptionClient = "api/holographic/perception/client"; /// <summary> /// API for getting or setting the Holographic Perception Simulation control mode. /// </summary> Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs +2 −2 Original line number Diff line number Diff line Loading @@ -317,14 +317,14 @@ namespace Microsoft.Tools.WindowsDevicePortal /// Gets the recording status /// </summary> [DataMember(Name = "ProcessStatus")] public ProcessStatus Status { get; private set; } public MrcProcessStatus Status { get; private set; } } /// <summary> /// Object representation of the recording process status /// </summary> [DataContract] public class ProcessStatus public class MrcProcessStatus { /// <summary> /// Gets the process status Loading
WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationPlayback.cs +199 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,12 @@ // </copyright> //---------------------------------------------------------------------------------------------- using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Threading.Tasks; namespace Microsoft.Tools.WindowsDevicePortal { /// <content> Loading @@ -14,12 +20,12 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for loading or unloading a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationLoadUnloadRecordingApi = "api/holographic/simulation/playback/session/file"; public static readonly string HolographicSimulationPlaybackSessionFileApi = "api/holographic/simulation/playback/session/file"; /// <summary> /// API for pausing a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationPauseApi = "api/holographic/simulation/playback/session/pause"; public static readonly string HolographicSimulationPlaybackPauseApi = "api/holographic/simulation/playback/session/pause"; /// <summary> /// API for uploading or deleting a Holographic Perception Simulation recording file. Loading @@ -34,7 +40,7 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for starting playback of a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationPlayApi = "api/holographic/simulation/playback/session/play"; public static readonly string HolographicSimulationPlaybackPlayApi = "api/holographic/simulation/playback/session/play"; /// <summary> /// API for loading or unloading a Holographic Perception Simulation recording. Loading @@ -49,15 +55,203 @@ namespace Microsoft.Tools.WindowsDevicePortal /// <summary> /// API for starting playback of a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationStopApi = "api/holographic/simulation/playback/session/stop"; public static readonly string HolographicSimulationPlaybackStopApi = "api/holographic/simulation/playback/session/stop"; /// <summary> /// API for retrieving the types of data in a Holographic Perception Simulation recording. /// </summary> public static readonly string HolographicSimulationTypesApi = "api/holographic/simulation/playback/session/types"; public static readonly string HolographicSimulationPlaybackDataTypesApi = "api/holographic/simulation/playback/session/types"; /// <summary> /// Enumeration describing the available Holgraphic Simulation playback states. /// </summary> public enum HolographicSimulationPlaybackStates { /// <summary> /// The simulation has been stopped. /// </summary> Stopped = 0, /// <summary> /// The simulation is playing. /// </summary> Playing, /// <summary> /// The simulation has been paused. /// </summary> Paused, /// <summary> /// Playback has completed. /// </summary> Complete, /// <summary> /// Playback is in an unexpected / unknown state. /// </summary> Unexpected = 9999 } /// <summary> /// Deletes the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to delete (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task DeleteHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Delete(HolographicSimulationPlaybackFileApi, payload); } /// <summary> /// Gets the playback state of a Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording (ex: testsession.xef).</param> /// <returns>HolographicSimulationPlaybackStates enum value describing the state of the recording.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task<HolographicSimulationPlaybackStates> GetHolographicSimulationPlaybackState(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } HolographicSimulationPlaybackStates playbackState = HolographicSimulationPlaybackStates.Unexpected; string payload = string.Format( "recording={0}", name); Uri uri = Utilities.BuildEndpoint( this.deviceConnection.Connection, HolographicSimulationPlaybackStateApi, payload); using (Stream dataStream = await this.Get(uri)) { if ((dataStream != null) && (dataStream.Length != 0)) { // Try to get the session state. try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationPlaybackSessionState)); HolographicSimulationPlaybackSessionState sessionState = (HolographicSimulationPlaybackSessionState)serializer.ReadObject(dataStream); playbackState = sessionState.State; } catch { // We did not receive the session state, check to see if we received a simulation error. dataStream.Position = 0; DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationError)); HolographicSimulationError error = (HolographicSimulationError)serializer.ReadObject(dataStream); throw new InvalidOperationException(error.Reason); } } } return playbackState; } /// <summary> /// Loads the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to load (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task LoadHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Post(HolographicSimulationPlaybackSessionFileApi, payload); } /// <summary> /// Unloads the specified Holographic Simulation recording. /// </summary> /// <param name="name">The name of the recording to unload (ex: testsession.xef).</param> /// <returns>Task tracking completion of the REST call.</returns> /// <remarks>This method is only supported on HoloLens devices.</remarks> public async Task UnloadHolographicSimulationRecording(string name) { if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily)) { throw new NotSupportedException("This method is only supported on HoloLens."); } string payload = string.Format( "recording={0}", name); await this.Delete(HolographicSimulationPlaybackSessionFileApi, payload); } #region Data contract /// <summary> /// Object representation of the Holographic Simulation playback state /// </summary> [DataContract] public class HolographicSimulationPlaybackSessionState { /// <summary> /// Gets the state value as a string /// </summary> [DataMember(Name = "state")] public string StateRaw { get; private set; } /// <summary> /// Gets the playback session state /// </summary> public HolographicSimulationPlaybackStates State { get { HolographicSimulationPlaybackStates state = HolographicSimulationPlaybackStates.Unexpected; switch (this.StateRaw) { case "stopped": state = HolographicSimulationPlaybackStates.Stopped; break; case "playing": state = HolographicSimulationPlaybackStates.Playing; break; case "paused": state = HolographicSimulationPlaybackStates.Paused; break; case "end": state = HolographicSimulationPlaybackStates.Complete; break; default: state = HolographicSimulationPlaybackStates.Unexpected; break; } return state; } } } #endregion // Data contract } }