| | |
| | | #include "stdafx.h" |
| | | #include "CStep.h" |
| | | #include "Common.h" |
| | | |
| | | |
| | | namespace SERVO { |
| | |
| | | |
| | | CStep::CStep() |
| | | { |
| | | m_listener = {nullptr}; |
| | | m_nWordThreadAddr = 0; |
| | | m_hWorkStop = nullptr; |
| | | m_hWorkThreadHandle = nullptr; |
| | |
| | | DeleteCriticalSection(&m_criticalSection); |
| | | } |
| | | |
| | | void CStep::setListener(StepListener listener) |
| | | { |
| | | m_listener.onEvent = listener.onEvent; |
| | | } |
| | | |
| | | void CStep::setCcLink(CCCLinkIEControl* pCcLink) |
| | | { |
| | | m_pCclink = pCcLink; |
| | | } |
| | | |
| | | void CStep::setEquipment(CEquipment* pEquipment) |
| | | { |
| | | m_pEquipment = pEquipment; |
| | | } |
| | | |
| | | CEquipment* CStep::getEquipment() |
| | | { |
| | | return m_pEquipment; |
| | | } |
| | | |
| | | void CStep::setName(const char* pszName) |
| | | { |
| | | m_strName = pszName; |
| | | } |
| | | |
| | | std::string& CStep::getName() |
| | | { |
| | | return m_strName; |
| | | } |
| | | |
| | | void CStep::getAttributeVector(CAttributeVector& attrubutes) |
| | | { |
| | | attrubutes.clear(); |
| | | attrubutes.addAttribute(new CAttribute("Network", |
| | | std::to_string(m_station.nNetNo).c_str(), "")); |
| | | attrubutes.addAttribute(new CAttribute("Station", |
| | | std::to_string(m_station.nStNo).c_str(), "")); |
| | | attrubutes.addAttribute(new CAttribute("Current Step", |
| | | std::to_string(m_nCurStep).c_str(), "")); |
| | | attrubutes.addAttribute(new CAttribute("Signal Dev", |
| | | std::to_string(m_nWriteSignalDev).c_str(), "")); |
| | | } |
| | | |
| | | void CStep::setWriteSignalDev(int dev) |
| | |
| | | // 1.读取数据 |
| | | nextStep(); |
| | | ASSERT(m_pCclink); |
| | | onReadData(); |
| | | |
| | | if (0 == onReadData()) { |
| | | if (m_listener.onEvent != nullptr) { |
| | | m_listener.onEvent(this, STEP_EVENT_READDATA, nullptr); |
| | | } |
| | | } |
| | | |
| | | // 2.给对方写ON |
| | | nextStep(); |
| | |
| | | |
| | | // 6.完成 |
| | | nextStep(); |
| | | onComplete(); |
| | | if (0 == onComplete()) { |
| | | if (m_listener.onEvent != nullptr) { |
| | | m_listener.onEvent(this, STEP_EVENT_COMPLETE, nullptr); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | m_nCurStep++; |
| | | Unlock(); |
| | | } |
| | | |
| | | void CStep::convertString(const char* pszBuffer, int size, std::string& strOut) |
| | | { |
| | | strOut.clear(); |
| | | int nLength = 0; |
| | | for (int i = 0; i < size; i++) { |
| | | if (pszBuffer[i] == '\0') break; |
| | | nLength++; |
| | | } |
| | | if (nLength > 0) { |
| | | strOut = std::string(pszBuffer, nLength); |
| | | } |
| | | } |
| | | } |
| | | |