ProfinetConnector/src/app.cpp
Vadim Sychev b992c1c3a6 dev(UML-981): Небольшой рефакторинг
1. разработаны абстрактные классы флагов и разделяемых даннных. Модуль
profinet их использует.
2. Разделяемые данныне переделаны на использование мьютексов буста
2022-08-04 14:21:05 +03:00

45 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "app.hpp"
#include "program_config.hpp"
bool App::Init(std::string profinet_config_file)
{
ProfinetSettings profinet_settings;
ProfinetDeviceSettings profinet_dev_settings;
/// Читаем настройки из файла
if (!programconf_getProfinetSettings("program_configure.json", profinet_settings))
{
return false;
}
///Создаем структуру в разделяемой памяти
ProfinetData_Map * p_profinetMap = shared_data_.Create("profinet_shared_data");
/// Читаем настройки из файла, выделяем память под структуру модулей и подмодулей
if (!programconf_getProfinetDeviceSettings(profinet_settings.profinet_device_config, profinet_dev_settings, p_profinetMap, shared_data_))
{
return false;
}
/// Настройка Profinet: Инициализация pnet, добавление DAP слотов и подслотов и подключение к ним модулей и подмодулей,
if (!profinet_.Config(profinet_settings, profinet_dev_settings, p_profinetMap))
{
return false;
}
/**
* Циклические данные устройства передаются с определенным периодом, сообщения от контроллера при этом не требуются.
*/
/// Запуск потока Profinet
profinet_.Start();
return true;
}
void App::Run()
{
for (;;)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}