You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
4.1 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
6 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
  1. #include "rgooseHardwareResource.h"
  2. #define LOG( X ) m_pLog->Log( "HWR", this, X )
  3. #ifdef DEBUG
  4. #define LOG_ERROR( X ) {\
  5. char _tBfrErrMSG2w34[256];\
  6. sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  7. m_pLog->Log( "HWR", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
  8. }
  9. #else
  10. #define LOG_ERROR( X ) m_pLog->Log( "HWR", this, _LOG_ERROR, X );
  11. #endif
  12. argusHardwareResource::argusHardwareResource( uint32_t id, ARGUS_HARDWARE_TYPE type ): basicObject(){
  13. m_bValid = false;
  14. m_pDBC = argusDBC::getInstance();
  15. m_pLog = basicLogCollection::getInstance();
  16. if( id > 0 ){
  17. if( m_pDBC!=NULL ){
  18. DBC_RESOURCE_DATA *tData = m_pDBC->getResourceData( id );
  19. if( tData != NULL ) {
  20. memcpy( &m_sSettings, tData, sizeof(DBC_RESOURCE_DATA));
  21. free( tData );
  22. #ifdef DEBUG
  23. char tBuff[256];
  24. switch( m_sSettings.type ) {
  25. case ARGUS_HARDWARE_USB_DC:{
  26. sprintf( tBuff, "USB Dry Contact [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  27. break;
  28. };
  29. case ARGUS_HARDWARE_IP_VIDEO_IN:{
  30. sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  31. break;
  32. };
  33. case ARGUS_HARDWARE_IP_VIDEO_OUT:{
  34. sprintf( tBuff, "IP Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  35. break;
  36. };
  37. case ARGUS_HARDWARE_IP_UART:{
  38. sprintf( tBuff, "IP UART [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  39. break;
  40. };
  41. case ARGUS_HARDWARE_ANALOG_VIDEO_IN:{
  42. sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  43. break;
  44. };
  45. case ARGUS_HARDWARE_ANALOG_VIDEO_OUT:{
  46. sprintf( tBuff, "Analog Video IN [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  47. break;
  48. };
  49. case ARGUS_HARDWARE_NETWORK_IPV4:{
  50. sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  51. break;
  52. };
  53. case ARGUS_HARDWARE_NETWORK_IPV6:{
  54. sprintf( tBuff, "Network Interface [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  55. break;
  56. };
  57. case ARGUS_HARDWARE_UART:{
  58. sprintf( tBuff, "HW UART [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  59. break;
  60. };
  61. default:{
  62. sprintf( tBuff, "Unknown Resource Type [%d] id: %d aux: %d", m_sSettings.type, id, m_sSettings.aux_id );
  63. break;
  64. };
  65. };
  66. LOG( tBuff );
  67. #endif
  68. } else {
  69. LOG_ERROR("Cannot Fetch Hardware Data from DB!");
  70. memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
  71. m_sSettings.id = id;
  72. m_sSettings.type = type;
  73. };
  74. } else {
  75. LOG_ERROR("No Database Object!");
  76. memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
  77. m_sSettings.id = id;
  78. m_sSettings.type = type;
  79. };
  80. } else {
  81. LOG_ERROR("Resource ID not set!");
  82. memset( &m_sSettings, 0, sizeof( DBC_RESOURCE_DATA ));
  83. m_sSettings.id = id;
  84. m_sSettings.type = type;
  85. };
  86. };
  87. argusHardwareResource::~argusHardwareResource(){
  88. };
  89. #undef LOG
  90. #undef LOG_ERROR