mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-01-11 19:44:44 +00:00
Merge pull request #186 from PepperDash/feature-2/camera-list-config
Feature 2/camera list config
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -397,3 +397,5 @@ FodyWeavers.xsd
|
|||||||
# JetBrains Rider
|
# JetBrains Rider
|
||||||
*.sln.iml
|
*.sln.iml
|
||||||
*.projectinfo
|
*.projectinfo
|
||||||
|
|
||||||
|
output/
|
||||||
Binary file not shown.
@@ -14,125 +14,125 @@ namespace PepperDash.Core
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
|
||||||
{
|
{
|
||||||
private const string SPlusKey = "Uninitialized SshClient";
|
private const string SPlusKey = "Uninitialized SshClient";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Object to enable stream debugging
|
/// Object to enable stream debugging
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
public CommunicationStreamDebugging StreamDebugging { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that fires when data is received. Delivers args with byte array
|
/// Event that fires when data is received. Delivers args with byte array
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
public event EventHandler<GenericCommMethodReceiveBytesArgs> BytesReceived;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that fires when data is received. Delivered as text.
|
/// Event that fires when data is received. Delivered as text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
public event EventHandler<GenericCommMethodReceiveTextArgs> TextReceived;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event when the connection status changes.
|
/// Event when the connection status changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
public event EventHandler<GenericSocketStatusChageEventArgs> ConnectionChange;
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
/////
|
/////
|
||||||
///// </summary>
|
///// </summary>
|
||||||
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
//public event GenericSocketStatusChangeEventDelegate SocketStatusChange;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Address of server
|
/// Address of server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Hostname { get; set; }
|
public string Hostname { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Port on server
|
/// Port on server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Username for server
|
/// Username for server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// And... Password for server. That was worth documenting!
|
/// And... Password for server. That was worth documenting!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True when the server is connected - when status == 2.
|
/// True when the server is connected - when status == 2.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsConnected
|
public bool IsConnected
|
||||||
{
|
{
|
||||||
// returns false if no client or not connected
|
// returns false if no client or not connected
|
||||||
get { return Client != null && ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
get { return Client != null && ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// S+ helper for IsConnected
|
/// S+ helper for IsConnected
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort UIsConnected
|
public ushort UIsConnected
|
||||||
{
|
{
|
||||||
get { return (ushort)(IsConnected ? 1 : 0); }
|
get { return (ushort)(IsConnected ? 1 : 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SocketStatus ClientStatus
|
public SocketStatus ClientStatus
|
||||||
{
|
{
|
||||||
get { return _ClientStatus; }
|
get { return _ClientStatus; }
|
||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
if (_ClientStatus == value)
|
if (_ClientStatus == value)
|
||||||
return;
|
return;
|
||||||
_ClientStatus = value;
|
_ClientStatus = value;
|
||||||
OnConnectionChange();
|
OnConnectionChange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SocketStatus _ClientStatus;
|
SocketStatus _ClientStatus;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contains the familiar Simpl analog status values. This drives the ConnectionChange event
|
/// Contains the familiar Simpl analog status values. This drives the ConnectionChange event
|
||||||
/// and IsConnected with be true when this == 2.
|
/// and IsConnected with be true when this == 2.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort UStatus
|
public ushort UStatus
|
||||||
{
|
{
|
||||||
get { return (ushort)_ClientStatus; }
|
get { return (ushort)_ClientStatus; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether client will attempt reconnection on failure. Default is true
|
/// Determines whether client will attempt reconnection on failure. Default is true
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoReconnect { get; set; }
|
public bool AutoReconnect { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Will be set and unset by connect and disconnect only
|
/// Will be set and unset by connect and disconnect only
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ConnectEnabled { get; private set; }
|
public bool ConnectEnabled { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// S+ helper for AutoReconnect
|
/// S+ helper for AutoReconnect
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort UAutoReconnect
|
public ushort UAutoReconnect
|
||||||
{
|
{
|
||||||
get { return (ushort)(AutoReconnect ? 1 : 0); }
|
get { return (ushort)(AutoReconnect ? 1 : 0); }
|
||||||
set { AutoReconnect = value == 1; }
|
set { AutoReconnect = value == 1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Millisecond value, determines the timeout period in between reconnect attempts.
|
/// Millisecond value, determines the timeout period in between reconnect attempts.
|
||||||
/// Set to 5000 by default
|
/// Set to 5000 by default
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int AutoReconnectIntervalMs { get; set; }
|
public int AutoReconnectIntervalMs { get; set; }
|
||||||
|
|
||||||
SshClient Client;
|
SshClient Client;
|
||||||
|
|
||||||
ShellStream TheStream;
|
ShellStream TheStream;
|
||||||
|
|
||||||
CTimer ReconnectTimer;
|
CTimer ReconnectTimer;
|
||||||
|
|
||||||
//Lock object to prevent simulatneous connect/disconnect operations
|
//Lock object to prevent simulatneous connect/disconnect operations
|
||||||
//private CCriticalSection connectLock = new CCriticalSection();
|
//private CCriticalSection connectLock = new CCriticalSection();
|
||||||
@@ -140,12 +140,12 @@ namespace PepperDash.Core
|
|||||||
|
|
||||||
private bool DisconnectLogged = false;
|
private bool DisconnectLogged = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Typical constructor.
|
/// Typical constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public GenericSshClient(string key, string hostname, int port, string username, string password) :
|
public GenericSshClient(string key, string hostname, int port, string username, string password) :
|
||||||
base(key)
|
base(key)
|
||||||
{
|
{
|
||||||
StreamDebugging = new CommunicationStreamDebugging(key);
|
StreamDebugging = new CommunicationStreamDebugging(key);
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
|
||||||
Key = key;
|
Key = key;
|
||||||
@@ -182,14 +182,6 @@ namespace PepperDash.Core
|
|||||||
}, System.Threading.Timeout.Infinite);
|
}, System.Threading.Timeout.Infinite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Just to help S+ set the key
|
|
||||||
/// </summary>
|
|
||||||
public void Initialize(string key)
|
|
||||||
{
|
|
||||||
Key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles closing this up when the program shuts down
|
/// Handles closing this up when the program shuts down
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -201,14 +193,14 @@ namespace PepperDash.Core
|
|||||||
{
|
{
|
||||||
this.LogDebug("Program stopping. Closing connection");
|
this.LogDebug("Program stopping. Closing connection");
|
||||||
Disconnect();
|
Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Connect to the server, using the provided properties.
|
/// Connect to the server, using the provided properties.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Connect()
|
public void Connect()
|
||||||
{
|
{
|
||||||
// Don't go unless everything is here
|
// Don't go unless everything is here
|
||||||
if (string.IsNullOrEmpty(Hostname) || Port < 1 || Port > 65535
|
if (string.IsNullOrEmpty(Hostname) || Port < 1 || Port > 65535
|
||||||
@@ -347,7 +339,7 @@ namespace PepperDash.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kills the stream, cleans up the client and sets it to null
|
/// Kills the stream, cleans up the client and sets it to null
|
||||||
@@ -468,18 +460,18 @@ namespace PepperDash.Core
|
|||||||
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
ReconnectTimer.Reset(AutoReconnectIntervalMs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper for ConnectionChange event
|
/// Helper for ConnectionChange event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnConnectionChange()
|
void OnConnectionChange()
|
||||||
{
|
{
|
||||||
if (ConnectionChange != null)
|
if (ConnectionChange != null)
|
||||||
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
|
ConnectionChange(this, new GenericSocketStatusChageEventArgs(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IBasicCommunication Members
|
#region IBasicCommunication Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends text to the server
|
/// Sends text to the server
|
||||||
@@ -582,10 +574,10 @@ public class SshConnectionChangeEventArgs : EventArgs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort Status { get { return Client.UStatus; } }
|
public ushort Status { get { return Client.UStatus; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// S+ Constructor
|
/// S+ Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SshConnectionChangeEventArgs() { }
|
public SshConnectionChangeEventArgs() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// EventArgs class
|
/// EventArgs class
|
||||||
@@ -593,9 +585,9 @@ public class SshConnectionChangeEventArgs : EventArgs
|
|||||||
/// <param name="isConnected">Connection State</param>
|
/// <param name="isConnected">Connection State</param>
|
||||||
/// <param name="client">The Client</param>
|
/// <param name="client">The Client</param>
|
||||||
public SshConnectionChangeEventArgs(bool isConnected, GenericSshClient client)
|
public SshConnectionChangeEventArgs(bool isConnected, GenericSshClient client)
|
||||||
{
|
{
|
||||||
IsConnected = isConnected;
|
IsConnected = isConnected;
|
||||||
Client = client;
|
Client = client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ namespace PepperDash.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current socket status of the client
|
/// The current socket status of the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("clinetStatus")]
|
[JsonProperty("clientStatus")]
|
||||||
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
SocketStatus ClientStatus { get; }
|
SocketStatus ClientStatus { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,22 @@ namespace PepperDash.Core.Config
|
|||||||
merged.Add("destinationLists",
|
merged.Add("destinationLists",
|
||||||
Merge(template["destinationLists"], system["destinationLists"], "destinationLists"));
|
Merge(template["destinationLists"], system["destinationLists"], "destinationLists"));
|
||||||
|
|
||||||
// Template tie lines take precedence. Config tool doesn't do them at system
|
|
||||||
// level anyway...
|
if (system["cameraLists"] == null)
|
||||||
if (template["tieLines"] != null)
|
merged.Add("cameraLists", template["cameraLists"]);
|
||||||
|
else
|
||||||
|
merged.Add("cameraLists", Merge(template["cameraLists"], system["cameraLists"], "cameraLists"));
|
||||||
|
|
||||||
|
if (system["audioControlPointLists"] == null)
|
||||||
|
merged.Add("audioControlPointLists", template["audioControlPointLists"]);
|
||||||
|
else
|
||||||
|
merged.Add("audioControlPointLists",
|
||||||
|
Merge(template["audioControlPointLists"], system["audioControlPointLists"], "audioControlPointLists"));
|
||||||
|
|
||||||
|
|
||||||
|
// Template tie lines take precedence. Config tool doesn't do them at system
|
||||||
|
// level anyway...
|
||||||
|
if (template["tieLines"] != null)
|
||||||
merged.Add("tieLines", template["tieLines"]);
|
merged.Add("tieLines", template["tieLines"]);
|
||||||
else if (system["tieLines"] != null)
|
else if (system["tieLines"] != null)
|
||||||
merged.Add("tieLines", system["tieLines"]);
|
merged.Add("tieLines", system["tieLines"]);
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
<Company>PepperDash Technologies</Company>
|
<Company>PepperDash Technologies</Company>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/PepperDash/PepperDashCore</RepositoryUrl>
|
<RepositoryUrl>https://github.com/PepperDash/PepperDashCore</RepositoryUrl>
|
||||||
<PackageTags>crestron;4series;</PackageTags>
|
<PackageTags>crestron;4series;</PackageTags>
|
||||||
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
<InformationalVersion>$(Version)</InformationalVersion>
|
<InformationalVersion>$(Version)</InformationalVersion>
|
||||||
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user