Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' into serial
Browse files Browse the repository at this point in the history
  • Loading branch information
btb committed Mar 11, 2016
2 parents d0d9449 + d666e9d commit 722d873
Show file tree
Hide file tree
Showing 25 changed files with 298 additions and 21 deletions.
5 changes: 3 additions & 2 deletions PanoptoRRLightService/RRLightService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="RemoteRecorderAPI">
<HintPath>..\..\..\..\..\..\..\tfs\Panopto\4_8_00\Panopto\Applications\RemoteRecorderAPI\bin\Release\RemoteRecorderAPI.dll</HintPath>
<Reference Include="RemoteRecorderAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>\\tfs\tfsbuilds\pre_prod_x86_Official\pre_prod_x86_Official_20151216.1\RemoteRecorderAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
Expand Down
Binary file modified PanoptoRRLightService/RemoteRecorderAPI.dll
Binary file not shown.
70 changes: 66 additions & 4 deletions PanoptoRRLightService/RemoteRecorderSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.ServiceModel;
using System.ServiceProcess;
using System.Threading;
Expand All @@ -19,23 +21,53 @@ public class RemoteRecorderSync
private IRemoteRecorderController controller;
private bool shouldStop = false;
private MainAppLogic.EnqueueStateMachineInput stateMachineInputCallback;
public Version RemoteRecorderVersion { get; private set; }

//Property to determine whether the current version of the remote recorder supports starting a new recording.
public bool SupportsStartNewRecording
{
get
{
return this.RemoteRecorderVersion != null &&
this.RemoteRecorderVersion.CompareTo(Version.Parse("5.0")) >= 0;
}
}

/// <summary>
/// Constructor
/// </summary>
/// <param name="stateMachineInputCallback"></param>
public RemoteRecorderSync(MainAppLogic.EnqueueStateMachineInput stateMachineInputCallback)
{
RemoteRecorderVersion = null;
SetUpController();

this.stateMachineInputCallback = stateMachineInputCallback;

try
{
//Try to get the current remote recorder version number
Process result = Process.GetProcessesByName("RemoteRecorder").FirstOrDefault();
if (result != null)
{
AssemblyName an = AssemblyName.GetAssemblyName(result.MainModule.FileName);
this.RemoteRecorderVersion = an.Version;
}
}
catch
{
//If we fail to get the RR version, set it to 4.9.0 by default.
this.RemoteRecorderVersion = Version.Parse("4.9.0");
}

//Start background thread to listen for input from recorder
BackgroundWorker bgw = new BackgroundWorker();
bgw.DoWork += delegate { BackgroundPollingWorker(); };
bgw.RunWorkerAsync();
}



// Stop the background thread
public void Stop()
{
Expand Down Expand Up @@ -71,7 +103,7 @@ public bool StopCurrentRecording()
}

/// <summary>
/// Stop the current recording
/// Resume the current recording
/// </summary>
/// <returns>true on success</returns>
public bool ResumeCurrentRecording()
Expand All @@ -96,7 +128,7 @@ public bool ResumeCurrentRecording()
}

/// <summary>
/// Stop the current recording
/// Pause the current recording
/// </summary>
/// <returns>true on success</returns>
public bool PauseCurrentRecording()
Expand All @@ -121,7 +153,7 @@ public bool PauseCurrentRecording()
}

/// <summary>
/// Stop the current recording
/// Start the next recording
/// </summary>
/// <returns>true on success</returns>
public bool StartNextRecording()
Expand Down Expand Up @@ -149,6 +181,36 @@ public bool StartNextRecording()
}

/// <summary>
/// Start a new recording (not a webcast)
/// </summary>
/// <returns>true on success</returns>
public bool StartNewRecording()
{
bool result = false;

try
{
Recording nextRecording = controller.GetNextRecording();
RemoteRecorderState cState = controller.GetCurrentState();

if (cState.Status != RemoteRecorderStatus.Recording
&& cState.CurrentRecording == null
&& nextRecording == null)
{
controller.StartNewRecording(false);
result = true;
}
}
catch (Exception e)
{
HandleRRException(e, false);
}

return result;
}

/// <summary>

/// Extend the current recording
/// </summary>
/// <returns>true on success</returns>
Expand Down Expand Up @@ -206,7 +268,7 @@ private void HandleRRException(Exception e, bool blockUntilRunning)
* exception and return to this loop, so it's safe.
*/
Thread.Sleep(RRServiceSetupInterval);

SetUpController();
}
}
Expand Down
88 changes: 73 additions & 15 deletions PanoptoRRLightService/StateMachine.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Uncomment the below to turn on debug output for this state machine
// Uncomment the below to turn on debug output for this state machine
// #define s_debugoutput

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using Panopto.RemoteRecorderAPI.V1;

namespace RRLightProgram
{
Expand Down Expand Up @@ -350,6 +353,29 @@ StateMachineInputArgs inputArgs
return startNext;
}

//Start new recording and turn green light on
private static bool ActionRecordNew(
StateMachine control,
RRState currentState,
StateMachineInputArgs inputArgs
)
{
bool startNext = false;
if (control.rrSync.SupportsStartNewRecording)
{
control.light.ChangeColor(DelcomColor.Green, false, null);
startNext = control.rrSync.StartNewRecording();
}
else
{
//If we can't start the next recording, flash red for 2 seconds then return the light to off before returning false
control.light.ChangeColor(DelcomColor.Red, false, TimeSpan.FromMilliseconds(2000));
Thread.Sleep(2000);
control.light.ChangeColor(DelcomColor.Off);
}
return startNext;
}

//Turn light off for preview
private static bool ActionPreview(
StateMachine control,
Expand Down Expand Up @@ -402,6 +428,20 @@ StateMachineInputArgs inputArgs
return true;
}

//Turn light red
private static bool ActionPreviewingButtonDown(
StateMachine control,
RRState currentState,
StateMachineInputArgs inputArgs
)
{
if (!control.rrSync.SupportsStartNewRecording)
{
control.light.ChangeColor(DelcomColor.Red);
}
return true;
}

//Turn light off
private static bool ActionNotQueuedButtonUp(
StateMachine control,
Expand All @@ -414,6 +454,18 @@ StateMachineInputArgs inputArgs
return true;
}

//Turn light off
private static bool ActionPreviewingButtonUp(
StateMachine control,
RRState currentState,
StateMachineInputArgs inputArgs
)
{
control.light.ChangeColor(DelcomColor.Off);

return true;
}

//Extend active recording
private static bool ActionExtendPaused(
StateMachine control,
Expand Down Expand Up @@ -518,7 +570,7 @@ public void ProcessStateMachineInput(StateMachineInputArgs inputArgs)
}

StateMachineAction action = m_actionTable[(int)transition.actionId];

if (action(this, State, inputArgs))
{
m_SMState = transition.newState;
Expand Down Expand Up @@ -568,15 +620,18 @@ private enum ActionId
IsPaused = 6,
Recording = 7,
Next = 8,
Preview = 9,
FaultDisconnect = 10,
Running = 11,
CantRecordButtonDown = 12,
CantRecordButtonUp = 13,
ExtendPaused = 14,
ExtendRecording = 15,
GetStatus = 16,
LAST = 17,
New = 9,
Preview = 10,
FaultDisconnect = 11,
Running = 12,
CantRecordButtonDown = 13,
CantRecordButtonUp = 14,
PreviewingButtonDown = 15,
PreviewingButtonUp = 16,
ExtendPaused = 17,
ExtendRecording = 18,
GetStatus = 19,
LAST = 20,
};

// Must be kept in sync with enum ActionID
Expand All @@ -591,11 +646,14 @@ private enum ActionId
new StateMachineAction(ActionRRIsPaused),
new StateMachineAction(ActionRRRecording),
new StateMachineAction(ActionRecordNext),
new StateMachineAction(ActionRecordNew),
new StateMachineAction(ActionPreview),
new StateMachineAction(ActionRRFaultOrDisconnect),
new StateMachineAction(ActionRRRunning),
new StateMachineAction(ActionNotQueuedButtonDown),
new StateMachineAction(ActionNotQueuedButtonUp),
new StateMachineAction(StateMachine.ActionPreviewingButtonDown),
new StateMachineAction(StateMachine.ActionPreviewingButtonUp),
new StateMachineAction(ActionExtendPaused),
new StateMachineAction(ActionExtendRecording),
new StateMachineAction(ActionGetStatus),
Expand Down Expand Up @@ -643,9 +701,9 @@ private enum ActionId
new Transition(RRS.RRPreviewing, StateMachineInput.RecorderRunning, ActionId.Running, RRS.RRRunning),
new Transition(RRS.RRPreviewing, StateMachineInput.Disconnected, ActionId.FaultDisconnect, RRS.RRDisconnected),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonPressed, ActionId.Noop, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonHeld, ActionId.Noop, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonDown, ActionId.CantRecordButtonDown, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonUp, ActionId.CantRecordButtonUp, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonHeld, ActionId.New, RRS.RRRecordingWait),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonDown, ActionId.PreviewingButtonDown, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.ButtonUp, ActionId.PreviewingButtonUp, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.CommandStart, ActionId.Noop, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.CommandStop, ActionId.Noop, RRS.RRPreviewing),
new Transition(RRS.RRPreviewing, StateMachineInput.CommandPause, ActionId.Noop, RRS.RRPreviewing),
Expand Down Expand Up @@ -902,4 +960,4 @@ private enum ActionId

#endregion Private
}
}
}
45 changes: 45 additions & 0 deletions PanoptoRRLightService/bin/Debug/RRLightService.exe.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,51 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="RRLightProgram.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<applicationSettings>
<RRLightProgram.Properties.Settings>
<setting name="LightPollingIntervalMS" serializeAs="String">
<value>50</value>
</setting>
<setting name="ControllerEndpoint" serializeAs="String">
<value>net.pipe://localhost/PanoptoRemoteRecorder/Controller</value>
</setting>
<setting name="LightSupportsYellow" serializeAs="String">
<value>False</value>
</setting>
<setting name="RecorderPollingIntervalMS" serializeAs="String">
<value>100</value>
</setting>
<setting name="HoldDuration" serializeAs="String">
<value>00:00:05</value>
</setting>
<setting name="MintimeBetweenClicksMilliseconds" serializeAs="String">
<value>300</value>
</setting>
<setting name="SerialPortName" serializeAs="String">
<value />
</setting>
<setting name="SerialPortBaudRate" serializeAs="String">
<value>9600</value>
</setting>
<setting name="SerialPortParity" serializeAs="String">
<value>None</value>
</setting>
<setting name="SerialPortDataBits" serializeAs="String">
<value>8</value>
</setting>
<setting name="SerialPortStopBits" serializeAs="String">
<value>One</value>
</setting>
<setting name="SerialMaxLength" serializeAs="String">
<value>255</value>
</setting>
</RRLightProgram.Properties.Settings>
</applicationSettings>
</configuration>

0 comments on commit 722d873

Please sign in to comment.