Old fashion design for PC-104
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.

194 lines
4.8 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgUISiteEngine.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgUISiteEngine.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgUISiteEngine.h"
  16. #include "LgUISiteCamera.h"
  17. #include "LgUISiteSensorLGS.h"
  18. #include "LgUISiteSensorWnd.h"
  19. #include "LgUISiteTroubleWnd.h"
  20. #include "LgUISiteTroubleListWnd.h"
  21. #include "LgUISiteClock.h"
  22. #include "..\UICamera\LgUICameraEngine.h"
  23. #include "..\UICamera\LgUICameraVideoWnd.h"
  24. #include "..\UIMap\LgUIMapEngine.h"
  25. #include "..\UIMap\LgUIMapWholeWnd.h"
  26. CLgUISiteEngine::CLgUISiteEngine()
  27. {
  28. }
  29. CLgUISiteEngine::~CLgUISiteEngine()
  30. {
  31. DestroyAllObject();
  32. }
  33. BOOL CLgUISiteEngine::OnActivateSensor( CLgUISiteSensor* pSensor )
  34. {
  35. if( !pSensor )
  36. return FALSE;
  37. CLgUISiteSensorWnd *pSensorWnd = *this;
  38. if( !pSensorWnd )
  39. return FALSE;
  40. // set new sensor for sensor property wnd
  41. if( !pSensorWnd->Link( pSensor ) )
  42. return FALSE;
  43. // try to activate camera connected to the sensor
  44. OnActivateVideoCamera( pSensor->GetVideoCamera() );
  45. return TRUE;
  46. }
  47. BOOL CLgUISiteEngine::OnActivateVideoCamera( CLgUISiteCamera* pCamera )
  48. {
  49. if( !pCamera )
  50. return FALSE;
  51. CLgUICameraEngine *pVideoCameraEngine = *this;
  52. if( !pVideoCameraEngine )
  53. return FALSE;
  54. // try to activate video camera
  55. if( !pCamera->CameraActivate( TRUE ) )
  56. return FALSE;
  57. // set it as active camera for video camera engine
  58. return pVideoCameraEngine->SetActiveCamera( pCamera );
  59. }
  60. BOOL CLgUISiteEngine::OnHalCreate( HAL_OBJECT_ID objID, CLgHALCamera* pRouterCamera )
  61. {
  62. // check map engine existance
  63. CLgUIMapEngine *pMapEngine = *this;
  64. if( !pMapEngine )
  65. return FALSE;
  66. // check camera engine existance
  67. CLgUICameraEngine *pCameraEngine = *this;
  68. if( !pCameraEngine )
  69. return FALSE;
  70. // check site clock existance
  71. CLgUISiteClock *pSiteClock = *this;
  72. if( !pSiteClock )
  73. return FALSE;
  74. CLgUISiteCamera *pCamera = new CLgUISiteCamera( objID );
  75. if( !pCamera )
  76. return FALSE;
  77. // Link within site engine
  78. CLgLink<CLgUISiteEngine,CLgUISiteCamera>::Link( pCamera );
  79. // perform router linking
  80. if( !pCamera->CLgHALObject::Link( pRouterCamera ) )
  81. return FALSE;
  82. // Link within map engine
  83. CLgUIMapWholeWnd *pMapWholeWnd = pMapEngine->GetWholeWnd();
  84. if( pMapWholeWnd )
  85. {
  86. if( !pMapWholeWnd->Link( pCamera ) )
  87. return FALSE;
  88. }
  89. // Link within camera engine
  90. if( !pCameraEngine->CLgLink<CLgUICameraEngine,CLgUICamera>::Link( pCamera ) )
  91. return FALSE;
  92. // Link within site clock
  93. if( !pSiteClock->CLgLink<CLgUISiteClock,CLgUISiteCamera>::Link( pCamera ) )
  94. return FALSE;
  95. return TRUE;
  96. }
  97. BOOL CLgUISiteEngine::OnHalCreate( HAL_OBJECT_ID objID, CLgHALSensor* pRouterSensor )
  98. {
  99. // check map engine existance
  100. CLgUIMapEngine *pMapEngine = *this;
  101. if( !pMapEngine )
  102. return FALSE;
  103. CLgUISiteSensorLGS *pSensor = new CLgUISiteSensorLGS( objID );
  104. if( !pSensor )
  105. return FALSE;
  106. // Link within site engine
  107. CLgLink<CLgUISiteEngine,CLgUISiteSensor>::Link( pSensor );
  108. // perform router linking
  109. if( !pSensor->CLgHALObject::Link( pRouterSensor ) )
  110. return FALSE;
  111. // Link within map engine
  112. CLgUIMapWholeWnd *pMapWholeWnd = pMapEngine->GetWholeWnd();
  113. if( pMapWholeWnd )
  114. {
  115. if( !pMapWholeWnd->Link( pSensor ) )
  116. return FALSE;
  117. }
  118. return TRUE;
  119. }
  120. void CLgUISiteEngine::DestroyAllObject()
  121. {
  122. CLgArray< CLgLink<CLgUISiteSensor,CLgUISiteEngine>* >& arrSensor = *this;
  123. CLgArray< CLgLink<CLgUISiteCamera,CLgUISiteEngine>* >& arrCamera = *this;
  124. // delete all dynamic objects
  125. while( arrCamera.GetCount() ) delete *arrCamera[0];
  126. while( arrSensor.GetCount() ) delete *arrSensor[0];
  127. }
  128. BOOL CLgUISiteEngine::OnHalLink( HAL_OBJECT_ID cameraID, HAL_OBJECT_ID sensorID )
  129. {
  130. CLgUISiteCamera *pCamera = NULL;
  131. CLgArray< CLgLink<CLgUISiteCamera,CLgUISiteEngine>* >& arrCamera = *this;
  132. for( INT i = 0; i < arrCamera.GetCount(); i++ )
  133. {
  134. CLgUISiteCamera *pTempCamera = *arrCamera[i];
  135. ASSERT( pTempCamera );
  136. if( pTempCamera->GetHALID() == cameraID )
  137. {
  138. pCamera = pTempCamera;
  139. break;
  140. }
  141. }
  142. if( !pCamera )
  143. return FALSE;
  144. CLgUISiteSensor *pSensor = NULL;
  145. CLgArray< CLgLink<CLgUISiteSensor,CLgUISiteEngine>* >& arrSensor = *this;
  146. for( i = 0; i < arrSensor.GetCount(); i++ )
  147. {
  148. CLgUISiteSensor *pTempSensor = *arrSensor[i];
  149. ASSERT( pTempSensor );
  150. if( pTempSensor->GetHALID() == sensorID )
  151. {
  152. pSensor = pTempSensor;
  153. break;
  154. }
  155. }
  156. if( !pSensor )
  157. return FALSE;
  158. return pCamera->CLgLink<CLgUISiteCamera,CLgUISiteSensor>::Link( pSensor );
  159. }