Correct commands in IrDaemonCommunicator to add in the missing '#' character and missing StartNewRace command.
Implement the irDaemon shutdown method, with logging. (IrDaemonController, IrDaemonControllerProviderFactory) Implement using correct commands for StartNewRace and RaceFinished in IrDaemonNotifier. Move PluginDetails to their own class as used by many classes/extensions.
This commit is contained in:
parent
d207d9448b
commit
27a6ae4631
@ -10,7 +10,7 @@ namespace IrDaemonNotifier
|
|||||||
private const int IRDAEMON_PORT_NO = 3006;
|
private const int IRDAEMON_PORT_NO = 3006;
|
||||||
private const int IRDAEMON_PROPERTY_PORT_NO = 3007;
|
private const int IRDAEMON_PROPERTY_PORT_NO = 3007;
|
||||||
|
|
||||||
private ILoggerService _logger;
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
public IrDaemonCommunicator(ILoggerService logger)
|
public IrDaemonCommunicator(ILoggerService logger)
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ namespace IrDaemonNotifier
|
|||||||
//TODO: convert to use an enum value perhaps? "supported command" style?
|
//TODO: convert to use an enum value perhaps? "supported command" style?
|
||||||
public void SendCommand(string command)
|
public void SendCommand(string command)
|
||||||
{
|
{
|
||||||
var formattedCommand = FormatCommand(command);
|
var formattedCommand = command;//FormatCommand(command); //seems we may not actually need any formatting..
|
||||||
|
|
||||||
//---create a TCPClient object at the IP and port no.---
|
//---create a TCPClient object at the IP and port no.---
|
||||||
var client = new TcpClient(IRDAEMON_SERVER_IP, IRDAEMON_PORT_NO);
|
var client = new TcpClient(IRDAEMON_SERVER_IP, IRDAEMON_PORT_NO);
|
||||||
@ -131,7 +131,8 @@ namespace IrDaemonNotifier
|
|||||||
public const string GetLastToken = "LAST_SCANNED_TOKEN";
|
public const string GetLastToken = "LAST_SCANNED_TOKEN";
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string Shutdown = "SHUTDOWN";
|
public const string Shutdown = "SHUTDOWN#";
|
||||||
public const string Reset = "RESET";
|
public const string Reset = "RESET#";
|
||||||
|
public const string StartNewRace = "START_NEW_RACE#";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,30 @@
|
|||||||
using System.Diagnostics;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using Interfaces;
|
using Interfaces;
|
||||||
|
|
||||||
namespace IrDaemonNotifier
|
namespace IrDaemonNotifier
|
||||||
{
|
{
|
||||||
public class IrDaemonController:ISystemControlProvider
|
public class IrDaemonController:ISystemControlProvider
|
||||||
{
|
{
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public IrDaemonController(ILoggerService logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
public void Shutdown()
|
public void Shutdown()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("test");
|
Debug.WriteLine("Shutdown controller");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var communicator = new IrDaemonCommunicator(_logger);
|
||||||
|
communicator.SendCommand(Commands.Shutdown);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "IrDaemonController Shutdown Error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginDetails GetPluginDetails()
|
public PluginDetails GetPluginDetails()
|
||||||
|
|||||||
@ -4,9 +4,16 @@ namespace IrDaemonNotifier
|
|||||||
{
|
{
|
||||||
public class IrDaemonControllerProviderFactory : ISystemControlProviderFactory
|
public class IrDaemonControllerProviderFactory : ISystemControlProviderFactory
|
||||||
{
|
{
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public IrDaemonControllerProviderFactory(ILoggerService logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
public ISystemControlProvider GetProvider()
|
public ISystemControlProvider GetProvider()
|
||||||
{
|
{
|
||||||
return new IrDaemonController();
|
return new IrDaemonController(_logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,11 +27,11 @@ namespace IrDaemonNotifier
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var communicator = new IrDaemonCommunicator(_logger);
|
var communicator = new IrDaemonCommunicator(_logger);
|
||||||
communicator.SendCommand(Commands.Reset);
|
communicator.SendCommand(Commands.StartNewRace);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Error(ex, "IrDaemonNotifier Error");
|
_logger.Error(ex, "IrDaemonNotifier NotifyRaceStarted Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +49,15 @@ namespace IrDaemonNotifier
|
|||||||
|
|
||||||
public void NotifyRaceFinished(NotificationEventArgs args)
|
public void NotifyRaceFinished(NotificationEventArgs args)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var communicator = new IrDaemonCommunicator(_logger);
|
||||||
|
communicator.SendCommand(Commands.Reset);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "IrDaemonNotifier NotifyRaceFinished Error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ using Interfaces;
|
|||||||
|
|
||||||
namespace IrDaemonNotifier
|
namespace IrDaemonNotifier
|
||||||
{
|
{
|
||||||
|
// TODO: The irDaemon will support tcp connections so that it will publish tokens
|
||||||
|
// TODO: as they get received rather than need to request them.
|
||||||
public class IrDaemonTransponderUtilities : ITransponderUtilityProvider
|
public class IrDaemonTransponderUtilities : ITransponderUtilityProvider
|
||||||
{
|
{
|
||||||
private readonly ILoggerService _logger;
|
private readonly ILoggerService _logger;
|
||||||
|
|||||||
@ -4,6 +4,6 @@ namespace IrDaemonNotifier
|
|||||||
{
|
{
|
||||||
public static class Resources
|
public static class Resources
|
||||||
{
|
{
|
||||||
public static readonly PluginDetails Details = new PluginDetails("IrDaemonNotifier", "Chris Watts", "IR Daemon Interface", "1.0.0.0");
|
public static readonly PluginDetails Details = new PluginDetails("IrDaemonNotifier", "Chris Watts", "IR Daemon Interface", "1.0.0.0", "IR Daemon Notifier");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user