mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-06 16:24:51 +00:00
Updates Json Schema mechansism and adds schema files for ControlPropertiesConfig and TcpSshPropertiesConfig classes
This commit is contained in:
@@ -13,7 +13,6 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public class ControlPropertiesConfig :PropertiesConfigBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The control method for the device
|
||||
/// </summary>
|
||||
@@ -38,6 +37,9 @@ namespace PepperDash.Core
|
||||
[JsonProperty("controlPortName", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
|
||||
public string ControlPortName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ConfigurationProperties for IP connections
|
||||
/// </summary>
|
||||
[JsonProperty("tcpSshProperties")]
|
||||
public TcpSshPropertiesConfig TcpSshProperties { get; set; }
|
||||
|
||||
@@ -78,119 +80,11 @@ namespace PepperDash.Core
|
||||
[JsonProperty("deviceReadyResponsePattern")]
|
||||
public string DeviceReadyResponsePattern { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public ControlPropertiesConfig()
|
||||
{
|
||||
SchemaJson = @"
|
||||
{
|
||||
'definitions': {},
|
||||
'$schema': 'http://json-schema.org/draft-07/schema#',
|
||||
'$id': 'http://example.com/root.json',
|
||||
'type': 'object',
|
||||
'title': 'The Root Schema',
|
||||
'properties': {
|
||||
'tcpSshProperties': {
|
||||
'$id': '#/properties/tcpSshProperties',
|
||||
'type': 'object',
|
||||
'title': 'The Tcpsshproperties Schema',
|
||||
'default': null
|
||||
},
|
||||
'method': {
|
||||
'$id': '#/properties/method',
|
||||
'type': 'string',
|
||||
'title': 'The Method Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'ssh'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'controlPortDevKey': {
|
||||
'$id': '#/properties/controlPortDevKey',
|
||||
'type': 'string',
|
||||
'title': 'The Controlportdevkey Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'processor'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'controlPortNumber': {
|
||||
'$id': '#/properties/controlPortNumber',
|
||||
'type': 'integer',
|
||||
'title': 'The Controlportnumber Schema',
|
||||
'default': 0,
|
||||
'examples': [
|
||||
1
|
||||
]
|
||||
},
|
||||
'controlPortName': {
|
||||
'$id': '#/properties/controlPortName',
|
||||
'type': 'string',
|
||||
'title': 'The Controlportname Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'hdmi1'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'irFile': {
|
||||
'$id': '#/properties/irFile',
|
||||
'type': 'string',
|
||||
'title': 'The Irfile Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'Comcast Motorola DVR.ir'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'ipid': {
|
||||
'$id': '#/properties/ipid',
|
||||
'type': 'string',
|
||||
'title': 'The Ipid Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'13'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'endOfLineChar': {
|
||||
'$id': '#/properties/endOfLineChar',
|
||||
'type': 'string',
|
||||
'title': 'The Endoflinechar Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'\\x0d'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'endOfLineString': {
|
||||
'$id': '#/properties/endOfLineString',
|
||||
'type': 'string',
|
||||
'title': 'The Endoflinestring Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'\n'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'deviceReadyResponsePattern': {
|
||||
'$id': '#/properties/deviceReadyResponsePattern',
|
||||
'type': 'string',
|
||||
'title': 'The Devicereadyresponsepattern Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'.*>'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
}
|
||||
},
|
||||
'required': [
|
||||
'method'
|
||||
]
|
||||
}
|
||||
";
|
||||
|
||||
|
||||
EndOfLineString = CrestronEnvironment.NewLine;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"title": "ControlPropertiesConfig",
|
||||
"$ref": "#/definitions/ControlPropertiesConfig",
|
||||
"definitions": {
|
||||
"ControlPropertiesConfig": {
|
||||
"properties": {
|
||||
"method": {
|
||||
"type": "string",
|
||||
"title": "Communication Method",
|
||||
"enum": [
|
||||
"none",
|
||||
"com",
|
||||
"ipid",
|
||||
"ipidtcp",
|
||||
"ir",
|
||||
"ssh",
|
||||
"tcpip",
|
||||
"telnet",
|
||||
"cresnet",
|
||||
"cec",
|
||||
"udp"
|
||||
]
|
||||
},
|
||||
"tcpSshProperties": {
|
||||
"$ref":"TcpSshPropertiesConfigSchema.json#definitions/TcpSshPropertiesConfig",
|
||||
"title": "Properties for IP based communication",
|
||||
"default": null
|
||||
},
|
||||
"comm": {
|
||||
|
||||
},
|
||||
"controlPortDevKey": {
|
||||
"type": "string",
|
||||
"title": "Key of the device where the control port is found",
|
||||
"examples": [
|
||||
"processor"
|
||||
]
|
||||
},
|
||||
"controlPortNumber": {
|
||||
"type": "integer",
|
||||
"title": "Control Port Number on the device referenced by controlPortDevKey",
|
||||
"examples": [
|
||||
1
|
||||
]
|
||||
},
|
||||
"controlPortName": {
|
||||
"type": "string",
|
||||
"title": "Control Port Name on the device referenced by controlPortDevKey",
|
||||
"examples": [
|
||||
"hdmi1"
|
||||
]
|
||||
},
|
||||
"irFile": {
|
||||
"type": "string",
|
||||
"title": "IR Filename",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"Comcast Motorola DVR.ir"
|
||||
],
|
||||
"pattern": "^(.*).ir$"
|
||||
},
|
||||
"ipid": {
|
||||
"type": "string",
|
||||
"title": "IPID of the device",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"13",
|
||||
"03",
|
||||
"0A",
|
||||
"F1"
|
||||
],
|
||||
"pattern": "^(?!00|01|02|FF)[0-9,A-F,a-f][0-9,A-F,a-f]$"
|
||||
},
|
||||
"endOfLineChar": {
|
||||
"type": "string",
|
||||
"title": "End of Line Character",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"\\x0d"
|
||||
]
|
||||
},
|
||||
"endOfLineString": {
|
||||
"type": "string",
|
||||
"title": "End of Line String",
|
||||
"default": "",
|
||||
"examples": [
|
||||
"\\n"
|
||||
]
|
||||
},
|
||||
"deviceReadyResponsePattern": {
|
||||
"type": "string",
|
||||
"title": "Response Pattern that indicates the device is ready to communicate",
|
||||
"default": "",
|
||||
"examples": [
|
||||
".*>"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"method"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"type": "object",
|
||||
"title": "ControlPropertiesConfig",
|
||||
"$ref": "#/definitions/TcpSshPropertiesConfig",
|
||||
"definitions": {
|
||||
"TcpSshPropertiesConfig": {
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string",
|
||||
"title": "Username Credential",
|
||||
"default":"",
|
||||
"examples": [
|
||||
"admin"
|
||||
],
|
||||
"pattern": "^(.*)$"
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"title": "Port Number",
|
||||
"minimum": 1,
|
||||
"maximum": 65535,
|
||||
"examples": [
|
||||
22,
|
||||
23,
|
||||
1515
|
||||
]
|
||||
},
|
||||
"address": {
|
||||
"type": "string",
|
||||
"title": "IP address or hostname",
|
||||
"examples": [
|
||||
"192.168.99.100",
|
||||
"myDeviceHostname"
|
||||
],
|
||||
"pattern": "^(.*)$"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"title": "Password Credential",
|
||||
"default":"",
|
||||
"examples": [
|
||||
"password"
|
||||
],
|
||||
"pattern": "^(.*)$"
|
||||
},
|
||||
"autoReconnect": {
|
||||
"type": "boolean",
|
||||
"title": "Auto Reconnect",
|
||||
"default": true,
|
||||
"examples": [
|
||||
true
|
||||
]
|
||||
},
|
||||
"autoReconnectIntervalMs": {
|
||||
"type": "integer",
|
||||
"title": "Auto Reconnect Interval in Ms",
|
||||
"default": 5000,
|
||||
"examples": [
|
||||
2000
|
||||
]
|
||||
},
|
||||
"bufferSize": {
|
||||
"type": "integer",
|
||||
"title": "Receive Buffer Size",
|
||||
"default": 32768,
|
||||
"examples": [
|
||||
32768
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"port",
|
||||
"address"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,8 @@ using Newtonsoft.Json;
|
||||
namespace PepperDash.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration properties for TCP/SSH Connections
|
||||
/// </summary>
|
||||
|
||||
/// Configuration properties for IP Connections
|
||||
/// </summary>
|
||||
public class TcpSshPropertiesConfig : PropertiesConfigBase
|
||||
{
|
||||
/// <summary>
|
||||
@@ -51,91 +50,11 @@ namespace PepperDash.Core
|
||||
/// </summary>
|
||||
public int AutoReconnectIntervalMs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Construtor
|
||||
/// </summary>
|
||||
public TcpSshPropertiesConfig()
|
||||
{
|
||||
SchemaJson = @"
|
||||
{
|
||||
'definitions': {},
|
||||
'$schema': 'http://json-schema.org/draft-07/schema#',
|
||||
'$id': 'http://example.com/root.json',
|
||||
'type': 'object',
|
||||
'title': 'The Root Schema',
|
||||
'properties': {
|
||||
'username': {
|
||||
'$id': '#/properties/username',
|
||||
'type': 'string',
|
||||
'title': 'The Username Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'admin'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'port': {
|
||||
'$id': '#/properties/port',
|
||||
'type': 'integer',
|
||||
'title': 'The Port Schema',
|
||||
'default': 0,
|
||||
'examples': [
|
||||
22
|
||||
]
|
||||
},
|
||||
'address': {
|
||||
'$id': '#/properties/address',
|
||||
'type': 'string',
|
||||
'title': 'The Address Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'10.11.50.135'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'password': {
|
||||
'$id': '#/properties/password',
|
||||
'type': 'string',
|
||||
'title': 'The Password Schema',
|
||||
'default': '',
|
||||
'examples': [
|
||||
'password'
|
||||
],
|
||||
'pattern': '^(.*)$'
|
||||
},
|
||||
'autoReconnect': {
|
||||
'$id': '#/properties/autoReconnect',
|
||||
'type': 'boolean',
|
||||
'title': 'The Autoreconnect Schema',
|
||||
'default': false,
|
||||
'examples': [
|
||||
true
|
||||
]
|
||||
},
|
||||
'autoReconnectIntervalMs': {
|
||||
'$id': '#/properties/autoReconnectIntervalMs',
|
||||
'type': 'integer',
|
||||
'title': 'The Autoreconnectintervalms Schema',
|
||||
'default': 0,
|
||||
'examples': [
|
||||
2000
|
||||
]
|
||||
},
|
||||
'bufferSize': {
|
||||
'$id': '#/properties/bufferSize',
|
||||
'type': 'integer',
|
||||
'title': 'The Buffersize Schema',
|
||||
'default': 0,
|
||||
'examples': [
|
||||
32768
|
||||
]
|
||||
}
|
||||
},
|
||||
'required': [
|
||||
'port',
|
||||
'address'
|
||||
]
|
||||
}
|
||||
";
|
||||
|
||||
|
||||
BufferSize = 32768;
|
||||
AutoReconnect = true;
|
||||
AutoReconnectIntervalMs = 5000;
|
||||
|
||||
@@ -123,6 +123,12 @@
|
||||
<Compile Include="WebApi\Presets\Preset.cs" />
|
||||
<Compile Include="WebApi\Presets\User.cs" />
|
||||
<Compile Include="WebApi\Presets\WebApiPasscodeClient.cs" />
|
||||
<EmbeddedResource Include="Comm\Schema\ControlPropertiesConfigSchema.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Comm\Schema\TcpSshPropertiesConfigSchema.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\ControlSystem.cfg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
||||
|
||||
Reference in New Issue
Block a user