半导体:Gem/Secs基本协议库的开发(5)

news2024/9/23 9:34:45

此篇是1-4 《半导体》的会和处啦,我们有了协议库,也有了通讯库,这不得快乐的玩一把~

一、先创建一个从站,也就是我们的Equipment端

QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle
CONFIG += no_debug_release         # 不会生成debug 和 release 文件目录


DESTDIR = $${PWD}/../../deploy/bin
OBJECTS_DIR = $${PWD}/../../build/sample/Equipment/tmp/obj
MOC_DIR = $${PWD}/../../build/sample/Equipment/tmp/obj
UI_DIR = $${PWD}/../../build/sample/Equipment/tmp/obj

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked 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 it uses 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.0

SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


win32:CONFIG(release, debug|release){
    win32: LIBS += -L$$PWD/../../deploy/lib/Release -lJC_Commucation
    win32: LIBS += -L$$PWD/../../deploy/lib/Release -lJcHsms
}
else:win32:CONFIG(debug, debug|release){
    win32: LIBS += -L$$PWD/../../deploy/lib/Debug -lJC_Commucation
    win32: LIBS += -L$$PWD/../../deploy/lib/Debug -lJcHsms
}

INCLUDEPATH += $$PWD/../../deploy/include
DEPENDPATH += $$PWD/../../deploy/include
#include <QCoreApplication>
#include <QDebug>
#include <iostream>
#include <QByteArray>
#include <string>
#include <QTimer>
using namespace std;

#include "../../SemiGeneralStandardLibrary/JcGemSecsLibrary/Commucation/commucation.h"
#include "../../SemiGeneralStandardLibrary/JcGemSecsLibrary/Driver/JcHsms/hsmsincludes.h"

/**
 * @brief OnStateChanged 连接状态改变回调事件
 * @param pComm
 * @param nState        0: 连接  1:断开连接
 * @param cSocket
 */
void OnStateChanged(ICommucation* pComm, __int32 nState, void *cSocket)
{
    SOCKET* c = (SOCKET*) cSocket;
    std::string str = nState == 0 ? std::string("  connected to ") : std::string("  disconnected from ");
    std::cout << "[OnStateChanged Event] : " << c <<  str << (void*)pComm << std::endl;
}

/// 无符号字节数组转16进制字符串
std::string bytesToHexString(const char* bytes,const int length)
{
    if (bytes == NULL) return "";
    std::string buff;
    const int len = length;
    for (int j = 0; j < len; j++) {
        int high = bytes[j]/16, low = bytes[j]%16;
        buff += (high<10) ? ('0' + high) : ('a' + high - 10);
        buff += (low<10) ? ('0' + low) : ('a' + low - 10);
        buff += " ";
    }

    return buff;
}


/*!
 * \brief onMessageRecived  接收到消息的回调事件
 * \param pComm
 * \param recvedMsg
 * \param cSocket
 */
void onMessageRecived(ICommucation* pComm,  char* message,int iRecvSize, void * cSocket)
{
     JcHsms ho(0,QString("JC Gem/Secs Test"),QString("1.0.1"));
     HsmsMessage hmsg = ho.interpretMessage(QByteArray(message,iRecvSize));
     HsmsMessage rsp = hmsg.dispatch();
     QByteArray responseByteArray = rsp.toByteArray();

     QString smlString = rsp.SmlString();
     string rHexString = bytesToHexString(message,iRecvSize);

     // qDebug().noquote() << "recv message ==> " << QString::fromStdString(rHexString);
     // qDebug().noquote() << "send message ==> " << responseByteArray.toHex(' ');

     qDebug().noquote() << QString("RECV S%1F%2 SystemBytes=%3").arg(QString::number((int)hmsg.GetHeader().Getstream()),
                                                          QString::number((int)hmsg.GetHeader().Getfunction()),
                                                           QString::number(hmsg.GetHeader().GetSystemBytes()));
     qDebug().noquote() << hmsg.SmlString();

     qDebug().noquote() << QString("SEND S%1F%2 SystemBytes=%3").arg(QString::number((int)rsp.GetHeader().Getstream()),
                                                           QString::number((int)rsp.GetHeader().Getfunction()),
                                                          QString::number( rsp.GetHeader().GetSystemBytes()));

     qDebug().noquote() << rsp.SmlString();

     int slen = responseByteArray.length();
     if(slen){
         int rslen = pComm->SendData(*((SOCKET*) cSocket),responseByteArray.data(),responseByteArray.length());
         if(rslen <= 0) {
             qDebug() << "Send Reply Message failed.";
         }
     }

}


/*!
 * \brief OnAsyncMsgTimeout  消息超时
 * \param pComm
 * \param nTransfer          消息ID
 * \param pClientData
 */
void OnAsyncMsgTimeout(ICommucation* pComm, __int32 nTransfer, void *pClientData)
{

}


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    const char* comm_dll_version = JC_CommDllVersion();
    qDebug() << comm_dll_version;

    /// [1] 建立通讯连接(以单个通讯连接对象为例)
    CommucationParam setting;
    EthernetCommucationParam eParam = {
        45000,10000,5000,10000,5000,  /* timeout */
        0                             /* PASSIVE */,
        5555,                         /*  port  */
        1                             /* DEVID */,
        "Device Host",
        "127.0.0.1"
    };
    SerialCommucationParam sParam = {2,9600,'N',8,1};
    setting.eParam = eParam;
    setting.sParam = sParam;

    /// 创建通讯对象
    ICommucation* o = NULL;
    o = JC_CreatCommObject(TcpServer,setting);

    /// 为通讯连接对象注册事件回调
    JC_SetEventCallBack(o,onMessageRecived,OnStateChanged,OnAsyncMsgTimeout);

    /// 启动监听
    JC_RunListenThread(o);

    /// 测试修改 Selected Equipment Status Data(SSD),线程安全
    float x[] = {12.3025,55.12,56.478,63.54};
    QTimer timer;
    timer.setInterval(300);
    QObject::connect(&timer,&QTimer::timeout,[&x](){
        static int i = 0;
        HsmsDataManager::Instance().UpdateSsdMap(1022,HsmsDataManager::ESD{F4,QVariant(x[++i%4])});
    });
    timer.start();


    QObject::connect(qApp,&QCoreApplication::aboutToQuit,[&o](){
        /// 释放通讯连接对象,结束通讯连接
        JC_ReleaseCommObject(o);
    });

    return a.exec();
}

二、创建一个主站,也就是我们的Host端

QT       += core gui network

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

DESTDIR = $${PWD}/../../deploy/bin
OBJECTS_DIR = $${PWD}/../../build/sample/Host/tmp/obj
MOC_DIR = $${PWD}/../../build/sample/Host/tmp/obj
UI_DIR = $${PWD}/../../build/sample/Host/tmp/obj

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked 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 it uses 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.0

SOURCES += \
    main.cpp \
    mcwidget.cpp

HEADERS += \
    mcwidget.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


win32:CONFIG(release, debug|release){
    win32: LIBS += -L$$PWD/../../deploy/lib/Release -lJC_Commucation
    win32: LIBS += -L$$PWD/../../deploy/lib/Release -lJcHsms
}
else:win32:CONFIG(debug, debug|release){
    win32: LIBS += -L$$PWD/../../deploy/lib/Debug -lJC_Commucation
    win32: LIBS += -L$$PWD/../../deploy/lib/Debug -lJcHsms
}


INCLUDEPATH += $$PWD/../../deploy/include
DEPENDPATH += $$PWD/../../deploy/include

// mcwidget.h
#ifndef MCWIDGET_H
#define MCWIDGET_H

#include <QWidget>
#include <QTcpServer>
#include <QLabel>
#include <QHBoxLayout>
#include <QTimer>
#include <iostream>
#include <QDebug>
#include <string>
#include <QByteArray>
#include <QList>
#include "../../SemiGeneralStandardLibrary/JcGemSecsLibrary/Commucation/commucation.h"
#include  "../../SemiGeneralStandardLibrary/JcGemSecsLibrary/Driver/JcHsms/hsmsincludes.h"

class TransHelper: public QObject
{
    Q_OBJECT
public:
    TransHelper(){
        qRegisterMetaType<HsmsMessage>("qRegisterMetaType");
        //qRegisterMetaType<HsmsMessage>("qRegisterMetaType&");
    }

    void RecivedMsgObject(HsmsMessage msg){
        emit RecivedMsgObjectSig(msg);
    }
signals:
    void RecivedMsgObjectSig(HsmsMessage);
};


class MyLabel : public QWidget
{
    Q_OBJECT
public:
    MyLabel(QString labName,QString labval,QWidget* parent = nullptr)
        :m_labname(labName),m_labVal(labval),QWidget(parent){
        m_nameLab = new QLabel(m_labname);
        m_valLab = new QLabel(m_labVal);
        m_nameLab->setFixedWidth(200);
        m_valLab->setFixedWidth(100);

        QHBoxLayout* ly = new QHBoxLayout;
        ly->addWidget(m_nameLab);
        ly->addWidget(m_valLab);
        ly->setContentsMargins(0,0,0,0);
        this->setContentsMargins(0,0,0,0);
        setLayout(ly);
    }

    void setValue(QString val)
    {
        m_labVal = val;
        m_valLab->setText(m_labVal);
    }
private:
    QString m_labname;
    QString m_labVal;
    QLabel* m_nameLab;
    QLabel* m_valLab;
};

class McWidget : public QWidget
{
    Q_OBJECT

public:
    McWidget(QWidget *parent = nullptr);
    ~McWidget();

    void initUi();
    static TransHelper transhelper;

private:
    ICommucation* o = NULL;
    QTimer linktesttimer;
    QTimer s1f3Rqtimer;

    QList<MyLabel*> llabs;
};
#endif // MCWIDGET_H
// mcwidget.cpp

#include "mcwidget.h"
#include <QDebug>
#include <functional>
#include <QVBoxLayout>

TransHelper McWidget::transhelper;

/**
 * @brief OnStateChanged 连接状态改变回调事件
 * @param pComm
 * @param nState        0: 连接  1:断开连接
 * @param cSocket
 */
void OnStateChanged(ICommucation* pComm, __int32 nState, void *cSocket)
{
    SOCKET* c= (SOCKET*) cSocket;
    std::string str = nState == 0 ? std::string("  connected to ") : std::string("  disconnected from ");
    std::cout << "[OnStateChanged ] : " << c <<  str << (void*)pComm << str << std::endl;
}


/*!
 * \brief onMessageRecived  接收到消息的回调事件
 * \param pComm
 * \param recvedMsg
 * \param cSocket
 */
void onMessageRecived(ICommucation* pComm,char* recvedMsg, int iRecvsize,void * cSocket)
{
    SOCKET* c= (SOCKET*) cSocket;
    // std::cout << "[onMessageRecived ] : " << (void*)pComm << " <-- "  << c  << "  : "
    //           << recvedMsg  <<  "  len=" << iRecvsize << std::endl;

    /// 通过gemsecs的协议进行解析和应答
    JcHsms ho(0,QString("JC Gem/Secs Test"),QString("1.0.1"));
    HsmsMessage hmsg = ho.interpretMessage(QByteArray(recvedMsg,iRecvsize));

    if(hmsg.GetHeader().Getstream() == 0x1
            && hmsg.GetHeader().Getfunction() == 0x4)
    { // S1F4
         McWidget::transhelper.RecivedMsgObject(hmsg);
    }
}


/*!
 * \brief OnAsyncMsgTimeout  消息超时
 * \param pComm
 * \param nTransfer          消息ID
 * \param pClientData
 */
void OnAsyncMsgTimeout(ICommucation* pComm, __int32 nTransfer, void *pClientData)
{
    qDebug() << QStringLiteral("同步发送请求消息超时");
}


McWidget::McWidget(QWidget *parent)
    : QWidget(parent)
{
    initUi();

    CommucationParam setting;
    EthernetCommucationParam eParam = {
        45000,10000,5000,10000,5000, /* timeout */
        0                            /* PASSIVE */,
        5555,                        /*  port  */
        1                            /* DEVID */,
        "Device Host",
        "127.0.0.1"
    };
    SerialCommucationParam sParam = {2,9600,'N',8,1};
    setting.eParam = eParam;
    setting.sParam = sParam;

    o = JC_CreatCommObject(TcpClient,setting);

    /// 注册回调事件
    JC_SetEventCallBack(o,onMessageRecived,OnStateChanged,OnAsyncMsgTimeout);

    /// 启动监听
    JC_RunListenThread(o);

    /// 发送 select.req 请求
    JcHsms ho(0,QString("JC Gem/Secs Test"),QString("1.0.1"));
    HsmsMessage srmsg = HsmsMessageDispatcher::selectReq(ho.unique_sessionID);
    QByteArray srbytes =  srmsg.toByteArray();

    std::string rbuf;
    bool ok = o->SendSyncMessage(srbytes.toStdString(),true,rbuf,10);
    std::cout << "recv reply buf :" << rbuf << std::endl;
    qDebug("send status:%s\n",ok ? "success" : "failed");


    std::function<void()> flinktest = [=](){

        HsmsMessage lktestMgr = HsmsMessageDispatcher::linktestReq();
        QByteArray lktestBytes = lktestMgr.toByteArray();

#if 0   /// 同步发送/接收消息
        std::string rbuf;
        bool ok = o->SendSyncMessage(lktestBytes.toStdString(),true,rbuf,10);
        std::cout << "recv reply buf :" << rbuf << std::endl;
        qDebug("send status:%s\n",ok ? "success" : "failed");
#else
        /// 异步发送接收消息(消息接收回调事件)
        o->SendData(0,lktestBytes.constData(),lktestBytes.length());
#endif

    };

    /// 立即执行一次
    if(ok) flinktest();

    /// 定时触发
    linktesttimer.setInterval(10000);// 10s
    QObject::connect(&linktesttimer,&QTimer::timeout,flinktest);
    linktesttimer.start();

    /// 定时发送S1F3 请求最新SSD
    std::function<void()> fs1f3Rq = [=,&ho]()
    {
        HsmsMessage s1f3ReqtMgr = HsmsMessageDispatcher::S1F3(ho.unique_sessionID);
        QByteArray s1f3ReqBytes = s1f3ReqtMgr.toByteArray();

#if 0   /// 同步发送/接收消息
        std::string rbuf;
        bool ok = o->SendSyncMessage(lktestBytes.toStdString(),true,rbuf,10);
        std::cout << "recv reply buf :" << rbuf << std::endl;
        qDebug("send status:%s\n",ok ? "success" : "failed");
#else
        /// 异步发送接收消息(消息接收回调事件)
        o->SendData(0,s1f3ReqBytes.constData(),s1f3ReqBytes.length());
#endif

    };

    s1f3Rqtimer.setInterval(30);
    QObject::connect(&s1f3Rqtimer,&QTimer::timeout,fs1f3Rq);
    s1f3Rqtimer.start();

    /// S1F4 Recived
    connect(&transhelper,&TransHelper::RecivedMsgObjectSig,[=](HsmsMessage hm){
         Secs2Item item = hm.GetItem();
         QVector<Secs2Item> v = item.GetItems();
         if(v.isEmpty() || v.length() != 23 ) return;

         llabs[0]->setValue(QString::number( v[0].toInt32().first()));

         for(int i =1;i<=3;++i){ // bool
             llabs[i]->setValue(QString::number(v[i].toBoolean().first()));
         }

         for(int i =4;i<=20;++i){ // int32
             llabs[i]->setValue(QString::number(v[i].toInt32().first()));
         }

         for(int i = 21;i <= 22;++i){ // float
             llabs[i]->setValue(QString::number(v[i].toFloat().first()));
         }
    });

}

McWidget::~McWidget()
{

}

void McWidget::initUi()
{
    llabs.clear();
    QVBoxLayout* vly = new QVBoxLayout;
    for(int i = 1001;i <= 1023; ++i){
        MyLabel* labptr = new MyLabel(QString::number(i),QString("0"));
        llabs.append(labptr);
        labptr->setFixedHeight(30);
        labptr->setFixedWidth(300);
        vly->addWidget(labptr);
    }
    setLayout(vly);
}
// main.cpp

#include "mcwidget.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    McWidget w;
    w.show();
    return a.exec();
}

三、演示结果

在这里插入图片描述
perfect!!!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1315902.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

深入理解JVM设计的精髓与独特之处

这是Java代码的执行过程 从软件工程的视角去深入拆解&#xff0c;无疑极具吸引力&#xff1a;首个阶段仅依赖于源高级语言的细微之处&#xff0c;而第二阶段则仅仅专注于目标机器语言的特质。 不可否认&#xff0c;在这两个编译阶段之间的衔接&#xff08;具体指明中间处理步…

C语言----文件操作(二)

在上一篇文章中我们简单介绍了在C语言中文件是什么以及文件的打开和关闭操作&#xff0c;在实际工作中&#xff0c;我们不仅仅是要打开和关闭文件&#xff0c;二是需要对文件进行增删改写。本文将详细介绍如果对文件进行安全读写。 一&#xff0c;以字符形式读写文件&#xff…

一文搞懂OSI参考模型与TCP/IP

OSI参考模型与TCP/IP 1. OSI参考模型1.1 概念1.2 数据传输过程 2. TCP/IP2.1 概念2.2 数据传输过程 3. 对应关系4. 例子4.1 发送数据包4.2 传输数据包4.3 接收数据包 1. OSI参考模型 1.1 概念 OSI模型&#xff08;Open System Interconnection Reference Model&#xff09;&a…

MLX:苹果 专为统一内存架构(UMA) 设计的机器学习框架

“晨兴理荒秽&#xff0c;带月荷锄归” 夜深闻讯&#xff0c;有点兴奋&#xff5e; 苹果为 UMA 设计的深度学习框架真的来了 统一内存架构 得益于 CPU 与 GPU 内存的共享&#xff0c;同时与 MacOS 和 M 芯片 交相辉映&#xff0c;在效率上&#xff0c;实现对其他框架的降维打…

【后端卷前端3】

侦听器 监听的数据是 data()中的动态数据~响应式数据 <template><div><p>{{showHello}}</p><button click"updateHello">修改数据</button></div> </template><script>export default {name: "goodsTe…

cesium 自定义贴图,shadertoy移植教程。

1.前言 cesium中提供了一些高级的api&#xff0c;可以自己写一些shader来制作炫酷的效果。 ShaderToy 是一个可以在线编写、测试和分享图形渲染着色器的网站。它提供了一个图形化的编辑器&#xff0c;可以让用户编写基于 WebGL 的 GLSL 着色器代码&#xff0c;并实时预览渲染结…

人工智能与大数据的紧密联系

随着科技的飞速发展&#xff0c;人工智能&#xff08;Artificial Intelligence&#xff0c;AI&#xff09;和大数据&#xff08;Big Data&#xff09;已成为当今社会的热门话题。人工智能在许多领域的应用越来越广泛&#xff0c;而大数据则提供了支持和驱动AI技术的巨大资源。本…

Android13适配所有文件管理权限

Android13适配所有文件管理权限 前言&#xff1a; 很早之前在Android11上面就适配过所有文件管理权限&#xff0c;这次是海外版升级到Android13&#xff0c;由于选择相册用的是第三方库&#xff0c;组内的同事没有上架Google的经验直接就提交代码&#xff0c;虽然功能没有问题…

14. JDBC

1. JDBC基础 • JDBC的全称是 Java Database Connectivity&#xff0c;即Java数据库连接&#xff0c;它是一种可以执行SQL语句的Java API。 • Java API是接口&#xff0c;其实现类由各数据库厂商提供实现&#xff0c;这些实现类就是“驱动程序”。 2.JDBC编程步骤 导入驱动…

[GXYCTF2019]Ping Ping Ping (文件执行漏洞)

本题考点&#xff1a; 1、命令联合执行 2、命令绕过空格方法 3、变量拼接 1、命令联合执行 ; 前面的执行完执行后面的| 管道符&#xff0c;上一条命令的输出&#xff0c;作为下一条命令的参数&#xff08;显示后面的执行结果&#xff09;|| 当前面的执行出错时&#xff08;为…

day04-报表技术PDF

1 EasyPOI导出word 需求&#xff1a;使用easyPOI方式导出合同word文档 Word模板和Excel模板用法基本一致&#xff0c;支持的标签也是一致的&#xff0c;仅仅支持07版本的word也是只能生成后缀是docx的文档&#xff0c;poi对doc支持不好所以easyPOI中就没有支持doc&#xff0c…

字节与位在物联网传输协议中的使用

1个字节(byte) 8个位(bit) 如下例子&#xff0c;是一个上报数据类型的表格&#xff0c;总有48位(6个字节) 假如报文给的数据类型数据是&#xff1a; 0x06 时&#xff0c;06十六进制转为二进制&#xff0c;结果是00000110 那么在图下就是 (bit1 和 bit2 都为 1) &#xff…

Python中的程序逻辑经典案例详解

我的博客 文章首发于公众号&#xff1a;小肖学数据分析 Python作为一种强大的编程语言&#xff0c;以其简洁明了的语法和强大的标准库&#xff0c;成为了理想的工具来构建这些解决方案。 本文将通过Python解析几个经典的编程问题。 经典案例 水仙花数 问题描述&#xff1a…

Python 爬虫之简单的爬虫(一)

爬取网页上所有链接 文章目录 爬取网页上所有链接前言一、基本内容二、代码编写1.引入库2.测试网页3.请求网页4.解析网页并保存 三、如何定义请求头&#xff1f;总结 前言 最近也学了点爬虫的东西。今天就先给大家写一个简单的爬虫吧。循序渐进&#xff0c;慢慢来哈哈哈哈哈哈…

关于技术架构的思考

技术选型实则是取舍的艺术 这句话是我偶然在一篇技术架构方面的文章上看到的&#xff0c;每当我需要给新项目进行技术选型&#xff0c;决定技术架构时&#xff0c;一直坚信的。 当我们做技术选型时&#xff0c;需要考虑的东西非常多。比如&#xff0c;用关系型数据库还是非关…

Linux 中的网站服务管理

目录 1.安装服务 2.启动服务 3.停止服务 4.重启服务 5.开机自启 6.案例 1.安装服务 网址服务程序 yum insatll httpd -y 查看所有服务 systemctl list-unit-files 2.启动服务 systemctl start httpd 查看服务进程&#xff0c;确认是否启动 ps -ef|grep httpd 3.停止…

关联规则 关联规则概述

关联规则概述 关联规则 (Association Rules) 反映一个事物与其他事物之间的相互依存性和关联性。如果两个或者多个事物之间存在一定的关联关系&#xff0c;那么&#xff0c;其中一个事物就能够通过其他事物预测到。 关联规则可以看作是一种IF-THEN关系。假设商品A被客户购买&…

D33|动态规划!启程!

1.动态规划五部曲&#xff1a; 1&#xff09;确定dp数组&#xff08;dp table&#xff09;以及下标的含义 2&#xff09;确定递推公式 3&#xff09;dp数组如何初始化 4&#xff09;确定遍历顺序 5&#xff09;举例推导dp数组 2.动态规划应该如何debug 找问题的最好方式就是把…

力扣日记12.13-【二叉树篇】从中序与后序遍历序列构造二叉树

力扣日记&#xff1a;【二叉树篇】从中序与后序遍历序列构造二叉树 日期&#xff1a;2023.12.13 参考&#xff1a;代码随想录、力扣 106. 从中序与后序遍历序列构造二叉树 题目描述 难度&#xff1a;中等 给定两个整数数组 inorder 和 postorder &#xff0c;其中 inorder 是二…

SpringData自定义操作

一、JPQL和SQL 查询 package com.kuang.repositories;import com.kuang.pojo.Customer; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingR…