2024-05-11 17:43:38 +08:00

121 lines
2.4 KiB
C++

#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <codecvt>
#include <grpcpp/grpcpp.h>
#include "global.h"
#include "SystemInfo.h"
#include "Logger.h"
#include "Toast.h"
#include <map>
#include "LanguageManager.h"
#include "../DataManage/DataHandle.h"
string g_AppPath;
string g_AppDisk;
Logger* g_log;
LanguageManager* g_LngManager;
Toast* g_Toast;
bool g_isDebug;
uint32_t g_ScanSerial;
string g_gno;
SystemInfo* g_SystemInfo;
class HBDSystem {
public:
HBDSystem(){}
~HBDSystem(){
DELP(g_log);
DELP(g_Toast);
DELP(g_SystemInfo);
DELP(g_LngManager);
//DELP(m_controller);
//DELP(m_win);
}
bool init(){
char szFilePath[MAX_PATH + 1] = { 0 };
GetModuleFileName(NULL, szFilePath, MAX_PATH);
(strrchr(szFilePath, '\\'))[1] = 0;
g_AppPath = szFilePath;
g_AppDisk = g_AppPath.substr(0, 2);
g_isDebug = false;
g_log = new Logger();
g_log->m_LogDao->Init();
g_SystemInfo = new SystemInfo();
g_Toast = new Toast();
g_Lang = (char*)"zh_CN";
//g_LngManager = new LanguageManager();
//ChartletManager::GetInstance()->Init();
//g_LngManager->Init();
return true;
}
};
int main(int argc, char** argv) {
HBDSystem* sys = new HBDSystem();
sys->init();
DataHandle* dataHandle = new DataHandle();
dataHandle->Init();
dataHandle->Usage();
std::string userInput;
bool unknowCmd = false;
while (true) {
if (!unknowCmd)printf("*请输入命令:");
std::getline(std::cin, userInput); // 读取用户输入
unknowCmd = false;
if (userInput == "0") {
dataHandle->Usage();
}
else if (userInput == "1") {
printf("service is exiting...\n");
dataHandle->Stop();
break;
}
else if (userInput == "2") {
dataHandle->AllTest();
}
else if (userInput == "3") {
dataHandle->AxisMoveTest();
}
else if (userInput == "4") {
dataHandle->ScanCtrlTest();
}
else if (userInput == "100") {
dataHandle->ParamReadUsage();
while (printf("*请输入命令:") && std::getline(std::cin, userInput)) {
if (userInput == "q") {
printf("返回上一级...\n"); break;
}
else if (userInput.empty()) {
continue;
}
else if (userInput == "h") {
dataHandle->ParamReadUsage(); continue;
}
dataHandle->Request(stoi(userInput));
}
}
else {
printf("未识别的命令,请重新输入命令:");
unknowCmd = true;
}
}
delete sys;
sys = nullptr;
return 0;
}