Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #13 from grf14003/dev
Updating master with the dev at the break in semesters
- Loading branch information
Showing
33 changed files
with
728 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
.vs/* | ||
|
||
# Excluding the build and executable folders | ||
breadcrumbs/build/* | ||
!breadcrumbs/build/.blank | ||
breadcrumbs/bin/* | ||
!breadcrumbs/bin/.blank |
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,5 @@ | ||
# Sensory Biofeedback System | ||
## Nich Chan, Greg Foss, Matt Scalzo & Nate Shaw | ||
|
||
|
||
This is our Senior Design Project. Our goal is to create a system that can interpret 3D data and give meaningful feedback through a belt of tactile motors. |
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,6 @@ | ||
// the configured options and settings for Tutorial | ||
|
||
#define VERSION_MAJOR @Bfs_VERSION_MAJOR@ | ||
#define VERSION_MINOR @Bfs_VERSION_MINOR@ | ||
|
||
#define ALGORITHM_SERVER_PORT @Bfs_ALGORITHM_SERVER_PORT@ |
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,47 @@ | ||
# This file controls the build process. When you save it, VS figures out what types of executables that it builds. | ||
# Then, you can switch the executable that you want to run at the top from the drop down and hit run to build and | ||
# run it. | ||
# | ||
|
||
cmake_minimum_required (VERSION 2.6) | ||
|
||
message("Starting CMAKE") | ||
project (Breadcrumbs) | ||
# The version number. | ||
set (Bfs_VERSION_MAJOR 1) | ||
set (Bfs_VERSION_MINOR 0) | ||
|
||
# Setting paths | ||
message("Setting paths...") | ||
set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src) # Code directory | ||
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR}/build) # Object files and such (.o) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) # Compiled executables for execution and test (.exe) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib) # Compiled libraries (.lib and .dll) | ||
set(CMAKE_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/include) # Publicly accessible header files | ||
message("Root directory: ${PROJECT_SOURCE_DIR}") | ||
message("Source directory: ${CMAKE_SOURCE_DIR}") | ||
message("Build directory: ${CMAKE_BINARY_DIR}") | ||
message("Executable directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") | ||
message("Library directory: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") | ||
message("Header file directory: ${INCLUDES_DIRECTORY}") | ||
|
||
# Configure a header file to pass some of the CMake settings to the source code | ||
set (Bfs_ALGORITHM_SERVER_PORT \"27634\") | ||
|
||
configure_file ( | ||
"${PROJECT_SOURCE_DIR}/CMakeConfig.h.in" | ||
"${CMAKE_INCLUDE_PATH}/CMakeConfig.h" | ||
) | ||
|
||
# Adding public includes to include search path | ||
include_directories("${CMAKE_INCLUDE_PATH}") | ||
# Adding private include files from source tree | ||
include_directories("${CMAKE_SOURCE_DIR}") | ||
|
||
# puts all .cpp files inside src to the SOURCES variable | ||
# TODO: replace this with a script for collecting cpp files | ||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/*.cpp") | ||
message("Source files: ${SOURCES}") | ||
|
||
# Adding executables | ||
add_executable(Breadcrumbs ${SOURCES}) |
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,16 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "basic_build", | ||
"generator": "Ninja", | ||
"configurationType": "Debug", | ||
"inheritEnvironments": [ "msvc_x64_x64" ], | ||
"buildRoot": "${projectDir}\\build\\${name}", | ||
"installRoot": "${projectDir}\\install\\${name}", | ||
"cmakeCommandArgs": "", | ||
"buildCommandArgs": "-v", | ||
"ctestCommandArgs": "", | ||
"variables": [] | ||
} | ||
] | ||
} |
Empty file.
Empty file.
File renamed without changes.
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,20 @@ | ||
/* | ||
This file correspondes to style.hpp and is an example of | ||
the .cpp files that would correspond to the .hpp file. | ||
*/ | ||
|
||
|
||
#include "style.hpp" | ||
|
||
|
||
char TestClass::attrTwoTimesTwo() | ||
{ | ||
return c_attrTwo << 1 | ||
} | ||
|
||
int TestClass::getAttrSum() | ||
{ | ||
return c_attrTwo + i_attrOne | ||
} |
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,39 @@ | ||
/* | ||
* | ||
* This file contains the style of each programming construct | ||
* to use in this project. | ||
* | ||
* It should be followed to the letter! All spaces are | ||
* necessary! Make sure to take note of camel case and other | ||
* variable naming schemes! | ||
* | ||
*/ | ||
|
||
#ifndef STYLE_HPP | ||
#define STYLE_HPP | ||
|
||
#include <stdio.h> | ||
|
||
#include "style.hpp" | ||
|
||
// Header File: | ||
class TestClass | ||
{ | ||
public: | ||
// Constructors | ||
TestClass(int AttrOne, char AttrTwo); | ||
// Mutator methods | ||
int getAttrSum(); | ||
char attrTwoTimesTwo(); | ||
void setAttrOne(int newAttrOne) { i_attrOne = newAttrOne } | ||
void setAttrTwo(char newAttrTwo) { c_attrTwo = newAttrTwo } | ||
// Accessor methods | ||
int getAttrOne() { return i_attrOne } | ||
char getAttrTwo() { return c_attrTwo } | ||
private: | ||
// Private variables | ||
int i_attrOne = 0; | ||
char c_attrTwo; | ||
}; | ||
|
||
#endif |
Empty file.
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,18 @@ | ||
|
||
#ifndef ALGO_BREADCRUMBS_HPP | ||
#define ALGO_BREADCRUMBS_HPP | ||
|
||
#include "Algorithm.hpp" | ||
|
||
class AlgoBreadcrumbs : public Algorithm | ||
{ | ||
public: | ||
using Algorithm::Algorithm; | ||
|
||
void loop(); | ||
bool loopCondition(); | ||
private: | ||
INT iterations = 1; | ||
}; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
#ifndef ALGORITHM_HPP | ||
#define ALGORITHM_HPP | ||
|
||
#include "AlgorithmServer.hpp" | ||
|
||
class Algorithm | ||
{ | ||
public: | ||
explicit Algorithm(size_t numProcs); | ||
~Algorithm(); | ||
|
||
virtual void loop() = 0; | ||
virtual bool loopCondition() { return false; }; | ||
private: | ||
size_t numIoProcs = 0; | ||
AlgorithmServer* server; | ||
}; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
#ifndef ALGORITHM_SERVER_HPP | ||
#define ALGORITHM_SERVER_HPP | ||
|
||
|
||
#undef UNICODE | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
|
||
#include <windows.h> | ||
#include <winsock2.h> | ||
#include <ws2tcpip.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <vector> | ||
|
||
#include "CMakeConfig.h" | ||
#include "DataSyncThread.hpp" | ||
|
||
#define ALGORITHM_PORT "10101" | ||
#define MAX_ACCEPT_FAILURES 5 | ||
|
||
#pragma comment (lib, "Ws2_32.lib") | ||
|
||
class AlgorithmServer | ||
{ | ||
public: | ||
AlgorithmServer(size_t numClients); | ||
~AlgorithmServer(); | ||
|
||
void serverThreadRuntime(); | ||
static DWORD serverThreadInit(LPVOID pThreadArgs) | ||
{ | ||
AlgorithmServer* pAlgorithmServerThread = (AlgorithmServer*)pThreadArgs; | ||
pAlgorithmServerThread->serverThreadRuntime(); | ||
return NULL; | ||
} | ||
|
||
// Updates Algorithm key/value store with IO key/value updates | ||
void pollForUpdates(); | ||
void startServer(); | ||
void stopServer(); | ||
|
||
private: | ||
HANDLE hThread; | ||
DWORD dwThreadId; | ||
bool continueThread = false; | ||
|
||
size_t numClients; | ||
std::vector<DataSyncThread> clientThreads; | ||
}; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef ATTRIBUTE_HPP | ||
#define ATTRIBUTE_HPP | ||
|
||
typedef struct BinaryAttributeStructure { | ||
char key[8]; | ||
unsigned char length[2]; | ||
} bAttrib; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// the configured options and settings for Tutorial | ||
|
||
#define VERSION_MAJOR 1 | ||
#define VERSION_MINOR 0 | ||
|
||
#define ALGORITHM_SERVER_PORT "27634" |
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,51 @@ | ||
|
||
#ifndef DATA_SYNC_THREAD_HPP | ||
#define DATA_SYNC_THREAD_HPP | ||
|
||
#define WIN32_LEAN_AND_MEAN | ||
|
||
#include <windows.h> | ||
#include <winsock2.h> | ||
#include <ws2tcpip.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
|
||
#include "Attribute.hpp" | ||
#include "CMakeConfig.h" | ||
|
||
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib | ||
#pragma comment (lib, "Ws2_32.lib") | ||
#pragma comment (lib, "Mswsock.lib") | ||
#pragma comment (lib, "AdvApi32.lib") | ||
|
||
/* | ||
This class contains the thread for communicating back and forth along a socket to sync attributes | ||
*/ | ||
class DataSyncThread | ||
{ | ||
private: | ||
SOCKET sock; | ||
HANDLE hThread; | ||
DWORD dwThreadId; | ||
bool continueThread = false; | ||
public: | ||
DataSyncThread(SOCKET s) { sock = s; }; | ||
|
||
// Synchronous functions | ||
void threadRuntime(); | ||
static DWORD threadInit(LPVOID pThreadArgs) | ||
{ | ||
DataSyncThread* pDataSyncThread = (DataSyncThread*)pThreadArgs; | ||
pDataSyncThread->threadRuntime(); | ||
return NULL; | ||
} | ||
int recvBytes(void* buffer, size_t numBytes); | ||
|
||
// Async control | ||
void startComms(); | ||
bool stopComms(); | ||
int connectToAlgorithm(char* serverName); | ||
}; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#ifndef IO_PROCESSOR_HPP | ||
#define IO_PROCESSOR_HPP | ||
|
||
|
||
#include <stdio.h> | ||
#include <Windows.h> | ||
|
||
|
||
/* | ||
This class is the class that abstracts the io processor side of the data exchange between | ||
IO processors and algorithms | ||
*/ | ||
class IOProcessor | ||
{ | ||
public: | ||
IOProcessor() {}; | ||
|
||
// Async control | ||
unsigned int startComms(); | ||
bool stopComms(); | ||
|
||
}; | ||
|
||
#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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
#ifndef VIRTUAL_OUTPUT_PROCESSOR_HPP | ||
#define VIRTUAL_OUTPUT_PROCESSOR_HPP | ||
|
||
|
||
#include <stdio.h> | ||
|
||
#include "IOProcessor.hpp" | ||
|
||
|
||
class VirtualOutputProcessor : public IOProcessor | ||
{ | ||
public: | ||
using IOProcessor::IOProcessor; | ||
|
||
void threadRuntime(IOProcessor* ioProc); | ||
}; | ||
|
||
#endif |
Empty file.
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,24 @@ | ||
|
||
import os | ||
import multiprocessing as mp | ||
import subprocess | ||
|
||
|
||
def start_program(command): | ||
cmd_list = command.split(" ") | ||
return subprocess.call(cmd_list) | ||
|
||
|
||
def start_program_no_hang(command): | ||
print("Running %s from cwd %s" % (command, os.getcwd())) | ||
proc = mp.Process(target=start_program, args=(command,)) | ||
proc.start() | ||
return proc | ||
|
||
|
||
def main(): | ||
start_program_no_hang("start cmd.exe /k \"..\\bin\\Breadcrumbs.exe\"") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.