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.

941 lines
24 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: kernel_.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of kernel_.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "..\LgLib\Version.h"
  16. #include "Kernel.h"
  17. CKernel::CKernel( PISRPROC pIsrProc ) : CIsr( pIsrProc )
  18. {
  19. m_nInitErrorSkipCounter = 20;
  20. m_pBoard = NULL;
  21. m_pShadow = NULL;
  22. m_pCamera = NULL;
  23. //#ifdef COMM_WITHOUT_INTERRUPTS
  24. m_pCameraComm = NULL;
  25. //#endif
  26. m_pOldIsrProc = NULL; //0722347522
  27. m_bTimerISR = FALSE;
  28. nTimerISRCount = 0;
  29. #ifdef BOARD_NO_RESPONCE_COUNT_INIT
  30. m_nBoardNoRespoceCount = BOARD_NO_RESPONCE_COUNT_INIT;
  31. #endif
  32. m_bRun = TRUE;
  33. m_nSerialNumber = 0;
  34. memset( m_pSerialNumber, 0, sizeof(m_pSerialNumber) );
  35. m_nAddress = 0;
  36. // init error timing
  37. memset( m_dwTimeErrorOverflowSST, 0, sizeof(m_dwTimeErrorOverflowSST)*4 );
  38. memset( m_dwTimeErrorOverflow, 0, sizeof(m_dwTimeErrorOverflow)*4 );
  39. memset( m_dwTimeErrorSun, 0, sizeof(m_dwTimeErrorSun)*4 );
  40. m_dwTimeErrorDelay_EA = 0UL;
  41. m_dwTimeErrorDelay_IQ = 0UL;
  42. m_dwTimePower = 0UL;
  43. #ifdef DETECTION_MULTI_PROFILES
  44. m_bActiveMasterDetectionProfile = 1;
  45. m_bActiveSlaveDetectionProfile = 4;
  46. #endif
  47. #ifndef LGS_PLS_1
  48. m_LRFDisable.bMaster = m_LRFDisable.bSlave = FALSE;
  49. #else
  50. m_LRFDisable.bMaster = FALSE;
  51. #ifdef INFINITE_SAF_STUDY
  52. m_LRFDisable.bSlave = FALSE;
  53. #else
  54. m_LRFDisable.bSlave = TRUE;
  55. #endif
  56. #endif
  57. m_bWaitFirstZero = TRUE;
  58. #ifndef LGS_DISABLE_FILE_SYSTEM
  59. // file system
  60. memset( &m_FileSystemPacket, 0, sizeof(m_FileSystemPacket) );
  61. #endif
  62. // prepare software version
  63. #ifdef LGS_MIRROR
  64. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM,%s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  65. #else
  66. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s", CLgVersion::GetBuildTimeStr(),
  67. #endif
  68. #ifdef BOARD_A2D_FOUR_SAMPLES
  69. "4"
  70. #else
  71. "1"
  72. #endif
  73. #ifdef COMPILE_AS_ANGLES
  74. ",AN"
  75. #endif
  76. #ifdef COMPILE_AS_GETFILE
  77. ",GF"
  78. #endif
  79. #ifdef DEBUG_BOARD_SET_TEST_BIT
  80. ",B"
  81. #endif
  82. #ifdef DEBUG_ENABLE_OLD_BOARD
  83. ",O"
  84. #endif
  85. #ifdef DEBUG_ENABLE_SEND_BOARDDATA
  86. ",S"
  87. #endif
  88. #ifdef COMM_RS485_PREVENT_ECHO
  89. ",E,ASDFGHJJ,"
  90. #endif
  91. #ifdef COMM_WITHOUT_INTERRUPTS
  92. ",I"
  93. #endif
  94. #ifdef BOARD_DEFFERED_PROCESSING
  95. ",D"
  96. #endif
  97. #ifdef BOARD_SUN_BIT_DISABLE
  98. ",S"
  99. #endif
  100. #ifdef LGS_PROTOCOL_TRANSMIT_DELAY
  101. ",T"
  102. #endif
  103. #ifdef BOARD_LINEARIZATION_ENABLE
  104. ",L"
  105. #endif
  106. #ifdef WATCHDOG_ENABLED
  107. ",W"
  108. #endif
  109. #ifdef BOARD_POWER_ENABLE
  110. ",P"
  111. #endif
  112. #ifndef EMBEDDED_CAMERA_DISABLED
  113. ",C"
  114. #endif
  115. #ifdef EMBEDDED_CAMERA_MIGVAN
  116. "O"
  117. #endif
  118. #ifdef EMBEDDED_CAMERA_MIC
  119. "M"
  120. #endif
  121. #ifdef EMBEDDED_CAMERA_JVC
  122. "J"
  123. #endif
  124. #ifdef EMBEDDED_CAMERA_PHILIPS
  125. "B"
  126. #endif
  127. #ifdef EMBEDDED_CAMERA_VICON
  128. "V"
  129. #endif
  130. #ifdef EMBEDDED_CAMERA_PELCO
  131. "P"
  132. #endif
  133. #ifdef EMBEDDED_CAMERA_CHINA
  134. "X"
  135. #endif
  136. #ifdef EMBEDDED_CAMERA_FLIR
  137. "F"
  138. #endif
  139. #ifdef EMBEDDED_CAMERA_HEBRON
  140. "H"
  141. #endif
  142. #ifdef EMBEDDED_CAMERA_AMERICAN_DYNAMICS
  143. "A"
  144. #endif
  145. );
  146. }
  147. CKernel::~CKernel()
  148. {
  149. Destroy();
  150. }
  151. #ifdef DETECTION_MULTI_PROFILES
  152. BOOL CKernel::setActiveDetectionProfile( BYTE profileID ){
  153. if( profileID != m_bActiveMasterDetectionProfile ){
  154. char APFN[32];
  155. FILE *APFD;
  156. if( profileID > 2 ) profileID = 2;
  157. sprintf( APFN, "%c:\\profile.ini", (char)(65+m_pBoard->Get_NVFS()) );
  158. //printf( "Save Settings to: %s\n", APFN );
  159. APFD = fopen( APFN, "w+" );
  160. if( APFD!=NULL ){
  161. fprintf( APFD, "%d\n", profileID );
  162. fclose( APFD );
  163. } else {
  164. //printf( "Cannot access file: %s\n", APFN );
  165. return FALSE;
  166. };
  167. m_bActiveMasterDetectionProfile = profileID;
  168. m_bActiveSlaveDetectionProfile = profileID+3;
  169. return TRUE;
  170. } else {
  171. return FALSE;
  172. };
  173. };
  174. LPCTSTR m_pDetectionProfiles[] = {
  175. { "init_m01.ini" },
  176. { "init_m02.ini" },
  177. { "init_m03.ini" },
  178. { "init_s01.ini" },
  179. { "init_s02.ini" },
  180. { "init_s03.ini" }
  181. };
  182. #endif
  183. #ifdef ALS_300
  184. BOOL CKernel::Create( CBoard *pBoard, CComm485 *pCommPort, CShadow *pShadow, CShadow *pShadowS, CComm485 *pCameraComm, CComm485::PORTS nCameraPort )
  185. #else
  186. BOOL CKernel::Create( CBoard *pBoard, CComm485 *pCommPort, CShadow *pShadow, CComm485 *pCameraComm, CComm485::PORTS nCameraPort )
  187. #endif
  188. {
  189. m_bWaitFirstZero = TRUE;
  190. //#ifdef DEBUG_PRINTOUT_MSGS
  191. // printf( "Destroy If Any..." );
  192. //};
  193. //Destroy();
  194. m_pShadow = pShadow;
  195. m_pBoard = pBoard;
  196. m_pComm485 = pCommPort;
  197. // create transport protocol
  198. #ifdef DEBUG_PRINTOUT_MSGS
  199. debugProcBegin( "Creating Protocol" );
  200. #endif
  201. if( !m_Protocol.Create( pCommPort ) ){
  202. #ifdef DEBUG_PRINTOUT_MSGS
  203. debugProcEnd(0);
  204. #endif
  205. return FALSE;
  206. };
  207. #ifdef DEBUG_PRINTOUT_MSGS
  208. debugProcEnd();
  209. #endif
  210. // assume that no camera
  211. LGS::CAMERA_PARAMETERS cp;
  212. cp.eType = LGS::CAMERA_TYPE_NONE;
  213. cp.nShift = 0;
  214. cp.bAuto = FALSE;
  215. cp.nAutoDelay = 0;
  216. // assume that no relay
  217. LGS::RELAY_PARAMETERS rp;
  218. rp.bAuto = FALSE;
  219. rp.nAutoDelay = 0;
  220. rp.bNormallyClose = FALSE;
  221. // no voltage control by default
  222. LGS::VOLTAGE_PARAMETERS vp;
  223. vp.bControl = FALSE;
  224. // both lasers enabled
  225. m_LRFDisable.bMaster = FALSE;
  226. m_LRFDisable.bSlave = FALSE;
  227. // load settings
  228. #ifdef DEBUG_PRINTOUT_MSGS
  229. debugProcBegin( "KERNEL:Load General Settings" );
  230. #endif
  231. LoadSettings( (PCHAR)m_pSerialNumber, &m_nSerialNumber, &m_nAddress, &cp, &rp, &vp, &m_LRFDisable );
  232. #ifdef DEBUG_PRINTOUT_MSGS
  233. debugProcEnd();
  234. debugProcBegin( "KERNEL:Load User Settings" );
  235. #endif
  236. // load user settings
  237. AUTO_RESET AutoReset;
  238. BOARD_SETTINGS BoardSettings;
  239. SWITCHER_SETTINGS SwitcherSettings;
  240. LoadUserSettings( &AutoReset, &BoardSettings, &SwitcherSettings , pCommPort, pCameraComm );
  241. LoadFSSettings( &AutoReset, &BoardSettings, &SwitcherSettings , pCommPort, pCameraComm );
  242. //Telling the board of Relay Default mode
  243. if( rp.bAuto ){
  244. BoardSettings.RelayDefaultMode = rp.bNormallyClose;
  245. } else {
  246. BoardSettings.RelayDefaultMode = FALSE;
  247. };
  248. #ifdef DEBUG_PRINTOUT_MSGS
  249. debugProcEnd();
  250. debugProcBegin("Allocating Camera Object");
  251. #endif
  252. m_pCamera = new CCamera;
  253. //#ifdef COMM_WITHOUT_INTERRUPTS
  254. m_pCameraComm = pCameraComm;
  255. //#endif
  256. #ifdef DEBUG_PRINTOUT_MSGS
  257. debugProcBegin( "Creating Camera[%d]", cp.eType );
  258. #endif
  259. if( !m_pCamera || !m_pCamera->Create( (LGS::E_CAMERA_TYPE)cp.eType, pCameraComm, nCameraPort, &cp, &SwitcherSettings ) )
  260. {
  261. #ifdef DEBUG_PRINTOUT_MSGS
  262. debugProcEnd(0);
  263. #endif
  264. return FALSE;
  265. }
  266. #ifdef DEBUG_PRINTOUT_MSGS
  267. debugProcEnd();
  268. debugProcEnd();
  269. debugProcBegin("Relay");
  270. #endif
  271. if( !m_Relay.Create( m_pBoard, &rp ) ){
  272. #ifdef DEBUG_PRINTOUT_MSGS
  273. debugProcEnd(0);
  274. #endif
  275. return FALSE;
  276. }
  277. #ifdef DEBUG_PRINTOUT_MSGS
  278. debugProcEnd();
  279. debugProcBegin( "Voltage Control" );
  280. #endif
  281. if( !m_Voltage.Create( &vp ) )
  282. {
  283. #ifdef DEBUG_PRINTOUT_MSGS
  284. debugProcEnd( 0 );
  285. #endif
  286. return FALSE;
  287. }
  288. #ifdef DEBUG_PRINTOUT_MSGS
  289. debugProcEnd();
  290. debugProcBegin("Tracker[0]");
  291. #endif
  292. if( !m_Tracker[0].Create( m_LRFDisable.bMaster, m_pCamera, &m_Relay, &m_AutoReset ) ) {
  293. #ifdef DEBUG_PRINTOUT_MSGS
  294. debugProcEnd( 0 );
  295. #endif
  296. return FALSE;
  297. };
  298. #ifdef DETECT_JUST_MOVING_TARGETS
  299. m_Tracker[0].SetMovingFilter( m_nMovingRadialFilter, m_nMovingDistanceFilter );
  300. m_Tracker[0].SetBlindZoneFilter( m_nBZSAngleFilter, m_nBZEAngleFilter, m_nBZSRangeFilter, m_nBZERangeFilter );
  301. #endif
  302. #ifdef DEBUG_PRINTOUT_MSGS
  303. debugProcEnd();
  304. #endif
  305. #ifndef LGS_MIRROR
  306. #ifndef LGS_PLS_1 // ALS Systems
  307. #ifdef DEBUG_PRINTOUT_MSGS
  308. debugProcBegin("Tracker[1]");
  309. #endif
  310. if( !m_Tracker[1].Create( m_LRFDisable.bSlave, m_pCamera, &m_Relay, &m_AutoReset ) ) {
  311. #ifdef DEBUG_PRINTOUT_MSGS
  312. debugProcEnd( 0 );
  313. #endif
  314. return FALSE;
  315. };
  316. #ifdef DETECT_JUST_MOVING_TARGETS
  317. m_Tracker[1].SetMovingFilter( m_nMovingRadialFilter, m_nMovingDistanceFilter );
  318. m_Tracker[1].SetBlindZoneFilter( m_nBZSAngleFilter, m_nBZEAngleFilter, m_nBZSRangeFilter, m_nBZERangeFilter );
  319. #endif
  320. #ifdef DEBUG_PRINTOUT_MSGS
  321. debugProcEnd();
  322. #endif
  323. #endif
  324. #endif
  325. #ifdef DEBUG_GRAPH_SCREEN_SST
  326. m_Tracker[0].SetIndex(0);
  327. m_Tracker[1].SetIndex(1);
  328. #endif
  329. #ifdef DEBUG_PRINTOUT_MSGS
  330. debugProcBegin( "Detector[0]" );
  331. #endif
  332. #ifdef DETECTION_MULTI_PROFILES
  333. char APFN[32];
  334. FILE *APFD;
  335. sprintf( APFN, "%c:\\profile.ini", (char)( 65+BoardSettings.nHID ) );
  336. //printf("Loading Profile from: %s\n", APFN );
  337. #ifdef DEBUG_PRINTOUT_MSGS
  338. debugProcBegin( "Load Active Detection Profile" );
  339. debug( APFN );
  340. #endif
  341. APFD = fopen( APFN, "r" );
  342. if( APFD!=NULL ){
  343. BYTE profileID;
  344. fscanf( APFD, "%d\n", &m_bActiveMasterDetectionProfile );
  345. m_bActiveSlaveDetectionProfile = m_bActiveMasterDetectionProfile+3;
  346. fclose( APFD );
  347. #ifdef DEBUG_PRINTOUT_MSGS
  348. debugProcEnd();
  349. #endif
  350. } else {
  351. //printf("Apply default profile settings\n");
  352. #ifdef DEBUG_PRINTOUT_MSGS
  353. debugProcEnd( 0 );
  354. #endif
  355. setActiveDetectionProfile( 1 );
  356. };
  357. //printf( "Loadded profile %d\n", m_bActiveMasterDetectionProfile );
  358. #ifdef DEBUG_PRINTOUT_MSGS
  359. debug( ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] );
  360. #endif
  361. #ifdef STORE_FIRST_SAF
  362. #ifdef WATCHDOG_ENABLED
  363. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], &m_WatchDog, LRF_ID_MASTER ) ) {
  364. #else
  365. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], LRF_ID_MASTER ) ) {
  366. #endif
  367. #else
  368. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] ) ) {
  369. #endif
  370. #else
  371. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, "init_m.ini" ) ) {
  372. #endif
  373. #ifdef DEBUG_PRINTOUT_MSGS
  374. debugProcEnd( 0 );
  375. #endif
  376. return FALSE;
  377. }
  378. #ifdef STORE_FIRST_SAF
  379. if( g_bSAFFileEnable ){
  380. m_Detector[0].load_stored_SAF();
  381. };
  382. #endif
  383. #ifdef DEBUG_PRINTOUT_MSGS
  384. debugProcEnd();
  385. #endif
  386. #ifdef LGS_MIRROR
  387. #ifdef DEBUG_PRINTOUT_MSGS
  388. debugProcBegin( "Detector[1]" );
  389. #endif
  390. #ifdef DETECTION_MULTI_PROFILES
  391. #ifdef DEBUG_PRINTOUT_MSGS
  392. debug( ( PCHAR ) m_pDetectionProfiles[m_bActiveSlaveDetectionProfile] );
  393. #endif
  394. #ifdef STORE_FIRST_SAF
  395. #ifdef WATCHDOG_ENABLED
  396. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], &m_WatchDog, LRF_ID_SLAVE ) ) {
  397. #else
  398. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], LRF_ID_SLAVE ) ) {
  399. #endif
  400. #else
  401. if( !m_Detector[1].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] ) ) {
  402. #endif
  403. #else
  404. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, "init_s.ini" ) ){
  405. #endif
  406. #ifdef DEBUG_PRINTOUT_MSGS
  407. debugProcEnd( 0 );
  408. #endif
  409. return FALSE;
  410. };
  411. #ifdef DEBUG_PRINTOUT_MSGS
  412. debugProcEnd();
  413. debugProcBegin( "Detector[2]" );
  414. #endif
  415. #ifdef DETECTION_MULTI_PROFILES
  416. #ifdef DEBUG_PRINTOUT_MSGS
  417. debug( ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] );
  418. #endif
  419. #ifdef STORE_FIRST_SAF
  420. #ifdef WATCHDOG_ENABLED
  421. if( !m_Detector[2].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], &m_WatchDog, LRF_ID_SLAVE ) ) {
  422. #else
  423. if( !m_Detector[2].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], LRF_ID_SLAVE ) ) {
  424. #endif
  425. #else
  426. if( !m_Detector[2].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] ) ) {
  427. #endif
  428. #else
  429. if( !m_Detector[2].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, "init_m.ini" ) ){
  430. #endif
  431. #ifdef DEBUG_PRINTOUT_MSGS
  432. debugProcEnd( 0 );
  433. #endif
  434. return FALSE;
  435. };
  436. #ifdef DEBUG_PRINTOUT_MSGS
  437. debugProcEnd();
  438. debugProcBegin( "Detector[3]" );
  439. #endif
  440. #ifdef DETECTION_MULTI_PROFILES
  441. #ifdef DEBUG_PRINTOUT_MSGS
  442. debug( ( PCHAR )m_pDetectionProfiles[m_bActiveSlaveDetectionProfile] );
  443. #endif
  444. #ifdef STORE_FIRST_SAF
  445. #ifdef WATCHDOG_ENABLED
  446. if( !m_Detector[3].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], &m_WatchDog, LRF_ID_SLAVE ) ) {
  447. #else
  448. if( !m_Detector[3].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], LRF_ID_SLAVE ) ) {
  449. #endif
  450. #else
  451. if( !m_Detector[3].Create( m_LRFDisable.bMaster, &m_Tracker[0], pShadow, 0, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] ) ) {
  452. #endif
  453. #else
  454. if( !m_Detector[3].Create( m_LRFDisable.bSlave, &m_Tracker[0], pShadow, 0, "init_s.ini" ) ){
  455. #endif
  456. #ifdef DEBUG_PRINTOUT_MSGS
  457. debugProcEnd( 0 );
  458. #endif
  459. return FALSE;
  460. };
  461. #ifdef DEBUG_PRINTOUT_MSGS
  462. debugProcEnd();
  463. #endif
  464. #else
  465. #if !defined ( LGS_PLS_1 ) & !defined( LGS_MND ) //ALS Systems
  466. #ifdef DEBUG_PRINTOUT_MSGS
  467. debugProcBegin( "Detector[1]" );
  468. #endif
  469. #ifdef DETECTION_MULTI_PROFILES
  470. #ifdef ALS_300
  471. #ifdef STORE_FIRST_SAF
  472. #ifdef WATCHDOG_ENABLED
  473. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[1], pShadowS, LGS_MAX_DETECTOR_ANGLES / 2, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], &m_WatchDog, LRF_ID_SLAVE ) ) {
  474. #else
  475. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[1], pShadowS, LGS_MAX_DETECTOR_ANGLES / 2, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile], LRF_ID_SLAVE ) ) {
  476. #endif
  477. #else
  478. if( !m_Detector[0].Create( m_LRFDisable.bMaster, &m_Tracker[1], pShadowS, LGS_MAX_DETECTOR_ANGLES / 2, ( PCHAR )m_pDetectionProfiles[m_bActiveMasterDetectionProfile] ) ) {
  479. #endif
  480. #else
  481. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[1], pShadow, LGS_MAX_DETECTOR_ANGLES / 2, ( PCHAR ) m_pDetectionProfiles[m_bActiveSlaveDetectionProfile] ) ) {
  482. #endif
  483. #else
  484. #ifdef ALS_300
  485. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[1], pShadowS, LGS_MAX_DETECTOR_ANGLES / 2, "init_s.ini" ) ){
  486. #else
  487. if( !m_Detector[1].Create( m_LRFDisable.bSlave, &m_Tracker[1], pShadow, LGS_MAX_DETECTOR_ANGLES / 2, "init_s.ini" ) ){
  488. #endif
  489. #endif
  490. #ifdef DEBUG_PRINTOUT_MSGS
  491. debugProcEnd( 0 );
  492. #endif
  493. return FALSE;
  494. };
  495. #ifdef DEBUG_PRINTOUT_MSGS
  496. debugProcEnd();
  497. #endif
  498. #endif
  499. #endif
  500. #ifdef DEBUG_PRINTOUT_MSGS
  501. debugProcBegin( "GetFile Object" );
  502. #endif
  503. if( !m_GetFile.Create() ){
  504. #ifdef DEBUG_PRINTOUT_MSGS
  505. debugProcEnd( 0 );
  506. #endif
  507. return FALSE;
  508. };
  509. #ifdef DEBUG_PRINTOUT_MSGS
  510. debugProcEnd();
  511. #ifndef RANGE_16BIT
  512. debugProcBegin("Calibrator[0]");
  513. #endif
  514. #endif
  515. #ifndef RANGE_16BIT
  516. if( !m_Calibrator[0].Create( "lt0.ini" ) ){
  517. #ifdef DEBUG_PRINTOUT_MSGS
  518. debugProcEnd( 0 ) ;
  519. #endif
  520. return FALSE;
  521. }
  522. #endif
  523. #ifdef DEBUG_PRINTOUT_MSGS
  524. debugProcEnd();
  525. #endif
  526. #ifndef LGS_MIRROR
  527. #ifndef LGS_PLS_1
  528. #ifdef DEBUG_PRINTOUT_MSGS
  529. #ifndef RANGE_16BIT
  530. debugProcBegin("Calibrator[1]");
  531. #endif
  532. #endif
  533. #ifndef RANGE_16BIT
  534. if( !m_Calibrator[1].Create( "lt1.ini" ) ){
  535. #ifdef DEBUG_PRINTOUT_MSGS
  536. debugProcEnd( 0 ) ;
  537. #endif
  538. return FALSE;
  539. }
  540. #endif
  541. #ifdef DEBUG_PRINTOUT_MSGS
  542. debugProcEnd();
  543. #endif
  544. #endif
  545. #endif
  546. #ifdef DEBUG_PRINTOUT_MSGS
  547. debugProcBegin( "Reseting Board" );
  548. #endif
  549. //m_pBoard->AsyncReset();
  550. m_pBoard->Reset();
  551. #ifdef DEBUG_PRINTOUT_MSGS
  552. debugProcEnd( );
  553. #endif
  554. // prepare software version
  555. #ifdef COMPILE_AS_GETFILE
  556. #ifdef LGS_MIRROR
  557. #ifdef LGS_STEPPER
  558. #ifdef RANGE_16BIT
  559. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  560. #else
  561. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  562. #endif
  563. #ifdef NO_EMBED_CAMERA
  564. "LFSSGFX"
  565. #else
  566. "LFSSGF"
  567. #endif
  568. #else
  569. #ifdef RANGE_16BIT
  570. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  571. #else
  572. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  573. #endif
  574. #ifdef NO_EMBED_CAMERA
  575. "LFSGFX"
  576. #else
  577. "LFSGF"
  578. #endif
  579. #endif
  580. #else
  581. #ifdef LGS_PLS_1
  582. #ifdef RANGE_16BIT
  583. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  584. #else
  585. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  586. #endif
  587. #ifdef NO_EMBED_CAMERA
  588. #ifdef LGS_PLS_200
  589. "PLSGFX100"
  590. #else
  591. "PLSGFX1"
  592. #endif
  593. #else
  594. #ifdef LGS_PLS_200
  595. "PLSGFX100"
  596. #else
  597. "PLSGFX1"
  598. #endif
  599. #endif
  600. #else
  601. #ifdef LGS_MND
  602. #ifdef RANGE_16BIT
  603. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(),
  604. #else
  605. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(),
  606. #endif
  607. #ifdef NO_EMBED_CAMERA
  608. "MNDGFX"
  609. #else
  610. "MNDGF"
  611. #endif
  612. #else
  613. #ifdef RANGE_16BIT
  614. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(),
  615. #else
  616. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(),
  617. #endif
  618. #ifdef NO_EMBED_CAMERA
  619. "ALSGFX"
  620. #else
  621. "ALSGF"
  622. #endif
  623. #endif
  624. #endif
  625. #endif // LGS_MIRROR
  626. #else
  627. #ifdef LGS_MIRROR
  628. #ifdef LGS_STEPPER
  629. #ifdef RANGE_16BIT
  630. #ifdef STORE_FIRST_SAF
  631. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  632. #else
  633. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  634. #endif
  635. #else
  636. #ifdef STORE_FIRST_SAF
  637. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  638. #else
  639. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  640. #endif
  641. #endif
  642. #ifdef NO_EMBED_CAMERA
  643. "LFSSX"
  644. #else
  645. "LFSS"
  646. #endif
  647. #else
  648. #ifdef RANGE_16BIT
  649. #ifdef STORE_FIRST_SAF
  650. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s F%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  651. #else
  652. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, 16b %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  653. #endif
  654. #else
  655. #ifdef STORE_FIRST_SAF
  656. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s F%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  657. #else
  658. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %dM, %s%s%s%s%s %s", CLgVersion::GetBuildTimeStr(), LGS_MIRROR,
  659. #endif
  660. #endif
  661. #ifdef NO_EMBED_CAMERA
  662. "LFSX"
  663. #else
  664. "LFS"
  665. #endif
  666. #endif
  667. #else
  668. #ifdef LGS_PLS_1
  669. #ifdef RANGE_16BIT
  670. #ifdef STORE_FIRST_SAF
  671. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  672. #else
  673. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  674. #endif
  675. #else
  676. #ifdef STORE_FIRST_SAF
  677. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  678. #else
  679. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  680. #endif
  681. #endif
  682. #ifdef NO_EMBED_CAMERA
  683. #ifdef LGS_PLS_200
  684. "PLSX100"
  685. #else
  686. "PLSX1"
  687. #endif
  688. #else
  689. #ifdef LGS_PLS_200
  690. "PLS100"
  691. #else
  692. "PLS1"
  693. #endif
  694. #endif
  695. #else
  696. #ifdef LGS_MND
  697. #ifdef RANGE_16BIT
  698. #ifdef STORE_FIRST_SAF
  699. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  700. #else
  701. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  702. #endif
  703. #else
  704. #ifdef STORE_FIRST_SAF
  705. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s F%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  706. #else
  707. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s %s %s", CLgVersion::GetBuildTimeStr(),
  708. #endif
  709. #endif
  710. #ifdef NO_EMBED_CAMERA
  711. "MNDX"
  712. #else
  713. "MND"
  714. #endif
  715. #else
  716. #ifdef RANGE_16BIT
  717. #ifdef STORE_FIRST_SAF
  718. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s F%s %s ", CLgVersion::GetBuildTimeStr(),
  719. #else
  720. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s 16b %s%s%s%s%s %s ", CLgVersion::GetBuildTimeStr(),
  721. #endif
  722. #else
  723. #ifdef STORE_FIRST_SAF
  724. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s F%s %s ", CLgVersion::GetBuildTimeStr(),
  725. #else
  726. s_nSoftwareVersion = sprintf( s_pSoftwareVersion, "%s %s%s%s%s%s %s ", CLgVersion::GetBuildTimeStr(),
  727. #endif
  728. #endif
  729. #ifdef NO_EMBED_CAMERA
  730. #ifdef ALS_300
  731. "ALSX300"
  732. #else
  733. "ALSX"
  734. #endif
  735. #else
  736. #ifdef ALS_300
  737. "ALS300"
  738. #else
  739. "ALS"
  740. #endif
  741. #endif
  742. #endif
  743. #endif
  744. #endif // LGS_MIRROR
  745. #endif // COMPILE_AS_GETFILE
  746. ,( g_bIsDMABoard )?"d":"i"
  747. ,( g_bNoBlackTargets )?"b":""
  748. ,( m_pBoard->m_bBoardBLO )?"BLO":""
  749. ,( g_bWatchDogEnable )?"WD":"NW"
  750. #ifdef STORE_FIRST_SAF
  751. #ifdef INFINITE_SAF_STUDY
  752. ,( g_bSAFFreezEnable )?((m_Detector[0].isSAFFrozen())?((g_bSAFFileEnable)?"F":"M"):"S"):"D"
  753. #else
  754. ,( g_bSAFFreezEnable )?((g_bSAFFileEnable)?"F":"M"):"D"
  755. #endif
  756. #endif
  757. #ifdef LGS_PLS_1
  758. , m_pBoard->GetBFW()
  759. , m_pBoard->GetBSW()
  760. #endif
  761. #ifdef LGS_STEPPER
  762. , m_pBoard->GetBFW()
  763. , m_pBoard->GetBSW()
  764. #endif
  765. #ifdef LGS_MND
  766. , m_pBoard->GetBFW()
  767. , m_pBoard->GetBSW()
  768. #endif
  769. , m_pBoard->GetBSN() );
  770. #ifdef WATCHDOG_ENABLED
  771. // start watchdog
  772. if( g_bWatchDogEnable ){
  773. #ifdef DEBUG_PRINTOUT_MSGS
  774. debugProcBegin( "Watchdog" );
  775. #endif
  776. if( !m_WatchDog.Create() ){
  777. #ifdef DEBUG_PRINTOUT_MSGS
  778. debugProcEnd( 0 );
  779. #endif
  780. return FALSE;
  781. }
  782. #ifdef DEBUG_PRINTOUT_MSGS
  783. debugProcEnd();
  784. #endif
  785. };
  786. #endif
  787. #ifdef DEBUG_PRINTOUT_MSGS
  788. debugProcBegin( "AutoReset" );
  789. #endif
  790. m_AutoReset.Create( &AutoReset );
  791. #ifdef DEBUG_PRINTOUT_MSGS
  792. debugProcEnd();
  793. #endif
  794. return TRUE;
  795. }
  796. void CKernel::Destroy()
  797. {
  798. #ifdef DEBUG_PRINTOUT_MSGS
  799. printf("Kernel Destroy...");
  800. #endif
  801. if( m_pCamera ){
  802. delete m_pCamera;
  803. m_pCamera = NULL;
  804. #ifdef DEBUG_PRINTOUT_MSGS
  805. printf("Camera Destroyed...");
  806. #endif
  807. }
  808. //#ifdef COMM_WITHOUT_INTERRUPTS
  809. m_pCameraComm = NULL;
  810. //#endif
  811. #ifndef COMPILE_AS_GETFILE
  812. if ( m_bTimerISR ){
  813. _dos_setvect( 0x72 , m_pOldIsrProc );
  814. #ifdef DEBUG_PRINTOUT_MSGS
  815. printf("Timer IRQ freed...");
  816. #endif
  817. };
  818. #endif
  819. m_GetFile.Destroy();
  820. #ifdef DEBUG_PRINTOUT_MSGS
  821. printf("GetFile Destroy...");
  822. #endif
  823. m_Protocol.Destroy();
  824. #ifdef DEBUG_PRINTOUT_MSGS
  825. printf("Protocol Destroy...");
  826. #endif
  827. m_Detector[0].Destroy();
  828. #ifdef DEBUG_PRINTOUT_MSGS
  829. printf("Detecor[0] Destroy...");
  830. #endif
  831. #if !defined( LGS_PLS_1 ) && !defined( LGS_MND )
  832. m_Detector[1].Destroy();
  833. #ifdef DEBUG_PRINTOUT_MSGS
  834. printf("Detecor[1] Destroy...");
  835. #endif
  836. #endif
  837. #ifdef LGS_MIRROR
  838. m_Detector[2].Destroy();
  839. #ifdef DEBUG_PRINTOUT_MSGS
  840. printf("Detecor[2] Destroy...");
  841. #endif
  842. m_Detector[3].Destroy();
  843. #ifdef DEBUG_PRINTOUT_MSGS
  844. printf("Detecor[3] Destroy...");
  845. #endif
  846. m_Tracker[0].Destroy();
  847. #ifdef DEBUG_PRINTOUT_MSGS
  848. printf("Tracker[0] Destroy...");
  849. #endif
  850. #else
  851. m_Tracker[0].Destroy();
  852. #ifdef DEBUG_PRINTOUT_MSGS
  853. printf("Tracker[0] Destroy...");
  854. #endif
  855. #if !defined(LGS_PLS_1) && !defined( LGS_MND )
  856. m_Tracker[1].Destroy();
  857. #ifdef DEBUG_PRINTOUT_MSGS
  858. printf("Tracker[1] Destroy...");
  859. #endif
  860. #endif
  861. #endif
  862. m_Voltage.Destroy();
  863. #ifdef DEBUG_PRINTOUT_MSGS
  864. printf("Voltage Ctrl Destroy...");
  865. #endif
  866. m_Relay.Destroy();
  867. #ifdef DEBUG_PRINTOUT_MSGS
  868. printf("Relay Destroy...");
  869. #endif
  870. #ifndef RANGE_16BIT
  871. m_Calibrator[0].Destroy();
  872. #ifdef DEBUG_PRINTOUT_MSGS
  873. printf("Calibrator[0] Destroy...");
  874. #endif
  875. #endif
  876. #ifndef LGS_MIRROR
  877. #if !defined( LGS_PLS_1 ) & !defined( LGS_MND )
  878. #ifndef RANGE_16BIT
  879. m_Calibrator[1].Destroy();
  880. #ifdef DEBUG_PRINTOUT_MSGS
  881. printf("Calibrator[1] Destroy...");
  882. #endif
  883. #endif
  884. #endif
  885. #endif
  886. m_AutoReset.Destroy();
  887. #ifdef DEBUG_PRINTOUT_MSGS
  888. printf("Autoreset Destroy...");
  889. #endif
  890. m_pBoard = NULL;
  891. m_pShadow = NULL;
  892. m_bRun = TRUE;
  893. }