本地構建和自動化構建_如何構建最強大,最安全的家庭自動化系統

本地構建和自動化構建

by Amir Off

由Amir Off

如何構建最強大,最安全的家庭自動化系統 (How to build the most robust and secure home automation system)

In this article, I’ll discuss how I built a Smart Home Automation System with Angular and Node.js on a Raspberry Pi without relying on any external cloud services.

在本文中,我將討論如何在Raspberry Pi上不依賴任何外部云服務的情況下,使用Angular和Node.js構建智能家居自動化系統。

介紹 (Intro)

Over the last few days, I spent some nights designing and developing a home automation system based on JavaScript, with the use of Angular and Node.js. And, like with any other project, the planning involved some deep research on the internet.

在過去的幾天里,我花了一些晚上使用Angular和Node.js設計和開發基于JavaScript的家庭自動化系統。 并且,與任何其他項目一樣,該計劃涉及對互聯網的一些深入研究。

It turned out that there are plenty of fish in the sea —plenty of solutions on how to implement a home automation system. Some offer paid services in “the cloud” and others explain how to build your own using a technology called MQTT.

事實證明,海中有很多魚-有關如何實施家庭自動化系統的大量解決方案。 一些提供“云”中的付費服務,另一些解釋如何使用稱為MQTT的技術構建自己的服務。

None of the solutions made any sense to me. All options were either expensive, or had inconvenient implementations or even security flaws.

沒有一種解決方案對我有意義。 所有選項要么昂貴,要么實現不便,甚至存在安全漏洞。

But, before we go any further, let’s explain what MQTT is. MQTT stands for MQ Telemetry Transport. It is a publish/subscribe, extremely simple and lightweight messaging protocol. MQTT is designed for constrained devices and low-bandwidth, high-latency, or unreliable networks.

但是,在進一步介紹之前,讓我們解釋一下MQTT是什么。 MQTT代表MQ遙測傳輸 。 它是一種發布/訂閱,極其簡單和輕便的消息傳遞協議。 MQTT專為受限設備和低帶寬,高延遲或不可靠的網絡而設計。

The design principles are to minimise network bandwidth and device resource requirements whilst attempting to ensure reliability and some degree of assurance of delivery. These principles also turn out to make the protocol ideal for the emerging “machine-to-machine” (M2M) or “Internet of Things” world of connected devices, and for mobile applications where bandwidth and battery power are at a premium.

設計原則是在嘗試確保可靠性和一定程度的交付保證的同時,最小化網絡帶寬和設備資源要求。 這些原則也使該協議成為新興的連接設備的“機器對機器”(M2M)或“物聯網”世界以及帶寬和電池電量極為寶貴的移動應用的理想選擇 。

Why wasn’t I convinced about using MQTT, or by any of the solutions I found on the internet? Two reasons:

為什么我對使用MQTT或我在互聯網上找到的任何解決方案都不滿意? 兩個原因:

  1. While the MQTT technology seems very convenient for IoT devices, I still thought it was unnecessary. The system which I will be showing in the following tutorial operates in the same medium where the IoT devices live. All benefits that MQTT has for being “fast” and having “low-bandwidth” become irrelevant. Plus there’s all the hassle that is involved in its implementation and all the extra overhead with the additional npm packages that are required for it to work in a JavaScript environment. Instead, I will be using generic JavaScript and Node.js libraries only, nothing more!

    盡管MQTT技術對于物聯網設備非常方便,但我仍然認為這是不必要的。 我將在以下教程中顯示的系統在IoT設備所在的相同介質上運行。 MQTT所具有的“快速”和“低帶寬”的所有優點變得無關緊要。 另外,它的實現還涉及所有麻煩,并且在JavaScript環境中運行它需要額外的npm軟件包帶來的所有額外開銷。 相反,我將僅使用通用JavaScript和Node.js庫,僅此而已!
  2. What about the security part? Well, I’m not a big fan of “the cloud” or cloud computing in general. In some cases it can be very beneficial, but in most cases it’s just unnecessary. Think about it: why would you have a service that is required for controlling your home appliances to be hosted somewhere else in “the cloud” and not in your own network?

    安全部分呢? 好吧,我一般都不喜歡“云”或云計算。 在某些情況下,這可能是非常有益的,但在大多數情況下,這是不必要的。 想一想:為什么您需要一項服務,以控制您的家用電器托管在“云”中而不是您自己的網絡中?

One might think that “the cloud” provides the ability to access your home appliances from anywhere in the world via the internet.

可能有人認為“云”提供了通過互聯網從世界任何地方訪問您的家用電器的能力。

But think about this: when your home network doesn’t have internet connection, “the cloud” becomes redundant. More importantly, you can still make your home automation system accessible from the internet using port-forwarding even if it’s hosted on your local network.

但是請考慮一下:當您的家庭網絡沒有Internet連接時,“云”將變得多余。 更重要的是,即使端口托管在本地網絡上,您仍然可以使用端口轉發從互聯網訪問家庭自動化系統。

This is when it “clicked” for me, and I thought about hosting the whole system on a Raspberry Pi and keeping it in my local network.

這是當它為我“點擊”時,我考慮過將整個系統托管在Raspberry Pi上,并將其保留在我的本地網絡中。

技術 (The technology)

  1. Software: The reason why I chose Angular and Node.js is because they’re based on JavaScript and I’m already familiar with it. After all, I wanted to design and develop a progressive web app that communicates with my IoT devices via HTTP — and JavaScript offered all the functionality that I needed.

    軟件:之所以選擇Angular和Node.js是因為它們基于JavaScript,并且我已經很熟悉。 畢竟,我想設計和開發一個漸進式Web應用程序,該應用程序可通過HTTP與我的IoT設備進行通信-JavaScript提供了我需要的所有功能。

  2. Hardware: The system works with microcontrollers like the Arduino Uno/Mega/Du/MKR1000, Adafruit HUZZAH CC3000, and any other microcontroller with a WiFi connection. I am using the ESP8266 as a base component for my home automation system. It’s a low-cost WiFi microchip with microcontroller capability. It has everything I need and for a cheap price! Lastly, we need to host the system somewhere on our local network — so what’s better than the Raspberry Pi?

    硬件:該系統可與Arduino Uno / Mega / Du / MKR1000,Adafruit HUZZAH CC3000和任何其他具有WiFi連接的微控制器一起使用。 我將ESP8266用作家庭自動化系統的基本組件。 這是一款具有微控制器功能的低成本WiFi微芯片。 它具有我需要的一切,而且價格便宜! 最后,我們需要將系統托管在本地網絡上的某個地方–那么有什么比Raspberry Pi更好的呢?

This won’t be a coding tutorial where I dive deep into coding, since this project is open-source and I will be publishing everything on GitHub. I will only demonstrate how to implement your own home automation system and will be going through each step. If you’re a developer please fork the repository and get involved in improving it.

這不是我將深入研究編碼的編碼教程,因為該項目是開源的,我將在GitHub上發布所有內容。 我將僅演示如何實現自己的家庭自動化系統,并將逐步進行每個步驟。 如果您是開發人員,請分叉存儲庫并參與改進。

設置 (The setup)

I estimate that it will take about 40 minutes to finish this whole setup plus any time spent online searching for solutions for installation errors.

我估計大約需要40分鐘才能完成整個安裝過程,并且花費任何時間在線搜索安裝錯誤的解決方案。

需要什么? (What is needed?)

A Raspberry Pi is required. In my example I’m using a Raspberry Pi 3, but it should work with most versions. The components needed are:

需要Raspberry Pi。 在我的示例中,我使用的是Raspberry Pi 3,但它適用于大多數版本。 所需的組件是:

  1. Raspberry Pi board

    樹莓派板
  2. MicroSD card (A class 10 with 16 GB or higher is recommended)

    MicroSD卡(建議使用16 GB或更高的Class 10)
  3. A USB MicroSD card reader or SD card adapter

    USB MicroSD讀卡器或SD卡適配器
  4. HDMI monitor and a USB keyboard (only required temporarily for the first boot of the Raspberry Pi)

    HDMI監視器和USB鍵盤(僅在Raspberry Pi首次啟動時臨時需要)
  5. Ethernet cable (not needed for Raspberry Pi 3 as it has built in WiFi)

    以太網電纜(Raspberry Pi 3內置WiFi不需要)

在Raspberry Pi上安裝Raspbian OS (Installing Raspbian OS on the Raspberry Pi)

Raspbian is a free operating system based on Debian Linux, and it is optimized for Raspberry Pi.

Raspbian是基于Debian Linux的免費操作系統,并且已針對Raspberry Pi進行了優化。

I recommend the headless “LITE” version. It has no desktop environment or any graphical user interface, and it’s remotely accessible from a computer or device on the same network via SSH. We’re keeping things simple since this is the only way we are going to access the Raspberry Pi. The LITE version has all the functionality we’re looking for.

我推薦無頭“ LITE”版本。 它沒有桌面環境或任何圖形用戶界面,并且可以通過SSH從同一網絡上的計算機或設備進行遠程訪問。 我們將事情保持簡單,因為這是我們訪問Raspberry Pi的唯一方法。 LITE版本具有我們正在尋找的所有功能。

  1. Download the latest Raspbian image from the official Raspberry Pi website.

    從Raspberry Pi官方網站下載最新的 Raspbian映像。

  2. Flash the Raspbian OS image to the SD card with Etcher or any other OS image burning software of your choice.

    使用Etcher或您選擇的任何其他OS映像刻錄軟件將Raspbian OS映像閃存到SD卡。

設置Raspberry Pi (Setting up the Raspberry Pi)

To get the Raspberry Pi ready to boot we need to:

要使Raspberry Pi準備啟動,我們需要:

  1. Insert the MicroSD card into the Raspberry Pi

    將MicroSD卡插入Raspberry Pi
  2. Connect the USB keyboard and the HDMI cable

    連接USB鍵盤和HDMI電纜
  3. Connect the Ethernet cable or if you have a Raspberry Pi 3 and want to use WiFi you should set up the network in the next section

    連接以太網電纜,或者如果您有Raspberry Pi 3并想使用WiFi,則應在下一部分中設置網絡

When the Raspberry Pi has finished booting up, log in using username pi and password raspberry

Raspberry Pi完成啟動后,使用用戶名pi和密碼raspberry登錄

啟用WiFi并連接到網絡 (Enabling WiFi and connecting to the network)

Skip this step if you chose to connect with an Ethernet cable.

如果您選擇使用以太網電纜連接,請跳過此步驟

  1. Open the “wpa-supplicant” configuration file

    打開“ wpa-supplicant”配置文件
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

2. add the following at the bottom of the file while adding your wifi name and password:

2.在文件底部添加以下內容,同時添加您的wifi名稱和密碼:

network={
ssid="your_networks_name"   psk="your_networks_password"
}

3. Press Ctrl+X to save the code. Confirm with Y then Enter

3.Ctrl+X保存代碼。 確認與Y然后Enter

4. Reboot the Raspberry Pi with the following command:

4.使用以下命令重新啟動Raspberry Pi:

$ sudo reboot

啟用S??SH并更改用戶名和密碼 (Enabling SSH and changing the username and password)

Now that the Raspberry Pi is connected to the internet, it’s recommended to change the default password.

現在Raspberry Pi已連接到Internet,建議更改默認密碼。

  1. Open the Raspberry Pi configuration tool and click the second option “Change User Password” and follow the instructions

    打開Raspberry Pi配置工具,然后單擊第二個選項“更改用戶密碼”,然后按照說明進行操作
$ sudo raspi-config

2. Select option 5 “Interfacing Options” then activate SSH

2.選擇選項5“接口選項”,然后激活SSH

3. Reboot the Raspberry Pi. When it’s up, you have SSH enabled and it’s ready to be accessed remotely from your desktop computer

3.重新啟動Raspberry Pi。 啟動時,您已啟用SSH,并且可以從臺式計算機遠程訪問它

$ sudo reboot

配置對Raspberry Pi的遠程訪問 (Configuring remote access to the Raspberry Pi)

Now, finally, the part when we install the required software on the Raspberry Pi. This part can be executed directly on the Pi through the terminal using a HDMI monitor and a USB keyboard. For convenience — and since we enable remote SSH connection — we’re going to connect from another desktop environment. This is the best and easiest way to remotely access and control the Pi whenever changes and configurations are needed.

現在,最后是我們在Raspberry Pi上安裝所需軟件的部分。 這部分可以使用HDMI監視器和USB鍵盤通過終端直接在Pi上執行。 為了方便起見,并且由于我們啟用了遠程SSH連接,因此我們將從另一個桌面環境進行連接。 每當需要更改和配置時,這是遠程訪問和控制Pi的最佳和最簡便的方法。

So, basically, this is how you can access the command line interface of a Raspberry Pi remotely from another computer or any device on the same network using SSH. This can be done in two ways:

因此,基本上,這就是您可以使用SSH從另一臺計算機或同一網絡上的任何設備遠程訪問Raspberry Pi的命令行界面的方法。 這可以通過兩種方式完成:

  1. Using the Command Prompt or PowerShell (I’m using Windows on a Desktop computer), replace with your username and IP address

    使用命令提示符或PowerShell(我在臺式計算機上使用Windows),替換為您的用戶名和IP地址
$ ssh username@ipaddress

If you do not know the IP address, type “hostname -I" in the Raspberry Pi command line.

如果您不知道 IP地址,請在Raspberry Pi命令行中鍵入“ hostname -I"

2. The second method is using a client program like PuTTY or any other functioning client SSH software. Here’s an easy guide for using PuTTY.

2.第二種方法是使用客戶端程序,例如PuTTY或任何其他程序 客戶端SSH軟件。 這是使用PuTTY的簡單指南

在Raspberry Pi上安裝所需的軟件 (Installing the required software on the Raspberry Pi)

Before installing anything, it’s recommended to update the Raspberry Pi’s operating system and packages. Doing this regularly will keep it up-to-date.

在安裝任何東西之前,建議先更新Raspberry Pi的操作系統和軟件包。 定期執行此操作可以使它保持最新狀態。

  1. Update the system packages list using the following command:

    使用以下命令更新系統軟件包列表:
$ sudo apt-get update

2. Upgrade all your installed packages to their latest version:

2.將所有已安裝的軟件包升級到最新版本:

$ sudo apt-get dist-upgrade

3. Download and install the latest version of Node.js:

3.下載并安裝最新版本的Node.js:

// To download$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
// To install$ sudo apt-get install -y nodejs
// Check if the installation was successful:$ node -v

4. Install the Angular CLI globally:

4.全局安裝Angular CLI:

$ npm install -g @angular/cli

5. Install the Git version-control system:

5.安裝Git版本控制系統:

$ sudo apt-get install git

安裝數據庫(MongoDB) (Installing the database (MongoDB))

We need a database for storing the registered users and their credentials. Here are the required steps:

我們需要一個數據庫來存儲注冊用戶及其憑證。 這是必需的步驟:

  1. Install MongoDB

    安裝MongoDB
$ sudo apt-get install mongodb

2. Start the MongoDB process

2.啟動MongoDB進程

$ sudo service mongodb start

3. Start the mongo Shell

3.啟動mongo Shell

$ mongo

3. Create a database called “smarthaus”

3.創建一個名為“ smarthaus”的數據庫

$ use smarthaus

In MongoDB, default database is test. If you didn’t create any database, then collections will be stored in test database.

在MongoDB中,默認數據庫為test。 如果您未創建任何數據庫,則集合將存儲在測試數據庫中。

安裝Smart Haus (Installing Smart Haus)

1. Check the current work directory using this command:

1.使用以下命令檢查當前工作目錄:

$ pwd
/* It will probably print "/home/pi"   where "pi" is the current user directory */

It’s recommended to clone the project’s repository under the pi’s user directory but you can navigate somewhere else if you’re sure.

建議在pi的用戶目錄下克隆項目的存儲庫,但如果確定的話,可以導航到其他地方。

2. Clone the repository from:

2.從以下位置克隆存儲庫:

$ git clone https://github.com/ameer157/smarthaus.git

Make sure to navigate inside the directory using:

確保使用以下內容瀏覽目錄:

$ cd smarthaus

Before installing any npm packages using “npm install” please refer to the npm guide to fix permissions to learn how to fix any “EACCESS ”errors you might face during installation. This is very important since it will prevent any npm permission errors, and allows you to install packages globally without using sudo. Using sudo with npm is not recommended and should be avoided.

在使用“ npm install”安裝任何npm軟件包之前,請參考npm指南以修復權限,以了解如何解決在安裝過程中可能遇到的任何“ EACCESS ”錯誤。 這非常重要,因為它將防止任何npm權限錯誤,并允許您在不使用sudo的情況下全局安裝軟件包。 不建議將sudo與npm一起使用, 應避免使用

3. Install all the required packages for the project:

3.安裝項目所需的所有軟件包:

$ npm install

啟動Node.js服務器 (Starting the Node.js server)

Before starting the server we need to build the project using the Angular CLI tool. And lastly, we configure the Raspberry Pi so that it runs the server whenever it boots up.

在啟動服務器之前,我們需要使用Angular CLI工具構建項目。 最后,我們配置Raspberry Pi,使其在啟動時運行服務器。

  1. Build the project using:

    使用以下命令構建項目:
$ ng build --prod

2. Edit the rc.local file using nano:

2.使用nano編輯rc.local文件:

$ sudo nano /etc/rc.local

3. Add the following on the line before exit 0 then exit and save the file:

3.exit 0之前的行中添加以下內容,然后退出并保存文件:

su pi -c 'cd /home/pi/smarthaus/backend && sudo node server.js > log.txt &'

The Node.js server is now ready! It will run on every system boot up and save logs in under the same directory in a “log.txt” file.

Node.js服務器現在準備就緒! 它將在每次系統啟動時運行,并將日志保存在同一目錄下的“ log.txt”文件中。

Let’s run it now and see if it works using this command:

現在運行它,并使用以下命令查看它是否有效:

$ sudo node server

The system in now accessible from any device on your network via the Raspberry Pi’s IP address.

現在可以通過Raspberry Pi的IP地址從網絡上的任何設備訪問該系統。

Please go ahead and fork this project and get involved in developing the missing parts ?

請著手這個項目,并涉足發展中缺少的部分?

結束 (The end)

We got ourselves a working home automation system running safely on a Raspberry Pi in our local network without the use of “the cloud” or somebody else’s server.

我們獲得了一個可以正常工作的家庭自動化系統,該系統可以在本地網絡中的Raspberry Pi上安全運行,而無需使用“云”或其他人的服務器。

My Raspberry Pi sitting next to my Fingbox and router in the living room ?

我的Raspberry Pi坐在客廳的Fingbox和路由器旁邊嗎?

I hope you enjoyed reading,Please follow and share for more tech stuff ??

希望您喜歡閱讀,請關注 分享更多的技術資料?

翻譯自: https://www.freecodecamp.org/news/the-most-robust-and-secure-home-automation-system-6d0ddbb39f29/

本地構建和自動化構建

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/393002.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/393002.shtml
英文地址,請注明出處:http://en.pswp.cn/news/393002.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

leetcode990. 等式方程的可滿足性(并查集)

給定一個由表示變量之間關系的字符串方程組成的數組,每個字符串方程 equations[i] 的長度為 4,并采用兩種不同的形式之一:“ab” 或 “a!b”。在這里,a 和 b 是小寫字母(不一定不同),表示單字母…

random對文件隨機重命名

對文件隨機重命名,這個用途可廣了,大家可以想想 echo off setlocal ENABLEDELAYEDEXPANSION for /r %%a in (*.txt) do ( set c!random! ren %%~dpnsa.txt !c!.txt) pause 本文轉自sucre03 51CTO博客,原文鏈接:http://blog…

AC日記——Periodic RMQ Problem codeforces 803G

G - Periodic RMQ Problem 思路&#xff1a; 題目給一段序列&#xff0c;然后序列復制很多次&#xff1b; 維護序列很多次后的性質&#xff1b; 線段樹動態開點&#xff1b; 來&#xff0c;上代碼&#xff1a; #include <cstdio> #include <cstring> #include <…

數據之路 - Python爬蟲 - 數據存儲

一、文件存儲 1.文件打開方式 文件打開方式說明r以只讀方式打開文件。文件的指針將會放在文件的開頭。這是默認模式rb以二進制只讀方式打開一個文件。文件指針將會放在文件的開頭r以讀寫方式打開一個文件。文件指針將會放在文件的開頭rb以二進制讀寫方式打開一個文件。文件指針…

創建react應用程序_如何使用React創建一個三層應用程序

創建react應用程序Discover Functional JavaScript was named one of the best new Functional Programming books by BookAuthority!“發現功能JavaScript”被BookAuthority評為最佳新功能編程書籍之一 &#xff01; Splitting a Single Page Application into layers has a …

linux update語句,MySQL 多表 update sql語句總結

MySQL 多表 update 有幾種不同的寫法。假定我們有兩張表&#xff0c;一張表為Product表存放產品信息&#xff0c;其中有產品價格列Price&#xff1b;另外一張表是ProductPrice表&#xff0c;我們要將ProductPrice表中的價格字段Price更新為Price表中價格字段的80%。在Mysql中我…

linux延時與定時操作

1、at ---系統延遲任務發起命令 at time >command ---任務指令 >ctrld ---發起任務 at -l ---列出延時任務Id at -r id ---刪除改id任務 at -m ---讓無輸出的命令產生郵件 at -M ---讓有輸…

windows修改PowerShell(命令提示符)默認中文編碼方式

如果以下方法都沒有作用的話&#xff0c;可以直接在代碼中調用<stdlib.h>中的system("mode con cp select65001")或者是system("chcp 65001")。當然&#xff0c;前提是你用的也是C、C、C#等強類型編程語言。 **************************************…

leetcode面試題 17.07. 嬰兒名字(并查集)

每年&#xff0c;政府都會公布一萬個最常見的嬰兒名字和它們出現的頻率&#xff0c;也就是同名嬰兒的數量。有些名字有多種拼法&#xff0c;例如&#xff0c;John 和 Jon 本質上是相同的名字&#xff0c;但被當成了兩個名字公布出來。給定兩個列表&#xff0c;一個是名字及對應…

appium+python+iOS 環境搭建與使用中常見問題的解決方案鏈接

&#xff08;1&#xff09;WebDriverAgent 安裝入門篇&#xff1a;https://www.cnblogs.com/zhanggui/p/9239827.html 重點摘要&#xff1a; 在WDA的Github上也給出了WDA的特性&#xff1a; 1.支持真機 &&模擬器 在模擬器上運行還是比較方便的&#xff0c;在真機上需要…

api工廠接口路徑是什么_為什么(幾乎)永遠不要再使用絕對路徑訪問API

api工廠接口路徑是什么by Vitaly Kondratiev通過維塔利康德拉季耶夫(Vitaly Kondratiev) 為什么(幾乎)永遠不要再使用絕對路徑訪問API (Why you should (almost) never use an absolute path to your APIs again) Recent advances in web apps architecture show that a decou…

雙機通信c語言程序,上傳一個自己編寫的I2C雙機通信程序

本帖最后由 micro_聽海 于 2012-11-24 19:58 編輯這幾天一直在搞AVR的twi(twi就是i2c)雙機通信程序&#xff0c;使用的是兩塊arduino開發板。因為最總要這個通信程序最總是要放在winavr的編譯環境中&#xff0c;所以沒有使用arduino自帶的庫函數。但是這沒關系&#xff0c;因為…

leetcode684. 冗余連接(并查集)

在本問題中, 樹指的是一個連通且無環的無向圖。 輸入一個圖&#xff0c;該圖由一個有著N個節點 (節點值不重復1, 2, …, N) 的樹及一條附加的邊構成。附加的邊的兩個頂點包含在1到N中間&#xff0c;這條附加的邊不屬于樹中已存在的邊。 結果圖是一個以邊組成的二維數組。每一…

Windows Server 2008 部署權限管理RMS

1.1 實戰&#xff1a;部署權限管理 試驗目的&#xff1a; 在單域環境中部署活動目錄權限管理服務&#xff0c;實現文檔的保護。 試驗環境&#xff1a; ? DCServer安裝Windows Server 2008企業版&#xff0c;是ess.com的域控制器&#xff0c;安裝企業CA。 ? RMSServer安裝Wind…

day5 Python爬蟲學習

一 實現京東上的自動搜索并提取信息 from selenium import webdriver # 導入鍵盤Keys from selenium.webdriver.common.keys import Keys import timedriver webdriver.Chrome()# 檢測代碼塊 try:# 隱式等待&#xff0c;等待標簽加載driver.implicitly_wait(10)# 往京東主頁…

虛擬dom添加虛擬dom_虛擬DOM緩慢。 認識記憶化的DOM

虛擬dom添加虛擬domby Sindre Osen Aarsaether通過Sindre Osen Aarsaether 虛擬DOM緩慢。 符合已記憶的DOM。 (The Virtual DOM is slow. Meet the Memoized DOM.) 超越虛擬DOM和狀態管理 (Moving beyond the Virtual DOM and State Management) The virtual DOM was a fantas…

編寫一個字節數的rtu C語言校驗程序,Modbus通信協議中CRC校驗的快速C語言算法

Modbus通信協議中CRC校驗的快速C語言算法2004年第11期            福 建 電 腦  63Modbus通信協議中CRC校驗的快速C語言算法孟開元(西安石油大學計算機學院陜西西安710065)【摘 要】 本文主要討論了Modbus通信協議的RTU幀格式中常用的錯誤校驗方法,即循環冗…

leetcode1319. 連通網絡的操作次數(并查集)

用以太網線纜將 n 臺計算機連接成一個網絡&#xff0c;計算機的編號從 0 到 n-1。線纜用 connections 表示&#xff0c;其中 connections[i] [a, b] 連接了計算機 a 和 b。 網絡中的任何一臺計算機都可以通過網絡直接或者間接訪問同一個網絡中其他任意一臺計算機。 給你這個…

Codeforces 600E Lomsat gelral (樹上啟發式合并)

題目鏈接 Lomsat gelral 占坑……等深入理解了再來補題解…… #include <bits/stdc.h>using namespace std;#define rep(i, a, b) for (int i(a); i < (b); i)typedef long long LL;const int N 600010;int n; int cc[N], col[N], sz[N], son[N]; LL ans[N];vect…

如何讓CloudStack使用KVM創建Windows實例成功識別并掛載數據盤

問題產生背景&#xff1a; 使用CloudStack KVM組合進行資源池納管工作&#xff0c;通過ISO鏡像文件創建了兩個模板&#xff1a; RHEL6U3 64位系統以及WindowsServer2008 R2 SP1 64位系統。然后通過模板創建實例&#xff0c;掛載外接存儲&#xff0c;實例啟動后&#xff0c;通過…