diff --git a/translated/tech/20220713 How I create music playlists on Linux.md b/published/20220713 How I create music playlists on Linux.md similarity index 75% rename from translated/tech/20220713 How I create music playlists on Linux.md rename to published/20220713 How I create music playlists on Linux.md index 4b43793dea..708acec8c8 100644 --- a/translated/tech/20220713 How I create music playlists on Linux.md +++ b/published/20220713 How I create music playlists on Linux.md @@ -3,32 +3,31 @@ [#]: author: "Rikard Grossman-Nielsen https://opensource.com/users/rikardgn" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14868-1.html" -如何在 Linux 上创建音乐播放列表 +如何编写 C 程序在 Linux 上创建音乐播放列表 ====== -使用我在 Linux 上制作的这个 C 程序在旅途中聆听你喜爱的歌曲。 -![Open source software helps artists create music][1] +![](https://img.linux.net.cn/data/attachment/album/202207/26/223349t4yiqd1yikb9k117.jpg) -图片来源:Opensource.com +> 使用我在 Linux 上制作的这个 C 程序在旅途中聆听你喜爱的歌曲。 -我最近在 Linux 中编写了一个 C 程序,从我广泛的 MP3 库中创建一个较小的随机 MP3 文件选择。该程序会遍历一个包含我的 MP3 库的目录,然后创建一个包含随机的、较小的歌曲选择的目录。然后我将 MP3 文件复制到我的智能手机上,以便随时随地收听。 +我最近在 Linux 中编写了一个 C 程序,从我广泛的 MP3 库中创建一个较小的随机 MP3 文件选集。该程序会遍历一个包含我的 MP3 库的目录,然后创建一个包含随机的、较小的歌曲选集的目录。然后我将这些 MP3 文件复制到我的智能手机上,以便随时随地收听。 瑞典是一个人口稀少的国家,有许多农村地区没有完整的手机覆盖。这就是在智能手机上拥有 MP3 文件的原因之一。另一个原因是我并不总是有钱购买流媒体服务,所以我喜欢拥有自己喜欢的歌曲的副本。 -你可以从它的 [Git 仓库][2]下载我的应用。我专门为 Linux 编写了它,部分原因是在 Linux 上很容易找到经过良好测试的文件 I/O 例程。多年前,我尝试使用专有的 C 库在 Windows 上编写相同的程序,但在尝试文件复制时遇到了困难。 Linux 使用户可以轻松直接地访问文件系统。 +你可以从它的 [Git 仓库][2] 下载我的应用。我专门为 Linux 编写了它,部分原因是在 Linux 上很容易找到经过良好测试的文件 I/O 例程。多年前,我尝试使用专有的 C 库在 Windows 上编写相同的程序,但在尝试文件复制时遇到了困难。Linux 使用户可以轻松直接地访问文件系统。 本着开源的精神,我没费多少力气就找到了 Linux 的文件 I/O 代码来激发我的灵感。我还发现了一些启发了我的分配内存的代码。我编写了随机数生成的代码。 该程序的工作方式如下所述: -1. 请求源目录和目标目录。 -2. 请求 MP3 文件目录下的文件个数。 -3. 搜索你希望复制的收藏的百分比(从 1.0% 到 88.0%)。如果你有 1000 个文件的集合并希望从你的集合中复制 125 个文件而不是 120 个文件,你也可以输入 12.5% 之类的数字。我将上限设置为 88%,因为复制超过 88% 的库将基本生成与你的基础库相似的库。当然,代码是开源的,因此你可以根据自己的喜好自由修改。 -4. 使用指针和 malloc 分配内存。一些操作需要内存,包括代表音乐收藏中文件的字符串列表。还有一个列表来保存随机生成的数字。 +1. 询问源目录和目标目录。 +2. 询问存放 MP3 文件的目录下的文件个数。 +3. 搜索你希望复制的收藏的百分比(从 1.0% 到 88.0%)。如果你有 1000 个文件的集合,并希望从你的集合中复制 125 个文件而不是 120 个文件,你也可以输入 12.5% 之类的数字。我将上限设置为 88%,因为复制超过 88% 的库将基本生成与你的基础库相似的库。当然,代码是开源的,因此你可以根据自己的喜好自由修改。 +4. 使用指针和 `malloc` 分配内存。一些操作需要内存,包括代表音乐收藏中文件的字符串列表。还有一个列表来保存随机生成的数字。 5. 生成所有文件范围内的随机数列表(例如,如果集合有 1000 个文件,则为 1 到 1000)。 6. 复制文件。 @@ -181,13 +180,13 @@ while(1) { } ``` -这将从指定的文件中读取多个字节 (readByteCount) 到字符缓冲区中。该函数的第一个参数是文件名(srcFileDesc)。第二个参数是一个指向字符缓冲区的指针,这之前在程序中声明过。该函数的最后一个参数是缓冲区的大小。 +这将从指定的文件中读取多个字节(`readByteCount`)到字符缓冲区中。该函数的第一个参数是文件名(`srcFileDesc`)。第二个参数是一个指向字符缓冲区的指针,这之前在程序中声明过。该函数的最后一个参数是缓冲区的大小。 程序返回读取的字节数(在本例中为 4 个字节)。如果返回的数字为 0 或更少,则第一个 `if` 子句会跳出循环。 如果读取字节数为 0,则所有写入完成,循环中断以写入下一个文件。如果读取的字节数小于 0,则发生错误并退出程序。 -当读取 4 个字节时,它会写入它们。write 函数接受三个参数。第一个是要写入的文件,第二个是字符缓冲区,第三个是要写入的字节数(4 个字节) .该函数返回写入的字节数。 +当读取 4 个字节时,它会写入它们。`write` 函数接受三个参数。第一个是要写入的文件,第二个是字符缓冲区,第三个是要写入的字节数(4 个字节) .该函数返回写入的字节数。 如果写入了 0 个字节,则发生了写入错误,因此第二个 `if` 子句退出程序。 @@ -206,7 +205,7 @@ via: https://opensource.com/article/22/7/c-linux-mp3 作者:[Rikard Grossman-Nielsen][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20220714 5 ways to learn C programming on Linux.md b/published/20220714 5 ways to learn C programming on Linux.md new file mode 100644 index 0000000000..4b7cc34de2 --- /dev/null +++ b/published/20220714 5 ways to learn C programming on Linux.md @@ -0,0 +1,104 @@ +[#]: subject: "5 ways to learn C programming on Linux" +[#]: via: "https://opensource.com/article/22/7/learn-c-linux" +[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" +[#]: collector: "lkxed" +[#]: translator: "Donkey-Hao" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14869-1.html" + +在 Linux 上学习 C 语言的五种方式 +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/26/232122wc4c5g55363bgj5g.jpg) + +> 请下载我们的电子书获得在 Linux 和 FreeDOS 上 C 语言编程的提示和技巧。 + +有许多关于为什么 C 语言能够经久不衰的说法。或许是因为它语法简单明了。又或许是因为它常被认为是实用的语言,因为它不基于其他高级语言,可以在任何平台上编译运行。C 显然是一种强大的语言,并且我认为它经久不衰与它作为其他技术的基础的方式相关。这里有 5 项我喜爱的基于 C 语言的技术,希望它们能够帮助你更多的了解 C 语言。 + +### 1、GObject 和 GTK + +C 语言不是面向对象编程的语言。它没有 `class` 关键字。 一些人用 C++ 进行面向对象编程,但是还有一些人坚持用 C 和 GObject 库。GObject 库为 C 语言提供了一个 `class` 结构体,GTK 项目以提供可通过 C 访问的工具包而闻名。没有 GTK ,就没有 GIMP (GTK 就是为此开发的)、GNOME 和其他成千上百流行的开源应用。 + +#### 了解更多 + +GObject 和 GTK 是使用 C 开始进行 GUI 编程的绝佳方式。它们“装备精良”,可以让你用 C 语言进行图形应用的编程,因为开发者为你做了许多“繁重工作”。他们定义了类和数据类型,创建了工具包,你所要做的就是将所有东西放在一起。 + +### 2、Ncurses + +如果 GTK 超过了你的需求,你或许认为一个终端用户界面terminal user interface(TUI)更适合你。Ncurses 库可以在终端创建“小部件”,创建一种在终端窗口上绘制图形的应用程序。你可以使用方向键控制界面,选择按钮和元素,就像不用鼠标来使用 GUI 应用一样。 + +#### 了解更多 + +利用 Ncurses 库使用 C 语言写一个 [猜数字][3] 游戏。 + +### 3、Lua 和 Moonscript + +Lua 是一种脚本语言,它可以使用内置的 C API 访问 C 语言库。它十分精巧、快捷以及简单,拥有约 30 个函数和少量内置库。你可以使用 Lua 进行系统自动化、游戏修改和脚本编写、使用 LÖVE 之类的前端进行游戏开发,或者使用 GTK 进行一般应用程序开发(例如 [Howl 文本编辑器][4])。 + +#### 了解更多 + +Lua 十分好的一点是你可以从它开始学习掌握基本的编程理念,然后当你有足够勇气直面基础编程语言时,再探索它的 C 语言 API 。另一方面,如果你只会 Lua ,那也没事儿。Lua 有很多的 [外部库][5] ,使其成为各种开发方式的绝佳选择。 + +### 4、Cython + +Lua 不是唯一带有 C 接口的编程语言。[Cython][6] 是一种编译器和编程语言,旨在使为 Python 编写 C 扩展就像编写 Python 代码一样容易。本质上,你可以编写 Python 并最终得到 C 语言程序。最简单的示例: + +``` +print("hello world") +``` + +创建一个 `setup.py` 脚本: + +``` +from setuptools import setup +from Cython.Build import cythonize + +setup( + ext_modules = cythonize("hello.pyx") +) +``` + +运行该 `setup` 脚本: + +``` +$ python3 ./setup.py +``` + +最后你会在同一个目录中得到一个 `hello.c` 和 `hello.cpython-39-x86_64-linux-gnu.so` 文件。 + +#### 了解更多 + +[Cython][7] 是 Python 的一个超集,支持 C 语言的函数和数据类型。它不可能帮你直接学习 C 语言,但它为希望学习 C 代码并将其集成到 Python 中的 Python 开发人员开辟了新的可能性。 + +### 5、FreeDOS + +了解更多 C 语言的最好方式是编写 C 代码,没有什么比写你可以真正使用的代码更令人激动的了。FreeDOS 项目是 DOS 的开源实现, 而 DOS 是 Windows 的前身。或许你已经用过 FreeDOS 了,或者作为运行 BIOS 更新程序的便捷开源方法,或者在模拟器中玩经典的计算机游戏。你可以用 FreeDOS 做更多事情。它是学习 C 语言的理想平台,其中包含一系列工具,鼓励你编写自己的命令和简单(或不那么简单,如果你愿意)的应用程序。当然你可以在任何系统上写 C 代码,但是 FreeDOS 的便利可能会让你感到耳目一新。天空有极限,但即使在地面上,你也可以用 C 做一些非常有趣的事情。 + +### 下载电子书 + +你可以从我们编写的新 [电子书][8] 中学到更多 C 语言,并在我们的电子书中了解有关 FreeDOS 上 C 语言的更多信息。这些是编程文章的集合,可帮助你学习 C 语言,并演示如何以有用的方式用 C 写一些代码。 + +> **[下载电子书][8]** + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/7/learn-c-linux + +作者:[Alan Smithee][a] +选题:[lkxed][b] +译者:[Donkey](https://github.com/Donkey-Hao) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alansmithee +[b]: https://github.com/lkxed +[1]: https://opensource.com/sites/default/files/lead-images/laptop_screen_desk_work_chat_text.png +[2]: https://opensource.com/downloads/guide-c-programming +[3]: https://opensource.com/article/21/8/guess-number-game-ncurses-linux +[4]: https://opensource.com/article/20/12/howl +[5]: https://opensource.com/article/19/11/getting-started-luarocks +[6]: http://cython.org +[7]: https://opensource.com/article/21/4/cython +[8]: https://opensource.com/downloads/guide-c-programming diff --git a/published/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md b/published/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md new file mode 100644 index 0000000000..aca08fc6d4 --- /dev/null +++ b/published/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md @@ -0,0 +1,314 @@ +[#]: subject: "How to Install Deepin Desktop in Arch Linux [Complete Guide]" +[#]: via: "https://www.debugpoint.com/deepin-arch-linux-install-20/" +[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" +[#]: collector: "lkxed" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-14867-1.html" + +如何在 Arch Linux 中安装深度桌面(DDE) +====== + +![](https://img.linux.net.cn/data/attachment/album/202207/26/170414x01pmevoo8o8b6ob.jpg) + +> 在本指南中,我们将解释在 Arch Linux 中安装漂亮的深度桌面(DDE)所需的步骤。 + +指南的第一部分解释了安装 Arch 基本系统的步骤。第二部分是在 Arch Linux 的基础上安装完整的深度桌面。 + +### 什么是深度桌面(DDE)? + +[深度操作系统][1] 是一个基于 Debian 稳定分支的、功能丰富且漂亮的桌面环境。深度桌面环境(DDE)是深度操作系统自主开发的桌面环境。它由它自己的 dde-kwin 窗口管理器驱动。深度桌面带有漂亮的停靠区和许多预装的深度原生的应用程序。 + +这个令人眼花缭乱的桌面环境 [可在 Arch 仓库中找到][2];这篇文章介绍了如何在 Arch Linux 中安装深度桌面。 + +本指南安装深度桌面环境 20.1。然而,其他版本的步骤也应该是类似的。 + +### 第一部分:安装 Arch Linux + +如果你已经安装了 Arch Linux,你可以跳过这一步,直接进入安装深度桌面部分。 + +要快速安装基本的 Arch Linux,请按照以下步骤进行。你也可以访问 [本指南][3] 了解以双启动或在虚拟机上安装 Arch Linux 的完整教程。 + +#### 下载 Arch Linux + +从下面的链接下载 Arch Linux 的 .iso 文件。这里有磁力链和 BT 链接。一旦你下载好了,就把 ISO 写入 U 盘。然后从该驱动器启动。 + +> **[下载 Arch Linux][4]** + +如果你打算通过 [GNOME Boxes][5]、[virt-manager][6] 将其安装为虚拟机镜像 —— 那么你不需要将其写入 U 盘。 + +#### 启动和配置分区 + +从 Arch Linux ISO 启动后,你必须运行一系列的命令来安装基本系统。 + +首先,运行下面的命令,找出设备的标识符。 + +``` +fdisk -l +``` + +![fdisk -l 之前的分区][7] + +然后用此设备标识符,运行下面的命令,开始对你的磁盘进行分区。请确保根据你的系统而修改下面的 `/dev/sda` 参数。 + +``` +cfdisk /dev/sda +``` + +在下一个提示中选择 `label type = dos`。 + +选择可用空间,并从底部选择 “NEW” 选项。在这个例子中,我将创建三个分区,如下所示: + +``` +/dev/sda1 - 1G - for /boot +/dev/sda2 - 5G - for root +/dev/sda3 - 1G - for swap +``` + +![cfdisk][8] + +在下一个屏幕中,提供启动分区(`/boot`)的大小(在这个例子中,我给出了 1GB)。选择它作为主分区。 + +对 5GB 大小的主根分区(`/`)重复同样的步骤。 + +![改变交换分区的类型][9] + +用同样的步骤创建一个大小为 1G 的交换分区(你可以根据你的需要改变大小)。创建交换分区后,确保在底部选择类型,并将其标记为 “Linux Swap/Solaris” 选项的交换分区。 + +![cfdisk 的最终分区列表][10] + +完成后,用底部的 “Write” 选项将变化写到磁盘上。确保你在写之前做一个备份,因为这是你系统中的一个永久性的改变。 + +在你继续之前,运行下面的命令来检查。在这个例子中,你可以看到,列出了三个分区。 + +``` +fdisk -l +``` + +![fdisk 中的最终分区列表][11] + +依次运行下面的命令,在上面新创建的分区中格式化并创建一个 ext4 文件系统。确保你根据你的需要改变 `/dev/sda1` 和 `/dev/sda2` 参数。 + +``` +mkfs.ext4 /dev/sda1 +mkfs.ext4 /dev/sda2 +mkswap /dev/sda3 +swapon /dev/sda3 +``` + +完成后,挂载系统并创建必要的目录。 + +``` +mount /dev/sda2 /mnt +mkdir /mnt/boot /mnt/var /mnt/home +mount /dev/sda1 /mnt/boot +``` + +同样,确保你根据你的系统改变 `/dev/sda1`、`/dev/sda2` 和 `/dev/sda3` 参数。 + +![准备文件系统][12] + +#### 安装基本系统 + +我希望你已经连接到互联网了。如果没有,请尝试使用 USB 网卡或有线网络连接,Arch 安装程序会自动配置和检测。如果你没有可用的有线连接,请按照本指南使用 Arch Linux 安装程序配置无线 Wi-Fi 网络。 + +依次运行下面的命令,将基本系统安装到挂载的分区中。下载的大小约为 400MB。 + +``` +pacman -Syy +pacstrap /mnt base base-devel linux linux-firmware nano dhcpcd net-tools grub +``` + +![安装基本系统][13] + +一旦完成,生成一个文件系统表,没有这个表你就无法启动系统。 + +``` +genfstab -U /mnt >> /mnt/etc/fstab +``` + +#### 配置基本系统 + +依次按照下面的命令来配置基本系统。这包括设置你的地区和语言,添加一个登录用户,以及设置互联网。 + +``` +arch-chroot /mnt +nano /etc/locale.gen +``` + +去掉开头的 `#`,取消对你选择的语言环境的注释。在本指南中,我选择了 `en_US.UTF-8 UTF-8`。按 `CTRL+O`、回车和 `CTRL+X` 退出 nano。 + +![改变语言环境][14] + +使用以下方法生成语言环境数据。 + +``` +locale-gen +``` + +使用下面的命令设置语言。 + +``` +echo LANG=en_US.UTF-8 > /etc/locale.conf +export LANG=en_US.UTF-8 +``` + +设置本地时区。 + +``` +ln -s /usr/share/zoneinfo/America/New_York /etc/localtime +``` + +同样,你可以根据你的需要来选择它们。你可以通过以下命令列出本地时区。 + +``` +ls /usr/share/zoneinfo +ls /usr/share/zoneinfo/America +``` + +依次使用下面的命令设置硬件时钟、创建主机名并启用互联网的 DHCP。你可以根据你的想法把 `debugpoint-pc` 改为任何主机名。 + +``` +hwclock --systohc --utc +echo debugpoint-pc > /etc/hostname +systemctl enable dhcpcd +``` + +下一步是设置 `root` 用户的密码、创建一个管理员用户,并将该用户添加到 `sudoers` 文件中。 + +按照下面的命令依次进行。确保根据你的需要将用户名`debugpoint` 改为其他名称。 + +``` +passwd rootuseradd -m -g users -G wheel -s /bin/bash debugpointpasswd debugpoint +``` + +![创建用户][15] + +打开 `sudoers` 文件,添加以下几行。 + +``` +nano /etc/sudoers +``` + +添加下面几行。由于你已经创建了 `root` 用户,该条目应该已经有了。 + +``` +root ALL=(ALL) ALL +debugpoint ALL=(ALL) ALL +``` + +![更新 sudoers 文件][16] + +安装 GRUB,建立初始的 Ramdisk 环境,并使用下面的命令卸载系统。 + +``` +grub-install /dev/sda +grub-mkconfig -o /boot/grub/grub.cfg +mkinitcpio -p linux +exit +``` + +![配置 GRUB][17] + +然后重新启动你的系统。 + +``` +umount /mnt/boot +umount /mnt +reboot +``` + +现在你已经成功地安装了 Arch Linux 基本系统。现在是安装完整的深度桌面的时候了。 + +### 第二部分:在 Arch Linux 中安装深度桌面 + +重新启动后,从 GRUB 中选择 Arch Linux。在 Arch Linux 的提示符下,开始依次运行以下命令。这些命令安装 Xorg 服务器、Lightdm 显示管理器和深度桌面组件。 + +对于所有的命令,使用默认的包版本,即在询问时按回车。 + +安装 Xorg 和显示管理器。大约安装大小为 80 MB。 + +``` +sudo pacman -S --need xorg lightdm +``` + +安装额外的组件和应用程序(约 550 MB)。 + +``` +sudo pacman -S --need deepin deepin-extra +``` + +安装完成后,通过修改 Lightdm 配置文件启用深度欢迎页。按照下面的命令。 + +``` +nano /etc/lightdm/lightdm.conf +``` + +并添加下面这一行。保存该文件(`CTRL+O`、`CTRL+X`)。 + +``` +greeter-session=lightdm-deepin-greeter +``` + +![在 Lightdm 登录页中添加深度欢迎欢迎页][18] + +现在是时候把显示管理器和网络管理器作为服务启用了。这样,下次登录时,它们就可以由 systemd 自动运行。 + +``` +systemctl enable lightdm +systemctl enable NetworkManager +``` + +![启用 Lightdm 和网络][19] + +使用 `reboot` 命令重新启动系统。 + +``` +reboot +``` + +如果一切顺利,你应该看到深度桌面的登录提示。使用你刚刚在上面的步骤中创建的凭证登录。你应该会看到最新的深度桌面环境。 + +![Arch Linux 中的深度 20.1 登录屏幕][20] + +![Arch Linux中的深度桌面 20.1][21] + +### 总结 + +我希望这个指南能帮助你在 Arch Linux 中安装深度桌面。虽然它不是我的日常环境,我觉得深度的桌面在本质上有些慢。可能是因为有太多的颜色渲染和动画,而且尽管它是建立在 Qt 上的,但没有为深度桌面进行适当的优化。 + +-------------------------------------------------------------------------------- + +via: https://www.debugpoint.com/deepin-arch-linux-install-20/ + +作者:[Arindam][a] +选题:[lkxed][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.debugpoint.com/author/admin1/ +[b]: https://github.com/lkxed +[1]: https://www.debugpoint.com/2020/09/deepin-20-review/ +[2]: https://archlinux.org/groups/x86_64/deepin/ +[3]: https://www.debugpoint.com/2020/11/install-arch-linux/ +[4]: https://www.archlinux.org/download/ +[5]: https://www.debugpoint.com/2020/05/install-use-gnome-boxes/ +[6]: https://www.debugpoint.com/2020/11/virt-manager/ +[7]: https://www.debugpoint.com/wp-content/uploads/2020/12/fdisk-l-before.jpg +[8]: https://www.debugpoint.com/wp-content/uploads/2020/12/cfdisk-1024x159.jpg +[9]: https://www.debugpoint.com/wp-content/uploads/2020/12/Swap-parition-type-change.jpg +[10]: https://www.debugpoint.com/wp-content/uploads/2020/12/final-partition-list-in-cfdisk-1024x178.jpg +[11]: https://www.debugpoint.com/wp-content/uploads/2020/12/final-partition-list-in-fdisk.jpg +[12]: https://www.debugpoint.com/wp-content/uploads/2020/12/prepare-file-system.jpg +[13]: https://www.debugpoint.com/wp-content/uploads/2020/12/Install-base-system-1024x205.jpg +[14]: https://www.debugpoint.com/wp-content/uploads/2020/12/change-locale.jpg +[15]: https://www.debugpoint.com/wp-content/uploads/2020/12/create-user.jpg +[16]: https://www.debugpoint.com/wp-content/uploads/2020/12/update-sudoers-file.jpg +[17]: https://www.debugpoint.com/wp-content/uploads/2020/12/configure-grub-1024x639.jpg +[18]: https://www.debugpoint.com/wp-content/uploads/2021/01/add-deepin-greeter-in-lightdm-login.jpg +[19]: https://www.debugpoint.com/wp-content/uploads/2020/12/Enable-lightdm-and-network-Install-Xfce-Desktop-in-Arch-Linux.jpg +[20]: https://www.debugpoint.com/wp-content/uploads/2021/01/Deepin-20.1-Login-screen-in-Arch-Linux-1024x771.jpg +[21]: https://www.debugpoint.com/wp-content/uploads/2021/01/Deepin-Desktop-20.1-in-Arch-Linux-1024x770.jpg diff --git a/sources/tech/20220614 Build a Smart Parking System for a Metro Station.md b/sources/tech/20220614 Build a Smart Parking System for a Metro Station.md deleted file mode 100644 index 45b3dbdb8b..0000000000 --- a/sources/tech/20220614 Build a Smart Parking System for a Metro Station.md +++ /dev/null @@ -1,141 +0,0 @@ -[#]: subject: "Build a Smart Parking System for a Metro Station" -[#]: via: "https://www.opensourceforu.com/2022/06/build-a-smart-parking-system-for-a-metro-station/" -[#]: author: "Dr Maheswari R. https://www.opensourceforu.com/author/dr-maheswari-r/" -[#]: collector: "lkxed" -[#]: translator: "Maisie-x " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -Build a Smart Parking System for a Metro Station -====== -This article will help you design a Web based application that automates a smart parking system for cars in a metro station using Node-RED. - -![Smart car parking][1] - -A Web application is software that gets executed on a Web server. Every Web application is accessed by the end user through a Web browser. These Web applications are programmed using a client-server architecture, where the user (client) is provided services through a remotely located server that might be hosted by a third-party. A Web API (application programming interface) is available across the Web and can be accessed by the user using the HTTP protocol, as shown in Figure 1. - -This article will demonstrate how to design a Web based application for an automated smart parking system for cars in a metro station. It is designed using open source Node-RED. This system creates an interactive and stylish user login form using a template node, where HTML and CSS are coded to get car owner details to automate the parking system. We can see the login and submission form flow diagrams in Figures 2 and 3. - -The nodes used are as follows: - -**[Metro smart parking node flow design][2]** -Node-RED is triggered using the command ‘node-red’. Through the URL *http://127.0.0.1:1880/*, the node-RED UI flow browser is enabled. We have considered that the Node-RED setup is done and working. - -![table function][3] - -![Figure 1: Web API][4] - -Follow the steps given below to create the login and submission forms. - -![Figure 2: Login form flow diagram][5] - -![Figure 3: Submission form flow diagram][6] - -*Login form* -1) From the node palette, drag and drop http in node, which creates an HTTP end point for creating Web services. -2) Connect http in node to function node. The latter helps to code JavaScript functions to run against the messages being received by the node. - -![Figure 4: Login form for smart parking for cars][7] - -3) Connect function node to template node, where the latter creates a Web API based on the provided template. -4) Connect template node to http response node; the latter sends responses back to requests received from an http input node. - -![Figure 5: Submission form for smart parking for cars][8] - -**Submission form** -1) Drag and drop http in node and connect it to json node, which converts and communicates the data as JSON string. -2) Connect http in node to debug node, which gives output in a debug monitor. -3) Place and connect json node to function node and connect the latter to http response node. - -After the creation of a complete flow, click on the Deploy button in the top right corner of the Node-RED window. To view the user interface, go to the link*127.0.0.1:1880/ui/.* -Once you enter and then click Submit, it will take you to the next page where you can read all the news articles. - -**Node-RED workflow** -In a single flow of Node-RED, you can create both the login form and submission form, as shown in Figures 4 and 5. - -Now we will configure the Node properties. - -*Login form:* Edit the http in property by choosing the method ‘Get’ and set the URL to ‘/MetroStation’ and configure the name as ‘Smart Parking’. - -![Figure 6: Http in node property configurations][9] - -| - | -| :- | -| Note: The URL can be any user defined local variable. | - -Now select the function node and edit its properties by coding the ‘msg.url = project’ and configure the name field with ‘Project Submission’. - -![Figure 7: Function node property configurations][10] - -In the Property window of the template node, configure the appropriate HTML code required for the login form and specify the name as ‘Display panel’. The Mustache template format is being used in this flow. Mustache is a simple Web template system that is described as a logicless template engine. It does not have any explicit control flow statements, such as ‘if’ and ‘else’ conditionals or ‘for’ loops. Looping and conditional evaluation can be achieved using section tags processing lists and lambdas. - -![Figure 8: Template node property configurations][11] - -Configure the edit property of http response node with the name ‘Smart Parking’ (Figure 9). - -![Figure 9: Http response node property configurations][12] - -*Submission form:*In the edit property window of http in node, choose the method ‘POST’ and the URL ‘/project’. - -![Figure 10: Http in node property configurations][13] - -In the JSON node edit window, set *Action* as ‘Convert between JSON String & Object’. Refer to Figure 11. - -![Figure 11: JSON node property configurations][14] - -The function node is configured as specified in Figure 12. - -![Figure 12: Function node property configurations][15] - -In http response node, edit the property name as ‘Project Submitted’. - -![Figure 13: Http response node property configurations][16] - -| - | -| :- | -| Note: Also add the comment node with comments as ‘Login Form’ and ‘Submission Form’ | - -![Figure 14: Debug node property configurations][17] - -**Dashboard UI Web page** -When the user clicks on Submit, the data given will be displayed in the UI and the debug node. If Reset is clicked, the details will be cleared, allowing the user to enter new details (Figure 15). - -![Figure 15: User login UI][18] - -Metro parking rates are provided through a hyperlink, and the tariff output is displayed in the UI. So the smart parking for cars is automated with appropriate hyperlinks to exhibit the parking tariff at the metro station. The final outputs of this automated system are retrieved and displayed in the Node-RED dashboard UI and debug monitor. - -![Figure 16: Metro parking tariff][19] - --------------------------------------------------------------------------------- - -via: https://www.opensourceforu.com/2022/06/build-a-smart-parking-system-for-a-metro-station/ - -作者:[Dr Maheswari R.][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.opensourceforu.com/author/dr-maheswari-r/ -[b]: https://github.com/lkxed -[1]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Smart-car-parking.jpg -[2]: https://www.opensourceforu.com/wp-content/uploads/2022/04/table-function-node-red.jpg -[3]: https://www.opensourceforu.com/wp-content/uploads/2022/04/table-function-node-red.jpg -[4]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-1-Web-Application-Programming-Interface300.jpg -[5]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-2-Login-Form-Flow-Diagram300.jpg -[6]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-3-Submission-Form-Flow-Diagram300.jpg -[7]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-4-Login-Form-of-Metro-Smart-Car-Parking300.jpg -[8]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-5-Submission-Form-of-Metro-Smart-Car-Parking300.jpg -[9]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-6-Http-in-Node-Property-Configurations300.jpg -[10]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-7-Function-Node-Property-Configurations300.jpg -[11]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-8-Template-Node-Property-Configurations300.jpg -[12]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-9-Template-Node-Property-Configurations300.jpg -[13]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-10-Http-in-Node-Property-Configurations300.jpg -[14]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-11-Json-Node-Property-Configurations300.jpg -[15]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-12-Function-Node-Property-Configurations300.jpg -[16]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-13-Http-Response-Node-Property-Configurations300.jpg -[17]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-14-Debug-Node-Property-Configurations300.jpg -[18]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-15-User-Login-UI300.jpg -[19]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-16-Parking-Tariff-Metro300.jpg diff --git a/sources/tech/20220714 5 ways to learn C programming on Linux.md b/sources/tech/20220714 5 ways to learn C programming on Linux.md deleted file mode 100644 index 4d517f42a6..0000000000 --- a/sources/tech/20220714 5 ways to learn C programming on Linux.md +++ /dev/null @@ -1,101 +0,0 @@ -[#]: subject: "5 ways to learn C programming on Linux" -[#]: via: "https://opensource.com/article/22/7/learn-c-linux" -[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" -[#]: collector: "lkxed" -[#]: translator: "Donkey" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -5 ways to learn C programming on Linux -====== -Download our new eBook for tips and tricks for C programming on Linux and FreeDOS. - -![Person using a laptop][1] - -There are many theories about why the C programming language has endured for as long as it has. Maybe it's the austerity of its syntax or the simplicity of its vocabulary. Or maybe it's that C is often seen as a utilitarian language, something that's rugged and ready to be used as a building material for something that needs no platform because it's going to be its own foundation. C is clearly a powerful language, and I think its longevity has a little something to do with the way it serves as a springboard for other popular technologies. Here are five of my favorite technologies that utilize and rely upon C, and how they can each help you learn more about C yourself. - -### 1. GObject and GTK - -C is not an object-oriented programming language. It has no `class` type. Some folks use C++ for object-oriented programming, but others stick with C along with the GObject libraries. The GObject subsystem provides a `class` structure for C, and the GTK project famously provides widgets accessible through C. Without GTK, there would be no GIMP (for which GTK was developed), GNOME, and hundreds of other popular open source applications.) - -#### Learn more - -GObject and GTK are excellent ways to start using C for GUI programming. They're well-equipped to get you programming graphical applications using C because they do so much of the "heavy lifting" for you. The classes and data types are defined, the widgets have been made, and all you have to do is put everything together. - -### 2. Ncurses - -If GTK is more than you need, you might decide a terminal user interface (TUI) is more your speed. The ncurses library creates "widgets" in a terminal, creating a kind of graphical application that gets drawn over your terminal window. You can control the interface with your arrow keys, selecting buttons and elements much the same way you might use a GUI application without a mouse. - -#### Learn more - -Get started by writing a [guessing game in C][3] using the ncurses library as your display. - -### 3. Lua and Moonscript - -Lua is a scripting language with access to C libraries through a built-in C API. It's a tiny, fast, and simple language with about 30 functions and just a handful of built-in libraries. You can get started with Lua for system automation, game modding and scripting, game development with a frontend like LÖVE, or general application development (like the [Howl text editor][4]) using GTK. - -#### Learn more - -The nice thing about Lua is that you can start out with it to learn the basic concepts of programming, and then start exploring its C API when you feel brave enough to interface directly with the foundational language. If, on the other hand, you never grow out of Lua, that's OK too. There's a wealth of [extra libraries][5] for Lua to make it a great choice for all manner of development. - -### 4. Cython - -Lua isn't the only language that interfaces with C. [Cython][6] is a compiler and language designed to make writing C extensions for Python as easy as writing Python code. Essentially, you can write Python and end up with C. The simplest possible example: - -``` -print("hello world") -``` - -Create a `setup.py` script: - -``` -from setuptools import setup -from Cython.Build import cythonize - -setup( - ext_modules = cythonize("hello.pyx") -) -``` - -Run the setup script: - -``` -$ python3 ./setup.py -``` - -And you end up with a `hello.c` and `hello.cpython-39-x86_64-linux-gnu.so` file in the same directory. - -#### Learn more - -The [Cython][7] language is a superset of Python with support for C functions, and datatypes. It isn't likely to directly help you learn C, but it opens up new possibilities for the Python developer looking to learn and integrate C code into Python. - -### 5. FreeDOS - -The best way to learn more about C is to write code in C, and there's nothing more exciting than writing code you can actually use. The FreeDOS project is an open source implementation of DOS, the predecessor to Windows. You may have already used FreeDOS, either as a handy open source method of running a BIOS updater, or maybe in an emulator to play a classic computer game. You can do a lot more with FreeDOS than that, though. It makes an ideal platform to learn C with a collection of tools that encourage you to write your own commands and simple (or not-so-simple, if you prefer) applications. Of course you can write C code on any OS, but there's a simplicity to FreeDOS that you might find refreshing. The sky's the limit, but even at ground level, you can do some amazingly fun things with C. - -### Download the eBook - -You can learn more about C in our **[new eBook][8]**, and more about C on FreeDOS in our eBook. These are collections of programming articles to help you learn C and to demonstrate how you can implement C in useful ways. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/7/learn-c-linux - -作者:[Alan Smithee][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/alansmithee -[b]: https://github.com/lkxed -[1]: https://opensource.com/sites/default/files/lead-images/laptop_screen_desk_work_chat_text.png -[2]: https://opensource.com/downloads/guide-c-programming -[3]: https://opensource.com/article/21/8/guess-number-game-ncurses-linux -[4]: https://opensource.com/article/20/12/howl -[5]: https://opensource.com/article/19/11/getting-started-luarocks -[6]: http://cython.org -[7]: https://opensource.com/article/21/4/cython -[8]: https://opensource.com/downloads/guide-c-programming diff --git a/sources/tech/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md b/sources/tech/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md deleted file mode 100644 index c2aae6dbcf..0000000000 --- a/sources/tech/20220716 How to Install Deepin Desktop in Arch Linux [Complete Guide].md +++ /dev/null @@ -1,297 +0,0 @@ -[#]: subject: "How to Install Deepin Desktop in Arch Linux [Complete Guide]" -[#]: via: "https://www.debugpoint.com/deepin-arch-linux-install-20/" -[#]: author: "Arindam https://www.debugpoint.com/author/admin1/" -[#]: collector: "lkxed" -[#]: translator: " " -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -How to Install Deepin Desktop in Arch Linux [Complete Guide] -====== -In this guide, we explain the steps required to install the beautiful Deepin Desktop in Arch Linux. - -The first part of the guide explains the steps for installing the base Arch system. The second part is installing the complete Deepin desktop on top of Arch Linux. - -### What is the Deepin Desktop? - -[Deepin][1] is a feature-rich and beautiful desktop environment based on Debian stable branch. Deepin desktop is a homegrown desktop environment by Deepin. It is powered by its own `dde-kwin` Window manager. Deepin desktop comes with nice looking dock and many native Deepin applications pre-loaded. - -This eye candy desktop environment is [available in the Arch repository][2]; this is how you can install Deepin Desktop Environment in Arch Linux. - -This guide installs Deepin 20.1 Desktop Environment. However, the steps should be similar for other versions as well. - -### Install Deepin Desktop in Arch Linux - -#### Part 1: Install Arch Linux - -If you have already Arch Linux installed, you can skip this step and directly go to the install Deepin Desktop section . - -For a quick Arch Linux base installation, follow the below steps. You can also visit [this guide][3] for a complete tutorial on installing Arch Linux as Dual Boot or on a virtual machine. - -##### Download Arch Linux - -Download Arch Linux .iso from the below link. There are magnet and torrent links available. Once you download it, write the ISO to a USB drive. And then boot from the drive. - -[Download Arch Linux][4] - -If you are planning to install it as a virtual machine image via [GNOME Boxes][5], [virt-manager][6] – then you do not need to write it to a USB drive. - -##### Boot and Configure Partitions - -After you boot from the Arch Linux iso, you have to run a series of commands to install the base system. - -First, run the below command to find out the device identifier. - -``` -fdisk -l -``` - -![fdisk -l before][7] - -Then with the device identifier, run the below command to start partitioning your disk. Make sure to change `/dev/sda` as per your system. - -``` -cfdisk /dev/sda -``` - -Select `label type = dos` the next prompt. - -Select the free space and choose the option NEW from the bottom. In this example, I will create three partitions as per below. - -``` -/dev/sda1 - 1G - for /boot/dev/sda2 - 5G - for root/dev/sda3 - 1G - for swap -``` - -![cfdisk][8] - -In the next screen, provide the partition size for the boot partition (for this example, I gave 1 GB). Select it as the primary partition. - -Repeat the same step for the main root partition of size 5GB. - -![Swap partition type change][9] - -Create a swap partition using the same steps with size 1G (you may change it as per your need). After you create the swap partition, make sure to choose Type at the bottom and mark it as a swap with the option “Linux Swap/Solaris”. - -![final partition list in cfdisk][10] - -Once done, write the changes to the disk using the Write option at the bottom. Make sure you take a backup before you write, as this is a permanent change in your system. - -Run the below command to check before you proceed. You can see in this example, that three partitions are listed. - -``` -fdisk -l -``` - -![final partition list in fdisk][11] - -Run the following commands in sequence to format and create an ext4 file system in the newly created partition above. Make sure you change the /dev/sda1 and /dev/sda2 as per your need. - -``` -mkfs.ext4 /dev/sda1mkfs.ext4 /dev/sda2mkswap /dev/sda3swapon /dev/sda3 -``` - -After completion, mount the system and create the necessary directories. - -``` -mount /dev/sda2 /mntmkdir /mnt/boot /mnt/var /mnt/homemount /dev/sda1 /mnt/boot -``` - -Again, make sure you change /dev/sda1, /dev/sda2 and /dev/sda3 as per your system. - -![prepare file system][12] - -##### Install the base system - -I hope you are already connected to the internet. If not, try using a USB dongle or wired internet connection which the Arch installer automatically configures and detect. If you do not have a wired connection available, follow this guide to configure a wireless or wifi network using the Arch Linux installer. - -Run the below commands in sequence to install the base system in the mounted partition. The download size is approx 400 MB. - -``` -pacman -Syypacstrap /mnt base base-devel linux linux-firmware nano dhcpcd net-tools grub -``` - -![Install base system][13] - -Once complete, generate a file system table without which you can’t boot the system. - -``` -genfstab -U /mnt >> /mnt/etc/fstab -``` - -##### Configure the base system - -Follow the below commands in sequence to configure the base system. This involves setting up your locale and language, adding a login user, and setting up the internet. - -``` -arch-chroot /mntnano /etc/locale.gen -``` - -Uncomment the locale of your choice by removing # at the beginning. For this guide, I have chosen en_US.UTF-8 UTF-8. Press CTRL+O, Enter, and CTRL+X to exit from nano. - -![change locale][14] - -Generate the locale using: - -``` -locale-gen -``` - -Set up the language using the below command. - -``` -echo LANG=en_US.UTF-8 > /etc/locale.confexport LANG=en_US.UTF-8 -``` - -Set up the local time zone. - -``` -ln -s /usr/share/zoneinfo/America/New_York /etc/localtime -``` - -Again, you can choose them as per your need. You can list the local time zones via the below commands. - -``` -ls /usr/share/zoneinfo -ls /usr/share/zoneinfo/America -``` - -Set up the hardware clock, create a hostname and enable the DHCP for the internet using the below commands in sequence. You can change `"arindam-pc"` to any hostname as per your desire. - -``` -hwclock --systohc --utc -echo debugpoint-pc > /etc/hostname -systemctl enable dhcpcd -``` - -The next step is to set up the root user password, create an admin user, and add the user to the sudoers file. - -Follow the below commands in sequence. Make sure to change the user name `debugpoint` to something else as per your need. - -``` -passwd rootuseradd -m -g users -G wheel -s /bin/bash debugpointpasswd debugpoint -``` - -![create user][15] - -Open the sudoers file and add the below lines. - -``` -nano /etc/sudoers -``` - -Add the below lines. As you already created the root user, the entry should be there. - -``` -root ALL=(ALL) ALLdebugpoint ALL=(ALL) ALL -``` - -![update sudoers file][16] - -Install grub, set up the initial ramdisk environment, and unmount the system using the below commands. - -``` -grub-install /dev/sdagrub-mkconfig -o /boot/grub/grub.cfgmkinitcpio -p linuxexit -``` - -![configure grub][17] - -Then reboot your system. - -``` -umount /mnt/bootumount /mntreboot -``` - -You have now successfully installed the Arch Linux base system. It’s time to install the complete Deepin desktop. - -#### Part 2: Install Deepin Desktop in Arch Linux - -After reboot, choose Arch Linux from grub. In the Arch Linux prompt, start running the following commands in sequence. These commands install the Xorg server, lightdm display manager and Deepin desktop components. - -For all the commands, use default as package versions, i.e. press enter when asked. - -* Install Xorg and display manager. Approx install size is 80 MB. - -``` -sudo pacman -S --needed xorg lightdm -``` - -* Install additional components and applications (approx 550 MB) - -``` -sudo pacman -S --needed deepin deepin-extra -``` - -After the installation, enable the Deepin greeter by modifying the lightdm configuration file. Follow the below commands. - -``` -nano /etc/lightdm/lightdm.conf -``` - -And add the below line. Save the file (CTRL+O, CTRL+X). - -``` -greeter-session=lightdm-deepin-greeter -``` - -![add deepin-greeter in lightdm login - install Deepin desktop in Arch Linux][18] - -Now it’s time to enable the display manager and network manager as service. So that next time you log on, they can run automatically by systemd. - -``` -systemctl enable lightdm -systemctl enable NetworkManager -``` - -![Enable lightdm and network][19] - -Reboot the system using the reboot command. - -``` -reboot -``` - -If all goes well, you should see the Deepin desktop login prompt. Login using the credentials you just created in the above steps. You should be greeted with the latest Deepin desktop environment. - -![Deepin 20.1 Login screen in Arch Linux][20] - -![Deepin Desktop 20.1 in Arch Linux][21] - -### Wrapping Up - -I hope this guide helped you to install the Deepin desktop in Arch Linux. Although it is not my daily driver, I feel Deepin’s desktop is somewhat slow in nature. Probably because of too much colour rendering and animation and not properly optimized by `dde-desktop` despite it being built on Qt. - --------------------------------------------------------------------------------- - -via: https://www.debugpoint.com/deepin-arch-linux-install-20/ - -作者:[Arindam][a] -选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.debugpoint.com/author/admin1/ -[b]: https://github.com/lkxed -[1]: https://www.debugpoint.com/2020/09/deepin-20-review/ -[2]: https://archlinux.org/groups/x86_64/deepin/ -[3]: https://www.debugpoint.com/2020/11/install-arch-linux/ -[4]: https://www.archlinux.org/download/ -[5]: https://www.debugpoint.com/2020/05/install-use-gnome-boxes/ -[6]: https://www.debugpoint.com/2020/11/virt-manager/ -[7]: https://www.debugpoint.com/wp-content/uploads/2020/12/fdisk-l-before.jpg -[8]: https://www.debugpoint.com/wp-content/uploads/2020/12/cfdisk-1024x159.jpg -[9]: https://www.debugpoint.com/wp-content/uploads/2020/12/Swap-parition-type-change.jpg -[10]: https://www.debugpoint.com/wp-content/uploads/2020/12/final-partition-list-in-cfdisk-1024x178.jpg -[11]: https://www.debugpoint.com/wp-content/uploads/2020/12/final-partition-list-in-fdisk.jpg -[12]: https://www.debugpoint.com/wp-content/uploads/2020/12/prepare-file-system.jpg -[13]: https://www.debugpoint.com/wp-content/uploads/2020/12/Install-base-system-1024x205.jpg -[14]: https://www.debugpoint.com/wp-content/uploads/2020/12/change-locale.jpg -[15]: https://www.debugpoint.com/wp-content/uploads/2020/12/create-user.jpg -[16]: https://www.debugpoint.com/wp-content/uploads/2020/12/update-sudoers-file.jpg -[17]: https://www.debugpoint.com/wp-content/uploads/2020/12/configure-grub-1024x639.jpg -[18]: https://www.debugpoint.com/wp-content/uploads/2021/01/add-deepin-greeter-in-lightdm-login.jpg -[19]: https://www.debugpoint.com/wp-content/uploads/2020/12/Enable-lightdm-and-network-Install-Xfce-Desktop-in-Arch-Linux.jpg -[20]: https://www.debugpoint.com/wp-content/uploads/2021/01/Deepin-20.1-Login-screen-in-Arch-Linux-1024x771.jpg -[21]: https://www.debugpoint.com/wp-content/uploads/2021/01/Deepin-Desktop-20.1-in-Arch-Linux-1024x770.jpg diff --git a/translated/tech/20220614 Build a Smart Parking System for a Metro Station.md b/translated/tech/20220614 Build a Smart Parking System for a Metro Station.md new file mode 100644 index 0000000000..0fb3b50f69 --- /dev/null +++ b/translated/tech/20220614 Build a Smart Parking System for a Metro Station.md @@ -0,0 +1,147 @@ +[#]: subject: "Build a Smart Parking System for a Metro Station" +[#]: via: "https://www.opensourceforu.com/2022/06/build-a-smart-parking-system-for-a-metro-station/" +[#]: author: "Dr Maheswari R. https://www.opensourceforu.com/author/dr-maheswari-r/" +[#]: collector: "lkxed" +[#]: translator: "Maisie-x " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +为地铁站构建智能停车系统 +====== +本文将帮助你设计一个基于 Web 的应用程序,该应用程序使用 Node-RED 为地铁站的汽车自动实现智能停车系统。 + +![Smart car parking][1] + +Web应用程序是在Web服务器上运行的软件。终端用户通过Web浏览器访问每个Web应用程序。Web应用程序使用客户端—服务器架构进行编程,该架构是用户(客户端)通过可能由第三方托管的远程服务器提供服务。Web API(应用程序编程接口)在Web上可用,用户可以通过HTTP协议访问该接口,如图1所示。 + +本文将演示如何为地铁设计一个基于Web的汽车自动智能停车系统。 它是使用开源的Node-RED设计。该系统使用模板节点创建了一个互动式且时尚的用户登录表单,该模板用HTML和CSS编码以获取车主详细,从而实现停车系统的自动化。我们可以在图2和图3看到登录表单和提交表单的流程图。 + +使用的节点如下: + +![table function][3] + +**地铁智能停车节点流程设计** + +Node-RED是使用’node-red‘命令激活。通过网址http://127.0.0.1:1880/ 可以访问Node-RED的用户界面流程图的浏览器。我们认为Node-RED设置已完成并且可以正常工作了。 + +![Figure 1: Web API][4] + +按照下面给出的步骤创建登录表单和提交表单。 + +![Figure 2: Login form flow diagram][5] + +![Figure 3: Submission form flow diagram][6] + +**登录表单** + +1) 在节点画布中,拖放http in节点,这会为创建Web服务创建一个HTTP访问点。 +2) 将http in节点连接到函数function节点。函数节点有助于编写JavaScripts函数处理节点接收到的消息。 + +![Figure 4: Login form for smart parking for cars][7] + +3) 将函数function节点连接到模板template节点,模板节点基于提供的模板创建一个Web API。 +4) 将模板template节点连接到http 响应response节点,响应节点将响应http输入节点的请求。 + +![Figure 5: Submission form for smart parking for cars][8] + +**提交表单** + +1) 拖放http in节点并将其连接到json节点,json节点将数据转换为JSON字符串进行通信。 +2) 将http in节点连接到调试debug节点,调试节点的调试监控器会输出结果。 +3) 将json节点放置并连接到函数function节点,将函数节点连接到http响应节点。 + +创建完整流程后,单击Node-RED窗口右上角的部署Deploy按钮。访问*127.0.0.1:1880/ui/*这个链接查看用户界面。 + +输入链接然后单击提交Submit后,该链接会跳转到下一页,您可以在该页面阅读所有新闻。 + +**Node-RED工作流程** + +在单个Node-RED流程中,您可以创建登录表单和提交表单,如图4和图5所示。 + +现在我们将配置节点属性。 + +**登录表单**:编辑http in属性:方法method选择 ‘Get’,网址URL设为‘/MetroStation’ ,名称name配置为 “智能停车系统Smart Parking”。(译注:下文http响应节点的名称为Smart parking,p字母小写,为了区分,此处中文翻译成智能停车系统。) + +![Figure 6: Http in node property configurations][9] + +| - | +| :- | +| 注意:任何用户可以定义网址URL为本地变量。 | + +现在选择函数节点,编辑函数节点属性:输入代码 ‘msg.url = project’ ,并配置代码名称name字段为 “项目提交Project Submission”。 + +![Figure 7: Function node property configurations][10] + +在模板节点的属性窗口,为登录表单配置相应的HTML代码,并将代码名称name命名为 “显示面板Display panel”。猜此流程使用了Mustache(译注:Mustache是胡子的意思,因为它的嵌入标记{{ }}非常像胡子)模板格式。Mustache是一个简单的Web模板系统,被描述为无逻辑的模板引擎。Mustache没有任何显式的控制流语句,例如 ‘if’ 和 ‘else’条件和‘for’ 循环。可以通过使用块标签处理列表和lambdas来实现循环和条件评估。 + +![Figure 8: Template node property configurations][11] + +配置编辑http响应response节点的属性,名称name设为 "智能停车Smart parking"(图9) 。 + +![Figure 9: Http response node property configurations][12] + +**提交表单**:在http in节点的编辑属性窗口,方法method选择‘POST’ ,网址URL设为 ‘/project’。 + +![Figure 10: Http in node property configurations][13] + +在JSON节点的编辑窗口,操作Action设为‘JSON字符串与对象互转Convert between JSON String & Object’,参考图11。 + +![Figure 11: JSON node property configurations][14] + +函数节点的配置如图12所示。 + +![Figure 12: Function node property configurations][15] + +在http响应response节点,编辑属性名称name为“已提交项目Project Submitted”。 + +![Figure 13: Http response node property configurations][16] + +| - | +| :- | +| 注意:添加带有评论的评论节点作为 “登录表单” 和 “提交表单”。 | + +![Figure 14: Debug node property configurations][17] + +**用户界面的控制面板** + +当用户单击提交Submit,给出的数据将显示在用户界面和调试节点。如果单击重置Reset,详细信息将被清除,允许用户输入新的详细信息(图15)。 + +![Figure 15: User login UI][18] + +地铁停车费通过超链接提供,收费表在用户界面显示。因此,汽车智能停车系统通过适当的超链接实现自动化,展示地铁站的停车费。该自动化系统的最终输出可以在Node-RED控制面板的用户界面和调试监控器调取和展示。 + +![Figure 16: Metro parking tariff][19] + +-------------------------------------------------------------------------------- + +via: https://www.opensourceforu.com/2022/06/build-a-smart-parking-system-for-a-metro-station/ + +作者:[Dr Maheswari R.][a] +选题:[lkxed][b] +译者:[Maisie-x](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.opensourceforu.com/author/dr-maheswari-r/ +[b]: https://github.com/lkxed +[1]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Smart-car-parking.jpg +[2]: https://www.opensourceforu.com/wp-content/uploads/2022/04/table-function-node-red.jpg +[3]: https://www.opensourceforu.com/wp-content/uploads/2022/04/table-function-node-red.jpg +[4]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-1-Web-Application-Programming-Interface300.jpg +[5]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-2-Login-Form-Flow-Diagram300.jpg +[6]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-3-Submission-Form-Flow-Diagram300.jpg +[7]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-4-Login-Form-of-Metro-Smart-Car-Parking300.jpg +[8]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-5-Submission-Form-of-Metro-Smart-Car-Parking300.jpg +[9]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-6-Http-in-Node-Property-Configurations300.jpg +[10]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-7-Function-Node-Property-Configurations300.jpg +[11]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-8-Template-Node-Property-Configurations300.jpg +[12]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-9-Template-Node-Property-Configurations300.jpg +[13]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-10-Http-in-Node-Property-Configurations300.jpg +[14]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-11-Json-Node-Property-Configurations300.jpg +[15]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-12-Function-Node-Property-Configurations300.jpg +[16]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-13-Http-Response-Node-Property-Configurations300.jpg +[17]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-14-Debug-Node-Property-Configurations300.jpg +[18]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-15-User-Login-UI300.jpg +[19]: https://www.opensourceforu.com/wp-content/uploads/2022/04/Figure-16-Parking-Tariff-Metro300.jpg