-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement openshock interface through sdk
- Loading branch information
Showing
28 changed files
with
589 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 14 additions & 30 deletions
44
OpenShock.VoiceRecognizer.Configuration/OpenShockConfigurationState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,32 @@ | ||
using OpenShock.VoiceRecognizer.Common; | ||
using System.Net.Sockets; | ||
using OpenShock.VoiceRecognizer.Common; | ||
|
||
namespace OpenShock.VoiceRecognizer.Configuration; | ||
|
||
public class OpenShockConfigurationState | ||
{ | ||
/*public ReactiveObject<string> APIKey { get; private set; } | ||
public ReactiveObject<string> GroupName { get; private set; }*/ | ||
public ReactiveObject<string> SendHost { get; private set; } | ||
public ReactiveObject<int> SendPort { get; private set; } | ||
|
||
public ReactiveObject<string> ExternalListenSetIntensityEndpoint { get; set; } | ||
public ReactiveObject<string> ExternalSendStartShockEndpoint { get; set; } | ||
public ReactiveObject<string> ExternalSendStartVibrationEndpoint { get; set; } | ||
public ReactiveObject<string> APIKey { get; private set; } | ||
public ReactiveObject<Guid> DeviceID { get; private set; } | ||
public ReactiveObject<Guid> ShockerID { get; private set; } | ||
|
||
public OpenShockConfigurationState() | ||
{ | ||
/*APIKey = new(string.Empty); | ||
GroupName = new(string.Empty);*/ | ||
SendHost = new(string.Empty); | ||
SendPort = new(9006); | ||
ExternalListenSetIntensityEndpoint = new(string.Empty); | ||
ExternalSendStartShockEndpoint = new(string.Empty); | ||
ExternalSendStartVibrationEndpoint = new(string.Empty); | ||
APIKey = new(string.Empty); | ||
DeviceID = new(Guid.Empty); | ||
ShockerID = new(Guid.Empty); | ||
} | ||
|
||
public void LoadFileConfiguration(ConfigurationFileFormat configurationFileFormat) | ||
{ | ||
/*APIKey.Value = configurationFileFormat.OpenShockAPIKey; | ||
GroupName.Value = configurationFileFormat.OpenShockGroupName;*/ | ||
SendHost.Value = configurationFileFormat.OpenShockSendHost; | ||
SendPort.Value = configurationFileFormat.OpenShockSendPort; | ||
ExternalListenSetIntensityEndpoint.Value = configurationFileFormat.OpenShockOscListenIntensityEndpoint; | ||
ExternalSendStartShockEndpoint.Value = configurationFileFormat.OpenShockOscSendShockEndpoint; | ||
ExternalSendStartVibrationEndpoint.Value = configurationFileFormat.OpenShockOscSendVibrateEndpoint; | ||
APIKey.Value = configurationFileFormat.OpenShockAPIKey; | ||
DeviceID.Value = configurationFileFormat.OpenShockDeviceID; | ||
ShockerID.Value = configurationFileFormat.OpenShockShockerID; | ||
} | ||
|
||
public void LoadDefaultConfiguration() | ||
{ | ||
/*APIKey.Value = string.Empty; | ||
GroupName.Value = string.Empty;*/ | ||
SendHost.Value = "127.0.0.1"; | ||
SendPort.Value = 0; | ||
ExternalListenSetIntensityEndpoint.Value = string.Empty; | ||
ExternalSendStartShockEndpoint.Value = string.Empty; | ||
ExternalSendStartVibrationEndpoint.Value = string.Empty; | ||
APIKey.Value = string.Empty; | ||
DeviceID.Value = Guid.Empty; | ||
ShockerID.Value = Guid.Empty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Serilog; | ||
using Serilog.Extensions.Logging; | ||
|
||
namespace OpenShock.VoiceRecognizer.IO.Logger; | ||
|
||
public static class Logger | ||
{ | ||
private static ILoggerFactory? _logFactory; | ||
|
||
public static ILogger<T>? GetLogger<T>() => | ||
_logFactory?.CreateLogger<T>(); | ||
|
||
public static void Initialize() | ||
{ | ||
if (_logFactory is not null) | ||
{ | ||
throw new InvalidOperationException("Log factory already initialize"); | ||
} | ||
|
||
var logConfig = new LoggerConfiguration() | ||
.MinimumLevel.Debug() | ||
.MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information) | ||
.Enrich.FromLogContext() | ||
.WriteTo.Console() | ||
.WriteTo.File("log.txt"); | ||
|
||
Log.Logger = logConfig.CreateLogger(); | ||
|
||
_logFactory = new SerilogLoggerFactory( | ||
Log.Logger | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.