CCOS.Dev.FPDDeviceMould.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "Log4CPP.h"
  8. using namespace CCOS::Dev::Detail::Detector;
  9. namespace nsFPD = CCOS::Dev::Detail::Detector;
  10. extern const char* g_szMouldPath;
  11. //Log4CPP::Logger* //gLogger = nullptr;
  12. template <typename _Container, typename T>
  13. inline _Container & operator << (_Container & ar, const T & t)
  14. {
  15. //ar.push_back(t);
  16. return ar;
  17. }
  18. FPDDeviceMould::FPDDeviceMould()
  19. {
  20. m_strIODevicePath = "/Detector";
  21. string strLogPath = GetProcessDirectory() + R"(\Conf\log_config.xml)";
  22. // 初始化日志系统
  23. if (!Log4CPP::init(logHostName, "FPD.Modle", strLogPath, true)) {
  24. std::cerr << "Failed to initialize log system! Using default configuration." << std::endl;
  25. // 即使配置文件加载失败,也可以继续使用默认配置
  26. }
  27. //
  28. FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  29. }
  30. FPDDeviceMould::~FPDDeviceMould()
  31. {
  32. }
  33. nsFPD::FPDDriverMould::FPDDriverMould()
  34. {
  35. }
  36. nsFPD::FPDDriverMould::~FPDDriverMould()
  37. {
  38. }
  39. std::string nsFPD::FPDDriverMould::GetGUID() const
  40. {
  41. return DetectorDriverType;
  42. }
  43. void nsFPD::FPDDriverMould::AddConfig(ConfigInfo config)
  44. {
  45. m_ConfigInfo << config;
  46. }
  47. ConfigInfo::ConfigInfo(const char* Key, const char* strType, const char* strAccess, const char* strRequired, const char* strDefaultValue)
  48. {
  49. strConfKey = Key;
  50. ResDataObject temp;
  51. temp.update(AttributeType, strType);
  52. temp.update(AttributeAccess, strAccess);
  53. temp.update(AttributeRequired, strRequired);
  54. temp.update(AttributeDefaultValue, strDefaultValue);
  55. resDescription = temp.encode();
  56. }
  57. ConfigInfo::~ConfigInfo()
  58. {
  59. }
  60. void ConfigInfo::SetList(const char* str)
  61. {
  62. ResDataObject temp;
  63. temp.decode(resDescription.c_str());
  64. temp.update(AttributeList, str);
  65. resDescription = temp.encode();
  66. }
  67. void ConfigInfo::SetRange(const char* strmin, const char* strmax)
  68. {
  69. ResDataObject temp;
  70. temp.decode(resDescription.c_str());
  71. temp.update(AttributeRangeMin, strmin);
  72. temp.update(AttributeRangeMax, strmax);
  73. resDescription = temp.encode();
  74. }
  75. const char* ConfigInfo::GetDescription()
  76. {
  77. return resDescription.c_str();
  78. }
  79. const char* ConfigInfo::GetCurrentValue()
  80. {
  81. return resValue.c_str();
  82. }
  83. void ConfigInfo::SetCurrentValue(const char* res)
  84. {
  85. resValue = res;
  86. }
  87. const char* ConfigInfo::GetKey()
  88. {
  89. return strConfKey.c_str();
  90. }