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.

267 lines
7.1 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 2.0 17/04/2000
  5. // Last modification: 08/10/2003
  6. // Project Intruder Position Indicator
  7. // SUBSYSTEM: Profile settings
  8. // FILE: Profile.cpp
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source of implementation of the CProfile class
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\LgLib\Version.h"
  16. #include "Profile.h"
  17. CProfile::CProfile()
  18. {
  19. _tcscpy(m_Data.LgsCommPort, _T("COM3:"));
  20. _tcscpy(m_Data.PtzCommPort, _T("COM4:"));
  21. _tcscpy(m_Data.FenceCommPort, _T("FILE:"));
  22. _tcscpy(m_Data.AlarmCommPort, _T("FILE:"));
  23. m_Data.LgsBaudRate = 19200;
  24. m_Data.LgsBitCount = 7;
  25. m_Data.LgsStopBits = ONESTOPBIT;
  26. m_Data.LgsProtocol = 2;
  27. m_Data.LgsNorth = -1;
  28. m_Data.LgsRange = 150;
  29. m_Data.LgsAutoBaudrate = FALSE;
  30. m_Data.LgsMasterOffset = m_Data.LgsSlaveOffset = 8;
  31. m_Data.LgsMasterDelta = m_Data.LgsSlaveDelta = 160;
  32. m_Data.LgsMasterWidth = m_Data.LgsSlaveWidth = 5400;
  33. m_Data.LgsMasterOrder = m_Data.LgsSlaveOrder = 1;
  34. m_Data.LgsMasterSST = m_Data.LgsSlaveSST = 1;
  35. m_Data.LgsMasterFlip = m_Data.LgsSlaveFlip = 16;
  36. m_Data.LgsTransactionTimeout = 100UL;
  37. m_Data.FogTime = 10 * 60;
  38. m_Data.FogWideTime = 3;
  39. m_Data.FenceTime = 5;
  40. m_Data.ReportHistory = 3;
  41. m_Data.PtzPanShift = 0;
  42. m_Data.PtzPresetMax = 500;
  43. m_Data.PtzIris[0] = 50;
  44. m_Data.PtzIris[1] = 100;
  45. m_Data.PtzTimeNight = 20 * 60;
  46. m_Data.PtzTimeDay = 6 * 60;
  47. m_Data.PtzTilt = 0;
  48. m_Data.PtzSpeed = 25;
  49. m_Data.PtzZoom = 0;
  50. m_Data.PtzTime = 2500;
  51. m_Data.PtzFullTime = 60;
  52. m_Data.PtzRangeZoom[0] = 10;
  53. m_Data.PtzRangeZoom[1] = 10;
  54. m_Data.PtzRangeZoom[2] = 10;
  55. m_Data.PtzRangeZoom[3] = 50;
  56. m_Data.PtzRangeZoom[4] = 50;
  57. m_Data.PtzRangeZoom[5] = 50;
  58. m_Data.PtzRangeZoom[6] = 50;
  59. m_Data.PtzRangeZoom[7] = 80;
  60. m_Data.PtzRangeZoom[8] = 80;
  61. m_Data.PtzRangeZoom[9] = 80;
  62. m_Data.PtzRangeFocus[0] = 10;
  63. m_Data.PtzRangeFocus[1] = 10;
  64. m_Data.PtzRangeFocus[2] = 10;
  65. m_Data.PtzRangeFocus[3] = 50;
  66. m_Data.PtzRangeFocus[4] = 50;
  67. m_Data.PtzRangeFocus[5] = 50;
  68. m_Data.PtzRangeFocus[6] = 50;
  69. m_Data.PtzRangeFocus[7] = 80;
  70. m_Data.PtzRangeFocus[8] = 80;
  71. m_Data.PtzRangeFocus[9] = 80;
  72. m_Data.PtzRangeTilt[0] = 0;
  73. m_Data.PtzRangeTilt[1] = 0;
  74. m_Data.PtzRangeTilt[2] = 0;
  75. m_Data.PtzRangeTilt[3] = 0;
  76. m_Data.PtzRangeTilt[4] = 0;
  77. m_Data.PtzRangeTilt[5] = 0;
  78. m_Data.PtzRangeTilt[6] = 0;
  79. m_Data.PtzRangeTilt[7] = 0;
  80. m_Data.PtzRangeTilt[8] = 0;
  81. m_Data.PtzRangeTilt[9] = 0;
  82. _tcscpy(m_Data.SettingsPassword, _T(""));
  83. _tcscpy(m_Data.SettingsReport, _T("\\REPORT"));
  84. _tcscpy(m_Data.SettingsScreen, _T("Screen08.bmp"));
  85. _tcscpy(m_Data.SettingsScreen020, _T("Screen020.bmp"));
  86. _tcscpy(m_Data.SettingsScreen050, _T("Screen050.bmp"));
  87. _tcscpy(m_Data.SettingsScreen100, _T("Screen100.bmp"));
  88. _tcscpy(m_Data.SettingsTargetTxt, _T("Targets"));
  89. _tcscpy(m_Data.SettingsTargetBmp, _T("Images"));
  90. _tcscpy(m_Data.SettingsLocatorBmp, _T("Locator"));
  91. _tcscpy(m_Data.SettingsPreAlarmBmp, _T("Prealarm"));
  92. // 15/04/2001
  93. m_Data.master_Xc = .0;
  94. m_Data.master_Yc = .0;
  95. m_Data.master_Zc = .0;
  96. m_Data.master_Psi = .0;
  97. m_Data.master_Theta = .0;
  98. m_Data.master_Phi = .0;
  99. m_Data.slave_Xc = .0;
  100. m_Data.slave_Yc = .0;
  101. m_Data.slave_Zc = .0;
  102. m_Data.slave_Psi = .0;
  103. m_Data.slave_Theta = .0;
  104. m_Data.slave_Phi = .0;
  105. m_Data.fRemote = 0;
  106. m_Data.VideoInput = 0;
  107. m_Data.VideoDevice = 0;
  108. m_Data.VideoStretch = TRUE;
  109. m_Data.LgsAutoReset = FALSE;
  110. m_Data.LgsAutoResetTime = 5;
  111. m_Data.VideoStandart = 0;
  112. // m_Data.ImageBitCount = 8;
  113. m_Data.LgsAddress = 0;
  114. m_Data.PtzMigvanSerialNumberManual = FALSE;
  115. memset( m_Data.PtzMigvanSerialNumber, '0', 5 );
  116. m_Data.PtzMic1300Address = 0;
  117. _tcscpy( m_Data.ParallelPort, _T("FILE:") );
  118. m_Data.ParallelEnableHiddenZone = FALSE;
  119. m_Data.ParallelEnableAlarm = FALSE;
  120. memset( m_Data.SettingsSuperPassword, 0, sizeof(m_Data.SettingsSuperPassword) );
  121. m_Data.FixedVideoInput = 1;
  122. m_Data.FixedVideoDevice = 0;
  123. m_Data.FixedVideoStandart = 0;
  124. m_Data.FixedVideoEnable = 0;
  125. m_Data.ExternalControl = ECT_NONE;
  126. m_Data.PCI1762 = 0;
  127. m_Data.LgsAutoBaudrate = FALSE;
  128. m_Data.LgsDisplayClockwise = FALSE;
  129. m_Data.LgsDisplayZeroDir = ZERO_DIR_RIGHT;
  130. m_Data.LgsDisplayZeroShift = 0;
  131. m_Data.WatchDogUserInterfaceTimeout = 30;
  132. m_Data.WatchDogUserInterfaceEnable = FALSE;
  133. m_Data.ReportQualityLocator = 50;
  134. m_Data.ReportQualityImage = 50;
  135. m_Data.CommAlarmDelay = FALSE;
  136. m_Data.CommAlarmDelayValue = 5;
  137. m_Data.DoplerAngle = 15;
  138. m_Data.DoplerTimeout = 300;
  139. Load( "SingleIPI.dat" );
  140. m_FixedVideoRegionArray.Load( "fvpolygon.dat" );
  141. // validate
  142. // if( m_Data.ImageBitCount != 8 && m_Data.ImageBitCount != 24 )
  143. // m_Data.ImageBitCount = 8;
  144. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CProfile::CProfile" );
  145. }
  146. CProfile::~CProfile()
  147. {
  148. Save("SingleIPI.dat");
  149. m_FixedVideoRegionArray.Store( "fvpolygon.dat" );
  150. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CProfile::~CProfile" );
  151. }
  152. void CProfile::Save(LPSTR pFileName)
  153. {
  154. HANDLE hFile = ::CreateFile(pFileName, GENERIC_WRITE,
  155. 0, NULL, CREATE_ALWAYS,
  156. FILE_ATTRIBUTE_NORMAL, NULL);
  157. if(hFile != INVALID_HANDLE_VALUE)
  158. {
  159. DWORD dwWritten;
  160. ::WriteFile(hFile, &m_Data, sizeof(m_Data), &dwWritten, NULL);
  161. ::CloseHandle(hFile);
  162. }
  163. }
  164. BOOL CProfile::Load(LPSTR pFileName)
  165. {
  166. HANDLE hFile = ::CreateFile(pFileName, GENERIC_READ,
  167. 0, NULL, OPEN_EXISTING,
  168. FILE_ATTRIBUTE_NORMAL, NULL);
  169. if(hFile != INVALID_HANDLE_VALUE)
  170. {
  171. DWORD dwWritten;
  172. ::ReadFile(hFile, &m_Data, sizeof(m_Data), &dwWritten, NULL);
  173. ::CloseHandle(hFile);
  174. return TRUE;
  175. }
  176. /*
  177. else // 14/03/2001
  178. ::MessageBox(NULL, _T("File \"Profile.dat\" not found\nProgram to be use default settings"),
  179. _T("Warning!"), MB_ICONWARNING | MB_OK);
  180. */
  181. return FALSE;
  182. }
  183. double CProfile::ConvertToUserCoordinate( double dAngle )
  184. {
  185. return ConvertDisplayToUserCoordinate( ConvertToDisplayCoordinate( dAngle ) );
  186. }
  187. double CProfile::ConvertDisplayToUserCoordinate( double dAngle )
  188. {
  189. switch( m_Data.LgsDisplayZeroDir )
  190. {
  191. default:
  192. case ZERO_DIR_RIGHT: dAngle += 0.0; break;
  193. case ZERO_DIR_DOWN: dAngle += 90.0; break;
  194. case ZERO_DIR_LEFT: dAngle += 180.0; break;
  195. case ZERO_DIR_UP: dAngle += 270.0; break;
  196. }
  197. if( m_Data.LgsDisplayClockwise )
  198. dAngle = 360.0 - dAngle;
  199. while( dAngle >= 360.0 ) dAngle -= 360.0;
  200. while( dAngle < 0.0 ) dAngle += 360.0;
  201. return dAngle;
  202. }
  203. double CProfile::ConvertToDisplayCoordinate( double dAngle )
  204. {
  205. if( m_Data.LgsDisplayClockwise ) dAngle += 360.0 - m_Data.LgsDisplayZeroShift;
  206. else dAngle += (double)m_Data.LgsDisplayZeroShift;
  207. return dAngle;
  208. }
  209. double CProfile::ConvertFromDisplayCoordinate( double dAngle )
  210. {
  211. if( m_Data.LgsDisplayClockwise ) dAngle -= 360.0 - m_Data.LgsDisplayZeroShift;
  212. else dAngle -= (double)m_Data.LgsDisplayZeroShift;
  213. return dAngle;
  214. }