JAVA实现GB/T 32960.3—2016电动汽车远程服务与管理系统技术规范 第3部分:通信协议及数据格式

news2024/9/20 0:59:53


完整的TCP服务端解析代码

1.maven依赖  不要的依赖自行删除,懒的删了 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.13.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.site</groupId>
    <artifactId>TcpServer</artifactId>
    <version>2.0</version>
    <name>TcpServer</name>
    <description>Tcp系统服务端</description>
    <properties>
        <java.version>1.8</java.version>
        <protobuf.version>3.3.0</protobuf.version>
        <hutool.version>5.7.16</hutool.version>
        <fastjson.version>1.2.78</fastjson.version>
        <plumelog.version>3.3</plumelog.version>
        <druid.version>1.2.8</druid.version>
        <redisson.version>3.7.3</redisson.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>${hutool.version}</version>
        </dependency>


        <!-- 阿里JSON解析器 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>


        <!-- redis 缓存操作 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>


        <!-- pool 对象池 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <!-- rabbitmq -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>

        <dependency>
            <groupId>com.plumelog</groupId>
            <artifactId>plumelog-logback</artifactId>
            <version>${plumelog.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>${protobuf.version}</version>
        </dependency>

        <!-- 阿里数据库连接池 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>${druid.version}</version>
        </dependency>

        <!-- Mysql驱动包 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.32</version>
        </dependency>


        <!-- 引入 websocket 依赖类 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
        </dependency>

        <!--常用工具类 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- SpringBoot 拦截器 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <!-- redisson -->
        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson</artifactId>
            <version>${redisson.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>javax.activation-api</artifactId>
            <version>1.2.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <!--			<version>2.12.6</version>-->
        </dependency>

        <dependency>
            <groupId>com.mybatis-flex</groupId>
            <artifactId>mybatis-flex-spring-boot-starter</artifactId>
            <version>1.9.3</version>
        </dependency>
        <dependency>
            <groupId>com.mybatis-flex</groupId>
            <artifactId>mybatis-flex-processor</artifactId>
            <version>1.9.3</version>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>target/classes</outputDirectory>
                            <useDefaultDelimiters>false</useDefaultDelimiters>
                            <delimiters>
                                <delimiter>${*}</delimiter>
                            </delimiters>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>${project.artifactId}</finalName>
    </build>

    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileActive>dev</profileActive>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>pro</id>
            <properties>
                <profileActive>pro</profileActive>
            </properties>
        </profile>
    </profiles>
</project>

2.cmd2实时数据接受

package com.site.tcp.command;

import com.site.tcp.server.TcpReceiveStructure;
import com.site.tcp.utils.*;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 程涛
 * @Title: CMD2
 * @Description: 实时信息上报
 * @date 2021年2月23日
 */
@Slf4j
public class CMD2 {

    public static void cmd2(TcpReceiveStructure cmdReceiveStructure) {
//		车辆VIN(车架号)
        String VIN = cmdReceiveStructure.VIN;
        byte[] date = cmdReceiveStructure.date;
        byte[] timeByte = new byte[6];
        System.arraycopy(date, 0, timeByte, 0, 6);
//		数据采集时间
        String time = JacTools.hexToTime(timeByte);
        int index = 6;
        while (index < date.length) {
            int type = JacTools.subBytesToInt(date, index, 1);
//			0x01	整车数据	详见7.2.3.1
//			0x02	驱动电机数据	详见7.2.3.2,且停车充电过程无需传输该数据
//			0x03	燃料电池数据	详见7.2.3.3
//			0x04	发动机数据	详见7.2.3.4,停车充电过程无需传输该数据
//			0x05	车辆位置数据	详见7.2.3.5
//			0x06	极值数据	详见7.2.3.6
//			0x07	报警数据	详见7.2.3.7
//			0x08~0x09	终端数据预留
//			0x0A~0x2F	平台交换协议自定义数据
            switch (type) {
                case 1:
                    byte[] carinfoByte = new byte[20];
                    System.arraycopy(date, index + 1, carinfoByte, 0, 20);
//				解析整车数据
                    AnalyzeVehicleData.getCarInfo(carinfoByte, VIN, time, 2);
                    index = index + 21;
                    break;
                case 2:
//                  驱动电机个数
                    index = DriveMotorUtils.getDriveMotor(date, VIN, time, index);
                    break;
                case 3:
//                  燃料电池数据
                    index = FuelCellUtils.getFuelCell(date, VIN, time, index);
                    break;
                case 4:
//                  发动机数据
                    index = EngineDataUtils.getEngineData(date, VIN, time, index);
                    break;
                case 5:
                    byte[] positioningInfoByte = new byte[9];
                    System.arraycopy(date, index + 1, positioningInfoByte, 0, 9);
//				    解析定位数据
                    AnalyzePositioningInfo.getPositioningInfo(positioningInfoByte, VIN, time);
                    index = index + 10;
                    break;
                case 6:
//                  极值数据
                    byte[] ExtremeInfoByte = new byte[14];
                    System.arraycopy(date, index + 1, ExtremeInfoByte, 0, 14);
                    ExtremeInfoUtils.getExtremeInfo(ExtremeInfoByte, VIN, time);
                    index = index + 15;
                    break;
                case 7:
                    index = AlarmInfoUtils.getAlarmInfo(date, VIN, time, index, 2);
                default:
                    index = date.length;
                    break;
            }
        }
    }
}

3.CMD3延迟数据补发

package com.site.tcp.command;

import com.site.tcp.server.TcpReceiveStructure;
import com.site.tcp.utils.*;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 程涛
 * @Title: CMD2
 * @Description: 实时信息上报
 * @date 2021年2月23日
 */
@Slf4j
public class CMD3 {

    public static void cmd3(TcpReceiveStructure cmdReceiveStructure) {
//		车辆VIN(车架号)
        String VIN = cmdReceiveStructure.VIN;
        byte[] date = cmdReceiveStructure.date;
        byte[] timeByte = new byte[6];
        System.arraycopy(date, 0, timeByte, 0, 6);
//		数据采集时间
        String time = JacTools.hexToTime(timeByte);
        int index = 6;

        while (index < date.length) {
            int type = JacTools.subBytesToInt(date, index, 1);
//			0x01	整车数据	详见7.2.3.1
//			0x02	驱动电机数据	详见7.2.3.2,且停车充电过程无需传输该数据
//			0x03	燃料电池数据	详见7.2.3.3
//			0x04	发动机数据	详见7.2.3.4,停车充电过程无需传输该数据
//			0x05	车辆位置数据	详见7.2.3.5
//			0x06	极值数据	详见7.2.3.6
//			0x07	报警数据	详见7.2.3.7
//			0x08~0x09	终端数据预留	
//			0x0A~0x2F	平台交换协议自定义数据	
            switch (type) {
                case 1:
                    byte[] carinfoByte = new byte[20];
                    System.arraycopy(date, index + 1, carinfoByte, 0, 20);
//				解析整车数据
                    AnalyzeVehicleData.getCarInfo(carinfoByte, VIN, time, 3);
                    index = index + 21;
                    break;
                case 2:
//                  驱动电机数据
                    index = DriveMotorUtils.getDriveMotor(date, VIN, time, index);
                    break;
                case 3:
//                  燃料电池数据
                    index = FuelCellUtils.getFuelCell(date, VIN, time, index);
                    break;
                case 4:
//                  发动机数据
                    index = EngineDataUtils.getEngineData(date, VIN, time, index);
                    break;
                case 5:
                    byte[] positioningInfoByte = new byte[9];
                    System.arraycopy(date, index + 1, positioningInfoByte, 0, 9);
//				    解析定位数据
                    AnalyzePositioningInfo.getPositioningInfo(positioningInfoByte, VIN, time);
                    index = index + 10;
                    break;
                case 6:
//                  极值数据
                    byte[] ExtremeInfoByte = new byte[14];
                    System.arraycopy(date, index + 1, ExtremeInfoByte, 0, 14);
                    ExtremeInfoUtils.getExtremeInfo(ExtremeInfoByte, VIN, time);
                    index = index + 15;
                    break;
                case 7:
                    index = AlarmInfoUtils.getAlarmInfo(date, VIN, time, index, 3);
                default:
                    index = date.length;
                    break;
            }
        }
    }

}

4 handler模块

package com.site.tcp.handler;

import com.site.tcp.server.TcpReceiveStructure;
import com.site.tcp.utils.JacTools;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class RequestDecoder extends ByteToMessageDecoder {

    // 记录上次未读完的字节
    private ByteBuf tempMessage = Unpooled.buffer();// 申请一块内存保存分包数据,根据最后一次0d出现的位置选择保留哪部分数据
    private int CurrentSize = 0; // 本次新传输的字节数
    private int TempMessageSize = 0; // 上次剩余的字节数
    private ByteBuf WorkByteBuf = Unpooled.buffer();// 最终操作的ByteBuf
    private byte[] WorkPackBuf = null;// 最终操作的字节数组

    /**
     * 用来进行解包操作,得到完整的合法数据包
     *
     * @param channelHandlerContext
     * @param byteBuf
     * @param list
     * @throws Exception
     */
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list)
            throws Exception {
        // log.info("=========开始分析数据========");
        WorkByteBuf.clear();
        CurrentSize = byteBuf.readableBytes();// 当前流可读取字节数
        TempMessageSize = tempMessage.readableBytes();// 上次保存的可读字节数
        // 进行合包操作
        if (TempMessageSize == 0) {
            WorkPackBuf = new byte[CurrentSize];// ByteBuf的转换的字节数组
            WorkByteBuf.writeBytes(byteBuf);
            WorkByteBuf.readBytes(WorkPackBuf);
        } else if (TempMessageSize > 0) {
            WorkByteBuf.writeBytes(tempMessage);
            WorkByteBuf.writeBytes(byteBuf);
            WorkPackBuf = new byte[CurrentSize + TempMessageSize];
            WorkByteBuf.readBytes(WorkPackBuf);
        } else {
            tempMessage.clear();
        }
        if (WorkPackBuf != null) {
            if (JacTools.subBytesToInt(WorkPackBuf, 0, 1) == 0x23 & JacTools.subBytesToInt(WorkPackBuf, 1, 1) == 0x23) {
//					车辆VIN码
                String VIN = JacTools.subBytesToString(WorkPackBuf, 4, 17);
//				命令标识
                int cmd = JacTools.subBytesToInt(WorkPackBuf, 2, 1);
//					消息长度
                int length = JacTools.subBytesToInt(WorkPackBuf, 22, 2);
//					数据域
                byte[] data = new byte[length];
                System.arraycopy(WorkPackBuf, 24, data, 0, length);
//					数据校验
                if (checksum(WorkPackBuf, length)) {
                    TcpReceiveStructure cmdReceiveStructure = new TcpReceiveStructure(VIN, cmd, data);
                    list.add(cmdReceiveStructure);
                    log.info("车辆数据上行》" + JacTools.bytesToHexString(WorkPackBuf));
                }
            }
        }
    }

    /**
     * 安全校验
     *
     * @param WorkPackBuf
     * @param length
     * @return
     */
    private static Boolean checksum(byte[] WorkPackBuf, int length) {
//		数据和域字节数组
        byte[] checksumByte = new byte[1];
        System.arraycopy(WorkPackBuf, length + 24, checksumByte, 0, 1);
//		数据和域字符
        String checksumStr = JacTools.bytesToHexString(checksumByte);

//		数据域
        byte[] data = new byte[length + 22];
        System.arraycopy(WorkPackBuf, 2, data, 0, length + 22);
        String bcc = JacTools.getBCC(data);
        return checksumStr.toUpperCase().equals(bcc);
    }

}
package com.site.tcp.handler;

import com.site.tcp.utils.JacTools;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import lombok.extern.slf4j.Slf4j;

/**
 * @program: ResponseEncoder
 * @description: 发送数据
 * @author: 程涛
 * @create: 2020-12-10
 **/

@Slf4j
public class ResponseEncoder extends ChannelOutboundHandlerAdapter {
	@Override
	public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
		String str = ((String) msg).toUpperCase();
		byte[] mess = JacTools.hexStringToByte(str);
		ByteBuf encoded = ctx.alloc().buffer(mess.length);
		encoded.writeBytes(mess);
		ctx.write(encoded);
		ctx.flush();
		log.info("车辆数据下行》 " + str);
	}
}
package com.site.tcp.handler;

import java.util.concurrent.TimeUnit;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.IdleStateHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * 空闲检测
 *
 * @author pjmike
 * @create 2018-10-25 16:21
 */
@Slf4j
public class ServerIdleStateHandler extends IdleStateHandler {
	/**
	 * 设置空闲检测时间为 60s
	 */
	private static final int READER_IDLE_TIME = 60;

	public ServerIdleStateHandler() {
		super(READER_IDLE_TIME, 0, 0, TimeUnit.SECONDS);
	}

	@Override
	protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception {
		ctx.close();
		log.error("车辆数据服务空闲检测超时断开连接");

	}
}
package com.site.tcp.handler;

import com.site.tcp.command.CMD2;
import com.site.tcp.command.CMD3;
import com.site.tcp.server.TcpReceiveStructure;
import com.site.tcp.utils.JacTools;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@ChannelHandler.Sharable
@Slf4j
public class TcpHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {

        TcpReceiveStructure cmdReceiveStructure = (TcpReceiveStructure) msg;
        switch (cmdReceiveStructure.cmd) {
//		实时信息上报
            case 2:
                CMD2.cmd2(cmdReceiveStructure);
                break;
//		信息补发
            case 3:
                CMD3.cmd3(cmdReceiveStructure);
                break;
            default:
                break;
        }
        String start = "2323";
        String back = JacTools.intToHex(cmdReceiveStructure.cmd, 1) + "01"
                + JacTools.strToHex(cmdReceiveStructure.VIN, 17) + "010006" + JacTools.getHexTime();
        String bcc = JacTools.getBCC(JacTools.hexToByteArr(back));
        ctx.writeAndFlush(start + back + bcc);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
//		cause.printStackTrace();
        log.error("-----客户端关闭:" + ctx.channel().remoteAddress(), cause);
//		Channel channel = ctx.channel();
//		if (!channel.isActive()) {
//			ctx.close();
//		}
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) {
        log.info("-----客户端断开" + ctx.channel().remoteAddress());
        ctx.close();
    }

    @Override
    public void channelRegistered(ChannelHandlerContext ctx) {
        log.info("-----客户端注册" + ctx.channel().remoteAddress());
    }

}

5.server模块

package com.site.tcp.server;

import java.nio.ByteOrder;

import com.site.tcp.handler.RequestDecoder;
import com.site.tcp.handler.ResponseEncoder;

import com.site.tcp.handler.TcpHandler;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

public class NettyServerHandlerInitializer extends ChannelInitializer<Channel> {

	@Override
	protected void initChannel(Channel ch) throws Exception {
		ch.pipeline()
//		空闲检测
//				.addLast(new ServerIdleStateHandler())
//		分包,大端
				.addFirst("decoder",
						new LengthFieldBasedFrameDecoder(ByteOrder.BIG_ENDIAN, Integer.MAX_VALUE, 22, 2, 1, 0, false))
				.addLast(new RequestDecoder()).addLast(new ResponseEncoder()).addLast(new TcpHandler());
	}
}
package com.site.tcp.server;

import java.net.InetSocketAddress;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @author pjmike
 * @create 2018-10-24 15:13
 */
@Component
public class TcpNettyServer {
	protected final Logger logger = LoggerFactory.getLogger(TcpNettyServer.class);

	/**
	 * boss 线程组用于处理连接工作
	 */
	private EventLoopGroup boss = new NioEventLoopGroup();
	/**
	 * work 线程组用于数据处理
	 */
	private EventLoopGroup work = new NioEventLoopGroup();
	@Value("${netty.tcpPort}")
	private Integer port;

	/**
	 * 启动Netty Server
	 *
	 * @throws InterruptedException
	 */
	@PostConstruct
	public void start() throws InterruptedException {
		ServerBootstrap bootstrap = new ServerBootstrap();
		bootstrap.group(boss, work)
				// 指定Channel
				.channel(NioServerSocketChannel.class)
				// 使用指定的端口设置套接字地址
				.localAddress(new InetSocketAddress(port))

				// 服务端可连接队列数,对应TCP/IP协议listen函数中backlog参数
				.option(ChannelOption.SO_BACKLOG, 1024)

				// 设置TCP长连接,一般如果两个小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文
				.childOption(ChannelOption.SO_KEEPALIVE, true)

				// 将小的数据包包装成更大的帧进行传送,提高网络的负载
				.childOption(ChannelOption.TCP_NODELAY, true)

				.childHandler(new NettyServerHandlerInitializer());
		ChannelFuture future = bootstrap.bind().sync();
		if (future.isSuccess()) {
			logger.info("启动车俩数据服务端");
		}
	}

	@PreDestroy
	public void destory() throws InterruptedException {
		boss.shutdownGracefully().sync();
		work.shutdownGracefully().sync();
		logger.info("关闭Netty");
	}
}

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

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

相关文章

C语言实现数据结构之队列

目录 队列一. 队列的概念及结构二. 队列的实现1. 要实现的功能2 具体的实现2.1 结构体2.2 初始化2.3 入队列2.4 出队列2.5 返回队首元素2.6 返回队尾元素2.7 队列元素个数2.8 队列判空2.9 队列销毁 三. 队列相关OJ题设计循环队列用队列实现栈用栈实现队列 四. 概念选择题五. 参…

WordPress公众号扫码登录/注册

目录 一、扫码过程概述 1.扫码进入公众号 2.输入关键字 3.输入验证码 4.登录验证 5.后续操作 6.基础要求 二、插件安装 三、公众号设置 五、登录页码制作 六、扫码登录测试 WordPress建设的网址,是支持用户注册的,不过不如使用“微信扫码”登录来的简单。不过要想…

IO

目录 一、IO流基本认识 1.1 字节流 1.2 字符流 1.3 高级流 二、IO流基本理解 2.1 IO流的分类 2.1.1 按照流的流向 2.1.2 按照处理数据单位 2.1.3 按照流的角色 2.2 IO流的选择 2.3 IO流的4个抽象基类 2.4 字节流和字符流的区别 2.4.1 使用场景 三、IO模型 3.1 BI…

Leetcode JAVA刷刷站(10)正则表达式匹配

一、题目概述 二、思路方向 在Java中&#xff0c;实现一个支持.和*的正则表达式匹配器&#xff0c;可以通过递归或动态规划&#xff08;DP&#xff09;的方法来完成。这里&#xff0c;我将使用动态规划的方法来解决这个问题&#xff0c;因为它更容易理解和实现。 动态规划的思…

代码随想录算法训练营43期 | Day 13 —— 二叉树part01

代码随想录算法训练营 二叉树理论基础二叉树的种类1. 满二叉树2. 完全二叉数3. 二叉搜索树3. 平衡二叉搜索树 二叉树的存储方式二叉树遍历方式二叉树的定义 二叉树的递归遍历144.前序遍历145.后序遍历94.中序遍历 二叉树迭代遍历前序遍历&#xff08;迭代法&#xff09;后序遍历…

实战项目:贪吃蛇游戏的实现(下)

前言 今天我们将继续贪吃蛇游戏的实现&#xff0c;紧接上期我们已经实现了贪吃蛇游戏的大部分基础知识&#xff0c;我们上期主要是学习了Windows系统的API函数,并实现了大部分的贪吃蛇设计&#xff0c;那这期我们将完成剩余的设计部分&#xff0c;并完成代码的实现。 好&…

UEC++学习(十六)变量添加中文注释、ui设置中文文本

&#xff08;一&#xff09;变量添加中文注释 在C 项目中创建变量&#xff0c;并在蓝图中显示变量的英文名同时附带中文注释&#xff0c;可以使用UPROPERTY 的 ToolTip 元数据属性来实现 UPROPERTY(EditAnywhere, meta (ToolTip "弹夹最大容量"))int32 MagCapacit…

目标检测算法,Yolov7本地化部署标注、训练(二)

安全帽检测、口罩检测、行为检测、目标物体检测&#xff0c;随着深度学习和计算机视觉技术的不断发展&#xff0c;目标检测成为了研究热点之一。YOLOv7作为YOLO系列的新成员&#xff0c;以其高效和准确的性能受到了广泛关注。本文将介绍如何在本地部署并利用YOLOv7完成目标检测…

StormBamboo 入侵 ISP 并滥用不安全的软件更新机制

关键要点 StormBamboo 成功入侵了一家互联网服务提供商 (ISP)&#xff0c;以毒害目标组织的 DNS 响应。不安全的软件更新机制旨在在运行 macOS 和 Windows 的受害者机器上秘密安装恶意软件。StormBamboo 部署的恶意软件包括 MACMA 恶意软件的新变种。对 MACMA 最新版本的分析表…

Python学习入门实验

&#xff08;1&#xff09;掌握python数字类型的使用方法 &#xff08;2&#xff09;掌握将数学表达式转换成python语言表达式的方法及注意 &#xff08;3&#xff09;掌握有关运算符号的特殊要求 &#xff08;4&#xff09;掌握输入、输出函数的使用方法 &#xff08;5&am…

Python与netCDF数据之全面解析空间偏相关分析详解

概要 在气象学、海洋学、环境科学等领域,netCDF(Network Common Data Form)是一种常用的数据格式,用于存储和共享多维科学数据。偏相关分析(Partial Correlation Analysis)是一种统计方法,用于研究多个变量之间的关系,同时控制其他变量的影响。本文将详细介绍如何使用…

VTK-vtkStructuredGrid学习

vtkStructuredGrid是具有规则拓扑和不规则几何的数据集。可以理解为单元格顺序沿着坐标轴排列&#xff0c;但是每个单元格可以不一样。看了很多文字解释&#xff0c;感觉不清楚&#xff0c;直接用图解验证&#xff1a; 1.使用CAD随意绘制个网格草图 2.获取这些点信息&#xff…

Sealos 就是小团队的神器

作者&#xff1a;阳明。Kubernetes 布道师&#xff0c;公众号 K8s 技术圈主理人 最近我们新开发了一个项目 fastclass.cn&#xff0c;这个项目是一个独立开发者的学习网站&#xff0c;我们的目标是帮助你使用 Figma、Python、Golang、React、VUE、Flutter、ChatGPT 等设计构建真…

【linux】linux中如何通过systemctl来创建和管理服务

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全…

【网络】从零认识IPv4

目录 IP地址定义 网络标识和主机标识 子网掩码 IPv4地址的分类 全局地址和私有地址 个人主页&#xff1a;东洛的克莱斯韦克-CSDN博客 IP地址定义 IP是网络中每台设备的唯一标识符&#xff0c;用于识别和定位计算机、服务器、路由器等设备&#xff0c;以便它们能够在网络上…

VictoriaMetrics快速入门

文章目录 Multitenancy集群部署启动vmstorage服务启动vminsert服务启动 vmselect服务 配置使用集群大小调整和可伸缩性grafana展示参考资料 VictoriaMetrics是快速&#xff0c;经济高效且可扩展的时间序列数据库。它可以用作Prometheus的长期远程存储。 VictoriaMetrics集群包含…

鸿蒙开发5.0【同页面内的点击操作响应时延问题】分析思路案例

1. 场景导入 同页面内点击操作时延是指&#xff0c;应用内手指点击从离开屏幕开始&#xff0c;到页面发生变化的时间。常见场景包括点击后界面元素变化&#xff0c;弹出弹窗或者loading动画等场景。 2. 性能指标 2.1 性能衡量起始点介绍 1.点击操作响应时延的性能衡量的起点…

GitLab-CI/CD指南

由于公司没有运维&#xff0c;写go服务时各个环境编译部署还是略显麻烦&#xff0c;由于代码管理使用的是 gitlab&#xff0c;所以决定使用 gitlab 自带的 CI/CD 来做自动编译和部署&#xff0c;这样每次提交代码以后就可以自动部署到服务器上了。 gitlab 本身只有 CI/CD 的接…

金蝶云星辰V1与旺店通·企业版对接集成采购入库单查询(列表+详情)连通创建其他入库单(其他)

金蝶云星辰V1与旺店通企业版对接集成采购入库单查询&#xff08;列表详情&#xff09;连通创建其他入库单(其他) 接入系统&#xff1a;金蝶云星辰V1 金蝶云星辰基于金蝶云苍穹云原生PaaS平台构建&#xff0c;聚焦小型企业在线经营和数字化管理&#xff0c;提供财务云、税务云、…

操作系统中的进程:深入解析与理解

文章目录 一、什么是进程&#xff1f;&#x1f914;二、进程的特性 &#x1f31f;三、进程的组成 &#x1f9e9;四、进程的状态与转换 &#x1f504;&#x1f500;五、进程的调度与管理 &#x1f527;&#x1f500;六、代码示例&#xff08;C&#xff09;创建进程进程等待&…