Casper преди 2 месеца
родител
ревизия
e53dda69e7

+ 1 - 1
sri-server-bg01/Dockerfile

@@ -67,7 +67,7 @@ RUN echo "Install Python Requirements:" \
 #        aiofiles==0.6.0 \
 #        python-multipart==0.0.5 \
 #        starlette==0.13.6 \
-#        fastapi==0.63.0 \
+#        fastapi==0.64.0 \
 #        fastapi-login==1.5.2 \
 #        supervisor==4.2.1 \
 #        uvicorn==0.13.3 \

+ 0 - 0
sri-server-bg03/1.txt


+ 0 - 46
sri-server-bg03/Dockerfile

@@ -1,46 +0,0 @@
-#FROM ubuntu:20.04
-FROM docker.m.daocloud.io/ubuntu:20.04
-ENV DEBIAN_FRONTEND noninteractive
-#FROM docker.m.daocloud.io/ubuntu:18.04
-
-RUN echo "Debug Tools:" \
-    && apt-get update \
-    && apt-get install -y inetutils-ping iproute2 net-tools wget unzip git bash
-
-RUN echo "Install Python v3.8:" \
-    && apt-get update \
-    && apt-get install -y  \
-        python3-dev \
-        python3-pip \
-        python3-setuptools \
-        python3-wheel \
-    && pip3 config set global.index-url https://mirror.baidu.com/pypi/simple \
-    && pip3 config set global.extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple \
-    && pip3 install --upgrade --quiet pip setuptools \
-    && python3 --version
-
-RUN echo "部署:安装protobuf" \
-    && apt update \
-    && apt install -y protobuf-compiler python3-protobuf \
-    && protoc --version
-
-#RUN echo "Install Python Requirements:" \
-#    && pip3 install --default-timeout=1800 --no-cache-dir \
-#        # --- for base --- \
-#        cython==3.0.0a9 \
-#        pyinstaller==4.10 \
-#        # --- for libraries --- \
-#        pycrypto==2.6.1 \
-#        paramiko==2.7.2 \
-#        apscheduler==3.7.0 \
-#        # --- for client --- \
-#        requests==2.25.1 \
-#        redis==3.5.3 \
-#        pymongo==3.11.2 \
-#        influxdb==5.3.1 \
-#        pymysql==0.9.3 \
-#        peewee==3.17.0 \
-#        SQLAlchemy==1.4.30 \
-#        paho-mqtt==1.6.1 \
-#    && echo "End."
-

+ 0 - 3
sri-server-bg03/README-usage-win.bash

@@ -1,3 +0,0 @@
-## USAGE
-
-pip install -r 1.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

+ 0 - 40
sri-server-bg03/README-usage.bash

@@ -1,40 +0,0 @@
-## NOTE
-
-echo "执行:构建调试" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml down \
-&& sudo docker-compose --file compose.yml up --detach --build \
-&& sudo docker exec -it sri-server-bg03 bash
-
-echo "执行:初装启动" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml down \
-&& sudo docker-compose --file compose.yml up --detach --build \
-&& sudo docker-compose --file compose.yml logs --follow
-
-echo "执行:开发调试" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml down \
-&& sudo docker-compose --file compose.yml up --detach \
-&& sudo docker exec -it sri-server-bg03 bash
-
-echo "执行:停服更新" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml down \
-&& sudo docker-compose --file compose.yml up --detach \
-&& sudo docker-compose --file compose.yml logs --follow
-
-echo "执行:代码更新" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml restart \
-&& sudo docker-compose --file compose.yml logs --follow
-
-echo "执行:跟踪日志" \
-&& project_path="/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03" \
-&& cd ${project_path} \
-&& sudo docker-compose --file compose.yml logs --follow

+ 0 - 6
sri-server-bg03/README.md

@@ -1,6 +0,0 @@
-## socket服务
-
-#### INFO
-
-* 用途:湛江项目
-* 状态:进行中(2024年7月)

+ 0 - 38
sri-server-bg03/compose.yml

@@ -1,38 +0,0 @@
-version: '3.5'
-services:
-
-    sri-server-bg03:
-
-        # --- building ---
-        image: sri-server-bg03:2024
-        build:
-            context: ./
-            dockerfile: ./Dockerfile
-        environment:
-            TZ: Asia/Shanghai
-
-        # --- binding ---
-        volumes:
-            - /home:/home
-        networks:
-            - sri_network
-        ports:
-            - "20916:20916"
-            - "20917:20917"
-
-        # --- running ---
-        container_name: sri-server-bg03
-
-        # --- for debug ---
-#        working_dir: /home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03
-#        stdin_open: true
-#        tty: true
-
-        # --- for release ---
-        working_dir: /home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03
-        command: bash run.sh
-        restart: always
-
-networks:
-    sri_network:
-        external: true

+ 0 - 15
sri-server-bg03/hub.py

@@ -1,15 +0,0 @@
-import sys
-import importlib
-
-sys.path.append('../3rdparty')
-
-methods = importlib.import_module(f"xlib")
-
-
-class Global(object):
-    pb = importlib.import_module(f"protobuf.protocol_pb2")
-
-    # emqx = importlib.import_module(f"xclient.xmqtt").Client(host='10.10.61.229', port=41883)
-
-    mdb = importlib.import_module(f"xclient.xmongo").Client(host='58.34.94.178', port=7030, database='bg',
-                                                            username='admin', password='admin')

+ 0 - 59
sri-server-bg03/lib/ConnectionMessage.py

@@ -1,59 +0,0 @@
-# # from hub import methods, Global
-#
-# import threading
-# import time
-# import json
-#
-# sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03')
-# protobuf = importlib.import_module(f"protobuf.protocol_pb2")
-#
-#
-# class ConnectionMessage(object):
-#     """消息处理"""
-#
-#     fn_dict = {
-#         protobuf.CS_Offer: ConnectionMessage.f1,
-#     }
-#
-#     @staticmethod
-#     def f1(client, userdata, message):
-#         pass
-#
-#     @staticmethod
-#     def decorate_method(client, userdata, message):
-#         """消息处理方法"""
-#         file_name = methods.now_string('%Y-%m-%d.log')
-#         log_file_path = f"/home/server/logs/{file_name}"
-#         log_dict = json.loads(message.payload)
-#         # methods.debug_log(f"MessageListener.20", f"#log_dict: {log_dict}")
-#
-#         log_list = list()
-#         for i in range(1, 5):
-#             v = str(log_dict.get(str(i)))
-#             log_list.append(v)
-#         methods.write_text(log_file_path, '|'.join(log_list) + '\n', 'a')
-#         methods.debug_log(f"MessageListener.24", f"#message.payload: {json.loads(message.payload)}")
-#
-#     @classmethod
-#     def start_check_loop(cls):
-#
-#         # --- check ---
-#         save_dir = f"/home/server/logs"
-#         if not methods.is_dir(save_dir):
-#             out = methods.run_command(f'mkdir -p {save_dir}', callback=True)
-#             methods.debug_log('MessageListener.33', f"#out: {out}")
-#
-#         Global.emqx.start_subscribe_loop(
-#             decorate_method=MessageListener.decorate_method,
-#             subscribe_topic='bg/log'
-#         )
-#
-#     @classmethod
-#     def run_background(cls, background_is=True):
-#         """"""
-#         p1 = threading.Thread(target=cls.start_check_loop)
-#         p1.start()
-#
-#
-# if __name__ == '__main__':
-#     MessageListener.run_background()

+ 0 - 84
sri-server-bg03/lib/ConnectionTest.py

@@ -1,84 +0,0 @@
-import socket
-import struct
-import traceback
-import time
-
-import sys
-import importlib
-
-# --- for linux
-# sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03')
-# sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/3rdparty')
-# host, port = '127.0.0.1', 20916
-# host, port = '127.0.0.1', 20917
-
-# --- for windows
-sys.path.append(r'E:\casper\repositories\repositories\sri-project.demo-py\sri-server-bg03')
-sys.path.append(r'E:\casper\repositories\repositories\sri-project.demo-py\3rdparty')
-host, port = '58.34.94.178', 20916
-# host, port = '58.34.94.178', 20917
-
-protobuf = importlib.import_module(f"xprotobuf.protocol_pb2")
-methods = importlib.import_module(f"xlib")
-
-
-
-def test():
-    head_sequence = '<hh'  # 字节序规则
-    head_size = struct.calcsize(head_sequence)
-
-    try:
-        client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        # client.bind(('localhost', port))
-        client.connect((host, port))
-
-        # --- send
-        object = protobuf.CSSign()
-        object.account = 'admin'
-        object.password = '123456'
-        head = protobuf.CS_Sign, object.ByteSize()
-        head_bytestream = struct.pack(head_sequence, *head)
-        body_bytestream = object.SerializeToString()
-        send_bytestream = head_bytestream + body_bytestream
-        print(f"Sent data: {send_bytestream}")
-        client.sendall(send_bytestream)
-
-        # 等待接收
-        count = 0
-        while True:
-
-            # --- 解析数据头
-            head_bytestream = client.recv(head_size)
-            if not head_bytestream:
-                continue
-            command_id, body_length = struct.unpack(head_sequence, head_bytestream)
-            methods.debug_log('Connection.284', f"Received values: {command_id, body_length}")
-
-            # --- 解析数据体
-            body_bytestream = client.recv(body_length)
-            object = protobuf.SCSign()
-            object.ParseFromString(body_bytestream)
-            print(f"Received Response: ret={object.ret}, name={object.name}")
-
-            # --- debug
-            count += 1
-            print(f"count: {count}")
-
-            # --- 发送1次就退出
-            # break
-
-            # --- 发送1次后等待
-            continue
-
-
-    except Exception as exception:
-
-        print(f"#exception: {exception.__class__.__name__}")
-        print(f"#traceback: {traceback.format_exc()}")
-
-    finally:
-        client.close()
-
-
-if __name__ == "__main__":
-    test()

+ 0 - 381
sri-server-bg03/lib/Connection_a1.py

@@ -1,381 +0,0 @@
-# from hub import methods, Global
-
-import threading
-import socket
-import struct
-import time
-# import cv2
-# import base64
-# import asyncio
-
-import sys
-import importlib
-
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03')
-protobuf = importlib.import_module(f"protobuf.protocol_pb2")
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/3rdparty')
-methods = importlib.import_module(f"xlib")
-
-
-class Connection(object):
-    """"""
-
-    tcp_server = None
-    tcp_client = None
-    all_connection_dict = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
-
-    @classmethod
-    def get_method_by_command_id(cls, command_id):
-        """获取方法名"""
-        fn_dict = {
-            protobuf.CS_Sign: cls.f1,  # 建立webrtc邀请
-        }
-        return fn_dict.get(command_id)
-
-    @classmethod
-    def f1(cls):
-        pass
-
-    # @classmethod
-    # def run_forever(cls):
-    #     """
-    #     调用协程方法
-    #     """
-    #     tasks = [cls.check_send()]
-    #     _loop = asyncio.new_event_loop()
-    #     asyncio.set_event_loop(_loop)
-    #     loop = asyncio.get_event_loop()
-    #     loop.run_until_complete(asyncio.wait(tasks))
-
-    # @classmethod
-    # async def check_send(cls):
-    #
-    #     # --- define ---
-    #     last_send_id = str()
-    #
-    #     while True:
-    #
-    #         try:
-    #             # --- fill face_type_name_dict ---
-    #             """
-    #             face_type_name_dict = {<type_uuid>: <name>}
-    #             """
-    #             face_type_name_dict = dict()
-    #             for item in Global.mdb.get_all('FaceType'):
-    #                 uuid = str(item.get('_id'))
-    #                 face_type_name_dict[uuid] = item.get('name')
-    #
-    #             # --- debug ---
-    #             # methods.debug_log(f"LineManage", f"m-21: run at {methods.now_string()} "
-    #             #                                  f"| {len(cls.line_dict.values())}")
-    #             # await asyncio.sleep(3)
-    #             # await asyncio.sleep(0.5)
-    #
-    #             # --- get send_data ---
-    #             """
-    #             send_data = {
-    #                 send_id: 数据id
-    #                 send_list: 数据列表
-    #             }
-    #             """
-    #             send_data = Global.rdb.get_one(key='send_data')
-    #             # send_data = db0.get_one(key='send_data')
-    #
-    #             # --- check ---
-    #             if not send_data:
-    #                 continue
-    #
-    #             # --- check ---
-    #             send_id = send_data.get('send_id')
-    #             if not send_id:
-    #                 continue
-    #
-    #             # --- check ---
-    #             if send_id == last_send_id:
-    #                 continue
-    #
-    #             # --- check ---
-    #             send_list = send_data.get('send_list')
-    #             if send_list is None or len(send_list) == 0:
-    #                 continue
-    #
-    #             # --- debug ---
-    #             # await asyncio.sleep(3)
-    #             # await asyncio.sleep(0.5)
-    #             methods.debug_log(f"LineManage", f"m-74: run at {methods.now_string()} "
-    #                                              f"| send count is {len(send_list)} "
-    #                                              f"| online count is {len(cls.line_dict.values())}")
-    #
-    #             # --- update ---
-    #             last_send_id = send_id
-    #
-    #             # --- send ---
-    #             for line_id in list(cls.line_dict.keys()):
-    #
-    #                 try:
-    #
-    #                     # --- check ---
-    #                     if not cls.check_line_is_live(line_id):
-    #                         methods.debug_log(f"LineManage", f"m-56: websocket link broken.")
-    #                         cls.line_dict.pop(line_id)
-    #                         continue
-    #
-    #                     # --- send ---
-    #                     """
-    #                     send_list = [
-    #                         {
-    #                             base_face_uuid: 底库人脸id
-    #                             snap_face_image: 抓拍人脸
-    #                             base_face_image_path: 底库人脸路径
-    #                             face_similarity: 相似度
-    #                         }
-    #                     ]
-    #                     """
-    #                     for data in send_list:
-    #
-    #                         # --- check ---
-    #                         if data.get('snap_face_image') is None:
-    #                             continue
-    #
-    #                         # --- define ---
-    #                         """
-    #                         send_dict = {
-    #                             input_face_b64: 抓拍人脸图像
-    #                             face_uuid: 人脸id
-    #                             face_name: 人脸名称
-    #                             known_face_b64: 底库人脸图像
-    #                             face_similarity: 相似度
-    #                             face_type_name_list: 人员类型
-    #                         }
-    #                         """
-    #                         send_dict = dict(
-    #                             input_face_b64=cls.image_to_b64(data.get('snap_face_image')),
-    #                             # input_face_b64=str(),
-    #                             known_face_b64=str(),
-    #                             face_uuid=str(),
-    #                             face_name=str(),
-    #                             face_similarity=data.get('face_similarity'),
-    #                             face_type_name_list=list(),
-    #                         )
-    #
-    #                         # --- fill known_face_b64 ---
-    #                         base_face_image_path = data.get('base_face_image_path')
-    #                         if base_face_image_path and methods.is_file(base_face_image_path):
-    #                             frame = cv2.imread(base_face_image_path)
-    #                             if frame is not None:
-    #                                 _, image = cv2.imencode('.jpg', frame)
-    #                                 base64_data = base64.b64encode(image)  # byte to b64 byte
-    #                                 s = base64_data.decode()  # byte to str
-    #                                 send_dict['known_face_b64'] = f'data:image/jpeg;base64,{s}'
-    #
-    #                         # --- fill face_uuid and face_name ---
-    #                         """
-    #                         Face: 陌生人脸表
-    #                         Face.face_name: 人脸名称
-    #                         """
-    #                         face_uuid = data.get('base_face_uuid')
-    #                         if face_uuid:
-    #                             send_dict['face_uuid'] = face_uuid
-    #                             face = Global.mdb.get_one_by_id('Face', face_uuid)
-    #                             if face and face.get('face_name'):
-    #                                 send_dict['face_name'] = face.get('face_name')
-    #
-    #                             # --- fill face_type_name_list ---
-    #                             face_type_uuid_list = face.get('face_type_uuid_list')
-    #                             if face_type_uuid_list:
-    #                                 send_dict['face_type_name_list'] = [face_type_name_dict.get(i)
-    #                                                                     for i in face_type_uuid_list
-    #                                                                     if face_type_name_dict.get(i)]
-    #
-    #                         # --- send ---
-    #                         # methods.debug_log(f"LineManage", f"m-153: send_dict is {send_dict}")
-    #                         line = cls.line_dict.get(line_id)
-    #                         send_json = methods.json_dumps(send_dict)
-    #                         await line.send_text(send_json)
-    #                         # await asyncio.sleep(0.1)
-    #
-    #                 except Exception as exception:
-    #
-    #                     # --- check ---
-    #                     if not cls.check_line_is_live(line_id):
-    #                         cls.line_dict.pop(line_id)
-    #
-    #                     if exception.__class__.__name__ == 'RuntimeError':
-    #                         methods.debug_log(f"LineManage", f"m-170: {cls.get_line_state()}")
-    #                     else:
-    #                         methods.debug_log('LineManage', f"m-172: exception | {exception}")
-    #                         methods.debug_log('LineManage', f"m-172: traceback | {methods.trace_log()}")
-    #
-    #         except Exception as exception:
-    #
-    #             methods.debug_log('LineManage', f"m-179: exception | {exception}")
-    #             methods.debug_log('LineManage', f"m-179: traceback | {methods.trace_log()}")
-    #             methods.debug_log('LineManage', f"m-179: wait 1 minutes try again!")
-    #             await asyncio.sleep(60)
-
-    # @classmethod
-    # def get_line_total(cls):
-    #     count = 0
-    #     for k, v in cls.line_dict.items():
-    #         count += 1
-    #     return count
-
-    # @classmethod
-    # def check_line_is_live(cls, line_id):
-    #     d1 = {
-    #         0: 'CONNECTING',
-    #         1: 'CONNECTED',
-    #         2: 'DISCONNECTED',
-    #     }
-    #     line = cls.line_dict.get(line_id)
-    #     if line and d1.get(line.client_state.value) != 'DISCONNECTED':
-    #         return True
-    #     else:
-    #         return False
-
-    # @classmethod
-    # def get_line_state(cls):
-    #     d1 = {
-    #         0: 'CONNECTING',
-    #         1: 'CONNECTED',
-    #         2: 'DISCONNECTED',
-    #     }
-    #     d2 = dict()  # {<line_id>: <state>}
-    #     for line_id, line in cls.line_dict.items():
-    #         state = d1.get(line.client_state.value)
-    #         _id = line_id[-6:]
-    #         d2[_id] = state
-    #     return d2
-
-    # @staticmethod
-    # def image_to_b64(image):
-    #     frame = numpy_method.to_array(image)  # list to numpy array
-    #     _, image = cv2.imencode('.jpg', frame)
-    #     base64_data = base64.b64encode(image)
-    #     s = base64_data.decode()
-    #     return f'data:image/jpeg;base64,{s}'
-
-    @classmethod
-    def create_tcp_server(cls, host='0.0.0.0', port=20916):
-        cls.tcp_server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-        cls.tcp_server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-        cls.tcp_server.bind((host, port))
-        cls.tcp_server.listen(10)  # 设置可处理的未处理连接请求的最大数量
-        methods.debug_log('Connection.260', f"Server listening on {host}:{port}")
-
-    @classmethod
-    def start_listener(cls):
-
-        cls.create_tcp_server()
-        head_sequence = '<hh'  # 字节序规则
-        head_size = struct.calcsize(head_sequence)
-
-        while True:
-
-            try:
-                # --- 等待连接 ---
-                client, ipv4 = cls.tcp_server.accept()
-                # cls.clients[ipv4] = client, 时间戳, 客户端类型
-                methods.debug_log('Connection.260', f"Connected by {ipv4}")
-
-                # --- 解析数据头
-                head_bytestream = client.recv(head_size)
-                if not head_bytestream:
-                    continue
-                command_id, body_length = struct.unpack(head_sequence, head_bytestream)
-                methods.debug_log('Connection.284', f"Received values: {command_id, body_length}")
-
-                # --- debug ---
-                # command_id, body_length = struct.unpack('<hh', head_bytestream)
-                # methods.debug_log('Connection.1', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('<HH', head_bytestream)
-                # methods.debug_log('Connection.2', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('>hh', head_bytestream)
-                # methods.debug_log('Connection.5', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('>HH', head_bytestream)
-                # methods.debug_log('Connection.6', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('@hh', head_bytestream)
-                # methods.debug_log('Connection.9', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('@HH', head_bytestream)
-                # methods.debug_log('Connection.10', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('=hh', head_bytestream)
-                # methods.debug_log('Connection.13', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('=HH', head_bytestream)
-                # methods.debug_log('Connection.14', f"Received values: {command_id, body_length}")
-
-                # command_id, body_length = struct.unpack('<ii', head_bytestream)
-                # methods.debug_log('Connection.3', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('<II', head_bytestream)
-                # methods.debug_log('Connection.4', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('>ii', head_bytestream)
-                # methods.debug_log('Connection.7', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('>II', head_bytestream)
-                # methods.debug_log('Connection.8', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('@ii', head_bytestream)
-                # methods.debug_log('Connection.11', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('@II', head_bytestream)
-                # methods.debug_log('Connection.12', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('=ii', head_bytestream)
-                # methods.debug_log('Connection.15', f"Received values: {command_id, body_length}")
-                # command_id, body_length = struct.unpack('=II', head_bytestream)
-                # methods.debug_log('Connection.16', f"Received values: {command_id, body_length}")
-
-                # --- 解析数据体
-                if command_id == protobuf.CS_KeepAlive:
-                    continue
-                elif command_id == protobuf.CS_Sign:
-                    # --- 接收请求数据
-                    body_bytestream = client.recv(body_length)
-                    object = protobuf.CSSign()
-                    object.ParseFromString(body_bytestream)
-                    print(f"Received Response: account={object.account}, password={object.password}")
-
-                    # --- 发送返回数据
-                    object = protobuf.SCSign()
-                    object.ret = True
-                    object.uid = 112233
-                    object.cid = 223344
-                    object.name = 'aabbcc'
-                    command_id = protobuf.SC_Sign
-                    body_length = object.ByteSize()
-                    head_bytestream = struct.pack(head_sequence, command_id, body_length)
-                    body_bytestream = object.SerializeToString()
-                    send_bytestream = head_bytestream + body_bytestream
-                    client.sendall(send_bytestream)
-                    print(f"Sent data: {send_bytestream}")
-
-                    # --- test ---
-                    # for _ in range(10):
-                    #     for i in range(3)[::-1]:
-                    #         methods.debug_log('SRIConnection.58', f"sleep {i}s! | [{ipv4}]")
-                    #         time.sleep(1)
-                    #     methods.debug_log('SRIConnection.58', f"send re_send_data | [{ipv4}]")
-                    #     client.sendall(send_bytestream)
-
-
-            except Exception as exception:
-
-                methods.debug_log('Connection.287', f"#exception: {exception}")
-                methods.debug_log('Connection.287', f"#traceback: {methods.trace_log()}")
-
-            finally:
-                client.close()
-
-    @classmethod
-    def run(cls, background_is=True):
-        thread_list = [
-            threading.Thread(target=cls.start_listener),  # 人脸检测 deepstream facenet
-        ]
-        for thread in thread_list:
-            thread.setDaemon(True)
-            thread.start()
-        if background_is:
-            return
-        for thread in thread_list:
-            thread.join()
-
-
-if __name__ == '__main__':
-    print(protobuf.CS_Offer)
-
-    Connection.run(background_is=False)

+ 0 - 282
sri-server-bg03/lib/Connection_b1.py

@@ -1,282 +0,0 @@
-# from hub import methods, Global
-
-import struct
-import asyncio
-import time
-# from concurrent.futures import ThreadPoolExecutor
-
-import sys
-import importlib
-
-# --- for linux
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03')
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/3rdparty')
-
-protobuf = importlib.import_module(f"xprotobuf.protocol_pb2")
-methods = importlib.import_module(f"xlib")
-
-
-class SRIConnection(asyncio.Protocol):
-    """"""
-
-    # head_sequence = '<hh'  # 字节序规则
-    # all_connection_dict = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
-    # executor = ThreadPoolExecutor()
-    clients = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
-
-    def connection_made(self, client):
-        self.client = client
-        self.peername = client.get_extra_info('peername')
-        print(f"Connection from {self.peername}")
-
-        # --- 自定义参数
-        self.head_sequence = '<hh'  # 字节序规则
-        self.head_size = struct.calcsize(self.head_sequence)
-        self.connection_id = f"{self.peername[0].replace('.', '')}{self.peername[1]}"  # 12700130000
-
-        # --- fill ---
-        self.clients[self.connection_id] = client, methods.now_ts(), 'type=vehicle'
-
-    def data_received(self, data):
-        asyncio.create_task(self.handle_data(data))
-
-    async def handle_data(self, data):
-
-        loop = asyncio.get_running_loop()
-        # 全局的 ThreadPoolExecutor,由 asyncio 库自动创建和管理。它的线程池大小默认是机器的CPU核心数乘以5
-        await loop.run_in_executor(None, self.process_data, data)
-        # 自定义的 ThreadPoolExecutor
-        # await loop.run_in_executor(SRIConnection.executor, self.process_data, data)
-
-        # result = await asyncio.get_running_loop().run_in_executor(None, self.process_data, data)
-        # if result:
-        #     self.client.write(result)
-
-    def process_data(self, data):
-
-        head_data = data[:self.head_size]
-        body_data = data[self.head_size:]
-
-        command_id, body_length = struct.unpack(self.head_sequence, head_data)
-        methods.debug_log('SRIConnection.37', f"Received values: {command_id}, {body_length}")
-
-        if command_id == protobuf.CS_KeepAlive:  # 2008
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: None")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: None")
-
-        elif command_id == protobuf.CS_Sign:  # 2000
-
-            # --- 接收请求数据
-            object = protobuf.CSSign()
-            object.ParseFromString(body_data)
-            methods.debug_log(f"{self.connection_id} | SRIConnection.100",
-                              f"Received Response: account={object.account}, password={object.password}")
-
-            # --- 发送返回数据
-            object = protobuf.SCSign()
-            object.ret = True
-            object.uid = 112233
-            object.cid = 223344
-            object.name = 'aabbcc'
-            re_command_id = protobuf.SC_Sign  # 4000
-            re_body_length = object.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = object.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-            # --- test ---
-            # for _ in range(10):
-            #     for i in range(3)[::-1]:
-            #         methods.debug_log(f"{self.connection_id} | SRIConnection.92", f"sleep {i}s!")
-            #         time.sleep(1)
-            #     methods.debug_log(f"{self.connection_id} | SRIConnection.94", f"send re_send_data")
-            #     self.client.write(re_send_data)
-
-        elif command_id == protobuf.CS_Add:  # 2009
-
-            # --- 接收请求数据 2009
-            """
-            CSAdd: 消息体
-            CSAdd.serial: string
-            CSAdd.type: int32 EgoType::Car | EgoType::None EgoType::User EgoType::Car
-            CSAdd.name: string
-            """
-            object0 = protobuf.CSAdd()
-            object0.ParseFromString(body_data)
-            methods.debug_log(f"{self.connection_id} | SRIConnection.105", f"#serial: {object0.serial}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.105", f"#name: {object0.name}")
-
-            # --- 发送返回数据 4016 todo 向所有 EgoType::User 也就是舱端发送消息
-            """
-            Robot: 消息体
-            Robot.rid: int32
-            Robot.name: string
-            Robot.type: int32
-            Robot.state: RobotState Offline Online Busy
-            """
-            o1 = protobuf.Robot()
-            o1.rid = 112233
-            o1.name = "aabbcc"
-            o1.type = 123
-            o1.state = protobuf.Robot.Online
-            """
-            SCAddRobot: 消息体
-            SCAddRobot.robot: Robot
-            """
-            o2 = protobuf.SCAddRobot()
-            o2.robot.CopyFrom(o1)
-            re_command_id = protobuf.SC_NotifyAdd  # 4016
-            re_body_length = o2.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o2.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-            # --- 发送返回数据 4007 todo 向请求来的车端,返回设置是否成功的消息
-            o1 = protobuf.SCAdd()
-            o1.ret = True
-            o1.uid = 112233
-            o1.name = 'aabbcc'
-            re_command_id = protobuf.SC_Add  # 4007
-            re_body_length = o1.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o1.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-        elif command_id == protobuf.CS_Offer:  # 2004
-
-            # --- 接收请求数据
-            object = protobuf.Offer()
-            object.ParseFromString(body_data)
-            print(f"Received Response: peer={object.peer}")
-
-            # --- 发送返回数据
-            o1 = protobuf.Offer()
-            o1.index = object.index
-            o1.peer = object.peer
-            o1.type = object.type
-            o1.sdp = object.sdp
-            re_command_id = protobuf.SC_NotifyOffer  # 4012
-            re_body_length = o1.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o1.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-        elif command_id == protobuf.CS_Answer:  # 2005
-
-            # --- 接收请求数据
-            object = protobuf.Answer()
-            object.ParseFromString(body_data)
-            print(f"Received Response: peer={object.peer}")
-
-            # --- 发送返回数据
-            o1 = protobuf.Offer()
-            o1.index = object.index
-            o1.peer = object.peer
-            o1.type = object.type
-            o1.sdp = object.sdp
-            re_command_id = protobuf.SC_NotifyAnswer  # 4011
-            re_body_length = o1.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o1.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-        elif command_id == protobuf.CS_Candidate:  # 2006
-
-            # --- 接收请求数据
-            object = protobuf.Candidate()
-            object.ParseFromString(body_data)
-            print(f"Received Response: peer={object.peer}")
-
-            # --- 发送返回数据
-            o1 = protobuf.Offer()
-            o1.index = object.index
-            o1.peer = object.peer
-            o1.type = object.type
-            o1.candidate = object.candidate
-            o1.sdpMLineIndex = object.sdpMLineIndex
-            o1.sdpMid = object.sdpMid
-            o1.egotype = object.egotype
-
-            re_command_id = protobuf.SC_NotifyCandidate  # 4013
-            re_body_length = o1.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o1.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-        elif command_id == protobuf.CS_Req:  # 2001  todo 实现收到qt端2001消息,向车端发送4009消息
-
-            # --- 接收请求数据
-            """
-            CSReq: 消息体
-            CSReq.peer: int32(uid,用户标识)
-            CSReq.index: int32(相机位置,RenderPosition)
-            CSReq.egotype: int32(终端类型,舱端/车端)
-            """
-            o1 = protobuf.CSReq()
-            o1.ParseFromString(body_data)
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"#peer: {o1.peer}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"#index: {o1.index}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"#egotype: {o1.egotype}")
-
-            # --- 发送返回数据
-            """
-            CSReq: 消息体
-            CSReq.peer: int32(uid,用户标识)
-            CSReq.index: int32(相机位置,RenderPosition)
-            CSReq.egotype: int32(终端类型,舱端/车端)
-            """
-            o2 = protobuf.CSReq()
-            o2.peer = o1.peer
-            o2.index = o1.index
-            o2.type = o1.egotype
-            re_command_id = protobuf.SC_NotifyReq  # 4009
-            re_body_length = o2.ByteSize()
-            re_head_data = struct.pack(self.head_sequence, re_command_id, re_body_length)
-            re_body_data = o2.SerializeToString()
-            re_send_data = re_head_data + re_body_data
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: {re_command_id}")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: {re_send_data}")
-            self.client.write(re_send_data)
-
-    def connection_lost(self, exc):
-        print(f"SRIConnection closed by {self.peername}")
-
-    # def connection_lost(self, exc):
-    #     print(f"Connection closed by {self.connection_id}")
-    #     if self.connection_id in SRIConnection.clients:
-    #         del SRIConnection.clients[self.connection_id]
-
-    @classmethod
-    async def run(cls):
-        loop = asyncio.get_running_loop()
-        server = await loop.create_server(
-            lambda: SRIConnection(),
-            '0.0.0.0', 20917
-        )
-        async with server:
-            print(f"Server listening on 0.0.0.0:20917")
-            methods.debug_log(f"SRIConnection.221", f"Server listening on 0.0.0.0:20917")
-            await server.serve_forever()
-
-
-if __name__ == '__main__':
-    asyncio.run(SRIConnection.run())
-    # asyncio.run(main())

+ 0 - 131
sri-server-bg03/lib/Connection_c1.py

@@ -1,131 +0,0 @@
-"""
-todo
-    1、实现 self.clients 循环检查逻辑
-"""
-# from hub import methods, Global
-
-import struct
-import asyncio
-import time
-# from concurrent.futures import ThreadPoolExecutor
-
-import sys
-import importlib
-
-# --- for linux
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/sri-server-bg03')
-sys.path.append('/home/server/repositories/repositories/sri-project.demo-py/3rdparty')
-
-protobuf = importlib.import_module(f"xprotobuf.protocol_pb2")
-methods = importlib.import_module(f"xlib")
-
-
-class SRIConnection(asyncio.Protocol):
-    """"""
-
-    head_sequence = '<hh'  # 字节序规则
-    # all_connection_dict = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
-    # executor = ThreadPoolExecutor()
-    clients = {}  # {<ipv4>: (socket, update_at, type)} | {<连接id>: (socket对象, 最后一次请求时间, 客户端类型)}
-
-    def connection_made(self, client):
-        self.client = client
-        self.peername = client.get_extra_info('peername')
-        print(f"Connection from {self.peername}")
-
-        # --- 自定义参数
-        self.head_sequence = '<hh'  # 字节序规则
-        self.head_size = struct.calcsize(self.head_sequence)
-        self.connection_id = f"{self.peername[0].replace('.', '')}{self.peername[1]}"  # 12700130000
-
-        # --- fill ---
-        self.clients[self.connection_id] = client, methods.now_ts(), 'type=vehicle'
-
-    def data_received(self, data):
-        asyncio.create_task(self.handle_data(data))
-
-    async def handle_data(self, data):
-        loop = asyncio.get_running_loop()
-        await loop.run_in_executor(None, self.process_data, data)
-
-    def process_data(self, data):
-        head_data = data[:self.head_size]
-        body_data = data[self.head_size:]
-
-        command_id, body_length = struct.unpack(self.head_sequence, head_data)
-        methods.debug_log('SRIConnection.37', f"Received values: {command_id}, {body_length}")
-
-        if command_id == protobuf.CS_KeepAlive:  # 2008
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_command_id: None")
-            methods.debug_log(f"{self.connection_id} | SRIConnection.113", f"re_send_data: None")
-
-    def connection_lost(self, exc):
-        print(f"Connection closed by {self.client_info}")
-        if self.client_info in CustomProtocol.clients:
-            del CustomProtocol.clients[self.client_info]
-        self.on_disconnect()
-
-    # def connection_lost(self, exc):
-    #     print(f"Connection closed by {self.connection_id}")
-    #     if self.connection_id in SRIConnection.clients:
-    #         del SRIConnection.clients[self.connection_id]
-
-    @classmethod
-    async def check_clients(cls):
-        count = 0
-        while True:
-            count += 1
-            print(f"#count: {count}", flush=True)
-            # for connection_id, (client, update_at, client_type) in cls.clients.items():
-            for connection_id in list(cls.clients.keys()):
-                client, update_at, client_type = cls.clients.get(connection_id)
-                print(f"#connection_id: {connection_id}, #update_at: {update_at}, #client_type: {client_type}",
-                      flush=True)
-
-                # 创建并发送消息
-                object = protobuf.SCAdd()
-                object.ret = True
-                object.uid = 112233
-                object.name = 'periodic_message'
-                re_command_id = protobuf.SC_Add  # 4007
-                re_body_length = object.ByteSize()
-                re_head_data = struct.pack(cls.head_sequence, re_command_id, re_body_length)
-                re_body_data = object.SerializeToString()
-                re_send_data = re_head_data + re_body_data
-                methods.debug_log(f"{connection_id} | SRIConnection.periodic", f"re_command_id: {re_command_id}")
-                methods.debug_log(f"{connection_id} | SRIConnection.periodic", f"re_send_data: {re_send_data}")
-                client.write(re_send_data)
-
-            await asyncio.sleep(3)  # 发送消息的间隔时间
-
-    # @classmethod
-    # async def check_clients(cls):
-    #     while True:
-    #         print("Checking client connections:", flush=True)
-    #         for client_info in list(cls.clients.keys()):
-    #             methods.debug_log(f"SRIConnection.221", f"Client {client_info} is connected")
-    #             print(f"Client {client_info} is connected", flush=True)
-    #         await asyncio.sleep(3)
-
-    @classmethod
-    async def run(cls):
-        loop = asyncio.get_running_loop()
-        server = await loop.create_server(
-            lambda: SRIConnection(),
-            '0.0.0.0', 20917
-        )
-
-        # asyncio.create_task(SRIConnection.check_clients())
-        # await loop.create_task(SRIConnection.check_clients())
-
-        async with server:
-            print("Server listening on 0.0.0.0:20917", flush=True)
-            methods.debug_log(f"SRIConnection.221", f"Server listening on 0.0.0.0:20917")
-            await loop.create_task(SRIConnection.check_clients())
-            await server.serve_forever()
-            # await send_task  # 确保任务在 server 关闭后也继续执行
-
-
-if __name__ == '__main__':
-    asyncio.run(SRIConnection.run())
-    # asyncio.run(main())

+ 0 - 21
sri-server-bg03/main.py

@@ -1,21 +0,0 @@
-# from app import generate_app
-# app = generate_app()
-
-def main():
-    # 监听mqtt消息服务
-    from lib.MessageListener import MessageListener
-    MessageListener.run_background(background_is=False)
-
-    # 给websocket发数据的
-    # from factories.line_manage import LineManage
-    # LineManage.run_background()
-
-    # websocket服务 与 api服务
-    # app.run(address='0.0.0.0', port=5042, debug=True)
-
-
-
-
-
-if __name__ == '__main__':
-    main()

+ 0 - 5
sri-server-bg03/run.sh

@@ -1,5 +0,0 @@
-#!/bin/bash
-
-echo "执行:启动" \
-&& python3 lib/Connection_b1.py
-

+ 0 - 12
sri-server-bg03/xprotobuf/README-usage.md

@@ -1,12 +0,0 @@
-## NOTE
-
-#### ubuntu下安装python的protobuf
-
-```
-apt update
-apt install protobuf-compiler -y
-protoc --version
-protoc --python_out=. protocol.proto
-
-apt install python3-protobuf
-```

+ 0 - 151
sri-server-bg03/xprotobuf/SRI202407-服务器端通讯测试文档(共6个).txt

@@ -1,151 +0,0 @@
-
-
-# --- test 2008 存活请求 ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-无
-# --- 返回 ---
-无
-
-
-# --- test 2000 舱端登录认证 ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-消息头:CS_Sign 2000
-消息体:
-message CSSign
-{
-    string account=1;
-    string password=2;
-};
-# --- 返回 ---
-消息头:SC_Sign 4000
-消息体:
-message SCSign
-{
-    bool  ret=1;
-    int32 uid=2;
-    int32 cid=3;
-    string name=4;
-};
-
-
-# --- test 2009 车端上线 ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-消息头:CS_Add 2009
-消息体:
-message CSAdd
-{
-    string serial=1;
-    int32  type=2;
-    string name=3;
-};
-# --- 返回1 ---
-消息头:SC_NotifyAdd 4016
-消息体:
-message Robot
-{
-    enum RobotState
-    {
-        Offline=0;
-        Online=1;
-        Busy=2;
-    };
-    int32 rid=1;
-    string name=2;
-    int32  type=3;
-    RobotState state=4;
-};
-message SCAddRobot
-{
-   Robot robot=1;
-};
-# --- 返回2 ---
-消息头:SC_Add 4007
-消息体:
-message SCAdd
-{
-    bool  ret=1;
-    int32 uid=2;
-    int32 cid=3;
-    string name=4;
-};
-
-
-# --- test 2004 offer ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-消息头:CS_Offer 2004
-消息体:
-message Offer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-# --- 返回 ---
-消息头:SC_NotifyOffer 4012
-消息体:
-message Offer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-
-
-# --- test 2005 answer ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-消息头:CS_Answer 2005
-消息体:
-message Answer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-# --- 返回 ---
-消息头:SC_NotifyAnswer 4011
-消息体:
-message Answer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-
-
-# --- test 2006 candidate ---
-服务器地址/端口:58.34.94.178/20917
-# --- 请求 ---
-消息头:CS_Candidate 2006
-消息体:
-message Candidate
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string candidate=4;
-    int32 sdpMLineIndex =5;
-    string sdpMid =6;
-    int32 egotype=7;
-};
-# --- 返回 ---
-消息头:SC_NotifyCandidate 4013
-消息体:
-message Candidate
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string candidate=4;
-    int32 sdpMLineIndex =5;
-    string sdpMid =6;
-    int32 egotype=7;
-};

+ 0 - 421
sri-server-bg03/xprotobuf/protocol.proto

@@ -1,421 +0,0 @@
-syntax="proto3";
-package RemoNet;
-enum CSMessage
-{
-  CS_NONE=0;
-  CS_Sign=2000;
-  CS_Req=2001;
-  CS_Rep=2002;
-  CS_CancelReq=2003;
-  CS_Offer=2004;
-  CS_Answer=2005;
-  CS_Candidate=2006;
-  CS_Leave=2007;
-  CS_KeepAlive=2008;
-  CS_Add=2009;
-  CS_Robot=2010;
-  CS_CloseVideo=2011;
-  CS_State=2014;
-};
-enum SCMessage
-{
-  SC_NONE=0;
-  SC_Sign=4000;
-  SC_Req=4001;
-
-  SC_Rep=4002;
-  SC_Cancel=4003;
-  SC_Offer=4004;
-  SC_Answer=4005;
-  SC_Candidate=4006;
-  SC_Add=4007;
-  SC_Robot=4008; 
-  SC_NotifyReq=4009;
-  SC_NotifyRep=4010;
-  SC_NotifyAnswer=4011;
-  SC_NotifyOffer=4012;
-  SC_NotifyCandidate=4013;
-  SC_NotifyLeave=4014;
-  SC_NotifyCancel=4015;
-  SC_NotifyAdd=4016;
-  SC_NotifyDel=4017;
-  SC_NotifyCloseVideo=4018;
-  SC_KickOff=4019;
-  SC_State=4022;
-  
-};
-enum CCMessage
-{
-   CC_None=0;
-   CC_Text=8000;
-   CC_CAN=8001;
-   CC_IMU=8002;
-   CC_ASKDATACHANNEL=8003;
-   CC_Manipulation=8004;
-   CC_Radar=8005;
-   CC_Switch=8006;
-   CC_Ping=8007;
-   CC_SensorStop=8008;
-   CC_StopACK=8009;
-   CC_LIDARDATA=8010;
-   CC_CANMSG=8011;
-   CC_STATE=8012;
-   CC_RobotAnalog=8017;
-   CC_BootReq=8013;
-   CC_StartupReq=8014;
-   CC_BootRep=8015;
-   CC_StartupRep=8016;
- //  CC_FrontLight=8017;
- //  CC_Wiper=8018;
- //  CC_BackLight=8019;
-};
-enum VideoDesc
-{
-	OK=0;
-	Busy=1;
-	Reject=2;
-	NoFound=3;
-	IsVideoing=4;
-
-};
-message CSAdd
-{
-    string serial=1;
-    int32  type=2;
-    string name=3;
-};
-message SCAdd
-{
-    bool  ret=1;
-    int32 uid=2;
-    int32 cid=3;
-    string name=4;
-};
-message SCKickOff
-{
-};
-message Robot
-{
-    enum RobotState
-    {
-        Offline=0;
-        Online=1;
-        Busy=2;
-    };
-    int32 rid=1;
-    string name=2;
-    int32  type=3;
-    RobotState state=4;
-};
-message CSRobot
-{
-};
-message SCRobot
-{
- repeated Robot robot=1;
-};
-
-message CSSign
-{
-    string account=1;
-    string password=2;
-};
-message SCSign
-{
-    bool  ret=1;
-    int32 uid=2;
-    int32 cid=3;
-    string name=4;
-};
- 
-
-message CSReq
-{
-   int32 peer=1;
-   int32 index=2;
-   int32 egotype=3;
-};
-message SCReq
-{
-    VideoDesc desc=1;
-    int32 peer=2;
-    int32 egotype=3;
-   
-};
-message CSRep
-{
- 
-   VideoDesc desc=1;
-   int32 peer=2;
-   int32 index=3;
-    int32 egotype=4;
-};
-message SCRep
-{
-  
-   VideoDesc desc=1;
-     int32 index=2;
-	 int32 egotype=3;
-   int32 peer=4;
-   
-};
-
-message Offer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-
-message Answer
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string sdp=4;
-};
-
-message Candidate
-{
-    int32 index=1;
-    int32 peer=2;
-    string type=3;
-    string candidate=4;
-    int32 sdpMLineIndex =5;
-    string sdpMid =6;
-    int32 egotype=7;
-};
-message Leave
-{
-   int32 peer=1;
-   int32 egotype=2;
-};
- message Close
-{
-int32 peer=1;
-int32 egotype=2;
-int32 index=3;
-};
- 
-message TestTextReq
-{
-  string text=1;
-};
-message CanMessage
-{
-   
-   int32 head=1;
-   int32 canid=2;
-   bytes data=3;
-};
-message CCCanMesage
-{
-   bool islidar=1;
-   repeated CanMessage message=2;
-};
-message Wiper
-{
-  bool ret=1;
-};
-message FrontLight
-{
-  bool ret=1;
-};
-message BackLight
-{
-  bool ret=1;
-};
-message CCAskDataChannel
-{
-};
-message IMuMessage
-{
-
-   float rx=1; 
-   float ry=2;
-  // float rz=3;
-};
-message CCPing
-{
-  int64 tick=1;
-};
-message CCRadarMessage
-{
-   int32 radar0=1;
-   int32 radar1=2;
-   int32 radar2=3;
-   int32 radar3=4;
-   int32 radar4=5;
-   int32 radar5=6;
-   int32 radar6=7;
-   int32 radar7=8;
-};
-enum Gears
-{
-   Null=0; //todo 关键字占用,None改为Null
-   N=1;
-   D=2;
-   R=3;
-};
-//挂挡
-enum Gears_D
-{
-   None_d=0;
-   D_1=1;
-   D_2=2;
-   D_3=3;
-   D_4=4;
-};
-//左右转向灯
-enum DirectionLight
-{
-  RightLight=0;
-  LeftLight=1;
-  OffLight=2;
-};
-message CCRobotAnalog
-{
-  int32  steer=1;
-  int32  arm=2;  //举升臂
-  int32  bucket=3; //翻斗
-  int32  throttle=4; //油门
-  int32  brake=5;  //刹车
- // bool   bootstrap=6; //钥匙一档上电
- // bool   startup=7;   //钥匙二档启动
-  bool   emergency=8; //急停
-  bool   resume=9;// 急停反转
-  Gears  gears=10;
-  bool   frontlight=11;
-  bool   backlight=12;
-  bool   wipe=13;
-  DirectionLight directionlight=14;//左右转向灯
-  bool   buzzer=15;//车鸣笛
-  Gears_D gears_d=16;//挂挡
-};
-message CCBootStrapReq
-{
-
-}
-message CCBooStrapRep
-{
-    bool ret=1;
-}
-message CCStartupReq
-{
-    
-}
-message CCStartupRep
-{
-   bool ret=1;
-}
-message CCSwitch
-{
-   bool front=1;
-};
-//todo 不支持optional
-//message LidarPoint
-//{
-// optional double timestamp = 1;
-// optional uint32 seq = 2;
-// optional string frame_id = 3;
-// optional uint32 height=4;
-// optional uint32 width=5;
-// optional bool is_dense=6;
-// optional bool is_left=7;
-// repeated float data = 8;
-//};
-message SensorStop
-{
-};
-message StopAck
-{
-};
-message CCManipulation
-{
-  bytes sensor=1;
-  bytes  car=2;
-};
-message SCAddRobot
-{
-   Robot robot=1;
-};
-message SCDelRobot
-{
-   int32 peer=1;
-   int32 egotype=2;
-};
-
-message State
-{
-   
-   /*
-   int32 work_pressure=1;//工作系统压力
-   int32 brake_pressure=2; //制动系统压力
-   int32 gearbox_oil_temp=3;//变速箱油温
-   int32 gearbox_oil_pressure=4; //变速箱油压
-   int32 engine_rpm=5;//发动机转速
-   int32 speed=6;
-   int32 engine_pressure=8;
-   int32 cold_water=9;
-   int32 steer_angle=10;
-   int32 left_lock=11;
-   int32 right_lock=12;
-   */
-   ///////////////////////////////////////////////////////状态参数
-   int32 engine_speed = 1;//发动机转速
-   int32 travel_speed = 2;//行驶速度
-   int32 fuel_level = 3;//燃油油位
-   int32 engine_temperature = 4;//发动机水温
-   int32 hydraulic_oil_temperature = 5;//液压油油温
-   int32 main_pump_1_pressure = 6;//主泵1压力
-   int32 main_pump_2_pressure = 7;//主泵2压力
-   int32 hand_gear = 8;//水箱水位
-   int32 actual_gear = 9;//发动机机油压力
-   float gripper_height = 10;//抓具高度
-   float amplitude = 11;//幅度
-   int32 boom_angle = 12;//动臂角度
-   int32 stick_angle = 13;//斗杆角度
-   ///////////////////////////////////////////////////////报警信息
-   int32 idle_protection = 14;//怠速保护
-   int32 front_toggle = 15;//前轮对中
-   int32 back_toggle = 16;//后轮对中
-   bytes error_Buff = 17;//报警信息
-   int32 interlock = 18;//启动联锁
-   int32 safety_switch = 19;//安全开关阀异常
-   int32 arm_lift_pilot = 20;//大臂提升先导比例阀异常
-   int32 arm_lowering_pilot = 21;//大臂下降先导比例阀异常
-   int32 lever_lifting_pilot = 22;//斗杆提升先导比例阀异常
-   int32 rod_lowering_pilot = 23;//斗杆下降先导比例阀异常
-   int32 left_rotary_pilot = 24;//左回转先导比例阀异常
-   int32 right_rotary_pilot = 25;//右回转先导比例阀异常
-   int32 grab_open_pilot = 26;//抓斗开启先导比例阀异常
-   int32 grab_close_pilot = 27;//抓斗闭合先导比例阀异常
-   int32 safety_valves = 28;//安全开关阀
-
-    //增加 0x384
-	int32 function_code =29 ;  //功能码
-	int32 main_add =30;        //主地址
-	int32 sub_add =31;         //次地址
-	int32 paramter=32 ;        //参数值
-
-   //增加0x28b  
-   int32 engine_spn =33;        //发动机实时故障SPN
-   int32 engine_fmi =34;       //发动机实时故障FMI
-   int32 engine_num =35;        //发动机故障次数
-
-   //增加0x28f
-   bytes all_Buff = 36;    //0x28f 信息  
-};
-
-message can_net_frame
-{
-   sint32 dlc =1;
-   int32 canid =2;
-   bytes data=3;
-};
-
-message CCCanMsg
-{
-    repeated can_net_frame frams=1;
-};

Файловите разлики са ограничени, защото са твърде много
+ 0 - 22
sri-server-bg03/xprotobuf/protocol_pb2.py


Някои файлове не бяха показани, защото твърде много файлове са промени