Skip to content

Version 1.0 #19

Merged
merged 50 commits into from May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
94cc09c
First draft adding client code, skeleton of server code.
grf14003 Dec 1, 2019
0c24eb9
Updating working branch with newest commit
grf14003 Dec 5, 2019
1f9bc0a
Submitting current work
ncc14003 Dec 6, 2019
b947e5a
Stabalizing server code and fixing attrib update decoding
grf14003 Jan 16, 2020
a01e7a7
Adding new attribs to vector and allow algorithm to get new values
grf14003 Jan 16, 2020
7ddbee6
Finishing basic attribute update framework
grf14003 Jan 16, 2020
32ef926
Merge branch 'working' into dev
grf14003 Jan 20, 2020
8d66382
Fixing compilation temporarily
grf14003 Jan 20, 2020
40d3d86
Reconfiguring build path and main folder to handle multiple compiled …
grf14003 Jan 28, 2020
7853c71
Automating the addition of new exe files
grf14003 Jan 28, 2020
3595c6f
Adding async start program function to startbfs.py
grf14003 Jan 28, 2020
7808d97
Adding test io processor and onside comms stop
grf14003 Jan 29, 2020
a53e2bc
Adding select to data sync listen thread
grf14003 Jan 29, 2020
dc5f87d
Fixing breadcrumbs server after data sync thread changes
grf14003 Jan 29, 2020
9ddca58
Adding error checking for nonexistent server in virtual output processor
grf14003 Feb 4, 2020
5112b4f
Adding configuration class framework
grf14003 Feb 5, 2020
3b5bad7
Logger header file
ncc14003 Feb 5, 2020
e0a0ecd
Added write_log commands
ncc14003 Feb 5, 2020
6f2cd46
Added write log commands
ncc14003 Feb 5, 2020
2e8ae8e
Added logging stuff
ncc14003 Feb 5, 2020
6b71112
Merge branch 'dev' of https://github.uconn.edu/grf14003/bfs into dev
ncc14003 Feb 5, 2020
c046290
Reverting change
ncc14003 Feb 6, 2020
c0cd1e9
Abstracting IO Processor into its own class
grf14003 Feb 6, 2020
0700c5f
Merging in new main file changes
grf14003 Feb 6, 2020
e62001b
Postponing logger info
ncc14003 Feb 11, 2020
6a9e7bd
Moving algorithm and io proc implementations to separate directory
grf14003 Feb 11, 2020
c2eee1e
Adding template main files for algorithm and io processors
grf14003 Feb 11, 2020
4dbd738
Getting rid of old main functions and adding auto generating main fil…
grf14003 Feb 12, 2020
f39005f
Changing name of cmake project to bfs from breadcrumbs
grf14003 Feb 12, 2020
f34a53c
Adding basic argument parsing to start script
grf14003 Feb 18, 2020
9d5cc72
Adding tdk library and adding modifying build system to account for it
grf14003 Feb 19, 2020
c294c4e
Adding dynamic library function for .dll and .lib files specific to e…
grf14003 Feb 20, 2020
7dd54da
Fixing dynamic library adding and adding single dll or library additi…
grf14003 Feb 20, 2020
20a0390
Fixing python script for Nate
grf14003 Feb 26, 2020
e8fa40e
Starting build script
grf14003 Feb 27, 2020
1c500bd
Adding automated build python script
grf14003 Mar 10, 2020
b5004ca
Adding optional build argument to startbfs script
grf14003 Mar 10, 2020
ea4c6ee
Adding command infrastructure to python run script
grf14003 Mar 11, 2020
1c27399
Adding pause on complete to start bfs script
grf14003 Mar 11, 2020
781ee5a
Adding graceful socket shutdown, fixing sent message clipping, fixing…
grf14003 Mar 11, 2020
65f4e5e
Fixing spacing in file paths and algorithm client limit
grf14003 Mar 11, 2020
36f9d80
Fixing client reaping memory leak and error
grf14003 Mar 12, 2020
79a4c3b
Adding a few extra commands to startbfs for convenience
grf14003 Apr 1, 2020
273a7fd
Adding ability for algorithm to send attributes. Also adding catch co…
grf14003 May 7, 2020
725a42a
Changing incoming attribute storage from vector to map
grf14003 May 7, 2020
dc14af5
Adding function for polling for attributes as maps
grf14003 May 8, 2020
fadc4b2
Switching some printfs to couts
grf14003 May 8, 2020
408745a
Adding check to data sync thread send to make sure thread is running …
grf14003 May 8, 2020
6800b75
Adding check to data sync thread send to make sure thread is running …
grf14003 May 8, 2020
c3619f3
Merge branch 'dev' of https://github.uconn.edu/grf14003/bfs into dev
grf14003 May 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions .gitignore
@@ -1,7 +1,9 @@
.vs/*

# Excluding the build and executable folders
breadcrumbs/build/*
!breadcrumbs/build/.blank
breadcrumbs/bin/*
!breadcrumbs/bin/.blank
bfs/build/*
!bfs/build/.blank
bfs/bin/*
!bfs/bin/.blank
*.log
*__pycache__*
File renamed without changes.
File renamed without changes.
177 changes: 177 additions & 0 deletions bfs/CMakeLists.txt
@@ -0,0 +1,177 @@
cmake_minimum_required (VERSION 2.6)

message("Starting CMAKE")
set(MSVC true)
project(Bfs)
string(TOLOWER ${PROJECT_NAME} ROOT_FOLDER_DIRNAME)
# 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_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin) # Compiled executables for execution and test (.exe)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${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
set(IMPLEMENATION_PATH ${PROJECT_SOURCE_DIR}/implementations)

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("")

# Including all tools
file(GLOB TOOL_INCLUDES CONFIGURE_DEPENDS "${PROJECT_SOURCE_DIR}/tools/*")

# Adding tools
foreach(X IN LISTS TOOL_INCLUDES)
message("Including library with ${X}")
add_subdirectory(${X})
endforeach()

# 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}")# Including dll header files
file(GLOB LIB_INCLUDES CONFIGURE_DEPENDS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/*/")
foreach(X IN LISTS LIB_INCLUDES)
message("Including lib headers: ${X}")
include_directories(${X})
endforeach()

find_library(TactorInterface NAME TactorInterface.lib PATHS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ea_tdk)
find_library(TActionManager NAME TActionManager.lib PATHS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ea_tdk)

# puts all .cpp files inside src to the SOURCES variable
# TODO: replace this with a script for collecting cpp files
file(GLOB_RECURSE BFS_SOURCE CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/*.cpp")

file(GLOB IMPLEMENTAIONS CONFIGURE_DEPENDS "${IMPLEMENATION_PATH}/*/")
foreach(IMPL IN LISTS IMPLEMENTAIONS)

message("\n=== Starting implementation(${IMPL}) build... ===")
# Check if implementation config file exists
if(EXISTS "${IMPL}/CMakeLists.txt")
message("Found configuration file!")
add_subdirectory(${IMPL})
endif()

set(IMPL_ALGO_PATH ${IMPL}/algos) # BFS Implemenation algo source file path
set(IMPL_IO_PROCS_PATH ${IMPL}/io_procs)
set(IMPL_INCLUDE_PATH ${IMPL}/include)

message("Implementation algo directory: ${IMPL_ALGO_PATH}")
message("Implementation io_procs directory: ${IMPL_IO_PROCS_PATH}")
message("Implementation include directory: ${IMPL_INCLUDE_PATH}")
message("")

# Adding implementation include
include_directories("${IMPL_INCLUDE_PATH}")

set(Bfs_TEMP_ALGORITHM_CLIENT_LIMIT 20)

file(MAKE_DIRECTORY ${IMPL}/gen)

file(GLOB ALGOS_EXECS CONFIGURE_DEPENDS "${IMPL_ALGO_PATH}/*.cpp")
foreach(X IN LISTS ALGOS_EXECS)
get_filename_component(N ${X} NAME_WE)
set(Bfs_TEMP_ALGORITHM_NAME ${N})
message("Generating Algorithm main(): ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp")
configure_file("${CMAKE_SOURCE_DIR}/template/AlgorithmTemplate.cpp.in" ${IMPL}/gen/${N}.cpp)
endforeach()

file(GLOB IO_PROC_EXECS CONFIGURE_DEPENDS "${IMPL_IO_PROCS_PATH}/*.cpp")
foreach(X IN LISTS IO_PROC_EXECS)
get_filename_component(N ${X} NAME_WE)
set(Bfs_TEMP_IOPROC_NAME ${N})
message("Generating IO Processor main(): ${PROJECT_SOURCE_DIR}/${ROOT_FOLDER_DIRNAME}/gen/${N}.cpp")
configure_file("${CMAKE_SOURCE_DIR}/template/IOProcessorTemplate.cpp.in" ${IMPL}/gen/${N}.cpp)
endforeach()
message("")

# Compiling BFS implementation source files
file(GLOB_RECURSE IMPL_SRC CONFIGURE_DEPENDS "${IMPL}/*.cpp")
list(FILTER IMPL_SRC EXCLUDE REGEX "${IMPL}/gen/*")
list(FILTER IMPL_SRC EXCLUDE REGEX "${IMPL}/algos/*")
list(FILTER IMPL_SRC EXCLUDE REGEX "${IMPL}/io_procs/*")

# Getting template output files to create executables
file(GLOB IMPL_EXECS CONFIGURE_DEPENDS "${IMPL}/gen/*.cpp")

# Adding executables
# This is fine for now, but we may want to switch to a more manual versio so we can
# configure which files are included in which exe's
foreach(X IN LISTS IMPL_EXECS)
get_filename_component(N ${X} NAME_WE)
message(STATUS "Generating Executable: ${N}.exe Main File: ${X}")

# Including any DLLs or LIBs
set(ALL_LIBS "")
message("Libs Stored in ${N}_IMPL_DLLS: ${${N}_IMPL_LIBS}")
foreach(LIB_PATH IN ITEMS ${${N}_IMPL_LIBS})
set(LIB_ABS_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIB_PATH}")
if (IS_DIRECTORY ${LIB_ABS_PATH})
# Need to include all DLLs and LIBs in the directory
file(GLOB DLLS CONFIGURE_DEPENDS "${LIB_ABS_PATH}/*.dll")
file(GLOB LIBS CONFIGURE_DEPENDS "${LIB_ABS_PATH}/*.lib")
foreach(DLL IN ITEMS ${DLLS})
get_filename_component(DLL_N ${DLL} NAME)
message("Adding DLL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DLL_N}")
file(COPY ${DLL} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endforeach()
foreach(LIB IN ITEMS ${LIBS})
get_filename_component(LIB_N ${LIB} NAME_WE)
find_library(${LIB_N} NAME ${LIB_N}.lib PATHS ${LIB})
message("Linking library: ${${LIB_N}}")
list(APPEND ALL_LIBS ${LIB_N})
endforeach()
else()
# Need to include just the given Library file (DLL or LIB)
get_filename_component(EXTENSION ${LIB_ABS_PATH} EXT)
if(${EXTENSION} STREQUAL ".dll")
get_filename_component(DLL_N ${LIB_ABS_PATH} NAME)
message("Adding DLL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DLL_N}")
configure_file(${LIB_ABS_PATH} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${DLL_N} COPYONLY)
elseif(${EXTENSION} STREQUAL ".lib")
get_filename_component(LIB_N ${LIB_ABS_PATH} NAME_WE)
find_library(${LIB_N} NAME ${LIB_N}.lib PATHS ${LIB_ABS_PATH})
message("Linking library: ${${LIB_N}}")
list(APPEND ALL_LIBS ${LIB_N})
endif()
endif()
endforeach()

# Getting Algorithm or IO Processor implementation source file:
set(EXEC_IMPL_SRC_FILE "")
if(EXISTS ${IMPL}/algos/${N}.cpp)
set(EXEC_IMPL_SRC_FILE "${IMPL}/algos/${N}.cpp")
elseif(EXISTS ${IMPL}/io_procs/${N}.cpp)
set(EXEC_IMPL_SRC_FILE "${IMPL}/io_procs/${N}.cpp")
endif()

add_executable(${N} ${IMPL_SRC} ${EXEC_IMPL_SRC_FILE} ${X} ${BFS_SOURCE})

# Exe specialized libraries
foreach(LIB IN ITEMS ${ALL_LIBS})
target_link_libraries(${N} ${${LIB}})
endforeach()

# All exe's depend on tinyxmls
target_link_libraries(${N} tinyxml2)

endforeach()
endforeach()
10 changes: 8 additions & 2 deletions breadcrumbs/CMakeSettings.json → bfs/CMakeSettings.json
Expand Up @@ -10,7 +10,13 @@
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": []
"variables": [
{
"name": "CMAKE_INSTALL_PREFIX",
"value": "C:/Users/Greg/Documents/git/bfs/breadcrumbs/install/basic_build",
"type": "PATH"
}
]
}
]
}
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bfs/config/config.txt
@@ -0,0 +1 @@
int i = 0
22 changes: 22 additions & 0 deletions bfs/config/sample_config_file.cfg
@@ -0,0 +1,22 @@
<?xml version = "1.0"?>
<algorithm>
<name>TestAlgo</name>
<type>Breadcrumbs</type>
<logger>
<level>4</level>
</logger>
</algorithm>
<io_processor>
<name>VirtualInputProcessor0</name>
<type>VirtualInputProcessor</type>
<logger>
<level>2</level>
</logger>
</io_processor>
<io_processor>
<name>VirtualOutputProcessor0</name>
<type>VirtualOutputProcessor</type>
<logger>
<level>1</level>
</logger>
</io_processor>
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions bfs/implementations/breadcrumbs/CMakeLists.txt
@@ -0,0 +1,4 @@

set (VirtualOutputIOProcessor_IMPL_LIBS
"ea_tdk"
PARENT_SCOPE)
27 changes: 27 additions & 0 deletions bfs/implementations/breadcrumbs/algos/AlgoBreadcrumbs.cpp
@@ -0,0 +1,27 @@

#include "AlgoBreadcrumbs.hpp"


void AlgoBreadcrumbs::loop()
{
int msgCount = 0;
Attribute msgCountAttrib = { "MSGCOUNT", sizeof(int), &msgCount };

map<string, Attribute> attribs = pollForAttributesMap();
if (attribs.size() > 0)
{
auto testKeyIter = attribs.find(string("testKey1"));
if (testKeyIter != attribs.end())
{
char value = *((char*) (*testKeyIter).second.getValue());
cout << "Test key 1 value updated to " << value << endl;
}

sendAttribute(msgCountAttrib);
}
}

bool AlgoBreadcrumbs::loopCondition()
{
return true;
}
@@ -1,13 +1,13 @@

#include <stdio.h>
#include "Config.hpp"

#include "AlgoBreadcrumbs.hpp"
#include "VirtualOutputProcessor.hpp"


int main()
{
Algorithm* algorithm = new AlgoBreadcrumbs(1);
Algorithm* algorithm = new AlgoBreadcrumbs(20);

// Loop
while (algorithm->loopCondition())
Expand Down
23 changes: 23 additions & 0 deletions bfs/implementations/breadcrumbs/gen/VirtualOutputIOProcessor.cpp
@@ -0,0 +1,23 @@

#include <iostream>

#include "DataSyncThread.hpp"
#include "VirtualOutputIOProcessor.hpp"


int main()
{
IOProcessor* client = new VirtualOutputIOProcessor;

if (!client->init())
{
while (client->loopCondition())
client->loop();

int result = client->close();
delete client;
return result;
}

return 0;
}
@@ -0,0 +1,18 @@
#ifndef VIRTUAL_OUTPUT_IO_PROCESSOR_HPP
#define VIRTUAL_OUTPUT_IO_PROCESSOR_HPP

#include "IOProcessor.hpp"

class VirtualOutputIOProcessor : public IOProcessor
{
public:
using IOProcessor::IOProcessor;

void loop();
bool loopCondition();

private:
int iterations = 10;
};

#endif
@@ -0,0 +1,26 @@

#include "VirtualOutputIOProcessor.hpp"


void VirtualOutputIOProcessor::loop()
{
char testValue = 'a' + iterations;
Attribute attrib("testKey1", 1, &testValue);
getComms()->sendAttribute(attrib);

if (getComms()->areIncomingAttributesAvailable()) {
vector<Attribute> attribs = getComms()->getIncomingAttributes();
for (Attribute attr : attribs)
{
cout << "Attribute " << attr.getKey() << " received!" << endl;
}
}

Sleep(500);
iterations--;
}

bool VirtualOutputIOProcessor::loopCondition()
{
return iterations >= 0;
}
Expand Up @@ -12,6 +12,10 @@ public:

virtual void loop() = 0;
virtual bool loopCondition() { return false; };

vector<Attribute> pollForAttributes() { return server->getAllIncomingAttributes(); };
map<string, Attribute> pollForAttributesMap() { return server->getAllIncomingAttributesMap(); };
void sendAttribute(Attribute attrib) { server->sendAttributeToAll(attrib); };
private:
size_t numIoProcs = 0;
AlgorithmServer* server;
Expand Down