12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "stdafx.h"
- #include "SensorADController.h"
- #include "ICommunicateEntity.h"
- using namespace DIOS::Dev::Detail::MachineryECOM;
- SensorADController::SensorADController()
- :m_communicate(nullptr)
- {
- }
- SensorADController::~SensorADController()
- {
- }
- std::string SensorADController::CLASSID()
- {
- return "B6193C55-C668-4ADA-88F0-13124D9025AD";
- }
- void SensorADController::Initialize(const std::string &name)
- {
- SetName(name);
- }
- void SensorADController::OnCommunicationEstablished(ICommunicateEntity *communicate)
- {
- m_communicate = communicate;
- }
- int SensorADController::GetCurrentADValue()
- {
- if (!m_communicate || m_communicateInterfaceID < 0)
- {
- return INVALID_AD_VALUE;
- }
- int retry = 0;
- AD_PARAM params;
- while (retry++ < 5)
- {
- m_communicate->AD_Ctrl(OP_READ, (AD_ID)m_communicateInterfaceID, AD_ATTR_NONE, params);
- if (params.ad_value.ad_value_short > 0)
- {
- break;
- }
- }
- return params.ad_value.ad_value_short;
- }
|