#include "Outriggers.h" #include "message_queue.h" COutriggersSensor::COutriggersSensor(CMessageQueue* q) :_message(q) { _run = false; } void COutriggersSensor::SetModbusTcpSensor(SensorModbusTcp* modbus) { _modbus = modbus; } void COutriggersSensor::Start() { if(!_run) { _thread = std::thread(&COutriggersSensor::Run, this); _run = true; } } void COutriggersSensor::Run() { while (_run) { _modbus->read_registers(0x00,0x10); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } } void COutriggersSensor::Stop() { if (_run) { _run = false; _thread.join(); } } void COutriggersSensor::Notify(uint16_t * buffer) { if (_run) { _message->_Feeddata.wire_sensor_l = buffer[0]; _message->_Feeddata.wire_sensor_r = buffer[1]; } }