Browse Source

v2.3.5 | 添加测试页面接口

master
zhaohe 1 month ago
parent
commit
a156954b47
  1. 35
      appdep/components/zservice_container/zservice_container.hpp
  2. 2
      appsrc/appconfig/basic/zappversion.hpp
  3. 22
      appsrc/baseservice/port/project_port.cpp
  4. 2
      appsrc/baseservice/port/project_port.hpp
  5. 1
      appsrc/main.cpp
  6. 4
      appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
  7. 27
      appsrc/service/app_core.cpp
  8. 1
      appsrc/service/app_core.hpp
  9. 6
      appsrc/service/hardware/device_io_ctrl_service.cpp
  10. 4
      appsrc/service/hardware/disinfectant_weight_update_service.cpp
  11. 57
      appsrc/service/hardware/sensor_state_sync_service.cpp
  12. 79
      appsrc/service/hardware/sensor_state_sync_service.hpp
  13. 4
      appsrc/service/hardware/warning_light_controler.cpp
  14. 114
      appsrc/service/test_page_ctrl_service.cpp
  15. 67
      appsrc/service/test_page_ctrl_service.hpp
  16. 267
      appsrc/service/test_page_mgr_service.cpp
  17. 57
      appsrc/service/test_page_mgr_service.hpp
  18. 60
      appsrc/service/test_page_service_v2.cpp
  19. 54
      appsrc/service/test_page_service_v2.hpp

35
appdep/components/zservice_container/zservice_container.hpp

@ -42,8 +42,7 @@ class ZserviceContainerAny {
template <typename ValueType>
explicit ZserviceContainerAny(const ValueType& value) : content_(new Holder<ValueType>(value)) {}
ZserviceContainerAny(const ZserviceContainerAny& other)
: content_(other.content_ ? other.content_->clone() : nullptr) {}
ZserviceContainerAny(const ZserviceContainerAny& other) : content_(other.content_ ? other.content_->clone() : nullptr) {}
public:
ZserviceContainerAny& swap(ZserviceContainerAny& rhs) {
@ -87,7 +86,7 @@ class ZserviceContainerAny {
public:
virtual const std::type_info& GetType() const = 0;
virtual ZPlaceHolder* clone() const = 0;
virtual ZPlaceHolder* clone() const = 0;
};
template <typename ValueType>
@ -136,7 +135,7 @@ ValueType zany_cast(const ZserviceContainerAny& any) {
class ServiceContrainer {
map<type_index, ZserviceContainerAny> services;
ServiceContrainer(){};
ServiceContrainer() {};
public:
static ServiceContrainer& get();
@ -148,7 +147,7 @@ class ServiceContrainer {
}
object->initialize();
type_index index = typeid(T);
services[index] = ZserviceContainerAny(object);
services[index] = ZserviceContainerAny(object);
};
template <typename T>
void regService(shared_ptr<T> object) {
@ -156,12 +155,12 @@ class ServiceContrainer {
return;
}
type_index index = typeid(T);
services[index] = ZserviceContainerAny(object);
services[index] = ZserviceContainerAny(object);
};
template <typename T>
shared_ptr<T> getService() {
type_index index = typeid(T);
auto result = services.find(index);
type_index index = typeid(T);
auto result = services.find(index);
if (result == services.end()) {
return nullptr;
}
@ -169,9 +168,19 @@ class ServiceContrainer {
};
template <typename T>
shared_ptr<T> getService(string file, int line) {
auto service = getService<T>();
if (service == nullptr) {
printf("[%s:%d] getService(%s) fail\n", file.c_str(), line, typeid(T).name());
exit(-1);
}
return service;
};
template <typename T>
void getToService(shared_ptr<T>& service) {
type_index index = typeid(T);
auto result = services.find(index);
type_index index = typeid(T);
auto result = services.find(index);
if (result == services.end()) {
service = nullptr;
}
@ -179,6 +188,8 @@ class ServiceContrainer {
};
};
#define SERVICE(type, name) shared_ptr<type> name = ServiceContrainer::get().getService<type>(__FILE__, __LINE__);
#define GET_SERVICE(type) (ServiceContrainer::get().getService<type>())
#define GET_TO_SERVICE(value) \
ServiceContrainer::get().getToService(value); \
@ -190,10 +201,10 @@ class ServiceContrainer {
#define BUILD_AND_REG_SERRVICE(type, ...) \
logger->info("build {}.....", #type); \
shared_ptr<type> type##_val(new type(__VA_ARGS__)); \
ServiceContrainer::get().regService(type##_val);\
ServiceContrainer::get().regService(type##_val); \
GET_SERVICE(type)->initialize();
#define REG_SERRVICE(type,object) \
#define REG_SERRVICE(type, object) \
shared_ptr<type> type##_val(object); \
ServiceContrainer::get().regService(type##_val);

2
appsrc/appconfig/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once
#define VERSION "2.3.4"
#define VERSION "2.3.5"
#define PROJECT_NAME "TRANSMIT_DM"

22
appsrc/baseservice/port/project_port.cpp

@ -55,7 +55,7 @@ string ProjectPort::getProjTypeString() { return projectType; }
void ProjectPort::initProjectSetting(int projectTypeInt) {
this->projectTypeInt = projectTypeInt;
// 设备ID初始化
if (isLageSpaceDM() || isDT300N() || isDT300W() || isDT600B()) {
if (isDT600N() || isDT300N() || isDT300W() || isDT600B()) {
// 加液泵
INSERT(HardwareComponent::AddLiquidPump, FIXBOARDID_LC_BOARD, kpumpid_add_liquid);
// 喷雾泵
@ -107,28 +107,28 @@ void ProjectPort::initProjectSetting(int projectTypeInt) {
// 00003072 INFO [PxxSensor] Sensor[4] id:4 ptype:P100 precision:1 unit:kpa zero:-900 full:1000 加液
float ProjectPort::ACPostPS_To_Pa(int rawval) {
if (isLageSpaceDM() || isDT300N() || isDT300W()) {
if (isDT600N() || isDT300N() || isDT300W()) {
return rawval / 10.0 * 1000;
} else {
THROW_APP_EXCEPTION(err::kappe_code_error, fmt::format("project [{}({})] not support: ", to_string(projectTypeInt).c_str(), projectTypeInt));
}
}
float ProjectPort::LiquidWeightPS_To_Pa(int rawval) {
if (isLageSpaceDM() || isDT300N() || isDT300W()) {
if (isDT600N() || isDT300N() || isDT300W()) {
return rawval;
} else {
THROW_APP_EXCEPTION(err::kappe_code_error, fmt::format("project [{}({})] not support: ", to_string(projectTypeInt).c_str(), projectTypeInt));
}
}
float ProjectPort::SprayPumpPostPS_To_Pa(int rawval) {
if (isLageSpaceDM() || isDT300N() || isDT300W()) {
if (isDT600N() || isDT300N() || isDT300W()) {
return rawval / 10.0 * 1000;
} else {
THROW_APP_EXCEPTION(err::kappe_code_error, fmt::format("project [{}({})] not support: ", to_string(projectTypeInt).c_str(), projectTypeInt));
}
}
float ProjectPort::AddLiquidPumpPostPS_To_Pa(int rawval) {
if (isLageSpaceDM() || isDT300N() || isDT300W()) {
if (isDT600N() || isDT300N() || isDT300W()) {
return rawval / 10.0 * 1000;
} else {
THROW_APP_EXCEPTION(err::kappe_code_error, fmt::format("project [{}({})] not support: ", to_string(projectTypeInt).c_str(), projectTypeInt));
@ -139,7 +139,7 @@ float ProjectPort::AirLeakDetectPS_To_Pa(int rawval) { return rawval; }
double ProjectPort::getGpm2SpeedRadio() {
float gpmToSpeedRadio = 0;
if (isLageSpaceDM()) {
if (isDT600N()) {
gpmToSpeedRadio = LARGE_SPACE_DM__GPM_TO_SPEED_RADIO;
} else if (isDT600B()) {
gpmToSpeedRadio = DT600B__GPM_TO_SPEED_RADIO;
@ -165,7 +165,7 @@ double ProjectPort::speed2gpm(double speed) {
}
float ProjectPort::pressurePa2VolumeG(int pa) {
if (isLageSpaceDM()) {
if (isDT600N()) {
return VolumeConvertor(VolumeConvertor::largeSpaceParam).pressurePa2VolumeG(pa);
}
if (isDT300N()) {
@ -182,7 +182,7 @@ float ProjectPort::pressurePa2VolumeG(int pa) {
}
int32_t ProjectPort::getMainH2O2SensorId() { return getId(HardwareComponent::MainH2O2Sensor).boardId; }
int32_t ProjectPort::getSprayLiquidPumpMaxRPM() {
if (isLageSpaceDM()) {
if (isDT600N()) {
return 600;
}
if (isDT600B()) {
@ -203,7 +203,7 @@ int32_t ProjectPort::getSprayLiquidPumpMaxRPM() {
* @brief
*/
int32_t ProjectPort::getDisinfectantBucketCapacity() {
if (isLageSpaceDM()) {
if (isDT600N()) {
return LARGE_SPACE_DM__DISINFECTANT_BUCKET_CAPACITY;
}
if (isDT300N()) {
@ -218,7 +218,7 @@ int32_t ProjectPort::getDisinfectantBucketCapacity() {
return 0;
}
int32_t ProjectPort::getExtH2O2SensorNum() {
if (isLageSpaceDM()) {
if (isDT600N()) {
return 2;
}
if (isDT300N()) {
@ -237,7 +237,7 @@ int32_t ProjectPort::getExtH2O2SensorNum() {
}
bool ProjectPort::isHasDisinfectantBucket() {
if (isLageSpaceDM()) {
if (isDT600N()) {
return true;
}
if (isDT300N()) {

2
appsrc/baseservice/port/project_port.hpp

@ -49,7 +49,7 @@ class ProjectPort {
/*******************************************************************************
* //设备类型判断 *
*******************************************************************************/
bool isLageSpaceDM() { return projectTypeInt == DT600N; }
bool isDT600N() { return projectTypeInt == DT600N; }
bool isDT300N() { return projectTypeInt == DT300N; }
bool isDT300W() { return projectTypeInt == DT300W; }
bool isDT100N() { return projectTypeInt == DT100N; }

1
appsrc/main.cpp

@ -142,6 +142,7 @@ int Main::main(int argc, char *argv[]) {
logger->info("#");
logger->info("build {}.....", "Config");
// logger->info("VolumeConvertor::largeSpaceParam:{}", VolumeConvertor(VolumeConvertor::largeSpaceParam).getFullVolumeG());
// logger->info("VolumeConvertor::smallSpaceParam:{}", VolumeConvertor(VolumeConvertor::smallSpaceParam).getFullVolumeG());
// logger->info("VolumeConvertor::pipeParam:{}", VolumeConvertor(VolumeConvertor::pipeParam).getFullVolumeG());

4
appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp

@ -565,7 +565,7 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event)
// }
// AppEventBus
if (PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
if (dwus->getWeight() < 10) {
logger->error("DisinfectantBucket is empty");
pushSnapshot(createErrorSnapshot(err::kappe_disinfectant_insufficient));
@ -673,7 +673,7 @@ void DisinfectionCtrlService::processStateFinished(DisinfectionEvent* event) {
s_remaintime = 0;
s_complete_tp = zsystem_clock().now();
if (PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
s_afterDisinfectantVolume_g = GET_SERVICE(DisinfectantWeightUpdateService)->getWeight();
} else if (PORT.isDT100N()) {
s_afterDisinfectantVolume_g = 0;

27
appsrc/service/app_core.cpp

@ -9,7 +9,7 @@
#include "service/front_end_realtime_display_content_mgr.hpp"
#include "service/os_mgr_service.hpp"
#include "service/setting_mgr_service.hpp"
#include "service/test_page_mgr_service.hpp"
#include "service/test_page_ctrl_service.hpp"
#include "service/user_mgr_service.hpp"
//
#include "device_check_point_check_service.hpp"
@ -26,8 +26,8 @@
#include "baseservice/db/device_ext_setting_dao.hpp"
#include "calibration/h2o2_liquid_weight_sensor_calibration_service.hpp"
#include "equipment_usage_info_mgr_service.hpp"
#include "service/hardware/sensor_state_sync_service.hpp"
#include "setting/ext_setting_mgr_service.hpp"
#include "test_page_service_v2.hpp"
// DeviceExtSettingDAO
@ -141,6 +141,7 @@ void AppCore::initialize() {
BUILD_AND_REG_SERRVICE(DisinfectantWeightUpdateService);
BUILD_AND_REG_SERRVICE(WarningLightControler);
BUILD_AND_REG_SERRVICE(SensorStateSyncService);
//
BUILD_AND_REG_SERRVICE(PipelinePressureControl);
BUILD_AND_REG_SERRVICE(UDiskMgrService);
@ -157,8 +158,7 @@ void AppCore::initialize() {
BUILD_AND_REG_SERRVICE(SettingMgrService);
BUILD_AND_REG_SERRVICE(DeviceInfoMgrService);
BUILD_AND_REG_SERRVICE(OsMgrService);
BUILD_AND_REG_SERRVICE(TestPageMgrService);
BUILD_AND_REG_SERRVICE(TestPageServiceV2);
BUILD_AND_REG_SERRVICE(TestPageCtrlService);
BUILD_AND_REG_SERRVICE(AddLiquidService);
BUILD_AND_REG_SERRVICE(AirLeakDetectTest);
@ -288,14 +288,31 @@ void AppCore::startStateReport(shared_ptr<MsgProcessContext> cxt) {
stateUpdateThread.reset(new Thread("stateUpdateThread", [this]() {
while (!ThisThread().getExitFlag()) {
// logger->info("start report");
try {
SEND_CLASS_REPORT(thisClass.className, "stateUpdate", getState());
} catch (const std::exception& e) {
logger->error("stateUpdateThread error:{}", e.what());
}
ThisThread().sleepForMs(500);
ThisThread().sleepForMs(1000);
// logger->info("end report");
// ThisThread().sleepForMs(1);
}
}));
// stateUpdateThread2.reset(new Thread("stateUpdateThread", [this]() {
// while (!ThisThread().getExitFlag()) {
// logger->info("start report");
// try {
// SEND_CLASS_REPORT(thisClass.className, "stateUpdate", getState());
// } catch (const std::exception& e) {
// logger->error("stateUpdateThread error:{}", e.what());
// }
// logger->info("end report");
// ThisThread().sleepForMs(1);
// }
// }));
}
void AppCore::stopStateReport(shared_ptr<MsgProcessContext> cxt) {
if (stateUpdateThread) {

1
appsrc/service/app_core.hpp

@ -43,6 +43,7 @@ class AppCore : public enable_shared_from_this<AppCore> {
list<shared_ptr<IAppEvent>> appEventList;
recursive_mutex appEventListMutex;
unique_ptr<Thread> stateUpdateThread;
unique_ptr<Thread> stateUpdateThread2;
public:
AppCore() {};

6
appsrc/service/hardware/device_io_ctrl_service.cpp

@ -96,7 +96,7 @@ void DeviceIoControlService::initialize() {
* @brief
*/
try {
if (PORT.isDT600B() || PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
// CAN_MASTER->clearResetFlag(kFixBoardId_LiquidCtrl);
// CAN_MASTER->clearResetFlag(kFixBoardId_PowerControl);
@ -137,7 +137,7 @@ void DeviceIoControlService::initialize() {
} catch (...) { \
}
int DeviceIoControlService::forceStopDeviceWithoutExc() {
if (PORT.isDT600B() || PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
TRY_DO(AddLiquidPump_stop());
TRY_DO(SprayPump_stop());
TRY_DO(Blower_close());
@ -155,7 +155,7 @@ int DeviceIoControlService::forceStopDeviceWithoutExc() {
int DeviceIoControlService::processHeartReportMsg(uint8_t from, report_heatpacket_data_t *report) {
// if (from < 100) {
logger->info(" REPORT [Heat ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{}", from, report->heartIndex, BoardTypeId2Str(report->boardType), report->flag);
logger->info(" REPORT [心跳 ][FROM:{}] HeatIndex:{:x} ToardType:{} flag:{}", from, report->heartIndex, BoardTypeId2Str(report->boardType), report->flag);
// }
// #define CHECK_BOARD_IS_REBOOT(boardid, ecode) \
// { \

4
appsrc/service/hardware/disinfectant_weight_update_service.cpp

@ -9,7 +9,7 @@ using namespace std;
void DisinfectantWeightUpdateService::initialize() { //
GET_TO_SERVICE(deviceIoControlService);
if (PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
updateThread.reset(new Thread("DisinfectantWeightUpdateService", [this]() { //
updateWeightThread();
}));
@ -40,7 +40,7 @@ float DisinfectantWeightUpdateService::getRoughWeight() {
void DisinfectantWeightUpdateService::updateWeightThread() {
while (true) {
if (PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
if (DS->isTestMode()) {
setNetWeight(1000);
}

57
appsrc/service/hardware/sensor_state_sync_service.cpp

@ -0,0 +1,57 @@
#include "sensor_state_sync_service.hpp"
using namespace iflytop;
using namespace std;
using namespace core;
void SensorStateSyncService::initialize() { GET_TO_SERVICE(deviceIoControlService); }
void SensorStateSyncService::startSync() {
if (updateThread && !updateThread->isWaitingForJoin()) {
logger->error("SensorStateSyncService update thread is already running");
exit(-1);
}
updateThread.reset(new Thread("SensorStateSyncServiceUpdateThread", [this]() { //
updateThreadLoop();
}));
}
void SensorStateSyncService::updateThreadLoop() {
ThisThread thisThread;
while (true) {
try {
float airCompressorCurrent = 0;
float blowerCurrent = 0;
float heaterCurrent = 0;
float heaterTemperature = 0;
if (PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W() || PORT.isDT600B()) {
airCompressorCurrent = deviceIoControlService->AC_readEI();
thisThread.sleepForMs(10);
blowerCurrent = deviceIoControlService->Blower_readEI();
thisThread.sleepForMs(10);
heaterCurrent = deviceIoControlService->Heater_readEI();
thisThread.sleepForMs(10);
heaterTemperature = deviceIoControlService->Heater_readTemperature();
thisThread.sleepForMs(10);
}
{
lock_guard<recursive_mutex> lock(m_mutex);
m_airCompressorCurrent = airCompressorCurrent;
m_blowerCurrent = blowerCurrent;
m_heaterCurrent = heaterCurrent;
m_heaterTemperature = heaterTemperature;
}
} catch (const appexception& e) {
logger->error("SensorStateSyncService update thread error: {}", e.what());
triggerError = true;
}
if (triggerError) {
thisThread.sleepForMs(20 * 1000);
} else {
thisThread.sleepForMs(1 * 1000);
}
}
}

79
appsrc/service/hardware/sensor_state_sync_service.hpp

@ -0,0 +1,79 @@
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
//
#include "baseservice/baseservice.hpp"
#include "device_io_ctrl_service.hpp"
//
#include "base/can_packet_dumper.hpp"
#include "base/h2o2_sensor_data_mgr.hpp"
//
#include "appcomponents/algo/moving_average_filter.hpp"
/**
* @brief
*
* service: SensorStateSyncService
*
* :
* :
* :
* :
*
*/
namespace iflytop {
using namespace std;
using namespace core;
class SensorStateSyncService : public enable_shared_from_this<SensorStateSyncService> {
THISCLASS(SensorStateSyncService);
unique_ptr<Thread> updateThread;
shared_ptr<DeviceIoControlService> deviceIoControlService;
shared_ptr<H2O2SensorDataMgr> h2o2SensorDataMgr;
float m_airCompressorCurrent = 0;
float m_blowerCurrent = 0;
float m_heaterCurrent = 0;
float m_heaterTemperature = 0;
recursive_mutex m_mutex;
bool triggerError = false;
public:
void initialize();
void startSync();
float getAirCompressorCurrent() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_airCompressorCurrent;
}
float getBlowerCurrent() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_blowerCurrent;
}
float getHeaterCurrent() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_heaterCurrent;
}
float getHeaterTemperature() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_heaterTemperature;
}
public:
void updateThreadLoop();
};
}; // namespace iflytop

4
appsrc/service/hardware/warning_light_controler.cpp

@ -50,7 +50,7 @@ void WarningLightControler::initialize() {
}
void WarningLightControler::beepCtrl(lightState_t state) {
if (PORT.isDT600B() || PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
switch (state) {
case kstate_warning:
m_beepState = !m_beepState;
@ -64,7 +64,7 @@ void WarningLightControler::beepCtrl(lightState_t state) {
void WarningLightControler::changeLightState(lightState_t state) {
m_nowState = state;
if (PORT.isDT600B() || PORT.isLageSpaceDM() || PORT.isDT300N() || PORT.isDT300W()) {
if (PORT.isDT600B() || PORT.isDT600N() || PORT.isDT300N() || PORT.isDT300W()) {
switch (m_nowState) {
case kstate_idle:
// 绿色

114
appsrc/service/test_page_ctrl_service.cpp

@ -0,0 +1,114 @@
#include "test_page_ctrl_service.hpp"
#include "appdep/components/ziconv.hpp"
using namespace iflytop;
using namespace testpage;
/**
* @brief
*
*
* WARNING:
* Date: 2024-12-05
*
*/
void TestPageCtrlService::initialize() {
REG_EXTFN(sprayPumpDoForward, void(int32_t), gpm);
REG_EXTFN(sprayPumpDoBackward, void(int32_t), gpm);
REG_EXTFN_VOID(sprayPumpDoStop, void());
REG_EXTFN_VOID(liquidFillingPumpDoLiquidFilling, void());
REG_EXTFN_VOID(liquidFillingPumpDoLiquidDischarge, void());
REG_EXTFN_VOID(liquidFillingPumpDoStop, void());
REG_EXTFN_VOID(airCompressorDoOpen, void());
REG_EXTFN_VOID(airCompressorDoClose, void());
REG_EXTFN_VOID(blowerDoOpen, void());
REG_EXTFN_VOID(blowerDoClose, void());
REG_EXTFN_VOID(heatingDoOpen, void());
REG_EXTFN_VOID(heatingDoClose, void());
REG_EXTFN_VOID(printerDoTest, void());
REG_EXTFN(airLeakDetectTestModeDoSetMode, void(string mode), mode);
REG_FN_VOID(readState, void());
m_thread.reset(new Thread("TestPageCtrlServiceReportThread", [this]() {
while (!ThisThread().getExitFlag()) {
ThisThread().sleepForMs(1000);
SEND_CLASS_REPORT(thisClass.className, "readState", readState());
}
}));
}
void TestPageCtrlService::sprayPumpDoForward(shared_ptr<MsgProcessContext> cxt, int32_t gpm) {
logger->info("sprayPumpDoForward gpm: {}", gpm);
deviceIoControlService->SprayPump_start(gpm);
}
void TestPageCtrlService::sprayPumpDoBackward(shared_ptr<MsgProcessContext> cxt, int32_t gpm) {
logger->info("sprayPumpDoBackward gpm: {}", gpm);
deviceIoControlService->SprayPump_start(-gpm);
}
void TestPageCtrlService::sprayPumpDoStop(shared_ptr<MsgProcessContext> cxt) {
logger->info("sprayPumpDoStop");
deviceIoControlService->SprayPump_stop();
}
void TestPageCtrlService::liquidFillingPumpDoLiquidFilling(shared_ptr<MsgProcessContext> cxt) {
deviceIoControlService->setAddFluidChannelSelectorValve(true);
deviceIoControlService->AddLiquidPump_stop();
usleep(500 * 1000);
deviceIoControlService->AddLiquidPump_addLiquid();
}
void TestPageCtrlService::liquidFillingPumpDoLiquidDischarge(shared_ptr<MsgProcessContext> cxt) {
deviceIoControlService->setAddFluidChannelSelectorValve(true);
deviceIoControlService->AddLiquidPump_stop();
usleep(500 * 1000);
deviceIoControlService->AddLiquidPump_drainLiquid();
}
void TestPageCtrlService::liquidFillingPumpDoStop(shared_ptr<MsgProcessContext> cxt) {
deviceIoControlService->AddLiquidPump_stop();
usleep(1500 * 1000);
deviceIoControlService->setAddFluidChannelSelectorValve(false);
}
void TestPageCtrlService::airCompressorDoOpen(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->AC_ctrl(1); }
void TestPageCtrlService::airCompressorDoClose(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->AC_ctrl(0); }
void TestPageCtrlService::blowerDoOpen(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->Blower_ctrl(90); }
void TestPageCtrlService::blowerDoClose(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->Blower_close(); }
void TestPageCtrlService::heatingDoOpen(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->Heater_ctrl(1); }
void TestPageCtrlService::heatingDoClose(shared_ptr<MsgProcessContext> cxt) { deviceIoControlService->Heater_ctrl(0); }
void TestPageCtrlService::printerDoTest(shared_ptr<MsgProcessContext> cxt) {
GET_SERVICE(UartPrinter)->print("abcdefghijklmn\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("opqrstuvwxyz\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("1234567890\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print(ZIconv::utf8_to_gb2312("打印机中文测试\n"));
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
}
void TestPageCtrlService::airLeakDetectTestModeDoSetMode(shared_ptr<MsgProcessContext> cxt, string mode) {
logger->info("airLeakDetectTestModeDoSetMode mode: {}", mode);
if (mode == "disinfection") { // 消毒模式
deviceIoControlService->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_disinfection});
} else if (mode == "inflation") { // 充气模式
deviceIoControlService->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_inflation});
} else if (mode == "leakTest") { // 漏气检测模式
deviceIoControlService->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_leakTest});
}
}
json TestPageCtrlService::readState() {
json state;
state["airCompressorCurrent"] = sensorStateSyncService->getAirCompressorCurrent();
state["blowerCurrent"] = sensorStateSyncService->getBlowerCurrent();
state["heaterCurrent"] = sensorStateSyncService->getHeaterCurrent();
state["heaterTemperature"] = sensorStateSyncService->getHeaterTemperature();
return state;
}

67
appsrc/service/test_page_ctrl_service.hpp

@ -0,0 +1,67 @@
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
//
#include "appbase/appbean/test_page_iterm.hpp"
#include "baseservice/baseservice.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
#include "service/hardware/sensor_state_sync_service.hpp"
#include "testpage/test_page_processer.hpp"
namespace iflytop {
using namespace testpage;
/**
* @brief
*
*
* WARNING:
* Date: 2024-12-05
*
*/
class TestPageCtrlService : public enable_shared_from_this<TestPageCtrlService> {
THISCLASS(TestPageCtrlService);
SERVICE(SensorStateSyncService, sensorStateSyncService);
SERVICE(DeviceStateService, deviceStateService);
SERVICE(DeviceIoControlService, deviceIoControlService);
unique_ptr<Thread> m_thread;
public:
void initialize();
private:
void sprayPumpDoForward(shared_ptr<MsgProcessContext> cxt, int32_t gpm);
void sprayPumpDoBackward(shared_ptr<MsgProcessContext> cxt, int32_t gpm);
void sprayPumpDoStop(shared_ptr<MsgProcessContext> cxt);
void liquidFillingPumpDoLiquidFilling(shared_ptr<MsgProcessContext> cxt);
void liquidFillingPumpDoLiquidDischarge(shared_ptr<MsgProcessContext> cxt);
void liquidFillingPumpDoStop(shared_ptr<MsgProcessContext> cxt);
void airCompressorDoOpen(shared_ptr<MsgProcessContext> cxt);
void airCompressorDoClose(shared_ptr<MsgProcessContext> cxt);
void blowerDoOpen(shared_ptr<MsgProcessContext> cxt);
void blowerDoClose(shared_ptr<MsgProcessContext> cxt);
void heatingDoOpen(shared_ptr<MsgProcessContext> cxt);
void heatingDoClose(shared_ptr<MsgProcessContext> cxt);
void printerDoTest(shared_ptr<MsgProcessContext> cxt);
void airLeakDetectTestModeDoSetMode(shared_ptr<MsgProcessContext> cxt, string mode);
private:
json readState();
};
} // namespace iflytop

267
appsrc/service/test_page_mgr_service.cpp

@ -1,267 +0,0 @@
#include "test_page_mgr_service.hpp"
#include "appdep/components/ziconv.hpp"
using namespace iflytop;
using namespace testpage;
/**
* @brief
*
*
* WARNING:
* Date: 2024-12-05
*
*/
void TestPageMgrService::getTestPageCfgInfo(shared_ptr<MsgProcessContext> cxt) { cxt->rely["items"] = m_testPageItemMgr.getPageCfgInfo(); }
void TestPageMgrService::onButton(shared_ptr<MsgProcessContext> cxt, string groupName, string buttonName, json params) { m_testPageItemMgr.processOnButton(groupName, buttonName, params); }
void TestPageMgrService::readState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = m_testPageItemMgr.readState(); }
void TestPageMgrService::startReportState(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.startReportState(1000); }
void TestPageMgrService::stopReportState(shared_ptr<MsgProcessContext> cxt) { m_testPageItemMgr.stopReportState(); }
int TestPageMgrService::PrinterTest_test() {
GET_SERVICE(UartPrinter)->print("abcdefghijklmn\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("opqrstuvwxyz\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("1234567890\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print(ZIconv::utf8_to_gb2312("打印机中文测试\n"));
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
return 0;
}
void TestPageMgrService::initialize() {
GET_TO_SERVICE(m_ds);
GET_TO_SERVICE(dcs);
REG_EXTFN_VOID(getTestPageCfgInfo, void());
REG_EXTFN(onButton, void(string, string, json), goupName, buttonName, params);
REG_EXTFN_VOID(readState, void());
REG_EXTFN_VOID(startReportState, void());
REG_EXTFN_VOID(stopReportState, void());
REG_FN_VOID(PrinterTest_test, void());
auto SprayPumpCtrl = m_testPageItemMgr.createButtons({"SprayPumpCtrl", "喷液泵控制"}, // 模组名
{
// 参数
{{"pumpVel", "速度"}, "g/min", {{"5"}, {"10"}, {"15"}}}, //
},
{
// 按键
{"forward", "正转"},
{"backward", "反转"},
{"stop", "停止"},
},
[this](string buttonName, vector<string> param) { //
logger->info("SprayPumpCtrl on button.{} ({})", buttonName, param[0]);
if (buttonName == "forward") {
dcs->SprayPump_start(atoi(param[0].c_str()));
} else if (buttonName == "backward") {
dcs->SprayPump_start(-atoi(param[0].c_str()));
} else if (buttonName == "stop") {
dcs->SprayPump_stop();
}
});
auto AddDischargePumpCtrl = m_testPageItemMgr.createButtons({"AddDischargePumpCtrl", "加液泵控制"}, // 模组名
{
// 参数
},
{
// 按键
{"addingLiquid", "加液"},
{"drainLiquid", "排液"},
{"stop", "停止"},
},
[this](string buttonName, vector<string> param) { //
logger->info("on AddDischargePumpCtrl.{}", buttonName);
if (buttonName == "addingLiquid") {
dcs->setAddFluidChannelSelectorValve(true);
dcs->AddLiquidPump_stop();
usleep(500 * 1000);
dcs->AddLiquidPump_addLiquid();
} else if (buttonName == "drainLiquid") {
dcs->setAddFluidChannelSelectorValve(true);
dcs->AddLiquidPump_stop();
usleep(500 * 1000);
dcs->AddLiquidPump_drainLiquid();
} else {
dcs->AddLiquidPump_stop();
usleep(1500 * 1000);
dcs->setAddFluidChannelSelectorValve(false);
}
});
auto AirCompressorCtrl = m_testPageItemMgr.createButtons({"AirCompressorCtrl", "空压机控制"}, // 模组名
{
// 参数
},
{
// 按键
{"on", "打开"},
{"off", "关闭"},
},
[this](string buttonName, vector<string> param) { //
logger->info("on AirCompressorCtrl.{}", buttonName);
if (buttonName == "on") {
dcs->AC_ctrl(1);
} else if (buttonName == "off") {
dcs->AC_close();
}
});
auto ACState = m_testPageItemMgr.createStates({"ACState", "空压机状态"}, {{"current", "电流"}}, [this](string stateName) { //
return fmt::format("{:.2f}A", dcs->AC_readEI());
});
auto BlowerCtrl = m_testPageItemMgr.createButtons({"BlowerCtrl", "风机控制"}, // 模组名
{
// 参数
},
{
// 按键
{"on", "打开"},
{"off", "关闭"},
},
[this](string buttonName, vector<string> param) { //
logger->info("on BlowerCtrl.{}", buttonName);
if (buttonName == "on") {
dcs->Blower_ctrl(90);
} else if (buttonName == "off") {
dcs->Blower_close();
}
});
auto Blower = m_testPageItemMgr.createStates({"Blower", "风机状态"}, {{"current", "电流"}}, [this](string stateName) { //
return fmt::format("{:.2f}A", dcs->Blower_readEI());
});
auto HeatingCtrl = m_testPageItemMgr.createButtons({"HeatingCtrl", "加热片控制"}, // 模组名
{
// 参数
},
{
// 按键
{"on", "打开"},
{"off", "关闭"},
},
[this](string buttonName, vector<string> param) { //
logger->info("on HeatingCtrl.{}", buttonName);
if (buttonName == "on") {
dcs->Heater_ctrl(1);
} else if (buttonName == "off") {
dcs->Heater_close();
}
});
auto HeatingState = m_testPageItemMgr.createStates({"HeatingState", "加热片状态"}, {{"temperature", "温度"}, {"current", "电流"}}, [this](string stateName) { //
if (stateName == "temperature") {
return fmt::format("{:.2f}℃", dcs->Heater_readTemperature());
} else if (stateName == "current") {
return fmt::format("{:.2f}A", dcs->Heater_readEI());
}
return string("error");
});
// 9
auto PrinterTest = m_testPageItemMgr.createButtons({"PrinterTest", "打印机测试"}, // 模组名
{
// 参数
},
{
// 按键
{"test", "测试"},
},
[this](string buttonName, vector<string> param) { PrinterTest_test(); });
// 10
/*******************************************************************************
* *
*******************************************************************************/
auto AirLeakDetectTestModeCtrl = m_testPageItemMgr.createButtons({"AirLeakDetectTestModeCtrl", "气密性检测通道控制"}, // 模组名
{
// 参数
},
{
// 按键
{"disinfection", "正常模式"},
{"inflation", "充气模式"},
{"leakTest", "漏气检测模式"},
},
[this](string buttonName, vector<string> param) { //
logger->info("AirLeakDetectTestModeCtrl buttonName:{} param:{}", buttonName, param);
if (buttonName == "disinfection") {
dcs->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_disinfection});
} else if (buttonName == "inflation") {
dcs->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_inflation});
} else if (buttonName == "leakTest") {
dcs->AirLeakDetectTestModeCtrl_setMode({kAirLeakTestMode_leakTest});
}
});
auto PosiPressurePropCtrl = m_testPageItemMgr.createButtons({"PosiPressurePropCtrl", "正压比例阀控制"}, // 模组名
{
// 参数
{{"pumpVel", "百分比"}, "%", {{"0"}, {"10"}, {"20"}, {"30"}, {"40"}, {"50"}, {"60"}, {"70"}, {"80"}, {"90"}, {"100"}}}, //
},
{
// 按键
{"set", "设置"},
{"close", "关闭"},
},
[this](string buttonName, vector<string> param) { //
logger->info("PosiPressurePropCtrl buttonName:{} params:{}", buttonName, param);
if (buttonName == "set") {
dcs->PosiPressureProp_setValve(atoi(param[0].c_str()));
} else if (buttonName == "close") {
dcs->PosiPressureProp_setValve(0);
}
});
auto NegaPressurePropCtrl = m_testPageItemMgr.createButtons({"NegaPressurePropCtrl", "负压比例阀控制"}, // 模组名
{
// 参数
{{"pumpVel", "百分比"}, "%", {{"0"}, {"10"}, {"20"}, {"30"}, {"40"}, {"50"}, {"60"}, {"70"}, {"80"}, {"90"}, {"100"}}}, //
},
{
// 按键
{"set", "设置"},
{"close", "关闭"},
},
[this](string buttonName, vector<string> param) { //
logger->info("NegaPressurePropCtrl buttonName:{} params:{}", buttonName, param);
if (buttonName == "set") {
dcs->NegaPressureProp_setValve(atoi(param[0].c_str()));
} else if (buttonName == "close") {
dcs->NegaPressureProp_setValve(0);
}
});
m_testPageItemMgr.insert(SprayPumpCtrl); // 1
m_testPageItemMgr.insert(AddDischargePumpCtrl); // 2
m_testPageItemMgr.insert(AirCompressorCtrl); // 3
m_testPageItemMgr.insert(ACState); // 4
m_testPageItemMgr.insert(BlowerCtrl); // 5
m_testPageItemMgr.insert(Blower); // 6
m_testPageItemMgr.insert(HeatingCtrl); // 7
m_testPageItemMgr.insert(HeatingState); // 8
m_testPageItemMgr.insert(PrinterTest); // 9
m_testPageItemMgr.insert(make_shared<PlaceHolder>()); // 10
if (PORT.isDT300W()) {
m_testPageItemMgr.insert(AirLeakDetectTestModeCtrl); // 11
m_testPageItemMgr.insert(PosiPressurePropCtrl); // 12
m_testPageItemMgr.insert(NegaPressurePropCtrl); // 13
}
m_testPageItemMgr.onState.connect([this](json state) { //
GET_SERVICE(IflytopFrontEndService)->sendClassReport(thisClass.className, "onState", state);
});
}

57
appsrc/service/test_page_mgr_service.hpp

@ -1,57 +0,0 @@
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
//
#include "appbase/appbean/test_page_iterm.hpp"
#include "baseservice/baseservice.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
#include "testpage/test_page_processer.hpp"
namespace iflytop {
using namespace testpage;
/**
* @brief
*
*
* WARNING:
* Date: 2024-12-05
*
*/
class TestPageMgrService : public enable_shared_from_this<TestPageMgrService> {
THISCLASS(TestPageMgrService);
shared_ptr<DeviceStateService> m_ds;
shared_ptr<DeviceIoControlService> dcs;
unique_ptr<Thread> m_thread;
TestPageItemMgr m_testPageItemMgr;
public:
void initialize();
private:
void getTestPageCfgInfo(shared_ptr<MsgProcessContext> cxt);
void onButton(shared_ptr<MsgProcessContext> cxt, string groupName, string buttonName, json params);
void readState(shared_ptr<MsgProcessContext> cxt);
void startReportState(shared_ptr<MsgProcessContext> cxt);
void stopReportState(shared_ptr<MsgProcessContext> cxt);
private:
int PrinterTest_test();
};
} // namespace iflytop

60
appsrc/service/test_page_service_v2.cpp

@ -1,60 +0,0 @@
#include "test_page_service_v2.hpp"
#include "appdep/components/ziconv.hpp"
using namespace iflytop;
using namespace testpage;
void TestPageServiceV2::initialize() {
GET_TO_SERVICE(m_ds);
GET_TO_SERVICE(dcs);
// REG_EXTFN_VOID(getSetting, json(void)); // 单位g
// REG_EXTFN(setDeviceId, void(string));
REG_EXTFN(doSprayPumpFroward, void(int), gpm);
REG_EXTFN(doSprayPumpBackward, void(int), gpm);
REG_EXTFN_VOID(doSprayPumpStop, void(void));
REG_EXTFN_VOID(doAddLiquid, void(void));
REG_EXTFN_VOID(doDrainLiquid, void(void));
REG_EXTFN_VOID(doStopAddLiquid, void(void));
REG_EXTFN_VOID(doPrinterTest, void(void));
}
void TestPageServiceV2::doSprayPumpFroward(shared_ptr<MsgProcessContext> cxt, int gpm) { dcs->SprayPump_start(gpm); }
void TestPageServiceV2::doSprayPumpBackward(shared_ptr<MsgProcessContext> cxt, int gpm) { dcs->SprayPump_start(-gpm); }
void TestPageServiceV2::doSprayPumpStop(shared_ptr<MsgProcessContext> cxt) { dcs->SprayPump_stop(); }
void TestPageServiceV2::doAddLiquid(shared_ptr<MsgProcessContext> cxt) {
dcs->setAddFluidChannelSelectorValve(true);
dcs->AddLiquidPump_stop();
usleep(500 * 1000);
dcs->AddLiquidPump_addLiquid();
}
void TestPageServiceV2::doDrainLiquid(shared_ptr<MsgProcessContext> cxt) {
dcs->setAddFluidChannelSelectorValve(true);
dcs->AddLiquidPump_stop();
usleep(500 * 1000);
dcs->AddLiquidPump_drainLiquid();
}
void TestPageServiceV2::doStopAddLiquid(shared_ptr<MsgProcessContext> cxt) {
dcs->AddLiquidPump_stop();
usleep(1500 * 1000);
dcs->setAddFluidChannelSelectorValve(false);
}
int TestPageServiceV2::doPrinterTest(shared_ptr<MsgProcessContext> cxt) {
GET_SERVICE(UartPrinter)->print("abcdefghijklmn\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("opqrstuvwxyz\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("1234567890\n");
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print(ZIconv::utf8_to_gb2312("打印机中文测试\n"));
usleep(100 * 1000);
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
GET_SERVICE(UartPrinter)->print("\n");
return 0;
}

54
appsrc/service/test_page_service_v2.hpp

@ -1,54 +0,0 @@
#pragma once
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <vector>
//
#include "appbase/appbean/test_page_iterm.hpp"
#include "baseservice/baseservice.hpp"
#include "service/hardware/device_io_ctrl_service.hpp"
#include "testpage/test_page_processer.hpp"
namespace iflytop {
using namespace testpage;
/**
* @brief
*
*
* WARNING:
* Date: 2024-12-05
*
*/
class TestPageServiceV2 : public enable_shared_from_this<TestPageServiceV2> {
THISCLASS(TestPageServiceV2);
shared_ptr<DeviceStateService> m_ds;
shared_ptr<DeviceIoControlService> dcs;
unique_ptr<Thread> m_thread;
TestPageItemMgr m_testPageItemMgr;
public:
void initialize();
private:
int doPrinterTest(shared_ptr<MsgProcessContext> cxt);
void doSprayPumpFroward(shared_ptr<MsgProcessContext> cxt, int gpm);
void doSprayPumpBackward(shared_ptr<MsgProcessContext> cxt, int gpm);
void doSprayPumpStop(shared_ptr<MsgProcessContext> cxt);
void doAddLiquid(shared_ptr<MsgProcessContext> cxt);
void doDrainLiquid(shared_ptr<MsgProcessContext> cxt);
void doStopAddLiquid(shared_ptr<MsgProcessContext> cxt);
};
} // namespace iflytop
Loading…
Cancel
Save