Commit 6c74e6a4 authored by Yuelong Yu's avatar Yuelong Yu
Browse files

WIP adding reboot

- fixed issue on reestablishing connection after reboot
- minor changes on methods
- disclaimer update
parent b133b470
Pipeline #23923 passed with stage
in 1 minute and 3 seconds
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -41,14 +41,12 @@ namespace AGIPDCtrlNS
m_start = false;
}
bool AGIPDComm::Init(sptr_network& tcp,string log_path)
void AGIPDComm::Init(sptr_network& tcp,string log_path)
{
LOG_TRACE(__FUNCTION__);
m_tcp = tcp;
m_logpath = log_path;
return true;
}
string AGIPDComm::GetFirmwareVersion()
......
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -48,10 +48,8 @@ namespace AGIPDCtrlNS
* \brief init the communication part
* \param tcp connection for communication
* \param log_path path for saving log files
* \return status. true : OK
* flase : init is failed
*/
bool Init(sptr_network& tcp, string log_path);
void Init(sptr_network& tcp, string log_path);
/**
* \brief get firmware version
......
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -211,10 +211,15 @@ namespace AGIPDCtrlNS
{
LOG_TRACE(__FUNCTION__);
LOG_INFOS("Disconnect metadata connection, it may take up to 2 mins");
m_metadata->Reboot();
auto ret = m_communication->Reboot();
if(ret != SC)
return ret;
m_metadata.reset();
m_communication.reset();
LOG_INFOS("wait for " + to_string(time_to_reboot) + " to reboot");
......@@ -321,7 +326,6 @@ namespace AGIPDCtrlNS
conn_com.reset();
m_communication.reset();
throw runtime_error(msg);
}
m_metadata = sptr_agipdmetadata(new AGIPDMetaData(conn_metadata,m_mc.data_length,m_mc.polling_interval));
std::thread(&AGIPDMetaData::DoTaskAction,m_metadata.get()).detach();
......
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -55,6 +55,14 @@ namespace AGIPDCtrlNS
m_exit = true;
}
void AGIPDMetaData::Reboot()
{
LOG_TRACE(__FUNCTION__);
m_exit = true;
while(m_running)
this_thread::sleep_for(std::chrono::seconds(1));
}
void AGIPDMetaData::DoTaskAction()
{
LOG_TRACE(__FUNCTION__);
......@@ -104,6 +112,8 @@ namespace AGIPDCtrlNS
void AGIPDMetaData::StartReadMetaData()
{
LOG_TRACE(__FUNCTION__);
m_running = true;
vector<uint8> data;
LOG_INFOS("read metadata thread start...");
while(true)
......@@ -158,6 +168,7 @@ namespace AGIPDCtrlNS
}
}
LOG_INFOS("read metadata thread quit...");
m_running = false;
}
void AGIPDMetaData::PrintCmd(vector<uint8>& cmd)
......
/*
* (c) Copyright 2018-2021 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -58,6 +58,7 @@ namespace AGIPDCtrlNS
*/
~AGIPDMetaData();
void DoTaskAction();
void Reboot();
RESPONSE GetHighVoltage(uint16& high_voltage);
RESPONSE GetHighVoltageSlewRate(uint16& hv_slewrate);
RESPONSE GetTemperatures(vector<int16>& temperature);
......@@ -81,7 +82,7 @@ namespace AGIPDCtrlNS
uint16 m_hv, m_hvsr, m_power;
uint32 m_length_of_metadata, m_polling_interval, m_acq_counter;
std::mutex m_mtx;
std::atomic<bool> m_exit;
std::atomic<bool> m_exit, m_running;
RESPONSE m_rs;
};
......
......@@ -8,32 +8,9 @@ target_link_libraries(${PROJECT_NAME} ${SHARED_LINKER_FLAGS})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${LIBRARY_VERSION}"
SOVERSION "${SO_VERSION}")
#install target
#install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIB_PATH})
#create and install pkg-config file
#configure_file(${CMAKE_MODULE_PATH}/pkgconfig.pc.cmake
# ${EXECUTABLE_OUTPUT_PATH}/${PROJECT_NAME}.pc @ONLY)
#install(FILES ${EXECUTABLE_OUTPUT_PATH}/${PROJECT_NAME}.pc
# DESTINATION ${CMAKE_INSTALL_LIB_PATH}/pkgconfig)
configure_file(${CMAKE_MODULE_PATH}/Version.h.cmake
${PROJECT_SOURCE_DIR}/src/Version.h @ONLY)
# get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
# foreach(dir ${dirs})
# message(STATUS "include dir='${dir}'")
# endforeach()
# get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LINK_DIRECTORIES)
# foreach(dir ${dirs})
# message(STATUS "library dir='${dir}'")
# endforeach()
#install target
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIB_PATH})
......
/*
* (c) Copyright 2018-2020 DESY
* (c) Copyright 2018-2022 DESY
*
* This file is part of FS-DS detector software.
*
......@@ -34,7 +34,7 @@ namespace TestNS
m_file =uptr_file(new FileReader());
auto ptr = static_pointer_cast<NetworkInterface>(m_tcp);
EXPECT_TRUE(m_agipd->Init(ptr,m_testdir));
m_agipd->Init(ptr,m_testdir);
}
void CtrlTest::TearDown()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment