Browse Source

Merge branch 'master' into try_support_dt100n

try_support_dt100n
zhaohe 4 weeks ago
parent
commit
1e8c9924d5
  1. 4
      appsrc/appbase/appbean/setting_id.hpp
  2. 2
      appsrc/appconfig/basic/zappversion.hpp
  3. 10
      appsrc/baseservice/db/calibrate_info_dao.hpp
  4. 38
      appsrc/baseservice/db/setting_db_dao.cpp
  5. 34
      appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.cpp
  6. 10
      appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp
  7. 22
      appsrc/service/app/disinfection_ctrl_service_ext.cpp
  8. 8
      appsrc/service/app/disinfection_ctrl_service_ext.hpp
  9. 13
      appsrc/service/os_mgr_service.cpp

4
appsrc/appbase/appbean/setting_id.hpp

@ -7,12 +7,12 @@
marco(type, continued_gs) /**/ \ marco(type, continued_gs) /**/ \
marco(type, stoped_satur) /**/ \ marco(type, stoped_satur) /**/ \
marco(type, continued_satur) /**/ \ marco(type, continued_satur) /**/ \
marco(type, stoped_humi) /**/ \
marco(type, continued_humi) /**/ \
marco(type, max_humidity) /**/ \ marco(type, max_humidity) /**/ \
marco(type, drainage_pump_speed) /**/ \ marco(type, drainage_pump_speed) /**/ \
marco(type, injection_pump_speed) /**/ \ marco(type, injection_pump_speed) /**/ \
marco(type, pre_heat_time_s) /**/ \ marco(type, pre_heat_time_s) /**/ \
marco(type, stoped_humi) /**/ \
marco(type, continued_humi) /**/ \
marco(type, record_period_min) /**/ \ marco(type, record_period_min) /**/ \
marco(type, record_printer_period_min) /**/ \ marco(type, record_printer_period_min) /**/ \
marco(type, loglevel) /*消毒等级*/ \ marco(type, loglevel) /*消毒等级*/ \

2
appsrc/appconfig/basic/zappversion.hpp

@ -1,3 +1,3 @@
#pragma once #pragma once
#define VERSION "3.0.4"
#define VERSION "3.0.7"
#define PROJECT_NAME "TRANSMIT_DM" #define PROJECT_NAME "TRANSMIT_DM"

10
appsrc/baseservice/db/calibrate_info_dao.hpp

@ -35,7 +35,7 @@ using namespace nlohmann;
namespace db { namespace db {
typedef struct { typedef struct {
int id;
int id;
float h2O2LiquidWeightSensorZeroBias; // H2O2液体重量传感器零点偏差 float h2O2LiquidWeightSensorZeroBias; // H2O2液体重量传感器零点偏差
} CalibrationInfo; } CalibrationInfo;
} // namespace db } // namespace db
@ -62,8 +62,12 @@ class CalibrationInfoDao : public KeyValDBV2Dao {
CalibrationInfo getCalibrationInfo(); CalibrationInfo getCalibrationInfo();
json getCalibrationInfoJson(); json getCalibrationInfoJson();
void setH2O2LiquidWeightSensorZeroBias(float bias);
float getH2O2LiquidWeightSensorZeroBias();
void setH2O2LiquidWeightSensorZeroBias(float bias);
float getH2O2LiquidWeightSensorZeroBias();
private: private:
void initialize(); void initialize();

38
appsrc/baseservice/db/setting_db_dao.cpp

@ -55,25 +55,25 @@ using namespace iflytop;
using namespace db; using namespace db;
static Setting settingInitTable[] = { static Setting settingInitTable[] = {
{.setting_id = SettingId::kstoped_gs},
{.setting_id = SettingId::kcontinued_gs},
{.setting_id = SettingId::kstoped_satur},
{.setting_id = SettingId::kcontinued_satur},
{.setting_id = SettingId::kmax_humidity},
{.setting_id = SettingId::kdrainage_pump_speed},
{.setting_id = SettingId::kinjection_pump_speed},
{.setting_id = SettingId::kpre_heat_time_s},
{.setting_id = SettingId::kstoped_humi},
{.setting_id = SettingId::kcontinued_humi},
{.setting_id = SettingId::krecord_period_min},
{.setting_id = SettingId::krecord_printer_period_min},
{.setting_id = SettingId::kloglevel},
{.setting_id = SettingId::kenable_bd_dehumidify},
{.setting_id = SettingId::kbd_dehumidify_threshold},
{.setting_id = SettingId::kenable_ad_dehumidify},
{.setting_id = SettingId::kad_dehumidify_threshold},
{.setting_id = SettingId::kenable_ad_degrade},
{.setting_id = SettingId::kad_degrade_threshold},
{.setting_id = SettingId::stoped_gs},
{.setting_id = SettingId::continued_gs},
{.setting_id = SettingId::stoped_satur},
{.setting_id = SettingId::continued_satur},
{.setting_id = SettingId::stoped_humi},
{.setting_id = SettingId::continued_humi},
{.setting_id = SettingId::max_humidity},
{.setting_id = SettingId::drainage_pump_speed},
{.setting_id = SettingId::injection_pump_speed},
{.setting_id = SettingId::pre_heat_time_s},
{.setting_id = SettingId::loglevel},
{.setting_id = SettingId::record_period_min},
{.setting_id = SettingId::record_printer_period_min},
{.setting_id = SettingId::enable_bd_dehumidify},
{.setting_id = SettingId::bd_dehumidify_threshold},
{.setting_id = SettingId::enable_ad_dehumidify},
{.setting_id = SettingId::ad_dehumidify_threshold},
{.setting_id = SettingId::enable_ad_degrade},
{.setting_id = SettingId::ad_degrade_threshold},
{.setting_id = SettingId::dvalue_correct_coefficient}, {.setting_id = SettingId::dvalue_correct_coefficient},
}; };

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

@ -214,7 +214,7 @@ void DisinfectionCtrlService::checkBeforeStart() {
void DisinfectionCtrlService::startWorkThread() { void DisinfectionCtrlService::startWorkThread() {
resetState(); resetState();
handlePumpStopFlag = false;
m_thread.reset(new Thread("DisinfectionStateMachineThread", [this]() { m_thread.reset(new Thread("DisinfectionStateMachineThread", [this]() {
DS->setDeviceState(DeviceState::Disinfection); DS->setDeviceState(DeviceState::Disinfection);
logger->info("DisinfectionStateMachineThread start"); logger->info("DisinfectionStateMachineThread start");
@ -550,8 +550,10 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event)
} else { } else {
if (isTimeToResumeDisinfection()) { if (isTimeToResumeDisinfection()) {
logger->info("resumeDisinfection"); logger->info("resumeDisinfection");
dics->AC_ctrl(1);
dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed));
if (!handlePumpStopFlag) {
dics->AC_ctrl(1);
dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed));
}
s_isDisinfectionTakeBreak = false; s_isDisinfectionTakeBreak = false;
tryLogState(true); tryLogState(true);
} }
@ -596,11 +598,35 @@ void DisinfectionCtrlService::processStateDisinfection(DisinfectionEvent* event)
// 检查是否消毒完成 // 检查是否消毒完成
} else if (event->event == kevent_update_cfg) { } else if (event->event == kevent_update_cfg) {
if (!s_isDisinfectionTakeBreak) {
if (!s_isDisinfectionTakeBreak && !handlePumpStopFlag) {
dics->AC_ctrl(1);
dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed)); dics->SprayPump_start(getSettingAsInt(SettingId::injection_pump_speed));
} }
if (handlePumpStopFlag) {
dics->SprayPump_stop();
dics->AC_close();
}
} }
} }
// void DisinfectionCtrlService::setHandleStopPumpInjectionFlag() {
// handlePumpStopFlag = true;
// updateCfg();
// }
// void DisinfectionCtrlService::clearHandleStopPumpInjectionFlag() {
// handlePumpStopFlag = false;
// updateCfg();
// }
void DisinfectionCtrlService::handleStopPumpInjection() {
handlePumpStopFlag = true;
updateCfg();
}
void DisinfectionCtrlService::handleStartPumpInjection() {
handlePumpStopFlag = false;
updateCfg();
}
void DisinfectionCtrlService::processStateEmpytLiquidFromTheLine(DisinfectionEvent* event) { void DisinfectionCtrlService::processStateEmpytLiquidFromTheLine(DisinfectionEvent* event) {
if (event->event == kevent_enter_state) { if (event->event == kevent_enter_state) {
tryLogState(true); tryLogState(true);

10
appsrc/service/app/disinfection_ctrl/disinfection_ctrl_service.hpp

@ -61,6 +61,8 @@ class DisinfectionCtrlService : public enable_shared_from_this<DisinfectionCtrlS
int s_afterDisinfectantVolume_g = {}; // 消毒后消毒剂量 int s_afterDisinfectantVolume_g = {}; // 消毒后消毒剂量
int s_disinfectantVolumeLevel = {}; // 消毒液位级别 int s_disinfectantVolumeLevel = {}; // 消毒液位级别
bool handlePumpStopFlag = false; //
public: public:
void initialize(); void initialize();
@ -88,6 +90,14 @@ class DisinfectionCtrlService : public enable_shared_from_this<DisinfectionCtrlS
void getStateSafeBlock(function<void()> syncState) { sm.getStateSafeBlock(syncState); } void getStateSafeBlock(function<void()> syncState) { sm.getStateSafeBlock(syncState); }
// void clearHandleStopPumpInjectionFlag();
// void setHandleStopPumpInjectionFlag();
void handleStopPumpInjection();
void handleStartPumpInjection();
bool getHandlePumpStopFlag() { return handlePumpStopFlag; }
map<string, string>& getRealtimeCfg() { return m_realtimeCfg; } map<string, string>& getRealtimeCfg() { return m_realtimeCfg; }
DisinfectionState getState() { return sm.getState(); } DisinfectionState getState() { return sm.getState(); }
int getCurStateRemainTimeS() { return s_remaintime; } int getCurStateRemainTimeS() { return s_remaintime; }

22
appsrc/service/app/disinfection_ctrl_service_ext.cpp

@ -52,6 +52,11 @@ void DisinfectionCtrlServiceExt::initialize() {
REG_EXTFN_VOID(getServiceConfig, void()); REG_EXTFN_VOID(getServiceConfig, void());
REG_EXTFN_VOID(startStateReport, void()); REG_EXTFN_VOID(startStateReport, void());
REG_EXTFN_VOID(stopStateReport, void()); REG_EXTFN_VOID(stopStateReport, void());
REG_EXTFN_VOID(handleStopPumpInjection, void());
REG_EXTFN_VOID(handleStartPumpInjection, void());
REG_EXTFN_VOID(setHandleStopPumpInjectionFlag, void());
REG_EXTFN_VOID(clearHandleStopPumpInjectionFlag, void());
stateUpdateThread.reset(new Thread("DisinfectionCtrlServiceExt-stateUpdateThread", [this]() { stateUpdateThread.reset(new Thread("DisinfectionCtrlServiceExt-stateUpdateThread", [this]() {
ThisThread thisThread; ThisThread thisThread;
@ -109,7 +114,23 @@ void DisinfectionCtrlServiceExt::setRealtimeConfig(shared_ptr<MsgProcessContext>
dcs->getRealtimeCfg()[key] = val; dcs->getRealtimeCfg()[key] = val;
dcs->updateCfg(); dcs->updateCfg();
} }
void DisinfectionCtrlServiceExt::handleStopPumpInjection(shared_ptr<MsgProcessContext> cxt) {
dcs->handleStopPumpInjection();
if (stateUpdateThread) stateUpdateThread->wake();
}
void DisinfectionCtrlServiceExt::handleStartPumpInjection(shared_ptr<MsgProcessContext> cxt) {
dcs->handleStartPumpInjection();
if (stateUpdateThread) stateUpdateThread->wake();
}
void DisinfectionCtrlServiceExt::clearHandleStopPumpInjectionFlag(shared_ptr<MsgProcessContext> cxt) {
dcs->handleStopPumpInjection();
if (stateUpdateThread) stateUpdateThread->wake();
}
void DisinfectionCtrlServiceExt::setHandleStopPumpInjectionFlag(shared_ptr<MsgProcessContext> cxt) {
dcs->handleStartPumpInjection();
if (stateUpdateThread) stateUpdateThread->wake();
}
void DisinfectionCtrlServiceExt::getState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = getState(); } void DisinfectionCtrlServiceExt::getState(shared_ptr<MsgProcessContext> cxt) { cxt->rely = getState(); }
json DisinfectionCtrlServiceExt::getState() { json DisinfectionCtrlServiceExt::getState() {
json rely; json rely;
@ -123,6 +144,7 @@ json DisinfectionCtrlServiceExt::getState() {
rely["injectedVelocity"] = dcs->getInjectedVelocity(); rely["injectedVelocity"] = dcs->getInjectedVelocity();
rely["startTimestamp"] = dcs->getStartTP(); rely["startTimestamp"] = dcs->getStartTP();
rely["completeTimestamp"] = dcs->getCompleteTP(); rely["completeTimestamp"] = dcs->getCompleteTP();
rely["handlePumpStopFlag"] = dcs->getHandlePumpStopFlag();
}); });
return rely; return rely;
} }

8
appsrc/service/app/disinfection_ctrl_service_ext.hpp

@ -44,6 +44,12 @@ class DisinfectionCtrlServiceExt : public enable_shared_from_this<DisinfectionCt
void setRealtimeConfig(shared_ptr<MsgProcessContext> cxt, string key, string val); void setRealtimeConfig(shared_ptr<MsgProcessContext> cxt, string key, string val);
void updateTargetLogLevel(shared_ptr<MsgProcessContext> cxt, float loglevel); void updateTargetLogLevel(shared_ptr<MsgProcessContext> cxt, float loglevel);
void clearHandleStopPumpInjectionFlag(shared_ptr<MsgProcessContext> cxt);
void setHandleStopPumpInjectionFlag(shared_ptr<MsgProcessContext> cxt);
void handleStopPumpInjection(shared_ptr<MsgProcessContext> cxt);
void handleStartPumpInjection(shared_ptr<MsgProcessContext> cxt);
/******************************************************************************* /*******************************************************************************
* * * *
*******************************************************************************/ *******************************************************************************/
@ -55,7 +61,7 @@ class DisinfectionCtrlServiceExt : public enable_shared_from_this<DisinfectionCt
json getState(); json getState();
DisinfectionState getDisinfectionState() { return dcs->getState(); } DisinfectionState getDisinfectionState() { return dcs->getState(); }
int64_t getDisinfectionStartTP() { return dcs->getStartTP(); }
int64_t getDisinfectionStartTP() { return dcs->getStartTP(); }
}; };
} // namespace iflytop } // namespace iflytop

13
appsrc/service/os_mgr_service.cpp

@ -35,4 +35,15 @@ void OsMgrService::updateTime(shared_ptr<MsgProcessContext> cxt, int hour, int m
dosystem(fmt::format("hwclock -w").c_str()); dosystem(fmt::format("hwclock -w").c_str());
} }
void OsMgrService::getTime(shared_ptr<MsgProcessContext> cxt) { cxt->rely["time"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); }
void OsMgrService::getTime(shared_ptr<MsgProcessContext> cxt) {
// cxt->rely["time"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
struct timeval tv;
gettimeofday(&tv, NULL);
// 计算毫秒级 Unix 时间戳
// TODO: 修改成时区来自系统
long long timestamp_ms = (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
timestamp_ms += 8 * 3600 * 1000; // 转换为北京时间(UTC+8)
cxt->rely["time"] = timestamp_ms;
}
Loading…
Cancel
Save