99个文件已添加
43个文件已修改
5个文件已删除
3369 ■■■■■ 已修改文件
README.md 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/ExportEnv.bat 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/JustDoubleClickMe.bat 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/SettingEnv.bat 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/aerial.tar.gz 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Babel-2.10.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Flask-2.1.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Jinja2-3.1.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Pygments-2.12.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Send2Trash-1.8.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/Werkzeug-2.1.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/anyio-3.6.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/argon2_cffi-21.3.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/asttokens-2.0.5-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/attrs-21.4.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/backcall-0.2.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/beautifulsoup4-4.11.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/bitarray-2.5.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/bleach-5.0.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/certifi-2022.6.15-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/cffi-1.15.0-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/charset_normalizer-2.0.12-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/click-8.1.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/colorama-0.4.5-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/debugpy-1.6.0-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/decorator-5.1.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/defusedxml-0.7.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/deprecation-2.1.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/entrypoints-0.4-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/executing-0.8.3-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/fastjsonschema-2.15.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/idna-3.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/importlib_metadata-4.11.4-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/ipykernel-6.15.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/ipython-8.4.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/ipython_genutils-0.2.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/ipywidgets-7.7.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/itsdangerous-2.1.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jedi-0.18.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/json5-0.9.8.tar.gz 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jsonschema-4.6.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyter_client-7.3.4-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyter_core-4.10.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyter_packaging-0.12.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyter_server-1.17.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyterlab-3.4.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyterlab_pygments-0.2.2-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyterlab_server-2.14.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/jupyterlab_widgets-1.1.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/matplotlib_inline-0.1.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/mistune-0.8.4-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/nbclassic-0.3.7-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/nbclient-0.6.4-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/nbconvert-6.5.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/nbformat-5.4.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/nest_asyncio-1.5.5-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/notebook-6.4.12-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/notebook_shim-0.1.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/numpy-1.23.0-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/open3d-0.14.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/opencv_python-4.6.0.66-cp36-abi3-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/packaging-21.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pandocfilters-1.5.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/parso-0.8.3-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pickleshare-0.7.5-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pika-1.2.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/prometheus_client-0.14.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/prompt_toolkit-3.0.29-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/protobuf-4.21.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/protoc_wheel_0-21.1-py2.py3-none-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/psutil-5.9.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pure_eval-0.2.2-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pycparser-2.21-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pyparsing-3.0.9-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pyrsistent-0.18.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pyserial-3.5-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/python_dateutil-2.8.2-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pytz-2022.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pywin32-304-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pywinpty-2.0.5-cp39-none-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/pyzmq-23.2.0-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/requests-2.28.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/setuptools-62.6.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/six-1.16.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/sniffio-1.2.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/soupsieve-2.3.2.post1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/stack_data-0.3.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/terminado-0.15.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/tinycss2-1.1.1-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/tomlkit-0.11.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/tornado-6.1-cp39-cp39-win_amd64.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/tqdm-4.64.0-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/traitlets-5.3.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/urllib3-1.26.9-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/wcwidth-0.2.5-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/webencodings-0.5.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/websocket_client-1.3.3-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/wheel-0.37.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/widgetsnbextension-3.6.1-py2.py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
env/requirements/zipp-3.8.0-py3-none-any.whl 补丁 | 查看 | 原始文档 | blame | 历史
requirements.txt 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts/mqClient.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts/mqServer.py 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_Slam.bat 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_SlamAuto.bat 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_bin2ply.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_ply_show.bat 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_startClient.bat 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_startServer.bat 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_udp2bin.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_udp2ply.bat 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_udp_get.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/bin2ply.bat 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/ply_show.bat 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/startClient.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/startServer.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/udp2bin.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/udp2ply.bat 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/udp_get.bat 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Server.py 289 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Server1.py 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/__init__.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/AcquisitionMain.py 428 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/CaptureThread.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/ControllThread.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/DustCleanerThread.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/MessageQueueThread.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/MessageThreads.py 947 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/Microwave.py 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/__init__.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/devices.py 294 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/__init__.py 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/demo/AutoGetUDP.bat 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/demo/AutoGetUDPtest.bat 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/demo/AutoSendAndGetTest.bat 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/demo/AutoSendUDPtest.bat 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/deviceTools.py 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/parsers.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/microwave/servers.py 187 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/protos/aerial.proto 257 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/protos/compile.bat 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/requirements.yaml 149 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/slam/__init__.py 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/__init__.py 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/tools.py 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
@@ -5,4 +5,30 @@
1. 根据proto数据结构,重新优化src\engine\MessageThreads.py的相关内容;
2. 采集端:修改src\engine\devices.py内的相机的数据采集线程;
3. 服务端:增加图像数据的消息解析;
4. src\engine\MessageThreads.py内添加数据发送和接收线程。
4. src\engine\MessageThreads.py内添加数据发送和接收线程。
## MQ keys
🎈Given that the name parameters of one couple of the server and client is set to as below shown:
🚩server name : `server0`
🚩client name : `bunker0.block0.device0`
1. Server:
    > Binding keys for receive messages from clients are shown below:
    >> `server0.logs.test0`
    >> `server0.images.test0`
    >> `server0.plys.test0`
    > Routing keys for send commands to the client are shown below:
    >> `bunker0.block0.device0`
2. Client:
    > Binding keys for receive commands from the server are shown below:
    >> `bunker0.block0.device0`
    > Routing keys for send messages to the server are shown below:
    >> `server0.logs.test0`
    >> `server0.images.test0`
    >> `server0.plys.test0`
env/ExportEnv.bat
File was deleted
env/JustDoubleClickMe.bat
File was deleted
env/SettingEnv.bat
@@ -2,31 +2,26 @@
@REM change to the filepath
cd %~dp0
@REM echo change to path: %cd%
if exist ../../aerial_deploy (
    echo the folder aerial_deploy is exited, removing it ...
    rmdir /S /Q "../../aerial_deploy"
    echo remove done!
)
cd ..
git lfs install
git lfs pull
@REM create the virtual env for this project
@REM please make sure your machine have installed a
@REM python with global env variable or select it by yourself.
cd %~dp0
mkdir "../../aerial_deploy"
python -m venv "../.env"
echo setting the env ...
tar -xzf "./aerial.tar.gz" -C "../../aerial_deploy"
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
if not exist ".env" (
    mklink /j ".env" "../aerial_deploy/")
@REM install some packages
python -m pip install --no-index -f "requirements" -r "../requirements.txt"
echo #####################################################################
python -c "import cv2, pika, flask; print('Hello World! The env is ready!')"
cd %~dp0
call "../src/protos/compile.bat"
echo ALL DONE!
echo =========== ALL DONE ================
echo Press any key to exit this windiow.
pause
env/aerial.tar.gz
File was deleted
env/requirements/Babel-2.10.3-py3-none-any.whl
Binary files differ
env/requirements/Flask-2.1.2-py3-none-any.whl
Binary files differ
env/requirements/Jinja2-3.1.2-py3-none-any.whl
Binary files differ
env/requirements/MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/Pygments-2.12.0-py3-none-any.whl
Binary files differ
env/requirements/Send2Trash-1.8.0-py3-none-any.whl
Binary files differ
env/requirements/Werkzeug-2.1.2-py3-none-any.whl
Binary files differ
env/requirements/anyio-3.6.1-py3-none-any.whl
Binary files differ
env/requirements/argon2_cffi-21.3.0-py3-none-any.whl
Binary files differ
env/requirements/argon2_cffi_bindings-21.2.0-cp36-abi3-win_amd64.whl
Binary files differ
env/requirements/asttokens-2.0.5-py2.py3-none-any.whl
Binary files differ
env/requirements/attrs-21.4.0-py2.py3-none-any.whl
Binary files differ
env/requirements/backcall-0.2.0-py2.py3-none-any.whl
Binary files differ
env/requirements/beautifulsoup4-4.11.1-py3-none-any.whl
Binary files differ
env/requirements/bitarray-2.5.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/bleach-5.0.0-py3-none-any.whl
Binary files differ
env/requirements/certifi-2022.6.15-py3-none-any.whl
Binary files differ
env/requirements/cffi-1.15.0-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/charset_normalizer-2.0.12-py3-none-any.whl
Binary files differ
env/requirements/click-8.1.3-py3-none-any.whl
Binary files differ
env/requirements/colorama-0.4.5-py2.py3-none-any.whl
Binary files differ
env/requirements/debugpy-1.6.0-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/decorator-5.1.1-py3-none-any.whl
Binary files differ
env/requirements/defusedxml-0.7.1-py2.py3-none-any.whl
Binary files differ
env/requirements/deprecation-2.1.0-py2.py3-none-any.whl
Binary files differ
env/requirements/entrypoints-0.4-py3-none-any.whl
Binary files differ
env/requirements/executing-0.8.3-py2.py3-none-any.whl
Binary files differ
env/requirements/fastjsonschema-2.15.3-py3-none-any.whl
Binary files differ
env/requirements/idna-3.3-py3-none-any.whl
Binary files differ
env/requirements/importlib_metadata-4.11.4-py3-none-any.whl
Binary files differ
env/requirements/ipykernel-6.15.0-py3-none-any.whl
Binary files differ
env/requirements/ipython-8.4.0-py3-none-any.whl
Binary files differ
env/requirements/ipython_genutils-0.2.0-py2.py3-none-any.whl
Binary files differ
env/requirements/ipywidgets-7.7.1-py2.py3-none-any.whl
Binary files differ
env/requirements/itsdangerous-2.1.2-py3-none-any.whl
Binary files differ
env/requirements/jedi-0.18.1-py2.py3-none-any.whl
Binary files differ
env/requirements/json5-0.9.8.tar.gz
New file
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0fa6e4d3ef062f93ba9cf2a9103fe8e68c7917dfa33519ae3ac8c7e48e3c84ff
size 22562
env/requirements/jsonschema-4.6.0-py3-none-any.whl
Binary files differ
env/requirements/jupyter_client-7.3.4-py3-none-any.whl
Binary files differ
env/requirements/jupyter_core-4.10.0-py3-none-any.whl
Binary files differ
env/requirements/jupyter_packaging-0.12.2-py3-none-any.whl
Binary files differ
env/requirements/jupyter_server-1.17.1-py3-none-any.whl
Binary files differ
env/requirements/jupyterlab-3.4.3-py3-none-any.whl
Binary files differ
env/requirements/jupyterlab_pygments-0.2.2-py2.py3-none-any.whl
Binary files differ
env/requirements/jupyterlab_server-2.14.0-py3-none-any.whl
Binary files differ
env/requirements/jupyterlab_widgets-1.1.1-py3-none-any.whl
Binary files differ
env/requirements/matplotlib_inline-0.1.3-py3-none-any.whl
Binary files differ
env/requirements/mistune-0.8.4-py2.py3-none-any.whl
Binary files differ
env/requirements/nbclassic-0.3.7-py3-none-any.whl
Binary files differ
env/requirements/nbclient-0.6.4-py3-none-any.whl
Binary files differ
env/requirements/nbconvert-6.5.0-py3-none-any.whl
Binary files differ
env/requirements/nbformat-5.4.0-py3-none-any.whl
Binary files differ
env/requirements/nest_asyncio-1.5.5-py3-none-any.whl
Binary files differ
env/requirements/notebook-6.4.12-py3-none-any.whl
Binary files differ
env/requirements/notebook_shim-0.1.0-py3-none-any.whl
Binary files differ
env/requirements/numpy-1.23.0-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/open3d-0.14.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/opencv_python-4.6.0.66-cp36-abi3-win_amd64.whl
Binary files differ
env/requirements/packaging-21.3-py3-none-any.whl
Binary files differ
env/requirements/pandocfilters-1.5.0-py2.py3-none-any.whl
Binary files differ
env/requirements/parso-0.8.3-py2.py3-none-any.whl
Binary files differ
env/requirements/pickleshare-0.7.5-py2.py3-none-any.whl
Binary files differ
env/requirements/pika-1.2.1-py2.py3-none-any.whl
Binary files differ
env/requirements/prometheus_client-0.14.1-py3-none-any.whl
Binary files differ
env/requirements/prompt_toolkit-3.0.29-py3-none-any.whl
Binary files differ
env/requirements/protobuf-4.21.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/protoc_wheel_0-21.1-py2.py3-none-win_amd64.whl
Binary files differ
env/requirements/psutil-5.9.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/pure_eval-0.2.2-py3-none-any.whl
Binary files differ
env/requirements/pycparser-2.21-py2.py3-none-any.whl
Binary files differ
env/requirements/pyparsing-3.0.9-py3-none-any.whl
Binary files differ
env/requirements/pyrsistent-0.18.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/pyserial-3.5-py2.py3-none-any.whl
Binary files differ
env/requirements/python_dateutil-2.8.2-py2.py3-none-any.whl
Binary files differ
env/requirements/pytz-2022.1-py2.py3-none-any.whl
Binary files differ
env/requirements/pywin32-304-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/pywinpty-2.0.5-cp39-none-win_amd64.whl
Binary files differ
env/requirements/pyzmq-23.2.0-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/requests-2.28.0-py3-none-any.whl
Binary files differ
env/requirements/setuptools-62.6.0-py3-none-any.whl
Binary files differ
env/requirements/six-1.16.0-py2.py3-none-any.whl
Binary files differ
env/requirements/sniffio-1.2.0-py3-none-any.whl
Binary files differ
env/requirements/soupsieve-2.3.2.post1-py3-none-any.whl
Binary files differ
env/requirements/stack_data-0.3.0-py3-none-any.whl
Binary files differ
env/requirements/terminado-0.15.0-py3-none-any.whl
Binary files differ
env/requirements/tinycss2-1.1.1-py3-none-any.whl
Binary files differ
env/requirements/tomlkit-0.11.0-py3-none-any.whl
Binary files differ
env/requirements/tornado-6.1-cp39-cp39-win_amd64.whl
Binary files differ
env/requirements/tqdm-4.64.0-py2.py3-none-any.whl
Binary files differ
env/requirements/traitlets-5.3.0-py3-none-any.whl
Binary files differ
env/requirements/urllib3-1.26.9-py2.py3-none-any.whl
Binary files differ
env/requirements/wcwidth-0.2.5-py2.py3-none-any.whl
Binary files differ
env/requirements/webencodings-0.5.1-py2.py3-none-any.whl
Binary files differ
env/requirements/websocket_client-1.3.3-py3-none-any.whl
Binary files differ
env/requirements/wheel-0.37.1-py2.py3-none-any.whl
Binary files differ
env/requirements/widgetsnbextension-3.6.1-py2.py3-none-any.whl
Binary files differ
env/requirements/zipp-3.8.0-py3-none-any.whl
Binary files differ
requirements.txt
New file
@@ -0,0 +1,10 @@
numpy==1.23.0
Flask==2.1.2
pika==1.2.1
protobuf==4.21.1
tqdm==4.64.0
opencv-python==4.6.0.66
pyserial==3.5
bitarray==2.5.1
protoc-wheel-0==21.1
open3d==0.14.1
scripts/mqClient.py
@@ -8,7 +8,7 @@
from src.engine.AcquisitionMain import AcquisitionMain
from src.engine.AcquisitionMain import Config
# from src.engine.AcquisitionMain import Config
def quit(signum, frame):
    print('You choose to stop me.')
@@ -20,16 +20,14 @@
        print("EXAMPLE: Client.py 172.17.17.206 chai password123 aerial_rpc pod1 http://172.17.17.206/api 192.168.2.65")
        exit(1)
    if len(sys.argv) != 8:
    if len(sys.argv) != 6:
        help()
    try:
        MQhost = str(sys.argv[1])
        MQuser = str(sys.argv[2])
        MQpassword = str(sys.argv[3])
        QUEUEname = str(sys.argv[4])
        DEVICEname = str(sys.argv[5])
        SERVERhost = str(sys.argv[6])
        MICROWAVEhost = str(sys.argv[7])
        DEVICEname = str(sys.argv[4])
        MICROWAVEhost = str(sys.argv[5])
    except Exception as e:
        print(e)
@@ -40,15 +38,13 @@
    signal.signal(signal.SIGTERM, quit)
    # client = AcquisitionMain('192.168.3.54', 'chai',
    #                       'password123', 'aerial_rpc', 'pod1', 'http://192.168.3.54:5000/api', 10)
    config_dir = os.path.join(__file__, "..",  "../src/config.json" )
    config_path = os.path.abspath(config_dir)
    config = Config(config_path)
    # config_dir = os.path.join(__file__, "..",  "../src/config.json" )
    # config_path = os.path.abspath(config_dir)
    # config = Config(config_path)
    client = AcquisitionMain(MQhost,
                             MQuser,
                             MQpassword, 
                             QUEUEname,
                             DEVICEname, 
                             SERVERhost,
                             MICROWAVEhost, # udp server host, 192.168.2.65 for production
                             config)
                            )
    client.start()
scripts/mqServer.py
@@ -8,26 +8,31 @@
from src.Server import MyServer
if __name__ == "__main__":
    def help():
        print("Usage: Server.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [WEBport] [SAVEfolder]")
        print("EXAMPLE: Server.py localhost chai password123 aerial_rpc 5000 ./Images")
        exit(1)
    if len(sys.argv) != 7:
    if len(sys.argv) != 8:
        help()
    try:
        MQhost = str(sys.argv[1])
        MQuser = str(sys.argv[2])
        MQpassword = str(sys.argv[3])
        QUEUEname = str(sys.argv[4])
        WEBhost = str(sys.argv[4])
        WEBport = int(sys.argv[5])
        SAVEfolder = str(sys.argv[6])
        save_folder = SAVEfolder
        save_folder = str(sys.argv[6])
        server_name = str(sys.argv[7])
    except Exception as e:
        print(e)
        help()
    server = MyServer(host=MQhost, user=MQuser, password=MQpassword, queue=QUEUEname, port=WEBport, SAVEfolder=save_folder)
    server = MyServer(MQhost=MQhost,
                    MQuser=MQuser,
                    MQpassword=MQpassword,
                    WEBhost=WEBhost,
                    WEBport=WEBport,
                    save_folder=save_folder,
                    server_name=server_name)
    server.run_all()
scripts_launch/TEST_Slam.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM set folder=T:\\Data\\projects\\huaneng\\00_Docs\\slamtest
@@ -43,9 +35,9 @@
if %choice% == y (
    %aerialpython% ./scripts/slamManualMode.py %folder% %alpha% %beta% %gamma% %savename%
    python ./scripts/slamManualMode.py %folder% %alpha% %beta% %gamma% %savename%
    @REM -------------- Usage: plot_ply.py [PLYfile]"
    %aerialpython% ./scripts/plot_ply.py %PLYfile%
    python ./scripts/plot_ply.py %PLYfile%
) else (
    echo you choose stop!
    exit
scripts_launch/TEST_SlamAuto.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM pre-defined parameters
@@ -64,9 +56,9 @@
if %choice% == y (
    %aerialpython% ./scripts/slamAutoMode.py %servo_path% %port% %speed% %degree_step% %time_delay% %alpha% %beta% %gamma% %microwaveHost% %udp_packets% %deviceName% %saveFolder%
    python ./scripts/slamAutoMode.py %servo_path% %port% %speed% %degree_step% %time_delay% %alpha% %beta% %gamma% %microwaveHost% %udp_packets% %deviceName% %saveFolder%
    @REM -------------- Usage: plot_ply.py [PLYfile]"
    %aerialpython% ./scripts/plot_ply.py %PLYfile%
    python ./scripts/plot_ply.py %PLYfile%
) else (
    echo you choose stop!
    exit
scripts_launch/TEST_bin2ply.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
echo [the folder example]: ./slamdata/
@@ -21,5 +13,5 @@
@REM ---------------Usage: bin2ply.py [BINfolder]
%aerialpython% ./scripts/bin2ply.py %BINfolder%
python ./scripts/bin2ply.py %BINfolder%
pause
scripts_launch/TEST_ply_show.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set PLYfile=./test60120.ply
scripts_launch/TEST_startClient.bat
@@ -2,25 +2,18 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set MQhost=localhost
@REM set MQhost=localhost
set MQhost=47.92.33.19
set MQuser=chai
set MQpassword=password123
set QUEUEname=aerial_rpc
set DEVICEname=pod1
set DEVICEname=bunker0.block0.device0
set SERVERhost=http://192.168.1.224/api
set MICROWAVEhost=localhost
set LOGfile=ClientTEST.log
@@ -30,6 +23,6 @@
echo Client.py is running ...
@REM -------- Usage: Client.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [DEVICEname] [SERVERhost] [MICROWAVEhost]
@REM %aerialpython% ./src/Client.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost% >> %LOGfile%
%aerialpython% ./scripts/mqClient.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost%
python ./scripts/mqClient.py %MQhost% %MQuser% %MQpassword% %DEVICEname% %MICROWAVEhost%
echo Client.py has been terminited.
pause
scripts_launch/TEST_startServer.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM set MQhost=localhost
@@ -22,14 +14,15 @@
set MQpassword=password123
set WEBhost=0.0.0.0
set WEBport=5000
set SAVEfolder=./Received_data_testing
set SAVEfolder=./data/server0/
set SERVERname=server0
set LOGfile=ServerTEST.log
@REM Launch the Server
echo the log file will be saved in the [%LOGfile%] file
echo Server.py is running ...
@REM -------- Usage: Server.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [WEBport] [SAVEfolder]")
%aerialpython% ./scripts/mqServer.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %WEBport% %SAVEfolder%
python ./scripts/mqServer.py %MQhost% %MQuser% %MQpassword% %WEBhost% %WEBport% %SAVEfolder% %SERVERname%
echo Server.py has been terminited.
pause
scripts_launch/TEST_udp2bin.bat
@@ -2,23 +2,15 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
echo [the UDP folder example]: ./slamdata/60/
set /p UDPfolder=Please input the UDP folder:
@REM ---------------Usage: udp2bin.py [UDPfolder]
%aerialpython% ./scripts/udp2bin.py %UDPfolder%
python ./scripts/udp2bin.py %UDPfolder%
pause
scripts_launch/TEST_udp2ply.bat
@@ -2,25 +2,17 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
echo [the UDP folder example]: ./slamdata/60/
set /p UDPfolder=Please input the UDP folder:
@REM ---------------Usage: udp2bin.py [UDPfolder]
%aerialpython% ./scripts/udp2bin.py %UDPfolder%
python ./scripts/udp2bin.py %UDPfolder%
@REM ---------------Usage: bin2ply.py [BINfolder]
%aerialpython% ./scripts/bin2ply.py %UDPfolder%
python ./scripts/bin2ply.py %UDPfolder%
pause
scripts_launch/TEST_udp_get.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set MICROWAVEhost=192.168.2.65
@@ -29,5 +21,5 @@
set folder=./%SAVEfolder%/%SUBfolder%/
echo the udp data will be saved in folder %folder%
@REM ---------------Usage: udp_get.py [MICROWAVEhost] [PACKETthreshold] [DEVICEname] [SAVEfolder]
%aerialpython% ./scripts/udp_get.py %MICROWAVEhost% %PACKETthreshold% %DEVICEname% %SAVEfolder% %SUBfolder%
python ./scripts/udp_get.py %MICROWAVEhost% %PACKETthreshold% %DEVICEname% %SAVEfolder% %SUBfolder%
pause
scripts_launch/bin2ply.bat
@@ -2,23 +2,14 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM please the folder path of the bin files.
@REM set BINfolder=./Manual_Microwave/pod1-2012-12-12-12-12-12/
@REM add vitrual env python to the path
path ".env/Scripts/";%path%
@REM ---------------Usage: bin2ply.py [BINfolder]
%aerialpython% ./scripts/bin2ply.py %BINfolder%
python ./scripts/bin2ply.py %BINfolder%
pause
scripts_launch/ply_show.bat
@@ -2,22 +2,11 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM please the folder path of the bin files.
@REM set PLYfile=./Manual_Microwave/pod1-2022-02-21-15-34-45/2522.ply
@REM -------------- Usage: plot_ply.py [PLYfile]"
%aerialpython% ./scripts/plot_ply.py %PLYfile%
python ./scripts/plot_ply.py %PLYfile%
pause
scripts_launch/startClient.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set MQhost=172.17.17.206
@@ -29,6 +21,6 @@
echo the log file will be saved in the [%LOGfile%] file
echo Client.py is running ...
@REM -------- Usage: Client.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [DEVICEname] [SERVERhost] [MICROWAVEhost]
%aerialpython% ./src/Client.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost% >> %LOGfile%
python ./src/Client.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost% >> %LOGfile%
echo Client.py has been terminited.
pause 
scripts_launch/startServer.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set MQhost=172.17.17.206
@@ -28,7 +20,7 @@
echo the log file will be saved in the [%LOGfile%] file
echo Server.py is running ...
@REM -------- Usage: Server.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [WEBport] [SAVEfolder]")
%aerialpython% ./src/Server.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %WEBport% %SAVEfolder% >> >> %LOGfile%
python ./src/Server.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %WEBport% %SAVEfolder% >> >> %LOGfile%
echo Server.py has been terminited.
pause
scripts_launch/udp2bin.bat
@@ -2,23 +2,15 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM please the folder path of the udp files.
@REM set UDPfolder=./Manual_Microwave/pod1-2012-12-12-12-12-12/
@REM ---------------Usage: udp2bin.py [UDPfolder]
%aerialpython% ./scripts/udp2bin.py %UDPfolder%
python ./scripts/udp2bin.py %UDPfolder%
pause
scripts_launch/udp2ply.bat
@@ -2,25 +2,17 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
@REM please the folder path of the udp files.
@REM set UDPfolder=./Manual_Microwave/pod1-2012-12-12-12-12-12/
@REM ---------------Usage: udp2bin.py [UDPfolder]
%aerialpython% ./scripts/udp2bin.py %UDPfolder%
python ./scripts/udp2bin.py %UDPfolder%
@REM ---------------Usage: bin2ply.py [BINfolder]
%aerialpython% ./scripts/bin2ply.py %UDPfolder%
python ./scripts/bin2ply.py %UDPfolder%
pause
scripts_launch/udp_get.bat
@@ -2,18 +2,10 @@
@REM change to the filepath
cd %~dp0
@REM add vitrual env python to the path
path "%~dp0/../.env/Scripts/";%path%
cd ..
set aerialpython=%cd%/.env/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
cd %~dp0
cd ..
echo change to path: %cd%
set MICROWAVEhost=192.168.2.65
@@ -21,5 +13,5 @@
SET DEVICEname=pod1
SET SAVEfolder=./Manual_Microwave
@REM ---------------Usage: udp_get.py [MICROWAVEhost] [PACKETthreshold] [DEVICEname] [SAVEfolder]
%aerialpython% ./scripts/udp_get.py %MICROWAVEhost% %PACKETthreshold% %DEVICEname% %SAVEfolder%
python ./scripts/udp_get.py %MICROWAVEhost% %PACKETthreshold% %DEVICEname% %SAVEfolder%
pause
src/Server.py
@@ -1,175 +1,208 @@
import sys              # NOQA: E402    
import os
from flask import Flask
from numpy import true_divide
from flask import Flask, request
import pika
import uuid
import queue
from werkzeug.wrappers import request
from threading import Thread
from datetime import datetime
from zmq import device
from .engine.DeviceManager import DeviceManager
from .engine.MessageQueueThread import MessageQueueThread
from .engine import MessageThreads as ths
from .protos import aerial_pb2 as pb
from .utils.tools import update_folder_for_today
class MyServer(Flask):
    def __init__(self, host, user, password, queue, port, SAVEfolder):
    def __init__(self,
                MQhost:str,
                MQuser:str,
                MQpassword:str,
                WEBhost:str,
                WEBport:int,
                save_folder:str,
                server_name:str
                ):
        Flask.__init__(self, __name__)
        self.host = host
        self.user = user
        self.password = password
        self.queue = queue
        self.port = port
        global save_folder
        save_folder = SAVEfolder
        self.MQhost = MQhost
        self.MQuser = MQuser
        self.MQpassword = MQpassword
        self.WEBhost = WEBhost
        self.WEBport = WEBport
        self.save_folder = save_folder
        self.server_name = server_name
        self.replay_host = "http://192.168.1.17:8001/admin/business/colletmeta/getDeviceMsg"
        today = datetime.now().strftime('%Y-%m-%d')
        today_folder = os.path.join(self.save_folder,today)
        self.today = {"today":today,
                    "today_folder":today_folder,
                    "sup_folder":self.save_folder,
                    "sub_folder": ""}
        self.task_uuid_folder = {"init":os.path.join(self.today["today_folder"],"init")}
        if not os.path.exists(self.task_uuid_folder["init"]):
            os.makedirs(self.task_uuid_folder["init"])
        self.route('/api', methods=['POST'])(self.api)
        self.route('/', methods=['GET'])(self.hello)
        self._def_routes()
        # threads
        self._device_state_reveiver_thread = None
        self._alarm_state_receiver_thread = None
        self._command_request_sender_thread = None
        self._command_response_receiver_thread = None
        # self._def_routes()
        # queue
        self.command_request_queue = queue.Queue()
        self.LogsReceiver_queue = queue.Queue()
        self.ImagesReceiver_queue = queue.Queue()
        self.PlysReceiver_queue = queue.Queue()
        self.CommandsSender_queue = queue.Queue()
    def _connect_to_MQ(self):
        credentials = pika.PlainCredentials(self.MQuser, self.MQpassword)
        self.parameters = pika.ConnectionParameters(
            credentials=credentials, host=self.MQhost)
            credentials=credentials, host=self.MQhost,heartbeat=0)
        # 连接队列服务器
        self.connection = pika.BlockingConnection(self.parameters)
        print(f"connected to MQ server: {self.MQhost} with user {self.MQuser}")
        try:
            self.connection = pika.BlockingConnection(self.parameters)
            print(f"connected to MQ server: {self.MQhost} with user {self.MQuser}")
            self.connection.close()
        except Exception :
            print("Can't connecting to the MQ server")
            exit(1)
    def _start_device_state_up_msg_receiver_thread(self):
        """start device state thread"""
        if self._device_state_reveiver_thread is None:
            self._device_state_reveiver_thread = \
                ths.device_state_receiverThread(self.parameters,"server")
            self._device_state_reveiver_thread.setDaemon(True)
            self._device_state_reveiver_thread.start()
    def _stop_device_state_up_msg_receiver_thread(self):
        """stop device state thread"""
        if self._device_state_reveiver_thread is not None:
            self._device_state_reveiver_thread.stop()
            self._device_state_reveiver_thread = None
    def _start_alarm_state_up_msg_receiver_thread(self):
        """start alarm state thread"""
        if self._alarm_state_receiver_thread is None:
            self._alarm_state_receiver_thread = \
                ths.alarm_state_receiverThread(self.parameters,"server")
            self._alarm_state_receiver_thread.setDaemon(True)
            self._alarm_state_receiver_thread.start()
    def _receiver_Thread_Launcher(self):
    def _stop_alarm_state_up_msg_receiver_thread(self):
        """stop alarm state thread"""
        if self._alarm_state_receiver_thread is not None:
            self._alarm_state_receiver_thread.stop()
            self._alarm_state_receiver_thread = None
        # launch logs receiver thread
        self.LogsReceiver_Thread = ths.receiverThread(
                                    MQparams=self.parameters,
                                    exchange_name='logs_topic',
                                    exchange_type='topic',
                                    MQqueue_name=f'{self.server_name}_logs_queue',
                                    binding_keys=[f'{self.server_name}.logs.test0'],
                                    message_queue=self.LogsReceiver_queue
                                    )
        self.LogsReceiver_Thread.setDaemon(True)
        self.LogsReceiver_Thread.setName("Thread-logsReceiver")
        self.LogsReceiver_Thread.start()
    def _start_command_response_receiver_thread(self):
        """start command response thread"""
        if self._command_response_receiver_thread is None:
            self._command_response_receiver_thread = \
                ths.command_response_receiverThread(self.parameters,"server")
            self._command_response_receiver_thread.setDaemon(True)
            self._command_response_receiver_thread.start()
        # launch images receiver thread
        self.ImagesReceiver_Thread = ths.receiverThread(
                                    MQparams=self.parameters,
                                    exchange_name='images_topic',
                                    exchange_type='topic',
                                    MQqueue_name=f'{self.server_name}_images_queue',
                                    binding_keys=[f"{self.server_name}.images.test0"],
                                    message_queue=self.ImagesReceiver_queue
                                    )
        self.ImagesReceiver_Thread.setDaemon(True)
        self.ImagesReceiver_Thread.setName("Thread-imagesReceiver")
        self.ImagesReceiver_Thread.start()
    def _stop_command_response_receiver_thread(self):
        """stop command response thread"""
        if self._command_response_receiver_thread is not None:
            self._command_response_receiver_thread.stop()
            self._command_response_receiver_thread = None
        # launch plys receiver thread
        self.PlysReceiver_Thread = ths.receiverThread(
                                    MQparams=self.parameters,
                                    exchange_name='plys_topic',
                                    exchange_type='topic',
                                    MQqueue_name=f'{self.server_name}_plys_queue',
                                    binding_keys=[f'{self.server_name}.plys.test0'],
                                    message_queue=self.PlysReceiver_queue
                                    )
        self.PlysReceiver_Thread.setDaemon(True)
        self.PlysReceiver_Thread.setName("Thread-plysReceiver")
        self.PlysReceiver_Thread.start()
    def _start_command_request_sender_thread(self):
        """start command request thread"""
        if self._command_request_sender_thread is None:
            self._command_request_sender_thread = \
                ths.command_request_senderThread(self.parameters,self.command_request_queue,"server")
            self._command_request_sender_thread.setDaemon(True)
            self._command_request_sender_thread.start()
        # launch decode thread
        queue_list = [self.LogsReceiver_queue,self.ImagesReceiver_queue,self.PlysReceiver_queue]
        queue_tags = ["Logs", "Images", "Plys"]
        self.MsgDecoder_Thread = ths.decodeThread(
                                    queue_list= queue_list,
                                    queue_tags= queue_tags,
                                    task_folder= self.task_uuid_folder  ,
                                    replay_host=self.replay_host
                                    )
    def _stop_command_request_sender_thread(self):
        """stop command request thread"""
        if self._command_request_sender_thread is not None:
            self._command_request_sender_thread.stop()
            self._command_request_sender_thread = None
        self.MsgDecoder_Thread.setDaemon(True)
        self.MsgDecoder_Thread.setName("Thread-dataDecoder")
        self.MsgDecoder_Thread.start()
    def _def_routes(self):
        self.routes = {
            pb.SysCommand.SYS_COMMAND: self._on_sys_command,
        }
    
    def _on_sys_command(self, req: pb.RequestCommand, resp: pb.ResponseCommand):
    def _sender_Thread_Launcher(self):
        self.command_request_queue.put(ths.Message(None,None,req.command,req.target))
        return
        # launcher commands sender thread
        self.CommandsSender_Thread = ths.senderThread(
                                    MQparams=self.parameters,
                                    exchange_name='commands_topic',
                                    exchange_type='topic',
                                    message_queue=self.CommandsSender_queue
                        )
        self.CommandsSender_Thread.setDaemon(True)
        self.CommandsSender_Thread.setName("Thread-commandsSender")
        self.CommandsSender_Thread.start()
    def _default(self, req: pb.RequestCommand, resp: pb.ResponseCommand):
        print('onknown command')
    def api(self):
        req = pb.RequestCommand()
        req.ParseFromString(request.data)
        # a function: _on_sys_command, refer to self._on_sys_command
        dispatcher = self.routes.get(req.sys_command, self._default)
        resp = pb.ResponseCommand()
        dispatcher(req, resp) # call the function
        resp.checksum = 12345
        response = Flask.response_class(
            resp.SerializeToString(),
            mimetype='application/x-protobuf'
        )
        return response, 200
    def hello(self):
        return 'Hello, This is acquisition demo API!'
    def api(self):
        try:
            success, response_bytes = self.verify_commands(request.data)
        except:
            response_bytes = b'command error!'
        response = Flask.response_class(
            response_bytes,
            mimetype='application/x-bytes'
        )
        return response,200
    def verify_commands(self,input_command:bytes):
        # parse the command from bytes to the pb object
        req_command = pb.CommandMessage()
        req_command.ParseFromString(input_command)
        # extracting some info for use
        source = req_command.source
        # generatetime = req_command.generatetime
        # syscommand = req_command.syscommand
        # subcommand = req_command.subcommand
        targetclient = req_command.targetclient
        # returnserver = req_command.returnserver
        taskuuid = req_command.taskuuid
        update_folder_for_today(self.today)
        task_path = os.path.join(self.today["today_folder"],taskuuid)
        self.task_uuid_folder[taskuuid] = task_path
        if not os.path.exists(task_path):
            os.makedirs(task_path)
        curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
        print(f"[x] {curr_time}|(From {source}): task [{taskuuid}] received and sending it to [{targetclient}]." )
        self.CommandsSender_queue.put([targetclient,input_command])
        response_bytes = bytes(f"Receive command success! The data will be save in [{os.path.abspath(task_path)}]",\
                        encoding="utf8")
        return True, response_bytes
    def run_rabbitmq(self):
        self._connect_to_MQ()
        self._start_device_state_up_msg_receiver_thread()
        self._start_alarm_state_up_msg_receiver_thread()
        self._start_command_response_receiver_thread()
        self._start_command_request_sender_thread()
        self._receiver_Thread_Launcher()
        self._sender_Thread_Launcher()
    def run_all(self):
        self.run_rabbitmq()
        self.run(debug=False, host=self.WEBhost, port=self.WEBport)
<<<<<<< HEAD
if __name__ == "__main__":
    def help():
        print("Usage: Server.py [MQhost] [MQuser] [MQpassword] [WEBhost] [WEBport] [SAVEfolder]")
        print("EXAMPLE: Server.py localhost chai password123 0.0.0.0 5000 ./Received_data/")
        exit(1)
    if len(sys.argv) != 7:
        help()
    try:
        MQhost = str(sys.argv[1])
        MQuser = str(sys.argv[2])
        MQpassword = str(sys.argv[3])
        WEBhost = str(sys.argv[4])
        WEBport = int(sys.argv[5])
        SAVEfolder = str(sys.argv[6])
    except Exception as e:
        print(e)
        help()
    server = MyServer(MQhost, MQuser, MQpassword, WEBhost, WEBport, SAVEfolder)
    server.run_all()
=======
>>>>>>> aa8a0ba3a86ff5dbbdfcd68c72a5e70e1c52e877
src/Server1.py
File was deleted
src/__init__.py
@@ -1,5 +1,5 @@
from .engine import *
from .microwave import *
from .protos import *
from .slam import *
from .utils import *
# from .engine import *
# from .microwave import *
# from .protos import *
# from .slam import *
# from .utils import *
src/engine/AcquisitionMain.py
@@ -1,19 +1,15 @@
import sys              # NOQA: E402
import os
import cv2
import logging
import json
from time import sleep
import pika
import queue
import requests
import time
import threading
from datetime import datetime
from .CaptureThread import CaptureThread
from .ControllThread import ControllThread
from .MicroWaveUDPThread import MicroWaveUDPThread
# from .CaptureThread import CaptureThread
# from .ControllThread import ControllThread
# from .MicroWaveUDPThread import MicroWaveUDPThread
from . import MessageThreads as ths
from .devices import cameraController
from .devices import cameraController, dustCleanerController,microwaveController
# # add python path of src to sys.path
# src_path = os.path.join(__file__, *(['..'] * 2))
@@ -27,86 +23,51 @@
IMAGE_HEIGHT = 2880
CAMERA_COUNT = 4
class Config:
    """
    config class
    """
    def __init__(self, config_file: str):
        self.interval: float = 10
        self.resolution = '4k'
# class Config:
#     """
#     config class
#     """
#     def __init__(self, config_file: str):
#         self.interval: float = 10
#         self.resolution = '4k'
        self.clean_lens_start_angle = 10
        self.clean_lens_end_angle = 90
        self.clean_lens_num = 2
        self.clean_lens_period = 1200
        self.clean_self_start_angle = 10
        self.clean_self_end_angle = 55
        self.clean_self_num = 2
        self.clean_self_period = 240
#         self.clean_lens_start_angle = 10
#         self.clean_lens_end_angle = 90
#         self.clean_lens_num = 2
#         self.clean_lens_period = 1200
#         self.clean_self_start_angle = 10
#         self.clean_self_end_angle = 55
#         self.clean_self_num = 2
#         self.clean_self_period = 240
        # load config file
        with open(config_file, 'r') as f:
            self.config = json.load(f)
            self.device_id = self.config['Device_ID']
            self.interval = self.config['Captue_Image_para']['capture_interval']
            self.resolution = self.config['Captue_Image_para']['resolution']
#         # load config file
#         with open(config_file, 'r') as f:
#             self.config = json.load(f)
#             self.device_id = self.config['Device_ID']
#             self.interval = self.config['Captue_Image_para']['capture_interval']
#             self.resolution = self.config['Captue_Image_para']['resolution']
            Clean_Brush_para = self.config['Clean_Brush_para']
            self.clean_lens_start_angle = Clean_Brush_para['clean_lens_start_angle']
            self.clean_lens_end_angle = Clean_Brush_para['clean_lens_end_angle']
            self.clean_lens_num = Clean_Brush_para['clean_lens_num']
            self.clean_lens_period = Clean_Brush_para['clean_lens_period']
            self.clean_self_start_angle = Clean_Brush_para['clean_self_start_angle']
            self.clean_self_end_angle = Clean_Brush_para['clean_self_end_angle']
            self.clean_self_num = Clean_Brush_para['clean_self_num']
            self.clean_self_period = Clean_Brush_para['clean_self_period']
            f.close()
        return
#             Clean_Brush_para = self.config['Clean_Brush_para']
#             self.clean_lens_start_angle = Clean_Brush_para['clean_lens_start_angle']
#             self.clean_lens_end_angle = Clean_Brush_para['clean_lens_end_angle']
#             self.clean_lens_num = Clean_Brush_para['clean_lens_num']
#             self.clean_lens_period = Clean_Brush_para['clean_lens_period']
#             self.clean_self_start_angle = Clean_Brush_para['clean_self_start_angle']
#             self.clean_self_end_angle = Clean_Brush_para['clean_self_end_angle']
#             self.clean_self_num = Clean_Brush_para['clean_self_num']
#             self.clean_self_period = Clean_Brush_para['clean_self_period']
#             f.close()
#         return
class AcquisitionMain (object):
    """
    acquisition main class
    """
    # def __init__(self,
    #              rabbitmq_host: str,
    #              rabbitmq_user: str,
    #              rabbitmq_password: str,
    #              rabbitmq_queue: str,
    #              device_id: str,
    #              api_url: str,
    #              udp_server_host: str,
    #              config: Config) -> None:
    #     """
    #     init AcquisitionMain class
    #     Args:
    #         rabbitmq_host: rabbitmq server host
    #         rabbitmq_user: rabbitmq user
    #         rabbitmq_password: rabbitmq password
    #         rabbitmq_queue: rabbitmq upload queue
    #         device_id: device id
    #         api_url: server api url
    #         udp_server_host: udp server host for micro wave, localhost for testing or 192.168.2.65 for production
    #         config: config object
    #     """
    #     self.rabbitmq_host: str = rabbitmq_host
    #     self.udp_server_host: str = udp_server_host
    #     self.rabbitmq_user: str = rabbitmq_user
    #     self.rabbitmq_password: str = rabbitmq_password
    #     self.rabbitmq_queue: str = rabbitmq_queue
    #     self.device_id: str = device_id
    #     self.message_send: int = 0
    #     self.api_url: str = api_url
    #     self.config = config
    #     self.image_quality: float = 95
    #     self.cameras: list = []
    #     self.msg_queue = queue.Queue()
    #     # thread members
    #     self._controll_thread = None
    #     self._capture_thread = None
    #     self._udp_thread = None
    def __init__(self, MQhost, MQuser, MQpassword, deviceID, MICROWAVEhost):
    def __init__(self,
                MQhost:str,
                MQuser:str,
                MQpassword:str,
                deviceID:str,
                MICROWAVEhost:str):
        # device ID
        self.device_id = deviceID
@@ -116,34 +77,28 @@
        self.MQpassword = MQpassword
        self.parameters = None
        # camera
        self.IMAGE_WIDTH = 3840
        self.IMAGE_HEIGHT = 2880
        self.CAMERA_COUNT = 4
        self.IMAGE_WIDTH = IMAGE_WIDTH
        self.IMAGE_HEIGHT = IMAGE_HEIGHT
        self.CAMERA_COUNT = CAMERA_COUNT
        # microwave
        self.MICROWAVEhost = MICROWAVEhost
        # threads
        self._device_state_sender_thread = None
        self._alarm_state_sender_thread = None
        self._command_request_receiver_thread = None
        self._command_response_sender_thread = None
        # queue
        self.device_state_queue = queue.Queue()
        self.alarm_state_queue = queue.Queue()
        self.command_request_queue = queue.Queue()
        self.command_response_queue = queue.Queue()
        self.image_data_queue = queue.Queue()
        self.udp_data_queue = queue.Queue()
        self.ply_data_queue = queue.Queue()
        # self.MICROWAVEPort = MICROWAVEhost
        self.MICROWAVEport = 9911
        self.queue_dict = {
            "device_state":self.device_state_queue,
            "alarm_state":self.alarm_state_queue,
            "command_request":self.command_request_queue,
            "command_response":self.command_response_queue,
            "image_data":self.image_data_queue,
            "udp_data":self.udp_data_queue,
            "ply_data":self.ply_data_queue
        }
        # dust cleaner
        self.com = "COM11"
        self.bps = "115200"
        self.timeout = 1
        # threads
        self.threads = []
        # queue
        self.CommandsReceiver_queue = queue.Queue()
        self.LogsSender_queue = queue.Queue()
        self.ImagesSender_queue = queue.Queue()
        self.PlysSender_queue = queue.Queue()
        # device
        self.cc = None # camera controller
@@ -159,110 +114,183 @@
        }
    def _connect_to_MQ(self):
        credentials = pika.PlainCredentials(self.MQuser, self.MQpassword)
        self.parameters = pika.ConnectionParameters(
            credentials=credentials, host=self.MQhost)
            credentials=credentials, host=self.MQhost,heartbeat=0)
        # 连接队列服务器
        try:
            self.connection = pika.BlockingConnection(self.parameters)
            print(f"connected to MQ server: {self.MQhost} with user {self.MQuser}")
            self.connection.close()
        except Exception :
            print("can't connecting to the MQ server")
            print("Can't connecting to the MQ server")
            exit(1)
    def _start_device_state_up_msg_sender_thread(self):
        """start device state thread"""
        if self._device_state_sender_thread is None:
            self._device_state_sender_thread = \
                ths.device_state_senderThread(self.parameters,\
                    self.device_state_queue,self.device_id)
            self._device_state_sender_thread.setDaemon(True)
            self._device_state_sender_thread.start()
    def _receiver_Thread_Launcher(self):
    def _stop_device_state_up_msg_sender_thread(self):
        """stop device state thread"""
        if self._device_state_sender_thread is not None:
            self._device_state_sender_thread.stop()
            self._device_state_sender_thread = None
        # launch a commands receiver thread
        self.CommandsReceiver_Thread = ths.receiverThread(
                                    MQparams=self.parameters,
                                    exchange_name='commands_topic',
                                    exchange_type='topic',
                                    MQqueue_name=f"{self.device_id}_commands_queue",
                                    binding_keys=[f"{self.device_id}"],
                                    message_queue=self.CommandsReceiver_queue
                                    )
        self.CommandsReceiver_Thread.setDaemon(True)
        self.CommandsReceiver_Thread.setName("Thread-commandsReceiver")
        self.CommandsReceiver_Thread.start()
    def _start_alarm_state_up_msg_sender_thread(self):
        """start alarm state thread"""
        if self._alarm_state_sender_thread is None:
            self._alarm_state_sender_thread = \
                ths.alarm_state_senderThread(self.parameters,\
                    self.alarm_state_queue,self.device_id)
            self._alarm_state_sender_thread.setDaemon(True)
            self._alarm_state_sender_thread.start()
        self.threads.append(self.CommandsReceiver_Thread)
    def _sender_Thread_Launcher(self):
    def _stop_alarm_state_up_msg_sender_thread(self):
        """stop alarm state thread"""
        if self._alarm_state_sender_thread is not None:
            self._alarm_state_sender_thread.stop()
            self._alarm_state_sender_thread = None
        # launch a logs sender thread
        self.LogsSender_Thread = ths.senderThread(
                                MQparams=self.parameters,
                                exchange_name="logs_topic",
                                exchange_type="topic",
                                message_queue=self.LogsSender_queue
                        )
        self.LogsSender_Thread.setDaemon(True)
        self.LogsSender_Thread.setName("Thread-logsSender")
        self.LogsSender_Thread.start()
        self.threads.append(self.LogsSender_Thread)
    def _start_command_response_sender_thread(self):
        """start command response thread"""
        if self._command_response_sender_thread is None:
            self._command_response_sender_thread = \
                ths.command_response_senderThread(self.parameters, \
                    self.command_response_queue,self.device_id)
            self._command_response_sender_thread.setDaemon(True)
            self._command_response_sender_thread.start()
        # launch a images sender thread
        self.ImagesSender_Thread = ths.senderThread(
                                MQparams=self.parameters,
                                exchange_name="images_topic",
                                exchange_type="topic",
                                message_queue=self.ImagesSender_queue
                        )
        self.ImagesSender_Thread.setDaemon(True)
        self.ImagesSender_Thread.setName("Thread-imageSender")
        self.ImagesSender_Thread.start()
    def _stop_command_response_sender_thread(self):
        """stop command response thread"""
        if self._command_response_sender_thread is not None:
            self._command_response_sender_thread.stop()
            self._command_response_sender_thread = None
        self.threads.append(self.ImagesSender_Thread)
        # launch a plys sender thread
        self.PlysSender_Thread = ths.senderThread(
                                MQparams=self.parameters,
                                exchange_name="plys_topic",
                                exchange_type="topic",
                                message_queue=self.PlysSender_queue
                        )
        self.PlysSender_Thread.setDaemon(True)
        self.PlysSender_Thread.setName("Thread-plysSender")
        self.PlysSender_Thread.start()
        self.threads.append(self.PlysSender_Thread)
    def _start_command_request_receiver_thread(self):
        """start command request thread"""
        if self._command_request_receiver_thread is None:
            self._command_request_receiver_thread = \
                ths.command_request_receiverThread(self.parameters,\
                self.command_request_queue,self.command_response_queue,self.device_id)
            self._command_request_receiver_thread.setDaemon(True)
            self._command_request_receiver_thread.start()
    def _stop_command_request_receiver_thread(self):
        """stop command request thread"""
        if self._command_request_receiver_thread is not None:
            self._command_request_receiver_thread.stop()
            self._command_request_receiver_thread = None
    def _connect_device(self):
        # connect to cameras
        self.cc = cameraController(
                        IMAGE_WIDTH=self.IMAGE_WIDTH,
                        IMAGE_HEIGHT=self.IMAGE_HEIGHT,
                        CAMERA_COUNT=self.CAMERA_COUNT,
                        device_id=self.device_id,
                        logs_queue=self.LogsSender_queue,
                        images_queue=self.ImagesSender_queue,
                        init_binding_key=self.device_id,
                        init_routing_key="server0"
        )
        self.dc = dustCleanerController(
                    com = self.com,
                    bps = self.bps,
                    timeout=self.timeout,
                    logs_queue=self.LogsSender_queue,
                    device_id=self.device_id,
                    init_binding_key=self.device_id,
                    init_routing_key="server0"
                    )
        self.mc = microwaveController(
                    MicrowaveHost=self.MICROWAVEhost,
                    MicrowavePort=self.MICROWAVEport,
                    init_packet_threshold=100,
                    init_timeusage_threshold=0.2,
                    device_id=self.device_id,
                    logs_queue=self.LogsSender_queue,
                    plys_queue=self.PlysSender_queue,
                    init_binding_key=self.device_id,
                    init_routing_key="server0"
        )
    def command_control(self):
        while True:
            try:
                while not self.CommandsReceiver_queue.empty():
                    command_bytes= self.CommandsReceiver_queue.get()
                    # parse the command from bytes to the pb object
                    req_command = pb.CommandMessage()
                    req_command.ParseFromString(command_bytes)
                    # extracting some info for use
                    source = req_command.source
                    generatetime = req_command.generatetime
                    syscommand = req_command.syscommand
                    subcommand = req_command.subcommand
                    targetclient = req_command.targetclient
                    returnserver = req_command.returnserver
                    taskuuid = req_command.taskuuid
                    curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                    print(f"[x] {curr_time}|(From {source}): task [{taskuuid}] received!" )
                    # command for camera
                    if syscommand == pb.SysCommand.CAMERA_COMMAND:
                        # capture image
                        if subcommand == pb.SubCommand.ONE_TIME_CAPTURE:
                            self.cc.capture(routing_key=returnserver,taskuuid=taskuuid)
                        # unknown command
                        else:
                            pass
                    # command for microwave device
                    elif syscommand == pb.SysCommand.MICROWAVE_COMMAND:
                        if subcommand == pb.SubCommand.ONE_CIRCLE_SCAN:
                            self.mc.scan(routing_key=returnserver,taskuuid=taskuuid)
                        # unknown command
                        else:
                            pass
                    # command for dust cleaner
                    elif syscommand == pb.Syscommand.DUSTCLEANER_COMMAND:
                        if subcommand == pb.SubCommand.ONE_CLEAN_SCAN:
                            self.dc.clean(routing_key=returnserver,taskuuid=taskuuid)
                        # unknown command
                        else:
                            pass
                    # unknown command
                    else:
                        pass
                else:
                    sleep(1)
            except:
                break
    def run_rabbitmq(self):
        self._connect_to_MQ()
        self._start_device_state_up_msg_sender_thread()
        self._start_alarm_state_up_msg_sender_thread()
        self._start_command_response_sender_thread()
        self._start_command_request_receiver_thread()
        self._receiver_Thread_Launcher()
        self._sender_Thread_Launcher()
    def run_device(self):
        self.connecting_camera()
        self.connecting_microwave()
        self.connecting_dustCleaner()
    def connecting_camera(self):
        # init the camera controller
        cc = cameraController(self.IMAGE_WIDTH,self.IMAGE_HEIGHT,\
            self.CAMERA_COUNT,self.device_id,self.queue_dict)
        # connecting to camera via opencv
        cc.open_cameras()
        # capture the data, and wrap it to data queue
        cc._start_captureThread()
    def connecting_microwave(self):
        pass
    def connecting_dustCleaner(self):
        pass
        self._connect_device()
    def run_all(self):
@@ -271,24 +299,26 @@
        self.run_rabbitmq()
        # connecting to devices and wrap data to the corressponding queue
        self.run_device()
        sleep(10)
        self.command_control()
    def stop_all(self):
        self._stop_alarm_state_up_msg_sender_thread()
        self._stop_device_state_up_msg_sender_thread()
        self._stop_command_request_receiver_thread()
        self._start_command_response_sender_thread()
        for t in self.threads:
            t.stop()
            print(f"stop {t.name}")
    def start(self):
        try:
            self.run_all()
            self._device_state_sender_thread.join()
        except Exception as e:
            print("running error, stop all threads")
        self._stop_alarm_state_up_msg_sender_thread()
        self.stop
        print("main thread end.")
        # try:
        #     self.run_all()
        #     print("[*] Client is runing ...")
        #     self.CommandsReceiver_Thread.join()
        # except Exception as e:
        #     print(e)
        #     print("running error, stop all threads")
        #     self.stop_all()
        # print("main thread end.")
        self.run_all()
        return 0
 
            
src/engine/CaptureThread.py
@@ -1,6 +1,4 @@
import sys
import cv2              # NOQA: E402
import os
import numpy as np
import threading
import time
src/engine/ControllThread.py
@@ -1,5 +1,3 @@
import os, sys
import queue
import time
import pika
src/engine/DustCleanerThread.py
@@ -1,5 +1,3 @@
import sys              # NOQA: E402
import os
import threading
import time
src/engine/MessageQueueThread.py
@@ -1,5 +1,3 @@
import sys              # NOQA: E402
import os
import pika
import threading
from ctypes import sizeof
src/engine/MessageThreads.py
@@ -3,10 +3,11 @@
import threading
import pika
import time
from time import sleep
import sys
from datetime import datetime
from typing import List
import numpy as np
import cv2
import requests
# # add python path of src to sys.path
# src_path = os.path.join(__file__, *(['..'] * 2))
@@ -14,6 +15,7 @@
# sys.path.insert(0, src_path)
from ..protos import aerial_pb2 as pb
from ..utils.tools import write_ply
@@ -33,7 +35,7 @@
                    # routing_key:str,
                    message_queue:queue.Queue,
                        ):
            super(senderThread,self).__init__()
            super().__init__()
            
            self.MQparams = MQparams
            self.exchange_name = exchange_name
@@ -48,7 +50,7 @@
    def stop(self):
        """stop the thread"""
        self.is_stop = True
        self.connection.close()
    #     self.connection.close()
    def run(self):
    
@@ -60,26 +62,26 @@
            while True:
                try:
                    if not self.message_queue.empty():
                    if not self.message_queue.empty() and not self.is_stop:
                        
                        # decode the routing key and message body from tuple list
                        message = self.message_queue.get()
                        msg_routing_key = message[0]
                        msg_body = message[1]
                        if msg_body is not False:
                            # publish a PERSISTENT message
                            channel.basic_publish(
                            exchange = self.exchange_name,
                            routing_key = msg_routing_key,
                            body = msg_body,
                            properties=pika.BasicProperties(
                                delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE
                                    )
                            )
                        # publish a PERSISTENT message
                        channel.basic_publish(
                        exchange = self.exchange_name,
                        routing_key = msg_routing_key,
                        body = msg_body,
                        properties=pika.BasicProperties(
                            delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE
                                )
                        )
                        timestamp = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                        caption = f"[x] {timestamp} | Sending message to[{msg_routing_key}]")
                        print(caption)
                            timestamp = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                            caption = f"[x] {timestamp} | Sending message to [{msg_routing_key}]"
                            print(caption)
                    else:
                        time.sleep(1)
@@ -94,10 +96,10 @@
                    exchange_name: str,
                    exchange_type:str,
                    MQqueue_name:str,
                    binding_keys:List(str),
                    binding_keys:List[str],
                    message_queue:queue.Queue,
                        ):
            super(senderThread,self).__init__()
            super().__init__()
            
            self.MQparams = MQparams
            self.exchange_name = exchange_name
@@ -113,7 +115,7 @@
    def stop(self):
        """stop the thread"""
        self.is_stop = True
        self.connection.close()
    #     self.connection.close()
    def run(self):
@@ -127,7 +129,8 @@
            # declare the queue and bind it with keys
            channel.queue_declare(queue=self.MQqueue_name, durable=True)
            for binding_key in self.binding_keys:
                channel.queue_bind(exchange=self.exchangeName, queue=self.MQqueue_name, routing_key=binding_key)
                channel.queue_bind(exchange=self.exchange_name, queue=self.MQqueue_name, routing_key=binding_key)
                print(f"[*] Using [{binding_key}] bind [{self.MQqueue_name}] on [{self.exchange_name}]")
            # consume the message
            channel.basic_qos(prefetch_count=1)
@@ -138,24 +141,29 @@
            channel.start_consuming()
    def callback(self,ch, method, properties, body):
        self.message_queue.put(body)
        if self.is_stop:
            ch.close()
        if body is not False:
            self.message_queue.put(body)
        ch.basic_ack(delivery_tag = method.delivery_tag)
class decodeThread(threading.Thread):
    def __init__(self,
        queue_list:List(queue.Queue),
        queue_tags:List(str),
        save_path:str):
        queue_list:List[queue.Queue],
        queue_tags:List[str],
        task_folder:dict[str,str],
        replay_host:str):
        super().__init__()
        self.queue_list = queue_list
        self.queue_tags = queue_tags
        self.queue_num = 0
        self.save_path = save_path
        self.task_folder = task_folder
        self.replay_host = replay_host
        self.is_stop = False
        assert len(self.queue_list) == len(self.queue_tags)
    def stop(self):
        """stop the thread"""
@@ -163,22 +171,22 @@
    def run(self) -> None:
        # creating a path for saving data
        time_tag = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
        self.save_root_folder = os.path.join(self.save_path,time_tag)
        os.makedirs(self.save_root_folder)
        # # creating a path for saving data
        # time_tag = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
        # self.save_root_folder = os.path.join(self.task_folder,time_tag)
        # os.makedirs(self.save_root_folder)
        self.logsmsg_folder = os.path.join(self.save_root_folder,"LogsMsg")
        self.imagesmsg_folder = os.path.join(self.save_root_folder,"ImagesMsg")
        self.plysmsg_folder = os.path.join(self.save_root_folder,"PlysMsg")
        self.commandsmsg_folder = os.path.join(self.save_root_folder,"CommandsMsg")
        # self.logsmsg_folder = os.path.join(self.save_root_folder,"LogsMsg")
        # self.imagesmsg_folder = os.path.join(self.save_root_folder,"ImagesMsg")
        # self.plysmsg_folder = os.path.join(self.save_root_folder,"PlysMsg")
        # self.commandsmsg_folder = os.path.join(self.save_root_folder,"CommandsMsg")
        sub_folder_list = [self.logsmsg_folder,self.imagesmsg_folder,
                        self.plysmsg_folder,self.commandsmsg_folder]
        # sub_folder_list = [self.logsmsg_folder,self.imagesmsg_folder,
        #                 self.plysmsg_folder,self.commandsmsg_folder]
        for folder in sub_folder_list:
            os.mkdir(folder)
            print(f"[NOTICE] Creating folder: {folder}")
        # for folder in sub_folder_list:
        #     os.mkdir(folder)
        #     print(f"[NOTICE] Creating folder: {folder}")
        # process the queue list
        self.queue_num = len(self.queue_list)
@@ -190,15 +198,14 @@
                queue = self.queue_list[i_tag]
                # make sure the queue is not empty
                while not queue.empty():
                while not queue.empty() and not self.is_stop:
                    # decode the msg using cooresponding method
                    queue_tag = self.queue_tags[i_tag]
                    decode_method = self.decode_select(queue_tag)
                    decode_method(queue)
                # next queue
                i += 1
    def decode_select(self,queue_tags:str):
        route_dic = {
            "Logs":self.decode_LogsMsg,
@@ -214,45 +221,57 @@
        while not queue.empty() and count < nums_limit:
            # extracting the msg from queue
            msg = queue.pop()
            msg = queue.get()
            msg_pb = pb.LogsMessage()
            msg_pb.ParseFromString(msg)
            # save the raw pb msg
            raw_file_name = os.path.join(self.logsmsg_folder,f"{curr_time}.LogsMsg")
            with open(raw_file_name, 'wb') as file:
                file.write(msg)
            # process the msg
            msg_source = msg_pb.source
            msg_timestamp = msg_pb.timestamp
            msg_context = msg_pb.context
            taskuuid = msg_pb.taskuuid
            save_folder = self.task_folder[taskuuid]
            # save the raw pb msg
            # curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
            raw_file_name = os.path.join(save_folder,f"{msg_timestamp}-{msg_source}.LogsMsg")
            with open(raw_file_name, 'wb') as file:
                file.write(msg)
            # display the info to the console
            curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
            print(f"[x] {curr_time}|(From {msg_source}): {msg_context}" )
            notice_str = f"[x] {curr_time}|(From {msg_source}): {msg_context}"
            print(notice_str)
            replay_to_(host = self.replay_host,
                        message=notice_str,
                        message_type="logs",
                        taskuuid=taskuuid)
            # next msg
            count += 1
    def decode_ImagesMsg(self,queue):
        while not queue.empty():
            # extracting the msg from queue
            msg = queue.pop()
            msg = queue.get()
            msg_pb = pb.ImagesMessage()
            msg_pb.ParseFromString(msg)
            # save the raw pb msg
            raw_file_name = os.path.join(self.imagesmsg_folder,f"{curr_time}.ImagesMsg")
            with open(raw_file_name, 'wb') as file:
                file.write(msg)
            # process the msg
            msg_source = msg_pb.source
            msg_timestamp = msg_pb.timestamp
            taskuuid = msg_pb.taskuuid
            save_folder = self.task_folder[taskuuid]
            # save the raw pb msg
            # curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
            raw_file_name = os.path.join(save_folder,f"{msg_timestamp}-{msg_source}.ImagesMsg")
            with open(raw_file_name, 'wb') as file:
                file.write(msg)
            # process the images
            id = 0
@@ -261,671 +280,217 @@
                image_byte = image.data
                # save the images
                if (image_byte is None) | (len(image_byte) == 0):
                if (image_byte is None) | (len(image_byte) != imagelegth ):
                    pass
                else:
                    filename = f"{msg_source}_{msg_timestamp}_image{id}.jpg"
                    filepath = os.path.join(self.imagesmsg_folder,filename)
                    filename = f"{msg_timestamp}-{msg_source}-image{id}.jpg"
                    filepath = os.path.join(save_folder,filename)
                    with open(filepath, 'wb') as f:
                        f.write(image)
                        f.write(image_byte)
                    # display the info to the console
                    curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                    print(f"[x] {curr_time}|(From {msg_source}): image{id} saved!" )
                    notice_str = f"[x] {curr_time}|(From {msg_source}): image{id} saved!"
                    print(notice_str)
                    replay_to_(host = self.replay_host,
                                message=notice_str,
                                message_type="images",
                                taskuuid=taskuuid)
                # next image item
                id += 1
    def decode_PlysMsg(self,queue):
        while not queue.empty():
            # extracting the msg from queue
            msg = queue.get()
            msg_pb = pb.PlysMessage()
            msg_pb.ParseFromString(msg)
        pass
            # process the msg
            msg_source = msg_pb.source
            msg_timestamp = msg_pb.timestamp
            taskuuid = msg_pb.taskuuid
            save_folder = self.task_folder[taskuuid]
            # save the raw pb msg
            # curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
            raw_file_name = os.path.join(save_folder,f"{msg_timestamp}-{msg_source}.PlysMsg")
            with open(raw_file_name, 'wb') as file:
                file.write(msg)
            # process the muti ply data
            id = 0
            for ply in msg_pb.Plydata:
                data_legth = ply.length
                data_byte = ply.data
                rows = ply.rows
                cols = ply.cols
                order = ply.order
                dt = ply.dtype
                # save the pointcloud array data
                if (data_byte is None) | (len(data_byte) != data_legth):
                        pass
                else:
                    # frame the bytes to array
                    data_array = np.frombuffer(data_byte,dtype=dt)
                    data_array = data_array.reshape(rows,cols,order=order)
                    # save the data with .ply format
                    filename = f"{msg_timestamp}-{msg_source}-pointcloud{id}"
                    write_ply(data_array,save_folder,filename)
                    # display the info to the console
                    curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                    notice_str = f"[x] {curr_time}|(From {msg_source}): ply{id} saved!"
                    print(notice_str)
                    replay_to_(host = self.replay_host,
                                message=notice_str,
                                message_type="plys",
                                taskuuid=taskuuid)
                # next ply item
                id += 1
    def decode_CommandsMsg(self,queue):
        pass
# 根据rabbitmq重新设置消息参数
class device_state_senderThread(senderThread):
    def __init__(self,
        MQparameters,
        input_msg_queue,
        sender_id,
        ):
        super(device_state_senderThread,self).__init__(
                    MQparameters, \
                    input_msg_queue,
                    sender_id,
                    "device_state",
                    "fanout"
                   )
# 根据rabbitmq重新设置消息参数
class device_state_receiverThread(receiverThread):
    def __init__(self,
        MQparameters,
        receiver_id):
        super(device_state_receiverThread,self).__init__(
                    MQparameters,
                    None,
                    None,
                    "device_state",
                    "fanout",
                    receiver_id
        )
    def callback(self, ch, method, properties, body):
        response_tag = f"{time.asctime()} received: {body}."
        print(response_tag)
        ch.basic_ack(delivery_tag = method.delivery_tag)
# 根据rabbitmq重新设置消息参数
class alarm_state_senderThread(senderThread):
    def __init__(self,
        MQparameters,
        input_msg_queue,
        sender_id,
        ):
        super(alarm_state_senderThread,self).__init__(
                    MQparameters, \
                    input_msg_queue,
                    sender_id,
                    "alarm_state",
                    "fanout"
                   )
    # 根据rabbitmq重新设置消息参数
class alarm_state_receiverThread(receiverThread):
    def __init__(self,
        MQparameters,
        receiver_id):
        super(alarm_state_receiverThread,self).__init__(
                    MQparameters,
                    None,
                    None,
                    "alarm_state",
                    "fanout",
                    receiver_id
        )
    def callback(self, ch, method, properties, body):
        response_tag = f"{time.asctime()} received: {body}."
        print(response_tag)
        ch.basic_ack(delivery_tag = method.delivery_tag)
# 根据rabbitmq重新设置消息参数
class command_request_senderThread(senderThread):
    def __init__(self,
        MQparameters,
        input_msg_queue,
        sender_id,
        ):
        super(command_request_senderThread,self).__init__(
                    MQparameters, \
                    input_msg_queue,
                    sender_id,
                    "command_request",
                    "topic"
                   )
# 根据rabbitmq重新设置消息参数
class command_request_receiverThread(receiverThread):
    def __init__(self,
        MQparameters,
        received_msg_queue,
        response_msg_queue,
        receiver_id):
        super(command_request_receiverThread,self).__init__(
                    MQparameters,
                    received_msg_queue,
                    response_msg_queue,
                    "command_request",
                    "topic",
                    receiver_id
        )
    def callback(self, ch, method, properties, body):
        received_msg = Message(None,None,body,None)
        self.queue.put(received_msg)
        response_tag = f"{time.asctime()},{self.receiver_id} received {self.exchangeName} message."
        print(response_tag)
        self.response_queue.put(Message(self.receiver_id,self.receiver_id,response_tag,''))
        ch.basic_ack(delivery_tag = method.delivery_tag)
# 根据rabbitmq重新设置消息参数
class command_response_senderThread(senderThread):
    def __init__(self,
        MQparameters,
        input_msg_queue,
        sender_id,
        ):
        super(command_response_senderThread,self).__init__(
                    MQparameters, \
                    input_msg_queue,
                    sender_id,
                    "command_response",
                    "fanout"
                   )
# 根据rabbitmq重新设置消息参数
class command_response_receiverThread(receiverThread):
    def __init__(self,
        MQparameters,
        receiver_id):
        super(command_response_receiverThread,self).__init__(
                    MQparameters,
                    None,
                    None,
                    "command_response",
                    "fanout",
                    receiver_id
        )
    def callback(self, ch, method, properties, body):
        response_tag = f"{time.asctime()} received: {body}."
        print(response_tag)
        ch.basic_ack(delivery_tag = method.delivery_tag)
# TODO
class image_data_senderThread(senderThread):
    def __init__(self,
        MQparameters,
        input_msg_queue,
        sender_id,
        ):
        super(command_response_senderThread,self).__init__(
                    MQparameters, \
                    input_msg_queue,
                    sender_id,
                    "image_data",
                    "fanout"
                   )
class image_data_receiverThread(receiverThread):
    pass
def message_sender(MQparams: pika.ConnectionParameters,
                exchange_name: str,
                exchange_type:str,
                routing_key:str,
                message:str,
                    ):
    # connect to RabbitMQ
    connection = pika.BlockingConnection(MQparams)
    # declare a exchange
    channel = connection.channel()
    channel.exchange_declare(exchange=exchange_name,
                            exchange_type=exchange_type)
    # publish a PERSISTENT message
    channel.basic_publish(
                exchange=exchange_name,
                routing_key=routing_key,
                body=message,
                properties=pika.BasicProperties(
                    delivery_mode=pika.spec.PERSISTENT_DELIVERY_MODE
                )
        )
    # close the connection
    connection.close()
def message_receiver(MQparams: pika.ConnectionParameters,
                exchange_name: str,
                exchange_type:str,
                queue_name:str,
                binding_keys:List[str],
                callback_fn:callable
                ):
    # connect to RabbitMQ
    connection = pika.BlockingConnection(MQparams)
    # declare a exchange
    channel = connection.channel()
    channel.exchange_declare(exchange=exchange_name,
                            exchange_type=exchange_type)
    # declare a durable queue
    channel.queue_declare(queue=queue_name,durable=True)
    # literate the binding keys and bind the queue
    for binding_key in binding_keys:
        channel.queue_bind(queue=queue_name,exchange=exchange_name,
                            routing_key=binding_key)
    # waiting for consuming the messages
    channel.basic_qos(prefetch_count=1)
    channel.basic_consume(queue=queue_name,
                        auto_ack=False,
                        on_message_callback=callback_fn
                        )
    channel.start_consuming()
# class device_state_up_msg_sender_thread(threading.Thread):
#     def __init__(self, MQparameters,device_state_msg_queue):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.queue = device_state_msg_queue
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
#         while not self.is_stop:
#             print("device_state_up_msg_sender_thread started")
#         channel = self.connection.channel()
#         channel.exchange_declare(exchange='device_state', exchange_type='fanout')
#         while True:
#             try:
#                 if not self.queue.empty():
#                     msg = self.msg_queue.get()
#                     channel.basic_publish(exchange='device_state', routing_key='', body=msg)
#                     print(time.asctime(), "send device state message")
#                 elif self.queue.empty():
#                     time.sleep(1)
#             except Exception as e:
#                 break
        
# class device_state_up_msg_receiver_thread(threading.Thread):
#     def __init__(self, MQparameters):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
        raise NotImplementedError("NOT IMPLEMENT!")
#     def run(self):
#         while not self.is_stop:
#             print("device_state_up_msg_receiver_thread started")
#             channel = self.connection.channel()
#             channel.exchange_declare(exchange='device_state', exchange_type='fanout')
def replay_to_(host:str,
            message:str,
            message_type:str,
            taskuuid:str,
            ):
#             result = channel.queue_declare(queue='', exclusive=True, durable=True)
#             queue_name = result.method.queue
    if taskuuid != "init":
        try:
            # target = host+taskuuid
            target = host
            print(f"Send message to [{target}]")
            payload = {"taskid":taskuuid, "messagetype":message_type, "message": message}
            r = requests.post(target,params = payload,timeout=3)
            print("send success!")
        except Exception as e:
            print(e)
            print("send error!")
            pass
#             channel.queue_bind(exchange='device_state', queue=queue_name)
#             def callback(ch, method, properties, body):
#                 print(f"Received: {body}")
#                 ch.basic_ack(delivery_tag = method.delivery_tag)
def send_logs_tool(logs:List[str],
                logs_queue:queue.Queue,
                source:str,
                routing_key:str,
                taskuuid:str = "init"):
#             channel.basic_consume(queue=queue_name, \
#                 on_message_callback=callback)
    for i, log in enumerate(logs):
        if log is not None:
            # constract a logs message
            logsMsg = pb.LogsMessage()
            logsMsg.source = source
            curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
            logsMsg.timestamp = curr_time
            logsMsg.context = log
            logsMsg.taskuuid = taskuuid
            # convert the proto object to string
            logsMsg_bytes = logsMsg.SerializeToString()
            # add logsmsg to queue
            logs_queue.put([routing_key,logsMsg_bytes])
#             channel.basic_qos(prefetch_count=1)
#             channel.start_consuming()
# class alarm_state_up_msg_sender_thread(threading.Thread):
def send_images_tool(images:List[np.array],
                    images_queue:queue.Queue,
                    source:str,
                    routing_key:str,
                    taskuuid:str = "init"):
#     def __init__(self, MQparameters,alarm_state_msg_queue):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.queue = alarm_state_msg_queue
#         self.connection = pika.BlockingConnection(self.parameters)
    # constract a images message
    imagesMsg = pb.ImagesMessage()
    imagesMsg.source = source
    curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
    imagesMsg.timestamp = curr_time
    imagesMsg.taskuuid = taskuuid
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
    for img in images:
        if img is not None:
            success,image_encoded = cv2.imencode(".jpg",img)
            if success:
                image_bytes = image_encoded.tobytes()
                image_length = len(image_bytes)
                # add the encoded image to msg
                image_item = imagesMsg.Image.add()
                image_item.length = image_length
                image_item.data = image_bytes
#     def run(self):
    # converting the pb image msg to bytes
    imageMsg_bytes = imagesMsg.SerializeToString()
    # add the imageMsg to the queue
    images_queue.put([routing_key,imageMsg_bytes])
def send_pointcloud_tool(pointclouds:queue.Queue,
                        plys_queue:queue.Queue,
                        source:str,
                        routing_key:str,
                        taskuuid:str = "init"):
    # constract a plys message
    plysMsg = pb.PlysMessage()
    plysMsg.source = source
    curr_time = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
    plysMsg.timestamp = curr_time
    plysMsg.taskuuid = taskuuid
    empty = True
    run =True
    while run:
        while not pointclouds.empty():
            value = pointclouds.get()
            if value is not False:
                empty = False
                pointcloud = np.array(value)
                # get the attributes of the PointCloudItem
                rows = pointcloud.shape[0]
                cols = pointcloud.shape[1]
                order = "C"
                dtype = str(pointcloud.dtype)
                data = pointcloud.tobytes(order=order)
                length = len(data)
                # add the pointcloud to the msg
                item  = plysMsg.Plydata.add()
                item.length = length
                item.rows = rows
                item.cols = cols
                item.order = order
                item.dtype = dtype
                item.data = data
            else:
                if not empty:
                    # converting the pb ply msg to bytes
                    plysMsg_bytes = plysMsg.SerializeToString()
                    # add the plysMsg to the queue
                    plys_queue.put([routing_key,plysMsg_bytes])
                    # end the outer while loop and triminate this function
                else:
                    print("[x] NO pointcloud has been captured!")
                run = False
        else:
            time.sleep(3)
    
#         while not self.is_stop:
#             print("alarm_state_up_msg_sender_thread started")
#             channel = self.connection.channel()
#             channel.exchange_declare(exchange='alarm_state', exchange_type='fanout')
#             while True:
#                 try:
#                     if not self.queue.empty():
#                         msg = self.msg_queue.get()
#                         channel.basic_publish(exchange='alarm_state', routing_key='', body=msg)
#                         print(time.asctime(), "send alarm state message")
#                     elif self.queue.empty():
#                         time.sleep(1)
#                 except Exception as e:
#                     break
# class alarm_state_up_msg_receiver_thread(threading.Thread):
#     def __init__(self, MQparameters):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
    
#         while not self.is_stop:
#             print("alarm_state_up_msg_receiver_thread started")
#             channel = self.connection.channel()
#             channel.exchange_declare(exchange='alarm_state', exchange_type='fanout')
#             result = channel.queue_declare(queue='', exclusive=True, durable=True)
#             queue_name = result.method.queue
#             channel.queue_bind(exchange='alarm_state', queue=queue_name)
#             def callback(ch, method, properties, body):
#                 print(f"Received: {body}")
#                 ch.basic_ack(delivery_tag = method.delivery_tag)
#             channel.basic_consume(queue=queue_name, \
#                 on_message_callback=callback)
#             channel.basic_qos(prefetch_count=1)
#             channel.start_consuming()
# class command_request_msg_sender_thread(threading.Thread):
#     def __init__(self, MQparameters,command_request_msg_queue,routing_key_queue):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.command_queue = command_request_msg_queue
#         self.key_queue = routing_key_queue
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
#         while not self.is_stop:
#             print("command_request_msg_sender_thread started")
#             channel = self.connection.channel()
#             channel.exchange_declare(exchange='command_msg', exchange_type='topic')
#             while True:
#                 try:
#                     if not self.command_queue.empty() and \
#                                 not self.key_queue.empty():
#                         msg = self.command_queue.get()
#                         routing_key = self.key_queue.get()
#                         corr_id = str(uuid.uuid4())
#                         channel.basic_publish(exchange='command_msg',
#                                                 routing_key = routing_key,
#                                                 body=msg,
#                                                 properties=pika.BasicProperties(
#                                                         correlation_id=corr_id
#                                                                             )
#                                                 )
#                         print(time.asctime(), f"send command request with ID:[{corr_id}]")
#                     elif self.queue.empty():
#                         time.sleep(1)
#                 except Exception as e:
#                     break
# class command_request_msg_receiver_thread(threading.Thread):
#     def __init__(self, MQparameters,command_request_msg_queue, \
#                         command_response_msg_queue, routing_key):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.queue = command_request_msg_queue
#         self.response_queue = command_response_msg_queue
#         self.routing_key = routing_key
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
#         while not self.is_stop:
#             print("command_request_msg_receiver_thread started")
#             channel = self.connection.channel()
#             channel.exchange_declare(exchange='command_msg', exchange_type='topic')
#             result = channel.queue_declare(queue='', exclusive=True, durable=True)
#             queue_name = result.method.queue
#             channel.queue_bind(exchange='command_msg', queue=queue_name, \
#                                 routing_key=self.routing_key)
#             def callback(ch, method, prop, body):
#                 print(time.asctime(), f"reveive command request with ID:[{prop.corr_id}]")
#                 self.queue.put(body)
#                 self.response_queue.put("")
#                 ch.basic_ack(delivery_tag = method.delivery_tag)
#             channel.basic_consume(queue=queue_name, \
#                 on_message_callback=callback)
#             channel.basic_qos(prefetch_count=1)
#             channel.start_consuming()
# class command_response_msg_sender_thread(threading.Thread):
#     def __init__(self, MQparameters,command_request_msg_queue):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.queue = command_request_msg_queue
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
#         while not self.is_stop:
#             print("command_response_msg_sender_thread started")
#         channel = self.connection.channel()
#         channel.exchange_declare(exchange='command_response', exchange_type='fanout')
#         while True:
#             try:
#                 if not self.queue.empty():
#                     msg = self.msg_queue.get()
#                     channel.basic_publish(exchange='command_response', routing_key='', body=msg)
#                     print(time.asctime(), "send device state message")
#                 elif self.queue.empty():
#                     time.sleep(1)
#             except Exception as e:
#                 break
# class command_down_rpc_sender_thread(threading.Thread):
#     def __init__(self, MQparameters, command_queue, routing_key_queue):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.command_queue = command_queue
#         self.key_queue = routing_key_queue
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self):
#         while not self.is_stop:
#             # print("command_down_rpc_sender_thread started")
#             channel = self.connection.channel()
#             # declare a exchange
#             channel.exchange_declare(exchange="command_rpc", \
#                                     exchange_type='topic')
#             # declare a callback queue
#             result = channel.queue_declare(queue='', exclusive=True)
#             callback_queue = result.method.queue
#             # bingding the queue
#             channel.queue_bind(
#                             exchange="command_rpc",
#                             queue=callback_queue,
#                             routing_key=routing_key
#                                 )
#             # init the command uuid
#             corr_id = str(uuid.uuid4())
#             command_response = None
#             # def a function to print the command respond message
#             def respond_callback(ch, method, properties, body):
#                 if properties.correlation_id == corr_id:
#                     command_response = body
#                     print(body)
#             # start the cosumer
#             channel.basic_consume(
#                                 queue=callback_queue,
#                                 on_message_callback=respond_callback,
#                                 auto_ack=True
#                                 )
#             # publish with tropic exchange
#             channel.basic_publish(
#                                 exchange="command_rpc",
#                                 routing_key=routing_key,
#                                 body = request_command,
#                                 properties=pika.BasicProperties(
#                                                 reply_to=callback_queue,
#                                                 correlation_id=corr_id
#                                                 ),
#                                     )
#             with command_response is None:
#                 self.connection.process_data_events()
# class command_down_rpc_receiver_thread(threading.Thread):
#     def __init__(self, MQparameters):
#         super().__init__(self)
#         self.parameters =  MQparameters
#         self.connection = pika.BlockingConnection(self.parameters)
#     def stop(self):
#         """stop the thread"""
#         self.is_stop = True
#         self.connection.close()
#     def run(self,commands_queue):
#         while not self.is_stop:
#             print("command_down_rpc_receiver_thread started")
#             channel = self.connection.channel()
#             # declare a exchange
#             channel.exchange_declare(exchange="command_rpc", \
#                                     exchange_type='topic')
#             # declare a callback queue
#             result = channel.queue_declare(queue='', exclusive=True)
#             callback_queue = result.method.queue
#             # bingding the queue
#             channel.queue_bind(
#                             exchange="command_rpc",
#                             queue=callback_queue,
#                             routing_key='pod*'
#                                 )
#             # def a function to reply the request from the sender
#             def on_request(ch, method, prop, body):
#                 commands_queue.put(body)
#                 response = f"{time.asctime()} {self.device_id} receive the command uuid:[{prop.correlation_id}]"
#                 print(response)
#                 ch.basic_publish(exchange="command_rpc",
#                                 routing_key = prop.reply_to,
#                                 properties = pika.BasicProperties(
#                                                 correlation_id=prop.corr_id
#                                 ),
#                                 body = response)
#                 ch.basic_ack(delivery_tag = method.delivery_tag)
#             # start the cosumer
#             channel.basic_qos(prefetch_count=1)
#             channel.basic_consume(
#                                 queue=callback_queue,
#                                 on_message_callback=on_request,
#                                 auto_ack=True
#                                 )
#             channel.start_consuming()
# class image_data_up_msg_sender_thread(threading.Thread):
#     pass
# class image_data_up_msg_receiver_thread(threading.Thread):
#     pass
# class ply_data_up_msg_sender_thread(threading.Thread):
#     pass
# class ply_data_up_msg_receiver_thread(threading.Thread):
#     pass
src/engine/Microwave.py
New file
@@ -0,0 +1,57 @@
import queue
from typing import Union
import threading
from .MessageThreads import send_logs_tool
from ..microwave.servers import MicroWaveUDPThread,UDP2PointcloudThread
class micorwaveMannager(object):
    def __init__(self,
            MicrowaveHost:str,
            MicrowavePort:int,
            ):
        # microwave
        self.MicrowaveHost = MicrowaveHost
        self.MicrowavePort = MicrowavePort
        # udp get
        self._udp_get_thread = None
        # self.packet_threshold = packet_threshold
        # self.timeusage_threshold = timeusage_threshold
        self.udp_queue = queue.Queue()
        self.udp_get_stop = threading.Event()
        self._udp_get_thread_name = "Thread-UDPGet"
        # udp to pointcloud
        self._udp2pointcloud_thread = None
        self.pointcloud_queue = queue.Queue()
        self._udp2pointcloud_thread_name = "Thread-UDP2PointCloud"
    def _udp_get_thread_launcher(self,
                    packet_threshold:Union[int, None],
                    timeusage_threshold:Union[int, None]):
        self.udp_get_stop.clear()
        self._udp_get_thread = MicroWaveUDPThread(MicrowaveHost=self.MicrowaveHost,
                            MicrowavePort=self.MicrowavePort,
                            udp_queue=self.udp_queue,
                            udp_get_stop=self.udp_get_stop,
                            packet_threshold=packet_threshold,
                            timeusage_threshold=timeusage_threshold)
        self._udp_get_thread.setDaemon(True)
        self._udp_get_thread.setName(self._udp_get_thread_name)
        self._udp_get_thread.start()
    def _udp2pointcloud_thread_launcher(self):
        self._udp2pointcloud_thread = UDP2PointcloudThread(
                                        udp_queue = self.udp_queue,
                                        pointcloud_queue=self.pointcloud_queue
                                        )
        self._udp2pointcloud_thread.setDaemon(True)
        self._udp2pointcloud_thread.setName(self._udp2pointcloud_thread_name)
        self._udp2pointcloud_thread.start()
src/engine/__init__.py
@@ -1,10 +1,10 @@
from .AcquisitionMain import *
from .CaptureThread import *
from .ControllThread import *
from .DeviceManager import *
from .DustCleaner import *
from .DustCleanerThread import *
from .MessageQueueThread import *
from .MicroWaveUDPThread import *
from .MessageThreads import *
from .devices import *
# from .AcquisitionMain import *
# from .CaptureThread import *
# from .ControllThread import *
# from .DeviceManager import *
# from .DustCleaner import *
# from .DustCleanerThread import *
# from .MessageQueueThread import *
# from .MicroWaveUDPThread import *
# from .MessageThreads import *
# from .devices import *
src/engine/devices.py
@@ -1,135 +1,239 @@
from lib2to3.pytree import convert
import cv2
import time
import threading
import numpy as np
import os, sys
from typing import List, Union
import queue
# # add python path of src to sys.path
# src_path = os.path.join(__file__, *(['..'] * 2))
# src_path = os.path.abspath(src_path)
# sys.path.insert(0, src_path)
from ..protos import aerial_pb2 as pb
from .DustCleaner import DustCleaner
from .Microwave import micorwaveMannager
from .MessageThreads import send_logs_tool, send_images_tool, send_pointcloud_tool
######################################### CAMERAS ############################################
class cameraController(object):
    def __init__(self,IMAGE_WIDTH,IMAGE_HEIGHT,CAMERA_COUNT,device_id,queue_dict):
    def __init__(self,
            IMAGE_WIDTH:int,
            IMAGE_HEIGHT:int,
            CAMERA_COUNT:int,
            device_id:str,
            logs_queue:queue.Queue,
            images_queue:queue.Queue,
            init_routing_key:str,
            init_binding_key:str,
            init_taskuuid:str = "init"
            ):
        self.IMAGE_WIDTH = IMAGE_WIDTH
        self.IMAGE_HEIGHT = IMAGE_HEIGHT
        self.CAMERA_COUNT = CAMERA_COUNT
        self.device_id = device_id
        self.queue_dict = queue_dict
        self.device_state_queue = self.queue_dict["device_state"]
        self.image_data_queue = self.queue_dict["image_data"]
        self._capture_thread = None
        self.logs_queue = logs_queue
        self.images_queue = images_queue
        self.routing_key = init_routing_key
        self.init_routing_key = init_routing_key
        self.binding_key = init_binding_key
        self.init_taskuuid = init_taskuuid
        self.taskuuid = init_taskuuid
        self._check_cameras()
    def open_cameras(self):
        """
        Test the ports and returns a tuple with the available ports and the ones that are working.
        """
    def _check_cameras(self):
        self.cameras = []
        self.camera_work = []
        self.working_ports = []
        test_logs = []
        test_images = []
        # init the cameras
        for dev_port in range(self.CAMERA_COUNT):
            # set the props of the camera by cv2 lib
            camera = cv2.VideoCapture(dev_port, cv2.CAP_DSHOW)
            camera.set(cv2.CAP_PROP_FRAME_WIDTH, self.IMAGE_WIDTH)
            camera.set(cv2.CAP_PROP_FRAME_HEIGHT, self.IMAGE_HEIGHT)
            camera.set(cv2.CAP_PROP_FPS, 1)
            if camera.isOpened():
                is_reading, img = camera.read()
                w = camera.get(3)
                h = camera.get(4)
            self.cameras.append(camera)
            self.camera_work.append(False)
        # test the cameras
        (test_logs, test_images) = self._capture_image(mode = "test")
        # generate the msg and put it to queues
        self._generate_msg(test_logs,test_images)
    def _generate_msg(self,logs:List[str],images:List):
        send_logs_tool(logs=logs,
                        logs_queue=self.logs_queue,
                        source=self.device_id,
                        routing_key=self.routing_key+".logs.test0",
                        taskuuid=self.taskuuid)
        send_images_tool(images=images,
                        images_queue=self.images_queue,
                        source=self.device_id,
                        routing_key=self.routing_key+".images.test0",
                        taskuuid=self.taskuuid)
    def _capture_image(self,mode:str = "capture"):
        """
        mode -> "test" or "capture"
        """
        TEST = False
        if mode == "test":
            TEST = True
        else:
            pass
        log_list = []
        image_list = []
        # iterate the cameras
        for dev_port, camera in enumerate(self.cameras):
            # init the flags
            is_reading = False
            log = None
            img = None
            if not TEST and self.camera_work[dev_port] is not True:
                pass
            else:
                # capture the image
                if camera.isOpened():
                    is_reading, img = camera.read()
                    w = camera.get(3)
                    h = camera.get(4)
                    if is_reading:
                        log = f"camera port {dev_port} is working and reads images ({h} x {w})"
                    else:
                        log = f"camera port {dev_port} can not work"
                else:
                    log = f"camera port {dev_port} can not found"
                # display
                print(f"{time.asctime()} | {log}")
            # add some tags for camera when test
            if TEST:
                self.working_ports.append(dev_port)
                if is_reading:
                    self.working_ports.append(dev_port)
                    self.cameras.append(camera)
                    msg = f"{time.asctime()} {self.device_id} camera port {dev_port} is working and reads images ({h} x {w})"
                    self.camera_work[dev_port] = True
            
                else:
                    msg = f"{time.asctime()} {self.device_id} camera port {dev_port} can not work"
            else:
                msg = f"{time.asctime()} {self.device_id} camera port {dev_port} can not found"
            log_list.append(log)
            image_list.append(img)
            # add msg to queue
            self.device_state_queue.put(msg)
            print(msg)
        return log_list, image_list
    def _start_captureThread(self):
        """start capture thread"""
        if self._capture_thread is None:
            self._capture_thread = \
                CaptureThread(self.cameras,self.image_data_queue,self.device_id,interval=10)
            self._capture_thread.setDaemon(True)
            self._capture_thread.start()
    def capture(self,routing_key:str, taskuuid:str):
    def _stop_captureThread(self):
        """stop capture thread"""
        if self._capture_thread is not None:
            self._capture_thread.stop()
            self._capture_thread = None
        self.routing_key = routing_key
        self.taskuuid = taskuuid
        (logs,images) = self._capture_image()
        # generate the msg and put it to queues
        self._generate_msg(logs,images)
        self.routing_key = self.init_routing_key
        self.taskuuid = self.init_taskuuid
class microwaveController(object):
    pass
class dustCleanerController(object):
    pass
class CaptureThread(threading.Thread):
    """
    camera capture thread
    """
    def __init__(self, cameras, msg_queue, interval, device_id,image_quality = 95):
        """init the thread"""
        threading.Thread.__init__(self)
        self.cameras = cameras
        self.msg_queue = msg_queue
        self.interval = interval
        self.image_quality = image_quality
        self.is_stop = False
######################################## MICROWAVE ###########################################
class microwaveController(micorwaveMannager):
    def __init__(self,
            MicrowaveHost: str,
            MicrowavePort: int,
            init_packet_threshold: Union[int, None],
            init_timeusage_threshold: Union[int, float, None],
            device_id:str,
            logs_queue:queue.Queue,
            plys_queue:queue.Queue,
            init_routing_key:str,
            init_binding_key:str,
            init_taskuuid:str = "init"
            ):
        super().__init__(MicrowaveHost, MicrowavePort)
        self.device_id = device_id
        self.plys_queue = plys_queue
    def stop(self):
        """stop the thread"""
        self.is_stop = True
        self.routing_key = init_routing_key
        self.init_routing_key = init_routing_key
        self.binding_key = init_binding_key
        self.init_taskuuid = init_taskuuid
        self.taskuuid = init_taskuuid
        # testing the device when instance the class
        self._get_pointcloud(init_packet_threshold,init_timeusage_threshold)
# TODO根据新的数据结构修改队消息队列。
    def run(self):
        print("CaptureThread started")
        encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), self.image_quality]
        self.next_time = time.time() + self.interval
        while not self.is_stop:
            this_time = time.time()
            if this_time > self.next_time:
                for i in range(len(self.cameras)):
                    _, frame = self.cameras[i].read()
                    capture_time = time.time()
                    _, encimg = cv2.imencode('.jpg', frame, encode_param)
                    if frame is not None:
                        np_array = np.asarray(encimg)  # frame 转换为numpy数组
                        byte_array = np_array.tobytes()  # numpy数组转换为byte数组
                        # convert the image to pb.DataField
                        imagedata = pb.DataField()
                        imagedata.data = byte_array
                        imagedata.length = len(byte_array)
    def _get_pointcloud(self,
                    packet_threshold:Union[int, None],
                    timeusage_threshold:Union[int, None]):
        self._udp_get_thread_launcher(packet_threshold,timeusage_threshold)
        self._udp2pointcloud_thread_launcher()
        self._generate_msg()
                        data_str = imagedata.SerializeToString()
    def _generate_msg(self):
        send_pointcloud_tool(pointclouds=self.pointcloud_queue,
                            plys_queue=self.plys_queue,
                            source=self.device_id,
                            routing_key=self.routing_key+".plys.test0",
                            taskuuid=self.taskuuid)
                        # create protobuf message
                        data_msg = pb.CapturedData()
                        data_msg.generate_time = capture_time
                        data_msg.generate_device = self.device_id
                        data_msg.camera_port = i
                        data_msg.image_data = data_str
    def scan(self,routing_key:str,taskuuid:str):
                        # add message to queue
                        self.msg_queue.put(data_msg)
        # self.routing_key = routing_key
        # self.taskuuid = self.init_taskuuid
                self.next_time += self.interval
            time.sleep(0.1)
        for camera in self.cameras:
            camera.release()
        print("CaptureThread stopped")
        # self._generate_msg()
        raise NotImplementedError
####################################### DUST CLEANER #########################################
class dustCleanerController(DustCleaner):
    def __init__(self, com, bps, timeout, logs_queue, device_id,
                init_routing_key:str,
                init_binding_key:str,
                init_taskuuid:str = "init"):
        super().__init__(com, bps, timeout)
        self.logs_queue = logs_queue
        self.device_id = device_id
        self.routing_key = init_routing_key
        self.init_routing_key = init_routing_key
        self.binding_key = init_binding_key
        self.init_taskuuid = init_taskuuid
        self.taskuuid = init_taskuuid
        self._check_cleaner()
    def _check_cleaner(self):
        success = self.Open()
        log = "Unknown log."
        if success:
            log = f"The port [{self.port}] refered to the dust cleaner is open."
        else:
            log = f"The port [{self.port}] refered to the dust cleaner can not open."
        # display
        print(f"{time.asctime()} | {log}")
        send_logs_tool(logs=[log],
                        logs_queue=self.logs_queue,
                        source = self.device_id,
                        routing_key=self.routing_key+".logs.test0")
    def clean(self,routing_key:str,taskuuid:str):
        raise NotImplementedError
src/microwave/__init__.py
@@ -1,5 +1,5 @@
from .components import *
from  .constants import *
from  .parsers import *
from  .servers import *
from .deviceTools import *
# from .components import *
# from  .constants import *
# from  .parsers import *
# from  .servers import *
# from .deviceTools import *
src/microwave/demo/AutoGetUDP.bat
@@ -2,19 +2,10 @@
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
@REM add vitrual env python to the path
path "%~dp0/../../../../.env/Scripts/";%path%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
echo All data will be save in '%cd%/saveUDPData/' folder
%aerialpython% udp_test_get.py microwave
python udp_test_get.py microwave
echo =========== ALL DONE ================
src/microwave/demo/AutoGetUDPtest.bat
@@ -2,19 +2,12 @@
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
@REM add vitrual env python to the path
path "%~dp0/../../../../.env/Scripts/";%path%
echo All data will be saved in '%cd%/saveUDPData/' folder
%aerialpython% udp_test_get.py test
python udp_test_get.py test
echo =========== ALL GET DONE ================
src/microwave/demo/AutoSendAndGetTest.bat
@@ -2,15 +2,9 @@
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
@REM add vitrual env python to the path
path "%~dp0/../../../../.env/Scripts/";%path%
start AutoGetUDPtest.bat 
start AutoSendUDPtest.bat
src/microwave/demo/AutoSendUDPtest.bat
@@ -2,19 +2,12 @@
@REM change to the filepath
cd %~dp0
echo change to path: %cd%
set aerialpython=%cd%/../../../env/aerial_deploy/python.exe
set envsetting=%cd%/env/SettingEnv.bat
@REM Setting the env
if not exist %aerialpython% (
    call %envsetting%
)
@REM add vitrual env python to the path
path "%~dp0/../../../../.env/Scripts/";%path%
echo All data saved in '%cd%/demoUDPData/' folder will be sent to 127.0.0.1:9911
%aerialpython% udp_test_send.py
python udp_test_send.py
echo =========== ALL SEND DONE ================
src/microwave/deviceTools.py
@@ -1,48 +1,25 @@
import datetime
import queue
from socketserver import BaseRequestHandler, UDPServer
import time
import os, sys
import open3d as o3d
from multiprocessing import  Pool
import numpy as np
import threading
from ..utils import file_fliter, write_ply
from .servers import MicroWaveReceiver
from ..utils.tools import file_fliter, write_ply
from .servers import MicroWaveReceiver,MicroWaveUDPThread
from .parsers import MicroWaveParser
# # add python path of src to sys.path
# src_path = os.path.join(__file__, *(['..'] * 2))
# src_path = os.path.abspath(src_path)
# sys.path.insert(1, src_path)
# udp_get
class PointCloudUDPRequestHandler(BaseRequestHandler):
    def handle(self):
        packet_threshold = self.server.packet_threshold
        packed_count = self.server.packed_count
        path = self.server.path
        print(time.asctime(),' Got connection from {}, {}'.format(self.client_address, packed_count))
        # Get message and client socket
        msg, sock = self.request
        time_tag = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
        f = open('{}/{}_packet{}.udp'.format(path,time_tag,packed_count), 'wb')
        f.write(msg)
        f.close()
        self.server.packed_count += 1
        self.server.udp_list.append(msg)
        if packed_count >= packet_threshold:
            UDPServer.server_close(self.server)
def udp_get_tool(microwaveHost,packetThreshold,deviceName,saveFolder,subFolder):
    # host = ''
    # host = '192.168.2.65' # use this host to get the udp data from microwave device
    port = 9911
    server =UDPServer((microwaveHost, port), PointCloudUDPRequestHandler)
    udp_queue = queue.Queue()
    udp_get_stop = threading.Event()
    if subFolder is not None:
        path = os.path.join(saveFolder,subFolder)
@@ -52,23 +29,42 @@
    if not os.path.exists(path):
        os.makedirs(path)
    server.path = os.path.abspath(path)
    server.packet_threshold = packetThreshold
    server.packed_count = 0
    server.udp_list = []
    udp_thread = MicroWaveUDPThread(MicrowaveHost=microwaveHost,
                                MicrowavePort=port,
                                udp_queue=udp_queue,
                                udp_get_stop=udp_get_stop,
                                packet_threshold=packetThreshold,
                                timeusage_threshold=None)
    udp_thread.setDaemon(True)
    udp_thread.setName("UDPGet_Thread")
    print(time.asctime(),'Server started on port', port)
    print('....')
    print('ctrl-c to quit server.')
    try:
        server.serve_forever()
        udp_thread.start()
        run = True
        while run:
            packed_count = 0
            while not udp_queue.empty():
                value = udp_queue.get()
                if value is not False:
                    time_tag = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
                    with ('{}/{}_packet{}.udp'.format(path,time_tag,packed_count), 'wb') as f:
                        f.write(udp_queue.get())
                        packed_count += 1
                else:
                    run = False
    except KeyboardInterrupt:
        server.server_close()
        udp_get_stop.set()
        print(time.asctime(),"Server Stopped")
    except:
        server.server_close()
        print(time.asctime(),"Server Stopped")
    return server.udp_list
        udp_get_stop.set()
        print(time.asctime(),"Server Stopped with unknown reasons")
# udp2bin
def udp2bin_tool(udp_folder_Or_list):
@@ -81,7 +77,7 @@
    else:
        UDPfolder = udp_folder_Or_list
        # example pod1-2022-02-21-13-25-03_packet125.udp --> 125
        sort_lambda = lambda x:int(x.split('packet')[1][:-4])
        sort_lambda = lambda x:int(x.split('packet')[-1][:-4])
        udp_files = file_fliter(UDPfolder,'udp', sort_lambda)
        Save = True
src/microwave/parsers.py
@@ -1,5 +1,3 @@
from tkinter import Frame
from .components import *
from .constants import *
from ctypes import sizeof, string_at
src/microwave/servers.py
@@ -1,10 +1,16 @@
import os, sys
from ctypes import sizeof, string_at
from socketserver import BaseRequestHandler, UDPServer
# from socketserver import _AddressType, _RequestType, BaseRequestHandler, BaseServer, UDPServer
from socketserver import BaseRequestHandler, BaseServer, UDPServer
import threading
from typing import Union
import warnings
import time
import queue
import numpy as np
from .components import *
from .constants import *
from ..protos import aerial_pb2 as pb
from .parsers import MicroWaveParser
@@ -97,6 +103,7 @@
        buf_size = len(buf)
        if buf_size == sizeof(Handshake):
            self._is_handshake(buf)
            return # there is only handshake(24 bytes) on it, end AddBuf func.
        if self.state == UDP_STATE_HAND_SHAKE:
            # after received handshake packet, we can get header block 
@@ -104,7 +111,7 @@
                # make sure to get a complete header
                result = self._get_header(buf)
            except Exception as e:
                warnings.warn(f"encounter an unknow error {e} when getting the header data in udp packets ...")
                warnings.warn(f"encounter an unknow error [{e}] when getting the header data in udp packets ...")
                result = False
            if not result:
@@ -135,38 +142,170 @@
            self.DataFrame.extend(bytes(buf))
            self._receive_footer(buf)
class UDP2PointcloudThread(threading.Thread):
    def __init__(self,
                udp_queue:queue.Queue,
                pointcloud_queue:queue.Queue,
                    ):
        self.udp_queue = udp_queue
        self.pointcloud_queue = pointcloud_queue
        super().__init__()
    def run(self):
        receiver = MicroWaveReceiver()
        print(time.asctime(),"DP2Pointcloud Thread is starting to decode the udp packets... ")
        run = True
        while run:
            while not self.udp_queue.empty():
                udp = self.udp_queue.get()
                if udp is not False:
                    receiver.AddBuf(udp)
                    if receiver.DataFrameReady:
                        buf = receiver.DataFrame
                        buf_data = MicroWaveParser.ParserFrame(buf)
                        for frame in buf_data:
                            Frame_id = frame[0]
                            FrameNumber = frame[1]
                            point_cloud = np.array(frame[2])
                            if len(point_cloud) == 0 :
                                print(f"Notice: Frame {FrameNumber} is empty!")
                            else:
                                print(time.asctime(),f"Frame {FrameNumber} ready")
                                self.pointcloud_queue.put(point_cloud)
                else:
                    run = False
                    self.pointcloud_queue.put(False)
        print(time.asctime(),"DP2Pointcloud Thread finshed to decode the udp packets... ")
class MicroWaveRequestHandler(BaseRequestHandler):
    """
    micro wave udp request handler
    """
    def __init__(self,
        request,
        client_address,
        server: BaseServer) -> None:
        super().__init__(request, client_address, server)
    def handle(self):
        # Get message and client socket
        buf, _ = self.request
        receiver = self.server.Receiver
        # add buffer to receiver
        receiver.AddBuf(buf)
        if receiver.DataFrameReady:
            # dataframe ready, add to udp_queue
            msg = pb.RequestCommand()
            msg.sys_command = pb.SysCommand.MICRO_WAVE_COMMAND
            msg.sub_command = pb.SubCommand.MICRO_WAVE_SUB_COMMAND
            data1 = pb.MicroWaveMessage()
            data1.length = len(receiver.DataFrame)
            data1.data = bytes(receiver.DataFrame)
            data1_str = data1.SerializeToString()
            msg.data1.length = len(data1_str)
            msg.data1.data = data1_str
            self.server.msg_queue.put(msg)
        if not self.server.udp_get_stop.isSet():
            buf, _ = self.request
            packed_count = self.server.packed_count
            print(f"{time.asctime()} | Got connection from {self.client_address}, {packed_count}")
            self.server.udp_queue.put(buf)
            self.server.packed_count += 1
        # else:
        #     UDPServer.server_close(self.server)
        #     self.server.udp_queue.put(False)
        #     print(f"{time.asctime()} | UDP-Get server is stopped by thresholds or keyborad interrupt.")
class MicroWaveUDPServer(UDPServer):
    """
    micro wave udp server
    """
    def __init__(self, server_address, msg_queue):
        super().__init__(server_address, MicroWaveRequestHandler)
        # create receiver instance
        self.Receiver = MicroWaveReceiver()
        self.msg_queue = msg_queue
    def __init__(self,
            server_address: tuple[str,int],
            RequestHandlerClass: MicroWaveRequestHandler,
            udp_queue:queue.Queue,
            udp_get_stop:threading.Event,
            packet_threshold:Union[int, None],
            timeusage_threshold:Union[int, None]
            ) -> None:
        self.server_address = server_address
        self.RequestHandlerClass = MicroWaveRequestHandler
        self.udp_queue = udp_queue
        self.udp_get_stop = udp_get_stop
        self.udp_get_stop.clear()
        self.packet_threshold = packet_threshold
        self.timeusage_threshold = timeusage_threshold # mins
        self.packed_count = 0
        super().__init__(server_address, RequestHandlerClass)
        print(f"[*] | Listening on address {server_address}")
        # record start time of the server
        if self.timeusage_threshold is not None:
            self.start_time = time.time()
    def service_actions(self) -> None:
        # check to stop the server via muti-thresdhold
        if self.packet_threshold is not None and \
                self.packed_count >= self.packet_threshold:
            self.udp_get_stop.set()
        if self.timeusage_threshold is not None:
            cur_time = time.time() # seconds
            time_usage = int(cur_time - self.start_time)
            if time_usage > 60*self.timeusage_threshold:
                self.udp_get_stop.set()
        if self.udp_get_stop.isSet():
            print(f"{time.asctime()} | UDP-Get server is stopped by thresholds or keyborad interrupt.")
            self.udp_queue.put(False)
            self._BaseServer__shutdown_request = True
            # self.__is_shut_down.set()
class MicroWaveUDPThread(threading.Thread):
    def __init__(self,
                MicrowaveHost:str,
                MicrowavePort:int,
                udp_queue:queue.Queue,
                udp_get_stop:threading.Event,
                packet_threshold:Union[int, None],
                timeusage_threshold:Union[int, None]
                ):
        super().__init__()
        self.MicrowaveHost = MicrowaveHost
        self.MicrowavePort = MicrowavePort
        self.udp_queue = udp_queue
        self.udp_get_stop = udp_get_stop
        self.packet_threshold = packet_threshold
        self.timeusage_threshold = timeusage_threshold
    def stop(self):
        """stop the server to stop the """
        self.udp_get_stop.set()
    def run(self):
        logs_list = []
        server = MicroWaveUDPServer(server_address=(self.MicrowaveHost,self.MicrowavePort),
                                    RequestHandlerClass=MicroWaveRequestHandler,
                                    udp_queue=self.udp_queue,
                                    udp_get_stop=self.udp_get_stop,
                                    packet_threshold=self.packet_threshold,
                                    timeusage_threshold=self.timeusage_threshold
                                    )
        try:
            print(time.asctime(),"UDP Getting Server is starting to capture the udp packet... ")
            server.serve_forever()
            print(time.asctime(),"UDP Getting Server finshed to capture the udp packet ")
        except Exception as e:
            print(e)
            server.server_close()
            self.udp_get_stop.set()
            print(time.asctime(),"[ERROR] UDP Getting Server Stopped with Unknown Reason!")
src/protos/aerial.proto
@@ -1,125 +1,159 @@
syntax = "proto3";
enum SysCommand {
  UNKOWN_COMMAND     = 0;   // 未知命令
  SYS_COMMAND        = 1;   // 系统命令
  SENSOR_COMMAND     = 2;   // 传感器命令
  FIVE_G_COMMAND     = 3;   // 通讯5G模块命令
  CAMERA_COMMAND     = 4;   // 摄像头参数命令
  IO_COMMAND         = 5;   // 外设IO口操作命令
  SYS_PARAMS_COMMAND = 6;   // 系统参数获取
  WIFI_COMMAND       = 7;   // 设备WIFI参数设置
  KERNEL_COMMAND     = 8;   // 核心计算参数设
  DEVICE_COMMAND     = 9;   // 工作设备参数设置
  MICRO_WAVE_COMMAND = 10;  // 毫米波
}
// enum SysCommand {
//   UNKOWN_COMMAND     = 0;   // 未知命令
//   SYS_COMMAND        = 1;   // 系统命令
//   SENSOR_COMMAND     = 2;   // 传感器命令
//   FIVE_G_COMMAND     = 3;   // 通讯5G模块命令
//   CAMERA_COMMAND     = 4;   // 摄像头参数命令
//   IO_COMMAND         = 5;   // 外设IO口操作命令
//   SYS_PARAMS_COMMAND = 6;   // 系统参数获取
//   WIFI_COMMAND       = 7;   // 设备WIFI参数设置
//   KERNEL_COMMAND     = 8;   // 核心计算参数设
//   DEVICE_COMMAND     = 9;   // 工作设备参数设置
//   MICRO_WAVE_COMMAND = 10;  // 毫米波
// }
enum SubCommand {
  option allow_alias = true;
// enum SubCommand {
//   option allow_alias = true;
   
  UNKOWN_SUB_COMMAND   = 0;                   // 未知子命令
//   UNKOWN_SUB_COMMAND   = 0;                   // 未知子命令
  // 系统命令
  POWER_ON_SUB_COMMAND = 1;                   // 开机
  POWER_OFF_SUB_COMMAND = 2;                  // 关机
//   // 系统命令
//   POWER_ON_SUB_COMMAND = 1;                   // 开机
//   POWER_OFF_SUB_COMMAND = 2;                  // 关机
  // 传感器命令
  SENSOR_INIT_SUB_COMMAND = 1;                // 传感器初始化
  SENSOR_REQURE_SUB_COMMAND = 2;              // 传感器参数获取
  RTK_SETTING_SUB_COMMAND = 3;                // RTK外设参数设置
  RTK_REQURE_SUB_COMMAND = 4;                 // RTK外设数据获取
//   // 传感器命令
//   SENSOR_INIT_SUB_COMMAND = 1;                // 传感器初始化
//   SENSOR_REQURE_SUB_COMMAND = 2;              // 传感器参数获取
//   RTK_SETTING_SUB_COMMAND = 3;                // RTK外设参数设置
//   RTK_REQURE_SUB_COMMAND = 4;                 // RTK外设数据获取
  // 通讯5G模块命令
  FIVE_G_INIT_SUB_COMMAND = 1;                // 5G模块参数初始化
  FIVE_G_SEND_IMAGE_SUB_COMMAND = 2;          // 5G通讯图像数据发送
  FIVE_G_REQURE_SUB_COMMAND = 3;              // 5G通讯接收
//   // 通讯5G模块命令
//   FIVE_G_INIT_SUB_COMMAND = 1;                // 5G模块参数初始化
//   FIVE_G_SEND_IMAGE_SUB_COMMAND = 2;          // 5G通讯图像数据发送
//   FIVE_G_REQURE_SUB_COMMAND = 3;              // 5G通讯接收
  // 摄像头参数命令
  CAMERA_NUMBER_SUB_COMMAND = 1;              // 设备摄像头个数
  CAMERA_RESOLUTION_SUB_COMMAND = 2;          // 设备摄像头工作分辨率
  CAMERA_FRAME_RATE_SUB_COMMAND = 3;          // 摄像头工作帧率
  CAMERA_OTHER_PARAMS_SUB_COMMAND = 4;        // 摄像头工作其他参数
//   // 摄像头参数命令
//   CAMERA_NUMBER_SUB_COMMAND = 1;              // 设备摄像头个数
//   CAMERA_RESOLUTION_SUB_COMMAND = 2;          // 设备摄像头工作分辨率
//   CAMERA_FRAME_RATE_SUB_COMMAND = 3;          // 摄像头工作帧率
//   CAMERA_OTHER_PARAMS_SUB_COMMAND = 4;        // 摄像头工作其他参数
  // 外设IO口操作命令
  CAMERA_DUST_REMOVAL_START_SUB_COMMAND = 1;  // 摄像头除尘启动
  CAMERA_CONTROL_START_SUB_COMMAND = 2;       // 外设控制数据启动(18路控制)
//   // 外设IO口操作命令
//   CAMERA_DUST_REMOVAL_START_SUB_COMMAND = 1;  // 摄像头除尘启动
//   CAMERA_CONTROL_START_SUB_COMMAND = 2;       // 外设控制数据启动(18路控制)
  // 系统参数获取
  CPU_FREQUENCY_SUB_COMMAND = 1;              // CPU主频工作数据
  CPU_KERNAL_TEMP_SUB_COMMAND = 2;            // CPU核心温度数据
  CPU_BETTERY_DATA_SUB_COMMAND = 3;           // 电池供电电量数据
//   // 系统参数获取
//   CPU_FREQUENCY_SUB_COMMAND = 1;              // CPU主频工作数据
//   CPU_KERNAL_TEMP_SUB_COMMAND = 2;            // CPU核心温度数据
//   CPU_BETTERY_DATA_SUB_COMMAND = 3;           // 电池供电电量数据
  // 设备WIFI参数设置
  WIFI_HOTSPOT_SETTING_SUB_COMMAND = 1;       // WIFI热点设置
  WIFI_HOTSPOT_START_STOP_SUB_COMMAND = 2;    // WIFI热点开启和关闭
//   // 设备WIFI参数设置
//   WIFI_HOTSPOT_SETTING_SUB_COMMAND = 1;       // WIFI热点设置
//   WIFI_HOTSPOT_START_STOP_SUB_COMMAND = 2;    // WIFI热点开启和关闭
  // 核心计算参数设置
  POINT_CLOUD_ACCURACY_SUB_COMMAND = 1;       // 点云计算精度
  SPLICING_PARAMS_SUB_COMMAND = 2;            // 拼接参数
  MAP_INTERFACE_PLATFORM_SUB_COMMAND = 3;     // 地图接口平台
  DATA_STORE_BACKUP_SUB_COMMAND = 4;          // 数据存储备份
//   // 核心计算参数设置
//   POINT_CLOUD_ACCURACY_SUB_COMMAND = 1;       // 点云计算精度
//   SPLICING_PARAMS_SUB_COMMAND = 2;            // 拼接参数
//   MAP_INTERFACE_PLATFORM_SUB_COMMAND = 3;     // 地图接口平台
//   DATA_STORE_BACKUP_SUB_COMMAND = 4;          // 数据存储备份
  // 工作设备参数设置
  SYSTEM_TIMER_SUB_COMMAND = 1;               // 系统工作定时
  SYSTEM_COORD_HEIGHT_SUB_COMMAND = 2;        // 工作区域坐标与高度
  TRIGGER_CONDITION_SUB_COMMAND = 3;          // 工作触发条件
  GRAVITY_FAILURE_SUB_COMMAND = 4;            // 重力加速度失效参数
  NINE_AXIS_FAILURE_SUB_COMMAND = 5;          // 九轴加速度失效参数
//   // 工作设备参数设置
//   SYSTEM_TIMER_SUB_COMMAND = 1;               // 系统工作定时
//   SYSTEM_COORD_HEIGHT_SUB_COMMAND = 2;        // 工作区域坐标与高度
//   TRIGGER_CONDITION_SUB_COMMAND = 3;          // 工作触发条件
//   GRAVITY_FAILURE_SUB_COMMAND = 4;            // 重力加速度失效参数
//   NINE_AXIS_FAILURE_SUB_COMMAND = 5;          // 九轴加速度失效参数
  // 毫米波
  MICRO_WAVE_SUB_COMMAND = 1;                 // 毫米波
//   // 毫米波
//   MICRO_WAVE_SUB_COMMAND = 1;                 // 毫米波
// }
// message DataField {
//   int32 length = 1;                           // 数据长度
//   bytes data = 2;                            // 数据内容
//   int32 checksum = 3;                        // 校验码
// }
// message CapturedData {
//   int64 capture_time = 1;                     // 采集时间
//   string capture_device =2;                   // 采集设备
//   int32 capture_port = 3;                     // 采集设备序号
//   DataField DataField = 4;
//   string data_type = 5;                         // 数据类型 image udp
// }
// message DataMessage{
//   int64 sending_time = 1;
//   string sending_device = 2;
//   string target_device = 3;
//   CapturedData CapturedData = 5;
// }
// message StateData {
//  int64 state_time = 1;
//  string state_device = 2;
//  DataField DataField = 4;
// }
// message StateMessage {
//   int64 sending_time = 1;
//   string sending_device = 2;
//   string target_device = 3;
//   CapturedData StatedData = 5;
// }
// message CommandData {
//   SysCommand SysCommand = 1;
//   SubCommand SubCommand = 2;
// }
// message CommandMessage {
//   int64 sending_time = 1;
//   string sending_device = 2;
//   string target_device = 3;
//   CommandData CommandData =4;
// }
enum SysCommand{
  UNKOWN_COMMAND     = 0;
  CAMERA_COMMAND     = 1;
  MICROWAVE_COMMAND   = 2;
  DUSTCLEANER_COMMAND   = 3;
}
message DataField {
  int32 length = 1;                           // 数据长度
  bytes data = 2;                            // 数据内容
  int32 checksum = 3;                        // 校验码
enum SubCommand{
  UNKOWN_SUBCOMMAND     = 0;
  // camera params
  ONE_TIME_CAPTURE      = 1;
  // microwave params
  ONE_CIRCLE_SCAN       = 2;
  // dust cleaner params
  ONE_CLEAN_SCAN        = 4;
}
message CapturedData {
  int64 capture_time = 1;                     // 采集时间
  string capture_device =2;                   // 采集设备
  int32 capture_port = 3;                     // 采集设备序号
  DataField DataField = 4;
  string data_type = 5;                         // 数据类型 image udp
}
message DataMessage{
  int64 sending_time = 1;
  string sending_device = 2;
  string target_device = 3;
  CapturedData CapturedData = 5;
}
message StateData {
 int64 state_time = 1;
 string state_device = 2;
 DataField DataField = 4;
}
message StateMessage {
  int64 sending_time = 1;
  string sending_device = 2;
  string target_device = 3;
  CapturedData StatedData = 5;
}
message CommandData {
  SysCommand SysCommand = 1;
  SubCommand SubCommand = 2;
}
message CommandMessage {
  int64 sending_time = 1;
  string sending_device = 2;
  string target_device = 3;
  CommandData CommandData =4;
message CommandMessage{
  string source = 1;
  string generatetime = 2;
  SysCommand syscommand = 3;
  SubCommand subcommand = 4;
  string targetclient = 5;
  string returnserver = 6;
  string taskuuid = 7;
}
message LogsMessage{
  string source = 1;
  string timestamp = 2;
  string context = 3;
  optional string taskuuid = 4;
}
@@ -135,20 +169,45 @@
  }
  repeated ImageItems Image = 3;
  optional string taskuuid = 4;
}
message PlyMessage
message PlysMessage
{
  string source = 1;
  string timestamp = 2;
  bytes plydata = 3;
  message PointCloudItem
  {
    int32 length = 1;
    int32 rows = 2;
    int32 cols = 3;
    string order = 4;
    string dtype = 5;
    bytes data = 6;
  }
  repeated PointCloudItem Plydata = 3;
  optional string taskuuid = 4;
  // enum ref_system
  // {
  //   MICROWAVE_SYSTEM = 0;
  //   DEVICE_SYSTEM = 1;
  // }
  // ref_system reference = 4
}
// message MicroWaveMessage
// {
//   int32 length = 1;                           // 数据长度
src/protos/compile.bat
@@ -3,8 +3,9 @@
@REM change to the filepath
cd %~dp0
set protoc=%cd%/../../.env/Library/bin/protoc.exe
path "%~dp0/../../.env/Scripts";%path%
@REM call "%cd%/../../.env/Scripts/activate.bat"
%protoc% aerial.proto --python_out=%cd%
python -m protoc aerial.proto --python_out=%cd%
echo protoc: aerial.proto compile done!
src/requirements.yaml
File was deleted
src/slam/__init__.py
@@ -1,3 +1,3 @@
from .core import *
from .manualMode import *
from .autoMode import *
# from .core import *
# from .manualMode import *
# from .autoMode import *
src/utils/__init__.py
@@ -1 +1 @@
from .tools import *
# from .tools import *
src/utils/tools.py
@@ -1,8 +1,8 @@
from email import header
import os, sys
import numpy as np
import time
from tqdm import tqdm
from datetime import datetime
def file_fliter(folder:str, file_ext:str, sort_format = None):
@@ -76,10 +76,27 @@
                header="".join(header),
                comments="",
                fmt=fmt)
    print(f"{time.asctime()} {name}.ply have been saved with {n_p} points!")
    print(f"{time.asctime()} | {name}.ply have been saved with {n_p} points!")
def update_folder_for_today(folder_tree:dict[str,str]):
    """
    "sup_folder" + "today" +"sub_folder" >> "today_folder"
    """
    try:
        sup = folder_tree["sup_folder"]
        sub = folder_tree["sub_folder"]
        today = datetime.now().strftime('%Y-%m-%d')
        today_folder = os.path.join(sup,today,sub)
        folder_tree["today"] = today
        folder_tree["today_folder"] = today_folder
    except Exception as e:
        raise ValueError(f"{e}")
if __name__ == "__main__":
    ply_array = read_ply('src\\microwave\\demo\\demoData\\2522.ply')