|
|
@ -26,6 +26,11 @@ PlateCodeScanerTab *PlateCodeScanerTab::inst() { |
|
|
|
return ins; |
|
|
|
} |
|
|
|
|
|
|
|
typedef struct { |
|
|
|
uint8_t buf[500]; |
|
|
|
int16_t len; |
|
|
|
} plate_code_cache_t; |
|
|
|
|
|
|
|
void PlateCodeScanerTab::construct(QTabWidget *fathertab) { |
|
|
|
/***********************************************************************************************************************
|
|
|
|
* 模块操作 * |
|
|
@ -47,58 +52,62 @@ void PlateCodeScanerTab::construct(QTabWidget *fathertab) { |
|
|
|
|
|
|
|
{ |
|
|
|
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "板夹仓扫描操作", 4); |
|
|
|
box->newFunc("开始扫描", {"startpos"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kplate_code_scaner_start_scan, atoi(args[0])); }); |
|
|
|
box->newFunc("开始扫描", {"stoppos"}, [this](int argn, const char **args) { ICM->callcmd1(getDeviceId(), kplate_code_scaner_push_card_and_scan, atoi(args[0])); }); |
|
|
|
box->newFunc("停止扫描", {}, [this](int argn, const char **args) { ICM->callcmd0(getDeviceId(), kplate_code_scaner_stop_scan); }); |
|
|
|
box->newFunc("读取结果", {}, [this](int argn, const char **args) { |
|
|
|
// int numResult = 0;
|
|
|
|
// ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_result_packet_num);
|
|
|
|
// numResult = ICM->getAck(0);
|
|
|
|
|
|
|
|
// uint8_t buf[1024] = {0};
|
|
|
|
// uint8_t len = 0;
|
|
|
|
// while (true) {
|
|
|
|
// ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_result);
|
|
|
|
// if (ICM->getAckBufLen() == 0) break;
|
|
|
|
plate_code_cache_t rawcode = {0}; |
|
|
|
int32_t packetIndex = 0; |
|
|
|
while (true) { |
|
|
|
ICM->callcmd1(getDeviceId(), kplate_code_scaner_read_result, packetIndex); |
|
|
|
if (ICM->getAckBufLen() == 0) break; |
|
|
|
|
|
|
|
memcpy(rawcode.buf + rawcode.len, ICM->getAckBuf(), ICM->getAckBufLen()); |
|
|
|
rawcode.len += ICM->getAckBufLen(); |
|
|
|
|
|
|
|
// memcpy(buf + len, ICM->getAckBuf(), ICM->getAckBufLen());
|
|
|
|
// len += ICM->getAckBufLen();
|
|
|
|
// }
|
|
|
|
ZQUI::ins()->ishow("read(%d),%d", packetIndex, ICM->getAckBufLen()); |
|
|
|
packetIndex++; |
|
|
|
} |
|
|
|
|
|
|
|
// int16_t *data = (int16_t *)buf;
|
|
|
|
// for (int i = 0; i < len / 2; i++) {
|
|
|
|
// ZQUI::ins()->ishow("%d", data[i]);
|
|
|
|
// }
|
|
|
|
ZQUI::ins()->ishow("pointNum:%d", rawcode.len / 2); |
|
|
|
|
|
|
|
DoInUi([this]() { |
|
|
|
DoInUi([this, rawcode]() { |
|
|
|
WidgetPlot2D *plot2d = new WidgetPlot2D(); |
|
|
|
QStringList lines; |
|
|
|
lines.push_back("line1"); |
|
|
|
plot2d->initGraphName(lines); |
|
|
|
for (size_t i = 0; i < 10; i++) { |
|
|
|
plot2d->addData("line1", i); |
|
|
|
|
|
|
|
int16_t *point_table = (int16_t *)rawcode.buf; |
|
|
|
|
|
|
|
for (int i = 0; i < rawcode.len / 2; i++) { |
|
|
|
plot2d->addData("line1", point_table[i]); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 15; i++) { |
|
|
|
plot2d->addRefLine(i * 12 + 6); |
|
|
|
} |
|
|
|
|
|
|
|
plot2d->show(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
box->newFunc("读取条码", {}, [this](int argn, const char **args) { |
|
|
|
int code0 = 0; |
|
|
|
int code1 = 0; |
|
|
|
// int32_t* rawcode, int32_t* legal, int32_t* item, int32_t* lot
|
|
|
|
ICM->callcmd0(getDeviceId(), kplate_code_scaner_read_code); |
|
|
|
code0 = ICM->getAck(0); |
|
|
|
code1 = ICM->getAck(1); |
|
|
|
|
|
|
|
ZQUI::ins()->ishow("code0=%d, code1=%d", code0, code1); |
|
|
|
int32_t rawcode = ICM->getAck(0); |
|
|
|
int32_t legal = ICM->getAck(1); |
|
|
|
int32_t item = ICM->getAck(2); |
|
|
|
int32_t lot = ICM->getAck(3); |
|
|
|
ZQUI::ins()->ishow("rawcode:0x%08x,legal:%d,item-lot: %d-%d", rawcode, legal, item, lot); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
ZQFunctionListBox *box = new ZQFunctionListBox(tab, "板夹仓扫码器-硬件调试", 4); |
|
|
|
|
|
|
|
// kplate_code_scaner_adc_readraw = CMDID(0x73, 6), // int32_t* val
|
|
|
|
// kplate_code_scaner_open_laser = CMDID(0x73, 7), //
|
|
|
|
// kplate_code_scaner_close_laser = CMDID(0x73, 8), //
|
|
|
|
|
|
|
|
box->newSubButton("读取ADC", [this](int argn, const char **args) { |
|
|
|
int val = 0; |
|
|
|
ICM->callcmd0(getDeviceId(), kplate_code_scaner_adc_readraw); |
|
|
@ -129,8 +138,17 @@ void PlateCodeScanerTab::construct(QTabWidget *fathertab) { |
|
|
|
|
|
|
|
tableBox->addReg("laster_intensity", kreg_plate_code_scaner_laster_intensity, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_gain", kreg_plate_code_scaner_scan_gain, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_step_interval", kreg_plate_code_scaner_scan_step_interval, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_point_num", kreg_plate_code_scaner_scan_point_num, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
|
|
|
|
tableBox->addReg("laster_intensity", kreg_plate_code_scaner_laster_intensity, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_gain", kreg_plate_code_scaner_scan_gain, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_velocity", kreg_plate_code_scaner_scan_velocity, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("scan_start_pos(0.1mm)", kreg_plate_code_scaner_scan_start_pos, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("final_stop_pos(0.1mm)", kreg_plate_code_scaner_final_stop_pos, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("code_judgment_threshold(0..4095)", kreg_plate_code_scaner_code_judgment_threshold, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("code_legal(1:有效,0:无效,-1:采集中断)", kreg_plate_code_scaner_code_legal, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("item", kreg_plate_code_scaner_item, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("lot", kreg_plate_code_scaner_lot, ZRegItem::krw | ZRegItem::kdec); |
|
|
|
tableBox->addReg("rawcode", kreg_plate_code_scaner_rawcode, ZRegItem::krw | ZRegItem::kbinary); |
|
|
|
|
|
|
|
tableBox->addSpacer(); |
|
|
|
tab->addSpacer(); |
|
|
|