1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include "Outriggers.h"
- #include "message_queue.h"
- COutriggersSensor::COutriggersSensor(CMessageQueue* q) :_message(q)
- {
- _run = false;
- }
- void COutriggersSensor::SetModbusTcpSensor(SensorModbusTcp<COutriggersSensor>* 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];
- }
- }
|