-
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.
Adding simple processor thread interface (#8)
* Adding simple sensor thread interface * Adding simple style guides (#7) * Adding simple style guides * Update style.hpp * [Broken]: For Display purposes only * IO Processor interface * Adding cpp file for IOProc and moving to includes * Adding simple sensor thread interface * [Broken]: For Display purposes only * IO Processor interface * Adding cpp file for IOProc and moving to includes * Fixing include gaurds * Removing unnecessary spaces in cmakelists
- Loading branch information
Showing
6 changed files
with
127 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* | ||
* Stores the interface for building a sensor thread | ||
* implementation. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef SENSOR_INTERFACE_HPP | ||
#define SENSOR_INTERFACE_HPP | ||
|
||
|
||
#include <stdio.h> | ||
#include <Windows.h> | ||
|
||
|
||
class IOProcessor | ||
{ | ||
public: | ||
// Thread routine for implementation to override | ||
virtual VOID threadRuntime() = 0; | ||
// Thread initialization, should not be called directly! | ||
static DWORD threadInit(LPVOID pIOProcessor); | ||
|
||
// Async control | ||
UINT8 startThread(LPVOID pThreadArgs); | ||
BOOL waitForThread(); | ||
|
||
// Sync control | ||
BOOLEAN bufferDataAvailable(); | ||
SIZE_T getBufferData(LPCSTR* bufferKeyArray, LPCSTR* bufferValueArray); | ||
VOID setDataStoreValue(LPCSTR key, LPCVOID value, SIZE_T valueSize); | ||
protected: | ||
LPCVOID threadArgs; | ||
DWORD dwThreadId; | ||
HANDLE hThread; | ||
|
||
}; | ||
|
||
#endif |
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,7 +1,17 @@ | ||
#include <stdio.h> | ||
|
||
#include "io/out_procs/VirtualOutputProcessor.hpp" | ||
|
||
|
||
int main() { | ||
printf("Hello world!\n"); | ||
|
||
int threadID = 0; | ||
IOProcessor *processor; | ||
processor = new VirtualOutputProcessor(); | ||
processor->startThread(&threadID); | ||
|
||
processor->waitForThread(); | ||
delete processor; | ||
|
||
return 0; | ||
} |
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,43 @@ | ||
|
||
#include "IOProcessor.hpp" | ||
|
||
|
||
DWORD IOProcessor::threadInit(LPVOID pIOProcessor) | ||
{ | ||
((IOProcessor*) pIOProcessor)->threadRuntime(); | ||
return 0; | ||
} | ||
|
||
UINT8 IOProcessor::startThread(LPVOID pThreadArgs) | ||
{ | ||
this->threadArgs = pThreadArgs; | ||
hThread = CreateThread( | ||
NULL, // default security attributes | ||
0, // use default stack size | ||
threadInit, // thread function name | ||
this, // argument to thread function | ||
0, // use default creation flags | ||
&dwThreadId); // returns the thread identifier | ||
return TRUE; | ||
} | ||
|
||
BOOL IOProcessor::waitForThread() | ||
{ | ||
WaitForSingleObject(hThread, INFINITE); | ||
return TRUE; | ||
} | ||
|
||
BOOLEAN bufferDataAvailable() | ||
{ | ||
return FALSE; | ||
} | ||
|
||
SIZE_T getBufferData(LPCSTR* bufferKeyArray, LPCSTR* bufferValueArray) | ||
{ | ||
return 0; | ||
} | ||
|
||
VOID setDataStoreValue(LPCSTR key, LPCVOID value, SIZE_T valueSize) | ||
{ | ||
|
||
} |
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,8 @@ | ||
|
||
#include "VirtualOutputProcessor.hpp" | ||
|
||
|
||
void VirtualOutputProcessor::threadRuntime() | ||
{ | ||
printf("VirtualOutputProcessor %d started.\n", *((int*) threadArgs)); | ||
} |
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,17 @@ | ||
|
||
#ifndef VIRTUAL_OUTPUT_PROCESSOR_HPP | ||
#define VIRTUAL_OUTPUT_PROCESSOR_HPP | ||
|
||
|
||
#include <stdio.h> | ||
|
||
#include "IOProcessor.hpp" | ||
|
||
|
||
class VirtualOutputProcessor : public IOProcessor | ||
{ | ||
public: | ||
void threadRuntime(); | ||
}; | ||
|
||
#endif |