学习Rust的第三天:猜谜游戏

基于Steve Klabnik的《The Rust Programming Language》一书。今天我们在rust中建立一个猜谜游戏。

Introduction 介绍

We will build a game that will pick a random number between 1 to 100 and the user has to guess the number on a correct guess the user wins.
我们将构建一个游戏,它将选择1到100之间的随机数字,用户必须猜测正确的猜测用户获胜的数字。

Algorithm 算法

This is what the pseudo code would look like
这就是伪代码的样子

secret_number = (Generate a random number)
loop {
	Write “Please input your guess”
	Read guess
	Write "Your guess : ${guess}"
	
	if(guess > secret_number){
		Write "Too high!"
	}else if(guess < secret_number){
		Write "Too low!"
	}else if(guess==number){
		Write "You win"
		break
	}
}

Step 1 : Set up a new project
步骤1:创建一个新项目

Use the cargo new command to set up a project
使用 cargo new 命令设置项目

$ cargo new guessing_game
$ cd guessing_game

Step 2 : Declaring variables and reading user input
步骤2:声明变量并阅读用户输入

Filename : main.rs Film:main.rs

use std::io;

fn main() {
    println!("Guess the number");
    println!("Please input your guess");

    let mut guess = String::new();

    io::stdin().read_line(&mut guess).expect("Failed to read line");
    println!("Your guess: {}", guess);
}

Let’s break the code down line by line :
让我们逐行分解代码:

  • use std::io; This line brings the std::io (standard input/output) library into scope. The std::io library provides a number of useful features for handling input/output.
    use std::io; 此行将 std::io (标准输入/输出)库带入范围。 std::io 库提供了许多用于处理输入/输出的有用特性。
  • fn main(){...} This is the main function where the program execution begins.
    fn main(){...} 这是程序开始执行的main函数。
  • println!("Guess the number"); println! is a macro that prints the text to the console.
    println!("Guess the number"); println! 是一个宏,它将文本打印到控制台。
  • println!("Please input your guess"); This line prompts the user to enter their guess.
    println!("Please input your guess"); 这一行提示用户输入他们的猜测。
  • let mut guess = String::new(); This line declares a mutable variable guess and initializes it to an empty string. *mut means the variable is mutable*, i.e., its value can be changed. String::new() creates a new, empty string.
    let mut guess = String::new(); 这一行声明了一个可变变量 guess ,并将其转换为空字符串。 *mut 表示变量是可变的 *,即,其值可以改变。 String::new() 创建一个新的空字符串。
  • io::stdin().read_line(&mut guess).expect("Failed to read line"); This line reads the user input from the standard input (keyboard). The entered input is put into the guess string. If this process fails, the program will stop execution and display the message "Failed to read line".
    io::stdin().read_line(&mut guess).expect("Failed to read line"); 这一行从标准输入(键盘)读取用户输入。输入的输入被放入 guess 字符串中。如果此过程失败,程序将停止执行,并显示消息“读取行失败”。
  • println!("Your guess : {guess}"); This line prints out the string "Your guess: ", followed by whatever the user inputted.
    println!("Your guess : {guess}"); 这一行打印出字符串“Your guess:“,后跟用户输入的任何内容。

Step 3 : Generating a random number
步骤3:生成随机数

The number should be different each time for replayability. Rust’s standard library doesn’t include random number functionality, but the Rust team provides a rand crate for this purpose.
为了可重玩性,每次的数字应该不同。Rust的标准库不包含随机数功能,但Rust团队为此提供了一个 rand crate。

A Rust crate is like a neatly packaged box of code that you can easily use and share with others in the Rust programming language.
Rust crate就像一个整齐打包的代码盒,您可以轻松使用Rust编程语言并与其他人共享。

To use the rand crate :
使用 rand crate:

Filename: Cargo.toml Filtrate:Cargo.toml

[package]
name = "guessing_game"
version = "0.1.0"
edition = "2021"

[dependencies]
rand = "0.8.5"  #append this line

Understanding the Cargo.toml file :
了解 Cargo.toml 文件:

  1. [package] [包]
  • name = "guessing_game": The name of the Rust package (or crate) is set to "guessing_game".
    name = "guessing_game" :Rust包(或crate)的名称设置为“guessing_game”。
  • version = "0.1.0": The version of the crate is specified as "0.1.0".
    version = "0.1.0" :机箱的版本指定为“0.1.0”。
  • edition = "2021": Specifies the Rust edition to use (in this case, the 2021 edition).
    edition = "2021" :指定要使用的Rust版本(在本例中为2021版)。

2. [dependencies] 2. [依赖关系]

  • rand = "0.8.5": Adds a dependency on the "rand" crate with version "0.8.5". This means the "guessing_game" crate relies on the functionality provided by the "rand" crate, and version 0.8.5 specifically.
    rand = "0.8.5" :在版本为“0.8.5”的“兰德”crate上添加依赖项。这意味着“guessing_game”crate依赖于“兰德”crate提供的功能,特别是0.8.5版本。

In simpler terms, this configuration file (Cargo.toml) is like a recipe for your Rust project, specifying its name, version, Rust edition, and any external dependencies it needs (in this case, the "rand" crate).
简单地说,这个配置文件( Cargo.toml )就像是Rust项目的配方,指定了它的名称、版本、Rust版本以及它需要的任何外部依赖(在本例中是“兰德”crate)。

After this without changing any code run cargo build , Why do we do that?
在此之后,不改变任何代码运行 cargo build ,为什么我们这样做?

  • Fetch Dependencies: cargo build fetches and updates the project's dependencies specified in Cargo.toml.
    获取依赖项: cargo build 获取并更新 Cargo.toml 中指定的项目依赖项。
  • Dependency Resolution: It resolves and ensures the correct versions of dependencies are installed.
    依赖项解析:它解析并确保安装了正确版本的依赖项。
  • Build Process: Compiles Rust code and dependencies into executable artifacts or libraries.
    构建过程:将Rust代码和依赖项编译为可执行工件或库。
  • Check for Errors: Identifies and reports compilation errors, ensuring code consistency.
    检查错误:检查并报告编译错误,确保代码一致性。
  • Update lock file: Updates the Cargo.lock file to record the exact dependency versions for reproducibility.
    更新锁定文件:更新 Cargo.lock 文件以记录精确的依赖性版本,以实现再现性。

Now let’s talk code 现在我们来谈谈代码

use std::io;
use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);
    println!("Secret number: {}", secret_number);

    println!("Please input your guess");

    let mut guess = String::new();

    io::stdin().read_line(&mut guess).expect("Failed to read line");
    println!("Your guess: {}", guess);
}

Running the program : 运行程序:

$ cargo run
Guess the number!
Secret number : 69
Please input your guess
32
Your guess : 32

Let’s see what we did here :
让我们看看我们在这里做了什么:

  • use rand::Rng; : This line is an import statement that brings the Rng trait into scope, allowing you to use its methods.
    use rand::Rng; :这一行是一个import语句,它将 Rng trait带入作用域,允许你使用它的方法。
  • rand::thread_rng(): This part initializes a random number generator specific to the current thread. The rand::thread_rng() function returns a type that implements the Rng trait.
    rand::thread_rng() :这部分提供了一个特定于当前线程的随机数生成器。 rand::thread_rng() 函数返回一个实现了 Rng trait的类型。
  • .gen_range(1..=100): Using the random number generator (Rng trait), this code calls the gen_range method to generate a random number within a specified range. The range is defined as 1..=100, meaning the generated number should be between 1 and 100 (inclusive).
    .gen_range(1..=100) :使用随机数生成器( Rng trait),这段代码调用 gen_range 方法来生成指定范围内的随机数。范围被定义为 1..=100 ,这意味着生成的数字应该在1和100之间(包括1和100)。

Step 4 : Comparing the guess to the user input
步骤4:将猜测与用户输入进行比较

Now that we have the input, the program compares the user’s guess to the secret number to determine if they guessed correctly. If the guess matches the secret number, the user is successful; otherwise, the program evaluates whether the guess is too high or too low.
现在我们有了输入,程序将用户的猜测与秘密数字进行比较,以确定他们是否猜对了。如果猜测与秘密数字匹配,则用户成功;否则,程序评估猜测是否过高或过低。

Let’s take a look at the code and then break it down :
让我们看看代码,然后分解它:

use std::io;
use std::cmp::Ordering;
use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);
    println!("Secret number: {}", secret_number);

    println!("Please input your guess");

    let mut guess = String::new();

    io::stdin().read_line(&mut guess).expect("Failed to read line");

    let guess: u32 = guess.trim().parse().expect("Please type a number!");
    println!("Your guess: {}", guess);

    match guess.cmp(&secret_number) {
        Ordering::Less => println!("Too small!"),
        Ordering::Greater => println!("Too big!"),
        Ordering::Equal => println!("You win!"),
    }
}

Running the program : 运行程序:

$ cargo run
Guess the number!
Secret number : 48
Please input your guess
98
Your guess : 98
Too big!

Explanation : 说明:

  • let guess: u32 = guess.trim().parse().expect("Please type a number!");: Shadowing the variable guess, it parses the string into an unsigned 32-bit integer. If parsing fails, it prints an error message.
    let guess: u32 = guess.trim().parse().expect("Please type a number!"); :隐藏变量 guess ,将字符串解析为无符号32位整数。如果解析失败,它将打印一条错误消息。
  • match guess.cmp(&secret_number) { ... }: Compares the user's guess to the secret number using a match statement, handling three cases: less than, greater than, or equal to the secret number.
    第0号:使用 match 语句将用户的猜测与秘密数字进行比较,处理三种情况:小于、大于或等于秘密数字。

Shadowing: 阴影:

  • Shadowing is when a new variable is declared with the same name as an existing variable, effectively “shadowing” the previous one.
    隐藏是当一个新变量与现有变量同名时,有效地“隐藏”前一个变量。
  • In this code, let guess: u32 = ... is an example of shadowing. The second guess shadows the first one, changing its type from String to u32. Shadowing is often used to reassign a variable with a new value and type while keeping the same name.
    在这段代码中, let guess: u32 = ... 是阴影的一个例子。第二个 guess 隐藏第一个,将其类型从 String 更改为 u32 。隐藏通常用于为变量重新分配新的值和类型,同时保持名称不变。

Step 5 : Looping the guesses till the user wins
第5步:循环猜测,直到用户获胜

In Step 5, the program implements a loop structure to repeatedly prompt the user for guesses until they correctly guess the secret number as we saw in the algorithm
在步骤5中,程序实现了一个循环结构,反复提示用户进行猜测,直到他们正确地猜出密码,就像我们在算法中看到的那样

As always code then explanation :
一如既往的代码然后解释:

use std::io;
use std::cmp::Ordering;
use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);
    println!("Secret number: {}", secret_number);

    loop {
        println!("Please input your guess");

        let mut guess = String::new();

        io::stdin().read_line(&mut guess).expect("Failed to read line");

        let guess: u32 = guess.trim().parse().expect("Please type a number!");
        println!("Your guess: {}", guess);

        match guess.cmp(&secret_number) {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal => {
                println!("You win!");
                break;
            },
        }
    }
}

Running the program: 运行程序:

$ cargo run
Guess the number!
Secret number : 23
Please input your guess
4
Your guess : 4
Too small!
Please input your guess
76
Your guess : 76
Too big!
Please input your guess
23
Your guess : 4
You win!

Explanation: 说明:

  • loop{...} statement is used to create an infinite loop
    loop{...} 语句用于创建无限循环
  • We are using the break statement to exit out of the program when the variables guess and secret_number are the same.
    当变量 guess 和 secret_number 相同时,我们使用 break 语句退出程序。

Step 6 : Handling invalid input
步骤6:处理无效输入

In Step 6, we want to handle invalid inputs and errors because of them. For example : entering a string in the prompt
在第6步中,我们要处理无效输入和由此产生的错误。例如:在提示符中输入字符串

use std::io;
use std::cmp::Ordering;
use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);
    println!("Secret number: {}", secret_number);

    loop {
        println!("Please input your guess");

        let mut guess = String::new();

        io::stdin().read_line(&mut guess).expect("Failed to read line");

        let guess: u32 = match guess.trim().parse() {
            Ok(num) => num,
            Err(_) => continue,
        };
        println!("Your guess: {}", guess);

        match guess.cmp(&secret_number) {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal => {
                println!("You win!");
                break;
            },
        }
    }
}

Running the program: 运行程序:

$ cargo run
Guess the number!
Secret number : 98
Please input your guess
meow
Please input your guess
43
Your guess : 43
Too small!

Parse User Input: 解析用户输入:

  • Attempts to parse the string in guess into an unsigned 32-bit integer.
    尝试将 guess 中的字符串解析为无符号32位整数。
  • Uses the trim method to remove leading and trailing whitespaces from the user's input.
    使用 trim 方法从用户输入中删除前导和尾随空格。

Match Statement: 匹配声明:

  • The match statement checks the result of the parsing operation.
    match 语句检查解析操作的结果。
  • Ok(num) => num: If parsing is successful, assigns the parsed number to the variable guess.
    Ok(num) => num :如果解析成功,将解析后的数字赋给变量 guess 。

Error Handling: 错误处理:

  • Err(_) => continue: If an error occurs during parsing, the placeholder '_' matches any error, and the code inside the loop continues, prompting the user for input again.
    第0号:如果在解析过程中出现错误,占位符'_'将匹配任何错误,循环中的代码将继续执行,提示用户再次输入。

Summary 总结

In this article, we embarked on our third day of learning Rust by building a guessing game. Here’s a summary of the key steps and concepts covered:Introduction
在本文中,我们通过构建一个猜谜游戏开始了学习Rust的第三天。以下是所涵盖的关键步骤和概念的摘要:简介

  • The goal is to create a game where the user guesses a randomly generated number between 1 and 100.
    我们的目标是创建一个游戏,让用户猜测1到100之间随机生成的数字。

Algorithm 算法

  • A generic algorithm was outlined, providing a high-level overview of the game’s logic.
    概述了一个通用算法,提供了游戏逻辑的高级概述。

Step 1: Set up a new project
步骤1:创建一个新项目

  • Used cargo new to create a new Rust project named "guessing_game."
    使用 cargo new 创建一个名为“guessing_game”的新Rust项目。“

Step 2: Declaring variables and reading user input
步骤2:声明变量并阅读用户输入

  • Introduced basic input/output functionality using std::io.
    使用 std::io 引入基本输入/输出功能。
  • Demonstrated reading user input, initializing variables, and printing messages.
    演示了阅读用户输入、初始化变量和打印消息。

Step 3: Generating a random number
步骤3:生成随机数

  • Added the rand crate as a dependency to generate random numbers.
    添加了 rand crate作为依赖项来生成随机数。
  • Used rand::thread_rng().gen_range(1..=100) to generate a random number between 1 and 100.
    使用 rand::thread_rng().gen_range(1..=100) 生成1到100之间的随机数。

Step 4: Comparing the guess to the user input
步骤4:将猜测与用户输入进行比较

  • Introduced variable shadowing and compared user input to the secret number.
    引入了变量跟踪,并将用户输入与秘密数字进行比较。
  • Used a match statement to handle different comparison outcomes.
    使用 match 语句处理不同的比较结果。

Step 5: Looping the guesses till the user wins
第5步:循环猜测,直到用户获胜

  • Implemented a loop structure to allow the user to make repeated guesses until they correctly guess the secret number.
    实现了一个循环结构,允许用户重复猜测,直到他们正确地猜测秘密数字。

Step 6: Handling invalid input
步骤6:处理无效输入

  • Addressed potential errors by adding error handling to the user input parsing process.
    通过向用户输入分析过程添加错误处理来解决潜在错误。
  • Used the continue statement to skip the current iteration and prompt the user again in case of an error.
    使用 continue 语句跳过当前迭代,并在出现错误时再次提示用户。

Final code : 最终代码:

use std::io;
use std::cmp::Ordering;
use rand::Rng;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1..=100);

    loop {
        println!("Please input your guess");

        let mut guess = String::new();

        io::stdin().read_line(&mut guess).expect("Failed to read line");

        let guess: u32 = match guess.trim().parse() {
            Ok(num) => num,
            Err(_) => continue,
        };
        println!("Your guess: {}", guess);

        match guess.cmp(&secret_number) {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal => {
                println!("You win!");
                break;
            },
        }
    }
}

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

AI音乐,8大变现方式——Suno:音乐版的ChatGPT - 第505篇

悟纤之歌 这是利用AI为自己制作的一首歌&#xff0c;如果你也感兴趣&#xff0c;可以花点时间阅读下本篇文章。 ​ 导读 随着新一代AI音乐创作工具Suno V3、Stable audio2.0、天工SkyMusic的发布&#xff0c;大家玩自创音乐歌曲&#xff0c;玩的不亦乐乎。而有创业头脑的朋友…

C语言 | Leetcode C语言题解之第32题最长有效括号

题目&#xff1a; 题解&#xff1a; int longestValidParentheses(char* s) {int n strlen(s);int left 0, right 0, maxlength 0;for (int i 0; i < n; i) {if (s[i] () {left;} else {right;}if (left right) {maxlength fmax(maxlength, 2 * right);} else if (…

HTML的超链接

前言&#xff1a; 如图&#xff0c;我们在浏览网页时经常可以看到这样的字体&#xff08;点击便跳转到了别的地方了&#xff09;&#xff0c;今日就和各位一起学习一下超链接的相关知识。 相关知识1&#xff1a; 超链接的标签为&#xff1a;a ~使用格式为&#xff1a; <a h…

SS3D翻译

SS3D AbstractIntroductionRelated WorkFully-Supervised 3D Object DetectionWeakly/Semi-Supervised 3D Object DetectionSparsely-Supervised 2D Object Detection MethodOverall FrameworkArchitecture of DetectorMissing-Annotated Instance Mining Module 缺失注释实例挖…

Kubernetes(k8s)集群搭建部署,master节点配置

目录 1.切换为root用户 2.关闭防火墙&#xff0c;关闭swap分区和禁用SElinux 3.安装docker 4.更改daemon.json文件&#xff0c;指定 Docker 守护进程使用的 cgroup 驱动程序 5.重启docker服务 6.配置kubernetes.repo 7.安装Kubelet、Kubeadm、Kubectl 8.设置开机自启 …

流量卡推广怎么申请一级代理

一、号卡推广的重要性 号卡推广对于通信运营商来说具有重要意义。首先&#xff0c;号卡推广是运营商获取新用户、扩大市场份额的重要手段。通过有效的推广策略&#xff0c;运营商可以吸引更多潜在用户&#xff0c;提高品牌知名度和用户黏性。其次&#xff0c;号卡推广有助于运…

java 读取xml文件

1、基本概念 &#xff08;1&#xff09;XML是EXtensible Markup Language 的缩写&#xff0c;翻译过来就是可扩展标记语言。所以很明显&#xff0c;XML和HTML一样都是标记语言&#xff0c;也就是说它们的基本语法都是标签。 &#xff08;2&#xff09;可扩展&#xff1a;XML允…

了解 RISC-V IOMMU

了解 RISC-V IOMMU 个人作为 IOMMU 初学者&#xff0c;从初学者的角度介绍我眼中 RISCV 的 IOMMU 如果有些描述不够专业&#xff0c;还请谅解&#xff0c;也欢迎讨论 部分内容来自 https://zhuanlan.zhihu.com/p/679957276&#xff08;对于 RISCV IOMMU 规范手册的翻译&#xf…

深入理解go语言中的切片

写在文章开头 从一个Java的开发角度来看&#xff0c;切片我们可以理解为Java中的ArrayList即一种动态数组的实现&#xff0c;本文会从源码的角度对切片进行深入剖析&#xff0c;希望对你有帮助。 Hi&#xff0c;我是 sharkChili &#xff0c;是个不断在硬核技术上作死的 java …

前端框架模板

前端框架模板 1、vue-element-admin vue-element-admin是基于element-ui 的一套后台管理系统集成方案。 **功能&#xff1a;**https://panjiachen.github.io/vue-element-admin-site/zh/guide/#功能 **GitHub地址&#xff1a;**GitHub - PanJiaChen/vue-element-admin: :t…

Win 运维 | Windows Server 系统事件日志浅析与日志审计实践

[ 重剑无锋&#xff0c;大巧不工。] 大家好&#xff0c;我是【WeiyiGeek/唯一极客】一个正在向全栈工程师(SecDevOps)前进的技术爱好者 作者微信&#xff1a;WeiyiGeeker 公众号/知识星球&#xff1a;全栈工程师修炼指南 主页博客: 【 https://weiyigeek.top 】- 为者常成&…

【Mamba】医学图像分割的Mamba评估指标参考(更新中...)

医学图像分割的Mamba评估指标参考 VM-UNet&VM-UNetV2LightM-UNetUltraLight-VM-UNetH-vmunetU-MambaLMa-UNetMamba-UNetVM-UNet&VM-UNetV2 DatasetModelmIoU(%)↑DSC(%)↑Acc(%)↑Spe(%)↑Sen(%)↑ISIC17UNet76.9886.9995.6597.4386.82ISIC17UTNetV277.3587.2395.8498.…

Java开发从入门到精通(十):Java常用的API编程接口:String

Java大数据开发和安全开发 (一)Java常用的API1.1 什么是API1.2 什么叫做包1.2.1 如何调用其他包的程序 1.3 JAVA的API&#xff1a;String1.3.1 创建String对象1.3.2 String提供的操作字符串数据的常用方法1.3.3 String练习案例 (一)Java常用的API 1.1 什么是API API(全称 App…

Ubuntu安装VMVare Workstation pro 17.5.1

由于需要装Kali&#xff0c;我电脑是Ubuntu单系统&#xff0c;所以只能使用linux版本的虚拟机&#xff0c;通过这种方式来安装虚拟机和Kali镜像。 参考CSDN博客资料&#xff1a;https://blog.csdn.net/xiaochong0302/article/details/127420124 github代码资料&#xff1a;vm…

2024 CKA 基础操作教程(十二)

题目内容 考点相关内容分析 Pods Pod 是可以在 Kubernetes 中创建和管理的、最小的可部署的计算单元。 Pod 是 Kubernetes 中的原子单元&#xff0c;用于封装应用程序的一个或多个容器、存储资源、唯一的网络 IP&#xff0c;以及有关如何运行容器的选项。Pod 提供了一个共享的…

如何实现超大场景三维模型数据立体裁剪

如何实现超大场景三维模型数据立体裁剪 实现超大场景三维模型数据的立体裁剪可以采用如下方法&#xff1a; 数据预处理&#xff1a;将超大场景三维模型数据进行划分和分割&#xff0c;将其拆分成多个小块或网格。这样可以方便进行后续的裁剪操作。 裁剪算法选择&#xff1a;根据…

场景文本检测识别学习 day04(目标检测的基础概念)

经典的目标检测方法 one-stage 单阶段法&#xff1a;YOLO系列、SSD系列 one-stage方法&#xff1a;仅预测一次&#xff0c;直接在特征图上预测每个物体的类别和边界框输入图像之后&#xff0c;使用CNN网络提取特征图&#xff0c;不加入任何补充&#xff08;锚点、锚框&#x…

OpenHarmony轻量系统开发【2】源码下载和开发环境

2.1源码下载 关于源码下载的&#xff0c;读者可以直接查看官网&#xff1a; https://gitee.com/openharmony/docs/tree/master/zh-cn/release-notes 本文这里做下总结&#xff1a; &#xff08;1&#xff09;注册码云gitee账号。 &#xff08;2&#xff09;注册码云SSH公钥…

如何采集opc服务器数据上传云端

为了进一步提高生产效率&#xff0c;生产制造的不断朝着智能化发展和升级&#xff0c;传统的自动化生产系统已经不能满足需求。传统的SCADA系统一般是用于现场的数据采集与控制&#xff0c;但是本地控制已经无法满足整个工厂系统智能化数字化的需求&#xff0c;智能化数字化是需…

【Altium Designer 20 笔记】PCB线宽与过孔尺寸

电源线&#xff1a;40mil1A&#xff08;一般翻倍给&#xff09;,地线比电源线粗一点即可&#xff1b;信号线&#xff1a;10-15mil 一、线宽 市电的火线和零线&#xff1a;80-100mil12V /24V 20mil~60mil 5V 20-30mil 3V 20-30mil GND 越宽越好20-30mil普通信号线 10mil-15mil…