CCOS.Dev.FPDDeviceMould.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 = getLogHostName();
  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()
  40. {
  41. }
  42. nsFPD::FPDDriverMould::FPDDriverMould()
  43. {
  44. }
  45. nsFPD::FPDDriverMould::~FPDDriverMould()
  46. {
  47. }
  48. std::string nsFPD::FPDDriverMould::GetGUID() const
  49. {
  50. return DetectorDriverType;
  51. }
  52. void nsFPD::FPDDriverMould::AddConfig(ConfigInfo config)
  53. {
  54. m_ConfigInfo << config;
  55. }
  56. ConfigInfo::ConfigInfo(const char* Key, const char* strType, const char* strAccess, const char* strRequired, const char* strDefaultValue)
  57. {
  58. strConfKey = Key;
  59. ResDataObject temp;
  60. temp.update(AttributeType, strType);
  61. temp.update(AttributeAccess, strAccess);
  62. temp.update(AttributeRequired, strRequired);
  63. temp.update(AttributeDefaultValue, strDefaultValue);
  64. resDescription = temp.encode();
  65. }
  66. ConfigInfo::~ConfigInfo()
  67. {
  68. }
  69. void ConfigInfo::SetList(const char* str)
  70. {
  71. ResDataObject temp;
  72. temp.decode(resDescription.c_str());
  73. temp.update(AttributeList, str);
  74. resDescription = temp.encode();
  75. }
  76. void ConfigInfo::SetRange(const char* strmin, const char* strmax)
  77. {
  78. ResDataObject temp;
  79. temp.decode(resDescription.c_str());
  80. temp.update(AttributeRangeMin, strmin);
  81. temp.update(AttributeRangeMax, strmax);
  82. resDescription = temp.encode();
  83. }
  84. const char* ConfigInfo::GetDescription()
  85. {
  86. return resDescription.c_str();
  87. }
  88. const char* ConfigInfo::GetCurrentValue()
  89. {
  90. return resValue.c_str();
  91. }
  92. void ConfigInfo::SetCurrentValue(const char* res)
  93. {
  94. resValue = res;
  95. }
  96. const char* ConfigInfo::GetKey()
  97. {
  98. return strConfKey.c_str();
  99. }