添加错误代码

This commit is contained in:
ranchuan
2023-06-28 18:08:38 +08:00
parent c2b79fe523
commit 28889fa479
21 changed files with 2299 additions and 99 deletions

1869
python/file/json.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -23,8 +23,13 @@ PLAN_ID=15
-- "方案ID不符",211
-- "检测项目不足,无法判定",212
-- "数据不合规",213
-- 2023.5.11
-- 修改脚本适配 雷管厂电解电容来料检测
-- 2023.5.12
-- 大于启停的时间从检测器异常改为芯片异常
-- 2023.5.19
-- 扫描uid超出最大返回时间范围则显示芯片异常
-- 添加起爆充能失败的判断,此时返回芯片异常
@@ -262,7 +267,7 @@ function JQ_Test_PowerPrapare(task,err_code)
return nil
else
-- 上电正常,排除检测器异常
del(err_code,1)
-- del(err_code,1)
print("检测上电充能")
-- 下一步是上电充能
return find_index(task["TaskIndex"]+2,1)
@@ -300,8 +305,8 @@ function JQ_Test_PowerOn(task,err_code)
print("检测电流")
return find_index(task["TaskIndex"]+2,3)
end
---- 排除接触异常
--del(err_code,3)
---- 排除检测板异常
del(err_code,1)
print("检测芯片UID")
-- 下一步检测芯片
return find_index(task["TaskIndex"]+2,4)
@@ -319,6 +324,13 @@ function JQ_Test_ScanUID(task,err_code)
only(err_code,5)
return nil
else
ret_value=find_return(task["TaskIndex"]+1)
-- 最大反馈时间在范围之外,芯片异常
if(ret_value[2]<task["TestStandard"][2]["Min"]) or (ret_value[2]>task["TestStandard"][2]["Max"]) then
only(err_code,5)
return nil
end
print("检测电流")
return find_index(task["TaskIndex"]+2,3)
--print("读取芯片代码")
@@ -416,12 +428,36 @@ function JQ_Test_BaseCurHigh(task,err_code)
del(err_code,3)
print("检测桥丝和电容")
-- 下一步检测桥丝和电容
return find_index(task["TaskIndex"]+2,12)
return find_index(task["TaskIndex"]+2,11)
end
end
-- 检测充能,失败则电容异常
function JQ_Test_ChgEnergy(task,err_code)
if(find_ack(task["TaskIndex"]+1,mid(check_data,1,8))==false)then
only(err_code,2)
return nil
else
ret_value=find_return(task["TaskIndex"]+1)
if((ret_value[1]>task["TestStandard"][1]["Max"]) or (ret_value[1]<task["TestStandard"][1]["Min"])) then
only(err_code,2)
return nil
end
if((ret_value[2]>task["TestStandard"][2]["Max"]) or (ret_value[2]<task["TestStandard"][2]["Min"])) then
only(err_code,2)
return nil
end
-- 排除电容异常
del(err_code,2)
print("检测桥丝")
-- 下一步检测桥丝
return find_index(task["TaskIndex"]+2,12)
end
end
-- 检测电容电压,返回下一个检测任务,nil停止检测
function JQ_Test_CheckDAC(task,err_code)
@@ -442,24 +478,39 @@ function JQ_Test_CheckDAC(task,err_code)
only(err_code,4)
return nil
else
-- 排除桥丝异常
ret_value=find_return(task["TaskIndex"]+1)
if((ret_value[1]>task["TestStandard"][1]["Max"]) or (ret_value[1]<task["TestStandard"][1]["Min"])) then
only(err_code,4)
return nil
end
-- 排除电容异常
del(err_code,4)
print("检测电容")
return find_index(task["TaskIndex"]+2,12)
-- 下一步检测起爆
return find_index(task["TaskIndex"]+2,20)
end
end
-- 检测电容电压,返回下一个检测任务,nil停止检测
function JQ_Test_CheckDAC2(task,err_code)
-- 起爆充能
function JQ_Test_BoomEnergy(task,err_code)
if(find_ack(task["TaskIndex"]+1,mid(check_data,1,8))==false)then
-- 检测电压失败则主电容异常
-- 检测电压失败则桥丝或主电容异常
print("task failed.task_index=",task["TaskIndex"])
only(err_code,2)
-- 这里判断上电充能值,如果偏大则桥丝异常,偏小则电容异常
-- 充能流程正常,返回第一个值是电压,第二个值是充能时间
-- local task_p=find_index(1,1)
-- ret_value=find_return(task_p["TaskIndex"]+1)
-- if(ret_value[2]>39999) then
-- only(err_code,4)
-- return nil
-- else
-- only(err_code,2)
-- return nil
-- end
only(err_code,5)
return nil
else
-- 排除电容异常
del(err_code,2)
-- 排除芯片异常,密码错误会导致起爆失败
del(err_code,5)
print("检测完毕")
return nil
@@ -469,6 +520,8 @@ end
-- 定义占位函数,不应该调用
function JQ_Test_Empty(task,err_code)
print("err function call,task index=",task["TaskIndex"])
@@ -479,18 +532,29 @@ end
-- 这个数组根据方案检测顺序确定
tasks_judge_fun={
JQ_Test_PowerPrapare,
JQ_Test_PowerOn,
JQ_Test_ScanUID,
JQ_Test_BaseCurLow,
JQ_Test_ReadChipID,
JQ_Test_Empty,
JQ_Test_BaseCurHigh,
JQ_Test_Empty,
JQ_Test_CheckDAC,
JQ_Test_Empty,
JQ_Test_Empty,
JQ_Test_CheckDAC2
JQ_Test_PowerPrapare,--0
JQ_Test_PowerOn,--1
JQ_Test_ScanUID,--2
JQ_Test_BaseCurLow,--3
JQ_Test_ReadChipID,--4
JQ_Test_Empty,--5
JQ_Test_Empty,--6
JQ_Test_Empty,--7
JQ_Test_BaseCurHigh,--8
JQ_Test_Empty,--9
JQ_Test_Empty,--10
JQ_Test_Empty,--11
JQ_Test_Empty,--12
JQ_Test_Empty,--13
JQ_Test_Empty,--14
JQ_Test_Empty,--15
JQ_Test_Empty,--16
JQ_Test_ChgEnergy,--17 充能统计
JQ_Test_Empty,--18
JQ_Test_CheckDAC,--19
JQ_Test_Empty,--20
JQ_Test_Empty,--21
JQ_Test_BoomEnergy,--22
}

84
python/file/prints.lua Normal file
View File

@@ -0,0 +1,84 @@
module = {}
function module:print_t ( t )
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
print(indent.."["..pos..'] => "'..val..'"')
else
print(indent.."["..pos.."] => "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
end
if (type(t)=="table") then
print(tostring(t).." {")
sub_print_r(t," ")
print("}")
else
sub_print_r(t," ")
end
print()
end
function byte_to_hex(byte,size)
local str_table="0123456789ABCDEF"
local str_ret=""
if(size==2) then
str_ret=string.char(
string.byte( str_table,((byte>>12)&0xf)+1),
string.byte( str_table,((byte>>8)&0xf)+1),
string.byte( str_table,((byte>>4)&0xf)+1),
string.byte(str_table,(byte&0xf)+1))
else
str_ret=string.char(string.byte(str_table,(byte%256)//16+1),string.byte(str_table,(byte%256)%16+1))
end
return str_ret
end
-- function byte_to_num(byte)
-- local str_ret=""
-- while true do
-- 打印数组
function module:print_a ( a,size ,fmt)
local str=""
if(a==nil) then return end
if(size==nil) then size=1 end
for pos,val in pairs(a) do
str=str..byte_to_hex(val,size)..", "
end
print(str)
end
function module:__tostring()
return "print table package"
end
return module