feat(UML-1666): Добавлена регистрация обработчика процесса
This commit is contained in:
parent
4cfbcac957
commit
b5d7d9ed63
@ -13,7 +13,7 @@ namespace free_rtos {
|
||||
|
||||
namespace ecat_pdo_fmmu {
|
||||
|
||||
void EthEcatPdoFMMU::init() {
|
||||
void EthEcatPdoFMMU::init(custom_promise::IPromise *promise_read = nullptr, custom_promise::IPromise *promise_write = nullptr) {
|
||||
std::vector<ecat_buffer::EcatBufferSlave>& buffer_slaves = ecat_buffer_.get_buffer_slaves();
|
||||
|
||||
pdo_fmmu_slaves_.reserve(buffer_slaves.size());
|
||||
@ -21,6 +21,9 @@ void EthEcatPdoFMMU::init() {
|
||||
for(ecat_buffer::EcatBufferSlave& buffer_slave : buffer_slaves) {
|
||||
pdo_fmmu_slaves_.emplace_back(EcatPdoFMMUSlave{buffer_slave});
|
||||
}
|
||||
|
||||
promise_read_ = promise_read;
|
||||
promise_write_ = promise_write;
|
||||
}
|
||||
|
||||
void EthEcatPdoFMMU::wait_op() {
|
||||
@ -131,6 +134,15 @@ void EthEcatPdoFMMU::process() {
|
||||
//read(0, process_data);
|
||||
|
||||
process_read_queue(pdo_read.data(), pdo_read.size());
|
||||
|
||||
if(promise_read_ != nullptr) {
|
||||
promise_read_->set_value(pdo_read.data(), pdo_read.size());
|
||||
}
|
||||
|
||||
if(promise_write_ != nullptr) {
|
||||
promise_write_->set_value(pdo_write.data(), pdo_write.size());
|
||||
}
|
||||
|
||||
process_write_queue(pdo_write.data(), pdo_write.size());
|
||||
|
||||
//write(0, process_data);
|
||||
@ -139,7 +151,7 @@ void EthEcatPdoFMMU::process() {
|
||||
}
|
||||
}
|
||||
|
||||
void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) {
|
||||
void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250, custom_promise::IPromise *promise_read = nullptr, custom_promise::IPromise *promise_write = nullptr) {
|
||||
std::vector<uint8_t> pdo_read(110, 0x00);
|
||||
std::vector<uint8_t> pdo_write(110, 0x00);
|
||||
free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer();
|
||||
@ -161,6 +173,15 @@ void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) {
|
||||
//DebugP_log("Tick !\r\n");
|
||||
|
||||
process_read_queue(pdo_read.data(), pdo_read.size());
|
||||
|
||||
if(promise_read != nullptr) {
|
||||
promise_read->set_value(pdo_read.data(), pdo_read.size());
|
||||
}
|
||||
|
||||
if(promise_write != nullptr) {
|
||||
promise_write->set_value(pdo_write.data(), pdo_write.size());
|
||||
}
|
||||
|
||||
process_write_queue(pdo_write.data(), pdo_write.size());
|
||||
|
||||
pdo_counter_++;
|
||||
|
||||
@ -50,11 +50,12 @@ private:
|
||||
|
||||
class EthEcatPdoFMMU {
|
||||
public:
|
||||
EthEcatPdoFMMU(ecat_buffer::EthEcatBuffer& ecat_buffer): ecat_buffer_{ecat_buffer} { }
|
||||
EthEcatPdoFMMU(ecat_buffer::EthEcatBuffer& ecat_buffer)
|
||||
: ecat_buffer_{ecat_buffer} { }
|
||||
|
||||
void init();
|
||||
void init(custom_promise::IPromise *promise_read, custom_promise::IPromise *promise_write);
|
||||
void process();
|
||||
void process_fake(uint32_t period_microsec);
|
||||
void process_fake(uint32_t period_microsec, custom_promise::IPromise *promise_read, custom_promise::IPromise *promise_write);
|
||||
|
||||
uint32_t get_pdo_counter() {
|
||||
return pdo_counter_;
|
||||
@ -120,6 +121,9 @@ private:
|
||||
queue::Queue<custom_promise::IPromise> queue_write_;
|
||||
queue::Queue<custom_promise::IPromise> queue_read_;
|
||||
|
||||
custom_promise::IPromise *promise_read_{nullptr};
|
||||
custom_promise::IPromise *promise_write_{nullptr};
|
||||
|
||||
uint32_t pdo_counter_{0};
|
||||
|
||||
void wait_op();
|
||||
@ -175,7 +179,6 @@ private:
|
||||
telegram.transfer(queue);
|
||||
} while(datagram_read.get_all_wkc() < 0x0001);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace ecat_pdo_fmmu
|
||||
|
||||
@ -9,17 +9,7 @@
|
||||
|
||||
namespace free_rtos {
|
||||
|
||||
/*
|
||||
* Порядок инициализации:
|
||||
* Инициализировать и открыть драйвер eth_.Init(...), eth_.Open()
|
||||
* Создать служебный поток ecat_task_.Create(...) с вызовом EthEcatApi::process()
|
||||
* Вызвать EthEcatApi::config_init(...)
|
||||
* Создать пользовательский поток ecat_task_pdo_.Create(...)
|
||||
* Для чтения/записи данных в пользовательском потоке вызвать
|
||||
* pdo_write(...), pdo_read(...) или pdo_write_async(...), pdo_read_async(...)
|
||||
*/
|
||||
|
||||
bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec = 250) {
|
||||
bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec, custom_promise::IPromise *pdo_promise_read, custom_promise::IPromise *pdo_promise_write) {
|
||||
bool status = false;
|
||||
|
||||
ecat_.Init(port_id, period_microsec);
|
||||
@ -51,7 +41,7 @@ bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32
|
||||
ecat_buffer_pdo_.init_sync_manager(sync_manager::SYNC_M2, sync_manager::SYNC_M3);
|
||||
ecat_buffer_pdo_.init_fmmu(fmmu::FMMU0, fmmu::FMMU1);
|
||||
|
||||
ecat_pdo_fmmu_.init();
|
||||
ecat_pdo_fmmu_.init(pdo_promise_read, pdo_promise_write);
|
||||
|
||||
status = ecat_.preop_to_safeop();
|
||||
|
||||
@ -72,8 +62,8 @@ void EthEcatApi::process() {
|
||||
ecat_pdo_fmmu_.process();
|
||||
}
|
||||
|
||||
void EthEcatApi::process_fake(uint32_t period_microsec = 250) {
|
||||
ecat_pdo_fmmu_.process_fake(period_microsec);
|
||||
void EthEcatApi::process_fake(uint32_t period_microsec, custom_promise::IPromise *pdo_promise_read, custom_promise::IPromise *pdo_promise_write) {
|
||||
ecat_pdo_fmmu_.process_fake(period_microsec, pdo_promise_read, pdo_promise_write);
|
||||
}
|
||||
|
||||
std::vector<ecat_buffer::PDOMap>& EthEcatApi::get_ecat_pdo_map() {
|
||||
|
||||
@ -18,16 +18,6 @@
|
||||
|
||||
namespace free_rtos {
|
||||
|
||||
/*
|
||||
* Порядок инициализации:
|
||||
* Инициализировать и открыть драйвер eth_.Init(...), eth_.Open()
|
||||
* Создать служебный поток ecat_task_.Create(...) с вызовом EthEcatApi::process()
|
||||
* Вызвать EthEcatApi::config_init(...)
|
||||
* Создать пользовательский поток ecat_task_pdo_.Create(...)
|
||||
* Для чтения/записи данных в пользовательском потоке вызвать
|
||||
* pdo_write(...), pdo_read(...) или pdo_write_async(...), pdo_read_async(...)
|
||||
*/
|
||||
|
||||
class EthEcatApi {
|
||||
public:
|
||||
EthEcatApi(Eth *eth)
|
||||
@ -38,9 +28,9 @@ public:
|
||||
, ecat_sdo_mailbox_{ecat_buffer_sdo_}
|
||||
, ecat_pdo_fmmu_{ecat_buffer_pdo_} { }
|
||||
|
||||
bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec);
|
||||
void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
|
||||
void process_fake(uint32_t period_microsec);
|
||||
bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec = 250, custom_promise::IPromise *pdo_promise_read = nullptr, custom_promise::IPromise *pdo_promise_write = nullptr);
|
||||
void process();
|
||||
void process_fake(uint32_t period_microsec = 250, custom_promise::IPromise *pdo_promise_read = nullptr, custom_promise::IPromise *pdo_promise_write = nullptr);
|
||||
std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();
|
||||
|
||||
uint32_t get_pdo_counter() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user