From 1823e5c63bac2246d066eb74318230952484c58a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 19 三月 2025 16:41:07 +0800
Subject: [PATCH] 1.Pin的连接和发送数据。
---
SourceCode/Bond/Servo/CEquipment.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index deaee05..78c64d7 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -27,6 +27,16 @@
}
m_mapStep.clear();
+ for (auto item : m_inputPins) {
+ delete item;
+ }
+ m_inputPins.clear();
+
+ for (auto item : m_outputPins) {
+ delete item;
+ }
+ m_outputPins.clear();
+
DeleteCriticalSection(&m_criticalSection);
}
@@ -374,6 +384,55 @@
return m_bVCREnable[index];
}
+ CPin* CEquipment::addPin(PinType type, char* pszName)
+ {
+ // 不允许名字添加重复的pin
+ CPin* pPin = getPin(pszName);
+ if (pPin != nullptr) return nullptr;
+
+
+ // 添加到Pin列表,看是输入pin或输出pin
+ if (type == PinType::INPUT) {
+ pPin = new CPin(this, type, pszName);
+ m_inputPins.push_back(pPin);
+ return pPin;
+ }
+ else if (type == PinType::OUTPUT) {
+ pPin = new CPin(this, type, pszName);
+ m_outputPins.push_back(pPin);
+ return pPin;
+ }
+
+ return nullptr;
+ }
+
+ CPin* CEquipment::getPin(char* pszName)
+ {
+ for (auto item : m_inputPins) {
+ if (item->getName().compare(pszName) == 0) {
+ return item;
+ }
+ }
+
+ for (auto item : m_outputPins) {
+ if (item->getName().compare(pszName) == 0) {
+ return item;
+ }
+ }
+
+ return nullptr;
+ }
+
+ std::vector<CPin*>& CEquipment::getInputPins()
+ {
+ return m_inputPins;
+ }
+
+ std::vector<CPin*>& CEquipment::getOutputPins()
+ {
+ return m_outputPins;
+ }
+
int CEquipment::recvSample(CPin* pPin, CSample* pSample)
{
LOGI("<CEquipment>recvSample, pin:%s", pPin->getName().c_str());
--
Gitblit v1.9.3