Skip to content

Commit

Permalink
Issue 5: Command-line driver
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanP committed Jun 2, 2012
1 parent 30110c0 commit 9b4c9bb
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ BOOST_AUTO_TEST_CASE( CONNECT_TO_SIM ) {
IEvent::Service::iRacingReader reader;

reader.setIsRunning(true);
reader.setRunOnce(true);

reader.run();
}
21 changes: 8 additions & 13 deletions ievent-service/ievent-service/irreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

IEvent::Service::iRacingReader::iRacingReader ():
_running(false),
_runOnce(false),
_connected(false),
_timeout(60000),
_g_data(NULL),
Expand Down Expand Up @@ -43,6 +44,10 @@ void IEvent::Service::iRacingReader::setIsRunning(bool isRunning) {
_running = isRunning;
}

void IEvent::Service::iRacingReader::setRunOnce(bool runOnce) {
_runOnce = runOnce;
}

bool IEvent::Service::iRacingReader::init() {
// Initialize network comms
_pub = PublisherPtr( new Publisher() );
Expand Down Expand Up @@ -74,7 +79,9 @@ bool IEvent::Service::iRacingReader::init() {
bool IEvent::Service::iRacingReader::shutdown() {
_handlers.clear();
_connected = false;
_running = false; // For testing only!
if (_runOnce) {
_running = false; // For testing only!
}

_pub = PublisherPtr();

Expand Down Expand Up @@ -106,18 +113,6 @@ void IEvent::Service::iRacingReader::run() {
BOOST_FOREACH(UpdatePtr handler, _handlers) {
handler->handleUpdate(pHeader, _g_data);
}
/*std::cerr<< irsdk_getSessionInfoStr() << std::endl;*/
/*
if (pHeader->numVars > 0) {
for(int i=0; i<pHeader->numVars; i++) {
const irsdk_varHeader *rec = irsdk_getVarHeaderEntry(i);
std::cerr << "Name: " << rec->name << std::endl;
}
} else {
std::cerr<< "No vars in header!" << std::endl;
}
*/

}
} else if (_connected && irsdk_isConnected()) {
Expand Down
2 changes: 2 additions & 0 deletions ievent-service/ievent-service/irreader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace IEvent {
void run();

void setIsRunning(bool isRunning);
void setRunOnce(bool runOnce);
bool isRunning();
private:

Expand All @@ -26,6 +27,7 @@ namespace IEvent {
const irsdk_header *pHeader;

bool _running;
bool _runOnce;
bool _connected;
char * _g_data;
int _g_nData;
Expand Down
40 changes: 40 additions & 0 deletions ievent/ievent-service-cmdline/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : ievent-service-cmdline Project Overview
========================================================================

AppWizard has created this ievent-service-cmdline application for you.

This file contains a summary of what you will find in each of the files that
make up your ievent-service-cmdline application.


ievent-service-cmdline.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

ievent-service-cmdline.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).

ievent-service-cmdline.cpp
This is the main application source file.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named ievent-service-cmdline.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////
21 changes: 21 additions & 0 deletions ievent/ievent-service-cmdline/ievent-service-cmdline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// ievent-service-cmdline.cpp : Defines the entry point for the console application.
//

#include <stdafx.h>
#include <Windows.h>

#include "irreader.hpp"


int main(int argc, char* argv[])
{
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);

IEvent::Service::iRacingReader reader;

reader.setIsRunning(true);
reader.setRunOnce(true);

reader.run();
}

100 changes: 100 additions & 0 deletions ievent/ievent-service-cmdline/ievent-service-cmdline.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
</PropertyGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
<RootNamespace>ieventservicecmdline</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\lib\yaml-cpp\include;C:\lib\zeromq-2.1.11\include;C:\lib\boost_1_49_0;C:\src\ievent\ievent-service\ievent-service;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\src\ievent\ievent\Debug;C:\lib\boost_1_49_0\stage\lib;C:\lib\zeromq-2.1.11\builds\msvc\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>libzmq.lib;ievent-service.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\lib\yaml-cpp\include;C:\lib\zeromq-2.1.11\include;C:\lib\boost_1_49_0;C:\src\ievent\ievent-service\ievent-service;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libzmq.lib;ievent-service.lib;libyaml-cppmd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\lib\yaml-cpp\Release;C:\src\ievent\ievent\Release;C:\lib\boost_1_49_0\stage\lib;C:\lib\zeromq-2.1.11\builds\msvc\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="ievent-service-cmdline.cpp" />
<ClCompile Include="stdafx.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ievent-service-cmdline.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions ievent/ievent-service-cmdline/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// ievent-service-cmdline.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
15 changes: 15 additions & 0 deletions ievent/ievent-service-cmdline/stdafx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here
8 changes: 8 additions & 0 deletions ievent/ievent-service-cmdline/targetver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// Including SDKDDKVer.h defines the highest available Windows platform.

// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.

#include <SDKDDKVer.h>
6 changes: 6 additions & 0 deletions ievent/ievent.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ievent-service-test", "..\i
{DDDD4071-F05D-A7CC-0D9A-2984F2D42029} = {DDDD4071-F05D-A7CC-0D9A-2984F2D42029}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ievent-service-cmdline", "ievent-service-cmdline\ievent-service-cmdline.vcxproj", "{5CC946EA-A95D-01A7-CF1A-83BDBF0AA051}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand All @@ -18,6 +20,10 @@ Global
{17773076-D2B1-9C94-2114-93D580061B67}.Debug|Win32.Build.0 = Debug|Win32
{17773076-D2B1-9C94-2114-93D580061B67}.Release|Win32.ActiveCfg = Release|Win32
{17773076-D2B1-9C94-2114-93D580061B67}.Release|Win32.Build.0 = Release|Win32
{5CC946EA-A95D-01A7-CF1A-83BDBF0AA051}.Debug|Win32.ActiveCfg = Debug|Win32
{5CC946EA-A95D-01A7-CF1A-83BDBF0AA051}.Debug|Win32.Build.0 = Debug|Win32
{5CC946EA-A95D-01A7-CF1A-83BDBF0AA051}.Release|Win32.ActiveCfg = Release|Win32
{5CC946EA-A95D-01A7-CF1A-83BDBF0AA051}.Release|Win32.Build.0 = Release|Win32
{DDDD4071-F05D-A7CC-0D9A-2984F2D42029}.Debug|Win32.ActiveCfg = Debug|Win32
{DDDD4071-F05D-A7CC-0D9A-2984F2D42029}.Debug|Win32.Build.0 = Debug|Win32
{DDDD4071-F05D-A7CC-0D9A-2984F2D42029}.Release|Win32.ActiveCfg = Release|Win32
Expand Down

0 comments on commit 9b4c9bb

Please sign in to comment.