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.

512 lines
13 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 05/04/2000
  5. // Last modification: 08/10/2003
  6. // Project Intruder Position Indicator
  7. // SUBSYSTEM: Application
  8. // FILE: Application.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of class CApplication
  13. //----------------------------------------------------------------------------
  14. #ifndef __APPLICATION__H__INCLUDED_
  15. #define __APPLICATION__H__INCLUDED_
  16. #include "ServiceDlg.h" // Added by ClassView
  17. #include "EventWnd.h" // Added by ClassView
  18. #define WM_ADD_TARGET (WM_USER+100)
  19. #define WM_SYNCHRONIZATION (WM_USER+101)
  20. //#define USE_FORCED_TIMER
  21. #ifdef USE_FORCED_TIMER
  22. #define WM_TIMER_FORCE (WM_USER+102)
  23. #endif
  24. #include "VideoForWindowsWnd.h"
  25. #include "VideoStaticWnd.h"
  26. #include "CameraDlg.h"
  27. #include "LogFiles.h"
  28. #include "Locator.h"
  29. #include "Preview.h"
  30. #include "Lgs.h"
  31. #include "LgsBR.h"
  32. #include "Profile.h"
  33. #include "Alarm.h"
  34. #include "ReportView.h"
  35. //#include "Polygon.h"
  36. #include "MessageDlg.h"
  37. #include "Fence.h"
  38. #include "AboutDlg.h"
  39. #include "SetupDlg.h"
  40. #include "EventQueue.h" // Added by ClassView
  41. #include "TransferDlg.h" // Added by ClassView
  42. #include "Transform.h"
  43. //#include "Spinner.h" // 23/04/2001
  44. #include "CameraPTZ.h" // 10/12/2001
  45. #include "..\LgLib\Remote\LgRemoteServerTcpIp.h" // 10/12/2001
  46. #include "..\LgLib\Remote\LgRemoteClientTcpIpMaster.h" // 10/12/2001
  47. #include "..\LgLib\Remote\LgRemoteClientTcpIpBoardReceiverClient.h" // 10/12/2001
  48. #include "..\lglib\Remote\LgRemoteInterface.h"
  49. #include "PhoneCallCenter.h"
  50. #include "ReportServer.h" // Added by ClassView
  51. #include "HZMaskDlg.h" // Added by ClassView
  52. #include "ImageButton.h" // Added by ClassView
  53. #include "..\LgLib\Net\LgNetDeviceGPIOLPT.h"
  54. #include "..\LgLib\Net\LgNetDeviceGPIOPCI1762.h"
  55. #include "..\LgLib\Net\LgNetDeviceGPIOCOM.h"
  56. #include "..\Lglib\MaskSchedule\LgMaskSchedule.h" // Added by ClassView
  57. #include "VideoDirectShowStation.h" // Added by ClassView
  58. #include "CalibratePTZDlg.h"
  59. #include "LgWatchDog.h"
  60. enum { MODE_NONE = 0,
  61. MODE_PREALARM = 1,
  62. MODE_MANUAL = 2,
  63. MODE_TARGET_AUTO = 3,
  64. MODE_TARGET_MANUAL = 4 };
  65. struct FLAGS_HOLDER {
  66. volatile BOOL bNeedReboot:1;
  67. volatile BOOL bNeedHome:1;
  68. volatile BOOL bNeedRotate:1;
  69. volatile BOOL bNeedStop:1;
  70. volatile BOOL bNeedTargetCapture:1;
  71. volatile BOOL bNeedPrealarmCapture:1;
  72. volatile BOOL bNeedPtzInquare:1;
  73. volatile BOOL bNeedPtzSave:1;
  74. volatile BOOL bNeedIris:1;
  75. volatile BOOL bNeedWiper:1;
  76. volatile BOOL bNeedDopler : 1;
  77. volatile BOOL bNeedDoplerOFF : 1;
  78. volatile BOOL bIrisMode:1;
  79. volatile BOOL bNeedSwitchNight:1;
  80. volatile BOOL bNeedSwitchDay:1;
  81. volatile BOOL bAlarmMode:1;
  82. volatile BOOL bViewZoneMode[6];
  83. volatile BOOL bConnected:1;
  84. volatile BOOL bFenceMode:1;
  85. volatile BOOL bFenceModeAuto:1;
  86. volatile BOOL bQuit:1;
  87. volatile BOOL bSetupMode:1;
  88. volatile BOOL bEditMode:1;
  89. volatile BOOL bDebugMode:1;
  90. volatile BOOL bNeedRestart:1;
  91. volatile BOOL bFogMode:1;
  92. volatile BOOL bNeedCancelDRD:1;
  93. volatile BOOL bShowWide;
  94. volatile BOOL bShowNormal: 1; // 11/05/2001, Capture video
  95. volatile BOOL bWiperOn : 1;
  96. volatile BOOL bPerformAutoLgsReset : 1;
  97. volatile BOOL bSuperUserMode : 1;
  98. volatile BOOL bVoltageOk : 1;
  99. volatile BOOL bDoplerOn : 1;
  100. };
  101. struct CLASSES_HOLDER {
  102. CVideoWnd *pVideoWnd;
  103. CVideoWnd *pFixedVideoWnd;
  104. // Spinner *pIndicator; // Instend of class CIndicator class Spinner 23/04/2001
  105. CCameraDlg *pCameraDlg;
  106. CLgsRadarWnd *pLocator;
  107. CPreview *pPreview;
  108. CLogFiles *pLog;
  109. CCameraPtz *pPTZ;
  110. CLgs *pLgs;
  111. CProfile *pProfile;
  112. CAlarm *pAlarm;
  113. CReportView *pReportView;
  114. CMessageDlg *pMessageDlg;
  115. CFence *pFence;
  116. CSetupDlg *pSetupDlg;
  117. transform_3* pTransformMaster; // For remote camera master, 10/04/2001
  118. transform_3* pTransformSlave; // For remote camera slave,10/04/2001
  119. };
  120. typedef struct INTERFACE_SKIN
  121. {
  122. RECT rMainVideo[2][2];
  123. RECT rMainFixedVideo[2];
  124. RECT rMainLocatorSmall;
  125. RECT rMainLocatorBig;
  126. RECT rMainEvent;
  127. RECT rMainMask;
  128. RECT rMainService;
  129. RECT rMainCamera;
  130. RECT rMainButtonReset;
  131. RECT rMainButtonResetLGS;
  132. RECT rMainButtonReport;
  133. RECT rMainButtonSound;
  134. RECT rMainButtonScale[3];
  135. RECT rMainDate;
  136. RECT rMainTime;
  137. HBITMAP hMainBackground;
  138. HBITMAP hMainService;
  139. HBITMAP hMainMask;
  140. HBITMAP hMainCamera;
  141. HBITMAP hMainButtonReset;
  142. HBITMAP hMainButtonResetLGS;
  143. HBITMAP hMainButtonReport;
  144. HBITMAP hMainButtonSoundOn;
  145. HBITMAP hMainButtonSoundOff;
  146. HBITMAP hMainButtonScale[3];
  147. RECT rReportImage;
  148. RECT rReportImageSlider;
  149. RECT rReportPreview;
  150. RECT rReportPreviewSlider;
  151. RECT rReportText;
  152. RECT rReportTree;
  153. RECT rReportLocator;
  154. RECT rReportDate;
  155. RECT rReportTime;
  156. RECT rReportButtonDetection;
  157. HBITMAP hReportBackground;
  158. HBITMAP hReportButtonDetection;
  159. }INTERFACE_SKIN;
  160. typedef struct PROGRAM_OPTIONS
  161. {
  162. BOOL bShowCommunicationErrors;
  163. BOOL bShowAll;
  164. }PROGRAM_OPTIONS;
  165. class CApplication;
  166. class CHZMaskSchedule : public CLgMaskSchedule
  167. {
  168. public:
  169. CHZMaskSchedule() { m_pApplication = NULL; }
  170. public:
  171. BOOL Create( CApplication *pApplication );
  172. protected:
  173. virtual void MaskSwitch( CLgMaskScheduleLgsSwitch &arrSwitch );
  174. private:
  175. CApplication *m_pApplication;
  176. };
  177. class CApplication :
  178. public CLgRemoteInterfaceLGS,
  179. public CLgRemoteInterfaceInfo
  180. #ifdef USE_FORCED_TIMER
  181. ,private CLgThread
  182. #endif
  183. {
  184. private:
  185. static LRESULT CALLBACK WndProc_(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  186. public:
  187. CApplication();
  188. ~CApplication();
  189. public:
  190. void ChangeWiper( BOOL bOn );
  191. void ChangeDopler( BOOL bOn );
  192. CLgDeviceLGS::PLGS_BORDER GetBorder();
  193. BOOL DrawMap( HWND );
  194. void ReloadBitmaps();
  195. void RestartLgs(HWND hWnd);
  196. void EnableLgs(BOOL bEnable);
  197. void ResetLgs( BOOL bAsk = TRUE );
  198. void OptionsDlg();
  199. void AddFenceEvent(INT n);
  200. void SetIrisMode(BOOL fDay);
  201. BOOL GetIrisMode();
  202. void ChangeEditMode();
  203. void ChangeSetupMode();
  204. void ShowRotatingIcon();
  205. void ShowReportView();
  206. void SetShowNormal(BOOL fEnable);
  207. void SetFenceMode(BOOL fEnable);
  208. void SetScale(INT n); // 13/05/2001
  209. void AddTarget(char master, const double& angle, const double& range, __int32 device, LONG nWidth );
  210. void Reset( LPCTSTR pReason, BOOL bOnFullReset = TRUE );
  211. void SetMode(INT nMode);
  212. void ChangeCameraMode();
  213. void ChangeViewZoneMode(INT n);
  214. void SetViewZoneMode( INT nMode, BOOL bOn );
  215. void ChangeAlarmMode();
  216. void ChangeFenceMode();
  217. void CaptureImage();
  218. void SetPtz();
  219. BOOL WndMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
  220. HWND GetSafeHwnd() const;
  221. CTargetQueue* GetTargetQueue();
  222. CLgs *GetLgs() { return m_Classes.pLgs; }
  223. CProfile *GetProfile() { return m_Classes.pProfile; }
  224. BOOL CheckStartPassword();
  225. private:
  226. void OnPaint( HWND hWnd );
  227. void OnDraw( HDC hDC );
  228. void OnDrawTime( HDC hDC );
  229. void OnTimer();
  230. void ReadSkin( HINSTANCE hInstance );
  231. void DeleteSkin();
  232. BOOL OnCreate();
  233. BOOL OnClose();
  234. LRESULT OnPowerBroadcast( HWND, WPARAM, LPARAM );
  235. void OnConnection(SYSTEMTIME& st, BOOL bConnected );
  236. void OnPower(SYSTEMTIME& st, BOOL bPowered );
  237. void OnOperationMode( SYSTEMTIME &st, BOOL bDetectionMode );
  238. void CheckIrisSwitchTime(SYSTEMTIME& st);
  239. void CheckFenceSwitchTime(LARGE_INTEGER& li);
  240. void CheckDoplerOFF( LARGE_INTEGER& li );
  241. void CheckFogSwitchTime(LARGE_INTEGER& li);
  242. void CheckReset(SYSTEMTIME& st, LARGE_INTEGER& li);
  243. void CheckPtzCommands(SYSTEMTIME& st, LARGE_INTEGER& li);
  244. void CheckShowTime(SYSTEMTIME& st, LARGE_INTEGER& li);
  245. private:
  246. // volatile LARGE_INTEGER m_LastSyncTime;
  247. volatile LARGE_INTEGER m_LastTargetTime;
  248. volatile LARGE_INTEGER m_FirstTargetTime;
  249. volatile LARGE_INTEGER m_LastFenceTime;
  250. volatile LARGE_INTEGER m_LastFogTime;
  251. volatile LARGE_INTEGER m_LastWideTime;
  252. volatile LARGE_INTEGER m_LastBlindTime;
  253. // volatile INT m_LastSyncVolume;
  254. // volatile INT m_SyncErrorCount;
  255. public:
  256. FLAGS_HOLDER m_Flags;
  257. private:
  258. TARGET_DESCRIPTION m_CaptureTD;
  259. CLASSES_HOLDER m_Classes;
  260. CTargetQueue m_TargetQueue;
  261. CTransferDlg m_TransferDlg;
  262. // SYSTEMTIME m_LastSyncSysTime;
  263. // CPolygons m_Polygons;
  264. DWORD m_nLastSnapShot;
  265. double m_LastTargetAngle;
  266. // double m_LastCameraPan;
  267. HANDLE m_hThreadTimer;
  268. DWORD m_dwThreadID;
  269. DWORD m_LastCaptureTime;
  270. DWORD m_PreviewTime;
  271. HWND m_hWnd;
  272. HWND hwndVideo;
  273. BOOL m_bLgsEnabled;
  274. INT m_nPresetCount;
  275. INT m_CurrentMode;
  276. INT m_CurrentScale;
  277. BOOL m_bSnapShotEnabled;
  278. BOOL m_bFirstTarget;
  279. public:
  280. CCameraPtz* GetCameraPTZ() { return m_Classes.pPTZ; }
  281. public:
  282. BOOL m_bInSetupMode;
  283. public:
  284. CHZMaskSchedule& GetHZMaskSchedule() { return m_HZMaskSchedule; }
  285. private:
  286. virtual BOOL OnRemoteInfoConnect( BOOL bConnected ) { return TRUE; }
  287. virtual BOOL DoRemoteInfoTransfer() { return TRUE; }
  288. virtual BOOL OnRemoteInfoTransfer( PLARGE_INTEGER pTX, PLARGE_INTEGER pRX ) { return TRUE; }
  289. private:
  290. CLgRemoteServerTcpIp m_RemoteServer;
  291. CLgRemoteClientTcpIpMultiIPI m_RemoteClientMaster;
  292. // CLgRemoteClientTcpIpBoardReceiverClient m_BoardReceiverClient;
  293. // CLgsBR m_BoardReceiverLgs;
  294. private:
  295. CReportServer m_ReportServer;
  296. virtual BOOL DoRemoteLgsReset();
  297. virtual BOOL DoRemoteLgsClear();
  298. virtual BOOL DoRemoteLgsBorder();
  299. virtual BOOL DoRemoteLgsSensitivity( BYTE bSensitivity );
  300. virtual BOOL DoRemoteLgsHiddenOn( BOOL bSet, BYTE bHiddenOn );
  301. virtual BOOL DoRemoteLgsConnect();
  302. virtual BOOL DoRemoteLgsPhoto();
  303. virtual BOOL DoRemoteLgsVoltage();
  304. private:
  305. CServiceDlg m_ServiceDlg;
  306. CHZMaskDlg m_MaskDlg;
  307. CEventWnd m_EventWnd;
  308. TCHAR m_pCommandLine[MAX_PATH];
  309. private:
  310. CImageButton m_ButtonReset;
  311. CImageButton m_ButtonReport;
  312. CImageButton m_ButtonSound;
  313. CImageButton m_ButtonResetLGS;
  314. CImageButton m_ButtonScale[3];
  315. private:
  316. INTERFACE_SKIN m_Skin;
  317. public:
  318. INTERFACE_SKIN& GetSkin() { return m_Skin; }
  319. private:
  320. void SetAlarmCheck(BOOL fEnable);
  321. void EnableScales(BOOL fEnable);
  322. void SetScaleCheck(INT n);
  323. void EnableResetLgs( BOOL fEnable );
  324. private:
  325. virtual void OnEvtInputChange( INT nInput, BOOL bOn );
  326. virtual void OnEvtGetInputAll( CLgDeviceGPIO::PGPIO_PINS pPins );
  327. private:
  328. void OnWmDrawMap( HWND hWnd, WPARAM wParam, LPARAM lParam );
  329. void OnWmFullDrawMap( HWND hWnd, WPARAM wParam, LPARAM lParam );
  330. private:
  331. void OnWmLgsResetNotify( HWND hWnd, WPARAM wParam, LPARAM lParam );
  332. private:
  333. void CheckExternalAlarm( LARGE_INTEGER *liTime );
  334. void AddExternalAlarm( double dAngle, LARGE_INTEGER *liTime );
  335. typedef struct PARALEL_PORT_ALARM
  336. {
  337. LARGE_INTEGER liTime;
  338. BOOL bOn;
  339. }PARALEL_PORT_ALARM;
  340. PARALEL_PORT_ALARM m_ParallelAlarm[9];
  341. private:
  342. BOOL m_bExternalAlarmInitiated;
  343. private:
  344. BOOL Capture( TARGET_DESCRIPTION& td );
  345. DWORD m_LastFixedCaptureTime;
  346. private:
  347. CVideoDirectShowStation m_VideoDirectShowStation;
  348. CHZMaskSchedule m_HZMaskSchedule;
  349. public:
  350. CPhoneCallCenter& GetCallCenter() { return m_PhoneCallCenter; }
  351. private:
  352. CPhoneCallCenter m_PhoneCallCenter;
  353. public:
  354. BOOL DrawBorder( BOOL bFast, BOOL bMaster, BOOL bSlave );
  355. void DrawFixedVideo( HDC hDC, RECT& rect, double scale );
  356. private:
  357. BOOL m_bExternalDrawInProgress;
  358. BOOL m_bExternalResetInProgress;
  359. private:
  360. void CheckMessageGPIO( SYSTEMTIME &st, LARGE_INTEGER &li );
  361. private:
  362. CLgNetDeviceGPIOLPT m_GPIOLPT;
  363. CLgNetDeviceGPIOPCI1762 m_GPIOPCI1762;
  364. CLgNetObject m_GPIOMsgSink;
  365. #ifdef USE_FORCED_TIMER
  366. private:
  367. virtual DWORD ThreadProc();
  368. #endif
  369. private:
  370. CCalibratePTZDlg m_CalibratePTZDlg;
  371. private:
  372. void CheckClientTask();
  373. typedef struct CLIENT_TASK
  374. {
  375. enum
  376. {
  377. DO_LGS_BORDER,
  378. DO_LGS_CLEAR,
  379. DO_LGS_HIDDEN_ON,
  380. DO_LGS_PHOTO,
  381. DO_LGS_RESET,
  382. DO_LGS_SENSITIVITY,
  383. DO_LGS_VOLTAGE
  384. } task;
  385. union
  386. {
  387. BYTE bSensitivity;
  388. struct
  389. {
  390. BOOL bSet;
  391. BYTE bHiddenOn;
  392. };
  393. };
  394. }CLIENT_TASK, *PCLIENT_TASK;
  395. CLgQueueP<CLIENT_TASK,100> m_ClientTaskArray;
  396. public:
  397. CLgWatchDog *GetWatchDog() { return m_pWatchDog; }
  398. private:
  399. CLgWatchDog *m_pWatchDog;
  400. public:
  401. PROGRAM_OPTIONS& GetProgramOptions() { return m_ProgramOptions; }
  402. private:
  403. PROGRAM_OPTIONS m_ProgramOptions;
  404. private:
  405. INT m_nRotatingIconStep;
  406. };
  407. inline
  408. HWND CApplication::GetSafeHwnd() const
  409. {
  410. return m_hWnd;
  411. }
  412. inline
  413. CTargetQueue* CApplication::GetTargetQueue()
  414. {
  415. return &m_TargetQueue;
  416. }
  417. inline
  418. void CApplication::RestartLgs(HWND hWnd)
  419. {
  420. m_Classes.pLgs->CmdRestartLgs(hWnd);
  421. }
  422. inline
  423. void CApplication::ReloadBitmaps()
  424. {
  425. m_Classes.pLocator->LoadBitmaps(m_Classes.pProfile);
  426. SetScale(m_CurrentScale);
  427. }
  428. /*
  429. NOTE: CHECK!!!
  430. inline
  431. void CApplication::CheckSnapshot()
  432. {
  433. if((GetTickCount() - m_nLastSnapShot) > (DWORD)m_Classes.pProfile->PtzTime() && m_bSnapShotEnabled )
  434. {
  435. if(m_Classes.pVideoWnd)
  436. m_Classes.pVideoWnd->Snapshot();
  437. m_nLastSnapShot = GetTickCount();
  438. }
  439. }
  440. */
  441. #endif