From bf55b2f3083cbfdeb83611b2fa2dd552bf5b0775 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 03 三月 2025 16:20:00 +0800
Subject: [PATCH] 1.开始处理Step属性值; 2.增加左侧master面板;
---
SourceCode/Bond/Servo/CStep.cpp | 107 +++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 87 insertions(+), 20 deletions(-)
diff --git a/SourceCode/Bond/Servo/CStep.cpp b/SourceCode/Bond/Servo/CStep.cpp
index 3873ddf..6690b0f 100644
--- a/SourceCode/Bond/Servo/CStep.cpp
+++ b/SourceCode/Bond/Servo/CStep.cpp
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "CStep.h"
+#include "Common.h"
namespace SERVO {
@@ -7,12 +8,13 @@
unsigned __stdcall StepWorkThreadFunction(LPVOID lpParam)
{
- CStep* pScale = (CStep*)lpParam;
- return pScale->WorkingProc();
+ CStep* pStep = (CStep*)lpParam;
+ return pStep->WorkingProc();
}
CStep::CStep()
{
+ m_listener = {nullptr};
m_nWordThreadAddr = 0;
m_hWorkStop = nullptr;
m_hWorkThreadHandle = nullptr;
@@ -20,6 +22,7 @@
m_hSignalOff = ::CreateEvent(NULL, TRUE, FALSE, NULL);
m_nCurStep = 0;
m_pCclink = nullptr;
+ m_nWriteSignalDev = 0;
InitializeCriticalSection(&m_criticalSection);
}
@@ -36,9 +39,52 @@
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)
+ {
+ m_nWriteSignalDev = dev;
}
void CStep::init()
@@ -86,23 +132,23 @@
// 1.读取数据
nextStep();
ASSERT(m_pCclink);
- StationIdentifier station(0, 255);
- DWordContainer dc;
- m_pCclink->ReadDWordData(station, DeviceType::W, 0x4a8c, 1, dc);
- int nState = dc.at(0);
- TRACE(">> nState:%d\n", nState);
+ if (0 == onReadData()) {
+ if (m_listener.onEvent != nullptr) {
+ m_listener.onEvent(this, STEP_EVENT_READDATA, nullptr);
+ }
+ }
// 2.给对方写ON
nextStep();
- m_pCclink->SetBitDevice(station, DeviceType::B, 0x30);
+ m_pCclink->SetBitDevice(m_station, DeviceType::B, m_nWriteSignalDev);
// 3.等待对方OFF
nextStep();
int nStep3Ret = ::WaitForSingleObject(m_hSignalOff, TIMEOUT * 1000);
if (nStep3Ret == WAIT_TIMEOUT) {
- timeout();
- m_pCclink->ResetBitDevice(station, DeviceType::B, 0x30);
+ m_pCclink->ResetBitDevice(m_station, DeviceType::B, m_nWriteSignalDev);
+ onTimeout();
goto RESET;
}
ResetEvent(m_hSignalOff);
@@ -110,18 +156,16 @@
// 4.给对方写OFF
nextStep();
- m_pCclink->ResetBitDevice(station, DeviceType::B, 0x30);
- TRACE("m_nCurStep:%d\n", m_nCurStep);
-
-
- // 5.对接CIM等
- nextStep();
- TRACE("m_nCurStep:%d\n", m_nCurStep);
+ m_pCclink->ResetBitDevice(m_station, DeviceType::B, m_nWriteSignalDev);
// 6.完成
nextStep();
- TRACE("m_nCurStep:%d\n", m_nCurStep);
+ if (0 == onComplete()) {
+ if (m_listener.onEvent != nullptr) {
+ m_listener.onEvent(this, STEP_EVENT_COMPLETE, nullptr);
+ }
+ }
}
}
@@ -147,6 +191,21 @@
Unlock();
}
+ int CStep::onReadData()
+ {
+ return 0;
+ }
+
+ int CStep::onComplete()
+ {
+ return 0;
+ }
+
+ int CStep::onTimeout()
+ {
+ return 0;
+ }
+
void CStep::resetStep()
{
Lock();
@@ -161,9 +220,17 @@
Unlock();
}
- void CStep::timeout()
+ void CStep::convertString(const char* pszBuffer, int size, std::string& strOut)
{
- TRACE(">>>>>>>>>>>>>>>> timeout:%d\n", m_nCurStep);
+ 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);
+ }
}
}
--
Gitblit v1.9.3