Skip to content

Commit

Permalink
Merge pull request #178 from Negusbuk/thermoDAQ2
Browse files Browse the repository at this point in the history
ThermoDAQ2 + new features and fixes in Common
  • Loading branch information
schuetzepaul authored Apr 14, 2022
2 parents dcff9ac + 356c353 commit 8e9151e
Show file tree
Hide file tree
Showing 215 changed files with 13,952 additions and 3,033 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ CMakeCache.txt
cmake_install.cmake
*_autogen

CTestTestfile.cmake
Testing

tkmodlabenv.csh
tkmodlabenv.sh
.cproject
Expand All @@ -16,3 +19,5 @@ share/assembly/*png
html/
.DS_Store
.orig
doxygen

56 changes: 36 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ find_package(PkgConfig REQUIRED)
add_compile_definitions(__${CMAKE_HOST_SYSTEM_NAME}__)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
add_compile_definitions(DARWIN)
message(STATUS "Building on MacOS system")
option(CMSTKMODLAB_FAKEIO "Build with fake IO support" ON)
option(CMSTKMODLAB_FAKEUEYE "Build with fake uEYE support" ON)
else()
Expand All @@ -73,8 +75,7 @@ if(CMSTKMODLAB_FAKEUEYE)
message(STATUS "Fake uEYE support: ON")
add_compile_definitions(NOUEYE)
else()
message(STATUS "Fake uEYE support: OFF")
include(Findueyeapi)
message(STATUS "Fake uEYE support: OFF")
endif()

find_package(CURL)
Expand All @@ -93,35 +94,20 @@ set(ENV{ROOT_DIR} ENV{ROOTSYS}/cmake)
find_package(ROOT 6.16 REQUIRED)
message(STATUS "Found ROOT (${ROOT_VERSION})")

pkg_check_modules(LIBGPHOTO2 REQUIRED IMPORTED_TARGET libgphoto2)
pkg_check_modules(OPENCV4 REQUIRED IMPORTED_TARGET opencv4)
pkg_check_modules(EXIV2 REQUIRED IMPORTED_TARGET exiv2)

include(FindQWT)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
option(CMSTKMODLAB_MARTA "Build with support for MARTA CO2 chiller" OFF)
else()
option(CMSTKMODLAB_MARTA "Build with support for MARTA CO2 chiller" ON)
endif()
option(CMSTKMODLAB_MARTA "Build with support for MARTA CO2 chiller" OFF)

if(CMSTKMODLAB_MARTA)
message(STATUS "Support for MARTA CO2 chiller: ON")
pkg_check_modules(libmodbus REQUIRED IMPORTED_TARGET libmodbus)
pkg_check_modules(MODBUS REQUIRED IMPORTED_TARGET libmodbus)
else()
message(STATUS "Support for MARTA CO2 chiller: OFF")
add_compile_definitions(NOMARTA)
endif()

add_subdirectory(external)
add_subdirectory(devices)
add_subdirectory(tools)
add_subdirectory(common)
add_subdirectory(common_test)

option(CMSTKMODLAB_THERMO1 "Build with support for version 1 of thermal test setup" OFF)
if(CMSTKMODLAB_THERMO1)
message(STATUS "Support for version 1 of thermal test setup: ON")
include(FindQWT)
else()
message(STATUS "Support for version 1 of thermal test setup: OFF")
endif()
Expand All @@ -134,6 +120,7 @@ else()
endif()

if(CMSTKMODLAB_THERMO1 OR CMSTKMODLAB_THERMO2)
pkg_check_modules(GSL REQUIRED IMPORTED_TARGET gsl)
add_subdirectory(thermo)
endif()

Expand Down Expand Up @@ -178,3 +165,32 @@ if(CMSTKMODLAB_PYTHON)
else()
message(STATUS "Python device modules: OFF")
endif()

if(CMSTKMODLAB_ASSEMBLY OR CMSTKMODLAB_DEFO)
pkg_check_modules(LIBGPHOTO2 REQUIRED IMPORTED_TARGET libgphoto2)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
find_package(OpenCV REQUIRED)
else()
pkg_check_modules(OPENCV4 REQUIRED IMPORTED_TARGET opencv4)
endif()
pkg_check_modules(EXIV2 REQUIRED IMPORTED_TARGET exiv2)
endif()

if(CMSTKMODLAB_ASSEMBLY AND NOT CMSTKMODLAB_FAKEUEYE)
include(Findueyeapi)
endif()

configure_file(tkmodlabenv.sh.in tkmodlabenv.sh)
configure_file(tkmodlabenv.csh.in tkmodlabenv.csh)

add_subdirectory(external)
add_subdirectory(devices)
add_subdirectory(tools)
add_subdirectory(common)
add_subdirectory(common_test)

enable_testing()
add_test(NAME testApplicationConfig COMMAND testApplicationConfig)
add_test(NAME testRingbuffer COMMAND testRingbuffer)
add_test(NAME testFifo COMMAND testFifo)
add_test(NAME testHistoryFifo COMMAND testHistoryFifo)
59 changes: 13 additions & 46 deletions assembly/assembly/AssemblyMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <AssemblyMainWindow.h>
#include <AssemblyLogFileController.h>
#include <AssemblyLogFileView.h>
#include <AssemblyParameters.h>
#include <AssemblyUtilities.h>

#include <string>
Expand Down Expand Up @@ -62,8 +61,6 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr

smart_motion_(nullptr),

params_(nullptr),

// Views
toolBar_(nullptr),
main_tab(nullptr),
Expand Down Expand Up @@ -109,11 +106,11 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr

/// Parameters
/// * instance created up here, so controllers can access it
params_ = AssemblyParameters::instance(config->getValue<std::string>("AssemblyParameters_file_path"), DBlogfile_path);
if(params_->isValidConfig() == false)
{
try{
config->append(config->getValue<std::string>("main", "AssemblyParameters_file_path"), "parameters");
} catch (...) {
NQLog("AssemblyMainWindow", NQLog::Fatal) << "\e[1;31m-------------------------------------------------------------------------------------------------------\e[0m";
NQLog("AssemblyMainWindow", NQLog::Fatal) << "\e[1;31mInitialization error: AssemblyParameters::instance() is invalid ! Abort !\e[0m";
NQLog("AssemblyMainWindow", NQLog::Fatal) << "\e[1;31mInitialization error: ApplicationConfig::append(\"parameters\") is invalid ! Abort !\e[0m";
NQLog("AssemblyMainWindow", NQLog::Fatal) << "\e[1;31m-------------------------------------------------------------------------------------------------------\e[0m";

return;
Expand All @@ -122,9 +119,9 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr

/// Motion
motion_model_ = new LStepExpressModel(
config->getValue<std::string>("LStepExpressDevice"),
config->getValue<std::string>("LStepExpressDevice_ver"),
config->getValue<std::string>("LStepExpressDevice_iver"),
config->getValue<std::string>("main", "LStepExpressDevice"),
config->getValue<std::string>("main", "LStepExpressDevice_ver"),
config->getValue<std::string>("main", "LStepExpressDevice_iver"),
1000,
1000
);
Expand Down Expand Up @@ -155,12 +152,12 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
/// -------------------

/// Vacuum Manager
std::string relayCardDevice = config->getValue<std::string>("RelayCardDevice");
std::string relayCardDevice = config->getValue<std::string>("main", "RelayCardDevice");
if (relayCardDevice=="Velleman")
{
relayCardModel_ = new VellemanModel(config->getValue<std::string>("VellemanDevice"));
relayCardModel_ = new VellemanModel(config->getValue<std::string>("main", "VellemanDevice"));
} else {
relayCardModel_ = new ConradModel(config->getValue<std::string>("ConradDevice"));
relayCardModel_ = new ConradModel(config->getValue<std::string>("main", "ConradDevice"));
}

relayCardManager_ = new RelayCardManager(relayCardModel_);
Expand Down Expand Up @@ -260,7 +257,7 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr

smart_motion_ = new AssemblySmartMotionManager(motion_manager_);

const int assembly_sequence(config->getValue<int>("assembly_sequence", 1));
const int assembly_sequence(config->getDefaultValue<int>("main", "assembly_sequence", 1));

if(assembly_sequence == 1)
{
Expand Down Expand Up @@ -337,7 +334,7 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
hwctr_view_->Vacuum_Widget()->updateVacuumChannelsStatus();

// enable motion stage controllers at startup
const bool startup_motion_stage = config->getValue<bool>("startup_motion_stage", false);
const bool startup_motion_stage = config->getDefaultValue<bool>("main", "startup_motion_stage", false);

if(startup_motion_stage)
{
Expand All @@ -360,10 +357,6 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
params_view_ = new AssemblyParametersView(controls_tab);
controls_tab->addTab(params_view_, tabname_Parameters);

params_view_->copy_values(params_->map_double());

params_->set_view(params_view_);

NQLog("AssemblyMainWindow", NQLog::Message) << "added view " << tabname_Parameters;

connect(params_view_, SIGNAL(request_moveToAbsRefPosition(double,double,double,double)), motion_manager_, SLOT(moveAbsolute(double,double,double,double)));
Expand Down Expand Up @@ -506,7 +499,7 @@ AssemblyMainWindow::AssemblyMainWindow(const QString& outputdir_path, const QStr
NQLog("AssemblyMainWindow", NQLog::Message) << "application initialized successfully";

// enable camera at startup
const bool startup_camera = config->getValue<bool>("startup_camera", false);
const bool startup_camera = config->getDefaultValue<bool>("main", "startup_camera", false);

if(startup_camera)
{
Expand Down Expand Up @@ -736,19 +729,6 @@ void AssemblyMainWindow::start_objectAligner(const AssemblyObjectAligner::Config
return;
}

if(params_ != nullptr)
{
const bool valid_params = params_->update();

if(valid_params == false)
{
NQLog("AssemblyMainWindow", NQLog::Warning) << "start_objectAligner"
<< ": failed to update AssemblyParameters, no action taken";

return;
}
}

// acquire image
connect(aligner_, SIGNAL(image_request()), image_ctr_, SLOT(acquire_image()));
connect(aligner_, SIGNAL(autofocused_image_request()), image_ctr_, SLOT(acquire_autofocused_image()));
Expand Down Expand Up @@ -844,19 +824,6 @@ void AssemblyMainWindow::start_multiPickupTest(const AssemblyMultiPickupTester::
return;
}

if(params_ != nullptr)
{
const bool valid_params = params_->update();

if(valid_params == false)
{
NQLog("AssemblyMainWindow", NQLog::Warning) << "start_multiPickupTest"
<< ": failed to update AssemblyParameters, no action taken";

return;
}
}

toolbox_view_->MultiPickupTester_Widget()->enable(false);

connect(multipickup_tester_, SIGNAL(measurement_finished()), multipickup_tester_, SLOT(start_pickup()));
Expand Down
2 changes: 0 additions & 2 deletions assembly/assembly/AssemblyMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ typedef AssemblyUEyeModel AssemblyUEyeModel_t;
#include <AssemblyMultiPickupTester.h>
#include <AssemblyToolboxView.h>
#include <AssemblySmartMotionManager.h>
#include <AssemblyParameters.h>
#include <AssemblyParametersView.h>
#include <AssemblyHardwareControlView.h>
#include <LStepExpressModel.h>
Expand Down Expand Up @@ -179,7 +178,6 @@ class AssemblyMainWindow : public QMainWindow

AssemblySmartMotionManager* smart_motion_;

AssemblyParameters* params_;

// Views
QToolBar* toolBar_;
Expand Down
6 changes: 3 additions & 3 deletions assembly/assembly/assembly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ int main(int argc, char** argv)
app.setStyle("cleanlooks");

// log output -----------
ApplicationConfig* config = ApplicationConfig::instance(std::string(Config::CMSTkModLabBasePath)+"/assembly/assembly.cfg");
ApplicationConfig* config = ApplicationConfig::instance(std::string(Config::CMSTkModLabBasePath)+"/assembly/assembly.cfg", "main");

const NQLog::LogLevel nqloglevel_stdout = ((NQLog::LogLevel) config->getValue<int>("LogLevel_stdout" , 2));
const NQLog::LogLevel nqloglevel_logfile = ((NQLog::LogLevel) config->getValue<int>("LogLevel_logfile", 2));
const NQLog::LogLevel nqloglevel_stdout = ((NQLog::LogLevel) config->getDefaultValue<int>("main", "LogLevel_stdout" , 2));
const NQLog::LogLevel nqloglevel_logfile = ((NQLog::LogLevel) config->getDefaultValue<int>("main", "LogLevel_logfile", 2));

NQLogger::instance()->addActiveModule("*");
NQLogger::instance()->addDestiniation(stdout, nqloglevel_stdout);
Expand Down
Loading

0 comments on commit 8e9151e

Please sign in to comment.