create IrDaemonNotifier project, that transmits to the irdaemon code to start race
This commit is contained in:
parent
2bc7ef9898
commit
ec05233e79
77
RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.cs
Normal file
77
RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Interfaces;
|
||||||
|
|
||||||
|
namespace IrDaemonNotifier
|
||||||
|
{
|
||||||
|
public class IrDaemonNotifier : INotifierProvider
|
||||||
|
{
|
||||||
|
private const int REMOTE_PORT_NO = 3006;
|
||||||
|
private const string REMOTE_SERVER_IP = "127.0.0.1";
|
||||||
|
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public IrDaemonNotifier(ILoggerService logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetDisplayName()
|
||||||
|
{
|
||||||
|
return "Ir Daemon Notifier";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetNotifierType()
|
||||||
|
{
|
||||||
|
return nameof(IrDaemonNotifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyRaceStarted(NotificationEventArgs args)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//---data to send to the server---
|
||||||
|
var message = string.Format("#{0}#\n", "RESET");
|
||||||
|
|
||||||
|
//---create a TCPClient object at the IP and port no.---
|
||||||
|
var client = new TcpClient(REMOTE_SERVER_IP, REMOTE_PORT_NO);
|
||||||
|
var nwStream = client.GetStream();
|
||||||
|
var bytesToSend = Encoding.ASCII.GetBytes(message);
|
||||||
|
|
||||||
|
//---send the text---
|
||||||
|
_logger.Trace("Sending: {0}", message);
|
||||||
|
nwStream.Write(bytesToSend, 0, bytesToSend.Length);
|
||||||
|
|
||||||
|
//---read back the text---
|
||||||
|
var bytesToRead = new byte[client.ReceiveBufferSize];
|
||||||
|
var bytesRead = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize);
|
||||||
|
_logger.Trace("Received: {0}", Encoding.ASCII.GetString(bytesToRead, 0, bytesRead));
|
||||||
|
client.Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Error(ex, "IrDaemonNotifier Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyRaceStarting(NotificationEventArgs args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyRaceLapEvent(NotificationEventArgs args, Pilot pilot)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyRaceWinner(NotificationEventArgs args, Pilot pilot)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NotifyRaceFinished(NotificationEventArgs args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj
Normal file
61
RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>IrDaemonNotifier</RootNamespace>
|
||||||
|
<AssemblyName>IrDaemonNotifier</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="IrDaemonNotifier.cs" />
|
||||||
|
<Compile Include="IrDaemonNotifierProviderFactory.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
|
||||||
|
<Project>{5C6DCC59-19F3-46AD-A479-926610F36257}</Project>
|
||||||
|
<Name>Interfaces</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Interfaces;
|
||||||
|
|
||||||
|
namespace IrDaemonNotifier
|
||||||
|
{
|
||||||
|
public class IrDaemonNotifierProviderFactory:INotifierProviderFactory
|
||||||
|
{
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public IrDaemonNotifierProviderFactory(ILoggerService logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
public INotifierProvider CreateProvider()
|
||||||
|
{
|
||||||
|
return new IrDaemonNotifier(_logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
public new string GetType()
|
||||||
|
{
|
||||||
|
return nameof(IrDaemonNotifierProviderFactory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
RaceLapTimer/IrDaemonNotifier/Properties/AssemblyInfo.cs
Normal file
36
RaceLapTimer/IrDaemonNotifier/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("IrDaemonNotifier")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("IrDaemonNotifier")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("916994f6-1711-4aeb-8de6-4ab6fcb3f080")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UdpNotifier", "UdpNotifier\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logger", "Logger", "{36BDEE78-985C-4AF5-A39B-3BE89FAEB281}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Logger", "Logger", "{36BDEE78-985C-4AF5-A39B-3BE89FAEB281}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IrDaemonNotifier", "IrDaemonNotifier\IrDaemonNotifier.csproj", "{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -49,6 +51,10 @@ Global
|
|||||||
{734097B0-A764-40AD-957A-43FE4F085B65}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{734097B0-A764-40AD-957A-43FE4F085B65}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{734097B0-A764-40AD-957A-43FE4F085B65}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{734097B0-A764-40AD-957A-43FE4F085B65}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{734097B0-A764-40AD-957A-43FE4F085B65}.Release|Any CPU.Build.0 = Release|Any CPU
|
{734097B0-A764-40AD-957A-43FE4F085B65}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -56,5 +62,6 @@ Global
|
|||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{9A93A12F-7591-406A-A4F3-41AA8299C4B4} = {36BDEE78-985C-4AF5-A39B-3BE89FAEB281}
|
{9A93A12F-7591-406A-A4F3-41AA8299C4B4} = {36BDEE78-985C-4AF5-A39B-3BE89FAEB281}
|
||||||
{734097B0-A764-40AD-957A-43FE4F085B65} = {CDAC76D5-5EC6-4357-A27C-0095BF98FDDF}
|
{734097B0-A764-40AD-957A-43FE4F085B65} = {CDAC76D5-5EC6-4357-A27C-0095BF98FDDF}
|
||||||
|
{916994F6-1711-4AEB-8DE6-4AB6FCB3F080} = {CDAC76D5-5EC6-4357-A27C-0095BF98FDDF}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user