2025-08-20 23:06:28 +08:00
|
|
|
|
#include "P13_InsPage.h"
|
|
|
|
|
|
#include "ui_P13_InsPage.h"
|
|
|
|
|
|
|
|
|
|
|
|
P13_InsPage::P13_InsPage(QWidget *parent) :
|
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
|
ui(new Ui::P13_InsPage)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
2025-09-30 15:36:46 +08:00
|
|
|
|
m_OpcUaManager = OpcUaManager::instance(); // 全局唯一OPC实例
|
2025-08-20 23:06:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
P13_InsPage::~P13_InsPage()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
2025-09-30 15:36:46 +08:00
|
|
|
|
void P13_InsPage::Write32Bit(uint8_t Key ,uint8_t Index,int8_t int8){
|
|
|
|
|
|
if(Key <1 || Key > 4) return;
|
|
|
|
|
|
if(Index > 3) return;
|
|
|
|
|
|
if(int8 <-127 || int8 > 127) return;
|
|
|
|
|
|
|
|
|
|
|
|
QString NodeId = QString("ns=6;s=::AsGlobalPV:PanelControlKey_%1").arg(Key);
|
|
|
|
|
|
uint32_t OldValue = gOPC_NodeValue[NodeId].toUInt();
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t ByteValue = static_cast<uint8_t>(int8); // 先转无符号字节
|
|
|
|
|
|
uint32_t Mask = ~(0xFFu << (Index * 8)); // 构造清除掩码
|
|
|
|
|
|
uint32_t NewValue = (OldValue & Mask) | (ByteValue << (Index * 8));
|
|
|
|
|
|
if(OldValue != NewValue){
|
|
|
|
|
|
qDebug()<<"发送节点:"<<NodeId<<"值"<<NewValue;
|
|
|
|
|
|
uint8_t Count = 0;
|
|
|
|
|
|
while (!m_OpcUaManager->writeNodeValue(NodeId,NewValue) && Count < 10) {
|
|
|
|
|
|
Count++;
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug()<<"成功发送节点:"<<NodeId<<"值"<<NewValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void P13_InsPage::Write32Bit(uint8_t Key, uint8_t Index, bool Bit)
|
|
|
|
|
|
{
|
|
|
|
|
|
/* 1. 参数校验 */
|
|
|
|
|
|
if (Key < 1 || Key > 4) return;
|
|
|
|
|
|
if (Index > 31) return; // 0…31 共 32 个 bit
|
|
|
|
|
|
|
|
|
|
|
|
/* 2. 构造 NodeId */
|
|
|
|
|
|
QString NodeId = QString("ns=6;s=::AsGlobalPV:PanelControlKey_%1").arg(Key);
|
|
|
|
|
|
|
|
|
|
|
|
/* 3. 读当前值(缓存里直接取) */
|
|
|
|
|
|
uint32_t OldValue = gOPC_NodeValue[NodeId].toUInt();
|
|
|
|
|
|
|
|
|
|
|
|
/* 4. 只改指定 bit,其余位不变 */
|
|
|
|
|
|
uint32_t NewValue;
|
|
|
|
|
|
if (Bit)
|
|
|
|
|
|
NewValue = OldValue | (1u << Index); // 置 1
|
|
|
|
|
|
else
|
|
|
|
|
|
NewValue = OldValue & ~(1u << Index); // 清 0
|
|
|
|
|
|
|
|
|
|
|
|
/* 5. 值没变就提前退出 */
|
|
|
|
|
|
if (OldValue == NewValue) return;
|
|
|
|
|
|
|
|
|
|
|
|
/* 6. 带重试的写操作 */
|
|
|
|
|
|
uint8_t Count = 0;
|
|
|
|
|
|
qDebug()<<"发送节点:"<<NodeId<<"值"<<NewValue;
|
|
|
|
|
|
while (!m_OpcUaManager->writeNodeValue(NodeId, NewValue) && Count < 10) {
|
|
|
|
|
|
++Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
qDebug()<<"成功发送节点:"<<NodeId<<"值"<<NewValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
void P13_InsPage::on_XZK_OperMode_activated(int index) {Write32Bit( 1, 0, static_cast<int8_t>(index));} //
|
|
|
|
|
|
void P13_InsPage::on_XZK_SpeedMode_activated(int index) {Write32Bit( 4, 5, static_cast< bool >(index));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_Track_sliderMoved(int position) {Write32Bit( 1, 1, static_cast<int8_t>(position));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_TrackL_sliderMoved(int position) {Write32Bit( 1, 2, static_cast<int8_t>(position));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_TrackR_sliderMoved(int position) {Write32Bit( 1, 3, static_cast<int8_t>(position));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_Cut_sliderMoved(int position) {Write32Bit( 2, 0, static_cast<int8_t>(position));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_Cutt_sliderMoved(int position) {Write32Bit( 2, 1, static_cast<int8_t>(position));} //
|
|
|
|
|
|
|
|
|
|
|
|
void P13_InsPage::on_Sider_Track_sliderReleased() {ui->Sider_Track->setValue(0); Write32Bit( 1, 1, static_cast<int8_t>(0));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_TrackL_sliderReleased() {ui->Sider_TrackL->setValue(0); Write32Bit( 1, 2, static_cast<int8_t>(0));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_TrackR_sliderReleased() {ui->Sider_TrackR->setValue(0); Write32Bit( 1, 3, static_cast<int8_t>(0));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_Cut_sliderReleased() {ui->Sider_Cut->setValue(0); Write32Bit( 2, 0, static_cast<int8_t>(0));} //
|
|
|
|
|
|
void P13_InsPage::on_Sider_Cutt_sliderReleased() {ui->Sider_Cutt->setValue(0); Write32Bit( 2, 1, static_cast<int8_t>(0));} //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void P13_InsPage::on_But_EStop_pressed() {Write32Bit( 2, 2, static_cast< int8_t >(0xFF));} //
|
|
|
|
|
|
void P13_InsPage::on_But_PumpStart_pressed() {Write32Bit( 3, 0, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_PumpStop_pressed() {Write32Bit( 3, 1, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_CutStart_pressed() {Write32Bit( 3, 2, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_CutStop_pressed() {Write32Bit( 3, 3, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_LoaderStart_pressed() {Write32Bit( 3, 4, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_LoaderStop_pressed() {Write32Bit( 3, 5, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportCorotation_pressed() {Write32Bit( 3, 6, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportReversal_pressed() {Write32Bit( 3, 7, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportStop_pressed() {Write32Bit( 3, 8, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_StandbyStart_pressed() {Write32Bit( 3, 9, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_StandbyStop_pressed() {Write32Bit( 3, 10, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_Reset_pressed() {Write32Bit( 3, 11, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportLifterStr_pressed() {Write32Bit( 3, 12, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportLifterShr_pressed() {Write32Bit( 3, 13, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportSwingStr_pressed() {Write32Bit( 3, 14, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportSwingShr_pressed() {Write32Bit( 3, 15, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_BoardLifterStr_pressed() {Write32Bit( 3, 16, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_BoardLifterShr_pressed() {Write32Bit( 3, 17, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_BoardExpansionStr_pressed() {Write32Bit( 3, 18, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_BoardExpansionShr_pressed() {Write32Bit( 3, 19, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportLStr_pressed() {Write32Bit( 3, 20, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportLShr_pressed() {Write32Bit( 3, 21, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportRStr_pressed() {Write32Bit( 3, 22, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportRShr_pressed() {Write32Bit( 3, 23, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_HydraulicStr_pressed() {Write32Bit( 3, 24, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_HydraulicShr_pressed() {Write32Bit( 3, 25, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_ECUStr_pressed() {Write32Bit( 3, 26, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_ECUShr_pressed() {Write32Bit( 3, 27, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportTmpStr_pressed() {Write32Bit( 3, 28, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_SupportTmpShr_pressed() {Write32Bit( 3, 29, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_RollerStr_pressed() {Write32Bit( 3, 30, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_RollerShr_pressed() {Write32Bit( 3, 31, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_LubPump_pressed() {Write32Bit( 4, 0, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_BoostPump_pressed() {Write32Bit( 4, 1, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TrackTension_pressed() {Write32Bit( 4, 2, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_TransportTension_pressed() {Write32Bit( 4, 3, static_cast< bool >(true));}
|
|
|
|
|
|
void P13_InsPage::on_But_DustFan_pressed() {Write32Bit( 4, 4, static_cast< bool >(true));}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void P13_InsPage::on_But_EStop_released() {Write32Bit( 2, 2, static_cast< int8_t >(0x00));} //
|
|
|
|
|
|
void P13_InsPage::on_But_PumpStart_released() {Write32Bit( 3, 0, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_PumpStop_released() {Write32Bit( 3, 1, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_CutStart_released() {Write32Bit( 3, 2, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_CutStop_released() {Write32Bit( 3, 3, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_LoaderStart_released() {Write32Bit( 3, 4, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_LoaderStop_released() {Write32Bit( 3, 5, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportCorotation_released() {Write32Bit( 3, 6, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportReversal_released() {Write32Bit( 3, 7, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportStop_released() {Write32Bit( 3, 8, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_StandbyStart_released() {Write32Bit( 3, 9, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_StandbyStop_released() {Write32Bit( 3, 10, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_Reset_released() {Write32Bit( 3, 11, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportLifterStr_released() {Write32Bit( 3, 12, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportLifterShr_released() {Write32Bit( 3, 13, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportSwingStr_released() {Write32Bit( 3, 14, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportSwingShr_released() {Write32Bit( 3, 15, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_BoardLifterStr_released() {Write32Bit( 3, 16, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_BoardLifterShr_released() {Write32Bit( 3, 17, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_BoardExpansionStr_released() {Write32Bit( 3, 18, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_BoardExpansionShr_released() {Write32Bit( 3, 19, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportLStr_released() {Write32Bit( 3, 20, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportLShr_released() {Write32Bit( 3, 21, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportRStr_released() {Write32Bit( 3, 22, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportRShr_released() {Write32Bit( 3, 23, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_HydraulicStr_released() {Write32Bit( 3, 24, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_HydraulicShr_released() {Write32Bit( 3, 25, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_ECUStr_released() {Write32Bit( 3, 26, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_ECUShr_released() {Write32Bit( 3, 27, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportTmpStr_released() {Write32Bit( 3, 28, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_SupportTmpShr_released() {Write32Bit( 3, 29, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_RollerStr_released() {Write32Bit( 3, 30, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_RollerShr_released() {Write32Bit( 3, 31, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_LubPump_released() {Write32Bit( 4, 0, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_BoostPump_released() {Write32Bit( 4, 1, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TrackTension_released() {Write32Bit( 4, 2, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_TransportTension_released() {Write32Bit( 4, 3, static_cast< bool >(false));} //
|
|
|
|
|
|
void P13_InsPage::on_But_DustFan_released() {Write32Bit( 4, 4, static_cast< bool >(false));} //
|