|
|
#include "tabbuilder.hpp"
#include "../dep.hpp"
using namespace iflytop; using namespace app_transmit_disinfection; using namespace transmit_disfection_protocol;
#define CAN_MASTER TransmitDisinfectionCanMaster::ins()
static void readBoardInfo(int deviceId) { ack_read_board_info_data_t ack = CAN_MASTER->readboardinfo(deviceId); ISHOW("boardType :%s(%d)", BoardTypeId2Str(ack.boardType), ack.boardType); ISHOW("projectId :%s(%d)", ProjectIDToString(ack.projectId), ack.projectId); ISHOW("protcol_version :%d", ack.protcol_version); ISHOW("software_version :%d", ack.software_version); ISHOW("hardware_version :%d", ack.hardware_version); }
static void readSysInfo(int deviceId) { //
ack_sysinfo_t ack = CAN_MASTER->readsysinfo(deviceId); ask_taskinfo_t task[20]; for (int i = 0; i < ack.taskNum; i++) { task[i] = CAN_MASTER->readtaskinfo(deviceId, i); } ISHOW("=========================== sys info ==========================="); ISHOW("total_heap_size :%d", ack.total_heap_size); ISHOW("free_heap_size :%d", ack.free_heap_size); ISHOW("free_sys_heap_size :%d", ack.free_sys_heap_size); ISHOW("sysHasRun :%d", ack.sysHasRun); ISHOW("=");
ISHOW("=========================== task info ==========================="); ISHOW("taskoff name state stackRemainSize priority"); for (int i = 0; i < ack.taskNum; i++) { ISHOW("%d %10s %c %d %d", i, task[i].taskName, task[i].state, task[i].stackRemindSize, task[i].priority); } ISHOW("="); }
ZQVTabPage *TabBuilder::getTab(const char *tabname) { if (tabMap.find(tabname) == tabMap.end()) { ZQVTabPage *tab = new ZQVTabPage(fathertab, tabname); tabMap[tabname] = tab; } return tabMap[tabname]; }
// int blowserIsOpen(int boardid) {}
// int airCompressorIsOpen(int boardid) {}
// int airTightnessTestACIsOpen(int boardid) {}
// int heaterIsOpen(int boardid) {}
// extChSelectorGetCh
// int airTightnessTestIsCutoff(int boardid) { return m_com->callcmd0(boardid, kfn_air_tightness_test_is_cutoff, DEFUALT_OVERTIME)->getContent(0); }
// void warningLightReadState(int boardid, int *r, int *g, int *b, int *warning);
void TabBuilder::buildBoardBasicCtrl(const char *tabname, int boardid) { //
ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "通用", 4); box->newSubButton("PingAll", [this, boardid](int argn, const char **args) { CAN_MASTER->pingAllBoard(); }); box->newSubButtonEnd();
if (boardid >= 0) { box->newSubButton("读取板卡信息", [this, boardid](int argn, const char **args) { readBoardInfo(boardid); }); box->newSubButton("读取系统信息", [this, boardid](int argn, const char **args) { readSysInfo(boardid); }); box->newSubButtonEnd(); box->newSubButton("清除复位标识", [this, boardid](int argn, const char **args) { CAN_MASTER->clearResetFlag(boardid); }); // enableReport
box->newSubButtonEnd(); box->newSubButton("使能上报", [this, boardid](int argn, const char **args) { CAN_MASTER->enableReport(boardid, 1); }); box->newSubButton("失能上报", [this, boardid](int argn, const char **args) { CAN_MASTER->enableReport(boardid, 0); }); box->newSubButtonEnd(); box->newSubButton("复位板卡", [this, boardid](int argn, const char **args) { CAN_MASTER->resetBoard(boardid); });
} else { box->newFunc("读取板卡信息", {"boardid"}, [this](int argn, const char **args) { readBoardInfo(atoi(args[0])); }); box->newFunc("读取系统信息", {"boardid"}, [this](int argn, const char **args) { readSysInfo(atoi(args[0])); }); box->newFunc("清除复位标识", {"boardid"}, [this](int argn, const char **args) { CAN_MASTER->clearResetFlag(atoi(args[0])); }); box->newFunc("使能上报", {"boardid"}, [this](int argn, const char **args) { CAN_MASTER->enableReport(atoi(args[0]), 1); }); box->newFunc("失能上报", {"boardid"}, [this](int argn, const char **args) { CAN_MASTER->enableReport(atoi(args[0]), 0); }); box->newFunc("复位板卡", {"boardid"}, [this](int argn, const char **args) { CAN_MASTER->resetBoard(atoi(args[0])); }); } } void TabBuilder::buildFnPumpCtrl(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "泵机控制(0:加液泵, 1:喷液泵)", 6); box->newFunc("pumpRotate", {"subid", "rpm"}, [](int argn, const char **args) { //
CAN_MASTER->pumpRotate(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1])); }); box->newFunc("pumpStop", {"subid"}, [](int argn, const char **args) { //
CAN_MASTER->pumpStop(kFixBoardId_LiquidCtrl, atoi(args[0])); });
box->newFunc("pumpSetIholdIrunIdelay", {"subid", "ihold", "irun", "idelay"}, [](int argn, const char **args) { //
CAN_MASTER->pumpSetIholdIrunIdelay(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1]), atoi(args[2]), atoi(args[3])); }); // pumpSetTzw
box->newFunc("pumpSetTzw", {"subid", "tzw"}, [](int argn, const char **args) { //
CAN_MASTER->pumpSetTzw(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1])); });
box->newFunc("pumpSetRamp", {"subid", "vs", "a1", "amx", "v1"}, [](int argn, const char **args) { //
CAN_MASTER->pumpSetRamp(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1]), atoi(args[2]), atoi(args[3]), atoi(args[4])); });
box->newFunc("pumpSetSubicReg", {"subid", "regadd", "val"}, [](int argn, const char **args) { //
CAN_MASTER->pumpSetSubicReg(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1]), atoi(args[2])); });
box->newFunc("pumpGetSubicReg", {"subid", "regadd"}, [](int argn, const char **args) { //
int val = CAN_MASTER->pumpGetSubicReg(kFixBoardId_LiquidCtrl, atoi(args[0]), atoi(args[1])); ISHOW("val:%x", val); });
box->newFunc("pumpIsRun", {"subid"}, [](int argn, const char **args) { //
int val = CAN_MASTER->pumpIsRun(kFixBoardId_LiquidCtrl, atoi(args[0])); ISHOW("val:%d", val); }); }
void TabBuilder::buildHearterTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "加热器", 4);
box->newSubButton("加热打开", [this, boardid](int argn, const char **args) { CAN_MASTER->heaterCtrl(boardid, 1); }); box->newSubButton("加热关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->heaterCtrl(boardid, 0); });
box->newSubButtonEnd(); box->newSubButton("加热安全阀打开", [this, boardid](int argn, const char **args) { CAN_MASTER->heaterCtrlSafeValve(boardid, 1); }); box->newSubButton("加热安全阀关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->heaterCtrlSafeValve(boardid, 0); }); box->newSubButtonEnd(); box->newSubButton("读取电流", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->heaterReadEI(boardid); ISHOW("val:%d", val); }); box->newSubButton("读取温度", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->heaterReadTemperature(boardid); ISHOW("val:%d", val); }); box->newSubButton("读取电流ADC", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->heaterReadEIAdcRaw(boardid); ISHOW("val:%d", val); });
box->newSubButton("读取温度Adc", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->heaterReadTemperatureAdcRaw(boardid); ISHOW("val:%d", val); }); box->newSubButton("是否运行", [this, boardid](int argn, const char **args) { bool val = CAN_MASTER->heaterIsOpen(boardid); ISHOW("val:%d", val); }); } void TabBuilder::buildH2O2SensorTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "H2O2", 4);
if (boardid >= 0) { box->newFunc("H2O2传感器读取校准日期", {}, [boardid](int argn, const char **args) { int32_t year, month, day; CAN_MASTER->h2o2SensorReadCalibrationDate(boardid, &year, &month, &day); ISHOW("year:%d,month:%d,day:%d", year, month, day); }); box->newFunc("H2O2传感器读取IC错误码", {}, [boardid](int argn, const char **args) { int val = CAN_MASTER->h2o2SensorReadSubIcErrorcode(boardid); ISHOW("val:%d", val); }); box->newFunc("H2O2传感器读取IC寄存器", {"reg", "num"}, [boardid](int argn, const char **args) { uint8_t *val = CAN_MASTER->h2o2SensorReadSubIcReg(boardid, atoi(args[0]), atoi(args[1])); ISHOW("val:%s", zhex2str(val, atoi(args[1]) * 2).c_str()); }); } else { box->newFunc("H2O2传感器读取校准日期", {"boardid"}, [this](int argn, const char **args) { int32_t year, month, day; CAN_MASTER->h2o2SensorReadCalibrationDate(atoi(args[0]), &year, &month, &day); ISHOW("year:%d,month:%d,day:%d", year, month, day); }); box->newFunc("H2O2传感器读取IC错误码", {"boardid"}, [this](int argn, const char **args) { int val = CAN_MASTER->h2o2SensorReadSubIcErrorcode(atoi(args[0])); ISHOW("val:%d", val); }); box->newFunc("H2O2传感器读取IC寄存器", {"boardid", "reg", "num"}, [this](int argn, const char **args) { uint8_t *val = CAN_MASTER->h2o2SensorReadSubIcReg(atoi(args[0]), atoi(args[1]), atoi(args[2])); ISHOW("val:%s", zhex2str(val, atoi(args[2]) * 2).c_str()); }); } }
void TabBuilder::buildTripleWarningLightTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "三色警报灯", 4); box->newFunc("三色指示灯控制", {"r", "g", "b", "warning"}, [this, boardid](int argn, const char **args) { //
CAN_MASTER->warningLightSetState(boardid, atoi(args[0]), atoi(args[1]), atoi(args[2]), atoi(args[3])); }); box->newFunc("读取三色指示灯状态", {}, [this, boardid](int argn, const char **args) { int r, g, b, warning; CAN_MASTER->warningLightReadState(boardid, &r, &g, &b, &warning); ISHOW("r:%d,g:%d,b:%d,warning:%d", r, g, b, warning); }); } void TabBuilder::buildWaterSensorTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "水浸", 4); box->newSubButton("读取-蒸发桶水浸传感器-状态", [this, boardid](int argn, const char **args) { int state = CAN_MASTER->evaporationTankWSReadState(boardid); ISHOW("state:%d", state); }); box->newSubButton("读取-设备底部水浸传感器-状态", [this, boardid](int argn, const char **args) { int state = CAN_MASTER->bottomWSReadState(boardid); ISHOW("state:%d", state); }); } void TabBuilder::buildBlowerTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "风机", 4); box->newSubButton("风机打开", [this, boardid](int argn, const char **args) { CAN_MASTER->blowerCtrl(boardid, 1); }); box->newSubButton("风机关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->blowerCtrl(boardid, 0); }); box->newSubButtonEnd(); box->newSubButton("风机安全阀打开", [this, boardid](int argn, const char **args) { CAN_MASTER->blowerCtrlSafeValve(boardid, 1); }); box->newSubButton("风机安全阀关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->blowerCtrlSafeValve(boardid, 0); }); box->newSubButtonEnd(); box->newSubButton("风机读取电流", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->blowerReadEI(boardid); ISHOW("val:%d", val); }); box->newSubButton("风机读取电流ADC", [this, boardid](int argn, const char **args) { int val = CAN_MASTER->blowerReadEIAdcRaw(boardid); ISHOW("val:%d", val); }); box->newSubButtonEnd(); box->newSubButton("风机是否错误", [this, boardid](int argn, const char **args) { bool val = CAN_MASTER->blowerReadElectricIsError(boardid); ISHOW("val:%d", val); }); box->newSubButton("风机是否打开", [this, boardid](int argn, const char **args) { bool val = CAN_MASTER->blowserIsOpen(boardid); ISHOW("val:%d", val); }); }
void TabBuilder::buildAirCompressorTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "空压机", 4); box->newSubButton("空压机打开", [this, boardid](int argn, const char **args) { CAN_MASTER->airCompressorCtrl(boardid, 1); }); box->newSubButton("空压机关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->airCompressorCtrl(boardid, 0); }); box->newSubButtonEnd(); // box->newFunc("空压机安全阀控制", {"valve_state"}, [this, boardid](int argn, const char **args) { CAN_MASTER->airCompressorCtrlSafeValve(boardid, atoi(args[0])); });
box->newSubButton("空压机安全阀打开", [this, boardid](int argn, const char **args) { CAN_MASTER->airCompressorCtrlSafeValve(boardid, 1); }); box->newSubButton("空压机安全阀关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->airCompressorCtrlSafeValve(boardid, 0); }); box->newSubButtonEnd(); box->newFunc("空压机读取电流", {}, [this, boardid](int argn, const char **args) { int val = CAN_MASTER->airCompressorReadEI(boardid); ISHOW("val:%d", val); }); box->newFunc("空压机读取电流ADC", {}, [this, boardid](int argn, const char **args) { int val = CAN_MASTER->airCompressorReadEIAdcRaw(boardid); ISHOW("val:%d", val); }); box->newFunc("空压机是否打开", {}, [this, boardid](int argn, const char **args) { bool val = CAN_MASTER->airCompressorIsOpen(boardid); ISHOW("val:%d", val); }); }
void TabBuilder::buildAirTightnessTestACTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "气密性测试空压机", 4); box->newSubButton("打开", [this, boardid](int argn, const char **args) { CAN_MASTER->airTightnessTestACCtrl(boardid, 1); }); box->newSubButton("关闭", [this, boardid](int argn, const char **args) { CAN_MASTER->airTightnessTestACCtrl(boardid, 0); }); box->newSubButtonEnd(); box->newSubButton("是否打开", [this, boardid](int argn, const char **args) { bool val = CAN_MASTER->airTightnessTestACIsOpen(boardid); ISHOW("val:%d", val); }); } void TabBuilder::buildPSBusTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "PSBus", 4); box->newFunc("读数据", {"subid"}, [this, boardid](int argn, const char **args) { int32_t val = CAN_MASTER->psBusReadData(boardid, atoi(args[0])); ISHOW("val:%d", val); });
box->newSubButton("读取扫描结果", [this, boardid](int argn, const char **args) { auto result = CAN_MASTER->psBusScan(boardid); for (int i = 0; i < 10; i++) { if (result.sensor[i].isOnline) { ISHOW("id %d, subid %d, ptype %s, uint %s, precision %d, zero %d, full %d", //
i, result.sensor[i].subid, PSType2Str(result.sensor[i].ptype), p100uint2Str(result.sensor[i].uint), result.sensor[i].precision, result.sensor[i].zero, result.sensor[i].full); } else { ISHOW("id %d, offline", i); } } });
box->newSubButtonEnd(); box->newSubButton("开始上报", [this, boardid](int argn, const char **args) { CAN_MASTER->psBusStartReport(boardid, 1000); }); box->newSubButton("停止上报", [this, boardid](int argn, const char **args) { CAN_MASTER->psBusStopReport(boardid); }); }
void TabBuilder::buildProportionalTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "比例阀", 4); box->newFunc("设置比例阀", {"valveId(1->255)", "valveValue(0->255)"}, [this, boardid](int argn, const char **args) { //
CAN_MASTER->proportionalSetValve(boardid, atoi(args[0]), atoi(args[1])); }); box->newFunc("读取比例阀位置", {}, [this, boardid](int argn, const char **args) { //
int32_t val = CAN_MASTER->proportionalReadPos(boardid); ISHOW("val:%d", val); }); box->newFunc("比例阀是否忙", {}, [this, boardid](int argn, const char **args) { //
int32_t val = CAN_MASTER->proportionalIsBusy(boardid); ISHOW("val:%d", val); }); } void TabBuilder::buildAirTightnessTestTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "气密性测试", 4); box->newSubButton("消毒模式", [this, boardid](int argn, const char **args) { //
CAN_MASTER->getCanProtocolCom()->callcmd1(boardid, kfn_air_leak_test_set_mode, 0, DEFUALT_OVERTIME); }); box->newSubButton("打气模式", [this, boardid](int argn, const char **args) { //
CAN_MASTER->getCanProtocolCom()->callcmd1(boardid, kfn_air_leak_test_set_mode, 1, DEFUALT_OVERTIME); }); box->newSubButton("气压测试模式", [this, boardid](int argn, const char **args) { //
CAN_MASTER->getCanProtocolCom()->callcmd1(boardid, kfn_air_leak_test_set_mode, 2, DEFUALT_OVERTIME); }); box->newSubButtonEnd(); box->newSubButton("读取模式(0:消毒,1:打气,2:气压测试)", [this, boardid](int argn, const char **args) { //
shared_ptr<Receipt> receipt = CAN_MASTER->getCanProtocolCom()->callcmd0(boardid, kfn_air_leak_test_get_mode, DEFUALT_OVERTIME); ISHOW("val:%d", receipt->getContent(0)); }); }
void TabBuilder::buildExtChSelectorTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "外部通道选择", 4); box->newFunc("设置外部通道(0:消毒 1:降解 2:除湿)", {"ch"}, [this, boardid](int argn, const char **args) { //
CAN_MASTER->extChSelectorSetCh(boardid, atoi(args[0])); }); box->newFunc("读取外部通道", {}, [this, boardid](int argn, const char **args) { //
int val = CAN_MASTER->extChSelectorGetCh(boardid); ISHOW("val:%d", val); }); }
void TabBuilder::buildValveCtrlTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电磁阀", 4); box->newFunc("加液进气电磁阀(打开,可以正常加液排液,关闭后加液泵倒转可以排空管路)", {"open(1)/cloce(0)"}, [this, boardid](int argn, const char **args) { //
CAN_MASTER->getCanProtocolCom()->callcmd1(boardid, kfn_set_add_fluid_channel_selector_valve, atoi(args[0]), DEFUALT_OVERTIME); }); }
// void TabBuilder::buildValveCtrlTab(const char *tabname, int boardid) {
// ZQVTabPage *tab = getTab(tabname);
// ZQFunctionListBox *box = new ZQFunctionListBox(tab, "电磁阀", 4);
// box->newFunc("加液进气电磁阀(打开,可以正常加液排液,关闭后加液泵倒转可以排空管路)", {"open(1)/cloce(0)"}, [this, boardid](int argn, const char **args) { //
// CAN_MASTER->getCanProtocolCom()->callcmd1(boardid, kfn_set_add_fluid_channel_selector_valve, atoi(args[0]), DEFUALT_OVERTIME);
// });
// }
void TabBuilder::buildLiquidLevelStateReaderTab(const char *tabname, int boardid) { ZQVTabPage *tab = getTab(tabname); ZQFunctionListBox *box = new ZQFunctionListBox(tab, "液位(IO版)状态读取", 4); box->newFunc("读取状态(如果是IO0:低液位,IO1:中液位,IO2:高液位)", {}, [this, boardid](int argn, const char **args) { //
shared_ptr<Receipt> receipt = CAN_MASTER->getCanProtocolCom()->callcmd0(boardid, kfn_liquid_level_read_io_state, DEFUALT_OVERTIME); ISHOW("IO0:%d", receipt->getContent(0) & 0x01); ISHOW("IO1:%d", (receipt->getContent(0) >> 1) & 0x01); ISHOW("IO2:%d", (receipt->getContent(0) >> 2) & 0x01); }); }
void TabBuilder::buildEnd() { for (auto &it : tabMap) { it.second->addSpacer(); } }
|