Browse Source

update

storage-in-realtime
zhaohe 11 months ago
parent
commit
83ae23378a
  1. 8
      appsrc/service/disinfection_logs_service.cpp
  2. 14
      appsrc/service/disinfection_logs_service.hpp
  3. 6
      appsrc/service/os_mgr_service.cpp
  4. 3
      appsrc/service/os_mgr_service.hpp

8
appsrc/service/disinfection_logs_service.cpp

@ -170,7 +170,7 @@ void DisinfectionLogsService::initialize() {
REG_EXTFN(deleteReport, void(string), logName);
REG_EXTFN(exportRecord, void(vector<string>), logNames);
REG_EXTFN(printRecord, void(string), logName);
REG_EXTFN_VOID(selftest, void());
REG_EXTFN(createFakeData, void(bool), printInPrinter);
m_csvHeaderDict.insert(CSVHeader::time, "时间");
m_csvHeaderDict.insert(CSVHeader::state, "设备状态");
@ -261,7 +261,7 @@ void DisinfectionLogsService::onAppDisinfectionFinishedEvent(shared_ptr<Disinfec
* 1.
* 2.PDF文件缓存
*/
printRecordFile(m_sessionId);
if (printfLogWhenDisinfectionFinished) printRecordFile(m_sessionId);
}
/**
@ -627,7 +627,7 @@ chrono::system_clock::time_point time_point_increment(chrono::system_clock::time
return tp;
}
void DisinfectionLogsService::selftest(shared_ptr<MsgProcessContext> cxt) {
void DisinfectionLogsService::createFakeData(shared_ptr<MsgProcessContext> cxt, bool printInPrinter) {
string ssid = createDisinfectionID();
onAppDisinfectionStartEvent(ssid);
@ -661,7 +661,9 @@ void DisinfectionLogsService::selftest(shared_ptr<MsgProcessContext> cxt) {
statistics->tLog = 10;
statistics->finalLog = 9;
printfLogWhenDisinfectionFinished = false;
onAppDisinfectionFinishedEvent(statistics);
printfLogWhenDisinfectionFinished = true;
}
shared_ptr<DisinfectionStateSnapshot> DisinfectionLogsService::selftest_createFakeSnapshot(zsystem_tp time, DisinfectionState state, int sensorNum, bool forceLog) {

14
appsrc/service/disinfection_logs_service.hpp

@ -33,6 +33,8 @@ class DisinfectionLogsService : public enable_shared_from_this<DisinfectionLogsS
list<string> m_recordFiles;
bool printfLogWhenDisinfectionFinished = true;
public:
DisinfectionLogsService();
void initialize();
@ -53,10 +55,12 @@ class DisinfectionLogsService : public enable_shared_from_this<DisinfectionLogsS
*******************************************************************************/
void getRecordList(shared_ptr<MsgProcessContext> cxt);
void getRecord(shared_ptr<MsgProcessContext> cxt, string logName);
void deleteReport(shared_ptr<MsgProcessContext> cxt,string logName);
void exportRecord(shared_ptr<MsgProcessContext> cxt,vector<string> logNames);
void printRecord(shared_ptr<MsgProcessContext> cxt,string logName);
void selftest(shared_ptr<MsgProcessContext> cxt);
void deleteReport(shared_ptr<MsgProcessContext> cxt, string logName);
void exportRecord(shared_ptr<MsgProcessContext> cxt, vector<string> logNames);
void printRecord(shared_ptr<MsgProcessContext> cxt, string logName);
// void selftest(shared_ptr<MsgProcessContext> cxt);
void createFakeData(shared_ptr<MsgProcessContext> cxt, bool printInPrinter);
private:
int32_t exportDisinfectionData(vector<string> files);
@ -64,7 +68,7 @@ class DisinfectionLogsService : public enable_shared_from_this<DisinfectionLogsS
void deleteRecordFile(string file);
void printRecordFile(string file);
bool dosystem(string cmd);
bool dosystem(string cmd);
shared_ptr<DisinfectionStateSnapshot> selftest_createFakeSnapshot(zsystem_tp time, DisinfectionState state, int sensorNum, bool forceLog);
};

6
appsrc/service/os_mgr_service.cpp

@ -29,9 +29,13 @@ void OsMgrService::updateDate(shared_ptr<MsgProcessContext> cxt, int year, int m
dosystem(fmt::format("hwclock -w").c_str());
}
void OsMgrService::updateTime(shared_ptr<MsgProcessContext> cxt, int hour, int min, int second) {
logger->info("updateDate {}:{}:{}", hour, min, second);
// date -s "2023-01-02 02:32:32"
dosystem(fmt::format("date -s \"`date +%Y-%m-%d` {:02}:{:02}:{:02}\"", hour, min, second).c_str());
dosystem(fmt::format("hwclock -w").c_str());
}
void OsMgrService::getTime(shared_ptr<MsgProcessContext> cxt) {
// logger->info("getTime");
// dosystem("date");
}

3
appsrc/service/os_mgr_service.hpp

@ -25,7 +25,8 @@ class OsMgrService : public enable_shared_from_this<OsMgrService> {
private:
void shutdown(shared_ptr<MsgProcessContext> cxt);
void updateDate(shared_ptr<MsgProcessContext> cxt, int year, int month, int day);
void updateTime(shared_ptr<MsgProcessContext> cxt,int hour, int min, int second);
void updateTime(shared_ptr<MsgProcessContext> cxt, int hour, int min, int second);
void getTime(shared_ptr<MsgProcessContext> cxt);
void dosystem(string order) {
logger->info("do:{}", order);

Loading…
Cancel
Save