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.

83 lines
2.3 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: 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. if( !m_Protocol.Create( m_pComm ) )
  37. return FALSE;
  38. SetProtocol( &m_Protocol );
  39. m_pTable[0] = pSwitcher->pTable[0];
  40. m_pTable[1] = pSwitcher->pTable[1];
  41. m_pTable[2] = pSwitcher->pTable[2];
  42. m_nTimeoutCommand = pSwitcher->nReplyTimeout;
  43. m_nTimeoutAfterCommand = pSwitcher->nCommandTimeout;
  44. m_nTimeoutEnterSwitch = pSwitcher->nAutoEnterTimeout * 1000L; // convert to ms
  45. m_nTimeoutInterSwitch = pSwitcher->nAutoSwitchTimeout * 1000L; // convert to ms
  46. m_nSwitchMode = pSwitcher->nAutoMode;
  47. return TRUE;
  48. }
  49. void CCameraNesherPTZ::Destroy()
  50. {
  51. m_Protocol.Destroy();
  52. if( m_pComm )
  53. {
  54. m_pComm->Destroy();
  55. m_pComm = NULL;
  56. }
  57. }
  58. BOOL CCameraNesherPTZ::CmdSetPTZ( PTZ_DEGREE dPan, PTZ_DEGREE dTilt, PTZ_PERCENT dZoom )
  59. {
  60. if ( dPan > m_pTable[2] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 4 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  61. else if ( dPan > m_pTable[1] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 3 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  62. else if ( dPan > m_pTable[0] ) dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 2 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  63. else dPan = (LGS_MIRROR_ANGLE_OF_VIEW * 1 / 4 - LGS_MIRROR_ANGLE_OF_VIEW / 8);
  64. return CLgDevicePTZNesher::CmdSetPTZ( dPan, dTilt, dZoom );
  65. }
  66. #endif // EMBEDDED_CAMERA_NESHER