Skip to content

Commit

Permalink
Merge branch 'feature/rs232-testing' into feature/presenter-pin-prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
ngenovese11 committed May 23, 2024
2 parents 95efe8d + 3e6ca7e commit 1875d37
Show file tree
Hide file tree
Showing 10 changed files with 564 additions and 286 deletions.
12 changes: 0 additions & 12 deletions src/V2/CallStatusJoinMap.cs

This file was deleted.

143 changes: 66 additions & 77 deletions src/V2/CiscoCallStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using PepperDash.Core;
using PepperDash.Core.Intersystem;
Expand All @@ -17,8 +16,6 @@ namespace epi_videoCodec_ciscoExtended.V2
public class CiscoCallStatus : CiscoRoomOsFeature, IJoinCalls, IHasCallHold, IHasDialer, IHasPolls,
IHasEventSubscriptions, IHandlesResponses
{
private readonly CCriticalSection activeCallItemsSync = new CCriticalSection();

private readonly IDictionary<string, CodecActiveCallItem> activeCallItems;

private readonly CiscoRoomOsDevice parent;
Expand Down Expand Up @@ -104,99 +101,91 @@ public void HandleResponse(string response)

var changedCallItems = new Dictionary<string, CodecActiveCallItem>();

activeCallItemsSync.Enter();
try
foreach (var line in response.Split('|'))
{
foreach (var line in response.Split('|'))
var ghostMatch = Regex.Match(line, ghostPattern);
if (ghostMatch.Success)
{
var ghostMatch = Regex.Match(line, ghostPattern);
if (ghostMatch.Success)
{
var callId = ghostMatch.Groups[1].Value;
var isGhost = bool.Parse(ghostMatch.Groups[2].Value);
var callId = ghostMatch.Groups[1].Value;
var isGhost = bool.Parse(ghostMatch.Groups[2].Value);

CodecActiveCallItem activeCall;
CodecActiveCallItem activeCall;

if (isGhost && activeCallItems.TryGetValue(callId, out activeCall))
{
activeCallItems.Remove(callId);
activeCall.Status = eCodecCallStatus.Disconnected;
if (isGhost && activeCallItems.TryGetValue(callId, out activeCall))
{
activeCallItems.Remove(callId);
activeCall.Status = eCodecCallStatus.Disconnected;

if (!changedCallItems.ContainsKey(callId))
{
changedCallItems.Add(callId, activeCall);
}
if (!changedCallItems.ContainsKey(callId))
{
changedCallItems.Add(callId, activeCall);
}

continue;
}

var match = Regex.Match(line, pattern);
if (match.Success)
{
var callId = match.Groups[1].Value;
var property = match.Groups[2].Value.Trim(new []{ ' ', '\"' });
var value = match.Groups[3].Value;
continue;
}

CodecActiveCallItem activeCall;
var match = Regex.Match(line, pattern);
if (match.Success)
{
var callId = match.Groups[1].Value;
var property = match.Groups[2].Value.Trim(new[] { ' ', '\"' });
var value = match.Groups[3].Value;

if (!activeCallItems.TryGetValue(callId, out activeCall))
CodecActiveCallItem activeCall;

if (!activeCallItems.TryGetValue(callId, out activeCall))
{
activeCall = new CodecActiveCallItem
{
activeCall = new CodecActiveCallItem
{
Id = callId
};
Id = callId
};

activeCallItems.Add(callId, activeCall);
}
activeCallItems.Add(callId, activeCall);
}

try
{
switch (property)
{
case "DisplayName":
activeCallItems[callId].Name = value;
break;
case "RemoteNumber":
activeCallItems[callId].Number = value;
break;
case "CallType":
activeCallItems[callId].Type =
(eCodecCallType) Enum.Parse(typeof (eCodecCallType), value, true);
break;
case "Status":
activeCallItems[callId].Status =
value == "Dialling"
? eCodecCallStatus.Dialing
: (eCodecCallStatus) Enum.Parse(typeof (eCodecCallStatus), value, true);
break;
case "Direction":
activeCallItems[callId].Direction =
(eCodecCallDirection) Enum.Parse(typeof (eCodecCallDirection), value, true);
break;
case "PlacedOnHold":
activeCallItems[callId].IsOnHold = bool.Parse(value);
break;
default:
break;
}
}
catch (Exception ex)
try
{
switch (property)
{
Debug.Console(0, this, "Failed parsing the call status:{0}", ex);
case "DisplayName":
activeCallItems[callId].Name = value;
break;
case "RemoteNumber":
activeCallItems[callId].Number = value;
break;
case "CallType":
activeCallItems[callId].Type =
(eCodecCallType)Enum.Parse(typeof(eCodecCallType), value, true);
break;
case "Status":
activeCallItems[callId].Status =
value == "Dialling"
? eCodecCallStatus.Dialing
: (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), value, true);
break;
case "Direction":
activeCallItems[callId].Direction =
(eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), value, true);
break;
case "PlacedOnHold":
activeCallItems[callId].IsOnHold = bool.Parse(value);
break;
default:
break;
}
}
catch (Exception ex)
{
Debug.Console(0, this, "Failed parsing the call status:{0}", ex);
}

if (!changedCallItems.ContainsKey(callId))
{
changedCallItems.Add(callId, activeCall);
}
if (!changedCallItems.ContainsKey(callId))
{
changedCallItems.Add(callId, activeCall);
}
}
}
finally
{
activeCallItemsSync.Leave();
}

CallIsIncoming.FireUpdate();
CallIsConnectedOrConnecting.FireUpdate();
Expand Down
6 changes: 3 additions & 3 deletions src/V2/CiscoCameras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ public void HandleResponse(string response)
{
case "DetectedConnector":
camera.Connector = Convert.ToInt32(value);
Debug.Console(1, this, "Camera:{0} | DetectedConnector {1}", cameraIndex, value);
// Debug.Console(1, this, "Camera:{0} | DetectedConnector {1}", cameraIndex, value);
break;
case "Capabilities Options":
camera.SetCapabilites(value);
Debug.Console(1, this, "Camera:{0} | Capabilities {1}", cameraIndex, value);
// Debug.Console(1, this, "Camera:{0} | Capabilities {1}", cameraIndex, value);
break;
default:
Debug.Console(1, this, "Camera:{0} | Property:{1} = {2}", cameraIndex, property, value);
// Debug.Console(1, this, "Camera:{0} | Property:{1} = {2}", cameraIndex, property, value);
break;
}
}
Expand Down
Loading

0 comments on commit 1875d37

Please sign in to comment.