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.

129 lines
3.5 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 2.0 04/04/2000
  5. // Last modification: 02/06/2001
  6. // Project Intruder Position Indicator
  7. // SUBSYSTEM: Camera navigation
  8. // FILE: Ptz878.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of class CPtz878
  13. //----------------------------------------------------------------------------
  14. #if !defined(__PTZ878__H__INCLUDED__)
  15. #define __PTZ878__H__INCLUDED__
  16. #define RESPONSE_WAIT_TIME 500
  17. #define MAX_PACKET_LENGTH 0x20
  18. class CApplication;
  19. class CProfile;
  20. class CPtz878
  21. {
  22. friend DWORD WINAPI ThreadProcPtz878(LPVOID lpvParam);
  23. public:
  24. CPtz878();
  25. ~CPtz878();
  26. public:
  27. bool IsReady() const;
  28. public:
  29. bool GetReplyData(LPBYTE pPan, LPBYTE pTilt, USHORT *pZoom, LPBYTE pAddress, LPBYTE pSerialNumber);
  30. bool Create(LPCTSTR pCommPort, CProfile *pProfile);
  31. bool CameraPanLeft(BYTE address, BYTE speed);
  32. bool CameraPanRight(BYTE address, BYTE speed);
  33. bool CameraPanStop(BYTE address);
  34. bool CameraTiltUp(BYTE address, BYTE speed);
  35. bool CameraTiltDown(BYTE address, BYTE speed);
  36. bool CameraTiltStop(BYTE address);
  37. bool CameraGotoPosition(BYTE address, BYTE pan, BYTE tilt, WORD zoom);
  38. bool CameraSetAddress(BYTE address, LPBYTE pNumber);
  39. bool CameraZoomTele(BYTE address);
  40. bool CameraZoomWide(BYTE address);
  41. bool CameraZoomStop(BYTE address);
  42. bool CameraInquarePosition(BYTE address);
  43. bool CameraSetFocus(BYTE address, bool manual);
  44. bool CameraSetIris(BYTE address, BYTE iLevel);
  45. bool CameraWarmBoot();
  46. bool CameraQueryAddress();
  47. public:
  48. static INT PanToDegree(BYTE Pan, bool fClockwise = FALSE);
  49. static BYTE DegreeToPan(INT Angle, bool fClockwise = FALSE);
  50. static __int8 DegreToPan(const double& Angle, bool fClockwise = false); // 12/04/2001
  51. static WORD ValueToZoom(WORD value);
  52. static WORD ZoomToValue(WORD zoom);
  53. private:
  54. bool DeinitComm();
  55. bool InitComm(LPCTSTR pCommPort);
  56. DWORD ThreadProc();
  57. private:
  58. bool ProtectCheck();
  59. private:
  60. void ProduceCheckSumAndSize();
  61. void PanRight(BYTE address, BYTE speed);
  62. void PanLeft(BYTE address, BYTE speed);
  63. void PanStop(BYTE address);
  64. void TiltUp(BYTE address, BYTE speed);
  65. void TiltDown(BYTE address, BYTE speed);
  66. void TiltStop(BYTE address);
  67. void SetPreset(BYTE address, BYTE pan, BYTE tilt, BYTE zoomL, BYTE zoomH);
  68. void GotoPreset(BYTE address);
  69. void ZoomTele(BYTE address);
  70. void ZoomWide(BYTE address);
  71. void ZoomStop(BYTE address);
  72. void SetFocus(BYTE address, bool manual);
  73. void SetIris(BYTE address, BYTE iLevel);
  74. void InquarePosition(BYTE address);
  75. void SetAddress(BYTE address, LPBYTE sn);
  76. void QueryAddress();
  77. void WarmBoot();
  78. private:
  79. bool InterpretResponse(DWORD dwReaded);
  80. private:
  81. volatile __int8 m_nReadyCount;// 21/05/2001
  82. volatile bool m_bQuit;
  83. volatile bool m_bTransfer;
  84. volatile bool m_bReady;
  85. private:
  86. CProfile* m_pProfile;
  87. HANDLE m_hThread;
  88. HANDLE m_hCommPort;
  89. DWORD m_nResponseSize;
  90. INT m_ptzCommand;
  91. INT m_nBufferCount;
  92. WORD m_ptzZoom;
  93. BYTE m_pBuffer[MAX_PACKET_LENGTH];
  94. BYTE m_pResponseBuffer[MAX_PACKET_LENGTH];
  95. BYTE m_ReplySN[5];
  96. BYTE m_ptzSN[5];
  97. BYTE m_ReplyPan;
  98. BYTE m_ReplyTilt;
  99. BYTE m_ReplyZoom;
  100. BYTE m_ReplyAddress;
  101. BYTE m_ptzPan;
  102. BYTE m_ptzTilt;
  103. BYTE m_ptzAddress;
  104. };
  105. inline
  106. bool CPtz878::IsReady() const
  107. {
  108. return m_bReady;
  109. }
  110. #endif