diff --git a/.gitignore b/.gitignore index b236644..403ed57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build release +tmp diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ffbe7..6264dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,20 @@ # 更新日志 +## v0.0.2.20240925_alpha + +**在之前写的代码基础上正式建立此项目文件,后续将在此项目上进行迭代开发** +### 🔄Changed +- 加载配置文件变更为绝对路径,会自动寻找exe文件所在文件夹的上层文件夹下的"configs/data_collection_configs.yaml"文件作为配置文件 + +### 🚀Refactored +- 将.bat文件修改为.ps1文件,即默认使用powershell编译 + - 实现"./run.ps1"直接运行build文件夹下的所有exe文件 + - 实现"./run.ps1 b"重新编译,并随后直接运行build文件夹下的所有exe文件 + - 实现"./run.ps1 p"打包编译好的文件,注意要先执行编译才能打包, 注意在CmakeList.txt文件中修改版本号 + + + ## v0.0.1.20240912_alpha **在之前写的代码基础上正式建立此项目文件,后续将在此项目上进行迭代开发** diff --git a/CMakeLists.txt b/CMakeLists.txt index 01aa1db..4e0e3dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # 指定为C++20 版本 set(CMAKE_CXX_STANDARD 20) -set(PROJ_NAME "TEST_Specim_Save") +set(PROJ_NAME "SEMS-data-collection") set(PROJ_VERSION_MAJOR 0) set(PROJ_VERSION_MINOR 0) -set(PROJ_VERSION_PATCH 1) +set(PROJ_VERSION_PATCH 2.20240927_alpha) #设置项目名字为HelloWorld project(${PROJ_NAME}) diff --git a/README.md b/README.md index 6ee2872..70a4989 100644 --- a/README.md +++ b/README.md @@ -3,23 +3,14 @@ 注意检查上层目录是否含有CompliteEnv文件夹, 以及其中依赖的编译环境 # 功能 -实现了测试光谱相机缓存机制的代码,确定了Specim FX10e相机默认的缓冲区是500帧图片 -光谱数据调取路径是,我们自己写的程序->官方驱动->通过网线从相机获取 -- 当程序读取速度大于拍摄速度时,程序会等拍摄完一帧再返回。 -- 当程序读取速度小于拍摄速度时,驱动会缓存没有及时调取的图像,然后按先进先出的原则返回最旧的一帧图像。当缓存大于500帧时,驱动会清除所有缓存,然后重新进行缓存 - -因此,如果想每时每刻都获取最新的一帧图像,只需要将缓冲区设置为2,(经过测试,设置为1会卡死,应该是不能同时操作同一个内存地址) +- 使用`/configs/data_collection_configs.yaml`文件中的参数,配置光谱相机,并持续采集数据保存到指定文件夹 # 命令手册 -- run rb : ReBuild 从头编译的命令, 适用于从来没编译过,或修改CMakeLists文件后重新编译。会先删除build文件夹,再重新编译 -- run rb e : ReBuild Execute 从头编译并执行 -- run.bat b : Build 编译,适用于已生成过Makefile且CMakeLists.txt没有变化,仅仅需要重新编译生成exe文件 -- run.bat b e : Build Execute 从头编译并执行 -- run.bat e : Execute 运行可执行文件 -- run.bat c : Clear 清理Build文件夹 -- run.bat p : Pack 打包项目 +- ./run.ps1 : 执行build文件夹下的所有exe可执行程序 +- ./run.ps1 b : ReBuild 从头编译的命令, 适用于从来没编译过,或修改CMakeLists文件后重新编译。会先删除build文件夹,再重新编译 +- ./run.ps1 p : Pack 打包项目,需先用`./run.ps1 b`编译,然后修改CMakeLists文件中的版本号 获取最新版本 http://10.8.8.8:3000/api/v1/repos/zhanpeng/SEMS-data-collection/releases/latest?token=e9aaae4b5f7756d0a2977764dbcbdfeb68bb2e13 diff --git a/configs/configs.yaml b/configs/data_collection_configs.yaml similarity index 100% rename from configs/configs.yaml rename to configs/data_collection_configs.yaml diff --git a/release/SEMS_data_collection_v0.0.1.20240911_alpha.zip b/release/SEMS_data_collection_v0.0.1.20240911_alpha.zip deleted file mode 100644 index 1664010..0000000 Binary files a/release/SEMS_data_collection_v0.0.1.20240911_alpha.zip and /dev/null differ diff --git a/run.bat b/run.bat deleted file mode 100644 index 2537e3c..0000000 --- a/run.bat +++ /dev/null @@ -1,100 +0,0 @@ -@echo off - -@REM @REM 检查环境变量 -call:check_path - -@REM 判断第一个参数是否为rb -if "%1"=="rb" ( - - @REM 判断是否存在build文件夹,若存在就删除 - call:remove_build_dir - - @REM 编译生成Makefile - cmake -B build -G "MinGW Makefiles" - @REM 编译生成可执行程序 - cmake --build build - - @REM 判断第二个参数是否为e,如果有代表要执行编译好的可执行程序 - if "%2"=="e" ( - call:run_build_exe - ) -) - -@REM run.bat b : Build 编译,适用于已生成过Makefile且CMakeLists.txt没有变化,仅仅需要重新编译生成exe文件 -@REM run.bat b e : Build Execute 从头编译并执行 - -@REM 判断第一个参数是否为rb -if "%1"=="b" ( - - - - @REM 编译生成可执行程序 - cmake --build build - - @REM 判断第二个参数是否为e,如果有代表要执行编译好的可执行程序 - if "%2"=="e" ( - call:run_build_exe - ) -) - -@REM run.bat e : Execute 运行可执行文件 -if "%1"=="e" ( - - call:run_build_exe - -) - - - - -@REM run.bat c : Clear 清理Build文件夹 -if "%1"=="c" ( - call:remove_build_dir -) - - - -@REM run.bat e : 打包 -if "%1"=="p" ( - @REM 判断是否存在build文件夹,若存在就删除 - call:remove_build_dir - @REM 编译生成Makefile - cmake -B build -G "MinGW Makefiles" - @REM 编译生成可执行程序 - cmake --build build - @REM 打包为安装包 - cmake --build build --target package -) - - -@REM 在执行完过程后加上goto :eof跳到文件尾, 避免执行到文件结束才返回 -goto :eof - - -:check_path -@REM 判断环境变量中是否存在编译所需要的文件夹,如果没有,就添加到环境变量 -set Nowdir=%cd% -cd ../CompliteEnv -call set_temp_env.bat -cd %Nowdir% -set PATH=C:\Program Files\Common Files\Pleora\eBUS SDK;%cd%\lib;%PATH% -echo PATH is seted to %PATH% -goto:eof - - -:run_build_exe -echo Starting to run EXE files in build folder... -@REM 遍历build下的exe文件,并一个一个的执行(其实编译后只有一个可执行文件) -for /f %%i in ('dir /b build\*.exe') do .\build\%%i -echo Stoped runing EXE files... -goto:eof - -:remove_build_dir - if exist build ( - rd /s /Q build - echo "The build folder has been removed." - ) else ( - echo "The build folder does not exist." - ) - -goto:eof \ No newline at end of file diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..6684b95 --- /dev/null +++ b/run.ps1 @@ -0,0 +1,67 @@ +Param($cmd) + +$Env:PATH="C:\Program Files\Common Files\Pleora\eBUS SDK;" #开发光谱相机所必需的路径 +$Env:PATH+="C:\Program Files\Git\cmd;" #开发所需的git命令的路径 +$Env:PATH+=(Resolve-Path ../CompliteEnv/mingw64/bin).path+";" #g++所在路径 +$Env:PATH+=(Resolve-Path ../CompliteEnv/CMake/bin).path+";" #cmake所在路径 +$Env:PATH+=(Resolve-Path ./lib).path+";" #本项目所需的动态链接库所在路径 + +Write-Host "PATH is set to $Env:PATH" + + +function Remove-Build-Dir +{ + If(Test-Path "build"){ #如果当前目录下build文件夹存在 + Remove-Item -Path "build" -Recurse #递归阐述build文件夹 + } + +} + + +function ReBuild-Target +{ + # 编译生成Makefile + cmake -B build -G "MinGW Makefiles" + # 编译生成可执行程序 + cmake --build build +} + + +function Run-All-Exe +{ + $exeFiles= Get-ChildItem -Path "build" -Filter *.exe + + Write-Host "Exe Files: $exeFiles" + ForEach($exeFile in $exeFiles){ + Write-Host "Processing file: $($exeFile.FullName)" + Start-Process -Wait -FilePath $exeFile.FullName -PassThru + } +} + + + + + +If($cmd -eq "b"){ + Write-Host "Rebuilding all targets..." + + Remove-Build-Dir + + ReBuild-Target + + Run-All-Exe +} + + +If($cmd -eq "p"){ + Write-Host "Packing all targets..." + cmake --build build --target package +} + +If([String]::IsNullOrEmpty($cmd)){ #如果没有任何参数就运行所有exe + Run-All-Exe +} + + + + diff --git a/src/main.cpp b/src/main.cpp index f3fabcb..1f7242f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,7 +14,7 @@ #include #include "visible_light_camera.h" - +#include #include @@ -64,7 +64,22 @@ int check_update_file_handle(std::string save_dir, std::ofstream &h_raw_spectal_ int main() { // std::cout << "Hello" << std::endl; - YAML::Node configs = YAML::LoadFile("./configs/configs.yaml"); + + char szPath[512] = {0}; + GetModuleFileName(NULL, szPath, sizeof(szPath)-1); + std::string exe_dir(szPath); + + //这里返回的是exe文件的完整路径,包括文件名,所以下面执行两边,就是先取出exe文件名,再去除exe所在文件夹 + //即实现找到exe所在文件夹的上层文件夹的绝对路径 + size_t lastSlashIndex = exe_dir.find_last_of('\\'); + exe_dir=exe_dir.substr(0,lastSlashIndex); //+1是为了也包含最后一个反斜杠 + lastSlashIndex = exe_dir.find_last_of('\\'); + exe_dir=exe_dir.substr(0,lastSlashIndex+1); //+1是为了也包含最后一个反斜杠 + + + std::cout << "Configs file path is " <listDevices();