|
@@ -8,73 +8,90 @@
|
|
|
#include "CommEntityUtil.hpp"
|
|
|
#include <string>
|
|
|
#include <map>
|
|
|
-#include <regex.h>
|
|
|
#include "array.h"
|
|
|
#include "fileutil.h"
|
|
|
#include <vector>
|
|
|
-#include <sys/utsname.h>
|
|
|
+#include <iostream>
|
|
|
+#include <memory>
|
|
|
|
|
|
+#include "EventCode.h"
|
|
|
+
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+#include<windows.h>
|
|
|
+#else
|
|
|
+#include <regex.h>
|
|
|
+#include <sys/utsname.h>
|
|
|
#include "RestfulFunc.h"
|
|
|
+
|
|
|
+#define NOT_SUPPOT_X11
|
|
|
+#ifndef NOT_SUPPOT_X11
|
|
|
+#include <X11/Xlib.h>
|
|
|
+#include <X11/Xutil.h>
|
|
|
+#endif //NOT_SUPPOT_X11
|
|
|
#include "DeviceAdaptChecker.h"
|
|
|
-#include "EventCode.h"
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
+#define DeviceControl_MouseMove 0x21400301 //鼠标移动
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_USB(SpReqAnsContext<DeviceControlService_USB_Req, DeviceControlService_USB_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->USB(ctx);
|
|
|
}
|
|
|
void CDeviceControlServerSession::Handle_GetUkeyID(SpReqAnsContext<DeviceControlService_GetUkeyID_Req, DeviceControlService_GetUkeyID_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->GetUkeyID(ctx);
|
|
|
}
|
|
|
void CDeviceControlServerSession::Handle_InitToken(SpReqAnsContext<DeviceControlService_InitToken_Req, DeviceControlService_InitToken_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->InitToken(ctx);
|
|
|
}
|
|
|
void CDeviceControlServerSession::Handle_QueryUSBStatus(SpReqAnsContext<DeviceControlService_QueryUSBStatus_Req, DeviceControlService_QueryUSBStatus_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->QueryUSBStatus(ctx);
|
|
|
}
|
|
|
void CDeviceControlServerSession::Handle_QueryHardwareInfo(SpReqAnsContext<DeviceControlService_QueryHardwareInfo_Req, DeviceControlService_QueryHardwareInfo_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->QueryHardwareInfo(ctx);
|
|
|
}
|
|
|
void CDeviceControlServerSession::Handle_ReadCenterConfigStr(SpReqAnsContext<DeviceControlService_ReadCenterConfigStr_Req, DeviceControlService_ReadCenterConfigStr_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->ReadCenterConfigStr(ctx);
|
|
|
}
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_ReadConfigValue(SpReqAnsContext<DeviceControlService_ReadConfigValue_Req, DeviceControlService_ReadConfigValue_Ans>::Pointer ctx)
|
|
|
{
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->ReadConfigValue(ctx);
|
|
|
}
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_GetDevInfo(SpReqAnsContext<DeviceControlService_GetDevInfo_Req, DeviceControlService_GetDevInfo_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->GetDevInfo(ctx);
|
|
|
}
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_TestConnectivity(SpReqAnsContext<DeviceControlService_TestConnectivity_Req, DeviceControlService_TestConnectivity_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->TestConnectivity(ctx);
|
|
|
}
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_GetVendorFileList(SpReqAnsContext<DeviceControlService_GetVendorFileList_Req, DeviceControlService_GetVendorFileList_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->GetVendorFileList(ctx);
|
|
|
}
|
|
|
|
|
|
void CDeviceControlServerSession::Handle_TestAdapterFileAvailable(SpReqAnsContext<DeviceControlService_TestAdapterFileAvailable_Req, DeviceControlService_TestAdapterFileAvailable_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
+ DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
m_pEntity->TestAdapterFileAvailable(ctx);
|
|
|
}
|
|
|
|
|
@@ -88,26 +105,46 @@ void CDeviceControlEntity::QueryHardwareInfo(SpReqAnsContext<DeviceControlServic
|
|
|
NetworkAddressesList ipAddrs;
|
|
|
SP::Module::Net::GetINETMacAddresses(macAddrs, ipAddrs);
|
|
|
|
|
|
-
|
|
|
- //根据设备类型获取厂商信息
|
|
|
- if (info.strMachineType == "RVC.PAD")
|
|
|
- {
|
|
|
+ // pad设备厂商为Microsoft, 其他设备读取root中的pinpad字段下的vendor
|
|
|
+ if (info.strMachineType == "RVC.PAD") {
|
|
|
DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("This is PAD device.");
|
|
|
- //国产化目前没有pad设备,后续按需修改
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ deviceFct = "Microsoft";
|
|
|
+ } else {
|
|
|
CSmartPointer<IConfigInfo> spConfig;
|
|
|
GetFunction()->OpenConfig(Config_Root, spConfig);
|
|
|
spConfig->ReadConfigValue("Device.PinPad", "Vendor", deviceFct);
|
|
|
}
|
|
|
|
|
|
//获取操作系统版本信息
|
|
|
+
|
|
|
+#if defined(_MSC_VER)
|
|
|
+ //获取windows系统版本
|
|
|
+ DWORD dwMajorVer, dwMinorVer, dwBuildNumber;
|
|
|
+ BOOL bRet = FALSE;
|
|
|
+ HMODULE hModNtdll = NULL;
|
|
|
+ if (hModNtdll = ::LoadLibraryW(L"ntdll.dll")) {
|
|
|
+ typedef void (WINAPI* pfRTLGETNTVERSIONNUMBERS)(DWORD*, DWORD*, DWORD*);
|
|
|
+ pfRTLGETNTVERSIONNUMBERS pfRtlGetNtVersionNumbers;
|
|
|
+ pfRtlGetNtVersionNumbers = (pfRTLGETNTVERSIONNUMBERS)::GetProcAddress(hModNtdll, "RtlGetNtVersionNumbers");
|
|
|
+ if (pfRtlGetNtVersionNumbers) {
|
|
|
+ pfRtlGetNtVersionNumbers(&dwMajorVer, &dwMinorVer, &dwBuildNumber);
|
|
|
+ dwBuildNumber &= 0x0ffff;
|
|
|
+ bRet = TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ ::FreeLibrary(hModNtdll);
|
|
|
+ hModNtdll = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ char buffer[1024];
|
|
|
+ sprintf(buffer, "%d.%d.%d", dwMajorVer, dwMinorVer, dwBuildNumber);
|
|
|
+ CSimpleStringA sysVer = (string("Windows ver[") + string(buffer) + "]").c_str();
|
|
|
+#else
|
|
|
utsname sysInfo;
|
|
|
uname(&sysInfo);
|
|
|
CSimpleStringA sysVer("UOS ");
|
|
|
sysVer.Append(sysInfo.release);
|
|
|
+#endif //_MSC_VER
|
|
|
|
|
|
if (ctx != NULL) {
|
|
|
ctx->Ans.ip = ipAddrs;
|
|
@@ -115,9 +152,19 @@ void CDeviceControlEntity::QueryHardwareInfo(SpReqAnsContext<DeviceControlServic
|
|
|
ctx->Ans.machineType = info.strMachineType;
|
|
|
ctx->Ans.site = info.strSite;
|
|
|
ctx->Ans.terminalNo = info.strTerminalID;
|
|
|
- ctx->Ans.termLimit = __ReadCenterConfigStr("TermLimitSwitch", "IEBrowser").second;
|
|
|
+ ctx->Ans.termLimit = "";
|
|
|
ctx->Ans.termVersion = info.InstallVersion.ToString();
|
|
|
-
|
|
|
+#ifdef DEVOPS_ON_ST /*DevOps流水线编译,ST环境*/
|
|
|
+ ctx->Ans.reserved1 = 1;
|
|
|
+#elif defined(DEVOPS_ON_UAT)/*DevOps流水线编译,UAT环境*/
|
|
|
+ ctx->Ans.reserved1 = 2;
|
|
|
+#elif defined(DEVOPS_ON_PRD)/*DevOps流水线编译,PRD环境*/
|
|
|
+ ctx->Ans.reserved1 = 3;
|
|
|
+#elif defined(DEVOPS_ON_DEV)/*DevOps流水线编译,Dev环境*/
|
|
|
+ ctx->Ans.reserved1 = 0;
|
|
|
+#else/*本地编译等非DevOps环境编译的版本*/
|
|
|
+ ctx->Ans.reserved1 = 0;
|
|
|
+#endif
|
|
|
ctx->Ans.reserved3 = sysVer;
|
|
|
ctx->Ans.reserved4 = deviceFct;
|
|
|
|
|
@@ -125,6 +172,55 @@ void CDeviceControlEntity::QueryHardwareInfo(SpReqAnsContext<DeviceControlServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+bool get_current_cursorPos(int& x, int& y)
|
|
|
+{
|
|
|
+#if (defined _WIN32 || defined _WIN64)
|
|
|
+ POINT p;
|
|
|
+ if (GetCursorPos(&p)) {
|
|
|
+ x = p.x;
|
|
|
+ y = p.y;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+#else
|
|
|
+
|
|
|
+#ifndef NOT_SUPPOT_X11
|
|
|
+ std::shared_ptr<Display> display(XOpenDisplay(NULL), [](Display* p) {
|
|
|
+ XCloseDisplay(p);
|
|
|
+});
|
|
|
+ XEvent event;
|
|
|
+ if (XQueryPointer(display.get(), XDefaultRootWindow(display), &event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, &event.xbutton.y_root,
|
|
|
+ &event.xbutton.x, &event.xbutton.y, &event.xbutton.state)) {
|
|
|
+ x = event.xbutton.x_root;
|
|
|
+ y = event.xbutton.y_root;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+#endif // !NOT_SUPPOT_X11
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+DWORD cursorPosUpdate(void* param)
|
|
|
+{
|
|
|
+ int curX = 0, curY = 0;
|
|
|
+ while (true) {
|
|
|
+ int tmpX = 0, tmpY = 0;
|
|
|
+ get_current_cursorPos(tmpX, tmpY);
|
|
|
+ if (tmpX != curX || tmpY != curY) {
|
|
|
+ LogEvent(Severity_Low, DeviceControl_MouseMove,
|
|
|
+ CSimpleString::Format("cursor move from (%d, %d) to (%d, %d)", curX, curY, tmpX, tmpY));
|
|
|
+ curX = tmpX;
|
|
|
+ curY = tmpY;
|
|
|
+ }
|
|
|
+ Sleep(20000);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
void CDeviceControlEntity::ReadCenterConfigStr(SpReqAnsContext<DeviceControlService_ReadCenterConfigStr_Req, DeviceControlService_ReadCenterConfigStr_Ans>::Pointer ctx)
|
|
|
{
|
|
|
auto ret = __ReadCenterConfigStr(ctx->Req.key, ctx->Req.entityName);
|
|
@@ -138,8 +234,6 @@ void CDeviceControlEntity::ReadCenterConfigStr(SpReqAnsContext<DeviceControlServ
|
|
|
|
|
|
void CDeviceControlEntity::ReadConfigValue(SpReqAnsContext<DeviceControlService_ReadConfigValue_Req, DeviceControlService_ReadConfigValue_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
if (ctx->Req.configType < 0 || ctx->Req.configType > Config_Cache + 1) {
|
|
|
ctx->Answer(Error_Param);
|
|
|
return;
|
|
@@ -254,54 +348,55 @@ void CDeviceControlEntity::ReadConfigValue(SpReqAnsContext<DeviceControlService_
|
|
|
|
|
|
void CDeviceControlEntity::TestConnectivity(SpReqAnsContext<DeviceControlService_TestConnectivity_Req, DeviceControlService_TestConnectivity_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d: %s:%d", ctx->Req.protocol, ctx->Req.ip.GetData(), ctx->Req.port);
|
|
|
|
|
|
- ErrorCodeEnum result(Error_NotInit);
|
|
|
-
|
|
|
- if (ctx->Req.protocol == 0) {
|
|
|
- result = Error_Param;
|
|
|
- } else if (ctx->Req.protocol == 1) { //Ping
|
|
|
- if (ctx->Req.ip.IsNullOrEmpty()) {
|
|
|
- result = Error_Param;
|
|
|
- } else {
|
|
|
- const int res = PingTest(std::string(ctx->Req.ip));
|
|
|
- if (res == 0) {
|
|
|
- ctx->Ans.result = 0;
|
|
|
- ctx->Ans.additionalMsg.Clear();
|
|
|
- } else {
|
|
|
- ctx->Ans.result = -1;
|
|
|
- ctx->Ans.additionalMsg = CSimpleStringA::Format("Ping %s failed: %d", ctx->Req.ip.GetData(), res);
|
|
|
- }
|
|
|
- result = Error_Succeed;
|
|
|
- }
|
|
|
- } else if (ctx->Req.protocol == 2) { //Normal socket connect Test
|
|
|
- if (ctx->Req.ip.IsNullOrEmpty() || ctx->Req.port <= 0) {
|
|
|
- result = Error_Param;
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Test socket connect available: %s:%d", ctx->Req.ip.GetData(), ctx->Req.port);
|
|
|
- std::string errMsg("");
|
|
|
- const int ret = SocketConnectTest(ctx->Req.ip.GetData(), ctx->Req.port, errMsg);
|
|
|
- ctx->Ans.result = ret;
|
|
|
- ctx->Ans.additionalMsg = errMsg.c_str();
|
|
|
- result = Error_Succeed;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (ctx->Req.protocol == 4) { //Http Test
|
|
|
- if (ctx->Req.ip.IsNullOrEmpty()) {
|
|
|
- result = Error_Param;
|
|
|
- } else {
|
|
|
- std::string msg;
|
|
|
- const int res = HttpProbe(std::string(ctx->Req.ip), msg);
|
|
|
- ctx->Ans.result = res;
|
|
|
- ctx->Ans.additionalMsg = msg.c_str();
|
|
|
- result = Error_Succeed;
|
|
|
- }
|
|
|
- } else {
|
|
|
- result = Error_NotSupport;
|
|
|
- }
|
|
|
- ctx->Answer(result);
|
|
|
+#if defined(_MSC_VER)
|
|
|
+ ctx->Answer(Error_NotImpl);
|
|
|
+#else
|
|
|
+ ErrorCodeEnum result(Error_NotInit);
|
|
|
+
|
|
|
+ if (ctx->Req.protocol == 0) {
|
|
|
+ result = Error_Param;
|
|
|
+ } else if (ctx->Req.protocol == 1) { //Ping
|
|
|
+ if (ctx->Req.ip.IsNullOrEmpty()) {
|
|
|
+ result = Error_Param;
|
|
|
+ } else {
|
|
|
+ const int res = PingTest(std::string(ctx->Req.ip));
|
|
|
+ if (res == 0) {
|
|
|
+ ctx->Ans.result = 0;
|
|
|
+ ctx->Ans.additionalMsg.Clear();
|
|
|
+ } else {
|
|
|
+ ctx->Ans.result = -1;
|
|
|
+ ctx->Ans.additionalMsg = CSimpleStringA::Format("Ping %s failed: %d", ctx->Req.ip.GetData(), res);
|
|
|
+ }
|
|
|
+ result = Error_Succeed;
|
|
|
+ }
|
|
|
+ } else if (ctx->Req.protocol == 2) { //Normal socket connect Test
|
|
|
+ if (ctx->Req.ip.IsNullOrEmpty() || ctx->Req.port <= 0) {
|
|
|
+ result = Error_Param;
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Test socket connect available: %s:%d", ctx->Req.ip.GetData(), ctx->Req.port);
|
|
|
+ std::string errMsg("");
|
|
|
+ const int ret = SocketConnectTest(ctx->Req.ip.GetData(), ctx->Req.port, errMsg);
|
|
|
+ ctx->Ans.result = ret;
|
|
|
+ ctx->Ans.additionalMsg = errMsg.c_str();
|
|
|
+ result = Error_Succeed;
|
|
|
+ }
|
|
|
+ } else if (ctx->Req.protocol == 4) { //Http Test
|
|
|
+ if (ctx->Req.ip.IsNullOrEmpty()) {
|
|
|
+ result = Error_Param;
|
|
|
+ } else {
|
|
|
+ std::string msg;
|
|
|
+ const int res = HttpProbe(std::string(ctx->Req.ip), msg);
|
|
|
+ ctx->Ans.result = res;
|
|
|
+ ctx->Ans.additionalMsg = msg.c_str();
|
|
|
+ result = Error_Succeed;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result = Error_NotSupport;
|
|
|
+ }
|
|
|
+ ctx->Answer(result);
|
|
|
+#endif //_MSC_VER
|
|
|
|
|
|
}
|
|
|
|
|
@@ -312,270 +407,277 @@ static CSimpleStringA GetRegexPatternString(const DeviceControlService_GetVendo
|
|
|
const char* suffix = "\\.so$";
|
|
|
CSimpleStringA strRegexPattern(prefix);
|
|
|
|
|
|
- //^lib(Gpio|PinPad)\.[a-zA-Z]*\.[0-9]*\.[0-9]*\.so$
|
|
|
- if (req.adapter.IsNullOrEmpty() || req.adapter.Compare("*") == 0) {
|
|
|
- CSimpleStringA tmp("(");
|
|
|
- if (strMachineType.Compare("RVC.Stand2S") == 0) {
|
|
|
- for (int i = 0; i < array_size(adapterList_4_stand2s); ++i) {
|
|
|
- if (i != 0) tmp += "|";
|
|
|
- tmp += adapterList_4_stand2s[i];
|
|
|
- }
|
|
|
- } else if (strMachineType.Compare("RVC.Stand1SPlus") == 0) {
|
|
|
- for (int i = 0; i < array_size(adapterList_4_stand1s); ++i) {
|
|
|
- if (i != 0) tmp += "|";
|
|
|
- tmp += adapterList_4_stand1s[i];
|
|
|
- }
|
|
|
- } else {
|
|
|
- tmp += ".*";
|
|
|
- }
|
|
|
- tmp += (")");
|
|
|
- strRegexPattern += tmp;
|
|
|
- } else {
|
|
|
- strRegexPattern += "(";
|
|
|
- strRegexPattern += req.adapter;
|
|
|
- strRegexPattern += ")";
|
|
|
- }
|
|
|
- strRegexPattern += "\\.";
|
|
|
- if (req.vendor.IsNullOrEmpty() || req.vendor.Compare("*") == 0) {
|
|
|
- strRegexPattern += "[a-zA-Z]*";
|
|
|
- } else {
|
|
|
- strRegexPattern += "(";
|
|
|
- strRegexPattern += req.vendor;
|
|
|
- strRegexPattern += ")";
|
|
|
- }
|
|
|
- strRegexPattern += "\\.";
|
|
|
- if (req.version.IsNullOrEmpty() || req.version.Compare("*") == 0) {
|
|
|
- strRegexPattern += "[0-9]*";
|
|
|
- } else {
|
|
|
- strRegexPattern += "(";
|
|
|
- strRegexPattern += req.version;
|
|
|
- strRegexPattern += ")";
|
|
|
- }
|
|
|
- strRegexPattern += "\\.";
|
|
|
- if (req.batch.IsNullOrEmpty() || req.batch.Compare("*") == 0) {
|
|
|
- strRegexPattern += "[0-9]*";
|
|
|
- } else {
|
|
|
- strRegexPattern += "(";
|
|
|
- strRegexPattern += req.batch;
|
|
|
- strRegexPattern += ")";
|
|
|
- }
|
|
|
- strRegexPattern += suffix;
|
|
|
+#if defined(RVC_OS_LINUX)
|
|
|
+
|
|
|
+ //^lib(Gpio|PinPad)\.[a-zA-Z]*\.[0-9]*\.[0-9]*\.so$
|
|
|
+ if (req.adapter.IsNullOrEmpty() || req.adapter.Compare("*") == 0) {
|
|
|
+ CSimpleStringA tmp("(");
|
|
|
+ if (strMachineType.Compare("RVC.Stand2S") == 0) {
|
|
|
+ for (int i = 0; i < array_size(adapterList_4_stand2s); ++i) {
|
|
|
+ if (i != 0) tmp += "|";
|
|
|
+ tmp += adapterList_4_stand2s[i];
|
|
|
+ }
|
|
|
+ } else if (strMachineType.Compare("RVC.Stand1SPlus") == 0) {
|
|
|
+ for (int i = 0; i < array_size(adapterList_4_stand1s); ++i) {
|
|
|
+ if (i != 0) tmp += "|";
|
|
|
+ tmp += adapterList_4_stand1s[i];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tmp += ".*";
|
|
|
+ }
|
|
|
+ tmp += (")");
|
|
|
+ strRegexPattern += tmp;
|
|
|
+ } else {
|
|
|
+ strRegexPattern += "(";
|
|
|
+ strRegexPattern += req.adapter;
|
|
|
+ strRegexPattern += ")";
|
|
|
+ }
|
|
|
+ strRegexPattern += "\\.";
|
|
|
+ if (req.vendor.IsNullOrEmpty() || req.vendor.Compare("*") == 0) {
|
|
|
+ strRegexPattern += "[a-zA-Z]*";
|
|
|
+ } else {
|
|
|
+ strRegexPattern += "(";
|
|
|
+ strRegexPattern += req.vendor;
|
|
|
+ strRegexPattern += ")";
|
|
|
+ }
|
|
|
+ strRegexPattern += "\\.";
|
|
|
+ if (req.version.IsNullOrEmpty() || req.version.Compare("*") == 0) {
|
|
|
+ strRegexPattern += "[0-9]*";
|
|
|
+ } else {
|
|
|
+ strRegexPattern += "(";
|
|
|
+ strRegexPattern += req.version;
|
|
|
+ strRegexPattern += ")";
|
|
|
+ }
|
|
|
+ strRegexPattern += "\\.";
|
|
|
+ if (req.batch.IsNullOrEmpty() || req.batch.Compare("*") == 0) {
|
|
|
+ strRegexPattern += "[0-9]*";
|
|
|
+ } else {
|
|
|
+ strRegexPattern += "(";
|
|
|
+ strRegexPattern += req.batch;
|
|
|
+ strRegexPattern += ")";
|
|
|
+ }
|
|
|
+ strRegexPattern += suffix;
|
|
|
+#endif //RVC_OS_LINUX
|
|
|
|
|
|
return strRegexPattern;
|
|
|
}
|
|
|
|
|
|
void CDeviceControlEntity::GetVendorFileList(SpReqAnsContext<DeviceControlService_GetVendorFileList_Req, DeviceControlService_GetVendorFileList_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
- ErrorCodeEnum result(Error_Succeed);
|
|
|
- int tmpResult = 0;
|
|
|
- CSimpleStringA tmpMsg(true);
|
|
|
-
|
|
|
- CSimpleStringA strDepDirPath;
|
|
|
- result = GetFunction()->GetPath("Dep", strDepDirPath);
|
|
|
-
|
|
|
- if (ctx->Req.root) {
|
|
|
- CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
- checker->Init(this);
|
|
|
- CAutoArray<AdapterRootConfigInfo> tmp;
|
|
|
- if (ctx->Req.adapter.IsNullOrEmpty() || ctx->Req.adapter.Compare("*") == 0) {
|
|
|
- tmp = checker->GetConfigedAdapterInfo();
|
|
|
- } else {
|
|
|
- tmp = checker->GetConfigedAdapterInfo(ctx->Req.adapter);
|
|
|
- }
|
|
|
- delete checker;
|
|
|
- checker = NULL;
|
|
|
-
|
|
|
- const int curSize = tmp.GetCount();
|
|
|
- ctx->Ans.filenames.Init(curSize);
|
|
|
- ctx->Ans.status.Init(curSize);
|
|
|
- ctx->Ans.port.Init(curSize);
|
|
|
- ctx->Ans.baudrate.Init(curSize);
|
|
|
-
|
|
|
- CSimpleStringA strDepDirPath2 = strDepDirPath + SPLIT_SLASH_STR;
|
|
|
- for (int i = 0; i < curSize; ++i) {
|
|
|
-
|
|
|
- ctx->Ans.filenames[i] = tmp[i].strDepDirWithSlashOrFileName;
|
|
|
- ctx->Ans.port[i] = tmp[i].dwPort;
|
|
|
- ctx->Ans.baudrate[i] = tmp[i].dwBaudRate;
|
|
|
-
|
|
|
- CSimpleStringA fullPath = strDepDirPath2 + ctx->Ans.filenames[i];
|
|
|
- ctx->Ans.status[i] = 0x2;
|
|
|
- if (ExistsFileA(fullPath)) {
|
|
|
- ctx->Ans.status[i] |= 0x1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- std::vector<std::string> adapterFiles;
|
|
|
- array_header_t* subs = fileutil_get_sub_files_a(strDepDirPath);
|
|
|
- if (subs) {
|
|
|
- regex_t reg;
|
|
|
- CSystemStaticInfo info;
|
|
|
- GetFunction()->GetSystemStaticInfo(info);
|
|
|
- CSimpleStringA pattern = GetRegexPatternString(ctx->Req, info.strMachineType);
|
|
|
- int ret = regcomp(®, pattern, REG_EXTENDED | REG_NOSUB);
|
|
|
- if (ret) {
|
|
|
- char ebuff[256];
|
|
|
- regerror(ret, ®, ebuff, 256);
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("regex failed: %s", ebuff);
|
|
|
- tmpResult = Error_Unexpect;
|
|
|
- tmpMsg = CSimpleStringA::Format("内部错误:REGEX %s", ebuff);
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pattern: %s", pattern.GetData());
|
|
|
- for (int i = 0; i < subs->nelts; ++i) {
|
|
|
- char* filenamePath = ARRAY_IDX(subs, i, char*);
|
|
|
- char* filename = &filenamePath[strDepDirPath.GetLength() + 1];
|
|
|
- ret = regexec(®, filename, 0, NULL, 0);
|
|
|
- if (0 == ret) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("filename %s matched!", filename);
|
|
|
- adapterFiles.push_back(std::string(filename));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const int curSize = adapterFiles.size();
|
|
|
- ctx->Ans.filenames.Init(curSize);
|
|
|
- ctx->Ans.status.Init(curSize);
|
|
|
- ctx->Ans.port.Init(curSize);
|
|
|
- ctx->Ans.baudrate.Init(curSize);
|
|
|
-
|
|
|
- for (int i = 0; i < curSize; ++i) {
|
|
|
- ctx->Ans.status[i] = 0;
|
|
|
- ctx->Ans.port[i] = 0;
|
|
|
- ctx->Ans.baudrate[i] = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (curSize > 0) {
|
|
|
- CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
- checker->Init(this);
|
|
|
- int cnt = 0;
|
|
|
- for (auto iter = adapterFiles.cbegin(); iter != adapterFiles.cend(); ++iter, ++cnt) {
|
|
|
- ctx->Ans.filenames[cnt] = iter->c_str();
|
|
|
- ctx->Ans.status[cnt] = 0x1;
|
|
|
- AdapterRootConfigInfo info;
|
|
|
- if (checker->IsThisFileConfigure(iter->c_str(), &info)) {
|
|
|
- ctx->Ans.status[cnt] |= 0x2;
|
|
|
- ctx->Ans.port[cnt] = info.dwPort;
|
|
|
- ctx->Ans.baudrate[cnt] = info.dwBaudRate;
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- delete checker;
|
|
|
- }
|
|
|
-
|
|
|
- toolkit_array_free2(subs);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.result = tmpResult;
|
|
|
- ctx->Ans.msg = tmpMsg;
|
|
|
- ctx->Answer(result);
|
|
|
- return;
|
|
|
+#if defined(_MSC_VER)
|
|
|
+ ctx->Answer(Error_NotImpl);
|
|
|
+#else
|
|
|
+ ErrorCodeEnum result(Error_Succeed);
|
|
|
+ int tmpResult = 0;
|
|
|
+ CSimpleStringA tmpMsg(true);
|
|
|
+
|
|
|
+ CSimpleStringA strDepDirPath;
|
|
|
+ result = GetFunction()->GetPath("Dep", strDepDirPath);
|
|
|
+
|
|
|
+ if (ctx->Req.root) {
|
|
|
+ CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
+ checker->Init(this);
|
|
|
+ CAutoArray<AdapterRootConfigInfo> tmp;
|
|
|
+ if (ctx->Req.adapter.IsNullOrEmpty() || ctx->Req.adapter.Compare("*") == 0) {
|
|
|
+ tmp = checker->GetConfigedAdapterInfo();
|
|
|
+ } else {
|
|
|
+ tmp = checker->GetConfigedAdapterInfo(ctx->Req.adapter);
|
|
|
+ }
|
|
|
+ delete checker;
|
|
|
+ checker = NULL;
|
|
|
+
|
|
|
+ const int curSize = tmp.GetCount();
|
|
|
+ ctx->Ans.filenames.Init(curSize);
|
|
|
+ ctx->Ans.status.Init(curSize);
|
|
|
+ ctx->Ans.port.Init(curSize);
|
|
|
+ ctx->Ans.baudrate.Init(curSize);
|
|
|
+
|
|
|
+ CSimpleStringA strDepDirPath2 = strDepDirPath + SPLIT_SLASH_STR;
|
|
|
+ for (int i = 0; i < curSize; ++i) {
|
|
|
+
|
|
|
+ ctx->Ans.filenames[i] = tmp[i].strDepDirWithSlashOrFileName;
|
|
|
+ ctx->Ans.port[i] = tmp[i].dwPort;
|
|
|
+ ctx->Ans.baudrate[i] = tmp[i].dwBaudRate;
|
|
|
+
|
|
|
+ CSimpleStringA fullPath = strDepDirPath2 + ctx->Ans.filenames[i];
|
|
|
+ ctx->Ans.status[i] = 0x2;
|
|
|
+ if (ExistsFileA(fullPath)) {
|
|
|
+ ctx->Ans.status[i] |= 0x1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ std::vector<std::string> adapterFiles;
|
|
|
+ array_header_t* subs = fileutil_get_sub_files_a(strDepDirPath);
|
|
|
+ if (subs) {
|
|
|
+ regex_t reg;
|
|
|
+ CSystemStaticInfo info;
|
|
|
+ GetFunction()->GetSystemStaticInfo(info);
|
|
|
+ CSimpleStringA pattern = GetRegexPatternString(ctx->Req, info.strMachineType);
|
|
|
+ int ret = regcomp(®, pattern, REG_EXTENDED | REG_NOSUB);
|
|
|
+ if (ret) {
|
|
|
+ char ebuff[256];
|
|
|
+ regerror(ret, ®, ebuff, 256);
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("regex failed: %s", ebuff);
|
|
|
+ tmpResult = Error_Unexpect;
|
|
|
+ tmpMsg = CSimpleStringA::Format("内部错误:REGEX %s", ebuff);
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pattern: %s", pattern.GetData());
|
|
|
+ for (int i = 0; i < subs->nelts; ++i) {
|
|
|
+ char* filenamePath = ARRAY_IDX(subs, i, char*);
|
|
|
+ char* filename = &filenamePath[strDepDirPath.GetLength() + 1];
|
|
|
+ ret = regexec(®, filename, 0, NULL, 0);
|
|
|
+ if (0 == ret) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("filename %s matched!", filename);
|
|
|
+ adapterFiles.push_back(std::string(filename));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const int curSize = adapterFiles.size();
|
|
|
+ ctx->Ans.filenames.Init(curSize);
|
|
|
+ ctx->Ans.status.Init(curSize);
|
|
|
+ ctx->Ans.port.Init(curSize);
|
|
|
+ ctx->Ans.baudrate.Init(curSize);
|
|
|
+
|
|
|
+ for (int i = 0; i < curSize; ++i) {
|
|
|
+ ctx->Ans.status[i] = 0;
|
|
|
+ ctx->Ans.port[i] = 0;
|
|
|
+ ctx->Ans.baudrate[i] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (curSize > 0) {
|
|
|
+ CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
+ checker->Init(this);
|
|
|
+ int cnt = 0;
|
|
|
+ for (auto iter = adapterFiles.cbegin(); iter != adapterFiles.cend(); ++iter, ++cnt) {
|
|
|
+ ctx->Ans.filenames[cnt] = iter->c_str();
|
|
|
+ ctx->Ans.status[cnt] = 0x1;
|
|
|
+ AdapterRootConfigInfo info;
|
|
|
+ if (checker->IsThisFileConfigure(iter->c_str(), &info)) {
|
|
|
+ ctx->Ans.status[cnt] |= 0x2;
|
|
|
+ ctx->Ans.port[cnt] = info.dwPort;
|
|
|
+ ctx->Ans.baudrate[cnt] = info.dwBaudRate;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ delete checker;
|
|
|
+ }
|
|
|
+
|
|
|
+ toolkit_array_free2(subs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx->Ans.result = tmpResult;
|
|
|
+ ctx->Ans.msg = tmpMsg;
|
|
|
+ ctx->Answer(result);
|
|
|
+ return;
|
|
|
+#endif //_MSC_VER
|
|
|
}
|
|
|
|
|
|
void CDeviceControlEntity::TestAdapterFileAvailable(
|
|
|
SpReqAnsContext<DeviceControlService_TestAdapterFileAvailable_Req, DeviceControlService_TestAdapterFileAvailable_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
- ErrorCodeEnum result(Error_Succeed);
|
|
|
- int tmpResult = 0;
|
|
|
- CSimpleStringA tmpMsg(true);
|
|
|
-
|
|
|
-
|
|
|
- if (ctx->Req.type == 1) /*循环验证配置适配器的有效性*/ {
|
|
|
- CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
- checker->Init(this);
|
|
|
- CAutoArray<CAdapterLoader*>& tmp = checker->AdapterCoinfigList();
|
|
|
- const int curSize = tmp.GetCount();
|
|
|
- std::vector<std::string> errlibNames;
|
|
|
- std::vector<std::string> errMsgs;
|
|
|
- for (int i = 0; i < curSize; ++i) {
|
|
|
- ErrorCodeEnum ec(Error_Succeed);
|
|
|
- CSimpleStringA strLastErrMsg(true);
|
|
|
- VendorLibInfoEx& libInfo = tmp[i]->vendorLibInfo;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to check %s", libInfo.toLibNameString().GetData());
|
|
|
- ec = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(libInfo, strLastErrMsg);
|
|
|
- if (ec != Error_Succeed) {
|
|
|
- errlibNames.push_back(std::string(libInfo.toLibNameString().GetData()));
|
|
|
- errMsgs.push_back(std::string(strLastErrMsg.GetData()));
|
|
|
-
|
|
|
- strLastErrMsg = CSimpleStringA::Format("%s: %s", libInfo.toLibNameString().GetData(), strLastErrMsg.GetData());
|
|
|
- if (!tmpMsg.IsNullOrEmpty()) tmpMsg += "\n";
|
|
|
- tmpMsg += strLastErrMsg;
|
|
|
- if (!!(ctx->Req.options & 0x1)) {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("detect critical error limit, break it.");
|
|
|
- tmpResult = ec;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- BroadcastAdapterTestResult(libInfo.toLibNameString(), ec, strLastErrMsg);
|
|
|
- }
|
|
|
- delete checker;
|
|
|
- checker = NULL;
|
|
|
-
|
|
|
- if (!(ctx->Req.options & 0x1) && !tmpMsg.IsNullOrEmpty()) {
|
|
|
- tmpResult = Error_Failed;
|
|
|
- }
|
|
|
-
|
|
|
- if (!errlibNames.empty()) {
|
|
|
- const int curErrSize = errlibNames.size();
|
|
|
- ctx->Ans.reserved1.Init(curErrSize);
|
|
|
- ctx->Ans.reserved2.Init(curErrSize);
|
|
|
- ctx->Ans.reserved3.Init(curErrSize);
|
|
|
-
|
|
|
- int cnt(0);
|
|
|
- for (auto iter = errlibNames.cbegin(); iter != errlibNames.cend(); ++iter) {
|
|
|
- ctx->Ans.reserved1[cnt] = 0;
|
|
|
- ctx->Ans.reserved2[cnt] = iter->c_str();
|
|
|
- ctx->Ans.reserved3[cnt] = errMsgs[cnt].c_str();
|
|
|
- cnt++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if (ctx->Req.filename.IsNullOrEmpty()) {
|
|
|
- ctx->Answer(Error_Param);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- VendorLibInfoEx libInfo;
|
|
|
- if (libInfo.Load(ctx->Req.filename)) {
|
|
|
-
|
|
|
- libInfo.optCfg.dwPort = ctx->Req.port;
|
|
|
- libInfo.optCfg.dwBaudRate = ctx->Req.baudrate;
|
|
|
- libInfo.optCfg.dwParam1 = ctx->Req.param1;
|
|
|
- libInfo.optCfg.dwParam2 = ctx->Req.param2;
|
|
|
-
|
|
|
- GetFunction()->GetPath("Dep", libInfo.optCfg.strDepDirWithSlashOrFileName);
|
|
|
- libInfo.optCfg.strDepDirWithSlashOrFileName += SPLIT_SLASH_STR;
|
|
|
-
|
|
|
- } else if (ctx->Req.filename.IndexOf(".") == -1) { //pure adapter name
|
|
|
-
|
|
|
- CAdapterLoader loader(ctx->Req.filename, this);
|
|
|
- tmpResult = loader.LoadConfigFromRootIni();
|
|
|
- libInfo = loader.vendorLibInfo;
|
|
|
-
|
|
|
- } else {
|
|
|
- DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("invalid adapter file name: %s", ctx->Req.filename.GetData());
|
|
|
- ctx->Answer(Error_MisMatched);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (tmpResult == 0) {
|
|
|
- tmpResult = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(libInfo, tmpMsg);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- ctx->Ans.status = tmpResult;
|
|
|
- ctx->Ans.msg = tmpMsg;
|
|
|
- ctx->Answer(result);
|
|
|
+#if defined(_MSC_VER)
|
|
|
+ ctx->Answer(Error_NotImpl);
|
|
|
+#else
|
|
|
+ ErrorCodeEnum result(Error_Succeed);
|
|
|
+ int tmpResult = 0;
|
|
|
+ CSimpleStringA tmpMsg(true);
|
|
|
+
|
|
|
+
|
|
|
+ if (ctx->Req.type == 1) /*循环验证配置适配器的有效性*/ {
|
|
|
+ CAdapterLoadChecker* checker = new CAdapterLoadChecker();
|
|
|
+ checker->Init(this);
|
|
|
+ CAutoArray<CAdapterLoader*>& tmp = checker->AdapterCoinfigList();
|
|
|
+ const int curSize = tmp.GetCount();
|
|
|
+ std::vector<std::string> errlibNames;
|
|
|
+ std::vector<std::string> errMsgs;
|
|
|
+ for (int i = 0; i < curSize; ++i) {
|
|
|
+ ErrorCodeEnum ec(Error_Succeed);
|
|
|
+ CSimpleStringA strLastErrMsg(true);
|
|
|
+ VendorLibInfoEx& libInfo = tmp[i]->vendorLibInfo;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to check %s", libInfo.toLibNameString().GetData());
|
|
|
+ ec = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(libInfo, strLastErrMsg);
|
|
|
+ if (ec != Error_Succeed) {
|
|
|
+ errlibNames.push_back(std::string(libInfo.toLibNameString().GetData()));
|
|
|
+ errMsgs.push_back(std::string(strLastErrMsg.GetData()));
|
|
|
+
|
|
|
+ strLastErrMsg = CSimpleStringA::Format("%s: %s", libInfo.toLibNameString().GetData(), strLastErrMsg.GetData());
|
|
|
+ if (!tmpMsg.IsNullOrEmpty()) tmpMsg += "\n";
|
|
|
+ tmpMsg += strLastErrMsg;
|
|
|
+ if (!!(ctx->Req.options & 0x1)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("detect critical error limit, break it.");
|
|
|
+ tmpResult = ec;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ BroadcastAdapterTestResult(libInfo.toLibNameString(), ec, strLastErrMsg);
|
|
|
+ }
|
|
|
+ delete checker;
|
|
|
+ checker = NULL;
|
|
|
+
|
|
|
+ if (!(ctx->Req.options & 0x1) && !tmpMsg.IsNullOrEmpty()) {
|
|
|
+ tmpResult = Error_Failed;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!errlibNames.empty()) {
|
|
|
+ const int curErrSize = errlibNames.size();
|
|
|
+ ctx->Ans.reserved1.Init(curErrSize);
|
|
|
+ ctx->Ans.reserved2.Init(curErrSize);
|
|
|
+ ctx->Ans.reserved3.Init(curErrSize);
|
|
|
+
|
|
|
+ int cnt(0);
|
|
|
+ for (auto iter = errlibNames.cbegin(); iter != errlibNames.cend(); ++iter) {
|
|
|
+ ctx->Ans.reserved1[cnt] = 0;
|
|
|
+ ctx->Ans.reserved2[cnt] = iter->c_str();
|
|
|
+ ctx->Ans.reserved3[cnt] = errMsgs[cnt].c_str();
|
|
|
+ cnt++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (ctx->Req.filename.IsNullOrEmpty()) {
|
|
|
+ ctx->Answer(Error_Param);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ VendorLibInfoEx libInfo;
|
|
|
+ if (libInfo.Load(ctx->Req.filename)) {
|
|
|
+
|
|
|
+ libInfo.optCfg.dwPort = ctx->Req.port;
|
|
|
+ libInfo.optCfg.dwBaudRate = ctx->Req.baudrate;
|
|
|
+ libInfo.optCfg.dwParam1 = ctx->Req.param1;
|
|
|
+ libInfo.optCfg.dwParam2 = ctx->Req.param2;
|
|
|
+
|
|
|
+ GetFunction()->GetPath("Dep", libInfo.optCfg.strDepDirWithSlashOrFileName);
|
|
|
+ libInfo.optCfg.strDepDirWithSlashOrFileName += SPLIT_SLASH_STR;
|
|
|
+
|
|
|
+ } else if (ctx->Req.filename.IndexOf(".") == -1) { //pure adapter name
|
|
|
+
|
|
|
+ CAdapterLoader loader(ctx->Req.filename, this);
|
|
|
+ tmpResult = loader.LoadConfigFromRootIni();
|
|
|
+ libInfo = loader.vendorLibInfo;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("invalid adapter file name: %s", ctx->Req.filename.GetData());
|
|
|
+ ctx->Answer(Error_MisMatched);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tmpResult == 0) {
|
|
|
+ tmpResult = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(libInfo, tmpMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ctx->Ans.status = tmpResult;
|
|
|
+ ctx->Ans.msg = tmpMsg;
|
|
|
+ ctx->Answer(result);
|
|
|
+#endif //_MSC_VER
|
|
|
|
|
|
return;
|
|
|
}
|
|
@@ -608,8 +710,6 @@ std::pair<ErrorCodeEnum, CSimpleStringA> CDeviceControlEntity::__ReadCenterConfi
|
|
|
|
|
|
void CDeviceControlEntity::BroadcastAdapterTestResult(const CSimpleStringA& adapterName, ErrorCodeEnum result, const CSimpleStringA& strErrMsg)
|
|
|
{
|
|
|
- LOG_FUNCTION();
|
|
|
-
|
|
|
DeviceControl::AdapterTestResult evt;
|
|
|
evt.result = result;
|
|
|
evt.adapterInfo = adapterName;
|
|
@@ -617,6 +717,16 @@ void CDeviceControlEntity::BroadcastAdapterTestResult(const CSimpleStringA& adap
|
|
|
SpSendBroadcast(GetFunction(), SP_MSG_OF(AdapterTestResult), SP_MSG_SIG_OF(AdapterTestResult), evt);
|
|
|
}
|
|
|
|
|
|
+void CDeviceControlEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+{
|
|
|
+ LOG_FUNCTION();
|
|
|
+ ErrorCodeEnum rt = m_fsm.Init(this);
|
|
|
+ ///**TODO(Gifur@9/28/2023): UOS 下需要监控鼠标移动状态吗? */
|
|
|
+#if defined(_MSC_VER)
|
|
|
+ CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&cursorPosUpdate, NULL, 0, NULL));
|
|
|
+#endif //_MSC_VER
|
|
|
+ pTransactionContext->SendAnswer(rt);
|
|
|
+}
|
|
|
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
SP_ENTITY(CDeviceControlEntity)
|