顶针盘与电压电流串口常连接

main
admin 2 months ago
parent 7554c180e2
commit b3dbcfc5b7

@ -1059,24 +1059,28 @@ void COtherMonitorDevMgr::OnO2ConcentrationCommRecv()
//读取机台的电流电压值
void COtherMonitorDevMgr::ReadDeviceCurrentAndVoltage()
{
ComComm Comm;
if(!Comm.Open(m_DeviceCurrentAndVoltageCommPort,COMM_BAUD_RATE_9600))
if (!DevComm.IsOpen())
{
if (!DevComm.Open(m_DeviceCurrentAndVoltageCommPort, COMM_BAUD_RATE_9600))
{
return;
}
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent1, Comm);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent2, Comm);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent3, Comm);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevVoltage1, Comm);
}
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent1);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent2);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevCurrent3);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevVoltage1);
#if 0
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevSmoke,CommMgr);
ReadDeviceCurrentAndVoltageExt(_MonitorValType_DevSmoke);
#endif
Comm.Close();
}
void COtherMonitorDevMgr::ReadDeviceCurrentAndVoltageExt(eMonitorValType MonitorValType,ComComm &Comm)
void COtherMonitorDevMgr::ReadDeviceCurrentAndVoltageExt(eMonitorValType MonitorValType)
{
if (!DevComm.IsOpen())
{
return;
}
Sleep(100);
unsigned char Buf[COM_BUF_LEN];
memset(Buf, 0, COM_BUF_LEN);
//ADDR
@ -1122,10 +1126,10 @@ void COtherMonitorDevMgr::ReadDeviceCurrentAndVoltageExt(eMonitorValType Monitor
Buf[i++] = CRCH;
Buf[i++] = CRCL;
//发送
Comm.Write(Buf,i);
DevComm.Write(Buf, i);
Sleep(100);
memset(Buf, 0, COM_BUF_LEN);
Comm.Read(Buf,COM_BUF_LEN);
DevComm.Read(Buf, COM_BUF_LEN);
//从串口数据中提取读数
double ReadVal = -1;
int high = Byte2Int(Buf[3]);

@ -102,10 +102,11 @@ public:
void FluoroscopyO2ConcentrationCommRecv();
void PLCReadFFUVal();
private:
void ReadDeviceCurrentAndVoltageExt(eMonitorValType MonitorValType,ComComm &Comm);
void ReadDeviceCurrentAndVoltageExt(eMonitorValType MonitorValType);
void DealAlarm(eAlarmType CurAlarmType, bool bThrow, CString ErrInfo);
private:
CCommPortMgr m_O2ConcentrationComm;//氧气浓度串口管理
ComComm DevComm;//设备电压电流串口
int m_O2ConcentrationCommPort;//氧气浓度串口端口
int m_nO2DevType;//氧浓度设备类型 0 TORAY 1 鸿瑞稻科 2 荧光学
bool m_bCheckO2Concentration;//是否检测氧气浓度

@ -71,11 +71,14 @@ int CSmartStraightLineSerDriverCtl::QueryPostion(int nTimeSecOut)
return -1;
}
int nRet = -1;
if (!m_comCtl.IsOpen())
{
bool bRet = m_comCtl.Open(m_nCom, m_nBaud);
if (!bRet)
{
return nRet;
}
}
if (m_comCtl.IsOpen())
{
m_comCtl.Purge();
@ -150,7 +153,7 @@ int CSmartStraightLineSerDriverCtl::QueryPostion(int nTimeSecOut)
}
} while (m_bInit);
}
m_comCtl.Close();
//m_comCtl.Close();
return nRet;
}
@ -227,13 +230,16 @@ int CSmartStraightLineSerDriverCtl::SetPostion(int nPostion,int nTimeSecOut)
string strOUT;
//测试发现偶尔出现USB 转COM 掉线问题,以及此设备报文必须发送后等待应答了才能发送下一个
//所以保险每次都重新打开串口
m_comCtl.Close();
//m_comCtl.Close();
if (!m_comCtl.IsOpen())
{
bool bRet = m_comCtl.Open(m_nCom, m_nBaud);
if (!bRet)
{
m_pLog->LogDebug("串口打开失败:%ld", GetLastError());
return nRet;
}
}
do
{
@ -304,7 +310,7 @@ int CSmartStraightLineSerDriverCtl::SetPostion(int nPostion,int nTimeSecOut)
break;
}
} while (m_bInit);
m_comCtl.Close();
//m_comCtl.Close();
return nRet;
}

Loading…
Cancel
Save