|
@@ -1,6 +1,7 @@
|
|
|
#ifndef JIOMAPPAGE_H
|
|
|
#define JIOMAPPAGE_H
|
|
|
#include "TreeViewManagerHead.h"
|
|
|
+#include "Src/common/JLogAllOutput.h"
|
|
|
#include <QMouseEvent>
|
|
|
|
|
|
class ClickCircleLabel : public QLabel {
|
|
@@ -8,11 +9,46 @@ class ClickCircleLabel : public QLabel {
|
|
|
|
|
|
public:
|
|
|
ClickCircleLabel(QWidget* parent = nullptr)
|
|
|
- : QLabel(parent), m_bClicked(false)
|
|
|
+ : QLabel(parent)
|
|
|
{
|
|
|
setFixedSize(30, 30);
|
|
|
}
|
|
|
|
|
|
+public:
|
|
|
+ /**设置io 轴名称
|
|
|
+ */
|
|
|
+ void setIoName(const QString& strName)
|
|
|
+ {
|
|
|
+ m_strName = strName;
|
|
|
+ UpDataIoStatus(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void UpDataIoStatus(bool isInit)
|
|
|
+ {
|
|
|
+ if (m_pCamera == nullptr)
|
|
|
+ {
|
|
|
+ m_pCamera = ns_module::CViewInterface::GetInstance();
|
|
|
+ if (m_pCamera == nullptr)
|
|
|
+ {
|
|
|
+ // 为了调试准备的
|
|
|
+ JLogAllOutput::cmd_error("io 轴设置失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isInit)
|
|
|
+ {
|
|
|
+ // 信号量
|
|
|
+ ns_db::DIGIT_IO_LEVEL nOutput;
|
|
|
+ m_pCamera->GetIoStatus(m_strName.toStdString(), nOutput);
|
|
|
+ m_bClicked = nOutput;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_pCamera->SetIoStatus(m_strName.toStdString(), m_bClicked);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected:
|
|
|
void paintEvent(QPaintEvent* event) override
|
|
|
{
|
|
@@ -25,7 +61,7 @@ protected:
|
|
|
int y = (height() - 2 * radius) / 2;
|
|
|
|
|
|
painter.setPen(Qt::NoPen);
|
|
|
- painter.setBrush(m_bClicked ? Qt::red : Qt::gray);
|
|
|
+ painter.setBrush(m_bClicked ? Qt::green : Qt::red);
|
|
|
painter.drawEllipse(x, y, 2 * radius, 2 * radius);
|
|
|
}
|
|
|
|
|
@@ -33,14 +69,20 @@ protected:
|
|
|
{
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
{
|
|
|
- m_bClicked = !m_bClicked;
|
|
|
+ m_bClicked = !m_bClicked;
|
|
|
+ UpDataIoStatus(false);
|
|
|
+
|
|
|
update();
|
|
|
}
|
|
|
QLabel::mousePressEvent(event);
|
|
|
}
|
|
|
|
|
|
private:
|
|
|
- bool m_bClicked; // 当前状态
|
|
|
+ bool m_bClicked; // 当前状态
|
|
|
+
|
|
|
+ QString m_strName;
|
|
|
+
|
|
|
+ ns_module::CViewInterface* m_pCamera = nullptr;
|
|
|
};
|
|
|
|
|
|
class JIoMapPage :public QObject
|
|
@@ -49,7 +91,9 @@ class JIoMapPage :public QObject
|
|
|
public:
|
|
|
JIoMapPage();
|
|
|
|
|
|
- static QWidget* CreateIoPage();
|
|
|
+ /**io 界面,先获取全部,后续可用,没用到的后续修改
|
|
|
+ */
|
|
|
+ static QWidget* CreateIoPage(const CONFIG_BASE_STRUCT& control);
|
|
|
};
|
|
|
|
|
|
#include <QApplication>
|