From 660c85159fdee4753192eb6a66d5549df5f7bf62 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Fri, 30 Aug 2024 16:35:26 +0800 Subject: [PATCH] =?utf8?q?=E6=9B=B4=E6=96=B0=E8=A1=A8=E7=9B=98=E5=88=B6?= =?utf8?q?=E4=BD=9C=E8=84=9A=E6=9C=AC=E4=BB=A5=E5=8F=8A=E8=AF=B4=E6=98=8E?= =?utf8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../make_tools/gen_dial_bin.sh | 117 ++++++++++-------- ...77\347\224\250\350\257\264\346\230\216.md" | 35 ++++++ ...7\347\224\250\350\257\264\346\230\216.txt" | 18 --- 3 files changed, 101 insertions(+), 69 deletions(-) create mode 100644 "tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" delete mode 100644 "tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.txt" diff --git a/tools/dial_converter_tool/make_tools/gen_dial_bin.sh b/tools/dial_converter_tool/make_tools/gen_dial_bin.sh index f4d5acbc2..44c33d71b 100644 --- a/tools/dial_converter_tool/make_tools/gen_dial_bin.sh +++ b/tools/dial_converter_tool/make_tools/gen_dial_bin.sh @@ -1,54 +1,69 @@ -#!/bin/bash -### - # @Date: 2024-06-07 09:44:50 +#!/bin/bash +### +# @Date: 2024-06-07 09:44:50 # @LastEditors: Caisking 3449750381@qq.com - # @LastEditTime: 2024-07-18 16:59:20 + # @LastEditTime: 2024-08-30 15:00:54 # @FilePath: /FD230/tools/dial_converter_tool/make_tools/gen_dial_bin.sh -### - -# 返回上一级目录 -cd .. - -# 检查并创建 out 和 dial_lzma 目录 -mkdir -p out dial_lzma - -# 获取 instance 目录下的所有子目录列表 -subdirs=(instance/*/) -for subdir in "${subdirs[@]}"; do - # 提取子目录名称 - dial=$(basename "$subdir") - - # 查找子目录中的 XML 文件并提取文件名 - xml_file=$(find "$subdir" -maxdepth 1 -type f -name "*.xml" -printf "%f\n" | head -n 1) - if [ -z "$xml_file" ]; then - echo "Error: XML file not found in $subdir" - continue - fi - - # 计算文件数量和大小 - dialfilecount=$(find "$subdir" -maxdepth 1 -type f | wc -l) - dialfilesize=$(du -sh "$subdir" | awk '{print $1}') - - # 输出统计信息 - echo "Processing $dial [$dialfilecount files, $dialfilesize size]" - - # 调用 main.py 处理子目录中的文件 - if ! python main.py -dir "$subdir" -output out/; then - echo "Error processing directory $dial" - continue - fi - - # 压缩 .bin 文件到 .lzma 文件 - bin_file="out/${xml_file%.xml}.bin" - lzma_file="dial_lzma/$dial/${xml_file%.xml}.lzma" - - # 创建必要的目录 - mkdir -p "$(dirname "$lzma_file")" - - # 使用 lzma_tool 压缩文件 - if ! ../../code/sdk/tools/bin/lzma_tool/lzma_tool -d12 -lc0 -lp0 e "$bin_file" "$lzma_file"; then - echo " lzma_tool directory $dial error" - else - echo " lzma_tool directory $dial ok" - fi +### + +# 返回上一级目录 +cd .. + +# 检查并创建 out 和 dial_lzma 目录 +mkdir -p out dial_lzma + +# 检查是否传入参数 +if [ "$#" -gt 1 ]; then + echo "Usage: $0 [dial_folder]" + exit 1 +fi + +# 如果有参数,则处理指定的目录;否则处理所有子目录 +if [ "$#" -eq 1 ]; then + subdirs=("instance/$1/") + if [ ! -d "instance/$1" ]; then + echo "Error: Specified directory 'instance/$1' does not exist." + exit 1 + fi +else + subdirs=(instance/*/) +fi + +for subdir in "${subdirs[@]}"; do + # 提取子目录名称 + dial=$(basename "$subdir") + + # 查找子目录中的 XML 文件并提取文件名 + xml_file=$(find "$subdir" -maxdepth 1 -type f -name "*.xml" -printf "%f\n" | head -n 1) + if [ -z "$xml_file" ]; then + echo "Error: XML file not found in $subdir" + continue + fi + + # 计算文件数量和大小 + dialfilecount=$(find "$subdir" -maxdepth 1 -type f | wc -l) + dialfilesize=$(du -sh "$subdir" | awk '{print $1}') + + # 输出统计信息 + echo "Processing $dial [$dialfilecount files, $dialfilesize size]" + + # 调用 main.py 处理子目录中的文件 + if ! python main.py -dir "$subdir" -output out/; then + echo "Error processing directory $dial" + continue + fi + + # 压缩 .bin 文件到 .lzma 文件 + bin_file="out/${xml_file%.xml}.bin" + lzma_file="dial_lzma/$dial/${xml_file%.xml}.lzma" + + # 创建必要的目录 + mkdir -p "$(dirname "$lzma_file")" + + # 使用 lzma_tool 压缩文件 + if ! ../../code/sdk/tools/bin/lzma_tool/lzma_tool -d12 -lc0 -lp0 e "$bin_file" "$lzma_file"; then + echo " lzma_tool directory $dial error" + else + echo " lzma_tool directory $dial ok" + fi done \ No newline at end of file diff --git "a/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" "b/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" new file mode 100644 index 000000000..93c2c128e --- /dev/null +++ "b/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.md" @@ -0,0 +1,35 @@ +## 在liunx环境运行表盘脚本 + +# 1.下载对应模块 +pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow + +pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python + +pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib + +## 2.对表盘工具进行赋权限 + +chmod +x gen_dial_bin.sh +./gen_dial_bin.sh + +## 3.制作运行单个表盘 +python ./main.py -dir ./instance/1028/ -output ./out/ + +#使用lzma_tool工具需要赋权限 + chmod +x ../lzma_tool/lzma_tool + + ### 更新版本 0830 +- 制作单个表盘以及lzma文件 **./gen_dial_bin.sh + 表盘文件夹路径** + + ``` + 示例 ./gen_dial_bin.sh ../instance/114/ + ``` + +- 制作所有的表盘以及lzma文件 + + ``` + ./gen_dial_bin.sh + ``` + + + diff --git "a/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.txt" "b/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.txt" deleted file mode 100644 index b091aa46d..000000000 --- "a/tools/dial_converter_tool/make_tools/\350\241\250\347\233\230\345\210\266\344\275\234\350\204\232\346\234\254\344\275\277\347\224\250\350\257\264\346\230\216.txt" +++ /dev/null @@ -1,18 +0,0 @@ - -在liunx环境运行表盘脚本 - -#下载对应模块 -pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow - -pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python - -pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib - -chmod +x make_dial.sh -./make_dial.sh - -#制作运行单个表盘 -python ./main.py -dir ./instance/1028/ -output ./out/ - -#使用lzma_tool工具需要赋权限 - chmod +x ../lzma_tool/lzma_tool \ No newline at end of file -- 2.17.1