Files
python_tools/web/layui/local_more_fun.js

555 lines
13 KiB
JavaScript
Raw Normal View History

2024-01-14 22:38:04 +08:00
/*var Local_More_View_ID = 0;
async function Local_More()
{
ShowBtAddr(1);
BtOper_Json.waittimeout = 1000;
BtOper_Json.waitack = true;
ShowCommMes("抗震检测",MesgType.MESG_TYPE_INFO);
ShowCommMes("循环延时用来控制充电时间",MesgType.MESG_TYPE_INFO);
//获取输入框数据
BtGetInputInfo();
await TransSleep(1000);
//开总线
BtOper_Json.busmode = 2;
BtOper_Json.cycletest = 0;
BtOper_Json.opercmd = EProCmdV.SET_BUS_MODE_;
await SendCmd(true);
await TransSleep(1000);
BtOper_Json.opercmd = EProCmdV.WRITE_UID_;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.WRITE_PWD_;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.BC_WRITE_ADDR_;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.SET_DELAY_;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.CHARGE_;
await SendCmd(true);
await TransSleep(BtOper_Json.rundelay);
await TimerAmend_( 1, 500, true, true, 1200);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.SET_PSWD_FLAG;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.BASE_CHECK_;
BtOper_Json.setparam[0] = 0;
await SendCmd(true);
await TransSleep(1000);
BtOper_Json.opercmd = EProCmdV.READ_STATE_;
await SendCmd(true);
await TransSleep(20);
BtOper_Json.opercmd = EProCmdV.BOOM_;
await SendCmd(true);
await TransSleep(20);
//关总线
BtOper_Json.opercmd = EProCmdV.SET_BUS_MODE_;
BtOper_Json.busmode = 1;
await SendCmd(true);
}*/
/*
* 时钟精度测试
* */
/*
async function Local_More()
{
var count = 0;
var rtv = 0;
GetEp1_InputInfo();
epro1_oper.commaddr = 1;
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
while(count < epro1_oper.cycle_runcount)
{
epro1_oper.cmd = 11;
ep1_bus_switch = 0;
await Ep1_SwitchBus();
Ep1_Beep(1);
count++;
await TransSleep(1500);
ShowCommMes("启动时钟精度自动检测 "+ epro1_oper.delayfire +"ms",MesgType.MESG_TYPE_INFO);
if(count == 1)
{
epro1_oper.cmd = 23;
rtv = await Ep1_SetPWDFlag();
if(rtv > 0)
{
ShowCommMes("密码验证失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
}
await TransSleep(100);
epro1_oper.cmd = 33;
rtv = await Ep1_ReadSysStatesCmd();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
await TransSleep(100);
epro1_oper.cmd = 1;
await Ep1_Charge();
await TransSleep(5000);
epro1_oper.cmd = 25;
rtv = await Ep1_WriteDelay();
if(rtv > 0)
{
ShowCommMes("延时设置失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
await TransSleep(100);
epro1_oper.cmd = 5;
await Ep1_ClkAmend(1,500);
await TransSleep(100);
epro1_oper.cmd = 35;
await Ep1_ReadAmend();
await TransSleep(100);
epro1_oper.cmd = 4 ;
await Ep1_Blast();
epro1_oper.cmd = 11;
ep1_bus_switch = 1;
await Ep1_SwitchBus();
ShowCommMes("等待起爆完成 ",MesgType.MESG_TYPE_INFO);
await TransSleep(3000+epro1_oper.delayfire);
ShowCommMes("测试完成 ");
}
}*/
/*
* @param 定时器翻转发送
*/
/*
async function Local_More()
{
var rtv = 0;
var param = [];
GetEp1_InputInfo();
epro1_oper.commaddr = 1;
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
epro1_oper.cmd = 100;
param[0] = epro1_oper.delayfire;
cmd_buf = Ep1_CmdData(0,8,20,param,0);
ep1_excuedcmd = 0;
Ep1_SendCmd(cmd_buf);
rtv = await Ep1_WaitCmdExcu(epro1_oper.cmd,1000);
await TransSleep(1000);
}*/
/*
在线搜索
* */
/*
async function Local_More()
{
var count = 0;
var rtv = 0;
var uid_head = '581900230A0'
GetEp1_InputInfo();
var flow_num = epro1_oper.cycle_bgaddr;
epro1_oper.commaddr = 1;
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
while((flow_num < epro1_oper.cycle_endaddr) && (epro1_oper.cycle_test > 0))
{
epro1_oper.commaddr = 1;
epro1_oper.uid = uid_head + IntFormat(4,flow_num);
await TransSleep(1000);
Ep1_Beep(1);
epro1_oper.cmd = 33;
rtv = await Ep1_ReadSysStatesCmd();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
continue
}
await TransSleep(50);
epro1_oper.cmd = 18;
rtv = await Ep1_WriteUID();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
continue
}
await TransSleep(50);
epro1_oper.cmd = 21;
rtv = await Ep1_WritePWD();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
continue
}
await TransSleep(50);
epro1_oper.cmd = 28;
epro1_oper.commaddr = 500;
rtv = await Ep1_WriteAddr();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
continue
}
await TransSleep(50);
epro1_oper.cmd = 10;
rtv = await Ep1_Sleep();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
continue
}
Ep1_Beep(2);
flow_num++;
ShowCommMes("注入UID: "+epro1_oper.uid+" 成功",MesgType.MESG_TYPE_INFO);
await TransSleep(1000);
}
}*/
/*
在线巡检搜索未注册雷管
* */
/*
async function Local_More()
{
var array_result = [];
var result_count = 0;
var ok_addr = [];
var rtv;
var count = 400;
while(1){
epro1_oper.cmd = 31;
epro1_oper.auset_addr_fac = count;
await Ep1_SearchTask();
await TransSleep(200);
var bgaddr = 21;
var ok_index = 0;
ok_addr = [];
count+=20;
while(bgaddr < count)
{
epro1_oper.cmd = 13;
var rtd = await Ep1_Inspect(bgaddr,bgaddr+50,1);
for(var index = 0; index <rtd.ok_addr.length;index++ )
{
ok_addr[ok_index++] = rtd.ok_addr[index];
}
await TransSleep(1000);
bgaddr += 50;
}
if(ok_index == 0)
{
ShowCommMes("搜索完成 数量:"+result_count ,MesgType.MESG_TYPE_INFO);
break;
}else{
ShowCommMes("次轮搜索到 "+ok_index ,MesgType.MESG_TYPE_INFO);
}
count -= 70;
for(var index = 0; index < ok_index; index++)
{
epro1_oper.cmd = 17;
epro1_oper.commaddr = ok_addr[index];
rtv = await Ep1_ReadUID();
await TransSleep(20);
if(rtv != 0)
{
continue;
}
var search_result = {
uid:"",
delay:0,
};
search_result.uid = epro1_oper.uid;
epro1_oper.cmd = 24;
rtv = await Ep1_ReadDelay();
await TransSleep(20);
if(rtv != 0)
{
continue;
}
search_result.delay = epro1_oper.delayfire;
ShowCommMes("uid "+search_result.uid+" 延时:"+ search_result.delay ,MesgType.MESG_TYPE_INFO);
array_result[result_count++] = search_result;
epro1_oper.cmd = 19;
epro1_oper.commaddr = 1000;
await Ep1_VerifiUidFeature();
await TransSleep(10);
epro1_oper.cmd = 10;
await Ep1_Sleep();
await TransSleep(20);
}
}
for(var index = 0; index < result_count; index++)
{
var result = array_result[index];
if(result.delay >= 5)
{
result.delay -= 5;
}else{
result.delay = "未设置";
}
ShowCommMes("UID"+result.uid+" 延时:" + result.delay,MesgType.MESG_TYPE_INFO);
}
}*/
/*
* 时钟精度测试
* */
/*
async function Local_More()
{
var count = 0;
var rtv = 0;
GetEp1_InputInfo();
epro1_oper.commaddr = 1;
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
epro1_oper.cmd = 11;
ep1_bus_switch = 0;
await Ep1_SwitchBus();
Ep1_Beep(1);
await TransSleep(1500);
ShowCommMes("启动测试 延时 "+ epro1_oper.delayfire +"ms",MesgType.MESG_TYPE_INFO);
epro1_oper.cmd = 23;
rtv = await Ep1_SetPWDFlag();
if(rtv > 0)
{
ShowCommMes("密码验证失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
await TransSleep(100);
epro1_oper.cmd = 33;
rtv = await Ep1_ReadSysStatesCmd();
if(rtv > 0)
{
ShowCommMes("通讯失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
await TransSleep(100);
epro1_oper.cmd = 1;
await Ep1_Charge();
await TransSleep(8000);
epro1_oper.cmd = 25;
rtv = await Ep1_WriteDelay();
if(rtv > 0)
{
ShowCommMes("延时设置失败 ",MesgType.MESG_TYPE_ERROR);
return ;
}
await TransSleep(100);
epro1_oper.cmd = 5;
await Ep1_ClkAmend(1,500);
await TransSleep(100);
epro1_oper.cmd = 35;
await Ep1_ReadAmend();
await TransSleep(100);
epro1_oper.cmd = 4 ;
await Ep1_Blast();
epro1_oper.cmd = 11;
ep1_bus_switch = 1;
await Ep1_SwitchBus();
Ep1_Beep(2);
await TransSleep(1500);
ShowCommMes("等待起爆完成 ",MesgType.MESG_TYPE_INFO);
await TransSleep(1500+epro1_oper.delayfire);
ShowCommMes("测试完成 ",MesgType.MESG_TYPE_INFO);
epro1_oper.cmd = 11;
ep1_bus_switch = 0;
await Ep1_SwitchBus();
await TransSleep(1500);
epro1_oper.cmd = 37;
epro1_oper.flash_r_bgaddr = 0x3E84;
epro1_oper.flash_r_len = 4;
var readbuf = await Ep1_ReadFlashCmd();
if(readbuf.length > 0)
{
var temp_v = 0;
temp_v = (readbuf[1] << 8) | readbuf[0];
temp_v = temp_v / 4096*3.3/0.43*3.43;
temp_v = temp_v.toFixed(1);
ShowCommMes("起爆电压 "+ temp_v,MesgType.MESG_TYPE_OK);
}else{
ShowCommMes("起爆电压读取失败 ",MesgType.MESG_TYPE_ERROR);
}
epro1_oper.flash_r_bgaddr = 0x3E60;
epro1_oper.flash_r_len = 4;
readbuf = await Ep1_ReadFlashCmd();
if(readbuf.length > 0)
{
var temp_buf = [];
temp_buf[0] = readbuf[0];
var boom_flg = Bytes2Str(temp_buf);
temp_buf[0] = readbuf[1];
var reset_flag = Bytes2Str(temp_buf);
ShowCommMes("起爆标志 "+ boom_flg + "复位标志 "+ reset_flag,MesgType.MESG_TYPE_OK);
}else{
ShowCommMes("读起爆标志失败 ",MesgType.MESG_TYPE_ERROR);
}
epro1_oper.flash_r_bgaddr = 0x3EF0;
epro1_oper.flash_r_len = 10;
readbuf = await Ep1_ReadFlashCmd();
var timer_count = 0;
var timer_remain = 0;
var awu_count = 0;
var max_dot = 0;
var lpt_reload = 0;
if(readbuf.length > 0)
{
timer_count = (readbuf[1] << 8) | readbuf[0];
timer_remain = (readbuf[3] << 8) | readbuf[2];
awu_count = (readbuf[5] << 8) | readbuf[4];
max_dot = (readbuf[7] << 8) | readbuf[6];
lpt_reload= (readbuf[9] << 8) | readbuf[8];
ShowCommMes("定时器打点数 "+ timer_count + "定时器余数 "+ timer_remain +" LPT打点数 "+ awu_count +" 最大标记点数 "+max_dot + " LPT周期值 "+lpt_reload,MesgType.MESG_TYPE_OK);
}else{
ShowCommMes("读取延时记录失败 ",MesgType.MESG_TYPE_ERROR);
}
var mask_count = 0;
var temp_count = 0;
epro1_oper.flash_r_bgaddr = 0x3C00;
epro1_oper.flash_r_len = 8;
while((epro1_oper.flash_r_len > 0) && (epro1_oper.flash_r_bgaddr <= 0x3DF8))
{
readbuf = await Ep1_ReadFlashCmd();
epro1_oper.flash_r_bgaddr += 8;
if(readbuf.length < 1)
{
ShowCommMes("标记点读取失败 ",MesgType.MESG_TYPE_ERROR);
return;
}
for(var index = 0; index < readbuf.length ;index++)
{
if(readbuf[index] == 0x00)
{
mask_count += 8;
continue;
}
temp_count = (~readbuf[index]) & 0x0FF;
while(temp_count > 0)
{
mask_count++;
temp_count >>= 1;
}
epro1_oper.flash_r_len = 0;
break;
}
}
ShowCommMes("记录打点数 " + mask_count,MesgType.MESG_TYPE_OK);
}*/
/*
工厂芯片测试
* */
/*
async function Local_More()
{
GetEp1_InputInfo();
epro1_oper.commaddr = 1;
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
var param = [];
param[0] = epro1_oper.delayfire & 0xFF;
var cmd_buf = Ep1_CmdData(1,8,0xFB,param,0);
ep1_excuedcmd = 0;
Ep1_SendCmd(cmd_buf);
var rtv = await Ep1_WaitCmdExcu(epro1_oper.cmd,1000);
}*/
/*
通讯测试
* */
async function Local_More()
{
GetEp1_InputInfo();
ShowCommMes("Local_More ",MesgType.MESG_TYPE_INFO);
epro1_oper.cmd = 11;
ep1_bus_switch = 0;
await Ep1_SwitchBus();
Ep1_Beep(1);
await TransSleep(1500);
ShowCommMes("启动通讯测试 ",MesgType.MESG_TYPE_INFO);
var count = 0;
while( (epro1_oper.cycle_test > 0)&&(epro1_oper.cycle_runcount > 0))
{
count = 0;
while((count < epro1_oper.cycle_group_count) && (epro1_oper.cycle_test > 0)&&(epro1_oper.cycle_runcount > 0))
{
epro1_oper.cycle_runcount --;
epro1_oper.commaddr = epro1_oper.cycle_bgaddr +count;
epro1_oper.cmd = 24;
await Ep1_ReadDelay();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 34;
await Ep1_ReadFirmwareCmd();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 33;
await Ep1_ReadSysStatesCmd();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 17;
await Ep1_ReadUID();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 19;
await Ep1_VerifiUidFeature();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 28;
await Ep1_WriteAddr();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 23;
await Ep1_SetPWDFlag();
await TransSleep(Math.round(Math.random()*180+20));
epro1_oper.cmd = 22;
await Ep1_VerifiPwdCmd();
await TransSleep(Math.round(Math.random()*180+20));
count++;
}
epro1_oper.cycle_runcount --;
}
}
function Localplugin_More()
{
ShowCommMes("Localplugin4_More ",MesgType.MESG_TYPE_INFO);
}