添加通用的异常判断算法
This commit is contained in:
@@ -141,30 +141,36 @@ def scheme_to_byte(j:json):
|
||||
# int转数组
|
||||
def arr_from_int(num:int):
|
||||
return bytearray([num&0xff,(num>>8)&0xff,(num>>16)&0xff,(num>>24)&0xff])
|
||||
# uchar转数组
|
||||
def arr_from_uchar(num:int):
|
||||
return bytearray([num&0xff])
|
||||
# u16转数组
|
||||
def arr_from_u16(num:int):
|
||||
return bytearray([num&0xff,(num>>8)&0xff])
|
||||
|
||||
|
||||
# 提取方案中的范围数据, 先max后min
|
||||
def scheme_get_task_range(j:json):
|
||||
t=bytearray()
|
||||
t+=arr_from_int(j["TaskID"])
|
||||
t+=arr_from_int(j["TaskIndex"])
|
||||
t+=arr_from_int(j["ReturnCount"])
|
||||
t+=arr_from_int(j["ExecuteErrCode"])
|
||||
t+=arr_from_uchar(j["TaskID"])
|
||||
t+=arr_from_uchar(j["TaskIndex"])
|
||||
t+=arr_from_uchar(j["ReturnCount"])
|
||||
t+=arr_from_uchar(j["ExecuteErrCode"])
|
||||
index=0
|
||||
for i in j["TestStandard"]:
|
||||
t+=arr_from_int(i["Max"])
|
||||
t+=arr_from_int(i["Min"])
|
||||
t+=arr_from_u16(i["Max"])
|
||||
t+=arr_from_u16(i["Min"])
|
||||
if (index<len(j["ResultErrCode"])):
|
||||
t+=arr_from_int(j["ResultErrCode"][index])
|
||||
t+=arr_from_uchar(j["ResultErrCode"][index])
|
||||
else:
|
||||
t+=arr_from_int(0)
|
||||
t+=arr_from_uchar(0)
|
||||
index+=1
|
||||
# 不足16的部分填充为16
|
||||
n=16-len(j["TestStandard"])
|
||||
for i in range(n):
|
||||
t+=arr_from_int(65535)
|
||||
t+=arr_from_int(0)
|
||||
t+=arr_from_int(0)
|
||||
t+=arr_from_u16(65535)
|
||||
t+=arr_from_u16(0)
|
||||
t+=arr_from_uchar(0)
|
||||
return t
|
||||
|
||||
# 根据方案生成主板用的字节数据
|
||||
|
Reference in New Issue
Block a user