添加识别设备型号功能;修改modbus tcp从机寄存器写入方式

CigaretteSH
CJ980606 8 months ago
parent 45381dfdf2
commit 81409c3f2c

@ -10,6 +10,11 @@ extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
extern PLCDevice* m_PLCDevice;
extern int work_camera_nums;
#ifdef __TCPSend
extern SyncQueue<_TCPSendInfo>* TCP_Info_queue;
extern threadSendTCP tcpSendThread;
#endif
inline void LossCallBackfunction(unsigned int pData, void* pUser) {
try {
CaptureThreadHIK* CaptureThreadHIKptr = (CaptureThreadHIK*)pUser;

@ -10,15 +10,15 @@
<LocalDebuggerEnvironment>PATH=$(QTDIR)\bin%3bD:\Qt\5.15.2\msvc2019_64\bin%3b$(PATH)</LocalDebuggerEnvironment>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2024-04-28T07:53:26.8147850Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-05-14T07:50:55.2278815Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2024-04-28T07:53:26.8795721Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-05-14T07:50:55.3158777Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2024-04-28T07:53:26.9413622Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-05-14T07:50:55.3628774Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2024-04-28T07:53:26.9872078Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2024-05-14T07:50:55.4078779Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

@ -35,14 +35,14 @@ bool PLCDevice::init_plc(PLCDevice* PLCptr)
bool PLCDevice::init_plc_tcp(PLCDevice* PLCptr)
{
#ifdef __ModebusServer
PLCptr->g_modbus = modbus_new_tcp("192.168.1.200", 2000);
PLCptr->g_modbus = modbus_new_tcp("192.168.1.180", 2000);
modbus_set_debug(PLCptr->g_modbus, 0); // 用flag设置debug调试标志位flag=1时显示modbus消息的字节
modbus_set_response_timeout(PLCptr->g_modbus, 1, 0); // 设置响应超时
modbus_connect(PLCptr->g_modbus);
modbus_set_slave(PLCptr->g_modbus, 1); // 设置从站id
uint8_t data;
int ret = modbus_read_bits(PLCptr->g_modbus, 30000, 1, &data);
int ret = modbus_read_bits(PLCptr->g_modbus, 0, 1, &data);
// 连接失败
if (-1 == ret)
{
@ -55,9 +55,8 @@ bool PLCDevice::init_plc_tcp(PLCDevice* PLCptr)
qDebug("TCP connect successful ");
}
#endif
#ifdef __ModebusClient
PLCptr->g_modbus = modbus_new_tcp("127.0.0.1", 502);
PLCptr->g_modbus = modbus_new_tcp("192.168.1.175", 4444);
modbus_set_debug(PLCptr->g_modbus, 0); // 用flag设置debug调试标志位flag=1时显示modbus消息的字节
modbus_set_response_timeout(PLCptr->g_modbus, 1, 0); // 设置响应超时
// 侦听主站连接

@ -11,7 +11,6 @@ public:
//[0]:1=连接,0=断开
uint8_t g_plc_status;
#ifdef __ModebusClient
int m_modbusSocket;
bool m_initialized;
@ -25,7 +24,6 @@ public:
void recieveMessages();
std::thread *modSerThread;
#endif
static bool init_plc(PLCDevice* PLCptr);
static bool init_plc_tcp(PLCDevice* PLCptr);

@ -27,19 +27,11 @@ bool AlgJd::init(QString model_path, QString model_name)
image_path = model_path + "/" + "alg_jd.jpg";
}
else {
#ifdef __DEBUGPATH
modelWeights = "../model/jd.weights";
classesFile = "../model/jd.names";
// Give the configuration and weight files for the model
modelConfiguration = "../model/jd.cfg";
image_path = "alg_jd.jpg";
#else
modelWeights = "D:/model/jd.weights";
classesFile = "D:/model/jd.names";
// Give the configuration and weight files for the model
modelConfiguration = "D:/model/jd.cfg";
image_path = "D:/model/alg_jd.jpg";
#endif
}
std::ifstream classNamesFile(classesFile.c_str());

@ -2,7 +2,7 @@
#include <opencv2/opencv.hpp>
#define NumberOfSupportedCameras 3
#define NumberOfSupportedCameras 2
//双软件
#define NumberOfIdentityCameras 8
#define EdgeEvent 1

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>878</width>
<height>226</height>
<width>319</width>
<height>270</height>
</rect>
</property>
<property name="windowTitle">
@ -41,7 +41,7 @@
<property name="geometry">
<rect>
<x>290</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>
@ -65,7 +65,7 @@
<property name="geometry">
<rect>
<x>390</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>
@ -89,7 +89,7 @@
<property name="geometry">
<rect>
<x>290</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -137,7 +137,7 @@
<property name="geometry">
<rect>
<x>390</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -161,7 +161,7 @@
<property name="geometry">
<rect>
<x>290</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -209,7 +209,7 @@
<property name="geometry">
<rect>
<x>390</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -410,7 +410,7 @@
<property name="geometry">
<rect>
<x>290</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -431,7 +431,7 @@
<property name="geometry">
<rect>
<x>390</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -451,7 +451,7 @@
<widget class="QLabel" name="label_hint">
<property name="geometry">
<rect>
<x>550</x>
<x>50</x>
<y>190</y>
<width>285</width>
<height>25</height>
@ -470,8 +470,8 @@
<widget class="QPushButton" name="pushButton_take">
<property name="geometry">
<rect>
<x>360</x>
<y>190</y>
<x>80</x>
<y>220</y>
<width>141</width>
<height>31</height>
</rect>
@ -492,7 +492,7 @@
<property name="geometry">
<rect>
<x>490</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -516,7 +516,7 @@
<property name="geometry">
<rect>
<x>490</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -537,7 +537,7 @@
<property name="geometry">
<rect>
<x>490</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -561,7 +561,7 @@
<property name="geometry">
<rect>
<x>490</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>
@ -585,7 +585,7 @@
<property name="geometry">
<rect>
<x>590</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -609,7 +609,7 @@
<property name="geometry">
<rect>
<x>590</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -630,7 +630,7 @@
<property name="geometry">
<rect>
<x>590</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -654,7 +654,7 @@
<property name="geometry">
<rect>
<x>590</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>
@ -678,7 +678,7 @@
<property name="geometry">
<rect>
<x>690</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -702,7 +702,7 @@
<property name="geometry">
<rect>
<x>690</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -723,7 +723,7 @@
<property name="geometry">
<rect>
<x>690</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -747,7 +747,7 @@
<property name="geometry">
<rect>
<x>690</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>
@ -771,7 +771,7 @@
<property name="geometry">
<rect>
<x>790</x>
<y>150</y>
<y>1910</y>
<width>70</width>
<height>30</height>
</rect>
@ -795,7 +795,7 @@
<property name="geometry">
<rect>
<x>790</x>
<y>20</y>
<y>1780</y>
<width>70</width>
<height>20</height>
</rect>
@ -816,7 +816,7 @@
<property name="geometry">
<rect>
<x>790</x>
<y>100</y>
<y>1860</y>
<width>70</width>
<height>30</height>
</rect>
@ -840,7 +840,7 @@
<property name="geometry">
<rect>
<x>790</x>
<y>50</y>
<y>1810</y>
<width>70</width>
<height>30</height>
</rect>

@ -571,6 +571,8 @@ Cigarette::Cigarette(QWidget* parent)
BeforeWork(g_sys_conf.shoot);//预热
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.work, 1);
ui.label_title->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
ui.label_title_2->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
ui.label_title_2->setText(QStringLiteral("运行中"));
#ifdef __UDPSend
sThread.sendData("Work", g_sys_conf.FeedbackPort);
#endif
@ -638,6 +640,8 @@ void Cigarette::start_work()
ret = m_PLCDevice->write_bit_2_plc( g_modbus_conf.work, 1);*/
//printf("write:\t%d\n", ret);
ui.label_title->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
ui.label_title_2->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
ui.label_title_2->setText(QStringLiteral("运行中"));
#ifdef __UDPSend
sThread.sendData("Work", g_sys_conf.FeedbackPort);
#endif
@ -654,6 +658,8 @@ void Cigarette::start_work()
//开始按钮
void Cigarette::on_btn_start_released()
{
uint16_t data[2] = { 1111,0 };
m_PLCTCPDevice->write_2_plc(0, 70, data);//条盒
emit sengMsgToClog("Start to work.");
if (!g_admin_mode)
{
@ -688,6 +694,8 @@ void Cigarette::pause_work()
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.work, 0);
//printf("write:\t%d\n", ret);
ui.label_title->setStyleSheet(tr("background-color: rgb(255, 255, 0);"));
ui.label_title_2->setStyleSheet(tr("background-color: rgb(255, 255, 0);"));
ui.label_title_2->setText(QStringLiteral("未运行"));
#ifdef __UDPSend
sThread.sendData("NoWork", g_sys_conf.FeedbackPort);
#endif

File diff suppressed because it is too large Load Diff

@ -37,6 +37,8 @@
#define Queue_Size 15
#define Unit_Queue_Size Queue_Size*3
#define StrobeLineTime 10000
//设备型号
#define EquipmentModel "条盒"
#ifdef __DEBUG
#define DEBUG(format, ...) printf (format, ##__VA_ARGS__)
@ -48,8 +50,8 @@
#define DEFAULT_CONFPATH_PATH "D:/conf"
#define DEFAULT_PIC_SAVE_PATH "D:/image"
// 主界面基本参数配置文件
//#define CONFPATH "D:/Release/conf_path2.txt"//小盒
#define CONFPATH "D:/Release/conf_path3.txt"//条盒
#define CONFPATH "D:/Release/conf_path2.txt"//小盒
//#define CONFPATH "D:/Release/conf_path3.txt"//条盒
// 相机旋转角度配置文件
#define ROTATE_FILE "rotate.txt"
#define MODBUS_CONFIGURE_FILE "modbus.txt"

@ -472,11 +472,7 @@ void DialogSetup::on_toolButton_choose_path_jpg_released() {
void DialogSetup::write_pswd()
{
std::fstream cfg_file;
#ifdef __DEBUGPATH
cfg_file.open("pswd.txt", std::ios::out | std::ios::trunc);
#else
cfg_file.open("D:/Release/pswd.txt", std::ios::out | std::ios::trunc);
#endif
if (cfg_file.good())
{
char buf[256];
@ -489,11 +485,7 @@ void DialogSetup::write_pswd()
void DialogSetup::write_pswd_op()
{
std::fstream cfg_file;
#ifdef __DEBUGPATH
cfg_file.open("pswd_op.txt", std::ios::out | std::ios::trunc);
#else
cfg_file.open("D:/Release/pswd_op.txt", std::ios::out | std::ios::trunc);
#endif
if (cfg_file.good())
{
char buf[256];

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>682</width>
<height>900</height>
<width>663</width>
<height>750</height>
</rect>
</property>
<property name="font">
@ -29,8 +29,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>900</height>
<width>851</width>
<height>1121</height>
</rect>
</property>
<widget class="QScrollArea" name="scrollArea">
@ -38,8 +38,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>901</height>
<width>781</width>
<height>1011</height>
</rect>
</property>
<property name="sizePolicy">
@ -61,9 +61,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-122</y>
<width>670</width>
<height>1000</height>
<y>0</y>
<width>779</width>
<height>1009</height>
</rect>
</property>
<property name="sizePolicy">
@ -145,7 +145,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>610</y>
<y>450</y>
<width>641</width>
<height>81</height>
</rect>
@ -206,7 +206,7 @@
<widget class="QLineEdit" name="lineEdit_confirm">
<property name="geometry">
<rect>
<x>440</x>
<x>445</x>
<y>32</y>
<width>91</width>
<height>31</height>
@ -324,7 +324,7 @@
<x>10</x>
<y>180</y>
<width>640</width>
<height>278</height>
<height>111</height>
</rect>
</property>
<property name="font">
@ -510,7 +510,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>100</y>
<y>1780</y>
<width>90</width>
<height>20</height>
</rect>
@ -531,7 +531,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<y>1810</y>
<width>180</width>
<height>20</height>
</rect>
@ -552,7 +552,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>130</y>
<y>1810</y>
<width>90</width>
<height>20</height>
</rect>
@ -573,7 +573,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<y>1780</y>
<width>180</width>
<height>20</height>
</rect>
@ -594,7 +594,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>130</y>
<y>1810</y>
<width>90</width>
<height>20</height>
</rect>
@ -615,7 +615,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>100</y>
<y>1780</y>
<width>180</width>
<height>20</height>
</rect>
@ -636,7 +636,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>130</y>
<y>1810</y>
<width>180</width>
<height>20</height>
</rect>
@ -657,7 +657,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>100</y>
<y>1780</y>
<width>90</width>
<height>20</height>
</rect>
@ -699,7 +699,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>160</y>
<y>1840</y>
<width>180</width>
<height>20</height>
</rect>
@ -720,7 +720,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>190</y>
<y>1870</y>
<width>180</width>
<height>20</height>
</rect>
@ -741,7 +741,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<y>1900</y>
<width>180</width>
<height>20</height>
</rect>
@ -762,7 +762,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>160</y>
<y>1840</y>
<width>90</width>
<height>20</height>
</rect>
@ -783,7 +783,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>190</y>
<y>1870</y>
<width>90</width>
<height>20</height>
</rect>
@ -804,7 +804,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>220</y>
<y>1900</y>
<width>90</width>
<height>20</height>
</rect>
@ -825,7 +825,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>160</y>
<y>1840</y>
<width>180</width>
<height>20</height>
</rect>
@ -846,7 +846,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>190</y>
<y>1870</y>
<width>180</width>
<height>20</height>
</rect>
@ -867,7 +867,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>220</y>
<y>1900</y>
<width>180</width>
<height>20</height>
</rect>
@ -888,7 +888,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>160</y>
<y>1840</y>
<width>90</width>
<height>20</height>
</rect>
@ -909,7 +909,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>190</y>
<y>1870</y>
<width>90</width>
<height>20</height>
</rect>
@ -930,7 +930,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>220</y>
<y>1900</y>
<width>90</width>
<height>20</height>
</rect>
@ -951,7 +951,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>250</y>
<y>1930</y>
<width>180</width>
<height>20</height>
</rect>
@ -972,7 +972,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>250</y>
<y>1930</y>
<width>90</width>
<height>20</height>
</rect>
@ -993,7 +993,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>250</y>
<y>1930</y>
<width>180</width>
<height>20</height>
</rect>
@ -1014,7 +1014,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>250</y>
<y>1930</y>
<width>90</width>
<height>20</height>
</rect>
@ -1036,9 +1036,9 @@
<property name="geometry">
<rect>
<x>10</x>
<y>770</y>
<y>610</y>
<width>641</width>
<height>148</height>
<height>61</height>
</rect>
</property>
<property name="font">
@ -1140,7 +1140,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>60</y>
<y>1040</y>
<width>90</width>
<height>20</height>
</rect>
@ -1161,7 +1161,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<y>1040</y>
<width>180</width>
<height>20</height>
</rect>
@ -1182,7 +1182,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>60</y>
<y>1040</y>
<width>90</width>
<height>20</height>
</rect>
@ -1203,7 +1203,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>60</y>
<y>1040</y>
<width>180</width>
<height>20</height>
</rect>
@ -1245,7 +1245,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>90</y>
<y>1070</y>
<width>180</width>
<height>20</height>
</rect>
@ -1266,7 +1266,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>90</y>
<y>1070</y>
<width>180</width>
<height>20</height>
</rect>
@ -1287,7 +1287,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>120</y>
<y>1100</y>
<width>180</width>
<height>20</height>
</rect>
@ -1308,7 +1308,7 @@
<property name="geometry">
<rect>
<x>320</x>
<y>120</y>
<y>1100</y>
<width>180</width>
<height>20</height>
</rect>
@ -1329,7 +1329,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>90</y>
<y>1070</y>
<width>90</width>
<height>20</height>
</rect>
@ -1350,7 +1350,7 @@
<property name="geometry">
<rect>
<x>210</x>
<y>120</y>
<y>1100</y>
<width>90</width>
<height>20</height>
</rect>
@ -1371,7 +1371,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>90</y>
<y>1070</y>
<width>90</width>
<height>20</height>
</rect>
@ -1392,7 +1392,7 @@
<property name="geometry">
<rect>
<x>510</x>
<y>120</y>
<y>1100</y>
<width>90</width>
<height>20</height>
</rect>
@ -1519,7 +1519,7 @@
<property name="geometry">
<rect>
<x>110</x>
<y>930</y>
<y>690</y>
<width>131</width>
<height>51</height>
</rect>
@ -1561,7 +1561,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>690</y>
<y>530</y>
<width>641</width>
<height>81</height>
</rect>
@ -1601,7 +1601,7 @@
<widget class="QLineEdit" name="lineEdit_confirm_op">
<property name="geometry">
<rect>
<x>440</x>
<x>445</x>
<y>32</y>
<width>91</width>
<height>31</height>
@ -1738,7 +1738,7 @@
<property name="geometry">
<rect>
<x>370</x>
<y>930</y>
<y>690</y>
<width>131</width>
<height>51</height>
</rect>
@ -1825,7 +1825,7 @@
<property name="geometry">
<rect>
<x>40</x>
<y>460</y>
<y>300</y>
<width>101</width>
<height>41</height>
</rect>
@ -1846,7 +1846,7 @@
<property name="geometry">
<rect>
<x>40</x>
<y>560</y>
<y>400</y>
<width>101</width>
<height>41</height>
</rect>
@ -1867,7 +1867,7 @@
<property name="geometry">
<rect>
<x>40</x>
<y>510</y>
<y>350</y>
<width>101</width>
<height>41</height>
</rect>
@ -1888,7 +1888,7 @@
<property name="geometry">
<rect>
<x>620</x>
<y>470</y>
<y>1380</y>
<width>27</width>
<height>25</height>
</rect>
@ -1906,7 +1906,7 @@
<property name="geometry">
<rect>
<x>190</x>
<y>470</y>
<y>1380</y>
<width>171</width>
<height>30</height>
</rect>
@ -1930,7 +1930,7 @@
<property name="geometry">
<rect>
<x>370</x>
<y>470</y>
<y>1380</y>
<width>241</width>
<height>30</height>
</rect>
@ -2020,7 +2020,7 @@
<property name="geometry">
<rect>
<x>520</x>
<y>930</y>
<y>690</y>
<width>131</width>
<height>21</height>
</rect>
@ -2040,7 +2040,7 @@
<property name="geometry">
<rect>
<x>520</x>
<y>960</y>
<y>720</y>
<width>131</width>
<height>21</height>
</rect>
@ -2060,7 +2060,7 @@
<property name="geometry">
<rect>
<x>190</x>
<y>520</y>
<y>330</y>
<width>171</width>
<height>30</height>
</rect>
@ -2084,7 +2084,7 @@
<property name="geometry">
<rect>
<x>370</x>
<y>520</y>
<y>330</y>
<width>241</width>
<height>30</height>
</rect>
@ -2100,7 +2100,7 @@
<property name="geometry">
<rect>
<x>620</x>
<y>520</y>
<y>330</y>
<width>27</width>
<height>25</height>
</rect>
@ -2118,7 +2118,7 @@
<property name="geometry">
<rect>
<x>190</x>
<y>570</y>
<y>390</y>
<width>171</width>
<height>30</height>
</rect>
@ -2142,7 +2142,7 @@
<property name="geometry">
<rect>
<x>370</x>
<y>570</y>
<y>390</y>
<width>241</width>
<height>30</height>
</rect>
@ -2158,7 +2158,7 @@
<property name="geometry">
<rect>
<x>620</x>
<y>570</y>
<y>390</y>
<width>27</width>
<height>25</height>
</rect>

@ -346,10 +346,14 @@ void ExportDataThread::run()
QStringList argsOk;
//条盒TJ 小盒BJ
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
/*zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");*/
zipFilePaths.append("416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append("416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
fileList.append(zipTimeStamp[0] + "ng.txt");
fileList.append(zipTimeStamp[0] + "ok.txt");
zipTimeStamp.clear();

@ -18,6 +18,7 @@ int main(int argc, char* argv[])
exit(0);
}
#endif
qRegisterMetaType<cv::Mat>("cv::Mat");
QApplication a(argc, argv);
#ifdef __DEBUGPATH
@ -25,6 +26,30 @@ int main(int argc, char* argv[])
#else
QPixmap pixmap("D:/Release/splash.jpg");
#endif
#if defined EquipmentModel
//比较设备型号标志文件-----------------------------------------------------------------------------
string ider;
string name = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/include/thrust/async/flag.txt";//设备型号标志文件
std::ifstream file_(name.c_str());
if (file_.good())
{
getline(file_, ider);
file_.close();
}
else
{
ider = "Default";
}
cout << "设备型号:" << ider << endl;
if (ider != EquipmentModel)
{
QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("设备型号匹配失败"), QMessageBox::Ok);
exit(0);
}
//比较设备型号标志文件-----------------------------------------------------------------------------
#endif
QSplashScreen splash(pixmap);
splash.show();
a.processEvents();

@ -31,7 +31,7 @@
</font>
</property>
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="Camera1">
<attribute name="title">
@ -53,66 +53,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera3">
<attribute name="title">
<string>Camera3</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_3"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera4">
<attribute name="title">
<string>Camera4</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_4"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera5">
<attribute name="title">
<string>Camera5</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_5"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera6">
<attribute name="title">
<string>Camera6</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_6"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera7">
<attribute name="title">
<string>Camera7</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_7"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="Camera8">
<attribute name="title">
<string>Camera8</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QTextBrowser" name="textBrowser_8"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

@ -68,6 +68,15 @@ void SyncWorkThread::run()
uint32_t result_index[NumberOfSupportedCameras] = { 0 };
while (!b_quit) {
QDateTime now_ts = QDateTime::currentDateTime();
//#ifdef __TCPSend
// _TCPSendInfo TCPSendInfo;
//#ifdef __TCPSend
// QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz");
// TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
// TCP_Info_queue->put(TCPSendInfo);
//#endif
//#endif
std::vector<std::pair<int, cv::Mat>> element_vec;
local_g_image_sync_queue->take(element_vec);
bool IsNGForAll = false;
@ -114,6 +123,12 @@ void SyncWorkThread::run()
#ifdef __TCPSend
_TCPSendInfo TCPSendInfo;
#endif
//#ifdef __TCPSend
// QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz");
// TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
// TCP_Info_queue->put(TCPSendInfo);
//#endif
if (!image.data)
{
continue; //图像为空,跳过
@ -172,6 +187,8 @@ void SyncWorkThread::run()
#ifdef SYNC_CAMERA
emit display_jd_no(local_camera_number, jd_no);
#endif
#ifdef __UDPSend
UDPSendInfo.JD = jd_no;
#endif
@ -339,11 +356,11 @@ void SyncWorkThread::run()
}
//条盒TJ 小盒BJ
file_name = g_conf_path.save_pics_path + "/"
+ now_ts.toString("yyyy-MM-dd") + "/"+"416_TJ_01_"
+ now_ts.toString("yyyy-MM-dd") + "/"+"416_BJ_01_"
+ now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz_") + ng_reason_maps[ngReason] + ".jpg";
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), merge_image));
#ifdef __TCPSend
QString sendName = "416_TJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz_") + ng_reason_maps[ngReason];
QString sendName = "416_BJ_01_" + now_ts.toString("yyyy-MM-dd_HH-mm-ss.zzz");
TCPSendInfo.pics_name = sendName.toLocal8Bit().constData();
TCP_Info_queue->put(TCPSendInfo);
#endif
@ -362,7 +379,7 @@ void SyncWorkThread::run()
emit event_ng(local_camera_number);
else if (local_SysConf.MisMatchAct == 0)//as ok
emit event_ok(local_camera_number);
//emit display_check_total(local_camera_number, ++(frame_total[local_camera_number]));
emit display_check_total(local_camera_number, ++(frame_total[local_camera_number]));
qDebug() << local_camera_number << "#camera# " << now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx " << unit_count;
}
#endif

@ -7,7 +7,7 @@
#pragma comment(lib, "ws2_32.lib")
extern PLCDevice* m_PLCTCPDevice;
extern PLCDevice* m_PLCDevice;
void threadSendTCP::init(SyncQueue<_TCPSendInfo>* p_TCP_Info_queue, std::string ip_, int port_) {
ip = QString::fromStdString(ip_);
port = port_;
@ -64,6 +64,7 @@ bool threadSendTCP::connectTCP() {
void threadSendTCP::run()
{
#ifdef __TCPClient
if (!connectTCP())
{
@ -74,6 +75,7 @@ void threadSendTCP::run()
_TCPSendInfo TCPSendInfo;
Local_TCP_Info_queue->take(TCPSendInfo);
num++;
sendData(&TCPSendInfo, num);
#ifdef __TCPServer
if (ClientStatus == QAbstractSocket::ConnectedState)
{
@ -83,6 +85,9 @@ void threadSendTCP::run()
#ifdef __TCPClient
sendData(&TCPSendInfo, num);
#endif
//mySocket->write("Hello! here is tcp client!\n");
//mySocket->flush();
}
}
@ -100,12 +105,43 @@ void threadSendTCP::sendData(_TCPSendInfo* TCPSendInfo, int Num) {
#if defined(__ModebusServer) || defined(__ModebusClient)
std::vector<int> asciiVals = stringToAscii(fileName);
//mySocket->write(fileName.c_str());
int temp = num % 2;
if (temp == 1)
{
m_PLCDevice->write_bit_2_plc(10006, 1);
}
else
{
m_PLCDevice->write_bit_2_plc(10006, 0);
}
//mySocket->write((char*)&temp,sizeof(char));
//mySocket->write("\n");
//mySocket->flush();
//
//遍历发送
int val_[35] = {};
int val_[32] = {};
uint8_t high[17] = {};
uint8_t low[17] = {};
uint16_t val[17] = {};
int h = 0;
int l = 0;
for (int i = 0; i < asciiVals.size(); i++)
{
val_[i] = asciiVals[i];
if (i % 2 == 0)
{
high[h] = asciiVals[i];
h++;
}
else
{
low[l] = asciiVals[i];
l++;
}
}
#endif
#ifdef __ModebusServer
@ -114,17 +150,18 @@ void threadSendTCP::sendData(_TCPSendInfo* TCPSendInfo, int Num) {
#endif
#ifdef __ModebusClient
for(int i = 0;i<sizeof(val_)/sizeof(int);i++)
for (int i = 0; i < sizeof(val) / sizeof(short); i++)
{
m_PLCTCPDevice->mapping->tab_registers[i] = val_[i];
m_PLCTCPDevice->mapping->tab_input_registers[i] = val_[i];
val[i]= (static_cast<uint16_t>(high[i]) << 8) | low[i];//组合高低字节
m_PLCTCPDevice->mapping->tab_registers[i] = val[i];
}
#endif
QDateTime ts_end = QDateTime::currentDateTime();
int time_process = ts_start.msecsTo(ts_end);
qDebug() << "end-now_ts=" << time_process;
}
//字符串转ASCII
std::vector<int> threadSendTCP::stringToAscii(const std::string& str)
{
@ -141,10 +178,12 @@ void threadSendTCP::onNewConnection()
mySocket = tcpServer->nextPendingConnection(); //创建socket
qDebug() << "NewConnectionConnected";
ClientStatus = QAbstractSocket::ConnectedState;
}
void threadSendTCP::onClientConnected()
{
qDebug() << "ClientConnected";
}

@ -56,14 +56,12 @@ public:
void start_work();
void sendData(_TCPSendInfo* TCPSendInfo, int Num);
std::vector<int> stringToAscii(const std::string& str);
#ifdef __TCPServer
private slots:
void onNewConnection();
void onClientConnected();
void onClientDisconnected();
#endif
public:
SyncQueue<_TCPSendInfo>* Local_TCP_Info_queue;
std::atomic_bool isLoop = { 0 };

Loading…
Cancel
Save