This commit is contained in:
Johannes Wendel
2020-01-23 11:41:46 +01:00
277 changed files with 21702 additions and 33233 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
*.idea*
cmake-build-debug
*__pycache__*

View File

@@ -1,10 +0,0 @@
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -lA'
alias cat='cat -n'
alias ncat='cat'
alias mkdir='mkdir -p'
alias pdfmerge='gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOUTPUTFILE='
alias sync_bash_rc='sync_bash .bashrc_ssh'
alias sync_bash_aliases='sync_bash .bash_aliases'
alias sync_bash_functions='sync_bash .bash_functions'

View File

@@ -1,79 +0,0 @@
function up {
[ "${1/[^0-9]/}" == "$1" ] && {
local ups=""
for i in $(seq 1 $1)
do
ups=$ups"../"
done
cd $ups
} || cd ../
}
function ccat {
pygmentize -g $1 | cat -n
}
function sync_bash {
if [ -z "$1" ]
then
exit 1
fi
echo $BASHRC_DIR
echo $1
rsync -avzhe ssh $1 $BASHRC_USER@$BASHRC_SERVER:$BASHRC_DIR/$1
}
function get_bash_file {
if [ -z "$1" ]
then
exit 1
fi
echo $BASHRC_DIR
echo $1
rsync -avzhe ssh $BASHRC_USER@$BASHRC_SERVER:$BASHRC_DIR/$1 $1
}
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
function extract {
if [ -z "$1" ]; then
# display usage if no parameters given
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
else
for n in "$@"
do
if [ -f "$n" ] ; then
case "${n%,}" in
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
tar xvf "$n" ;;
*.lzma) unlzma ./"$n" ;;
*.bz2) bunzip2 ./"$n" ;;
*.rar) unrar x -ad ./"$n" ;;
*.gz) gunzip ./"$n" ;;
*.zip) unzip ./"$n" ;;
*.z) uncompress ./"$n" ;;
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
7z x ./"$n" ;;
*.xz) unxz ./"$n" ;;
*.exe) cabextract ./"$n" ;;
*.cpio) cpio -id < ./"$n" ;;
*)
echo "extract: '$n' - unknown archive method"
return 1
;;
esac
else
echo "'$n' - file does not exist"
return 1
fi
done
fi
}
IFS=$SAVEIFS
calc() {
echo "scale=3;$@" | bc -l
}

View File

@@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1201473626">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.base.1201473626" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" id="cdt.managedbuild.toolchain.gnu.base.1201473626" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1201473626.1183094578" name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.base.35862587" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.base">
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.base.259134770" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
<builder id="cdt.managedbuild.target.gnu.builder.base.1998872973" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.target.gnu.builder.base"/>
<tool id="cdt.managedbuild.tool.gnu.archiver.base.2094605115" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1924689129" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.compiler.base.2057159901" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base"/>
<tool id="cdt.managedbuild.tool.gnu.c.linker.base.1349114117" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.1196470376" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1152367637" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base"/>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="FlippR-Driver.null.187760080" name="FlippR-Driver"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>

View File

@@ -1,4 +1,16 @@
.csettings/*
build build
src/Debug CMakeFiles
/Debug/ CMakeCache.txt
bin
*.log
.settings/* .settings/*
*.bin
*.cmake
*.out
.settings/*
Makefile
.project
.cproject
.idea*
nbproject*

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FlippR-Driver</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.base.1201473626" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-525411911894964134" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
</project>

View File

@@ -1,71 +0,0 @@
eclipse.preferences.version=1
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
org.eclipse.cdt.codan.checkers.nocommentinside=-Error
org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
org.eclipse.cdt.codan.checkers.nolinecomment=-Error
org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
org.eclipse.cdt.codan.checkers.noreturn=Error
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}

View File

@@ -1,13 +0,0 @@
eclipse.preferences.version=1
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/CPATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/CPATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/CPLUS_INCLUDE_PATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/CPLUS_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/C_INCLUDE_PATH/delimiter=\:
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/C_INCLUDE_PATH/operation=remove
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/append=true
environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.1796611039/appendContributed=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1796611039/LIBRARY_PATH/delimiter=\:
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1796611039/LIBRARY_PATH/operation=remove
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1796611039/append=true
environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.1796611039/appendContributed=true

View File

@@ -1,3 +1,133 @@
project(flippr-driver) ####################### OPTIONS #########################
option(CROSS_COMPILE "Enables crosscompiling for raspberry pi" OFF)
option(BUILD_SHARED_LIB "Build a shared lib instead of a static." OFF)
option(ENABLE_TESTING "Enables testing." ON)
option(BUILD_NETWORKING "Build socket communication executable." ON)
option(BUILD_CLI "Makes a basic testing cli" OFF)
subdirs(build Debug etc json_example src) #################### CONFIGURATION ######################
set(OUTPUT_PATH bin)
set(LIB_DIR lib)
set(DEFAULT_BUILD_TYPE DEBUG)
set(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_FLAGS -pthread)
IF(NOT_PI)
add_definitions(-DNOT_PI)
message("Compiling not for Pi")
ENDIF()
project(FlippR-Driver)
###################### START_CMAKE #######################
cmake_minimum_required(VERSION 3.0.1)
project(FlippR-Driver VERSION 0.1.0)# LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#set easylogging flags
add_definitions(-DELPP_NO_DEFAULT_LOG_FILE)
# Compile library to output_path
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/${OUTPUT_PATH})
# Default to Release build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE})
endif(NOT CMAKE_BUILD_TYPE)
#set code-coverage flags if Debug mode
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
message("Setting gcov flags")
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov")
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}" )
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
#################### Adding Library #####################
file(GLOB_RECURSE SOURCES src/*.cpp)
if(BUILD_SHARED_LIB)
add_library(${PROJECT_NAME} SHARED ${SOURCES})
else()
add_library(${PROJECT_NAME} STATIC ${SOURCES} cli/OutputInterpreter.cpp cli/OutputInterpreter.h src/output/items/detail/DriverBoardItem.cpp src/output/items/detail/DriverBoardItem.h include/DriverFactory.h src/utility/Colors.h src/output/factories/SoundFactory.cpp src/output/factories/SoundFactory.h src/output/factories/ItemFactory.cpp src/output/factories/ItemFactory.h src/output/factories/FlipperFactory.cpp src/output/factories/FlipperFactory.h src/output/factories/LampFactory.cpp src/output/factories/LampFactory.h src/output/factories/DisplayFactory.cpp src/output/factories/DisplayFactory.h src/output/factories/SolenoidFactory.cpp src/output/factories/SolenoidFactory.h src/utility/helper_functions.hpp)
endif(BUILD_SHARED_LIB)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include)
# Set libraries include path
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/${LIB_DIR})
######################### BOOST #########################
# Boost configuration
set(BOOST_COMPONENTS program_options thread timer chrono filesystem)
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
if(Boost_FOUND)
# Include and link with boost
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
message ("Boost found and linked at ${Boost_INCLUDE_DIRS}")
else()
message (FATAL_ERROR "Can't find Boost.")
endif(Boost_FOUND)
##################### WIRING_PI ##########################
find_library(wiringPi_LIB wiringPi)
if(NOT wiringPi_LIB)
message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.")
add_definitions(-DNO_WIRING_PI)
else()
message(STATUS "Found wiring pi.")
target_include_directories(${PROJECT_NAME} PUBLIC ${wiringPi_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${wiringPi_LIB})
endif()
find_library(crypt_LIB crypt)
if(NOT crypt_LIB)
message(FATAL_ERROR "Could not find crypt library")
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${crypt_LIB})
##################### EASYLOGGING #########################
set(EASYLOGGING_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/${LIB_DIR}/easylogging)
add_library(Easylogging STATIC ${EASYLOGGING_INCLUDE_DIR}/easylogging++.cc)
target_include_directories(${PROJECT_NAME} PUBLIC ${EASYLOGGING_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC Easylogging)
######################## CATCH ############################
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/tests)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
####################### THREAD ############################
find_package(Threads REQUIRED)
if(NOT CMAKE_THREAD_LIBS_INIT)
message(FATAL_ERROR, "Could not find libthread")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE ${Threads_LIBRARIES})
if(ENABLE_TESTING)
add_subdirectory(tests)
endif(ENABLE_TESTING)
if(BUILD_NETWORKING)
add_subdirectory(networking)
endif(BUILD_NETWORKING)
if(BUILD_CLI)
add_subdirectory(cli)
endif(BUILD_CLI)
####################### END_CMAKE ########################

View File

@@ -1,44 +0,0 @@
cmake_minimum_required(VERSION 3.9.1)
project(flippr-driver)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") # enable C++11 standard
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(SOURCE_DIR ../src)
find_package(Threads)
find_package(Boost)
include_directories(${SOURCE_DIR}/input)
include_directories(${SOURCE_DIR}/output)
include_directories(${SOURCE_DIR}/lib)
include_directories(${SOURCE_DIR}/utilities)
file(GLOB SOURCES ${SOURCE_DIR}/*/*.cpp)
add_library(flippr_driver STATIC ${SOURCES})
target_link_libraries(flippr_driver ${CMAKE_SOURCE_DIR}/lib/libwiringPi.so.2.44)
enable_testing(TRUE)
# Prepare "Catch" library for other executables
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../src/tests)
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}/*)
# Make test executable
set(TEST_SOURCES ${SOURCE_DIR}/../tests/input)
include_directories(${TEST_SOURCES})
include_directories(${TEST_SOURCES}/mocks)
file(GLOB SOURCES ${TEST_SOURCES}/*.cpp)
file(GLOB HEADER_SOURCES ${TEST_SOURCES}/*.hpp)
add_executable(tests ${SOURCES} ${HEADER_SOURCES})
target_link_libraries(flippr_driver)
target_link_libraries(tests Catch)

View File

@@ -1,21 +0,0 @@
{
"input":
{
"row":
{
"A":"GPIO_13",
"B":"GPIO_14",
"C":"GPIO_15",
},
"column":
{
"A":"GPIO_17",
"B":"GPIO_18",
"C":"GPIO_19",
"input":"GPIO_20"
}
},
"output":
{
}
}

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.6.2)
project(flippR_driver_CLI)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/${OUTPUT_PATH}/cli)
add_executable(${PROJECT_NAME} main.cpp PrintHandler.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE FlippR_Driver)

View File

@@ -0,0 +1,16 @@
//
// Created by rhetenor on 5/5/19.
//
#include "OutputInterpreter.h"
#include <fstream>
#include <iostream>
using namespace std;
OutputInterpreter::OutputInterpreter(std::string output_lamp_config_file, std::string output_solenoid_config_file,
std::string output_sound_config_file, std::string output_display_config_file)
{
output_driver = flippR_driver::get_OutputDriver(output_lamp_config_file, output_solenoid_config_file, output_sound_config_file, output_display_config_file);
}

View File

@@ -0,0 +1,23 @@
//
// Created by rhetenor on 5/5/19.
//
#ifndef FLIPPR_DRIVER_OUTPUTINTERPRETER_H
#define FLIPPR_DRIVER_OUTPUTINTERPRETER_H
#include "DriverFactory.h"
class OutputInterpreter
{
public:
OutputInterpreter(std::string output_lamp_config_file, std::string output_solenoid_config_file,
std::string output_sound_config_file, std::string output_display_config_file);
void startInterpreter();
private:
std::shared_ptr<flippR_driver::output::OutputDriver> output_driver;
};
#endif //FLIPPR_DRIVER_OUTPUTINTERPRETER_H

View File

@@ -0,0 +1,18 @@
//
// Created by rhetenor on 13.09.18.
//
#include "PrintHandler.h"
#include <iostream>
PrintHandler::PrintHandler(std::shared_ptr<flippR_driver::input::InputDriver> driver) :
flippR_driver::input::EventHandler(driver)
{
}
void PrintHandler::handle(flippR_driver::input::Event &event)
{
std::cout << "Event " << event.name << " (" << std::to_string(event.address) << ") occured!\n";
}

View File

@@ -0,0 +1,21 @@
//
// Created by rhetenor on 13.09.18.
//
#ifndef flippR_driver_PRINTHANDLER_H
#define flippR_driver_PRINTHANDLER_H
#include <memory>
#include "input/EventHandler.h"
#include "input/InputDriver.h"
class PrintHandler : public flippR_driver::input::EventHandler
{
public:
PrintHandler(std::shared_ptr<flippR_driver::input::InputDriver> driver);
virtual void handle(flippR_driver::input::Event& event) override;
};
#endif //flippR_driver_PRINTHANDLER_H

101
FlippR-Driver/cli/main.cpp Normal file
View File

@@ -0,0 +1,101 @@
//
// Created by rhetenor on 13.09.18.
//
#include <boost/program_options.hpp>
#include <iostream>
#include <fstream>
#include <memory>
#include <signal.h>
#include "DriverFactory.h"
#include "input/InputDriver.h"
#include "PrintHandler.h"
using namespace flippR_driver;
namespace po = boost::program_options;
PrintHandler* print_handler = nullptr;
void __sigint_handler(int param)
{
printf("Caught SIGINT... aborting!\n");
exit(EXIT_SUCCESS);
}
static void show_usage(const std::string &name)
{
std::cout << "Usage: " << name << " [-ipc=<input_pin_config_file> -imc=<input_matrix_config_file>] "
<< "[-opc=<output_pin_config_file> -odc=<output_display_config_file> -olc=<output_lamp_config_file>] "
<< "-osolc=<output_solenoid_config_file> -osc=<output_sound_config_file>]";
}
static void register_program_options(po::options_description &po_desc, boost::optional<std::string> &input_pin_config_file, std::string &input_matrix_config_file,
boost::optional<std::string> &output_pin_config_file, std::string &output_display_config_file, std::string &output_lamp_config_file, std::string &output_solenoid_config_file, std::string &output_sound_config_file)
{
po_desc.add_options()
("help", "print_help_message")
("input_pin_config,ipc", po::value<boost::optional<std::string>>(&input_pin_config_file), "input pin config file")
("input_matrix_config,imc", po::value<std::string>(&input_matrix_config_file), "input matrix config file")
("output_pin_config,opc", po::value<boost::optional<std::string>>(&output_pin_config_file), "output pin config file")
("output_display_config,idc", po::value<std::string>(&output_display_config_file), "output display config file")
("output_lamp_config,ilc", po::value<std::string>(&output_lamp_config_file), "output lamp config file")
("output_solenoid_config,isolc", po::value<std::string>(&output_solenoid_config_file), "output solenoid config file")
("output_sound_config,isc", po::value<std::string>(&output_sound_config_file), "output sound config file")
;
}
static PrintHandler* start_print_handler(const std::string &input_config_file, const std::string &matrix_config_file)
{
std::ifstream input_config;
std::ifstream matrix_config;
try
{
input_config.open(input_config_file);
matrix_config.open(matrix_config_file);
}
catch(const std::exception& e)
{
std::cout << e.what();
exit(EXIT_FAILURE);
}
std::shared_ptr<input::InputDriver> driver = flippR_driver::get_InputDriver(input_config, matrix_config);
return new PrintHandler(driver);
}
int main (int argc, char *argv[])
{
if(argc < 3)
{
show_usage(argv[0]);
exit(EXIT_FAILURE);
}
// registering sigint
signal(SIGINT, __sigint_handler);
po::options_description po_desc("Options");
boost::optional<std::string> input_pin_config_file, output_pin_config_file;
std::string input_matrix_config_file, output_display_config_file, output_lamp_config_file, output_solenoid_config_file, output_sound_config_file;
register_program_options(po_desc, input_pin_config_file, input_matrix_config_file, output_pin_config_file, output_display_config_file, output_lamp_config_file, output_solenoid_config_file, output_sound_config_file);
// todo parse
if(input_pin_config_file)
{
print_handler = start_print_handler(*input_pin_config_file, input_matrix_config_file);
}
if(output_pin_config_file)
{
start_output_driver(*output_pin_config_file, )
}
while(1);
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,9 @@
{
"input-config" :"../../contrib/json_example/input/Input_Pin_Config.json",
"matrix-config" :"../../contrib/json_example/input/Input_Matrix_Config.json",
"lamp-config" :"../../contrib/json_example/output/Lamp_Config.json",
"solenoid-config" :"../../contrib/json_example/output/Solenoid_Config.json",
"sound-config" :"../../contrib/json_example/output/Sound_Config.json",
"display-config" :"../../contrib/json_example/output/Display_Config.json",
"lamp-config" :"../../contrib/json_example/output/Lamp_Config.json"
}

View File

@@ -0,0 +1,81 @@
# Copyright (c) 2013 Nathan Osman
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Determines whether the compiler supports C++11
macro(check_for_cxx11_compiler _VAR)
message(STATUS "Checking for C++11 compiler")
set(${_VAR})
try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON)
if(NOT _COMPILER_TEST_RESULT AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=11 -DCMAKE_CXX_STANDARD_REQUIRED=ON)
if(_COMPILER_TEST_RESULT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
message(STATUS "To enable C++11 install libc++ standard library from https://libcxx.llvm.org/")
endif()
endif()
if(_COMPILER_TEST_RESULT AND ((MSVC AND (MSVC10 OR MSVC11 OR MSVC12 OR MSVC14)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.8.1) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.3) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")))
set(${_VAR} 1)
message(STATUS "Checking for C++11 compiler - available")
else()
message(STATUS "Checking for C++11 compiler - unavailable")
endif()
endmacro()
# Sets the appropriate flag to enable C++11 support
macro(enable_cxx11)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DPOCO_ENABLE_CPP11)
endmacro()
# Determines whether the compiler supports C++14
macro(check_for_cxx14_compiler _VAR)
message(STATUS "Checking for C++14 compiler")
set(${_VAR})
try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON)
if(NOT _COMPILER_TEST_RESULT AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
try_compile(_COMPILER_TEST_RESULT ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/test_compiler.cpp CMAKE_FLAGS -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON)
if(_COMPILER_TEST_RESULT)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
message(STATUS "To enable C++14 install libc++ standard library from https://libcxx.llvm.org/")
endif()
endif()
if(_COMPILER_TEST_RESULT AND ((MSVC AND (MSVC14)) OR
(CMAKE_COMPILER_IS_GNUCXX AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 4.9.2) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.4) OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")))
set(${_VAR} 1)
message(STATUS "Checking for C++14 compiler - available")
else()
message(STATUS "Checking for C++14 compiler - unavailable")
endif()
endmacro()
# Sets the appropriate flag to enable C++14 support
macro(enable_cxx14)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DPOCO_ENABLE_CPP14)
endmacro()

View File

@@ -0,0 +1,132 @@
# http://www.cmake.org/Wiki/CMake_Useful_Variables :
# CMAKE_BUILD_TYPE
# Choose the type of build. CMake has default flags for these:
#
# * None (CMAKE_C_FLAGS or CMAKE_CXX_FLAGS used)
# * Debug (CMAKE_C_FLAGS_DEBUG or CMAKE_CXX_FLAGS_DEBUG)
# * Release (CMAKE_C_FLAGS_RELEASE or CMAKE_CXX_FLAGS_RELEASE)
# * RelWithDebInfo (CMAKE_C_FLAGS_RELWITHDEBINFO or CMAKE_CXX_FLAGS_RELWITHDEBINFO
# * MinSizeRel (CMAKE_C_FLAGS_MINSIZEREL or CMAKE_CXX_FLAGS_MINSIZEREL)
# Setting CXX Flag /MD or /MT and POSTFIX values i.e MDd / MD / MTd / MT / d
#
# For visual studio the library naming is as following:
# Dynamic libraries:
# - PocoX.dll for release library
# - PocoXd.dll for debug library
#
# Static libraries:
# - PocoXmd.lib for /MD release build
# - PocoXtmt.lib for /MT release build
#
# - PocoXmdd.lib for /MD debug build
# - PocoXmtd.lib for /MT debug build
if(MSVC)
if(POCO_MT)
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
set(STATIC_POSTFIX "mt" CACHE STRING "Set static library postfix" FORCE)
else(POCO_MT)
set(STATIC_POSTFIX "md" CACHE STRING "Set static library postfix" FORCE)
endif(POCO_MT)
if (ENABLE_MSVC_MP)
add_definitions(/MP)
endif()
else(MSVC)
# Other compilers then MSVC don't have a static STATIC_POSTFIX at the moment
set(STATIC_POSTFIX "" CACHE STRING "Set static library postfix" FORCE)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
endif(MSVC)
# Add a d postfix to the debug libraries
if(POCO_STATIC)
set(CMAKE_DEBUG_POSTFIX "${STATIC_POSTFIX}d" CACHE STRING "Set Debug library postfix" FORCE)
set(CMAKE_RELEASE_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set Release library postfix" FORCE)
set(CMAKE_MINSIZEREL_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set MinSizeRel library postfix" FORCE)
set(CMAKE_RELWITHDEBINFO_POSTFIX "${STATIC_POSTFIX}" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
else(POCO_STATIC)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set Debug library postfix" FORCE)
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix" FORCE)
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinSizeRel library postfix" FORCE)
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "Set RelWithDebInfo library postfix" FORCE)
endif()
# OS Detection
include(CheckTypeSize)
find_package(Cygwin)
if(WIN32)
add_definitions( -DPOCO_OS_FAMILY_WINDOWS -DUNICODE -D_UNICODE -D__LCC__) #__LCC__ define used by MySQL.h
endif(WIN32)
if (CYGWIN)
add_definitions(-DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING)
add_definitions(-D_XOPEN_SOURCE=500 -D__BSD_VISIBLE)
else (CYGWIN)
if (UNIX AND NOT ANDROID )
add_definitions( -DPOCO_OS_FAMILY_UNIX )
# Standard 'must be' defines
if (APPLE)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_STAT64)
set(SYSLIBS ${CMAKE_DL_LIBS})
else (APPLE)
add_definitions( -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
if (QNX)
add_definitions( -DPOCO_HAVE_FD_POLL)
set(SYSLIBS m socket)
else (QNX)
add_definitions( -D_XOPEN_SOURCE=500)
if (${CMAKE_SYSTEM} MATCHES "AIX")
add_definitions( -DPOCO_HAVE_FD_POLL)
else()
add_definitions( -DPOCO_HAVE_FD_EPOLL)
endif()
set(SYSLIBS pthread ${CMAKE_DL_LIBS} rt)
endif (QNX)
endif (APPLE)
endif(UNIX AND NOT ANDROID )
endif (CYGWIN)
if (CMAKE_SYSTEM MATCHES "SunOS")
add_definitions( -DPOCO_OS_FAMILY_UNIX )
# Standard 'must be' defines
add_definitions( -D_XOPEN_SOURCE=500 -D_REENTRANT -D_THREAD_SAFE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 )
set(SYSLIBS pthread socket xnet nsl resolv rt ${CMAKE_DL_LIBS})
endif(CMAKE_SYSTEM MATCHES "SunOS")
if (CMAKE_COMPILER_IS_MINGW)
add_definitions(-DWC_NO_BEST_FIT_CHARS=0x400 -DPOCO_WIN32_UTF8)
add_definitions(-D_WIN32 -DMINGW32 -DWINVER=0x500 -DODBCVER=0x0300 -DPOCO_THREAD_STACK_SIZE)
endif (CMAKE_COMPILER_IS_MINGW)
# SunPro C++
if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
add_definitions( -D_BSD_SOURCE -library=stlport4)
endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
# iOS
if (IOS)
add_definitions( -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES )
endif(IOS)
#Android
if (ANDROID)
add_definitions( -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_WSTRING -DPOCO_NO_SHAREDMEMORY )
endif(ANDROID)

View File

@@ -0,0 +1,29 @@
get_filename_component(UNITTEST_FILENAME ${UNITTEST} NAME)
message(STATUS "Cleanup /data/local/tmp ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "rm -r /data/local/tmp/*" OUTPUT_QUIET)
foreach(_TEST_DATA IN ITEMS ${TEST_FILES})
message(STATUS "Push ${_TEST_DATA} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${_TEST_DATA} /data/local/tmp/ OUTPUT_QUIET)
endforeach()
message(STATUS "Push ${LIBRARY_DIR} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${LIBRARY_DIR} /data/local/tmp/ OUTPUT_QUIET)
message(STATUS "Push ${UNITTEST} to android ...")
execute_process(COMMAND ${ANDROID_NDK}/../platform-tools/adb push ${UNITTEST} /data/local/tmp/ OUTPUT_QUIET)
message(STATUS "Execute ${UNITTEST_FILENAME} ${TEST_PARAMETER} on android ...")
execute_process(
COMMAND ${ANDROID_NDK}/../platform-tools/adb shell "cd /data/local/tmp;su root sh -c 'LD_LIBRARY_PATH=/data/local/tmp/lib TMPDIR=/data/local/tmp HOME=/data/local/tmp ./${UNITTEST_FILENAME} ${TEST_PARAMETER};echo exit code $?'"
RESULT_VARIABLE _RESULT
OUTPUT_VARIABLE _OUT
ERROR_VARIABLE _ERR
)
if(_RESULT)
message(FATAL_ERROR "Execution of ${UNITTEST_FILENAME} failed")
else()
string(REGEX MATCH "exit code ([0-9]+)" _EXIT_CODE ${_OUT})
if(NOT "${CMAKE_MATCH_1}" EQUAL 0)
string(REGEX REPLACE "exit code [0-9]+" "" _PRINT_OUT ${_OUT})
message(FATAL_ERROR "${UNITTEST_FILENAME} execution error: ${_PRINT_OUT} ${_ERR}")
endif()
endif()

View File

@@ -0,0 +1,94 @@
# -*- cmake -*-
# - Find Apache Portable Runtime
# Find the APR includes and libraries
# This module defines
# APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR, where to find apr.h, etc.
# APR_LIBRARIES and APRUTIL_LIBRARIES, the libraries needed to use APR.
# APR_FOUND and APRUTIL_FOUND, If false, do not try to use APR.
# also defined, but not for general use are
# APR_LIBRARY and APRUTIL_LIBRARY, where to find the APR library.
# APR first.
FIND_PATH(APR_INCLUDE_DIR apr.h
/usr/local/include/apr-1
/usr/local/include/apr-1.0
/usr/include/apr-1
/usr/include/apr-1.0
)
SET(APR_NAMES ${APR_NAMES} apr-1)
FIND_LIBRARY(APR_LIBRARY
NAMES ${APR_NAMES}
PATHS /usr/lib /usr/local/lib
)
IF (APR_LIBRARY AND APR_INCLUDE_DIR)
SET(APR_LIBRARIES ${APR_LIBRARY})
SET(APR_FOUND "YES")
ELSE (APR_LIBRARY AND APR_INCLUDE_DIR)
SET(APR_FOUND "NO")
ENDIF (APR_LIBRARY AND APR_INCLUDE_DIR)
IF (APR_FOUND)
IF (NOT APR_FIND_QUIETLY)
MESSAGE(STATUS "Found APR: ${APR_LIBRARIES}")
ENDIF (NOT APR_FIND_QUIETLY)
ELSE (APR_FOUND)
IF (APR_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find APR library")
ENDIF (APR_FIND_REQUIRED)
ENDIF (APR_FOUND)
# Deprecated declarations.
SET (NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_APR_LIB_PATH ${APR_LIBRARY} PATH)
MARK_AS_ADVANCED(
APR_LIBRARY
APR_INCLUDE_DIR
)
# Next, APRUTIL.
FIND_PATH(APRUTIL_INCLUDE_DIR apu.h
/usr/local/include/apr-1
/usr/local/include/apr-1.0
/usr/include/apr-1
/usr/include/apr-1.0
)
SET(APRUTIL_NAMES ${APRUTIL_NAMES} aprutil-1)
FIND_LIBRARY(APRUTIL_LIBRARY
NAMES ${APRUTIL_NAMES}
PATHS /usr/lib /usr/local/lib
)
IF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
SET(APRUTIL_LIBRARIES ${APRUTIL_LIBRARY})
SET(APRUTIL_FOUND "YES")
ELSE (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
SET(APRUTIL_FOUND "NO")
ENDIF (APRUTIL_LIBRARY AND APRUTIL_INCLUDE_DIR)
IF (APRUTIL_FOUND)
IF (NOT APRUTIL_FIND_QUIETLY)
MESSAGE(STATUS "Found APRUTIL: ${APRUTIL_LIBRARIES}")
ENDIF (NOT APRUTIL_FIND_QUIETLY)
ELSE (APRUTIL_FOUND)
IF (APRUTIL_FIND_REQUIRED)
MESSAGE(STATUS "Could not find APRUTIL library")
ENDIF (APRUTIL_FIND_REQUIRED)
ENDIF (APRUTIL_FOUND)
# Deprecated declarations.
SET (NATIVE_APRUTIL_INCLUDE_PATH ${APRUTIL_INCLUDE_DIR} )
GET_FILENAME_COMPONENT (NATIVE_APRUTIL_LIB_PATH ${APRUTIL_LIBRARY} PATH)
MARK_AS_ADVANCED(
APRUTIL_LIBRARY
APRUTIL_INCLUDE_DIR
)

View File

@@ -0,0 +1,31 @@
# -*- cmake -*-
# - Find Apache Runtime
# Find the APACHE includes and libraries
# This module defines
# APACHE_INCLUDE_DIR and APACHEUTIL_INCLUDE_DIR, where to find APACHE.h, etc.
# APACHE_LIBRARIES and APACHEUTIL_LIBRARIES, the libraries needed to use APACHE.
# APACHE_FOUND and APACHEUTIL_FOUND, If false, do not try to use APACHE.
# also defined, but not for general use are
# APACHE_LIBRARY and APACHEUTIL_LIBRARY, where to find the APACHE library.
FIND_PATH(APACHE_INCLUDE_DIR httpd.h
/usr/local/include/apache2
/usr/include/apache2
)
IF (APACHE_INCLUDE_DIR)
SET(APACHE_FOUND "YES")
ELSE (APACHE_LIBRARY AND APACHE_INCLUDE_DIR)
SET(APACHE_FOUND "NO")
ENDIF (APACHE_INCLUDE_DIR)
IF (APACHE_FOUND)
MESSAGE(STATUS "Found APACHE: ${APACHE_INCLUDE_DIR}")
ENDIF (APACHE_FOUND)
MARK_AS_ADVANCED(
APACHE_INCLUDE_DIR
)

View File

@@ -0,0 +1,94 @@
SET(BINDIR32_ENV_NAME "ProgramFiles(x86)")
SET(BINDIR32 $ENV{${BINDIR32_ENV_NAME}})
find_path(MYSQL_INCLUDE_DIR mysql.h
/usr/include/mysql
/usr/local/include/mysql
/opt/mysql/mysql/include
/opt/mysql/mysql/include/mysql
/usr/local/mysql/include
/usr/local/mysql/include/mysql
$ENV{MYSQL_INCLUDE_DIR}
$ENV{MYSQL_DIR}/include
$ENV{ProgramFiles}/MySQL/*/include
${BINDIR32}/MySQL/include
$ENV{SystemDrive}/MySQL/*/include)
if (NOT MYSQL_INCLUDE_DIR)
find_path(MARIADB_INCLUDE_DIR mysql.h
/usr/include/mariadb
/usr/local/include/mariadb
/opt/mariadb/mariadb/include
/opt/mariadb/mariadb/include/mariadb
/usr/local/mariadb/include
/usr/local/mariadb/include/mariadb
$ENV{MARIADB_INCLUDE_DIR}
$ENV{MARIADB_DIR}/include)
endif (NOT MYSQL_INCLUDE_DIR)
if (WIN32)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
set(libsuffixDist debug)
set(libsuffixBuild Debug)
else (CMAKE_BUILD_TYPE STREQUAL Debug)
set(libsuffixDist opt)
set(libsuffixBuild Release)
add_definitions(-DDBUG_OFF)
endif (CMAKE_BUILD_TYPE STREQUAL Debug)
find_library(MYSQL_LIB NAMES mysqlclient
PATHS
$ENV{MYSQL_DIR}/lib/${libsuffixDist}
$ENV{MYSQL_DIR}/libmysql/${libsuffixBuild}
$ENV{MYSQL_DIR}/client/${libsuffixBuild}
$ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist}
${BINDIR32}/MySQL/lib
$ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist})
else (WIN32)
find_library(MYSQL_LIB NAMES mysqlclient mysqlclient_r
PATHS
/usr/lib/mysql
/usr/local/lib/mysql
/usr/local/mysql/lib
/usr/local/mysql/lib/mysql
/opt/mysql/mysql/lib
/opt/mysql/mysql/lib/mysql
$ENV{MYSQL_DIR}/libmysql_r/.libs
$ENV{MYSQL_DIR}/lib
$ENV{MYSQL_DIR}/lib/mysql)
if (NOT MYSQL_LIB)
find_library(MARIADB_LIB NAMES mariadbclient
PATHS
/usr/lib/mariadb
/usr/local/lib/mariadb
/usr/local/mariadb/lib
/usr/local/mariadb/lib/mariadb
/opt/mariadb/mariadb/lib
/opt/mariadb/mariadb/lib/mariadb
$ENV{MARIADB_DIR}/libmariadb/.libs
$ENV{MARIADB_DIR}/lib
$ENV{MARIADB_DIR}/lib/mariadb)
endif (NOT MYSQL_LIB)
endif (WIN32)
if (MYSQL_INCLUDE_DIR AND MYSQL_LIB)
get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIB} PATH)
set(MYSQL_FOUND TRUE)
message(STATUS "Found MySQL Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
include_directories(${MYSQL_INCLUDE_DIR})
link_directories(${MYSQL_LIB_DIR})
elseif((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB)
get_filename_component(MYSQL_LIB_DIR ${MARIADB_LIB} PATH)
set(MYSQL_FOUND TRUE)
set(MYSQL_LIB ${MARIADB_LIB})
if(MARIADB_INCLUDE_DIR)
set(MYSQL_INCLUDE_DIR ${MARIADB_INCLUDE_DIR})
endif(MARIADB_INCLUDE_DIR)
message(STATUS "Found MariaDB Include directory: ${MYSQL_INCLUDE_DIR} library directory: ${MYSQL_LIB_DIR}")
message(STATUS "Use MariaDB for MySQL Support")
include_directories(${MYSQL_INCLUDE_DIR} )
link_directories(${MYSQL_LIB_DIR})
else ((MARIADB_INCLUDE_DIR OR MYSQL_INCLUDE_DIR) AND MARIADB_LIB)
message(STATUS "Couldn't find MySQL or MariaDB")
endif (MYSQL_INCLUDE_DIR AND MYSQL_LIB)

View File

@@ -0,0 +1,61 @@
#
# Find the ODBC driver manager includes and library.
#
# ODBC is an open standard for connecting to different databases in a
# semi-vendor-independent fashion. First you install the ODBC driver
# manager. Then you need a driver for each separate database you want
# to connect to (unless a generic one works). VTK includes neither
# the driver manager nor the vendor-specific drivers: you have to find
# those yourself.
#
# This module defines
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires MySQL.
find_path(ODBC_INCLUDE_DIRECTORIES
NAMES sql.h
HINTS
/usr/include
/usr/include/odbc
/usr/include/iodbc
/usr/local/include
/usr/local/include/odbc
/usr/local/include/iodbc
/usr/local/odbc/include
/usr/local/iodbc/include
"C:/Program Files/ODBC/include"
"C:/Program Files/Microsoft SDKs/Windows/v7.0/include"
"C:/Program Files/Microsoft SDKs/Windows/v6.0a/include"
"C:/ODBC/include"
DOC "Specify the directory containing sql.h."
)
find_library(ODBC_LIBRARIES
NAMES iodbc odbc odbcinst odbc32
HINTS
/usr/lib
/usr/lib/odbc
/usr/local/lib
/usr/local/lib/odbc
/usr/local/odbc/lib
"C:/Program Files/ODBC/lib"
"C:/ODBC/lib/debug"
"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/Lib"
DOC "Specify the ODBC driver manager library here."
)
# MinGW find usually fails
if(MINGW)
set(ODBC_INCLUDE_DIRECTORIES ".")
set(ODBC_LIBRARIES odbc32)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ODBC
DEFAULT_MSG
ODBC_INCLUDE_DIRECTORIES
ODBC_LIBRARIES
)
mark_as_advanced(ODBC_FOUND ODBC_LIBRARIES ODBC_INCLUDE_DIRECTORIES)

View File

@@ -0,0 +1,33 @@
#
# - Find pcre
# Find the native PCRE includes and library
#
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
# PCRE_LIBRARIES - List of libraries when using pcre.
# PCRE_FOUND - True if pcre found.
IF (PCRE_INCLUDE_DIRS)
# Already in cache, be silent
SET(PCRE_FIND_QUIETLY TRUE)
ENDIF (PCRE_INCLUDE_DIRS)
FIND_PATH(PCRE_INCLUDE_DIR pcre.h)
SET(PCRE_NAMES pcre)
FIND_LIBRARY(PCRE_LIBRARY NAMES ${PCRE_NAMES} )
# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
IF(PCRE_FOUND)
SET( PCRE_LIBRARIES ${PCRE_LIBRARY} )
SET( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} )
ELSE(PCRE_FOUND)
SET( PCRE_LIBRARIES )
SET( PCRE_INCLUDE_DIRS )
ENDIF(PCRE_FOUND)
MARK_AS_ADVANCED( PCRE_LIBRARIES PCRE_INCLUDE_DIRS )

View File

@@ -0,0 +1,66 @@
# - Find libpq
# Find the native PostgreSQL includes and library
#
# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc.
# PGSQL_LIBRARIES - List of libraries when using PGSQL.
# PGSQL_FOUND - True if PGSQL found.
MACRO(FIND_PGSQL)
IF (PGSQL_INCLUDE_DIR)
# Already in cache, be silent
SET(PostgreSQL_FIND_QUIETLY TRUE)
ENDIF (PGSQL_INCLUDE_DIR)
FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
$ENV{ProgramFiles}/PostgreSQL/*/include
$ENV{SystemDrive}/PostgreSQL/*/include
/usr/local/pgsql/include
/usr/local/postgresql/include
/usr/local/include/pgsql
/usr/local/include/postgresql
/usr/local/include
/usr/include/pgsql
/usr/include/postgresql
/usr/include
/usr/pgsql/include
/usr/postgresql/include
)
SET(PGSQL_NAMES pq libpq)
SET(PGSQL_SEARCH_LIB_PATHS
${PGSQL_SEARCH_LIB_PATHS}
$ENV{ProgramFiles}/PostgreSQL/*/lib
$ENV{SystemDrive}/PostgreSQL/*/lib
/usr/local/pgsql/lib
/usr/local/lib
/usr/lib
)
FIND_LIBRARY(PGSQL_LIBRARY
NAMES ${PGSQL_NAMES}
PATHS ${PGSQL_SEARCH_LIB_PATHS}
)
IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
SET(PGSQL_FOUND TRUE)
SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} )
ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
SET(PGSQL_FOUND FALSE)
SET( PGSQL_LIBRARIES )
ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
IF (PGSQL_FOUND)
IF (NOT PostgreSQL_FIND_QUIETLY)
MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}")
ENDIF (NOT PostgreSQL_FIND_QUIETLY)
ELSE (PGSQL_FOUND)
IF (PostgreSQL_FIND_REQUIRED)
MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.")
MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library")
ENDIF (PostgreSQL_FIND_REQUIRED)
ENDIF (PGSQL_FOUND)
MARK_AS_ADVANCED(
PGSQL_LIBRARY
PGSQL_INCLUDE_DIR
)
ENDMACRO(FIND_PGSQL)

View File

@@ -0,0 +1,87 @@
# - Try to find Sqlite3
# Once done this will define
#
# SQLITE3_FOUND - system has Sqlite3
# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory
# SQLITE3_LIBRARIES - Link these to use Sqlite3
# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)
# in cache already
set(SQLITE3_FOUND TRUE)
else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_SQLITE3 sqlite3)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(SQLITE3_INCLUDE_DIR
NAMES
sqlite3.h
PATHS
${_SQLITE3_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(SQLITE3_LIBRARY
NAMES
sqlite3
PATHS
${_SQLITE3_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (SQLITE3_LIBRARY)
set(SQLITE3_FOUND TRUE)
endif (SQLITE3_LIBRARY)
set(SQLITE3_INCLUDE_DIRS
${SQLITE3_INCLUDE_DIR}
)
if (SQLITE3_FOUND)
set(SQLITE3_LIBRARIES
${SQLITE3_LIBRARIES}
${SQLITE3_LIBRARY}
)
endif (SQLITE3_FOUND)
if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
set(SQLITE3_FOUND TRUE)
endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES)
if (SQLITE3_FOUND)
if (NOT Sqlite3_FIND_QUIETLY)
message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}")
endif (NOT Sqlite3_FIND_QUIETLY)
else (SQLITE3_FOUND)
if (Sqlite3_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Sqlite3")
endif (Sqlite3_FIND_REQUIRED)
endif (SQLITE3_FOUND)
# show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view
mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)
endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS)

View File

@@ -0,0 +1,53 @@
if (CMAKE_VERSION VERSION_LESS 2.8.9)
message(FATAL_ERROR "Poco requires at least CMake version 2.8.9")
endif()
if (NOT Poco_FIND_COMPONENTS)
set(Poco_NOT_FOUND_MESSAGE "The Poco package requires at least one component")
set(Poco_FOUND False)
return()
endif()
set(_Poco_FIND_PARTS_REQUIRED)
if (Poco_FIND_REQUIRED)
set(_Poco_FIND_PARTS_REQUIRED REQUIRED)
endif()
set(_Poco_FIND_PARTS_QUIET)
if (Poco_FIND_QUIETLY)
set(_Poco_FIND_PARTS_QUIET QUIET)
endif()
get_filename_component(_Poco_install_prefix "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
set(_Poco_NOTFOUND_MESSAGE)
# Let components find each other, but don't overwrite CMAKE_PREFIX_PATH
set(_Poco_CMAKE_PREFIX_PATH_old ${CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH ${_Poco_install_prefix})
foreach(module ${Poco_FIND_COMPONENTS})
find_package(Poco${module}
${_Poco_FIND_PARTS_QUIET}
${_Poco_FIND_PARTS_REQUIRED}
PATHS "${_Poco_install_prefix}" NO_DEFAULT_PATH
)
if (NOT Poco${module}_FOUND)
if (Poco_FIND_REQUIRED_${module})
set(_Poco_NOTFOUND_MESSAGE "${_Poco_NOTFOUND_MESSAGE}Failed to find Poco component \"${module}\" config file at \"${_Poco_install_prefix}/Poco${module}/Poco${module}Config.cmake\"\n")
elseif(NOT Poco_FIND_QUIETLY)
message(WARNING "Failed to find Poco component \"${module}\" config file at \"${_Poco_install_prefix}/Poco${module}/Poco${module}Config.cmake\"")
endif()
endif()
# For backward compatibility set the LIBRARIES variable
list(APPEND Poco_LIBRARIES "Poco::${module}")
endforeach()
# Restore the original CMAKE_PREFIX_PATH value
set(CMAKE_PREFIX_PATH ${_Poco_CMAKE_PREFIX_PATH_old})
if (_Poco_NOTFOUND_MESSAGE)
set(Poco_NOT_FOUND_MESSAGE "${_Poco_NOTFOUND_MESSAGE}")
set(Poco_FOUND False)
endif()

View File

@@ -0,0 +1,11 @@
set(PACKAGE_VERSION @APPLICATION_VERSION@)
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@@ -0,0 +1,304 @@
# Copyright Siemens AG, 2014
# Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
# and Contributors.
#
# SPDX-License-Identifier: BSL-1.0
#
# Collection of common functionality for Poco CMake
# Find the Microsoft mc.exe message compiler
#
# CMAKE_MC_COMPILER - where to find mc.exe
if (WIN32)
# cmake has CMAKE_RC_COMPILER, but no message compiler
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
# this path is only present for 2008+, but we currently require PATH to
# be set up anyway
get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH)
get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH)
get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH)
get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH)
get_filename_component(kit10wow_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH)
file(GLOB kit10_list ${kit10_dir}/bin/10.* ${kit10wow_dir}/bin/10.*)
if (X64)
set(sdk_bindir "${sdk_dir}/bin/x64")
set(kit_bindir "${kit_dir}/bin/x64")
set(kit81_bindir "${kit81_dir}/bin/x64")
foreach (tmp_elem ${kit10_list})
if (IS_DIRECTORY ${tmp_elem})
list(APPEND kit10_bindir "${tmp_elem}/x64")
endif()
endforeach()
else (X64)
set(sdk_bindir "${sdk_dir}/bin")
set(kit_bindir "${kit_dir}/bin/x86")
set(kit81_bindir "${kit81_dir}/bin/x86")
foreach (tmp_elem ${kit10_list})
if (IS_DIRECTORY ${tmp_elem})
list(APPEND kit10_bindir "${tmp_elem}/x86")
endif()
endforeach()
endif (X64)
endif ()
find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}" ${kit10_bindir}
DOC "path to message compiler")
if (NOT CMAKE_MC_COMPILER)
message(FATAL_ERROR "message compiler not found: required to build")
endif (NOT CMAKE_MC_COMPILER)
message(STATUS "Found message compiler: ${CMAKE_MC_COMPILER}")
mark_as_advanced(CMAKE_MC_COMPILER)
endif(WIN32)
#===============================================================================
# Macros for Source file management
#
# POCO_SOURCES_PLAT - Adds a list of files to the sources of a components
# Usage: POCO_SOURCES_PLAT( out name platform sources)
# INPUT:
# out the variable the sources are added to
# name: the name of the components
# platform: the platform this sources are for (ON = All, OFF = None, WIN32, UNIX ...)
# sources: a list of files to add to ${out}
# Example: POCO_SOURCES_PLAT( SRCS Foundation ON src/Foundation.cpp )
#
# POCO_SOURCES - Like POCO_SOURCES_PLAT with platform = ON (Built on all platforms)
# Usage: POCO_SOURCES( out name sources)
# Example: POCO_SOURCES( SRCS Foundation src/Foundation.cpp)
#
# POCO_SOURCES_AUTO - Like POCO_SOURCES but the name is read from the file header // Package: X
# Usage: POCO_SOURCES_AUTO( out sources)
# Example: POCO_SOURCES_AUTO( SRCS src/Foundation.cpp)
#
# POCO_SOURCES_AUTO_PLAT - Like POCO_SOURCES_PLAT but the name is read from the file header // Package: X
# Usage: POCO_SOURCES_AUTO_PLAT(out platform sources)
# Example: POCO_SOURCES_AUTO_PLAT( SRCS WIN32 src/Foundation.cpp)
#
#
# POCO_HEADERS - Adds a list of files to the headers of a components
# Usage: POCO_HEADERS( out name headers)
# INPUT:
# out the variable the headers are added to
# name: the name of the components
# headers: a list of files to add to HDRSt
# Example: POCO_HEADERS( HDRS Foundation include/Poco/Foundation.h )
#
# POCO_HEADERS_AUTO - Like POCO_HEADERS but the name is read from the file header // Package: X
# Usage: POCO_HEADERS_AUTO( out headers)
# Example: POCO_HEADERS_AUTO( HDRS src/Foundation.cpp)
#
#
# POCO_MESSAGES - Adds a list of files to the messages of a components
# and adds the generated headers to the header list of the component.
# On platforms other then Windows this does nothing
# Usage: POCO_MESSAGES( out name messages)
# INPUT:
# out the variable the message and the resulting headers are added to
# name: the name of the components
# messages: a list of files to add to MSGS
# Example: POCO_MESSAGES( HDRS Foundation include/Poco/Foundation.mc )
#
macro(POCO_SOURCES_PLAT out name platform)
source_group("${name}\\Source Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN})
if(NOT (${platform}))
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
endif()
endmacro()
macro(POCO_SOURCES out name)
POCO_SOURCES_PLAT( ${out} ${name} ON ${ARGN})
endmacro()
macro(POCO_SOURCES_AUTO out)
POCO_SOURCES_AUTO_PLAT( ${out} ON ${ARGN})
endmacro()
macro(POCO_SOURCES_AUTO_PLAT out platform)
foreach( f ${ARGN})
get_filename_component(fname ${f} NAME)
# Read the package name from the source file
file(STRINGS ${f} package REGEX "// Package: (.*)")
if(package)
string(REGEX REPLACE ".*: (.*)" "\\1" name ${package})
# Files of the Form X_UNIX.cpp are treated as headers
if(${fname} MATCHES ".*_.*\\..*")
#message(STATUS "Platform: ${name} ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} ${name} OFF ${f})
else()
#message(STATUS "Source: ${name} ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} ${name} ${platform} ${f})
endif()
else()
#message(STATUS "Source: Unknown ${f} ${platform}")
POCO_SOURCES_PLAT( ${out} Unknown ${platform} ${f})
endif()
endforeach()
endmacro()
macro(POCO_HEADERS_AUTO out)
foreach( f ${ARGN})
get_filename_component(fname ${f} NAME)
# Read the package name from the source file
file(STRINGS ${f} package REGEX "// Package: (.*)")
if(package)
string(REGEX REPLACE ".*: (.*)" "\\1" name ${package})
#message(STATUS "Header: ${name} ${f}")
POCO_HEADERS( ${out} ${name} ${f})
else()
#message(STATUS "Header: Unknown ${f}")
POCO_HEADERS( ${out} Unknown ${f})
endif()
endforeach()
endmacro()
macro(POCO_HEADERS out name)
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
source_group("${name}\\Header Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN})
endmacro()
macro(POCO_MESSAGES out name)
if (WIN32)
foreach(msg ${ARGN})
get_filename_component(msg_name ${msg} NAME)
get_filename_component(msg_path ${msg} ABSOLUTE)
string(REPLACE ".mc" ".h" hdr ${msg_name})
set_source_files_properties(${hdr} PROPERTIES GENERATED TRUE)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${hdr}
DEPENDS ${msg}
COMMAND ${CMAKE_MC_COMPILER}
ARGS
-h ${CMAKE_CURRENT_BINARY_DIR}
-r ${CMAKE_CURRENT_BINARY_DIR}
${msg_path}
VERBATIM # recommended: p260
)
# Add the generated file to the include directory
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Add the generated headers to POCO_HEADERS of the component
POCO_HEADERS( ${out} ${name} ${CMAKE_CURRENT_BINARY_DIR}/${hdr})
endforeach()
set_source_files_properties(${ARGN} PROPERTIES HEADER_FILE_ONLY TRUE)
source_group("${name}\\Message Files" FILES ${ARGN})
list(APPEND ${out} ${ARGN})
endif (WIN32)
endmacro()
#===============================================================================
# Macros for Package generation
#
# POCO_GENERATE_PACKAGE - Generates *Config.cmake
# Usage: POCO_GENERATE_PACKAGE(target_name)
# INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_GENERATE_PACKAGE(Foundation)
macro(POCO_GENERATE_PACKAGE target_name)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
if ("${CMAKE_VERSION}" VERSION_LESS "3.0.0")
if (NOT EXISTS "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake")
export(TARGETS "${target_name}" APPEND
FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::"
)
endif ()
else ()
export(EXPORT "${target_name}Targets"
FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::"
)
endif ()
configure_file("cmake/Poco${target_name}Config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
@ONLY
)
set(ConfigPackageLocation "lib/cmake/${PROJECT_NAME}")
install(
EXPORT "${target_name}Targets"
FILE "${PROJECT_NAME}${target_name}Targets.cmake"
NAMESPACE "${PROJECT_NAME}::"
DESTINATION "lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}"
)
install(
FILES
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}Config.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}${target_name}ConfigVersion.cmake"
DESTINATION "lib${LIB_SUFFIX}/cmake/${PROJECT_NAME}"
COMPONENT Devel
)
endmacro()
#===============================================================================
# Macros for simplified installation
#
# POCO_INSTALL - Install the given target
# Usage: POCO_INSTALL(target_name)
# INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_INSTALL(Foundation)
macro(POCO_INSTALL target_name)
install(
DIRECTORY include/Poco
DESTINATION include
COMPONENT Devel
PATTERN ".svn" EXCLUDE
)
install(
TARGETS "${target_name}" EXPORT "${target_name}Targets"
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
if (MSVC)
# install the targets pdb
POCO_INSTALL_PDB(${target_name})
endif()
endmacro()
# POCO_INSTALL_PDB - Install the given target's companion pdb file (if present)
# Usage: POCO_INSTALL_PDB(target_name)
# INPUT:
# target_name the name of the target. e.g. Foundation for PocoFoundation
# Example: POCO_INSTALL_PDB(Foundation)
#
# This is an internal macro meant only to be used by POCO_INSTALL.
macro(POCO_INSTALL_PDB target_name)
get_property(type TARGET ${target_name} PROPERTY TYPE)
if ("${type}" STREQUAL "SHARED_LIBRARY" OR "${type}" STREQUAL "EXECUTABLE")
install(
FILES $<TARGET_PDB_FILE:${target_name}>
DESTINATION bin
COMPONENT Devel
OPTIONAL
)
endif()
endmacro()

View File

@@ -0,0 +1,36 @@
CMAKE Files contributed by Andrew J. P. Maclean <a.maclean@optusnet.com.au>
Put the following files in the directory where your source code is:
CMakeLists.txt
PocoConfig.cmake.
Edit CMakeLists.txt to include your source and header files. The sections of interest are:
# Add any source files here.
SET( EXE_SRCS
"My File.cpp"
)
# Add any include files here.
SET( EXE_INCS
"My File.h"
)
Then create a subdirectory called build.
In Linux:
cd build
ccmake ..
or
ccmake -GKDevelop3 ..
(This will set up everything so you can use KDevelop3).
In Windows:
run CMakeSetup.exe and set the source code directory and where to build the libraries.
If CMake cannot find Poco, you will see that the variable Poco_INCLUDE_DIR has the value Poco_INCLUDE_DIR-NOTFOUND. Just set this value to the top level direcotry of where the Poco includes are.
If there is a different version of Poco, you may have to add edit the variables SUFFIX_FOR_INCLUDE_PATH, and SUFFIX_FOR_LIBRARY_PATH adding in the new Poco version in a similar manner to the existing ones in the file PocoConfig.cmake.
Finally:
In Linux
Either type "make" or if you are using KDevelop, click on the <ProjectName>.kdevelop file.
In Windows just use your IDE or nmake if you use nmake.

View File

@@ -0,0 +1,22 @@
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF("${rm_retval}" STREQUAL 0)
ELSE("${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF("${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)

View File

@@ -0,0 +1,9 @@
#include <iostream>
#include <string>
int main()
{
std::string str = "Try to compile";
std::cout << str << '\n';
return 0;
}

View File

@@ -0,0 +1 @@
input events entprellen über flanken statt zeit

View File

@@ -0,0 +1,193 @@
{
"global_bounce_time" : 10,
"input_matrix" :
[
{
"name" : "Out hole",
"address" : 16,
"priority" : 99,
"bounce_time" : 10
},
{
"name" : "Left outer exit canal",
"address" : 17,
"priority" : 2
},
{
"name" : "Inner left canal",
"address" : 18,
"priority" : 2
},
{
"name" : "Left flap contacts",
"address" : 19,
"priority" : 2
},
{
"name" : "Right flap contacts",
"address" : 20,
"priority" : 2
},
{
"name" : "Right inner canal",
"address" : 21,
"priority" : 2
},
{
"name" : "Right central exit canal",
"address" : 22,
"priority" : 2
},
{
"name" : "Right kicker contact",
"address" : 23,
"priority" : 2
},
{
"name" : "Contacts",
"address" : 24,
"priority" : 2
},
{
"name" : "1st moving target bottom left bank",
"address" : 25,
"priority" : 2
},
{
"name" : "2nd moving target bottom left bank",
"address" : 26,
"priority" : 2
},
{
"name" : "3rd moving target bottom left bank",
"address" : 27,
"priority" : 2
},
{
"name" : "4th moving target bottom left bank",
"address" : 28,
"priority" : 2
},
{
"name" : "Fixed special red target",
"address" : 29,
"priority" : 2
},
{
"name" : "Fixed special orange target",
"address" : 30,
"priority" : 2
},
{
"name" : "1st moving target bottom right bank",
"address" : 31,
"priority" : 2
},
{
"name" : "2nd moving target bottom right bank",
"address" : 32,
"priority" : 2
},
{
"name" : "3rd moving target bottom right bank",
"address" : 33,
"priority" : 2
},
{
"name" : "Spinning target",
"address" : 34,
"priority" : 2
},
{
"name" : "1st Button",
"address" : 35,
"priority" : 2
},
{
"name" : "2nd button",
"address" : 36,
"priority" : 2
},
{
"name" : "3rd button",
"address" : 37,
"priority" : 2
},
{
"name" : "4th button",
"address" : 38,
"priority" : 2
},
{
"name" : "5th button",
"address" : 39,
"priority" : 2
},
{
"name" : "1st moving target top central bank",
"address" : 40,
"priority" : 2
},
{
"name" : "2nd moving target top central bank",
"address" : 41,
"priority" : 2
},
{
"name" : "3rd moving target top central bank",
"address" : 42,
"priority" : 2
},
{
"name" : "4th moving target top central bank",
"address" : 43,
"priority" : 2
},
{
"name" : "5th moving target top central bank",
"address" : 44,
"priority" : 2
},
{
"name" : "1st fixed target",
"address" : 45,
"priority" : 2
},
{
"name" : "2nd fixed target",
"address" : 46,
"priority" : 2
},
{
"name" : "Top left pop contact",
"address" : 47,
"priority" : 2
},
{
"name" : "Bottom right pop contact",
"address" : 48,
"priority" : 2
},
{
"name" : "5th fixed target",
"address" : 49,
"priority" : 2
},
{
"name" : "4th fixed target",
"address" : 50,
"priority" : 2
},
{
"name" : "3rd fixed target",
"address" : 51,
"priority" : 2
},
{
"name" : "Rising ball contact",
"address" : 52,
"priority" : 2
}
]
}

View File

@@ -0,0 +1,14 @@
{
"update_frequency": 1000,
"row": {
"A": 15,
"B": 16,
"C": 1
},
"col": {
"A": 4,
"B": 5,
"C": 6
},
"data": 10
}

View File

@@ -0,0 +1,48 @@
{
"update_frequency": 1000,
"display_board" :
{
"segment_select" :
{
"A" : 22,
"B" : 27,
"C" : 17
},
"digit_select" :
{
"A": 19,
"B": 13,
"C": 6,
"D": 5
},
"run" : 12
},
"displays" :
[
{
"digits" : 8,
"name" : "Player_1",
"address" : 1
},
{
"digits" : 8,
"name" : "Player_2",
"address" : 20
},
{
"digits" : 8,
"name" : "Player_3",
"address" : 12
},
{
"digits" : 8,
"name" : "Player_4",
"address" : 16
},
{
"digits" : 8,
"name" : "Special_Display",
"address" : 4
}
]
}

View File

@@ -0,0 +1,417 @@
{
"port_extenders" :
[
{
"name" : "extender_1",
"i2c_address" : 32,
"pin_base" : 65
}
],
"address_pins" :
{
"A0":
{
"address" : 9,
"extender" : "extender_1"
},
"A1":
{
"address" : 8,
"extender" : "extender_1"
},
"A2":
{
"address" : 1,
"extender" : "extender_1"
}
},
"enable_pins":
{
"E1" :
{
"address" : 2,
"extender" : "extender_1"
},
"E2" :
{
"address" : 10,
"extender" : "extender_1"
},
"E3" :
{
"address" : 3,
"extender" : "extender_1"
},
"E4" :
{
"address" : 11,
"extender" : "extender_1"
},
"E5" :
{
"address" : 4,
"extender" : "extender_1"
},
"E6" :
{
"address" : 12,
"extender" : "extender_1"
},
"E7" :
{
"address" : 5,
"extender" : "extender_1"
},
"E8" :
{
"address" : 13,
"extender" : "extender_1"
},
"E9" :
{
"address" : 12
},
"E10" :
{
"address" : 13
},
"E11" :
{
"address" : 6,
"extender" : "extender_1"
},
"E12" :
{
"address" : 14,
"extender" : "extender_1"
},
"E13" :
{
"address" : 15,
"extender" : "extender_1"
}
},
"data_pin" : {
"address" : 0,
"extender" : "extender_1"
},
"run" : {
"address" : 7,
"extender" : "extender_1"
},
"lamps" :
[
{
"address" : 0,
"name" : "Special 100000 Points"
},
{
"address" : 1,
"name" : "Special 200000 Points"
},
{
"address" : 2,
"name" : "Woman Speech Lamp"
},
{
"address" : 3,
"name" : "Highest Score"
},
{
"address" : 4,
"name" : "Pop 2+4"
},
{
"address" : 5,
"name" : "Special 300000 Points"
},
{
"address" : 6,
"name" : "Pop 1+3"
},
{
"address" : 7,
"name" : "Special Orange"
},
{
"address" : 8,
"name" : "Down"
},
{
"address" : 9,
"name" : "Lamp 30 Sec"
},
{
"address" : 10,
"name" : "Lamp 20 Sec"
},
{
"address" : 11,
"name" : "Lamp 10 Sec"
},
{
"address" : 12,
"name" : "Lamp 5 Sec"
},
{
"address" : 13,
"name" : "Can Play 4"
},
{
"address" : 14,
"name" : "Can Play 3"
},
{
"address" : 15,
"name" : "P Of Champ"
},
{
"address" : 16,
"name" : "M Of Champ"
},
{
"address" : 17,
"name" : "A Of Champ"
},
{
"address" : 18,
"name" : "Can Play 2"
},
{
"address" : 19,
"name" : "Big Bonus 20000"
},
{
"address" : 20,
"name" : "Can Play 1"
},
{
"address" : 21,
"name" : "H Of Champ"
},
{
"address" : 22,
"name" : "C Of Champ"
},
{
"address" : 23,
"name" : "Special Red"
},
{
"address" : 24,
"name" : "Super Bonus"
},
{
"address" : 25,
"name" : "Bonus 20000"
},
{
"address" : 26,
"name" : "2nd Kicker Lamp"
},
{
"address" : 27,
"name" : "Bonus 18000"
},
{
"address" : 28,
"name" : "Bonus 17000"
},
{
"address" : 29,
"name" : "Bonus 16000"
},
{
"address" : 30,
"name" : "Man Speech Lamp"
},
{
"address" : 31,
"name" : "Bonus 15000"
},
{
"address" : 32,
"name" : "Bonus 14000"
},
{
"address" : 33,
"name" : "Bonus 13000"
},
{
"address" : 34,
"name" : "Bonus 12000"
},
{
"address" : 35,
"name" : "Ball"
},
{
"address" : 36,
"name" : "Bonus 11000"
},
{
"address" : 37,
"name" : "Bonus 10000"
},
{
"address" : 38,
"name" : "Bonus 9000"
},
{
"address" : 39,
"name" : "Bonus 8000"
},
{
"address" : 40,
"name" : "Bonus 7000"
},
{
"address" : 41,
"name" : "Bonus 6000"
},
{
"address" : 42,
"name" : "Bonus 5000"
},
{
"address" : 43,
"name" : "Pop 5 Head Lamp"
},
{
"address" : 44,
"name" : "Bonus 3000"
},
{
"address" : 45,
"name" : "Bonus 2000"
},
{
"address" : 46,
"name" : "Bonus 1000"
},
{
"address" : 47,
"name" : "Bonus 4000"
},
{
"address" : 48,
"name" : "Right Advance Time"
},
{
"address" : 49,
"name" : "UP"
},
{
"address" : 50,
"name" : "Bonux Multiplier x50"
},
{
"address" : 51,
"name" : "Bonus Multiplier x20"
},
{
"address" : 52,
"name" : "Bonus Multiplier x10"
},
{
"address" : 53,
"name" : "Credit"
},
{
"address" : 54,
"name" : "Bonus 19000"
},
{
"address" : 55,
"name" : "5th Button"
},
{
"address" : 56,
"name" : "4th Button"
},
{
"address" : 57,
"name" : "3rd Button"
},
{
"address" : 58,
"name" : "2nd Button"
},
{
"address" : 59,
"name" : "1st Button"
},
{
"address" : 61,
"name" : "Lamp 5"
},
{
"address" : 62,
"name" : "Lamp 4"
},
{
"address" : 63,
"name" : "Ball To Play"
},
{
"address" : 64,
"name" : "Tunnel Lamp 20000 Points"
},
{
"address" : 65,
"name" : "Tunnel Lamp 30000 Points"
},
{
"address" : 66,
"name" : "Tunnel Lamp 50000 Points"
},
{
"address" : 67,
"name" : "Match"
},
{
"address" : 68,
"name" : "Lamp 3"
},
{
"address" : 69,
"name" : "Lamp 2"
},
{
"address" : 70,
"name" : "1st Kicker Lamp"
},
{
"address" : 71,
"name" : "Lamp 1"
},
{
"address" : 72,
"name" : "Left Advance Time"
},
{
"address" : 73,
"name" : "Tilt"
},
{
"address" : 74,
"name" : "Game Over"
},
{
"address" : 75,
"name" : "500000 Points"
},
{
"address" : 76,
"name" : "200000 Points"
},
{
"address" : 77,
"name" : "150000 Points"
},
{
"address" : 78,
"name" : "100000 Points"
}
]
}

View File

@@ -0,0 +1,71 @@
{
"port_extenders" :
[
{
"name" : "extender_0",
"i2c_address" : 32,
"pin_base" : 65
}
],
"deactivation_time_milliseconds" : 10,
"flippers" :
[
{
"address" : 60,
"name" : "Flipper Relay"
},
{
"address" : 91,
"name" : "Top Flipper Relay"
}
],
"solenoids" :
[
{
"_comment" :"addresses relative to port_extender",
"address" : 79,
"name" : "Out Hole",
"deactivation_time_milliseconds" : 15
},
{
"address" : 82,
"name" : "Bottom Right Pop"
},
{
"address" : 92,
"name" : "Right Kicker"
},
{
"address" : 94,
"name" : "Top Central Bank"
},
{
"address" : 95,
"name" : "Coin Mechanism Coil"
},
{
"address" : 96,
"name" : "Top Left Pop"
},
{
"address" : 97,
"name" : "Bottom Right Bank"
},
{
"address" : 98,
"name" : "Bottom Left Bank"
},
{
"address" : 99,
"name" : "Knocker"
},
{
"address" : 100,
"name" : "Right Flap"
},
{
"address" : 101,
"name" : "Left Flap"
}
]
}

View File

@@ -0,0 +1,336 @@
{
"port_extenders" :
[
{
"i2c_address" : 34,
"name" : "extender_0",
"pin_base" : 81
}
],
"fire_pin" :
{
"address" : 13,
"extender" : "extender_0"
},
"address_pins" :
[
{
"id" : 0,
"address" : 15,
"extender" : "extender_0"
},
{
"id" : 1,
"address" : 14,
"extender" : "extender_0"
},
{
"id" : 2,
"address" : 12,
"extender" : "extender_0"
},
{
"id" : 3,
"address" : 10,
"extender" : "extender_0"
},
{
"id" : 4,
"address" : 8,
"extender" : "extender_0"
},
{
"id" : 5,
"address" : 9,
"extender" : "extender_0"
},
{
"id" : 6,
"address" : 11,
"extender" : "extender_0"
}
],
"sounds" :
[
{
"id" : 255,
"address" : 0,
"name" : "Deactivation Sound"
},
{
"id" : 0,
"address" : 22,
"name" : "Sound 1"
},
{
"id" : 1,
"address" : 23,
"name" : "Sound 2"
},
{
"id" : 2,
"address" : 24,
"name" : "Sound 3"
},
{
"id" : 3,
"address" : 25,
"name" : "Sound 4"
},
{
"id" : 4,
"address" : 26,
"name" : "Sound 5"
},
{
"id" : 5,
"address" : 27,
"name" : "Sound 6"
},
{
"id" : 6,
"address" : 28,
"name" : "Sound 7"
},
{
"id" : 7,
"address" : 29,
"name" : "Sound 8"
},
{
"id" : 8,
"address" : 30,
"name" : "Sound 9"
},
{
"id" : 9,
"address" : 31,
"name" : "Sound 10"
},
{
"id" : 10,
"address" : 32,
"name" : "Sound 11"
},
{
"id" : 11,
"address" : 33,
"name" : "Sound 12"
},
{
"id" : 12,
"address" : 34,
"name" : "Sound 13"
},
{
"id" : 13,
"address" : 35,
"name" : "Sound 14"
},
{
"id" : 14,
"address" : 36,
"name" : "Sound 15"
},
{
"id" : 15,
"address" : 37,
"name" : "Sound 16"
},
{
"id" : 16,
"address" : 38,
"name" : "Sound 17"
},
{
"id" : 17,
"address" : 39,
"name" : "Sound 18"
},
{
"id" : 18,
"address" : 40,
"name" : "Sound 19"
},
{
"id" : 19,
"address" : 41,
"name" : "Sound 20"
},
{
"id" : 20,
"address" : 42,
"name" : "Sound 21"
},
{
"id" : 21,
"address" : 43,
"name" : "Sound 22"
},
{
"id" : 22,
"address" : 44,
"name" : "Sound 23"
},
{
"id" : 23,
"address" : 45,
"name" : "Sound 24"
},
{
"id" : 24,
"address" : 46,
"name" : "Sound 25"
},
{
"id" : 25,
"address" : 47,
"name" : "Sound 26"
},
{
"id" : 26,
"address" : 48,
"name" : "Sound 27"
},
{
"id" : 27,
"address" : 49,
"name" : "Sound 28"
},
{
"id" : 28,
"address" : 50,
"name" : "Speech 1: \"You're good! But I'm still the Champ!\""
},
{
"id" : 29,
"address" : 51,
"name" : "Speech 2: \"Twenty\""
},
{
"id" : 30,
"address" : 52,
"name" : "Speech 3: \"Seconds\""
},
{
"id" : 31,
"address" : 53,
"name" : "Speech 4: \"Five, Four, Three, Two, One.\""
},
{
"id" : 32,
"address" : 54,
"name" : "Speech 5: \"Challenge the champ!\""
},
{
"id" : 33,
"address" : 55,
"name" : "Speech 6: \"Good. You're a champ!\""
},
{
"id" : 34,
"address" : 56,
"name" : "Speech 7: \"Wow.\""
},
{
"id" : 35,
"address" : 57,
"name" : "Speech 8: \"This is a maximum score.\""
},
{
"id" : 36,
"address" : 58,
"name" : "Speech 9: \"What a low score!\""
},
{
"id" : 37,
"address" : 59,
"name" : "Speech 10: \"Try harder!\""
},
{
"id" : 38,
"address" : 60,
"name" : "Speech 11: \"Be careful.\""
},
{
"id" : 39,
"address" : 61,
"name" : "Speech 12: \"The last ball.\""
},
{
"id" : 40,
"address" : 62,
"name" : "Speech 13: \"Be ready for the Game Time Bonus.\""
},
{
"id" : 41,
"address" : 63,
"name" : "Speech 14: \"That's naughty!\""
},
{
"id" : 42,
"address" : 64,
"name" : "Speech 15: \"Another coin please.\""
},
{
"id" : 43,
"address" : 65,
"name" : "Speech 16: \"Sorry. The time is over.\""
},
{
"id" : 44,
"address" : 66,
"name" : "Speech 17: \"I am the champ! Challenge me!\""
},
{
"id" : 45,
"address" : 67,
"name" : "Speech 18: \"Time is short.\""
},
{
"id" : 46,
"address" : 68,
"name" : "Speech 19: \"Once again for the special.\""
},
{
"id" : 47,
"address" : 69,
"name" : "Speech 20: \"Go for the high level board.\""
},
{
"id" : 48,
"address" : 70,
"name" : "Speech 21: \"Play gently to beat me.\""
},
{
"id" : 49,
"address" : 71,
"name" : "Speech 22: \"Quick! Hit the special.\""
},
{
"id" : 50,
"address" : 72,
"name" : "Speech 23: \"Shoot the special.\""
},
{
"id" : 51,
"address" : 73,
"name" : "Speech 24: \"Thirty\""
},
{
"id" : 52,
"address" : 74,
"name" : "Speech 25: \"Red\""
},
{
"id" : 53,
"address" : 75,
"name" : "Speech 27: \"Yellow\""
},
{
"id" : 54,
"address" : 76,
"name" : "Speech 28: \"Go for the Special.\""
}
]
}

View File

@@ -0,0 +1,10 @@
{
"type" : "Solenoid",
"name" : "Right flap",
"functions" :
{
"trigger" : false
}
}
string function;
lamp

View File

@@ -0,0 +1,8 @@
{
"input-config" :"../../contrib/json_example/input/Input_Pin_Config.json",
"matrix-config" :"../../contrib/json_example/input/Input_Matrix_Config.json",
"lamp-config" :"../../contrib/json_example/output/Lamp_Config.json",
"solenoid-config" :"../../contrib/json_example/output/Solenoid_Config.json",
"sound-config" :"../../contrib/json_example/output/Sound_Config.json",
"display-config" :"../../contrib/json_example/output/Display_Config.json"
}

View File

@@ -0,0 +1,14 @@
#!/bin/sh
echo "Making sure the code compiles!!!"
if [ ! -d 'FlippR-Driver/build' ]; then
echo "Make sure you have the build folder!"
exit 1
fi
cd FlippR-Driver/build
cmake ..
make
exit $rc

View File

@@ -0,0 +1,13 @@
@startuml
Sound -> GPIOInterface:activate()
GPIOInterface --> GPIOInterface:setAddress()
GPIOInterface --> GPIOInterface:setDataPin(1)
GPIOInterface -> Sound:done
Sound --> Sound:sleep_for()
Sound -> GPIOInterface:deactivate()
GPIOInterface --> GPIOInterface:setAddress()
GPIOInterface --> GPIOInterface:setDataPin(0)
GPIOInterface -> Sound:done
@enduml

View File

@@ -0,0 +1,373 @@
@startuml
/' Objects '/
namespace flippR_driver::output::items {
class Display <template<int DigitCount>> {
+Display(int address, int id)
+~Display()
-address : int
+content : std::array<char, DigitCount>
-fit_string(std::string& score_string) : std::string
+get_content() : std::vector<char>
+write_content(std::array<char, DigitCount> content) : void
+write_score(int score) : void
}
}
namespace flippR_driver::output {
class DisplayController {
+DisplayController(std::vector<std::shared_ptr<items::IDisplay> > displays, std::shared_ptr<utility::IOutputGPIOInterface> pin_controller)
+~DisplayController()
-is_running : bool
-pin_controller : std::shared_ptr<utility::IOutputGPIOInterface>
-display_cycle_thread : std::thread
-displays : std::vector<std::shared_ptr<items::IDisplay> >
-cycle_displays() : void
}
}
namespace flippR_driver::utility {
class DisplayGPIOInterface {
+DisplayGPIOInterface()
+~DisplayGPIOInterface()
}
}
namespace flippR_driver::utility {
class GPIOInterface {
+GPIOInterface()
+~GPIOInterface()
#{static} read_pin(char address) : bool
+{static} GPIO_LIB_INITIALIZED : static std::once_flag
-pin_base : unsigned int
#{static} initialize_input_pin(char address) : void
#{static} initialize_output_pin(char address) : void
#{static} write_pin(char address, char data) : void
}
}
namespace flippR_driver::utility {
abstract class IBlockingQueue <template<typename T>> {
+~IBlockingQueue()
+{abstract} pop() : T
+{abstract} push(T const& value) : void
}
}
namespace flippR_driver::output::items {
abstract class IDisplay {
+IDisplay()
+~IDisplay()
+{abstract} get_content() : std::vector<char>
}
}
namespace flippR_driver::output {
class IDisplayController {
+IDisplayController()
+~IDisplayController()
}
}
namespace flippR_driver::output::items {
class IDriverBoardItem {
+~IDriverBoardItem()
}
}
namespace flippR_driver::utility {
abstract class IInputGPIOInterface {
+~IInputGPIOInterface()
+{abstract} read_data(char pin) : bool
}
}
namespace flippR_driver::output::items {
abstract class IItem {
+~IItem()
+{abstract} get_address() : uint8_t
}
}
namespace flippR_driver::utility {
abstract class IOutputGPIOInterface {
+~IOutputGPIOInterface()
+{abstract} activate(output::items::IDriverBoardItem* driver_board_item) : void
+{abstract} activate(output::items::ISoundItem* sound) : void
+{abstract} deactivate(output::items::IDriverBoardItem* driver_board_item) : void
+{abstract} deactivate(output::items::ISoundItem* sound) : void
+{abstract} write_display(std::shared_ptr<output::items::IDisplay> display) : void
}
}
namespace flippR_driver::output::items {
class ISoundItem {
}
}
namespace flippR_driver::utility {
class InputGPIOInterface {
+InputGPIOInterface(std::istream& input_config)
+read_data(char pin) : bool
-col_address_A : char
-col_address_B : char
-col_address_C : char
-data_address : char
-row_address_A : char
-row_address_B : char
-row_address_C : char
-init_members(std::istream& input_config_stream) : void
-init_pins() : void
-write_col(char data) : void
-write_row(char data) : void
}
}
namespace flippR_driver::utility {
class InputSocketHandler {
+InputSocketHandler(boost::asio::io_service& service, std::string socket_file)
-serialize_event(input::Event& event) : nlohmann::json
+handle(input::Event& event) : void
}
}
namespace flippR_driver::output::items {
class Item {
+Item(std::shared_ptr<utility::IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~Item()
#gpio_interface : const std::shared_ptr<utility::IOutputGPIOInterface>
#name : const std::string
#address : const uint8_t
+get_address() : uint8_t
}
}
namespace flippR_driver::output::items {
class Lamp {
+Lamp(std::shared_ptr<utility::IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~Lamp()
-activated : bool
+is_activated() : bool
+activate() : void
+deactivate() : void
}
}
namespace flippR_driver::output {
class OutputDriver {
+OutputDriver(std::map<std::string, std::shared_ptr<items::ISolenoid> > solenoids, std::map<std::string, std::shared_ptr<items::ILamp> > lamps, std::map<char, std::shared_ptr<items::IDisplay> > displays, std::map<std::string, std::shared_ptr<items::ISound> > sounds)
+~OutputDriver()
-displays : std::map<char, std::shared_ptr<items::IDisplay> >
-lamps : std::map<std::string, std::shared_ptr<items::ILamp> >
-solenoids : std::map<std::string, std::shared_ptr<items::ISolenoid> >
-sounds : std::map<std::string, std::shared_ptr<items::ISound> >
+get_display(char number) : std::shared_ptr<items::IDisplay>
+get_lamp(std::string name) : std::shared_ptr<items::ILamp>
+get_solenoid(std::string name) : std::shared_ptr<items::ISolenoid>
+get_sound(std::string name) : std::shared_ptr<items::ISound>
+get_displays() : std::vector<std::shared_ptr<items::IDisplay> >
+get_lamps() : std::vector<std::shared_ptr<items::ILamp> >
+get_solenoids() : std::vector<std::shared_ptr<items::ISolenoid> >
+get_sounds() : std::vector<std::shared_ptr<items::ISound> >
}
}
namespace flippR_driver::output {
class OutputDriverFactory {
+{static} getOutputDriver(std::ifstream& output_gpio_config, std::ifstream& output_config) : std::shared_ptr<OutputDriver>
}
}
namespace flippR_driver::utility {
class OutputGPIOInterface {
+OutputGPIOInterface(std::istream& output_config_stream)
+~OutputGPIOInterface()
-pins_display : std::map<std::string, uint8_t>
-pins_driver_board : std::map<std::string, uint8_t>
-pins_sound : std::map<std::string, uint8_t>
-output_item_mutex : std::mutex
+activate(output::items::IDriverBoardItem* driver_board_item) : void
+activate(output::items::ISoundItem* sound) : void
+deactivate(output::items::IDriverBoardItem* driver_board_item) : void
+deactivate(output::items::ISoundItem* sound) : void
-fire_sound(bool fire) : void
-initialize_all_pins(uint8_t pin_base) : void
-initialize_i2c_addresses() : void
-initialize_pins() : void
-parse_output_config(nlohmann::json& output_config) : void
-parse_pins_display(nlohmann::json& display_board_config) : void
-parse_pins_driver_board(nlohmann::json& driver_board_config) : void
-parse_pins_sound(nlohmann::json& sound_board_config) : void
-select_latch(uint8_t latch) : void
-select_mux(uint8_t latch) : void
-select_pin(uint8_t pin) : void
-write_data(bool data) : void
+write_display(output::items::IDisplay* display) : void
-write_driver_board_address(uint8_t address) : void
-write_sound_address(uint8_t address) : void
}
}
namespace flippR_driver::utility {
class SocketHandler {
+SocketHandler(boost::asio::io_service& service, std::string socket_file)
#socket : boost::asio::local::stream_protocol::socket
#write_to_socket(nlohmann::json& data) : void
}
}
namespace flippR_driver::output::items {
class Solenoid {
+Solenoid(std::shared_ptr<utility::IOutputGPIOInterface> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time)
+~Solenoid()
-deactivation_time : std::chrono::milliseconds
-trigger_task : std::future<void>
+trigger() : void
-triggerTask() : void
}
}
namespace flippR_driver::output::items {
class Sound {
+Sound(std::shared_ptr<utility::IOutputGPIOInterface> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id)
+~Sound()
-deactivation_time : std::chrono::milliseconds
-play_task : std::future<void>
+id : u_int
+play() : void
-playTask() : void
}
}
/' Inheritance relationships '/
namespace flippR_driver::utility {
GPIOInterface <|-- InputGPIOInterface
}
namespace flippR_driver::utility {
GPIOInterface <|-- OutputGPIOInterface
}
namespace flippR_driver::output::items {
IDisplay <|-- Display
}
namespace flippR_driver::output {
IDisplayController <|-- DisplayController
}
namespace flippR_driver::output::items {
IDriverBoardItem <|-- Lamp
}
namespace flippR_driver::output::items {
IDriverBoardItem <|-- Solenoid
}
namespace flippR_driver::utility {
IInputGPIOInterface <|-- InputGPIOInterface
}
namespace flippR_driver::output::items {
IItem <|-- IDriverBoardItem
}
namespace flippR_driver::output::items {
IItem <|-- ISoundItem
}
namespace flippR_driver::output::items {
IItem <|-- Item
}
namespace flippR_driver::utility {
IOutputGPIOInterface <|-- OutputGPIOInterface
}
namespace flippR_driver::output::items {
ISoundItem <|-- Sound
}
namespace flippR_driver::output::items {
Item <|-- Lamp
}
namespace flippR_driver::output::items {
Item <|-- Solenoid
}
namespace flippR_driver::output::items {
Item <|-- Sound
}
namespace flippR_driver::utility {
SocketHandler <|-- InputSocketHandler
}
/' Aggregation relationships '/
flippR_driver::output.DisplayController o-- flippR_driver::output::items.IDisplay
flippR_driver::output.DisplayController o-- flippR_driver::utility.IOutputGPIOInterface
flippR_driver::output::items.Item o-- flippR_driver::utility.IOutputGPIOInterface
flippR_driver::output.OutputDriver o-- flippR_driver::output::items.IDisplay
@enduml

View File

@@ -0,0 +1,256 @@
@startuml
/' Objects '/
namespace flippR_driver::output::items {
class Display <template<int DigitCount>> {
+Display(int address, int id)
+~Display()
-address : int
+content : std::array<char, DigitCount>
-fit_string(std::string& score_string) : std::string
+get_content() : std::vector<char>
+write_content(std::array<char, DigitCount> content) : void
+write_score(int score) : void
}
}
namespace flippR_driver::output {
class DisplayController {
+DisplayController(std::vector<std::shared_ptr<items::IDisplay> > displays, std::shared_ptr<IOutputGPIOInterface> pin_controller)
+~DisplayController()
-is_running : bool
-pin_controller : std::shared_ptr<IOutputGPIOInterface>
-display_cycle_thread : std::thread
-displays : std::vector<std::shared_ptr<items::IDisplay> >
-cycle_displays() : void
}
}
namespace flippR_driver::output::items {
class DriverBoardItem {
+DriverBoardItem(std::shared_ptr<IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~DriverBoardItem()
}
}
namespace flippR_driver::output::items {
abstract class IDisplay {
+~IDisplay()
+{abstract} get_content() : std::vector<char>
}
}
namespace flippR_driver::output {
class IDisplayController {
+~IDisplayController()
}
}
namespace flippR_driver::output::items {
abstract class IItem {
+~IItem()
+{abstract} get_name() : std::string
+{abstract} get_address() : uint8_t
}
}
namespace flippR_driver::output {
abstract class IOutputGPIOInterface {
+~IOutputGPIOInterface()
+{abstract} activate(items::DriverBoardItem* driver_board_item) : void
+{abstract} activate(items::SoundItem* sound) : void
+{abstract} deactivate(items::DriverBoardItem* driver_board_item) : void
+{abstract} deactivate(items::SoundItem* sound) : void
+{abstract} write_display(std::shared_ptr<output::items::IDisplay> display) : void
}
}
namespace flippR_driver::output::items {
class Item {
+Item(std::shared_ptr<IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~Item()
#gpio_interface : const std::shared_ptr<IOutputGPIOInterface>
#name : const std::string
#address : const uint8_t
+get_name() : std::string
+get_address() : uint8_t
}
}
namespace flippR_driver::output::items {
class Lamp {
+Lamp(std::shared_ptr<IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~Lamp()
-activated : bool
+is_activated() : bool
+activate() : void
+deactivate() : void
}
}
namespace flippR_driver::output {
class OutputDriver {
+OutputDriver(std::map<std::string, std::shared_ptr<items::ISolenoid> > solenoids, std::map<std::string, std::shared_ptr<items::ILamp> > lamps, std::map<std::string, std::shared_ptr<items::ISound> > sounds, std::map<char, std::shared_ptr<items::IDisplay> > displays)
+~OutputDriver()
+get_display(char number) : boost::optional<std::shared_ptr<items::IDisplay> >
+get_lamp(std::string name) : boost::optional<std::shared_ptr<items::ILamp> >
+get_solenoid(std::string name) : boost::optional<std::shared_ptr<items::ISolenoid> >
+get_sound(std::string name) : boost::optional<std::shared_ptr<items::ISound> >
-displays : const std::map<char, std::shared_ptr<items::IDisplay> >
-lamps : const std::map<std::string, std::shared_ptr<items::ILamp> >
-solenoids : const std::map<std::string, std::shared_ptr<items::ISolenoid> >
-sounds : const std::map<std::string, std::shared_ptr<items::ISound> >
+get_displays() : std::vector<std::shared_ptr<items::IDisplay> >
+get_lamps() : std::vector<std::shared_ptr<items::ILamp> >
+get_solenoids() : std::vector<std::shared_ptr<items::ISolenoid> >
+get_sounds() : std::vector<std::shared_ptr<items::ISound> >
}
}
namespace flippR_driver::output {
class OutputGPIOInterface {
+OutputGPIOInterface(std::map<std::string, uint8_t> pins_driver_board, std::map<std::string, uint8_t> pins_sound, std::map<std::string, uint8_t> pins_display)
+~OutputGPIOInterface()
-pins_display : const std::map<std::string, uint8_t>
-pins_driver_board : const std::map<std::string, uint8_t>
-pins_sound : const std::map<std::string, uint8_t>
-output_item_mutex : std::mutex
+activate(items::DriverBoardItem* driver_board_item) : void
+activate(items::SoundItem* sound) : void
+deactivate(items::DriverBoardItem* driver_board_item) : void
+deactivate(items::SoundItem* sound) : void
-fire_sound(bool fire) : void
-initialize_all_pins(uint8_t pin_base) : void
-initialize_i2c_addresses() : void
-initialize_pins() : void
-select_latch(uint8_t latch) : void
-select_mux(uint8_t latch) : void
-select_pin(uint8_t pin) : void
-write_data(bool data) : void
+write_display(std::shared_ptr<output::items::IDisplay> display) : void
-write_driver_board_address(uint8_t address) : void
-write_sound_address(uint8_t address) : void
}
}
namespace flippR_driver::output::items {
class Solenoid {
+Solenoid(std::shared_ptr<IOutputGPIOInterface> pin_controller, u_int8_t address, std::string name, std::chrono::milliseconds deactivation_time)
+~Solenoid()
-deactivation_time : std::chrono::milliseconds
-trigger_task : std::future<void>
+trigger() : void
-triggerTask() : void
}
}
namespace flippR_driver::output::items {
class Sound {
+Sound(std::shared_ptr<IOutputGPIOInterface> pin_controller, uint8_t address, std::string name, std::chrono::milliseconds deactivation_time, u_int id)
+~Sound()
-deactivation_time : std::chrono::milliseconds
-play_task : std::future<void>
+id : u_int
+play() : void
-playTask() : void
}
}
namespace flippR_driver::output::items {
class SoundItem {
+SoundItem(std::shared_ptr<IOutputGPIOInterface> pin_controller, uint8_t address, std::string name)
+~SoundItem()
}
}
/' Inheritance relationships '/
namespace flippR_driver::output::items {
DriverBoardItem <|-- Lamp
}
namespace flippR_driver::output::items {
DriverBoardItem <|-- Solenoid
}
namespace flippR_driver::output::items {
IDisplay <|-- Display
}
namespace flippR_driver::output {
IDisplayController <|-- DisplayController
}
namespace flippR_driver::output::items {
IItem <|-- Item
}
namespace flippR_driver::output {
IOutputGPIOInterface <|-- OutputGPIOInterface
}
namespace flippR_driver::output::items {
Item <|-- DriverBoardItem
}
namespace flippR_driver::output::items {
Item <|-- SoundItem
}
namespace flippR_driver::output::items {
SoundItem <|-- Sound
}
/' Aggregation relationships '/
flippR_driver::output.DisplayController o-- flippR_driver::output::items.IDisplay
namespace flippR_driver::output {
DisplayController o-- IOutputGPIOInterface
}
flippR_driver::output::items.Item o-- flippR_driver::output.IOutputGPIOInterface
flippR_driver::output.OutputDriver o-- flippR_driver::output::items.IDisplay
@enduml

View File

@@ -1 +0,0 @@

View File

@@ -1,16 +0,0 @@
{
"input_matrix" :
[
{
"name" : "event_01",
"address" : 123,
"priority" : 1
},
{
"name" : "event_02",
"address" : 2,
"priority" : 2
},
]
}

View File

@@ -0,0 +1,23 @@
//
// Created by rhetenor on 13.09.18.
//
#ifndef flippR_driver_DRIVERFACTORY_H
#define flippR_driver_DRIVERFACTORY_H
#include <istream>
#include <memory>
#include "input/InputDriver.h"
#include "output/OutputDriver.h"
namespace flippR_driver
{
std::shared_ptr<input::InputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream);
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::string & lamp_config_path,
std::string & solenoid_config_path,
std::string & sound_config_path,
std::string & display_config_path);
}
#endif //flippR_driver_DRIVERFACTORY_H

View File

@@ -0,0 +1,44 @@
/*
* InputEvent.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef INPUTEVENT_H_
#define INPUTEVENT_H_
#include <set>
#include <string>
#include <chrono>
namespace flippR_driver {
namespace input {
class Event {
public:
Event(uint8_t address, int priority, std::string name);
std::string getJsonString();
friend bool operator==(const Event &left, const Event &right);
friend bool operator<(const Event &left, const Event &right) {
return left.priority < right.priority;
}
public:
std::string name;
uint8_t address;
int priority;
std::chrono::time_point<std::chrono::high_resolution_clock> last_activation;
};
bool operator==(const Event &left, const Event &right);
}
}
#endif /* INPUTEVENT_H_ */

View File

@@ -0,0 +1,43 @@
/*
* EventHandler.h
*
* Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef SRC_IEVENTHANDLER_H_
#define SRC_IEVENTHANDLER_H_
#include "input/Event.h"
#include "InputDriver.h"
#include <memory>
namespace flippR_driver
{
namespace input
{
class EventHandler
{
public:
explicit EventHandler(std::shared_ptr<InputDriver> input_driver) :
input_driver(std::move(input_driver))
{
this->input_driver->register_event_handler(std::shared_ptr<EventHandler>(this));
}
virtual ~EventHandler()
{
this->input_driver->unregister_event_handler(std::shared_ptr<EventHandler>(this));
};
virtual void handle(flippR_driver::input::Event &event) = 0;
private:
const std::shared_ptr<InputDriver> input_driver;
};
}
}
#endif /* SRC_IEVENTHANDLER_H_ */

View File

@@ -0,0 +1,37 @@
/*
* InputDriver.h
*
* Created on: Jun 14, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef SRC_INPUT_IINPUTDRIVER_H_
#define SRC_INPUT_IINPUTDRIVER_H_
#include "Event.h"
#include <memory>
#include <boost/optional/optional_io.hpp>
namespace flippR_driver
{
namespace input
{
class EventHandler;
class InputDriver {
public:
virtual ~InputDriver() = default;
virtual void register_event_handler(std::shared_ptr<EventHandler> handler) = 0;
virtual void unregister_event_handler(std::shared_ptr<EventHandler> handler) = 0;
virtual boost::optional<std::shared_ptr<Event>> get_event(std::string name) = 0;
};
}
}
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */

View File

@@ -0,0 +1,78 @@
/*
* OutputDriver.h
*
* Created on: Aug 2, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _SRC_OUTPUT_IOUTPUTDRIVER_H_
#define _SRC_OUTPUT_IOUTPUTDRIVER_H_
#include <vector>
#include <memory>
#include <map>
#include <boost/optional.hpp>
#include "output/DisplayController.h"
#include "output/items/Solenoid.h"
#include "output/items/Lamp.h"
#include "output/items/Sound.h"
#include "output/items/Display.h"
#include "output/items/Flipper.h"
namespace flippR_driver
{
namespace output
{
class OutputDriver
{
public:
OutputDriver(std::shared_ptr<output::DisplayController> display_controller, std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids,
std::map<std::string, std::shared_ptr<items::Lamp>> lamps, std::map<std::string, std::shared_ptr<items::Sound>> sounds,
std::map<std::string, std::shared_ptr<items::Flipper>> flippers, std::map<std::string, std::shared_ptr<output::items::Display>> displays);
~OutputDriver() = default;
void activate_displays() const;
void deactivate_displays() const;
void activate_all_lamps() const;
void deactivate_all_lamps() const;
void rotate_all_lamps() const;
void activate_all_flipper_relays() const;
void deactivate_all_flipper_relays() const;
void shut_down_driver() const;
// todo driver board run for activate/deactivate?
// todo what is flipper_relay ?
std::vector<std::shared_ptr<items::Lamp>> get_lamps() const;
std::vector<std::shared_ptr<items::Solenoid>> get_solenoids() const;
std::vector<std::shared_ptr<items::Sound>> get_sounds() const;
std::vector<std::shared_ptr<items::Flipper>> get_flippers() const;
std::vector<std::shared_ptr<items::Display>> get_displays() const;
boost::optional<std::shared_ptr<items::Lamp>> get_lamp(const std::string &name) const;
boost::optional<std::shared_ptr<items::Solenoid>> get_solenoid(const std::string &name) const;
boost::optional<std::shared_ptr<items::Sound>> get_sound(const std::string &name) const;
boost::optional<std::shared_ptr<items::Flipper>> get_flipper(const std::string &name) const;
boost::optional<std::shared_ptr<items::Display>> get_display(const std::string &name) const;
private:
std::shared_ptr<output::DisplayController> display_controller;
const std::map<std::string, std::shared_ptr<items::Lamp>> lamps;
const std::map<std::string, std::shared_ptr<items::Solenoid>> solenoids;
const std::map<std::string, std::shared_ptr<items::Sound>> sounds;
const std::map<std::string, std::shared_ptr<items::Flipper>> flippers;
const std::map<std::string, std::shared_ptr<items::Display>> displays;
};
} /* namespace output */
}
#endif

View File

@@ -0,0 +1,34 @@
/*
* IOutputDisplay.h
*
* Created on: Nov 20, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef FLIPPR_DRIVER_OUTPUT_ITEMS_DISPLAY_H_
#define FLIPPR_DRIVER_OUTPUT_ITEMS_DISPLAY_H_
#include "Item.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
class Display : public virtual items::Item
{
public:
virtual ~Display() = default;
virtual void write_score(unsigned int score) = 0;
};
}
}
}
#endif /* SRC_OUTPUT_IOUTPUTDISPLAY_H_ */

View File

@@ -0,0 +1,30 @@
//
// Created by rhetenor on 20.11.18.
//
#ifndef FLIPPR_DRIVER_OUTPUT_ITEMS_EIGHTDIGITDISPLAY_H
#define FLIPPR_DRIVER_OUTPUT_ITEMS_EIGHTDIGITDISPLAY_H
#include <string>
#include "output/items/Display.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
class EightDigitDisplay : public virtual Display
{
public:
virtual ~EightDigitDisplay() = default;
virtual void write_content(std::string content) = 0;
};
}
}
}
#endif //FLIPPR_DRIVER_IEIGHTDIGITDISPLAY_H

View File

@@ -0,0 +1,35 @@
/*
* Flipper.h
*
* Created on: May 5, 2019
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _INCLUDE_FLIPPR_CODE_FLIPPER_H
#define _INCLUDE_FLIPPR_CODE_FLIPPER_H
#include "Item.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
class Flipper : public virtual Item
{
public:
virtual ~Flipper() = default;
virtual void activate() = 0;
virtual void deactivate() = 0;
virtual bool is_activated() = 0;
};
}
}
}
#endif //FLIPPR_CODE_FLIPPER_H

View File

@@ -0,0 +1,34 @@
/*
* ICabinetItem.h
*
* Created on: Aug 7, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _SRC_OUTPUT_ICABINETITEM_H_
#define _SRC_OUTPUT_ICABINETITEM_H_
#include <string>
#include <Poco/RefCountedObject.h>
#include <Poco/JSON/Object.h>
namespace flippR_driver
{
namespace output
{
namespace items
{
class Item
{
public:
virtual ~Item() = default;
virtual std::string get_name() const = 0;
};
}
}
}
#endif

View File

@@ -0,0 +1,37 @@
/*
* Lamp.h
*
* Created on: Aug 7, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _SRC_OUTPUT_ILAMP_H_
#define _SRC_OUTPUT_ILAMP_H_
#include "Item.h"
#include <chrono>
namespace flippR_driver
{
namespace output
{
namespace items
{
class Lamp : public virtual Item
{
public:
virtual ~Lamp() = default;
virtual void activate() = 0;
virtual void deactivate() = 0;
virtual bool is_activated() = 0;
virtual std::chrono::milliseconds get_activation_time() const = 0;
};
}
}
}
#endif

View File

@@ -0,0 +1,30 @@
//
// Created by rhetenor on 20.11.18.
//
#ifndef FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
#define FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H
#include <string>
#include "Display.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
class SevenDigitDisplay : public virtual Display
{
public:
virtual ~SevenDigitDisplay() = default;
virtual void write_content(std::string & content) = 0;
};
}
}
}
#endif //FLIPPR_DRIVER_ISEVENDIGITDISPLAY_H

View File

@@ -0,0 +1,33 @@
/*
* Solenoid.h
*
* Created on: Aug 7, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _SRC_OUTPUT_ISOLENOID_H_
#define _SRC_OUTPUT_ISOLENOID_H_
#include "Item.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
// todo get name? parent calss output_item?
class Solenoid : public virtual Item
{
public:
virtual ~Solenoid() = default;
virtual void trigger() = 0;
};
}
}
}
#endif

View File

@@ -0,0 +1,31 @@
/*
* Sound.h
*
* Created on: Aug 2, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef _SRC_OUTPUT_ISOUND_H_
#define _SRC_OUTPUT_ISOUND_H_
#include "Item.h"
namespace flippR_driver
{
namespace output
{
namespace items
{
class Sound : public virtual Item
{
public:
virtual ~Sound() = default;
virtual void play() = 0;
};
}
} /* namespace output */
}
#endif

View File

@@ -270,7 +270,7 @@ using enable_if_t = typename std::enable_if<B, T>::type;
template<typename T> template<typename T>
using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type; using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
// implementation of C++14 index_sequence and affiliates // impl of C++14 index_sequence and affiliates
// source: https://stackoverflow.com/a/32223343 // source: https://stackoverflow.com/a/32223343
template<std::size_t... Ints> template<std::size_t... Ints>
struct index_sequence struct index_sequence
@@ -7369,7 +7369,7 @@ boundaries compute_boundaries(FloatType value)
// value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
static_assert(std::numeric_limits<FloatType>::is_iec559, static_assert(std::numeric_limits<FloatType>::is_iec559,
"internal error: dtoa_short requires an IEEE-754 floating-point implementation"); "internal error: dtoa_short requires an IEEE-754 floating-point impl");
constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit) constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1); constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);

View File

@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.6.2)
project(flippR_driver_networking)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/networking)
set(SOURCES
input/InputSocketHandler.cpp
output/OutputRequestHandler.cpp
output/OutputRequestHandlerFactory.cpp
FlippRServer.cpp
input/InputSocketHandlerFactory.cpp
)
add_executable(${PROJECT_NAME} ${SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE FlippR-Driver)
####################### POCO ##############################
find_package(Poco REQUIRED COMPONENTS Foundation Net JSON Util)
if(NOT Poco_FOUND)
message(FATAL_ERROR, "Could not find libPoco")
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC Poco::Foundation Poco::Net Poco::JSON Poco::Util)

View File

@@ -0,0 +1,298 @@
//
// Created by rhetenor on 5/21/19.
//
#include "FlippRServer.h"
#include "output/OutputRequestHandlerFactory.h"
#include "input/InputSocketHandlerFactory.h"
#include "DriverFactory.h"
#include "utility/Colors.h"
#include "utility/LoggerFactory.h"
#include <Poco/Net/SocketAddress.h>
#include <Poco/Net/ServerSocket.h>
#include <Poco/Net/HTTPServer.h>
#include <Poco/Util/HelpFormatter.h>
#include <Poco/JSON/Parser.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <boost/filesystem.hpp>
int main(int argc, char** argv)
{
std::cout << FGRN("Starting FlippR-Server ... ") << std::endl;
flippR_driver::networking::FlippRServer app;
return app.run(argc, argv);
}
namespace flippR_driver
{
namespace networking
{
using namespace Poco::Net;
using namespace Poco::Util;
using namespace Poco::JSON;
using namespace Poco;
namespace fs = boost::filesystem;
FlippRServer::FlippRServer() :
help_requested(false),
input_port(9980),
output_port(9981)
{}
void FlippRServer::parse_server_config_file()
{
std::ifstream config;
Parser parser;
Object::Ptr json;
try
{
config.open(this->server_config);
}
catch(const std::exception e)
{
logger().error(FCYN("server_config.json not specified!"));
exit(Application::EXIT_USAGE);
}
try
{
auto parse = parser.parse(config);
json = parse.extract<Object::Ptr>();
}
catch(const std::exception e)
{
logger().error(e.what());
exit(Application::EXIT_IOERR);
}
logger().information(FCYN("Parsing server_config.json..."));
Object::NameList keys = json->getNames();
std::sort(keys.begin(), keys.end());
if(!std::includes(keys.begin(), keys.end(), REQUIRED_CONFIG_KEYS.begin(), REQUIRED_CONFIG_KEYS.end()))
{
std::string config_keys;
config_keys = std::accumulate(REQUIRED_CONFIG_KEYS.begin(), REQUIRED_CONFIG_KEYS.end(), config_keys);
logger().error("Need all of the following keys to be specified in server_config json" + config_keys);
Application::EXIT_USAGE;
}
this->configs = *json;
config.close();
}
void FlippRServer::uninitialize()
{
this->output_driver->shut_down_driver();
this->output_server->stop();
ServerApplication::uninitialize();
Poco::File socket_file(this->output_socket_file_path);
if (socket_file.exists())
socket_file.remove();
Poco::File input_socket_file(this->input_socket_file_path);
if (input_socket_file.exists())
input_socket_file.remove();
}
/**
* Initially called before main.
*/
void FlippRServer::initialize(Application &self)
{
this->parse_server_config_file();
//Todo May restructure with subsystems
//make this one application and subsystems ServerApplications
this->initialize_output_driver();
//this->initialize_input_driver();
this->output_server = std::unique_ptr<Poco::Net::HTTPServer>(this->build_output_server());
this->output_server->start();
this->input_server = std::unique_ptr<TCPServer>(this->build_input_server());
//this->input_server->start();
logger().warning(FRED("Input server not started!"));
ServerApplication::initialize(self);
}
void FlippRServer::initialize_output_driver()
{
std::string lamp_config_path;
std::string solenoid_config_path;
std::string sound_config_path;
std::string display_config_path;
try
{
lamp_config_path = this->configs["lamp-config"].toString();
solenoid_config_path = this->configs["solenoid-config"].toString();
sound_config_path = this->configs["sound-config"].toString();
display_config_path = this->configs["display-config"].toString();
}
catch(const std::exception& e)
{
logger().error(e.what());
exit(EXIT_FAILURE);
}
this->output_driver = flippR_driver::get_OutputDriver(solenoid_config_path,
lamp_config_path,
sound_config_path,
display_config_path);
}
void FlippRServer::initialize_input_driver()
{
std::ifstream input_config_stream;
std::ifstream matrix_config_stream;
try
{
input_config_stream.open(this->configs["input-config"].toString());
matrix_config_stream.open(this->configs["matrix-config"].toString());
}
catch(const std::exception& e)
{
logger().error(e.what());
exit(EXIT_FAILURE);
}
this->input_driver = flippR_driver::get_InputDriver(input_config_stream, matrix_config_stream);
}
int FlippRServer::main(const std::vector<std::string>& args)
{
if(!help_requested)
{
logger().information(FGRN("Server running!"));
waitForTerminationRequest();
}
return Application::EXIT_OK;
}
HTTPServer* FlippRServer::build_output_server()
{
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->output_port);
this->output_socket_file_path = this->get_runtime_dir() + OUTPUT_SOCKET_NAME;
Poco::File socket_file(output_socket_file_path);
if (socket_file.exists())
socket_file.remove();
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
ServerSocket server_socket(address);
return new HTTPServer(new OutputRequestHandlerFactory(this->output_driver), server_socket, new HTTPServerParams);
}
TCPServer* FlippRServer::build_input_server()
{
unsigned short port = (unsigned short) config().getInt("FlippRServer.port", this->input_port);
this->input_socket_file_path = this->get_runtime_dir() + INPUT_SOCKET_NAME;
Poco::File socket_file(input_socket_file_path);
if (socket_file.exists())
{
socket_file.remove();
logger().information(FRED("Seems that server is already running. Make sure that only one instance of server is running."));
}
SocketAddress address(SocketAddress::UNIX_LOCAL, socket_file.path());
ServerSocket server_socket(address);
return new TCPServer(new input::InputSocketHandlerFactory(this->input_driver), server_socket);
}
void FlippRServer::defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display this help")
.required(false)
.repeatable(false)
.callback(OptionCallback<FlippRServer>(
this, &FlippRServer::handle_help)));
options.addOption(Option("input-port", "i", "Define the port for the TCP-Input-Server, which represents the flipper inputs. Default 9980")
.required(false)
.repeatable(false)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
.argument("input-port", true));
options.addOption(Option("output-port", "o", "Define the port for the HTTP-Output-Server, which represents the flipper outputs. Default 9981")
.required(false)
.repeatable(false)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
.argument("output-port", true));
options.addOption(Option("server-config", "s", "Specify where the server-config file with paths to the other configs is located. Only needed when not in this folder.")
.required(true)
.repeatable(false)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::handle_config_file))
.argument("server-config", true));
options.addOption(Option("debug", "d", "Switch debug messages on.")
.required(false)
.repeatable(true)
.callback(OptionCallback<FlippRServer>(this, &FlippRServer::create_debug_logger)));
}
void FlippRServer::handle_config_file(const std::string &name, const std::string &value)
{
if(name == "input-port")
this->input_port = std::stoi(value);
else if(name == "output-port")
this->output_port = std::stoi(value);
else if(name == "server-config")
this->server_config = value;
else
{
logger().information("Configuration \"" + name + "\" is not known.");
return;
}
logger().information(KMAG "Set " + name + " to " + value + RST);
}
void FlippRServer::handle_help(const std::string& name, const std::string& value)
{
Poco::Util::HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader(
"The FlippR-Server, one must specify a json with all needed config files.");
helpFormatter.format(std::cout);
stopOptionsProcessing();
help_requested = true;
}
std::string FlippRServer::get_runtime_dir()
{
return std::getenv("XDG_RUNTIME_DIR") ? std::string(std::getenv("XDG_RUNTIME_DIR")) + "/" : DEFAULT_RUNTIME_DIR;
}
void FlippRServer::create_debug_logger(const std::string &name, const std::string &value)
{
utility::LoggerFactory::ActivateDebugLog();
logger().information(FCYN("Activated debug logging."));
}
}
}

View File

@@ -0,0 +1,74 @@
//
// Created by rhetenor on 5/21/19.
//
#ifndef FLIPPR_DRIVER_FLIPPRSERVER_H
#define FLIPPR_DRIVER_FLIPPRSERVER_H
#include "output/OutputDriver.h"
#include "input/InputDriver.h"
#include <Poco/Util/ServerApplication.h>
#include <Poco/Net/HTTPServer.h>
#include <Poco/Dynamic/Struct.h>
#include <Poco/File.h>
namespace flippR_driver
{
namespace networking
{
class FlippRServer : public Poco::Util::ServerApplication
{
public:
FlippRServer();
int main(const std::vector<std::string>& args);
void initialize(Poco::Util::Application& self);
void uninitialize();
void defineOptions(Poco::Util::OptionSet& options);
void handle_help(const std::string &name, const std::string &port);
void handle_config_file(const std::string &name, const std::string &value);
private:
void initialize_output_driver();
void initialize_input_driver();
void parse_server_config_file();
std::string get_runtime_dir();
Poco::Net::HTTPServer* build_output_server();
Poco::Net::TCPServer* build_input_server();
void create_debug_logger(const std::string &name, const std::string &value);
private:
const char * DEFAULT_RUNTIME_DIR = "/tmp/";
const char * INPUT_SOCKET_NAME = "S.flippR_driver.in";
const char * OUTPUT_SOCKET_NAME = "S.flippR_driver.out";
const std::vector<std::string> REQUIRED_CONFIG_KEYS = {"display-config", "input-config", "lamp-config",
"matrix-config", "solenoid-config", "sound-config"};
std::string output_socket_file_path, input_socket_file_path;
int input_port;
int output_port;
bool help_requested;
Poco::DynamicStruct configs;
std::string server_config;
std::shared_ptr<input::InputDriver> input_driver;
std::shared_ptr<output::OutputDriver> output_driver;
std::unique_ptr<Poco::Net::HTTPServer> output_server;
std::unique_ptr<Poco::Net::TCPServer> input_server;
};
};
}
#endif //FLIPPR_DRIVER_FLIPPRSERVER_H

View File

@@ -0,0 +1,58 @@
/*
* SocketConnection.cpp
*
* Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "InputSocketHandler.h"
using Poco::Net::StreamSocket;
using Poco::Net::TCPServerConnection;
using flippR_driver::input::InputDriver;
using flippR_driver::input::EventHandler;
using flippR_driver::input::Event;
namespace flippR_driver
{
namespace networking
{
namespace input
{
InputSocketHandler::InputSocketHandler(StreamSocket streamSocket, std::shared_ptr<InputDriver> inputDriver) :
TCPServerConnection(streamSocket),
EventHandler(inputDriver)
{
}
void InputSocketHandler::run()
{
//todo should ne closed when connection is closed
// while(this->socket().poll(100, Poco::Net::Socket::SelectMode::SELECT_ERROR))
while(true)
{
Event event = this->queue.pop();
if(event.name == "END")
{
return;
}
std::string str = event.getJsonString() + std::string(1, 0x02 ) ;
this->socket().sendBytes(str.c_str(), str.size());
}
}
void InputSocketHandler::handle(Event &event)
{
this->queue.push(event);
}
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* SocketConnection.h
*
* Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef FLIPPR_CODE_INPUTSOCKETCONNECTION_H
#define FLIPPR_CODE_INPUTSOCKETCONNECTION_H
#include <Poco/Net/TCPServerConnection.h>
#include "input/InputDriver.h"
#include "input/EventHandler.h"
#include "input/Event.h"
#include "utility/BlockingQueue.hpp"
namespace flippR_driver
{
namespace networking
{
namespace input
{
class InputSocketHandler : public Poco::Net::TCPServerConnection, flippR_driver::input::EventHandler
{
public:
InputSocketHandler(Poco::Net::StreamSocket streamSocket, std::shared_ptr<flippR_driver::input::InputDriver> input_driver);
void run() override;
void handle(flippR_driver::input::Event &event) override;
private:
utility::BlockingQueue<flippR_driver::input::Event> queue;
};
}
}
}
#endif //FLIPPR_CODE_INPUTSOCKETCONNECTION_H

View File

@@ -0,0 +1,31 @@
//
// Created by johannes on 15.06.19.
//
#include "InputSocketHandlerFactory.h"
#include "InputSocketHandler.h"
namespace flippR_driver
{
namespace networking
{
namespace input
{
using namespace Poco::Net;
InputSocketHandlerFactory::InputSocketHandlerFactory(std::shared_ptr<flippR_driver::input::InputDriver> inputDriver) :
input_driver(inputDriver)
{
}
TCPServerConnection *InputSocketHandlerFactory::createConnection(const Poco::Net::StreamSocket &socket)
{
return new InputSocketHandler(socket, this->input_driver);
}
}
}
}

View File

@@ -0,0 +1,33 @@
//
// Created by johannes on 15.06.19.
//
#ifndef FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H
#define FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H
#include <Poco/Net/TCPServerConnectionFactory.h>
#include <input/InputDriver.h>
namespace flippR_driver
{
namespace networking
{
namespace input
{
class InputSocketHandlerFactory : public Poco::Net::TCPServerConnectionFactory
{
public:
explicit InputSocketHandlerFactory(std::shared_ptr<flippR_driver::input::InputDriver> inputDriver);
Poco::Net::TCPServerConnection* createConnection(const Poco::Net::StreamSocket &socket) override;
private:
std::shared_ptr<flippR_driver::input::InputDriver> input_driver;
};
}
}
}
#endif //FLIPPR_DRIVER_INPUTSOCKETHANDLERFACTORY_H

View File

@@ -0,0 +1,9 @@
//
// Created by rhetenor on 5/21/19.
//
int main(int argc, const char* argv[])
{
}

View File

@@ -0,0 +1,21 @@
//
// Created by rhetenor on 4/15/19.
//
#include <Poco/Net/HTTPServerParams.h>
#include "OutputHTTPServer.h"
#include "OutputRequestHandlerFactory.h"
namespace flippR_driver
{
namespace networking
{
using namespace Poco::Net;
OutputHTTPServer::OutputHTTPServer(std::shared_ptr<output::OutputDriver> output_driver, Socket &socket) :
HTTPServer(new OutputRequestHandlerFactory(output_driver), socket, new HTTPServerParams())
{}
}
}

View File

@@ -0,0 +1,28 @@
//
// Created by rhetenor on 4/15/19.
//
#ifndef FLIPPR_CODE_OUTPUTHTTPSERVER_H
#define FLIPPR_CODE_OUTPUTHTTPSERVER_H
#include <Poco/Net/HTTPServer.h>
#include <Poco/Net/Socket.h>
#include "output/OutputDriver.h"
namespace flippR_driver
{
namespace networking
{
class OutputHTTPServer : public Poco::Net::HTTPServer
{
public:
explicit OutputHTTPServer(std::shared_ptr<output::OutputDriver> output_driver, Poco::Net::Socket &socket);
};
}
}
#endif //FLIPPR_CODE_OUTPUTHTTPSERVER_H

View File

@@ -0,0 +1,319 @@
//
// Created by rhetenor on 3/6/19.
//
#include <Poco/Net/HTTPServerResponse.h>
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Exception.h>
#include <string>
#include "OutputRequestHandler.h"
namespace flippR_driver
{
namespace networking
{
using namespace Poco;
using namespace Poco::Net;
OutputRequestHandler::OutputRequestHandler(std::shared_ptr<output::OutputDriver> output_driver) :
output_driver(output_driver)
{}
/**
* Handles a REST request with a URI form of:
*
* address/{item_type}/[item_name]/[action]/[score]
*
* Where
* {item_type} is either solenoids, lamps, sounds, displays, or one of the two special events: activate and deactivate
* [item_name] is the string name of an item (optional if you want to get the list of all available items)
* [action] is the particular action for the item:
* Solenoids: trigger
* lamps: activate, deactivate, status
* sounds: play
* displays: write_score (for this is the additional optional attribute [score]
*
* @param request
* @param response
*/
void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
HTTPServerResponse &response)
{
auto path_segments = getPathSegments(URI(request.getURI()));
// fill up vector
for(int i = path_segments.size(); i < 4; i++)
{
path_segments.emplace_back("");
}
std::string item_type = path_segments.at(0);
std::string item_name = path_segments.at(1);
std::string action = path_segments.at(2);
std::string score = path_segments.at(3);
if(item_type == "deactivate")
{
this->output_driver->deactivate_displays();
this->output_driver->deactivate_all_lamps();
this->output_driver->deactivate_all_flipper_relays();
return;
}
if(item_type == "activate")
{
this->output_driver->activate_displays();
this->output_driver->activate_all_flipper_relays();
return;
}
response.setContentType("text/json");
try
{
boost::optional<Poco::JSON::Object> json_response = parseRequest(item_type, item_name, action, score);
if(json_response)
{
response.setStatus(HTTPServerResponse::HTTP_OK);
std::ostream& ostr = response.send();
json_response->stringify(ostr);
}
}
catch(const NotFoundException &e)
{
response.setStatusAndReason(HTTPServerResponse::HTTP_NOT_FOUND, e.displayText());
}
catch(const Poco::InvalidArgumentException &e)
{
response.setStatusAndReason(HTTPServerResponse::HTTP_BAD_REQUEST, e.displayText());
}
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score)
{
std::string log_msg = "Got request from client to " + action + " " + item_type + " with name " + item_name + " (" + score + ")";
Poco::Logger::root().information(log_msg);
if(item_type == "solenoids")
{
return parseSolenoid(item_name, action);
}
else if(item_type == "lamps")
{
return parseLamp(item_name, action);
}
else if(item_type == "sounds")
{
return parseSound(item_name, action);
}
else if(item_type == "displays")
{
return parseDisplay(item_name, action, score);
}
else if(item_type == "flippers")
{
return parseFlipper(item_name, action);
}
else
{
throw new Poco::NotFoundException("No item type called " + item_type);
}
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
response.set("solenoids", getItemArray(this->output_driver->get_solenoids()) );
return response;
}
auto opt_solenoid = this->output_driver->get_solenoid(item_name);
if(!opt_solenoid)
{
throw new Poco::NotFoundException("No solenoid with name \"" + item_name + "\"!");
}
auto solenoid = opt_solenoid->get();
if(action == "trigger")
{
solenoid->trigger();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on solenoids!");
}
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
response.set("lamps", getItemArray(this->output_driver->get_lamps()) );
return response;
}
auto opt_lamp = this->output_driver->get_lamp(item_name);
if(!opt_lamp)
{
throw new Poco::NotFoundException("No lamp with name \"" + item_name + "\"!");
}
auto lamp = opt_lamp->get();
if(action == "activate")
{
lamp->activate();
}
else if(action == "deactivate")
{
lamp->deactivate();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on lamps!");
}
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
response.set("sounds", getItemArray(this->output_driver->get_sounds()) );
return response;
}
auto opt_sound = this->output_driver->get_sound(item_name);
if(!opt_sound)
{
throw new Poco::NotFoundException("No sound with name \"" + item_name + "\"!");
}
auto sound = opt_sound->get();
if(action == "play")
{
sound->play();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on sounds!");
}
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std::string& display_name, const std::string& action, const std::string& score)
{
Poco::JSON::Object response;
if(display_name == "")
{
response.set("displays", getItemArray(this->output_driver->get_displays()));
return response;
}
auto opt_display = this->output_driver->get_display(display_name);
if(!opt_display)
{
throw new Poco::NotFoundException("No display with name \"" + display_name + "\"!");
}
auto display = opt_display->get();
if(action == "write_score")
{
try
{
unsigned int numerical_score = std::stoi(score);
display->write_score(numerical_score);
}
catch(std::invalid_argument &e)
{
throw new Poco::InvalidArgumentException("Could not convert " + score + " to a number!\n" + e.what());
}
}
else
{
throw new Poco::NotFoundException("No Action with name \"" + action + "\" on sounds!");
}
return response;
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseFlipper(const std::string& item_name, const std::string& action)
{
Poco::JSON::Object response;
if(item_name == "")
{
response.set("flippers", getItemArray(this->output_driver->get_flippers()) );
return response;
}
auto opt_flipper = this->output_driver->get_flipper(item_name);
if(!opt_flipper)
{
throw new Poco::NotFoundException("No flipper with name \"" + item_name + "\"!");
}
auto flipper = opt_flipper->get();
if(action == "activate")
{
flipper->activate();
}
else if(action == "deactivate")
{
flipper->deactivate();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on flippers!");
}
return response;
}
std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)
{
std::vector<std::string> path_segments;
uri.getPathSegments(path_segments);
return path_segments;
}
template<typename T>
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items)
{
Poco::JSON::Array array;
for ( auto & item : items )
{
Poco::JSON::Object var;
var.set("name", item->get_name());
array.add(var);
}
return array;
}
}
}

View File

@@ -0,0 +1,261 @@
//
// Created by rhetenor on 3/6/19.
//
#include <Poco/Net/HTTPServerResponse.h>
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Exception.h>
#include <string>
#include "OutputRequestHandler.h"
namespace flippR_driver
{
namespace networking
{
using namespace Poco;
using namespace Poco::Net;
OutputRequestHandler::OutputRequestHandler(std::shared_ptr<output::OutputDriver> output_driver) :
output_driver(output_driver)
{}
/**
* Handles a REST request with a URI form of:
*
* address/{item_type}/[item_name]/[action]/[score]
*
* Where
* {item_type} is either solenoids, lamps, sounds, displays, or one of the two special events: activate and deactivate
* [item_name] is the string name of an item (optional if you want to get the list of all available items)
* [action] is the particular action for the item:
* solenoids: trigger
* lamps: activate, deactivate, status
* sounds: play
* displays: write_score (for this is the additional optional attribute [score]
*
* @param request
* @param response
*/
void OutputRequestHandler::handleRequest(HTTPServerRequest &request,
HTTPServerResponse &response)
{
auto path_segments = getPathSegments(URI(request.getURI()));
// fill up vector
for(int i = path_segments.size(); i < 4; i++)
{
path_segments.emplace_back("");
}
std::string item_type = path_segments.at(0);
std::string item_name = path_segments.at(1);
std::string action = path_segments.at(2);
std::string score = path_segments.at(3);
if(item_type == "deactivate")
{
this->output_driver->deactivate_displays();
this->output_driver->deactivate_all_lamps();
return;
}
if(item_type == "activate")
{
this->output_driver->activate_displays();
return;
}
response.setContentType("text/json");
response.setStatus(HTTPServerResponse::HTTP_OK);
try
{
boost::optional<Poco::JSON::Object> json_response = parseRequest(item_type, item_name, action, score);
if(json_response)
{
std::ostream& ostr = response.send();
json_response->stringify(ostr);
}
}
catch(const NotFoundException &e)
{
response.setStatusAndReason(HTTPServerResponse::HTTP_NOT_FOUND, e.displayText());
}
catch(const Poco::InvalidArgumentException &e)
{
response.setStatusAndReason(HTTPServerResponse::HTTP_BAD_REQUEST, e.displayText());
}
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score)
{
if(item_type == "solenoids")
{
return parseSolenoid(item_name, action);
}
else if(item_type == "lamps")
{
return parseLamp(item_name, action);
}
else if(item_type == "sounds")
{
return parseSound(item_name, action);
}
else if(item_type == "displays")
{
return parseDisplay(item_name, action, score);
}
else
{
throw new Poco::NotFoundException("No item type called " + item_type);
}
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSolenoid(const std::string& item_name, const std::string& action)
{
if(item_name == "")
{
Poco::JSON::Object response;
response.set("solenoids", this->output_driver->get_solenoids());
return response;
}
auto opt_solenoid = this->output_driver->get_solenoid(item_name);
if(!opt_solenoid)
{
throw new Poco::NotFoundException("No solenoid with name \"" + item_name + "\"!");
}
auto solenoid = opt_solenoid->get();
if(action == "trigger")
{
solenoid->trigger();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on solenoids!");
}
return {};
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseLamp(const std::string& item_name, const std::string& action)
{
if(item_name == "")
{
Poco::JSON::Object response;
response.set("lamps", this->output_driver->get_lamps());
return response;
}
auto opt_lamp = this->output_driver->get_lamp(item_name);
if(!opt_lamp)
{
throw new Poco::NotFoundException("No lamp with name \"" + item_name + "\"!");
}
auto lamp = opt_lamp->get();
if(action == "activate")
{
lamp->activate();
}
else if(action == "deactivate")
{
lamp->deactivate();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on lamps!");
}
return {};
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseSound(const std::string& item_name, const std::string& action)
{
if(item_name == "")
{
Poco::JSON::Object response;
response.set("sounds", this->output_driver->get_sounds());
return response;
}
auto opt_sound = this->output_driver->get_sound(item_name);
if(!opt_sound)
{
throw new Poco::NotFoundException("No sound with name \"" + item_name + "\"!");
}
auto sound = opt_sound->get();
if(action == "play")
{
sound->play();
}
else
{
throw new Poco::NotFoundException("No action with name \"" + action + "\" on sounds!");
}
return {};
}
boost::optional<Poco::JSON::Object> OutputRequestHandler::parseDisplay(const std::string& item_name, const std::string& action, const std::string& score)
{
if(item_name == "")
{
Poco::JSON::Object response;
response.set("displays", this->output_driver->get_displays());
return response;
}
uint8_t display_number = std::stoi(item_name);
auto opt_display = this->output_driver->get_display(display_number);
if(!opt_display)
{
throw new Poco::NotFoundException("No display with number \"" + item_name + "\"!");
}
auto display = opt_display->get();
if(action == "write_score")
{
try
{
unsigned int numerical_score = std::stoi(score);
display->write_score(numerical_score);
}
catch(std::invalid_argument &e)
{
throw new Poco::InvalidArgumentException("Could not convert " + score + " to a number!\n" + e.what());
}
}
else
{
throw new Poco::NotFoundException("No Action with name \"" + action + "\" on sounds!");
}
return {};
}
std::vector<std::string> OutputRequestHandler::getPathSegments(Poco::URI uri)
{
std::vector<std::string> path_segments;
uri.getPathSegments(path_segments);
return path_segments;
}
}
}

View File

@@ -0,0 +1,53 @@
//
// Created by rhetenor on 3/6/19.
//
#ifndef FLIPPR_CODE_OUTPUTREQUESTHANDLER_H
#define FLIPPR_CODE_OUTPUTREQUESTHANDLER_H
#include <Poco/Net/HTTPRequestHandler.h>
#include <Poco/URI.h>
#include <Poco/JSON/JSON.h>
#include <memory>
#include <boost/optional.hpp>
#include <Poco/Logger.h>
#include <Poco/JSON/Object.h>
#include "output/OutputDriver.h"
namespace flippR_driver
{
namespace networking
{
class OutputRequestHandler : public Poco::Net::HTTPRequestHandler
{
public:
OutputRequestHandler(std::shared_ptr<output::OutputDriver> output_driver);
void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response) override;
private:
boost::optional<Poco::JSON::Object> parseRequest(const std::string& item_type, const std::string& item_name, const std::string& action, const std::string& score = 0);
boost::optional<Poco::JSON::Object> parseSolenoid(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseLamp(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseSound(const std::string& item_name, const std::string& action);
boost::optional<Poco::JSON::Object> parseDisplay(const std::string& display_name, const std::string& action, const std::string& score);
boost::optional<Poco::JSON::Object> parseFlipper(const std::string& item_name, const std::string& action);
std::vector<std::string> getPathSegments(Poco::URI uri);
private:
std::shared_ptr<output::OutputDriver> output_driver;
};
template<typename T>
Poco::JSON::Array getItemArray(const std::vector<std::shared_ptr<T>> & items);
}
}
#endif //FLIPPR_CODE_OUTPUTREQUESTHANDLER_H

View File

@@ -0,0 +1,24 @@
//
// Created by rhetenor on 4/15/19.
//
#include "OutputRequestHandlerFactory.h"
#include "OutputRequestHandler.h"
namespace flippR_driver
{
namespace networking
{
using namespace Poco::Net;
OutputRequestHandlerFactory::OutputRequestHandlerFactory(std::shared_ptr<output::OutputDriver> output_driver) :
output_driver(output_driver)
{}
HTTPRequestHandler *OutputRequestHandlerFactory::createRequestHandler(const HTTPServerRequest &request)
{
return new OutputRequestHandler(this->output_driver);
}
}
}

View File

@@ -0,0 +1,31 @@
//
// Created by rhetenor on 4/15/19.
//
#ifndef FLIPPR_CODE_OUTPUTREQUESTHANDLERFACTORY_H
#define FLIPPR_CODE_OUTPUTREQUESTHANDLERFACTORY_H
#include <Poco/Net/HTTPRequestHandlerFactory.h>
#include <memory>
#include "output/OutputDriver.h"
namespace flippR_driver
{
namespace networking
{
class OutputRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory
{
public:
explicit OutputRequestHandlerFactory(std::shared_ptr<output::OutputDriver> output_driver);
Poco::Net::HTTPRequestHandler* createRequestHandler(const Poco::Net::HTTPServerRequest& request) override;
private:
std::shared_ptr<output::OutputDriver> output_driver;
};
}
}
#endif //FLIPPR_CODE_OUTPUTREQUESTHANDLERFACTORY_H

View File

@@ -0,0 +1,6 @@
[Dolphin]
Timestamp=2019,5,6,20,16,26
Version=4
[Settings]
HiddenFilesShown=true

View File

@@ -1,3 +0,0 @@
project(flippr-driver)
subdirs(bin input lib tests utilities)

View File

@@ -0,0 +1,26 @@
//
// Created by rhetenor on 13.09.18.
//
#include "DriverFactory.h"
#include "utility/LoggerFactory.h"
#include "input/InputDriverFactory.h"
#include "output/OutputDriverFactory.h"
namespace flippR_driver
{
std::shared_ptr<input::InputDriver> get_InputDriver(std::istream& input_config_stream, std::istream& matrix_config_stream)
{
return input::InputDriverFactory::get_InputDriver(input_config_stream, matrix_config_stream);
}
std::shared_ptr<output::OutputDriver> get_OutputDriver(std::string & lamp_config_path,
std::string & solenoid_config_path,
std::string & sound_config_path,
std::string & display_config_path)
{
return output::OutputDriverFactory::get_OutputDriver(lamp_config_path, solenoid_config_path, sound_config_path, display_config_path);
}
}

View File

@@ -0,0 +1,72 @@
/*
* PinController.cpp
*
* Created on: Jun 15, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "PinController.h"
#include "utility/config.h"
#include "utility/LoggerFactory.h"
#ifndef NO_WIRING_PI
#include <wiringPi.h>
#include <mcp23017.h>
#else
#warning "Include testing wiringPi library"
#include "utility/wiringPiTesting.hpp"
#endif
namespace flippR_driver
{
std::once_flag PinController::GPIO_LIB_INITIALIZED;
PinController::PinController()
{
CLOG(DEBUG, OUTPUT_LOGGER) << "Created PinController";
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
}
void PinController::initialize_input_pin(uint8_t address)
{
pinMode(address, INPUT);
}
void PinController::initialize_output_pin(const uint8_t address)
{
pinMode(address, OUTPUT);
}
void PinController::write_pin(uint8_t address, bool value)
{
digitalWrite(address, value);
}
bool PinController::read_pin(uint8_t address)
{
return PULLDOWN == digitalRead(address);
}
void PinController::initialize_port_expander(const uint8_t i2c_address, const uint8_t pin_base)
{
auto initialized_port_extender = this->initialized_port_extenders.insert(std::pair<uint8_t, uint8_t>(i2c_address, pin_base));
if(not initialized_port_extender.second)
{
if(initialized_port_extender.first->second != pin_base)
{
char hex_string[4];
sprintf(hex_string, "%X", i2c_address);
CLOG(WARNING, OUTPUT_LOGGER) << "Port extender with address 0x" << hex_string
<< " is already initialized with pin base " << int(pin_base) << ". Check config files!";
}
return;
}
mcp23017Setup(pin_base, i2c_address);
char hex_string[4];
sprintf(hex_string, "%X", i2c_address);
CLOG(INFO, OUTPUT_LOGGER) << "MCP23017 initialized with i2c-address 0x" << hex_string << " and pin-base " << int(pin_base) << ".";
}
}

View File

@@ -0,0 +1,47 @@
/*
* PinController.hpp
*
* Responsible for communicating with the actual GPIO hardware.
*
* Created on: May 6, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#ifndef SRC_UTILITIES_GPIOINTERFACE_H_
#define SRC_UTILITIES_GPIOINTERFACE_H_
#include <mutex>
#include <fstream>
#include <map>
namespace flippR_driver
{
class PinController
{
public:
PinController();
virtual ~PinController() = default;
void initialize_port_expander(const uint8_t i2c_address, const uint8_t pin_base);
protected:
static void initialize_output_pin(const uint8_t address);
static void initialize_input_pin(uint8_t address);
static void write_pin(uint8_t address, bool value);
static bool read_pin(uint8_t address);
public:
static std::once_flag GPIO_LIB_INITIALIZED;
static std::mutex lock;
std::map<uint8_t, uint8_t> initialized_port_extenders;
};
}
#endif

View File

@@ -1,73 +0,0 @@
/*
* Detector.cpp
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#include "Detector.h"
#include <iostream>
#include <math.h>
#include "../utilities/config.h"
namespace Input
{
Detector::Detector(InputGPIOInterface* input_gpio_interface, std::map<char, Event> events, IEventNotifier* event_notifier) :
input_gpio_interface(input_gpio_interface), events(events), is_running(true), event_notifier(event_notifier)
{
detect_thread = std::thread(&Detector::detect, this);
CLOG(WARNING, INPUT_LOGGER) << "Created Detector";
}
Detector::~Detector()
{
is_running = false;
detect_thread.join();
delete this->input_gpio_interface;
this->input_gpio_interface = NULL;
delete this->event_notifier;
this->event_notifier = NULL;
}
// Cycles over all s and enqueues an event if detected.
void Detector::detect()
{
while(is_running)
{
char address;
if(check_inputs(address))
{
try
{
Event& event = events.at(address);
event_notifier->distribute_event(event);
}
catch(std::out_of_range& e)
{
CLOG(WARNING, INPUT_LOGGER) << "Did not found event for address: " << address << " check config-file";
}
}
}
}
bool Detector::check_inputs(char& address)
{
for(int pin = 0; pin < (INPUT_MATRIX_SIZE * INPUT_MATRIX_SIZE); pin++)
{
if(input_gpio_interface->read_input_data(pin))
{
address = pin;
return true;
}
}
return false;
}
}

View File

@@ -1,48 +1,27 @@
/* /*
* Detector.h * Detector.h
* *
* Responsible for detecting InputEvents. * Created on: Jun 13, 2018
* * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
* Creates two Threads;
* One cycles over the inputs gpios and pushes detected input events to a queue.
* The other cycles over the queue and notifies input event handlers.
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/ */
#ifndef DETECTOR_H_ #ifndef SRC_INPUT_DETECTOR_H_
#define DETECTOR_H_ #define SRC_INPUT_DETECTOR_H_
#include "IDetector.h"
namespace Input namespace flippR_driver
{
namespace input
{ {
class Detector : public IDetector class Detector
{ {
public: public:
Detector(InputGPIOInterface* input_gpio_interface, std::map<char, Event> events, IEventNotifier* event_notifier); virtual ~Detector() = default;
~Detector();
private:
void detect();
bool check_inputs(char& address);
private:
InputGPIOInterface* input_gpio_interface;
std::map<char, Event> events;
IEventNotifier* event_notifier;
bool is_running;
std::thread detect_thread;
}; };
} }
}
#endif
#endif /* DETECTOR_H_ */

View File

@@ -0,0 +1,62 @@
//
// Created by rhetenor on 21.09.18.
//
#include "DistributingEvent.h"
namespace flippR_driver
{
namespace input
{
DistributingEvent::DistributingEvent(uint8_t address, int priority, std::string name,
std::chrono::milliseconds bounce_time, std::shared_ptr<EventNotifier> event_notifier)
:
Event(address, priority, std::move(name)),
bounce_time(bounce_time),
event_notifier(std::move(event_notifier)),
activation_state(NOT_ACTIVATED)
{}
void DistributingEvent::distribute()
{
event_notifier->distribute_event(*this);
}
void DistributingEvent::active()
{
if(!is_bouncing())
{
if(activation_state != ACTIVATED)
{
activation_state = activation_state == NOT_ACTIVATED ? FIRST_ACTIVATED : ACTIVATED;
}
last_activation = std::chrono::high_resolution_clock::now();
if(activation_state == FIRST_ACTIVATED)
{
this->distribute();
}
}
}
bool DistributingEvent::is_bouncing()
{
std::chrono::time_point<std::chrono::high_resolution_clock> now = std::chrono::high_resolution_clock::now();
std::chrono::milliseconds elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(now - last_activation);
return elapsed_time < bounce_time;
}
void DistributingEvent::inactive()
{
if(activation_state == ACTIVATED)
{
this->last_activation = std::chrono::high_resolution_clock::now();
activation_state = NOT_ACTIVATED;
}
}
}
}

View File

@@ -0,0 +1,50 @@
//
// Created by rhetenor on 21.09.18.
//
#ifndef flippR_driver_DISTRIBUTINGEVENT_H
#define flippR_driver_DISTRIBUTINGEVENT_H
#include "input/Event.h"
#include "input/EventNotifier.h"
namespace flippR_driver
{
namespace input
{
class DistributingEvent : public Event
{
public:
DistributingEvent(uint8_t address, int priority, std::string name,
std::chrono::milliseconds bounce_time, std::shared_ptr<EventNotifier> event_notifier);
void active();
void inactive();
private:
bool is_bouncing();
void distribute();
public:
const std::chrono::milliseconds bounce_time;
private:
enum ActivationState
{
NOT_ACTIVATED,
FIRST_ACTIVATED,
ACTIVATED
};
const std::shared_ptr<EventNotifier> event_notifier;
ActivationState activation_state;
};
}
}
#endif //flippR_driver_DISTRIBUTINGEVENT_H

View File

@@ -0,0 +1,41 @@
/*
* Event.cpp
*
* Created on: Jun 15, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/
#include "input/Event.h"
#include "json/json.hpp"
#include "utility/config.h"
namespace flippR_driver
{
namespace input
{
Event::Event(uint8_t address, int priority, std::string name) :
address(address), priority(priority), name(name)
{
CLOG_IF(VLOG_IS_ON(0), DEBUG, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
}
std::string Event::getJsonString()
{
nlohmann::json json;
json["name"] = this->name;
json["address"] = this->address;
json["priority"] = this->priority;
return json.dump();
}
bool operator==(const Event& left, const Event& right)
{
return left.name == right.name;
}
}
}

View File

@@ -1,49 +0,0 @@
/*
* InputEvent.h
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef INPUTEVENT_H_
#define INPUTEVENT_H_
#include <set>
#include <string>
#include "../utilities/config.h"
namespace Input
{
class Event
{
public:
Event(char address, char priority, std::string name) :
address(address), priority(priority), name(name)
{
CLOG_IF(VLOG_IS_ON(HIGH_VERBOSITY), INFO, INPUT_LOGGER) << "Created event: " << name << ", address: " << address;
}
bool operator==(const Event& other)
{
return this->name == other.name;
}
friend bool operator<(const Event& left, const Event& right)
{
return left.priority < right.priority;
}
private:
char address;
char priority;
std::string name;
};
}
#endif /* INPUTEVENT_H_ */

View File

@@ -1,54 +0,0 @@
/*
* InputEventHandler.h
*
* This interface must be implemented to be informed about input events.
*
* Please be aware that handle must be implemented thread safe!
*
* Created on: Apr 5, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef INPUTEVENTHANDLER_H_
#define INPUTEVENTHANDLER_H_
#include "Event.hpp"
#include "IInputDriver.h"
#include "../utilities/IEventHandler.h"
#include "../utilities/config.h"
namespace Input
{
class EventHandler;
class EventHandler : public IEventHandler
{
public:
EventHandler(std::shared_ptr<IInputDriver> input_driver) :
input_driver(input_driver)
{
this->input_driver->register_event_handler(this);
CLOG(INFO, INPUT_LOGGER) << "Created EventHandler";
}
virtual ~EventHandler()
{
this->input_driver->unregister_event_handler(this);
this->input_driver = NULL;
}
// This function is intended to be non pure, if it is called when the derived class doesn't exist anymore
virtual void handle(Event& event)
{
CLOG(WARNING, INPUT_LOGGER) << "Called EventHandler parent class";
}
private:
std::shared_ptr<IInputDriver> input_driver;
};
}
#endif /* INPUTEVENTHANDLER_H_ */

View File

@@ -1,70 +0,0 @@
/*
* EventNotifier.cpp
*
* Created on: May 17, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#include <boost/thread.hpp>
#include "../utilities/config.h"
#include "EventNotifier.h"
namespace Input
{
EventNotifier::EventNotifier()
: is_running(true)
{
notify_thread = std::thread(&EventNotifier::notify, this);
CLOG(INFO, INPUT_LOGGER) << "Created EventNotifier and started thread";
}
EventNotifier::~EventNotifier()
{
is_running = false;
notify_thread.join();
}
void EventNotifier::register_event_handler(IEventHandler* handler)
{
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
event_handler.insert(handler);
}
void EventNotifier::unregister_event_handler(IEventHandler* handler)
{
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
event_handler.erase(handler);
}
void EventNotifier::distribute_event(Event& event)
{
event_queue.push(event);
}
void EventNotifier::notify()
{
while(is_running)
{
Event event = event_queue.pop();
// getting a guard and calling all registered handlers
std::lock_guard<std::mutex> event_handler_guard(event_handler_mutex);
for(auto handler : event_handler)
{
boost::thread handler_caller(boost::bind(&IEventHandler::handle, handler, event));
if(!handler_caller.timed_join(boost::posix_time::milliseconds(HANDLER_TIMEOUT)))
{
CLOG(WARNING, INPUT_LOGGER) << "Handler " << typeid(handler).name() << " didn't finish in "
<< HANDLER_TIMEOUT << " milliseconds. Aborting Execution!";
}
}
}
}
}

View File

@@ -1,53 +1,33 @@
/* /*
* InputEventNotifier.h * EventNotifier.h
* *
* Created on: May 17, 2018 * Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht * Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
*/ */
#ifndef SRC_INPUT_EVENTNOTIFIER_H_ #ifndef SRC_INPUT_IEVENTNOTIFIER_H_
#define SRC_INPUT_EVENTNOTIFIER_H_ #define SRC_INPUT_IEVENTNOTIFIER_H_
#include "IEventNotifier.h" #include "input/Event.h"
#include "input/EventHandler.h"
#include <memory>
#include <set> namespace flippR_driver
#include <thread> {
#include <mutex> namespace input
#include "../utilities/BlockingQueue.hpp"
#include "Event.hpp"
#include "EventHandler.hpp"
#define HANDLER_TIMEOUT 2000
namespace Input
{ {
class EventNotifier : public IEventNotifier class EventNotifier
{ {
public: public:
EventNotifier(); virtual ~EventNotifier() = default;
~EventNotifier();
void register_event_handler(IEventHandler* handler); virtual void register_event_handler(std::shared_ptr<EventHandler> handler) = 0;
void unregister_event_handler(IEventHandler* handler); virtual void unregister_event_handler(std::shared_ptr<EventHandler> handler) = 0;
void distribute_event(Event& event); virtual void distribute_event(const Event &event) = 0;
private:
void notify();
private:
BlockingQueue<Event> event_queue;
std::set<IEventHandler*> event_handler;
bool is_running;
std::thread notify_thread;
std::mutex event_handler_mutex;
}; };
} }
}
#endif
#endif /* SRC_INPUT_EVENTNOTIFIER_H_ */

View File

@@ -1,30 +0,0 @@
/*
* IDetector.h
*
* Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_INPUT_IDETECTOR_H_
#define SRC_INPUT_IDETECTOR_H_
#include <thread>
#include <map>
#include "../utilities/InputGPIOInterface.h"
#include "Event.hpp"
#include "EventNotifier.h"
namespace Input
{
class IDetector
{
public:
virtual ~IDetector() = 0;
};
}
#endif /* SRC_INPUT_IDETECTOR_H_ */

View File

@@ -1,29 +0,0 @@
/*
* IEventNotifier.h
*
* Created on: Jun 13, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_INPUT_IEVENTNOTIFIER_H_
#define SRC_INPUT_IEVENTNOTIFIER_H_
#include "IEventHandler.h"
#include "Event.hpp"
namespace Input
{
class IEventNotifier
{
public:
virtual ~IEventNotifier() = 0;
virtual void register_event_handler(IEventHandler* handler) = 0;
virtual void unregister_event_handler(IEventHandler* handler) = 0;
virtual void distribute_event(Event& event) = 0;
};
}
#endif /* SRC_INPUT_IEVENTNOTIFIER_H_ */

View File

@@ -1,25 +0,0 @@
/*
* IInputDriver.h
*
* Created on: Jun 14, 2018
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
*/
#ifndef SRC_INPUT_IINPUTDRIVER_H_
#define SRC_INPUT_IINPUTDRIVER_H_
#include "IEventHandler.h"
#include "IEventNotifier.h"
namespace Input {
class IInputDriver
{
public:
virtual ~IInputDriver() = 0;
virtual void register_event_handler(IEventHandler* handler) = 0;
virtual void unregister_event_handler(IEventHandler* handler) = 0;
};
}
#endif /* SRC_INPUT_IINPUTDRIVER_H_ */

Some files were not shown because too many files have changed in this diff Show More