CCOS.Dev.FPDDeviceMould.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // CCOS.Dev.FPDDriverMould.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "FileVersion.hpp"
  4. #include "EasyJSONEncoder.hpp"
  5. #include "CCOS.Dev.FPDDeviceMould.hpp"
  6. #include "common_api.h"
  7. #include "LogLocalHelper.h"
  8. #include "Log4CPP.h"
  9. using namespace CCOS::Dev::Detail::Detector;
  10. namespace nsFPD = CCOS::Dev::Detail::Detector;
  11. extern const char* g_szMouldPath;
  12. //Log4CPP::Logger* //gLogger = nullptr;
  13. template <typename _Container, typename T>
  14. inline _Container & operator << (_Container & ar, const T & t)
  15. {
  16. //ar.push_back(t);
  17. return ar;
  18. }
  19. FPDDeviceMould::FPDDeviceMould()
  20. {
  21. m_strIODevicePath = "/Detector";
  22. string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)";
  23. logHostName = "FPDDeviceMould";
  24. // 初始化日志系统
  25. bool ret = initLogModule(
  26. logHostName, // 主机名(用于日志路径中的{host}占位符)
  27. "FPD.Modle", // 唯一模块名
  28. strLogPath, // 配置文件路径
  29. true // 是否输出到控制台(可选)
  30. );
  31. if (!ret) {
  32. std::cerr << "Log init failed!" << std::endl;
  33. return;
  34. }
  35. FPDSetLocalModuleName("FPD.Modle");
  36. //
  37. FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  38. }
  39. FPDDeviceMould::FPDDeviceMould(const std::string& logHostName)
  40. {
  41. m_strIODevicePath = "/Detector";
  42. string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)";
  43. // 初始化日志系统
  44. bool ret = initLogModule(
  45. logHostName, // 主机名(用于日志路径中的{host}占位符)
  46. "FPD.Modle", // 唯一模块名
  47. strLogPath, // 配置文件路径
  48. true // 是否输出到控制台(可选)
  49. );
  50. if (!ret) {
  51. std::cerr << "Log init failed!" << std::endl;
  52. return;
  53. }
  54. FPDSetLocalModuleName("FPD.Modle");
  55. //
  56. FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  57. }
  58. FPDDeviceMould::~FPDDeviceMould()
  59. {
  60. }
  61. nsFPD::FPDDriverMould::FPDDriverMould()
  62. {
  63. }
  64. nsFPD::FPDDriverMould::~FPDDriverMould()
  65. {
  66. }
  67. std::string nsFPD::FPDDriverMould::GetGUID() const
  68. {
  69. return DetectorDriverType;
  70. }
  71. void nsFPD::FPDDriverMould::AddConfig(ConfigInfo config)
  72. {
  73. m_ConfigInfo << config;
  74. }
  75. ConfigInfo::ConfigInfo(const char* Key, const char* strType, const char* strAccess, const char* strRequired, const char* strDefaultValue)
  76. {
  77. strConfKey = Key;
  78. ResDataObject temp;
  79. temp.update(AttributeType, strType);
  80. temp.update(AttributeAccess, strAccess);
  81. temp.update(AttributeRequired, strRequired);
  82. temp.update(AttributeDefaultValue, strDefaultValue);
  83. resDescription = temp.encode();
  84. }
  85. ConfigInfo::~ConfigInfo()
  86. {
  87. }
  88. void ConfigInfo::SetList(const char* str)
  89. {
  90. ResDataObject temp;
  91. temp.decode(resDescription.c_str());
  92. temp.update(AttributeList, str);
  93. resDescription = temp.encode();
  94. }
  95. void ConfigInfo::SetRange(const char* strmin, const char* strmax)
  96. {
  97. ResDataObject temp;
  98. temp.decode(resDescription.c_str());
  99. temp.update(AttributeRangeMin, strmin);
  100. temp.update(AttributeRangeMax, strmax);
  101. resDescription = temp.encode();
  102. }
  103. const char* ConfigInfo::GetDescription()
  104. {
  105. return resDescription.c_str();
  106. }
  107. const char* ConfigInfo::GetCurrentValue()
  108. {
  109. return resValue.c_str();
  110. }
  111. void ConfigInfo::SetCurrentValue(const char* res)
  112. {
  113. resValue = res;
  114. }
  115. const char* ConfigInfo::GetKey()
  116. {
  117. return strConfKey.c_str();
  118. }