本測試程式旨在驗證雲端太陽能監控業者是否符合台電 DREAMS 規範,使其針對所管理電站能夠:
詳細對接細節謹以台電官方公告為準。 如對測試程式本身實作細節有疑問,請於 Issues 提問,感謝。
sudo apt update
sudo apt install docker.io
sudo apt install docker-compose
如果遇到安裝 docker 時 ubuntu 的台灣伺服器連不上,可以參考這篇
git clone https://github.com/thingnario/dreams-cloud-joint-tester.git
cd dreams-cloud-joint-tester
git submodule update --init --recursive
*.env.sample
都複製一份,並改名為 *.env
(去掉 .sample
)。然後請將裡面內容作適度更改,特別是密碼的部分。
MYSQL_ROOT_PASSWORD=top_secret # MySQL root 密碼
MYSQL_DATABASE=dreams_business # 無須更改
MYSQL_ADDRESS=mysql # 無須更改,"mysql"是docker之間的alias
ADMIN_ACCESS_TOKEN=top_secret_token # API server的API token(Admin,供測試程式本身使用)
JOINTER_ACCESS_TOKEN=site_token_for_cloud_jointer # API server的API token(雲端對接系統專用)
API_HOST=localhost # API server的host name/IP address,非本機使用時請更改
API_PORT=3000 # API server的port,有特別做port forwarding才需更改
chmod 755 deploy.sh
sudo ./deploy.sh
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
1b85aebeb5d7 dreamscloudjointtester_mq-dreams "/entrypoint.sh pyth?? About a minute ago Up 47 seconds dreamscloudjointtester_mq-dreams_1
dfbb0818bb41 dreamscloudjointtester_dnp3-master "/entrypoint.sh /dre?? About a minute ago Up 33 seconds dreamscloudjointtester_dnp3-master_1
7a9945482f8a dreamscloudjointtester_master "docker-entrypoint.s?? About a minute ago Up About a minute dreamscloudjointtester_master_1
f8ea868874dd dreamscloudjointtester_mq "docker-entrypoint.s?? About a minute ago Up About a minute dreamscloudjointtester_mq_1
dfcd177e08a3 dreamscloudjointtester_nginx "nginx -g 'daemon of?? About a minute ago Up 47 seconds dreamscloudjointtester_nginx_1
b279e48d0a0e mysql:5.7.29 "docker-entrypoint.s?? About a minute ago Up About a minute dreamscloudjointtester_mysql_1
421bddc6ef5e dreams-cloud-joint-tester-fake-modbus-server "python -m fake_slave" About a minute ago Up About a minute 0.0.0.0:502->502/tcp, :::502->502/tcp fake-modbus-server
使用 fake-modbus-server Docker 容器
可以通過以下步驟來設置並驗證 fake-modbus-server Docker 容器的連線
確認 fake-modbus-server container 有在執行
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
421bddc6ef5e dreams-cloud-joint-tester-fake-modbus-server "python -m fake_slave" About a minute ago Up About a minute 0.0.0.0:502->502/tcp, :::502->502/tcp fake-modbus-server
EMS 模擬器 Modbus Register 欄位
Address | Type | Description | R/W | Data Type | Unit | Note |
---|---|---|---|---|---|---|
21 | holding | Line Current PhaseA A相線電流 | R | int32 | 0.1A | 電表數值 |
23 | holding | Line Current PhaseB B相線電流 | R | int32 | 0.1A | 電表數值 |
25 | holding | Line Current PhaseC C相線電流 | R | int32 | 0.1A | 電表數值 |
27 | holding | Line Current PhaseN N相線電流 | R | int32 | 0.1A | 電表數值 |
29 | holding | Line Voltage Phase AB AB線電壓 | R | uint32 | 0.01V | 電表數值 併聯點電壓 (kV) 因電壓在高壓側 建議單位改為1V |
31 | holding | Line Voltage Phase BC BC線電壓 | R | uint32 | 0.01V | 電表數值 因電壓在高壓側 建議單位改為1V |
33 | holding | Line Voltage Phase AC AC線電壓 | R | uint32 | 0.01V | 電表數值 因電壓在高壓側 建議單位改為1V |
35 | holding | 實功 | R | int32 | kW | 電表數值 放電時為正值 |
37 | holding | 虛功 | R | int32 | kVar | 電表數值 |
39 | holding | 功率因數 | R | int16 | % | 並聯點 |
40 | holding | 頻率 | R | uint16 | 0.1Hz | 電表數值 |
41 | holding | 累積放電量 | R | uint32 | kWh | 電表數值 |
43 | holding | 累積充電量 | R | uint32 | kWh | 電表數值 |
45 | holding | 儲能系統狀態 | R | uint16 | 0: stand by 1: charging 2. discharging 3. error | |
46 | holding | 儲能系統電量(SOC) | R | uint16 | kWh | 儲能系統數值 |
47 | holding | 儲能系統循環使用次數(battery cycle count) | R | uint16 | 儲能系統數值 | |
48 | holding | 時間戳 | R | uint32 | unix time |
modbus_tcp_reader.py
腳本來驗證連線並獲取所需的數據。需要安裝相關 Python 模組
pip install pymodbus
腳本說明
usage: modbus_tcp_reader.py [-h] [-H HOST] [-P PORT] -U UNIT -T {di,co,ir,hr} -A ADDRESS -C COUNT
options:
-h, --help show this help message and exit
-H HOST, --host HOST the host address (default: localhost).
-P PORT, --port PORT the port number (default: 502)
-U UNIT, --unit UNIT the unit identifier (range: 1..255)
-T {di,co,ir,hr}, --table {di,co,ir,hr}
the primary table (choices: di,co,ir,hr)
-A ADDRESS, --address ADDRESS
the address to be read (range: 0..65535)
-C COUNT, --count COUNT
the count to be read (range: 1..2000 [di,co] or 1..125 [ir,hr]
此 EMS 模擬器的參數如下:
執行腳本範例
python3 modbus_tcp_reader.py -A 21 -C 27 -T hr -U 7
Namespace(host='localhost', port=502, unit=7, table='hr', address=21, count=27)
modbus client: ModbusTcpClient(localhost:502)
modbus connected: True
holding registers: ['0x0', '0xe', '0x0', '0xe', '0x0', '0xf', '0x0', '0x0', '0x11', '0xf93e', '0x11', '0xeb49', '0x11', '0xf10a', '0xffff', '0xfff1', '0x0', '0x19', '0x33', '0x258', '0x1', '0x5923', '0x0', '0xcf72', '0x0', '0xbd', '0x13']
modbus response ReadRegisterResponse (27)