wu_xinjun
2022-06-07 aa8a0ba3a86ff5dbbdfcd68c72a5e70e1c52e877
optimize for mq
2个文件已添加
11个文件已修改
268 ■■■■■ 已修改文件
scripts/mqClient.py 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts/mqServer.py 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_startClient.bat 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts_launch/TEST_startServer.bat 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Client.py 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/Server.py 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/__init__.py 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/AcquisitionMain.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/CaptureThread.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/ControllThread.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/DustCleanerThread.py 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/MessageQueueThread.py 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/engine/MicroWaveUDPThread.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
scripts/mqClient.py
New file
@@ -0,0 +1,54 @@
import signal
import os, sys
# 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)
from src.engine.AcquisitionMain import AcquisitionMain
from src.engine.AcquisitionMain import Config
def quit(signum, frame):
    print('You choose to stop me.')
    sys.exit()
if __name__ == '__main__':
    def help():
        print("Usage: Client.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [DEVICEname] [SERVERhost] [MICROWAVEhost]")
        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:
        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])
    except Exception as e:
        print(e)
        help()
    print("Start AcquisitionMain")
    signal.signal(signal.SIGINT, quit)
    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)
    client = AcquisitionMain(MQhost,
                             MQuser,
                             MQpassword,
                             QUEUEname,
                             DEVICEname,
                             SERVERhost,
                             MICROWAVEhost, # udp server host, 192.168.2.65 for production
                             config)
    client.start()
scripts/mqServer.py
New file
@@ -0,0 +1,33 @@
import sys
import os
# 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)
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:
        help()
    try:
        MQhost = str(sys.argv[1])
        MQuser = str(sys.argv[2])
        MQpassword = str(sys.argv[3])
        QUEUEname = str(sys.argv[4])
        WEBport = int(sys.argv[5])
        SAVEfolder = str(sys.argv[6])
        save_folder = SAVEfolder
    except Exception as e:
        print(e)
        help()
    server = MyServer(host=MQhost, user=MQuser, password=MQpassword, queue=QUEUEname, port=WEBport, SAVEfolder=save_folder)
    server.run_all()
scripts_launch/TEST_startClient.bat
@@ -16,7 +16,7 @@
echo change to path: %cd%
set MQhost=192.168.1.224
set MQhost=localhost
set MQuser=chai
set MQpassword=password123
set QUEUEname=aerial_rpc
@@ -30,6 +30,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% ./src/Client.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost%
%aerialpython% ./scripts/mqClient.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %DEVICEname% %SERVERhost% %MICROWAVEhost%
echo Client.py has been terminited.
pause
scripts_launch/TEST_startServer.bat
@@ -16,7 +16,8 @@
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
@@ -29,7 +30,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%
%aerialpython% ./scripts/mqServer.py %MQhost% %MQuser% %MQpassword% %QUEUEname% %WEBport% %SAVEfolder%
echo Server.py has been terminited.
pause
src/Client.py
@@ -1,49 +1,49 @@
import signal
import os, sys
# import signal
# import os, sys
from .engine.AcquisitionMain import AcquisitionMain
from .engine.AcquisitionMain import Config
# from .engine.AcquisitionMain import AcquisitionMain
# from .engine.AcquisitionMain import Config
def quit(signum, frame):
    print('You choose to stop me.')
    sys.exit()
# def quit(signum, frame):
#     print('You choose to stop me.')
#     sys.exit()
if __name__ == '__main__':
    def help():
        print("Usage: Client.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [DEVICEname] [SERVERhost] [MICROWAVEhost]")
        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 __name__ == '__main__':
#     def help():
#         print("Usage: Client.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [DEVICEname] [SERVERhost] [MICROWAVEhost]")
#         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:
        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])
#     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])
#         DEVICEname = str(sys.argv[5])
#         SERVERhost = str(sys.argv[6])
#         MICROWAVEhost = str(sys.argv[7])
    except Exception as e:
        print(e)
        help()
#     except Exception as e:
#         print(e)
#         help()
    print("Start AcquisitionMain")
    signal.signal(signal.SIGINT, quit)
    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__, "..", "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()
#     print("Start AcquisitionMain")
#     signal.signal(signal.SIGINT, quit)
#     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__, "..", "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()
src/Server.py
@@ -9,13 +9,16 @@
class MyServer(Flask):
    def __init__(self, host, user, password, queue, port):
    def __init__(self, host, user, password, queue, port, SAVEfolder):
        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.route('/api', methods=['POST'])(self.api)
        self.route('/', methods=['GET'])(self.hello)
@@ -84,27 +87,3 @@
        msg.data1.length = len(data1_str)
        msg.data1.data = data1_str
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:
        help()
    try:
        MQhost = str(sys.argv[1])
        MQuser = str(sys.argv[2])
        MQpassword = str(sys.argv[3])
        QUEUEname = str(sys.argv[4])
        WEBport = int(sys.argv[5])
        SAVEfolder = str(sys.argv[6])
        global save_folder
        save_folder = SAVEfolder
    except Exception as e:
        print(e)
        help()
    server = MyServer(host="localhost", user='chai', password='password123', queue='aerial_rpc', port=5000)
    server.run_all()
src/__init__.py
@@ -0,0 +1,5 @@
from .engine import *
from .microwave import *
from .protos import *
from .slam import *
from .utils import *
src/engine/AcquisitionMain.py
@@ -12,12 +12,12 @@
from .ControllThread import ControllThread
from .MicroWaveUDPThread import MicroWaveUDPThread
# 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)
# # 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 ..protos import aerial_pb2 as pb
IMAGE_WIDTH = 3840
src/engine/CaptureThread.py
@@ -6,12 +6,12 @@
import time
# 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)
# # 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 ..protos import aerial_pb2 as pb
class CaptureThread(threading.Thread):
src/engine/ControllThread.py
@@ -6,12 +6,12 @@
import threading
from .DustCleanerThread import DustCleanerThread
# 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)
# # 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 ..protos import aerial_pb2 as pb
class ControllThread(threading.Thread):
    """
src/engine/DustCleanerThread.py
@@ -5,12 +5,12 @@
from .DustCleaner import DustCleaner
# 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)
# # 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 ..protos import aerial_pb2 as pb
src/engine/MessageQueueThread.py
@@ -5,13 +5,13 @@
from ctypes import sizeof
from .DeviceManager import DeviceManager
# 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)
# # 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 microwave.components import HeaderBlock
from protos import aerial_pb2 as pb
from ..microwave.components import HeaderBlock
from ..protos import aerial_pb2 as pb
class MessageQueueThread(threading.Thread):
    def __init__(self,
src/engine/MicroWaveUDPThread.py
@@ -6,7 +6,7 @@
src_path = os.path.abspath(src_path)
sys.path.insert(0, src_path)
from microwave.servers import MicroWaveUDPServer
from ..microwave.servers import MicroWaveUDPServer
class MicroWaveUDPThread (threading.Thread):