For DOS Protected Mode version of sensor core software
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
3.0 KiB

3 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: cnesher.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of ctks576.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "cnesher.h"
  16. #ifdef EMBEDDED_CAMERA_NESHER
  17. #include "..\lglib\comm\pnesher.cpp"
  18. #include "..\lglib\device\dnesher.cpp"
  19. CCameraNesherPTZ::CCameraNesherPTZ()
  20. {
  21. m_pComm = NULL;
  22. m_pCamera = NULL;
  23. }
  24. CCameraNesherPTZ::~CCameraNesherPTZ()
  25. {
  26. Destroy();
  27. }
  28. BOOL CCameraNesherPTZ::Create( CCamera *pCamera, CComm485* pComm, CComm485::PORTS nPort, LGS::PCAMERA_PARAMETERS pParameters, SWITCHER_SETTINGS *pSwitcher )
  29. {
  30. // destroy old incarnation :)
  31. Destroy();
  32. m_pComm = pComm;
  33. m_pCamera = pCamera;
  34. if( !m_pComm->Create( nPort, 19200L, 8, CComm485::_NOPARITY ) )
  35. return FALSE;
  36. #ifndef COMM_WITHOUT_INTERRUPTS
  37. #ifdef INCLUDE_WINDOWS_DEFINITIONS
  38. m_pComm->SetFCT( FALSE );
  39. #endif
  40. #endif
  41. if( !m_Protocol.Create( m_pComm ) )
  42. return FALSE;
  43. SetProtocol( &m_Protocol );
  44. m_pTable[0] = pSwitcher->pTable[0];
  45. m_pTable[1] = pSwitcher->pTable[1];
  46. m_pTable[2] = pSwitcher->pTable[2];
  47. // printf("Nesher Parameters: Com:%ld ACom:%ld ESw:%ld ISw:%ld\n", (INT32) pSwitcher->nReplyTimeout, (INT32) pSwitcher->nReplyTimeout, (INT32) pSwitcher->nAutoEnterTimeout, (INT32) pSwitcher->nAutoSwitchTimeout );
  48. m_nTimeoutCommand = pSwitcher->nReplyTimeout;
  49. m_nTimeoutAfterCommand = pSwitcher->nCommandTimeout;
  50. #ifdef INCLUDE_WINDOWS_DEFINITIONS
  51. if( g_bIsDMABoard ){
  52. m_nTimeoutEnterSwitch = pSwitcher->nAutoEnterTimeout * 1000L; // convert to ms
  53. m_nTimeoutInterSwitch = pSwitcher->nAutoSwitchTimeout * 1000L; // convert to ms
  54. } else {
  55. #endif
  56. m_nTimeoutEnterSwitch = pSwitcher->nAutoEnterTimeout*1000L; // convert to ms
  57. m_nTimeoutInterSwitch = pSwitcher->nAutoSwitchTimeout*1000L; // convert to ms
  58. #ifdef INCLUDE_WINDOWS_DEFINITIONS
  59. };
  60. #endif
  61. // printf("Nesher Parameters: Com:%ld ACom:%ld ESw:%ld ISw:%ld\n", (INT32) m_nTimeoutCommand, (INT32) m_nTimeoutAfterCommand, (INT32) m_nTimeoutEnterSwitch, (INT32) m_nTimeoutInterSwitch );
  62. m_nSwitchMode = pSwitcher->nAutoMode;
  63. return TRUE;
  64. }
  65. void CCameraNesherPTZ::Destroy()
  66. {
  67. m_Protocol.Destroy();
  68. if( m_pComm )
  69. {
  70. m_pComm->Destroy();
  71. m_pComm = NULL;
  72. }
  73. }
  74. BOOL CCameraNesherPTZ::CmdSetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
  75. {
  76. if ( dPan > m_pTable[2] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 4 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  77. else if ( dPan > m_pTable[1] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 3 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  78. else if ( dPan > m_pTable[0] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 2 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  79. else dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 1 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  80. return CLgDevicePTZNesher::CmdSetPTZ( dPan, dTilt, dZoom );
  81. }
  82. #endif // EMBEDDED_CAMERA_NESHER dos