From c099e6662b8a6e320ac314d31eda9b40455e5aa7 Mon Sep 17 00:00:00 2001 From: lyg <1543117173@qq.com> Date: 星期四, 22 五月 2025 09:27:37 +0800 Subject: [PATCH] 修改指令json生成相关提示词和代码逻辑 --- knowledgebase/db/db_helper.py | 75 +++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 1 deletions(-) diff --git a/knowledgebase/db/db_helper.py b/knowledgebase/db/db_helper.py index c394644..4f193d1 100644 --- a/knowledgebase/db/db_helper.py +++ b/knowledgebase/db/db_helper.py @@ -1,4 +1,5 @@ import uuid +from enum import Enum from sqlalchemy.orm import sessionmaker, scoped_session @@ -384,10 +385,82 @@ "checkSum": 20, "insUnit": 4, "insUnitList": 11, - "input": 19 + "input": 19, + "pktSeqCnt": 25, + "variableLength": 14 } +class BinaryType(Enum): + Integer = 0 # 鏁村瀷 + Float = 1 # 娴偣鍨� + Ascii = 2 # ASCII + + +class NumberDataType(Enum): + Unsigned = 0 # 鏃犵鍙锋暣鍨� + SignInteger = 1 # 鏈夌鍙锋暣鍨� + Phy = 2 # 鐗╃悊閲� + Bytes = 3 # 澶氬瓧鑺傜爜 + + +class InputFormat(Enum): + Binary = 0 # 浜岃繘鍒� + Decimal = 1 # 鍗佽繘鍒� + Hex = 2 # 鍗佸叚杩涘埗 + + +class ProcessMethod(Enum): + Dirct = 0 # 鐩磋 + Equivalent = 1 # 褰撻噺 + Formula = 2 # 鍏紡 + Script = 3 # 鑴氭湰 + + +class ExpressionType(Enum): + Count = 0 # 涓暟璁$畻 + Formula = 1 # 鏁板�艰绠� + + +class EnumType(Enum): + NameValue = 0 # 鍚嶅�煎鏋氫妇 + Range = 1 # 鑼冨洿鏋氫妇 + Classify = 2 # 澶氱骇鍒嗙被 + InsCategory = 3 # 鎸囦护绫诲埆鏋氫妇 + InsUnit = 4 # 鎸囦护鍗曞厓鏋氫妇 + InsFormat = 5 # 鎸囦护鏍煎紡鏋氫妇 + + +def make_attr(field: dict): + """ + 鑾峰彇瀛楁瀹氫箟鐨凙TTR銆� + + 浣嶆帺鐮侊紝鐢ㄤ簬鏍囪瘑鑺傜偣绫诲瀷銆� + 绫诲瀷锛�0~2 BinaryType; + 3~5 DataType; + 6~8: InputFormat; + 9 : IsSubPackage; + 10: IsSendFlag锛� + 11~13: ProcessMethod锛� + 14~16: ExpressionType锛� + 17~19: EnumType + + :param field: 瀛楁淇℃伅 + :return: + """ + attr = 0 + # 鍗虫椂杈撳叆锛屾棤绗﹀彿鏁存暟锛屽崄杩涘埗锛岀洿璇� + if field['type'] == ins_ty['input']: + attr |= (NumberDataType.Unsigned.value << 3) | (InputFormat.Decimal.value << 6) | (ProcessMethod.Dirct.value << 11) + # 鏄惁鏄瓙鍖� + attr |= (1 << 9) if field['type']==ins_ty['subPkt'] else 0 + # 鏄惁鏄彂閫佹爣璁� + attr |= (1 << 10) if field['type']==ins_ty['sendFlag'] else 0 + # 璁$畻绫诲瀷 + # 鏋氫妇绫诲瀷 + + return attr + def create_ins_format(proj_pk: str, parent_pk: str, info: dict) -> TInsFormat: ins_format = TInsFormat( C_INS_FORMAT_PK=get_pk(), -- Gitblit v1.9.1