123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664 |
- #include "..\..\..\..\Deliver\include\DIOS.Dev.Collimator.Mould.hpp"
- //
- #include "stdafx.h"
- #include <assert.h>
- #include "Helper.JSON.hpp"
- #include "DIOS.Dev.Collimator.Mould.hpp"
- #include "EasyJSONEncoder.hpp"
- #include "DIOSDICOMInfo.h"
- using namespace DIOS::Dev::Detail::Collimator;
- namespace nsGEN = DIOS::Dev::Detail::Collimator;
- //template <typename _Container, typename T>
- //inline _Container& operator << (_Container& ar, const T& t)
- //{
- // ar.push_back(t);
- // return ar;
- //}
- string nsGEN::GetProcessDirectory()
- {
- string ret = "";
- char szFilename[MAX_PATH] = { 0 };
- DWORD res = GetModuleFileNameA(0, szFilename, MAX_PATH);
- if (res == 0)
- {
- return ret;
- }
- string fullpath = szFilename;
- string::size_type firstHit = fullpath.find_last_of('\\');
- if (firstHit == string::npos || firstHit == 0)
- {
- return ret;
- }
- ret = fullpath.substr(0, firstHit);//kick last \
- return ret;
- }
- //获取配置文件中指定模块的版本号
- bool nsGEN::GetVersion(string& version, HMODULE hMyModule)
- {
- try {
- char filename[MAX_PATH + 1] = { 0 };
- if (GetModuleFileName(hMyModule, filename, MAX_PATH) == 0)
- {
- printf("dll HMODULEis null\n");
- //mLog::Error("dll HMODULEis null\n");
- return false;
- }
- printf("get Generator path:{$}\n", filename);
- //mLog::Info("get Generator path:{$}\n", filename);
- DWORD dummy;
- DWORD size = GetFileVersionInfoSize(filename, &dummy);
- if (size == 0)
- {
- return false;
- }
- auto data = make_unique<BYTE[]>(size);
- if (!GetFileVersionInfo(filename, 0, size, &data[0]))
- {
- return false;
- }
- UINT32 len = 0;
- VS_FIXEDFILEINFO* fixed_file_info = 0;
- if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
- {
- return false;
- }
- // version 为版本号
- UINT32 vBitNumber = 0;
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- return true;
- }
- catch (...)
- {
- printf("get Generator Mould version failed");
- //mLog::Error("get Generator Mould version failed\n");
- }
- return false;
- }
- bool nsGEN::GetVersion(string& version, ResDataObject& config)
- {
- try {
- string procdir = "";
- char filename[MAX_PATH + 1] = { 0 };
- procdir = nsGEN::GetProcessDirectory();
- if (procdir.empty())
- {
- if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
- {
- return false;
- }
- }
- else
- {
- string oemdrvpath = (const char*)config["oemdriver"];
- {
- string keystr = "%ROOT%";
- string::size_type pos = 0;
- string::size_type keylen = keystr.size();
- string::size_type replen = procdir.size();
- while ((pos = oemdrvpath.find(keystr, pos)) != string::npos)
- {
- oemdrvpath.replace(pos, keylen, procdir);
- pos += replen;
- }
- }
- strncpy_s(filename, oemdrvpath.c_str(), MAX_PATH);
- }
- printf("get Generator path:{$}\n", filename);
- //mLog::Info("get Generator path:{$}\n", filename);
- DWORD dummy;
- DWORD size = GetFileVersionInfoSize(filename, &dummy);
- if (size == 0)
- {
- return false;
- }
- auto data = make_unique<BYTE[]>(size);
- if (!GetFileVersionInfo(filename, 0, size, &data[0]))
- {
- return false;
- }
- UINT32 len = 0;
- VS_FIXEDFILEINFO* fixed_file_info = 0;
- if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
- {
- return false;
- }
- // version 为版本号
- UINT32 vBitNumber = 0;
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- return true;
- }
- catch (...)
- {
- printf("get Generator Mould version failed");
- //mLog::Error("get Generator Mould version failed\n");
- }
- return false;
- }
- bool nsGEN::GetVersion(string& version)
- {
- try {
- char filename[MAX_PATH + 1] = { 0 };
- if (GetModuleFileName(nullptr, filename, MAX_PATH) == 0)
- {
- return false;
- }
- printf("get Generator path:{$}\n", filename);
- //mLog::Info("get Generator path:{$}\n", filename);
- DWORD dummy;
- DWORD size = GetFileVersionInfoSize(filename, &dummy);
- if (size == 0)
- {
- return false;
- }
- auto data = make_unique<BYTE[]>(size);
- if (!GetFileVersionInfo(filename, 0, size, &data[0]))
- {
- return false;
- }
- UINT32 len = 0;
- VS_FIXEDFILEINFO* fixed_file_info = 0;
- if (!VerQueryValue(&data[0], TEXT("\\"), reinterpret_cast<void**>(&fixed_file_info), &len))
- {
- return false;
- }
- // version 为版本号
- UINT32 vBitNumber = 0;
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionMS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = HIWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- version += ".";
- vBitNumber = LOWORD(fixed_file_info->dwProductVersionLS);
- version += to_string(vBitNumber);
- return true;
- }
- catch (...)
- {
- printf("get Generator Mould version failed");
- //mLog::Error("get Generator Mould version failed\n");
- }
- return false;
- }
- //-----------------------------------------------------------------------------
- // nsGEN::ColliamtorMould
- //-----------------------------------------------------------------------------
- nsGEN::ColliamtorMould::ColliamtorMould()
- {
- }
- nsGEN::ColliamtorMould::~ColliamtorMould()
- {
- }
- void nsGEN::ColliamtorMould::Register (Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::XSIZE, this, &ColliamtorMould::JSGetCollimatorXSize);
- Dispatch->Get.Push(AttrKey::YSIZE, this, &ColliamtorMould::JSGetCollimatorYSize);
- Dispatch->Get.Push(AttrKey::XRatio, this, &ColliamtorMould::JSGetCollimatorXRatio);
- Dispatch->Get.Push(AttrKey::YRatio, this, &ColliamtorMould::JSGetCollimatorYRatio);
- Dispatch->Get.Push(AttrKey::MaxWidth, this, &ColliamtorMould::JSGetCollimatorMaxWidth);
- Dispatch->Get.Push(AttrKey::MaxHigh, this, &ColliamtorMould::JSGetCollimatorMaxHigh);
- Dispatch->Get.Push(AttrKey::ThresholdValue, this, &ColliamtorMould::JSGetCollimatorThresholdValue);
- Dispatch->Get.Push(AttrKey::SID, this, &ColliamtorMould::JSGetCollimatorSID);
- Dispatch->Get.Push(AttrKey::FILTER, this, &ColliamtorMould::JSGetCollimatorFilter);
- Dispatch->Get.Push(AttrKey::ANGLE, this, &ColliamtorMould::JSGetCollimatorAngle);
- Dispatch->Get.Push(AttrKey::MODE, this, &ColliamtorMould::JSGetCollimatorMode);
- Dispatch->Get.Push(AttrKey::LIGHT, this, &ColliamtorMould::JSGetCollimatorLight);
- Dispatch->Action.Push(ActionKey::SetCollimatorSize, this, &ColliamtorMould::JSSetCollimatorSize);
- Dispatch->Action.Push(ActionKey::SetCollimatorRatio, this, &ColliamtorMould::JSSetCollimatorRatio);
- Dispatch->Action.Push(ActionKey::SetCollimatorSID, this, &ColliamtorMould::JSSetCollimatorSID);
- Dispatch->Action.Push(ActionKey::SetCollimatorFilter, this, &ColliamtorMould::JSSetCollimatorFilter);
- Dispatch->Action.Push(ActionKey::SetCollimatorAngle, this, &ColliamtorMould::JSSetCollimatorAngle);
- Dispatch->Action.Push(ActionKey::SetCollimatorMode, this, &ColliamtorMould::JSSetCollimatorMode);
- Dispatch->Action.Push(ActionKey::SetTechParamsInfo, this, &ColliamtorMould::JSSetTechParamsInfo);
- Dispatch->Action.Push(ActionKey::SetCollimatorLight, this, &ColliamtorMould::JSSetCollimatorLight);
- Dispatch->Action.Push(ActionKey::SetHCollimatorOpen, this, &ColliamtorMould::JSSetHCollimatorOpen);
- Dispatch->Action.Push(ActionKey::SetHCollimatorClose, this, &ColliamtorMould::JSSetHCollimatorClose);
- Dispatch->Action.Push(ActionKey::SetVCollimatorOpen, this, &ColliamtorMould::JSSetVCollimatorOpen);
- Dispatch->Action.Push(ActionKey::SetVCollimatorClose, this, &ColliamtorMould::JSSetVCollimatorClose);
- Dispatch->Action.Push(ActionKey::Reset, this, &ColliamtorMould::JSReset);
- }
- //-----------------------------------------------------------------------------
- // 所有的消息响应函数
- //-----------------------------------------------------------------------------
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorSize(std::string in, std::string& out)
- {
- ResDataObject json;
- json.decode(in.c_str());
- int xvalue = atoi(((string)json[0]).c_str());
- int yvalue = atoi(((string)json[1]).c_str());
- return SetCollimatorSize(xvalue, yvalue);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorRatio(std::string in, std::string& out)
- {
- ResDataObject json;
- json.decode(in.c_str());
- float xvalue = atof(((string)json[0]).c_str());
- float yvalue = atof(((string)json[1]).c_str());
- return SetCollimatorRatio(xvalue, yvalue);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorSID(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetCollimatorSID(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorFilter(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetCollimatorFilter(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorAngle(std::string in, std::string& out)
- {
- auto value = JSONTo <float>(in);
- return SetCollimatorAngle(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorMode(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetCollimatorMode(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetCollimatorLight(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetCollimatorLight(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetHCollimatorOpen(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetHCollimatorOpen(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetHCollimatorClose(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetHCollimatorClose(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetVCollimatorOpen(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetVCollimatorOpen(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetVCollimatorClose(std::string in, std::string& out)
- {
- auto value = JSONTo <int>(in);
- return SetVCollimatorClose(value);
- }
- RET_STATUS nsGEN::ColliamtorMould::JSSetTechParamsInfo(std::string in, std::string& out)
- {
- ResDataObject json;
- json.decode(in.c_str());
- TECHPARAM_INFO info;
- info.SetVal(json[0].encode());
- string strcollimatorwidth = info.m_CollimatorWidth;
- string strcollimatorheight = info.m_CollimatorHeight;
- string strcollimatorfilter = info.m_CollimatorFilter;
- string strSID = info.m_SID;
- DWORD Width = 0;
- DWORD Height = 0;
- DWORD dwFilter = 0;
- DWORD dwSID = 0;
- dwSID = (DWORD)atoi(strSID.c_str());
- if (dwSID >= 0)
- {
- SetCollimatorSID(dwSID);
- }
- if (strcollimatorwidth.find("IN") != string::npos)
- {
- Width = (DWORD)(atof(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()) * 2.54);
- }
- else
- {
- Width = (DWORD)(atoi(strcollimatorwidth.substr(0, strcollimatorwidth.size() - 2).c_str()));
- }
- if (strcollimatorheight.find("IN") != string::npos)
- {
- Height = (DWORD)(atof(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()) * 2.54);
- }
- else
- {
- Height = (DWORD)(atoi(strcollimatorheight.substr(0, strcollimatorheight.size() - 2).c_str()));
- }
- if (Width != 0 && Height != 0)
- {
- SetCollimatorSize(Width, Height);
- }
- dwFilter = (DWORD)atoi(strcollimatorfilter.c_str());
- if (dwFilter >= 0)
- {
- SetCollimatorFilter(dwFilter);
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorXSize(std::string& out)
- {
- auto value = GetXSize();
- out= ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorYSize(std::string& out)
- {
- auto value = GetYSize();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorXRatio(std::string& out)
- {
- auto value = GetXRatio();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorYRatio(std::string& out)
- {
- auto value = GetYRatio();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMaxWidth(std::string& out)
- {
- auto value = m_fMaxWidth;
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMaxHigh(std::string& out)
- {
- auto value = m_fMaxHigh;
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorThresholdValue(std::string& out)
- {
- auto value = m_fThresholdValue;
- out = ToJSON(value);
- return RET_STATUS();
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorSID(std::string& out)
- {
- auto value = GetSID();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorFilter(std::string& out)
- {
- auto value = GetFilter();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorAngle(std::string& out)
- {
- auto value = GetAngle();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorMode(std::string& out)
- {
- auto value = GetMode();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSGetCollimatorLight(std::string& out)
- {
- auto value = GetCollimatorLight();
- out = ToJSON(value);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::JSReset(std::string in, std::string& out)
- {
- return Reset();
- }
- RET_STATUS nsGEN::ColliamtorMould::Reset()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //-----------------------------------------------------------------------------
- // 所有的 GetXX 函数
- //-----------------------------------------------------------------------------
- int nsGEN::ColliamtorMould::GetXSize() { return m_CollimatorUnit.m_XRatio->Get(); }
- int nsGEN::ColliamtorMould::GetYSize() { return m_CollimatorUnit.m_YRatio->Get(); }
- int nsGEN::ColliamtorMould::GetXRatio() { return m_CollimatorUnit.m_XSize->Get(); }
- int nsGEN::ColliamtorMould::GetYRatio() { return m_CollimatorUnit.m_YSize->Get(); }
- RET_STATUS nsGEN::ColliamtorMould::SetCollimatorRatio(float xproportion, float yproportion)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //int nsGEN::ColliamtorMould::GetMaxWidth(){ return m_CollimatorUnit.m_MaxWidth->Get();}
- //int nsGEN::ColliamtorMould::GetMaxHigh(){ return m_CollimatorUnit.m_MaxHigh->Get();}
- int nsGEN::ColliamtorMould::GetSID() { return m_CollimatorUnit.m_SID->Get(); }
- int nsGEN::ColliamtorMould::GetFilter() { return m_CollimatorUnit.m_Filter->Get(); }
- int nsGEN::ColliamtorMould::GetAngle() { return m_CollimatorUnit.m_Angle->Get(); }
- int nsGEN::ColliamtorMould::GetMode() { return m_CollimatorUnit.m_Mode->Get(); }
- int nsGEN::ColliamtorMould::GetCollimatorLight() { return m_CollimatorUnit.m_Light->Get(); }
- RET_STATUS nsGEN::ColliamtorMould::SetHCollimatorOpen(bool bStatus)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::SetHCollimatorClose(bool bStatus)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::SetVCollimatorOpen(bool bStatus)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsGEN::ColliamtorMould::SetVCollimatorClose(bool bStatus)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //-----------------------------------------------------------------------------
- // nsGEN::DriverMould
- //-----------------------------------------------------------------------------
- nsGEN::DriverMould::DriverMould ()
- {
- ConfigInfo Vender (ConfKey::DiosType, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(Vender);
- ConfigInfo Model (ConfKey::DiosModel, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(Model);
- EasyJSONEncoder synList;
- synList.Set ("0", "1");
- synList.Set ("1", "2");
- ConfigInfo GenIsConnect (ConfKey::DiosIsConnect, "int", "RW", "FALSE", "");
- GenIsConnect.SetList (synList.ToString ().c_str ());
- m_ConfigInfo.push_back(GenIsConnect);
- ConfigInfo SCFType (ConfKey::DiosSCFType, "string", "R", "TRUE", "");
- m_ConfigInfo.push_back(SCFType);
- EasyJSONEncoder COMList;
- COMList.Set ("0", "COM1");
- COMList.Set ("1", "COM2");
- COMList.Set ("2", "COM3");
- COMList.Set ("3", "COM4");
- COMList.Set ("4", "COM5");
- COMList.Set ("5", "COM6");
- COMList.Set ("6", "COM7");
- COMList.Set ("7", "COM8");
- COMList.Set ("8", "COM9");
- COMList.Set ("9", "COM10");
- COMList.Set ("10", "COM11");
- COMList.Set ("11", "COM12");
- ConfigInfo SCFPort (ConfKey::DiosSCFPort, "string", "RW", "TRUE", "");
- SCFPort.SetList (COMList.ToString ().c_str ());
- m_ConfigInfo.push_back(SCFPort);
- ConfigInfo SCFBaudrate (ConfKey::DiosSCFBaudrate, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(SCFBaudrate);
- ConfigInfo SCFBytesize (ConfKey::DiosSCFBytesize, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(SCFBytesize);
- ConfigInfo SCFParity (ConfKey::DiosSCFParity, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(SCFParity);
- ConfigInfo SCFStopbits (ConfKey::DiosSCFStopbits, "int", "R", "FALSE", "");
- m_ConfigInfo.push_back(SCFStopbits);
- }
- nsGEN::DriverMould::~DriverMould ()
- {
- }
- #ifdef _WIN64
- #ifdef _DEBUG
- static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64D.dll";
- static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64D.dll";
- #else
- static const auto COM_SCFDllName = "Dios.Dev.SerialSCFX64.dll";
- static const auto TCP_SCFDllName = "Dios.Dev.TcpipSCFX64.dll";
- #endif
- #endif
- std::string nsGEN::DriverMould::GetGUID () const
- {
- return DeviceDriverType;
- }
- string nsGEN::DriverMould::GetConnectDLL(string& ConfigFileName)
- {
- string ConnectDLL = COM_SCFDllName;
- ResDataObject r_config, Connection;
- if (!r_config.loadFile(ConfigFileName.c_str()))
- return ConnectDLL;
- if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
- {
- Connection = r_config["CONFIGURATION"]["connections"]["Value"];
- }
- else
- {
- Connection = r_config["CONFIGURATION"]["connections"][0];
- }
- if ((string)Connection["type"] == "COM")
- ConnectDLL = COM_SCFDllName;
- else
- ConnectDLL = TCP_SCFDllName;
- return ConnectDLL;
- }
- ResDataObject nsGEN::DriverMould::GetConnectParam(string& ConfigFileName)
- {
- ResDataObject r_config, Connection;
- if (!r_config.loadFile(ConfigFileName.c_str()))
- return Connection;
- if (r_config["CONFIGURATION"]["connections"].GetKeyCount("Value") > 0)
- {
- Connection = r_config["CONFIGURATION"]["connections"]["Value"];
- }
- else
- {
- Connection = r_config["CONFIGURATION"]["connections"][0];
- }
- return Connection;
- }
- void DIOS::Dev::Detail::Collimator::TransJsonText(ResDataObject& config)
- {
- for (int x = 0; x < config.size(); x++)
- {
- //如果有Value
- if (config[x].GetKeyCount("Value") > 0)
- {
- //mLog::FINFO("TRY COVERT [{$}] VALUE {$}", config.GetKey(x), config[x]["Value"].size() > 0 ? config[x]["Value"].encode() : (const char*)config[x]["Value"]);
- if (config[x]["Value"].size() <= 0)
- {
- string va = (const char*)config[x]["Value"];
- config[x] = va.c_str();
- }
- else
- {
- ResDataObject rest = config[x]["Value"];
- config[x] = rest;
- //mLog::FINFO("convert object [{$}], object {$}", config.GetKey(x), rest.encode());
- }
- }
- //mLog::FINFO("After Convert {$}", config.encode());
- }
- }
|