更新表盘制作脚本以及说明文档
authorCaisking <3449750381@qq.com>
Fri, 30 Aug 2024 08:35:26 +0000 (16:35 +0800)
committerCaisking <3449750381@qq.com>
Fri, 30 Aug 2024 08:35:26 +0000 (16:35 +0800)
tools/dial_converter_tool/make_tools/gen_dial_bin.sh
tools/dial_converter_tool/make_tools/表盘制作脚本使用说明.md [new file with mode: 0644]
tools/dial_converter_tool/make_tools/表盘制作脚本使用说明.txt [deleted file]

index f4d5acb..44c33d7 100644 (file)
@@ -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/表盘制作脚本使用说明.md b/tools/dial_converter_tool/make_tools/表盘制作脚本使用说明.md
new file mode 100644 (file)
index 0000000..93c2c12
--- /dev/null
@@ -0,0 +1,35 @@
+## 在liunx环境运行表盘脚本\r
+\r
+# 1.下载对应模块\r
+pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow\r
+\r
+pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python\r
+\r
+pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib\r
+\r
+## 2.对表盘工具进行赋权限\r
+\r
+chmod +x gen_dial_bin.sh\r
+./gen_dial_bin.sh\r
+\r
+## 3.制作运行单个表盘\r
+python ./main.py -dir ./instance/1028/ -output ./out/\r
+\r
+#使用lzma_tool工具需要赋权限\r
+ chmod +x ../lzma_tool/lzma_tool\r
+\r
+ ### 更新版本 0830\r
+- 制作单个表盘以及lzma文件   **./gen_dial_bin.sh + 表盘文件夹路径**\r
+\r
+  ```\r
+     示例  ./gen_dial_bin.sh ../instance/114/\r
+  ```\r
+\r
+- 制作所有的表盘以及lzma文件\r
+\r
+  ```\r
+      ./gen_dial_bin.sh\r
+  ```\r
+\r
+  \r
+\r
diff --git a/tools/dial_converter_tool/make_tools/表盘制作脚本使用说明.txt b/tools/dial_converter_tool/make_tools/表盘制作脚本使用说明.txt
deleted file mode 100644 (file)
index b091aa4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-\r
-在liunx环境运行表盘脚本\r
-\r
-#下载对应模块\r
-pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Pillow\r
-\r
-pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python\r
-\r
-pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib\r
-\r
-chmod +x make_dial.sh\r
-./make_dial.sh\r
-\r
-#制作运行单个表盘\r
-python ./main.py -dir ./instance/1028/ -output ./out/\r
-\r
-#使用lzma_tool工具需要赋权限\r
- chmod +x ../lzma_tool/lzma_tool
\ No newline at end of file