2025-01-04 13:21:33 -04:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <exception>
|
2025-01-10 17:37:49 -04:00
|
|
|
#include <thread>
|
|
|
|
|
#include <mutex>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <condition_variable>
|
|
|
|
|
#include <boost/asio.hpp>
|
2025-01-05 13:25:40 -04:00
|
|
|
#include <opts.h>
|
2024-09-04 14:08:50 +10:00
|
|
|
#include <mind.h>
|
2025-01-05 14:19:53 -04:00
|
|
|
#include <deviceManager/deviceManager.h>
|
2025-01-08 15:06:31 -04:00
|
|
|
#include <senseApis/senseApiManager.h>
|
2025-01-10 17:37:49 -04:00
|
|
|
#include "componentThread.h"
|
2024-09-04 14:08:50 +10:00
|
|
|
|
2025-01-10 17:37:49 -04:00
|
|
|
namespace hk {
|
2025-01-08 13:43:44 -04:00
|
|
|
|
2025-01-10 17:37:49 -04:00
|
|
|
static int initializeHarikoff(int argc, char **argv, char **envp);
|
|
|
|
|
|
|
|
|
|
} // namespace hk
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv, char **envp)
|
2024-09-04 14:08:50 +10:00
|
|
|
{
|
2025-01-10 17:37:49 -04:00
|
|
|
try {
|
|
|
|
|
std::cout << __func__ << ": Entering main()" << std::endl;
|
|
|
|
|
|
2025-01-11 04:34:49 -04:00
|
|
|
// Validate thread IDs
|
|
|
|
|
hk::ComponentThread::validateThreadIds();
|
2025-01-10 17:37:49 -04:00
|
|
|
|
|
|
|
|
int ret = hk::initializeHarikoff(argc, argv, envp);
|
|
|
|
|
if (ret != 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2025-01-11 04:34:49 -04:00
|
|
|
|
|
|
|
|
// Signal all threads
|
|
|
|
|
for (const auto& [id, componentThread]
|
|
|
|
|
: hk::ComponentThread::componentThreads) {
|
|
|
|
|
hk::ComponentThread::signalThread(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Infinite loop calling yield
|
|
|
|
|
while (true) {
|
|
|
|
|
std::this_thread::yield();
|
|
|
|
|
}
|
2025-01-10 17:37:49 -04:00
|
|
|
}
|
2025-01-11 04:34:49 -04:00
|
|
|
catch (const std::exception& e)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << __func__ << ": Exception occurred: " << e.what()
|
|
|
|
|
<< std::endl;
|
2025-01-10 17:37:49 -04:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
catch (...) {
|
|
|
|
|
std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::cout << __func__ << ": Exiting normally" << std::endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace hk {
|
2025-01-08 15:06:31 -04:00
|
|
|
|
2025-01-10 17:37:49 -04:00
|
|
|
static int initializeHarikoff(int argc, char **argv, char **envp)
|
|
|
|
|
{
|
|
|
|
|
std::cout << __func__ << ": Entering" << std::endl;
|
|
|
|
|
|
|
|
|
|
using namespace hk;
|
2025-01-08 13:43:44 -04:00
|
|
|
OptionParser &options = OptionParser::getOptions();
|
2025-01-05 14:01:16 -04:00
|
|
|
hk::Mind mind;
|
2024-09-05 18:20:33 +10:00
|
|
|
|
2025-01-05 14:01:16 -04:00
|
|
|
std::cout << PACKAGE_NAME << " " << PACKAGE_VERSION << std::endl;
|
2025-01-05 13:25:40 -04:00
|
|
|
|
2025-01-04 13:21:33 -04:00
|
|
|
try {
|
2025-01-10 18:27:10 -04:00
|
|
|
options.parseArguments(argc, argv, envp);
|
2025-01-04 13:21:33 -04:00
|
|
|
}
|
2025-01-11 04:34:49 -04:00
|
|
|
catch (const std::invalid_argument& e)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << __func__ << ": Exception occurred: " << e.what() << '\n'
|
|
|
|
|
<< options.getUsage() << '\n';
|
2025-01-04 13:21:33 -04:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-05 13:35:14 -04:00
|
|
|
if (options.printUsage) {
|
|
|
|
|
std::cout << options.getUsage() << std::endl;
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
2025-01-05 14:03:44 -04:00
|
|
|
|
2025-01-10 18:27:10 -04:00
|
|
|
std::cout << options.stringifyOptions() << std::endl;
|
|
|
|
|
DeviceManager::getInstance().collateAllDeviceSpecs();
|
2025-01-07 14:14:57 -04:00
|
|
|
DeviceManager::getInstance().parseAllDeviceSpecs();
|
2025-01-10 18:27:10 -04:00
|
|
|
std::cout << DeviceManager::stringifyDeviceSpecs() << std::endl;
|
2025-01-08 15:06:31 -04:00
|
|
|
sense_api::SenseApiManager::getInstance().loadAllSenseApiLibsFromOptions();
|
2025-01-10 17:37:49 -04:00
|
|
|
|
2025-01-11 04:34:49 -04:00
|
|
|
/* Start the threads */
|
|
|
|
|
|
2025-01-10 17:37:49 -04:00
|
|
|
std::cout << __func__ << ": Exiting" << std::endl;
|
|
|
|
|
return 0;
|
2025-01-07 14:14:57 -04:00
|
|
|
}
|
2025-01-10 17:37:49 -04:00
|
|
|
|
|
|
|
|
} // namespace hk
|