Skip to content

Commit

Permalink
Revert removal + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
guiguem committed Oct 12, 2023
1 parent 786ac85 commit b657e22
Show file tree
Hide file tree
Showing 35 changed files with 1,183 additions and 92 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ main
*.root
*#
cmake-*
# removing the backup unity files and so on...
*.bak.*
build-*
install-*
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ project(${PROJECT_NAME} VERSION ${PROJECT_VERSION})
include(HKPackageBuilder)
hkbuilder_prepare_project()
set( PUBLIC_EXT_LIBS )
set( PRIVATE_EXT_LIBS )
hk_check_dependencies()

add_subdirectory(src)
add_subdirectory(app)
add_subdirectory(UserTools)
44 changes: 44 additions & 0 deletions UserTools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

# Definition of ToolChain
# Some hack to build the ToolChain library whose source files exist in the ToolFrameworkCore library
set (TOOLCHAIN_SRC ${ToolFrameworkCore_SRC_DIR}/ToolChain.cpp)
pbuilder_library(
TARGET HKToolChain
SOURCES ${TOOLCHAIN_SRC}
PROJECT_LIBRARIES HKFactory
PUBLIC_EXTERNAL_LIBRARIES ${PUBLIC_EXT_LIBRARIES} # should contain at least ToolFrameworkCore::ToolFrameworkCore and hk-DataModel::DataModel
PRIVATE_EXTERNAL_LIBRARIES ${PRIVATE_EXT_LIBS}
)
# Exporting library
pbuilder_component_install_and_export(
COMPONENT Library
LIBTARGETS HKToolChain
)
# End of hack

# Find all the local tools to be compiled with hk-ToolApp
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child}
AND NOT "${child}" STREQUAL "template"
AND NOT "${child}" STREQUAL "Factory"
AND NOT "${child}" STREQUAL "InactiveTools"
)
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()

SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})

MESSAGE(STATUS "List of tools dir to be added: ${SUBDIRS}")
FOREACH (dir ${SUBDIRS})
hk_add_tool(${dir})
list( APPEND PUBLIC_EXT_LIBS ${dir})
ENDFOREACH ()


add_subdirectory(Factory)
32 changes: 32 additions & 0 deletions UserTools/DummyTool/DummyTool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "DummyTool.h"

DummyTool::DummyTool() : Tool() {}

bool DummyTool::Initialise(std::string configfile, DataModel& data) {

if(configfile != "")
m_variables.Initialise(configfile);
// m_variables.Print();

m_data = &data;
m_log = m_data->Log;

if(!m_variables.Get("verbose", m_verbose))
m_verbose = 1;

Log("test 1", 1, m_verbose);

return true;
}

bool DummyTool::Execute() {

Log("test 2", 2, m_verbose);
// sleep(2);
return true;
}

bool DummyTool::Finalise() {

return true;
}
34 changes: 34 additions & 0 deletions UserTools/DummyTool/DummyTool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef DummyTool_H
#define DummyTool_H

#include <iostream>
#include <string>

#include "Tool.h"

/**
* \class DummyTool
*
* This is a simple dummy Tool designed to show operation of a Tool. It also provides a default Tool for the
* Default ToolChain.
*
* $Author: B.Richards $
* $Date: 2019/05/28 10:44:00 $
*/

class DummyTool : public Tool {

public:

DummyTool(); ///< Constructor
bool Initialise(std::string configfile,
DataModel& data); ///< Assigns verbosity from config file and creates a log message.
bool Execute(); ///< Creates a log message.
bool Finalise(); ///< Does nothing

private:

int m_verbose;
};

#endif
17 changes: 17 additions & 0 deletions UserTools/Factory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
file(GLOB_RECURSE SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "Factory.cpp")

pbuilder_library(
TARGET HKFactory
SOURCES ${SRC}
PROJECT_LIBRARIES ${TOOLS_LIBS}
PUBLIC_EXTERNAL_LIBRARIES ${PUBLIC_EXT_LIBS} ${EXT_TOOLS_LIBS}
PRIVATE_EXTERNAL_LIBRARIES ${PRIVATE_EXT_LIBS}
)

pbuilder_install_headers(${HEADERS})

# Exporting library
pbuilder_component_install_and_export(
COMPONENT Library
LIBTARGETS HKFactory
)
9 changes: 9 additions & 0 deletions UserTools/Factory/Factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Factory.h"

Tool* Factory(std::string tool) {
Tool* ret=0;

// if (tool=="Type") tool=new Type;
if (tool=="DummyTool") ret=new DummyTool;
return ret;
}
1 change: 1 addition & 0 deletions UserTools/InactiveTools/PythonScript
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/local/hk/hk-ToolApp/UserTools/ImportedTools/TFToolPack/PythonScript/
1 change: 1 addition & 0 deletions UserTools/InactiveTools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# DAQFramework
1 change: 1 addition & 0 deletions UserTools/InactiveTools/SubToolChain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/local/hk/hk-ToolApp/UserTools/ImportedTools/TFToolPack/SubToolChain/
1 change: 1 addition & 0 deletions UserTools/InactiveTools/ThreadedSubToolChain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/usr/local/hk/hk-ToolApp/UserTools/ImportedTools/TFToolPack/ThreadedSubToolChain/
1 change: 1 addition & 0 deletions UserTools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# DAQFramework
188 changes: 188 additions & 0 deletions UserTools/ToolSelect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
#!/bin/bash

if ! command -v dialog &> /dev/null
then
echo "dialog package needed for operation. Please install then re-run script"
exit
fi


#cat Factory.cpp | grep -v '/' |grep if| awk '{print $4}' | sed s:';':: > on
num=1

#ls */*.cpp | sed s:/:' ': | awk '{print $2}' | sed s:.cpp:: | grep -v Factory
#ls -p | grep -v Factory | grep -v template | grep / | sed s:/::\

dialog --backtitle "Options" \
--radiolist "Select (with spacebar) option:" 0 0 0 \
1 "Activate/Deactivate Tools" on \
2 "Restore Backup" off 2>tmpoption

if [ $? -eq 0 ]
then

if [ `cat tmpoption` -eq 1 ]
then

dialog --checklist "Activate or Deactivate Tools with <spacebar>, Enter for OK and ESC for Cancel:" 0 0 0 \
`for Tool in \`ls */*.cpp | grep -v template/ | sed s:/:' ': | awk '{print $2}' | sed s:.cpp:: | grep -v Factory\`
do
fin=0
for current in \`cat Factory/Factory.cpp | grep -v '/' |grep if| awk '{print $4}' | sed s:';':: \`
do
if [ $Tool == $current ]
then
fin=1
echo "$Tool $num on "
fi
done
if [ $fin -eq 0 ]
then
echo "$Tool $num off "
fi
num=$(expr 1 + $num)
done
for Tool in \`ls InactiveTools/*/*.cpp | sed s:/:' ':g | awk '{print $3}' | sed s:.cpp:: \`
do
echo "$Tool $num off "
num=$(expr 1 + $num)
done` 2> tmptools
if [ $? -eq 0 ]
then
dialog --title "Message" --yesno "Backup existing configuration?" 0 0
if [ $? -eq 0 ]
then
cp Unity.h Unity.bak.`date +%F.%T`
cp Factory/Factory.cpp Factory/Factory.bak.`date +%F.%T`
fi
rm -f Unity.h
for Tool in `cat tmptools`
do
echo "#include <$Tool.h>" >> Unity.h
done
touch Unity.h
echo "#include \"Factory.h\"
Tool* Factory(std::string tool) {
Tool* ret=0;
// if (tool==\"Type\") tool=new Type;" > Factory/Factory.cpp
for Tool in `cat tmptools`
do
echo "if (tool==\"$Tool\") ret=new $Tool;" >> Factory/Factory.cpp
done
echo "return ret;
}" >> Factory/Factory.cpp
for dir in `ls */ | grep / | sed s:'/\:':: | grep -v Factory | grep -v template | grep -v InactiveTools | grep -v ImportedTools`
do
exists=0
for Tool in `cat tmptools`
do
if [ $Tool == $dir ]
then
exists=1
fi
done
if [ $exists -eq 0 ]
then
mv $dir InactiveTools/
fi
done
for dir in `ls InactiveTools/`
do
for Tool in `cat tmptools`
do
if [ $Tool == $dir ]
then
mv InactiveTools/$dir ./
fi
done
done
fi
rm -f tmptools
else
dialog --radiolist "Select backup with <spacebar>, Enter for OK and ESC for Cancel:" 0 0 0 \
`for backup in \`ls *.bak.*\`
do
echo $backup . off
done
` 2> tmpbackup

if [ $? -eq 0 ]
then

if [ -s tmpbackup ]
then

dialog --title "Message" --yesno "Backup existing configuration?" 0 0
if [ $? -eq 0 ]
then
cp Unity.h Unity.bak.`date +%F.%T`
cp Factory/Factory.cpp Factory/Factory.bak.`date +%F.%T`
fi

cp `cat tmpbackup` Unity.h
cp `cat tmpbackup | sed s:Unity:Factory/Factory:` Factory/Factory.cpp
fi

fi

rm -f tmpbackup


for dir in `ls */ | grep / | sed s:'/\:':: | grep -v Factory | grep -v template | grep -v InactiveTools | grep -v ImportedTools`
do
exists=0
for Tool in `cat Factory/Factory.cpp | grep -v '/' |grep if| awk '{print $4}' | sed s:';':: `
do
if [ $Tool == $dir ]
then
exists=1
fi
done

if [ $exists -eq 0 ]
then
mv $dir InactiveTools/
fi
done

for dir in `ls InactiveTools/`
do
for Tool in `cat Factory/Factory.cpp | grep -v '/' |grep if| awk '{print $4}' | sed s:';':: `
do
if [ $Tool == $dir ]
then
mv InactiveTools/$dir ./
fi
done

done



fi


fi

rm -f tmpoption
clear
1 change: 1 addition & 0 deletions UserTools/Unity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <DummyTool.h>
Loading

0 comments on commit b657e22

Please sign in to comment.