QT串口和数据库通信
创建串口
串口连接客户端并向服务器发送消息
client.pro
#-------------------------------------------------
#
# Project created by QtCreator 2024-07-02T14:11:20
#
#-------------------------------------------------QT += core gui network
QT += core gui serialportgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = client
TEMPLATE = app# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0SOURCES += main.cpp\widget.cppHEADERS += widget.hFORMS += widget.ui
widget.h
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QTcpSocket>
#include <QSerialPort>namespace Ui {
class Widget;
}class Widget : public QWidget
{Q_OBJECTpublic:explicit Widget(QWidget *parent = 0);~Widget();void InitClient();void InitWidget();private slots:void on_connect_bt_clicked();void OnReadData();void OnReadyData1();void on_open_bt_clicked();private:Ui::Widget *ui;QTcpSocket *m_pSocket;QSerialPort *m_pSerial;
};#endif // WIDGET_H
main.cpp
#include "widget.h"
#include <QApplication>int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.InitClient();w.InitWidget();w.show();return a.exec();
}
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QHostAddress>
#include <QSerialPort>
#include <QSerialPortInfo>Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);m_pSocket = NULL;m_pSerial = NULL;
}Widget::~Widget()
{delete ui;
}void Widget::InitClient()
{qDebug() << "Widget::InitClient() enter";if (NULL == m_pSocket){m_pSocket = new QTcpSocket(this);connect(m_pSocket, SIGNAL(readyRead()), this, SLOT(OnReadData()));}qDebug() << "Widget::InitClient() exit";
}void Widget::on_connect_bt_clicked()
{qDebug() << "Widget::on_connect_bt_clicked() enter";QString strIP = ui->ip_edit->text();QString strPort = ui->port_edit->text();qDebug() << strIP << " " << strPort;if (strIP.length() == 0 || strPort.length() == 0){qDebug() << "input error";return;}if (NULL == m_pSocket){qDebug() << "socket error";return;}m_pSocket->connectToHost(QHostAddress("127.0.0.1"), strPort.toShort());if (m_pSocket->waitForConnected(3000)){qDebug() << "connect ok";}else{qDebug() << "connect error";}qDebug() << "Widget::on_connect_bt_clicked() exit";
}void Widget::OnReadData()
{QByteArray arr = m_pSocket->readAll();qDebug() << arr;
}void Widget::InitWidget()
{qDebug() << "Widget::InitWidget() enter";if (NULL == m_pSerial){m_pSerial = new QSerialPort(this);connect(m_pSerial, SIGNAL(readyRead()), this, SLOT(OnReadyData1()));}qDebug() << "Widget::InitWidget() exit";
}void Widget::OnReadyData1() //串口数据就绪槽函数,当串口有数据可读时,该函数会被调用
{qDebug() << "Widget::OnReadyData1() enter";QByteArray strData = m_pSerial->readAll(); // 读取所有数据,处理接收到的数据m_pSocket->write(strData.toStdString().data());qDebug() << "Widget::OnReadyData1() exit";
}void Widget::on_open_bt_clicked()
{qDebug() << "Widget::on_open_bt_clicked() enter";if (NULL == m_pSerial){qDebug() << "serial obj error";return;}QString strBt = ui->open_bt->text();if (strBt == "open"){QString strCom = ui->uart_com->currentText();if (strCom.length() == 0){qDebug() << "com port error";return;}m_pSerial->setPortName(strCom);m_pSerial->setBaudRate(QSerialPort::Baud9600);m_pSerial->setDataBits(QSerialPort::Data8);m_pSerial->setStopBits(QSerialPort::OneStop);m_pSerial->setParity(QSerialPort::NoParity);m_pSerial->setFlowControl(QSerialPort::NoFlowControl);if (!m_pSerial->isOpen()){if (m_pSerial->open(QIODevice::ReadWrite)){qDebug() << "open ok";ui->open_bt->setText("close");ui->uart_com->setEnabled(false);}else{qDebug() << "open error";}}}else{m_pSerial->close();ui->open_bt->setText("open");//ui->send_bt->setEnabled(false);ui->uart_com->setEnabled(true);}
qDebug() << "Widget::on_open_bt_clicked() exit";}
widget.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Widget</class><widget class="QWidget" name="Widget"><property name="geometry"><rect><x>0</x><y>0</y><width>692</width><height>468</height></rect></property><property name="windowTitle"><string>Widget</string></property><widget class="QLabel" name="label"><property name="geometry"><rect><x>30</x><y>140</y><width>72</width><height>15</height></rect></property><property name="text"><string>ip</string></property></widget><widget class="QLineEdit" name="ip_edit"><property name="geometry"><rect><x>110</x><y>140</y><width>181</width><height>21</height></rect></property></widget><widget class="QLabel" name="label_2"><property name="geometry"><rect><x>30</x><y>180</y><width>72</width><height>15</height></rect></property><property name="text"><string>port</string></property></widget><widget class="QLineEdit" name="port_edit"><property name="geometry"><rect><x>110</x><y>180</y><width>181</width><height>21</height></rect></property></widget><widget class="QPushButton" name="connect_bt"><property name="geometry"><rect><x>340</x><y>150</y><width>93</width><height>28</height></rect></property><property name="text"><string>connect</string></property></widget><widget class="QComboBox" name="uart_com"><property name="geometry"><rect><x>30</x><y>50</y><width>87</width><height>22</height></rect></property><item><property name="text"><string>com9</string></property></item></widget><widget class="QPushButton" name="open_bt"><property name="geometry"><rect><x>200</x><y>50</y><width>93</width><height>28</height></rect></property><property name="text"><string>open</string></property></widget></widget><layoutdefault spacing="6" margin="11"/><resources/><connections/>
</ui>
服务器接收数据并存储在数据库内
server.pro
#-------------------------------------------------
#
# Project created by QtCreator 2024-07-02T09:20:48
#
#-------------------------------------------------QT += core gui network
QT += core gui sqlgreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = server
TEMPLATE = app# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0SOURCES += main.cpp\widget.cpp \db.cppHEADERS += widget.h \common.h \db.hFORMS += widget.ui
common.h
#ifndef _COMMON_H_
#define _COMMON_H_#include <QDebug>
#include <QTime>#define _TIME_ qPrintable(QTime::currentTime().toString("hh:mm:ss:zzz"))#define FUNCTION_ENTER qDebug("%s %s %d %s start!",__FILE__,__FUNCTION__,__LINE__,_TIME_);
#define FUNCTION_EXIT qDebug("%s %s %d %s end!",__FILE__,__FUNCTION__,__LINE__,_TIME_);#endif //_COMMON_H_
db.h
#ifndef _DB_H_
#define _DB_H_#include <QSqlDatabase>
#include <QSqlQuery>class DBManager
{
public:enum DBMANAGER_TYPE{DBMANAGER_OK = 0,DBMANAGER_ERR,};public:static DBManager * GetInstance();static void DestroyInstance();int ExecSql(QString strSql);int ExecSql(QString strSql, QSqlQuery &query);private:DBManager();~DBManager();void InitDb();private:static DBManager *m_pManager;QSqlDatabase m_db;
};#endif //_DB_H_
widget.h
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QTcpServer>namespace Ui {
class Widget;
}class Widget : public QWidget
{Q_OBJECTpublic:explicit Widget(QWidget *parent = 0);~Widget();void InitServer();void InitWidget();private slots:void OnNewConnection();void on_listen_bt_clicked();void Insert();void on_pushButton_2_clicked();private:Ui::Widget *ui;QTcpServer *m_pServer;
};#endif // WIDGET_H
db.cpp
#include "common.h"
#include "db.h"
#include <QSqlError>DBManager *DBManager::m_pManager = NULL;int DBManager::ExecSql(QString strSql, QSqlQuery &query)
{FUNCTION_ENTER;if (strSql.length() == 0){return DBMANAGER_ERR;}query = m_db.exec(strSql);if (m_db.lastError().isValid()){qDebug() << m_db.lastError().text();return DBMANAGER_ERR;}FUNCTION_EXIT;return DBMANAGER_OK;
}int DBManager::ExecSql(QString strSql)
{FUNCTION_ENTER;if (strSql.length() == 0){return DBMANAGER_ERR;}m_db.exec(strSql);if (m_db.lastError().isValid()){qDebug() << m_db.lastError().text();return DBMANAGER_ERR;}FUNCTION_EXIT;return DBMANAGER_OK;
}DBManager::DBManager()
{FUNCTION_ENTER;FUNCTION_EXIT;
}DBManager::~DBManager()
{FUNCTION_ENTER;FUNCTION_EXIT;
}DBManager *DBManager::GetInstance()
{FUNCTION_ENTER;if (NULL == m_pManager){m_pManager = new DBManager();m_pManager->InitDb();}FUNCTION_EXIT;return m_pManager;
}void DBManager::DestroyInstance()
{FUNCTION_ENTER;if (NULL != m_pManager){delete m_pManager;m_pManager = NULL;}FUNCTION_EXIT;
}void DBManager::InitDb()
{FUNCTION_ENTER;m_db = QSqlDatabase::addDatabase("QMYSQL");m_db.setHostName("localhost");m_db.setDatabaseName("text");m_db.setUserName("root");m_db.setPassword("123456");if (m_db.open()){qDebug() << "open ok";}FUNCTION_EXIT;
}
main.cpp
#include "widget.h"
#include <QApplication>
#include <QSqlDatabase> //sql驱动基础
#include <QSqlQuery>//sql查询相关
#include <QSqlError>//sql输出错误int main(int argc, char *argv[])
{QApplication a(argc, argv);Widget w;w.InitServer();w.InitWidget();w.show();return a.exec();
}
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QHostAddress>
#include <QTcpSocket>
#include "common.h"
#include "db.h"
#include <QTableWidgetItem>Widget::Widget(QWidget *parent) :QWidget(parent),ui(new Ui::Widget)
{ui->setupUi(this);m_pServer = NULL;
}Widget::~Widget()
{delete ui;
}void Widget::InitServer()
{qDebug() << "Widget::InitServer() enter";if (NULL == m_pServer){m_pServer = new QTcpServer(this);connect(m_pServer, SIGNAL(newConnection()), this, SLOT(OnNewConnection()));}qDebug() << "Widget::InitServer() exit";
}void Widget::InitWidget()
{FUNCTION_ENTER;ui->tableWidget->setColumnCount(2);ui->tableWidget->setRowCount(5);QStringList strList;strList << "id"<<"name" ;ui->tableWidget->setHorizontalHeaderLabels(strList);ui->tableWidget->setAutoScroll(true);ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);ui->tableWidget->setSelectionBehavior( QAbstractItemView::SelectRows);FUNCTION_EXIT;
}void Widget::OnNewConnection()
{qDebug() << "new connection";QTcpSocket *pTmp = m_pServer->nextPendingConnection();if (NULL != pTmp){connect(pTmp, SIGNAL(readyRead()), this, SLOT(Insert()));}
}void Widget::on_listen_bt_clicked()
{qDebug() << "Widget::on_listen_bt_clicked() enter";if (NULL == m_pServer){return;}QString strIP = ui->ip_edit->text();QString strPort = ui->port_edit->text();if (strIP.length() == 0 || strPort.length() == 0){qDebug() << "input error";return;}bool bRet = m_pServer->listen(QHostAddress(strIP), strPort.toShort());if (bRet == true){qDebug() << "server listen ok";}qDebug() << "Widget::on_listen_bt_clicked() enter";
}void Widget::Insert()
{FUNCTION_ENTER;DBManager *pTmp = DBManager::GetInstance();if (NULL == pTmp){qDebug() << "db error";}QTcpSocket *pTmps = (QTcpSocket *)sender();if (NULL == pTmps){qDebug() << "socket error";return;}QByteArray arr = pTmps->readAll();//qDebug() << arr;QString str(arr);QStringList list = str.split(" ");QString strSql = QString("insert into text2 (id,name) values ('%1', '%2')").arg(list.at(0)).arg(list.at(1));int iRet = pTmp->ExecSql(strSql);if (iRet != DBManager::DBMANAGER_OK){qDebug() << "insert data error";return;}FUNCTION_EXIT;
}void Widget::on_pushButton_2_clicked()
{FUNCTION_ENTER;DBManager *pTmp = DBManager::GetInstance();if (NULL == pTmp){qDebug() << "db error";}QString strSql = "select * from text2";QSqlQuery query;int iRet = pTmp->ExecSql(strSql, query);if (iRet != DBManager::DBMANAGER_OK){qDebug() << "select data error";return;}int i = 0;while(query.next()){int j = 0;for (j = 0; j < 2; j++){//qDebug() << query.value(j).toString();QTableWidgetItem *pItem = new QTableWidgetItem(query.value(j).toString());ui->tableWidget->setItem(i, j, pItem);}i++;}FUNCTION_EXIT;
}
widget.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"><class>Widget</class><widget class="QWidget" name="Widget"><property name="geometry"><rect><x>0</x><y>0</y><width>893</width><height>629</height></rect></property><property name="windowTitle"><string>Widget</string></property><widget class="QLabel" name="label"><property name="geometry"><rect><x>80</x><y>60</y><width>72</width><height>15</height></rect></property><property name="text"><string>ip</string></property></widget><widget class="QLineEdit" name="ip_edit"><property name="geometry"><rect><x>140</x><y>60</y><width>221</width><height>21</height></rect></property></widget><widget class="QLineEdit" name="port_edit"><property name="geometry"><rect><x>140</x><y>100</y><width>221</width><height>21</height></rect></property></widget><widget class="QLabel" name="label_2"><property name="geometry"><rect><x>70</x><y>100</y><width>71</width><height>21</height></rect></property><property name="text"><string>port</string></property></widget><widget class="QPushButton" name="listen_bt"><property name="geometry"><rect><x>400</x><y>100</y><width>93</width><height>28</height></rect></property><property name="text"><string>listen</string></property></widget><widget class="QTableWidget" name="tableWidget"><property name="geometry"><rect><x>60</x><y>170</y><width>531</width><height>301</height></rect></property></widget><widget class="QPushButton" name="pushButton_2"><property name="geometry"><rect><x>670</x><y>180</y><width>101</width><height>31</height></rect></property><property name="text"><string>select</string></property></widget></widget><layoutdefault spacing="6" margin="11"/><resources/><connections/>
</ui>
测试
相关文章:
QT串口和数据库通信
创建串口 串口连接客户端并向服务器发送消息 client.pro #------------------------------------------------- # # Project created by QtCreator 2024-07-02T14:11:20 # #-------------------------------------------------QT core gui network QT core gui…...
WebKitWebKit简介及工作流程
简介 引擎能够解析HTML、CSS、JavaScript等网页标准,从而将互联网内容呈现给用户。 WebKit的主要特点包括: 开源性:它是一个开源项目,任何人都可以查看、修改和贡献代码。跨平台:WebKit可以在多个操作系统上运行&am…...
架构分析(CPU:ARM vs RISC-V)
ARM N2 ARM V2 对比 N2和V2,整体架构具有一致性。保证 SiFive P870 P870 Pipeline Veyron V1...
使用 Docker Compose 部署 RabbitMQ 的一些经验与踩坑记录
前言 RabbitMQ 是一个功能强大的开源消息队列系统,它实现了高效的消息通信和异步处理。 本文主要介绍其基于 Docker-Compose 的部署安装和一些使用的经验。 特点 成熟,稳定消息持久化灵活的消息路由高性能,高可用性,可扩展性高支…...
前端八股速通(持续更新中...)
1、深拷贝和浅拷贝的区别 浅拷贝:浅拷贝是拷贝一层,引用类型共享地址。 如果属性是基本类型,拷贝的就是基本类型的值。 如果属性是引用类型,拷贝的就是内存地址。 意思是,当进行浅拷贝时,对于对象的每一…...
【语音识别和生成】语音识别和语音合成技术
语音识别和生成:语音识别和语音合成技术 目录 引言语音识别技术 语音识别的基本原理语音识别系统的组成语音识别的关键技术 语音合成技术 语音合成的基本原理语音合成系统的组成语音合成的关键技术 语音识别和生成的应用 智能助理智能家居语音翻译医疗健康教育和学…...
Redis#架构师面试题
1、Redis锁存在哪些问题及如何解决? 1、死锁问题 加过期时间设定 2、原子性问题 通过“set…nx...ex…”命令,将加锁、过期命令编排到一起,它们是原子操作了,可以避免死锁。 3、释放其他线程的锁问题 当过期时间设置小于线程…...
关于#define的使用方法总结
文章目录 #define 预处理指令一、#define宏定义二、查看预处理文件三、#define 的使用方法四、C语言宏中“#”和“##”的用法五、常见的宏定义总结六、常考题目 #define 预处理指令 #define 是 C 和 C 编程语言中的预处理指令,用于定义宏(macro…...
Unity顶点动画(Vertex Animation):创造动态视觉效果
在Unity中,顶点动画(Vertex Animation)是一种强大的技术,它允许开发者直接在顶点级别上操作和变形网格,从而实现各种动态视觉效果。顶点动画不依赖于骨骼绑定,因此非常适合模拟布料、流体、面部表情等复杂的动画效果。本文将探讨顶…...
WSL for Windows
1、安装 超详细Windows10/Windows11 子系统(WSL2)安装Ubuntu20.04(带桌面环境)_wsl安装ubuntu20.04-CSDN博客https://blog.csdn.net/weixin_44301630/article/details/122390018 注意,安装之后首次启动 Ubuntu 时&…...
Matlab freqz 代码简单实现
相关代码打开matlab源码也可以看到,这里做了简单实现,与源码并不完全一样。 实现代码 [h2 w2] freqzfir(data); [h1 w1] freqz(data); h2h2; h12 [h1, h2];[h4 w4] freqziir(b,a, 2001,true); [h3 w3] freqz(b,a, w4, whole); h4 h4; h34 h…...
待办app哪款好?高效待办软件推荐
在快节奏的现代生活中,一款高效的待办事项管理软件对于提升工作效率和个人时间管理至关重要。面对市场上众多的待办app,哪款才是你的最佳选择呢?经过深入体验和对比,我发现敬业签这款高效待办软件是个不错的选择。 敬业签的快速记…...
【OSCP系列】OSCP靶机-BTRsys-2.1(原创)
OSCP系列靶机—BTRsys-2.1 原文转载已经过授权 原文链接:Lusen的小窝 - 学无止尽,不进则退 (lusensec.github.io) 一、主机发现 二、端口扫描 1、快速扫描 2、全端口扫描 3、服务系统探测 4、漏洞探测 80端口扫到了一些目录,有wordpress框…...
攻坚克难岁月长,自主腾飞世界强——回顾近代中国数据库的发展与飞跃
前言 最近看了《中国数据库前世今生》纪录片,感触颇深,也是一直在思考到底该用何种方式起笔来回顾这段筚路蓝缕却又充满民族自豪感的历程。大概构思了一周左右吧,我想,或许还是应该从那个计算机技术在国内刚刚萌芽的年代开始讲起…...
WEB前端12-axios基础
Vue2-axios基础 1.axios基本概念 在现代的前端开发中,处理网络请求是至关重要的一部分。Axios 是一个流行的基于 Promise 的 HTTP 客户端,它可以在浏览器和 Node.js 环境中使用。它的设计简单易用,支持并行请求、拦截器、CSRF 防护等特性&a…...
Ubuntu 防火墙设置
目录 1. 安装防火墙 2. 开启和关闭防火墙 3. 开放端口和服务规则 4. 关闭端口和删除服务规则 5. 查看防火墙状态 1. 安装防火墙 如果已经安装就忽略 # 安装ufw(Uncomplicated Firewall),这是Ubuntu上管理防火墙的一个简单工具 sudo ap…...
JL 跳转指令的理解
一般情况下,JU 和 JC 是最常见的跳转指令;但有时会用到JL 指令,JL 说起来更像是一组指令,类似C,C# 语言中的 switch case 语句,但是有个明显的不同,前者的判断条件可以是任意合理数字,后者范围…...
vue大屏展示组件库datav
主要用于构建大屏数据展示页面,具有多种类型组件可供使用。详情参考 datav官网 一、安装 npm 安装 npm install jiaminghi/data-viewyarn安装 yarn add jiaminghi/data-view二、使用 在main.js中注册为全局组件 import dataV from jiaminghi/data-view Vue.us…...
Vue.js 与 Ajax(vue-resource)的集成应用
Vue.js 与 Ajax(vue-resource)的集成应用 Vue.js 是一款流行的前端JavaScript框架,以其简洁、灵活和高效的特点而受到开发者的喜爱。在实际开发中,与后端服务的通信是不可或缺的,而Ajax技术是实现这一功能的关键。在V…...
【讲解下AI Native应用中的模型微调】
🌈个人主页: 程序员不想敲代码啊 🏆CSDN优质创作者,CSDN实力新星,CSDN博客专家 👍点赞⭐评论⭐收藏 🤝希望本文对您有所裨益,如有不足之处,欢迎在评论区提出指正,让我们共…...
【SOC 芯片设计 DFT 学习专栏 -- DFT DRC规则检查】
请阅读【嵌入式及芯片开发学必备专栏】 请阅读【芯片设计 DFT 学习系列 】 如有侵权,请联系删除 转自: 芯爵ChipLord 2024年07月10日 12:00 浙江 文章目录 概述DRC的概念Tessent DRC检查的概述时钟相关检查扫描相关检查BIST规则检查预DFT时钟规则检查 …...
深度学习:如何计算感受野
感受野(Receptive Field)是卷积神经网络(CNN)中的一个重要概念,用于描述输入图像中的一个像素在输出特征图中影响的区域大小。在设计和理解卷积神经网络时,计算感受野有助于理解网络如何对输入数据进行处理…...
【状语从句】
框架 概念,特点主将从现连接词时间条件地点结果方式让步原因目的比较省略倒装 解读 1【概念,特点】 一个完整的句子,去修饰另一个完整句子中的动词,称为状语从句;特点:从句完整,只用考虑连接词是…...
阿里云服务器安装Anaconda后无法检测到
前言 问题如标题所言,就是conda -V验证错误,不过后来发现其实就是虽然安装时,同意了写入环境变量,但是其实还没有写入,需要手动写入。下面也会重复一遍安装流程。 安装 到[Anaconda下载处](Download Now | Anaconda)查…...
在没有源程序的情况时,如何通过控制鼠标按钮控制电脑exe程序?
有时候想控制第三方软件,但是没有源程序,可以控制鼠标键盘自动操作软件达到我们想要的目的 首先建一个功能类包含窗口控制,鼠标控制和输入控制等 csharp using System; using System.Collections.Generic; using System.Linq; using System.…...
如何排查GD32 MCU复位是由哪个复位源导致的?
上期为大家讲解了GD32 MCU复位包括电源复位和系统复位,其中系统复位还包括独立看门狗复位、内核软复位、窗口看门狗复位等,在一个GD32系统中,如果莫名其妙产生了MCU复位,如何排查具体是由哪个复位源导致的呢? GD32 MC…...
【C算法】编程初学者入门训练140道(1~20)
牛客编程初学者入门训练150题 BC1 实践出真知BC2 我是大VBC3 有容乃大BC6 小飞机BC7 缩短二进制BC8 十六进制转十进制BC9 printf的返回值BC10 成绩输入输出BC11 学生基本信息输入输出BC12 字符圣诞数BC13 ASCII 码BC14 出生日期输入输出BC15 按照格式输入并交换输出BC16 字符转…...
消息队列-rabbitmq(生产者.消费者. 消息.可靠性)
生产者者的可靠性 为了保证我们生产者在发送消息的时候消息不丢失,我们需要保证发送者的可靠性 1.生产者重试 假如发送消息的时候消息丢失 ,我们可以使用发送者 重试机制,尝试重新发送消息 实现该机制非常简单,只需要在yml文…...
《InheriBT行为树》For Unity
InheriBT: Unity Editor中的行为树编辑框架 行为树(Behavior Tree)是一种广泛应用于人工智能(AI)领域的决策模型,特别是在游戏开发中。行为树通过分层结构和节点的组合,实现了复杂行为的简洁表达。然而&am…...
黑马头条Day11- 实时计算热点文章、KafkaStream
一、今日内容 1. 定时计算与实时计算 2. 今日内容 KafkaStream 什么是流式计算KafkaStream概述KafkaStream入门案例SpringBoot集成KafkaStream 实时计算 用户行为发送消息KafkaStream聚合处理消息更新文章行为数量替换热点文章数据 二、实时流式计算 1. 概念 一般流式计…...
pnpm 设置国内源
pnpm config set registry https://registry.npmmirror.com/...
链表分割 C语言
链表分割_牛客题霸_牛客网 (nowcoder.com) ( 点击前面链接即可查看题目) /* struct ListNode {int val;struct ListNode *next;ListNode(int x) : val(x), next(NULL) {} };*/ #include <cstddef> class Partition { public:ListNode* partition(ListNode* pHea…...
python编程,设计一个详细的软件 与SADS 相似
软件功能模块: 用户界面模块(UI Module) 项目管理界面模型构建界面分析和设计界面结果展示和报告生成界面 数据库模块(Database Module) 材料数据库结构组件数据库设计标准和规范数据库用户项目数据存储 模型构建模块&…...
META 备受期待的 Llama 3 405B 即将发布
本心、输入输出、结果 文章目录 META 备受期待的 Llama 3 405B 即将发布前言Llama 3 405B或许会彻底改变专用模型的数据质量Llama 3 405B将形成新的模型生态系统:从基础模型到专家组合Llama 3 405B有最高效 API 的竞争Llama 3 405B 基准测试META 备受期待的 Llama 3 405B 即将…...
c# Math.Round()四舍五入取整数
可以使用Math.Round()方法进行四舍五入取整数的操作。 以下是使用Math.Round()方法的实现方法: 将浮点数直接作为参数传递给Math.Round()方法,并指定要保留的小数位数。此方法将返回最接近的整数值。 double number 3.89; int roundedNumber (int)Mat…...
【C++BFS算法】886. 可能的二分法
本文涉及的点 CBFS算法 LeetCod886. 可能的二分法 给定一组 n 人(编号为 1, 2, …, n), 我们想把每个人分进任意大小的两组。每个人都可能不喜欢其他人,那么他们不应该属于同一组。 给定整数 n 和数组 dislikes ,其…...
【MySQL】记录MySQL加载数据(LOAD DATA)
MySQL LOAD DATA 一、背景二、模拟生成用户信息三、加载到mysql表3.1、建表语句3.2 加载数据3.3、查看结果 一、背景 现在有个需求是将用户信息存入student.data文件中,在现在load到数据库中 二、模拟生成用户信息 假设用户信息,包含姓名,…...
6 网络
6 网络 1、概念2 IP地址3、套接字4、TCP协议4.1 TCP协议的基本特征4.2 建立连接4.4 终止连接4.5 编程模型 5、UDP协议5.1 UDP协议的基本特性5.2 常用函数5.3 UDP通信模型 6、域名解析 1、概念 计算机网络是实现资源共享和信息传递的计算机系统 ISO/OSI网络协议模型 TCP/IP协…...
SQL中CASE WHEN的用法
CASE WHEN的用法 1. CASE WHEN数据转换 说明:使用CASE WHEN我们可以将范围的数据转换成特定的值来表达; 假如:有一个员工表Employee(employee_id,department_id.salary,name,age); 需求:需要根据薪资情况来评定等级:…...
CTF-Web习题:[GXYCTF2019]Ping Ping Ping
题目链接:[GXYCTF2019]Ping Ping Ping 解题思路 访问靶机,得到如下页面,类似于URL参数 尝试用HackBar构造url传输过去看看 发现返回了ping命令的执行结果,可以猜测php脚本命令是ping -c 4 $ip,暂时不知道执行的函数…...
python+vue3+onlyoffice在线文档系统实战20240725笔记,首页开发
解决遗留问题 内容区域的高度没有生效,会随着菜单的高度自动变化。 解决方案:给侧边加上一个最小高度。 首页设计 另一种设计: 进来以后,是所有的文件夹和最近的文件。 有一张表格,类似于Windows目录详情&…...
映美精彩色相机IFrameQueueBuffer转halcon的HObject
1.之前写了黑白IFrameQueueBuffer转halcon的HObject,下载这边文件写,彩色IFrameQueueBuffer转halcon的HObject 2.相机的部署跟黑白的一样,不同的是取图的格式改变 if (CamerTakeImageOne._camer_take_image_static._camer_is_exit){textbox_m…...
写代码对人的影响
1 代码是需要跑起来的,不能你写了一段代码运行不了 2 代码过程中有大量的bug,经常异常报错,你需要花费时间去解决 对人的影响就是解决问题的态度得到强化,解决问题要比坚持正确困难,坚持正确只是需要自然而然的努力&…...
Hive-基础介绍
简介 Apache Hive是一款数据仓库系统 功能 可以将存储在Hadoop(HDFS)中的数据映射为一张数据库表。核心是将HQL语句转化为MapRece程序,然后提交到Hadoop执行。 组件 用户接口:CLI(shell命令行)、WebGUI、Thrift Server元数据存储(Metastore)&#x…...
网站如何从0-1搭建部署蓝图介绍
第一步:网站规划 确定网站目的:明确网站的目标和预期的受众。内容规划:决定网站将包含哪些内容和功能。技术需求分析:确定所需的技术栈,例如前端和后端技术。 第二步:设计 草图和布局:绘制网…...
面向对象(封装)练习题 巩固一下啦!
# 设计一个类,用来描述手机 class Phone:# 提供私有成员变量:__is_5g_enable__is_5g_enable False # 5g状态# 提供私有成员方法:__check_5gdef __check_5g(self):if self.__is_5g_enable:print("5g开启")else:print("5g关闭…...
一些问题 7/28
get post可以public吗 在Java Servlet中,doGet()和doPost()方法的访问修饰符通常是public,因为这些方法需要被Servlet容器(如Tomcat)调用。 如果将这些方法声明为private或protected,Servlet容器将无法访问它们&…...
昇思MindSpore 应用学习-基于MobileNetv2的垃圾分类
基于MobileNetv2的垃圾分类 本文档主要介绍垃圾分类代码开发的方法。通过读取本地图像数据作为输入,对图像中的垃圾物体进行检测,并将检测结果图片保存到文件中。 1、实验目的 了解熟悉垃圾分类应用代码的编写(Python语言)&…...
matlab 常用数据类型的转换
目录 一、数据类型1、整型2、浮点型3、逻辑型4、元胞数组5、结构体 二、数据类型转换三、图像数据类型转换四、参考链接 一、数据类型 1、整型 int和unit都是整型,只是前一个有符号,后一个没有符号,比如在16位系统中,int范围是-3…...
Cocos Creator2D游戏开发(6)-飞机大战(4)-敌机产生
敌机产生&玩家发射子弹 敌机产生: 创建一个空节点 创建一个敌机预制体 把敌机图片拖入预制体内 使用代码生成敌机 让敌机动起来 创建一个预制体enemy_prefab双击预制体enemy_prefab,然后拖入一个敌机图片,设置好方向和尺寸,一定要记得保存然后关闭(场景编辑器里面的保存)…...