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.

819 lines
20 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: ObjectFactory.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of ObjectFactory.h
  13. //----------------------------------------------------------------------------
  14. #ifndef __OBJECT__FACTORY__H__INCLUDED__
  15. #define __OBJECT__FACTORY__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif // _MSC_VER > 1000
  19. #include "Background.h"
  20. #include "..\..\LgLib\MFC\FileGroup.h"
  21. #include "..\..\LgLib\LgAux.h"
  22. #include "..\..\LgLib\UIMap\LgUIMapBackground.h"
  23. #include "..\..\LgLib\LgString.h"
  24. #include "HiddenZoneList.h"
  25. #include "BorderLGS.h"
  26. #define NORMAL_SIZE 16
  27. #ifndef SETUP_LGS_PROJECT
  28. class CDevice;
  29. class CSensor;
  30. class CVideoDevice;
  31. class CSocket;
  32. class CDirectInput;
  33. class CDirectOutput;
  34. #endif
  35. namespace OFNS
  36. {
  37. enum E_DEVICE_TYPE
  38. {
  39. DT_NONE = -1,
  40. DT_FIRST = 0,
  41. DT_CAMERA = 0, // Fixed camera
  42. DT_MIGVAN_CAMERA = 1,
  43. DT_MIGVAN_VM8X4 = 4,
  44. DT_RABBIT = 2,
  45. DT_RABBIT_CAMERA = 3,
  46. DT_SOCKET = 5,
  47. DT_VIDEO_IN = 6,
  48. DT_LGS = 7,
  49. DT_DRY_CONTACTS = 8,
  50. DT_CLD = 9,
  51. DT_CAMERA_PTZ = 10,
  52. DT_CAMERA_LGS = 11,
  53. DT_PCI_1762 = 12,
  54. DT_COUNT = 13
  55. };
  56. enum E_PIN_TYPE
  57. {
  58. PT_NONE = 0,
  59. PT_VIDEO_IN = 1, // video input
  60. PT_VIDEO_OUT = 2, // video output
  61. PT_RABBIT_CAMERA = 3,// logical connection rabbit with rabbit camera
  62. PT_CAMERA_RABBIT = 4,// logical connection rabbit camera with rabbit
  63. PT_SOCKET_MD = 5, // connection with communication line multi-drop
  64. PT_SOCKET_PTZ = 6, // connection with communication line Migvan PTZ
  65. PT_SOCKET_VM = 7, // connection with communication line Migvan Video Multiplexor
  66. PT_SOCKET_LGS = 8, // connection with communication line single LGS
  67. PT_SOCKET_MIC1300 = 9,// connection with communication line camera MIC1300
  68. PT_SOCKET_TKS576 = 10,// connection with communication line camera TKS576
  69. PT_SOCKET_PG3AD = 11, // connection with communication line camera Philips G3 AutoDome
  70. PT_SOCKET_VICON = 12, // connection with communication line camera Vicon
  71. PT_SOCKET_AMERICAN_DYNAMIS = 13,
  72. PT_LGS_CAMERA = 14,// logical connection LGS with LGS's camera
  73. PT_CAMERA_LGS = 15,// logical connection LGS's camera with LGS
  74. PT_CAMERA_SENSOR = 16,// logical connection camera with sensor
  75. PT_SENSOR_CAMERA = 17,// logical connection sensor with camera
  76. PT_INPUT_SENSOR = 18, // logical connection dry-contact with sensor
  77. PT_SENSOR_INPUT = 19, // logical connection sensor with dry-contact
  78. PT_OUTPUT_EVENT = 20, // logical connection for output to event
  79. PT_EVENT_OUTPUT = 21, // logical connection for event to output
  80. };
  81. enum E_PIN_SUB_TYPE
  82. {
  83. PST_NONE = 0,
  84. PST_SENSOR = 1,
  85. PST_COMMAND = 2,
  86. };
  87. struct PIN_DESC
  88. {
  89. E_PIN_TYPE nPinType;
  90. E_PIN_SUB_TYPE nPinSubType;
  91. E_PIN_TYPE nTruePinType;
  92. int nDeviceMax;
  93. POINT pos;
  94. int nSubIndex;
  95. LPCTSTR pName;
  96. };
  97. class CObjectFactory;
  98. /***************************************************************************
  99. ***************************************************************************/
  100. class COFPin
  101. {
  102. public:
  103. COFPin();
  104. virtual ~COFPin();
  105. // WARNING: Partial initialization, it needs to initiate m_Owner.nIndex!
  106. void Initialize( int nOwnerType, int nOwnerPin, PIN_DESC *pPinDesk );
  107. void Serialize(CArchive& ar);
  108. BOOL IsFree() { return m_nDeviceCount < m_nDeviceMax; }
  109. int GetType() { return m_nPinType; }
  110. int GetSubType() { return m_nPinSubType; }
  111. int GetTrueType() { return m_nTruePinType; }
  112. CString GetName() { return m_Name; }
  113. COLORREF GetColor();
  114. CObjectFactory *GetOF() { return m_pOF; };
  115. int GetParam() { return m_nParam; }
  116. void SetParam( int nParam ) { m_nParam = nParam; }
  117. public:
  118. // WARNING: connect both pins: this and pPin!
  119. BOOL Connect( COFPin *pPin );
  120. // WARNING: disconnect only this pin!
  121. BOOL Disconnect( COFPin *pPin );
  122. public:
  123. struct DID
  124. {
  125. int nType;
  126. int nIndex;
  127. int nPin;
  128. };
  129. DID m_Owner;
  130. int m_nPinType;
  131. int m_nPinSubType;
  132. int m_nTruePinType;
  133. int m_nSubIndex;
  134. DID *m_pDevice;
  135. int m_nDeviceCount;
  136. int m_nDeviceMax;
  137. CPoint m_Pos;
  138. CString m_Name;
  139. int m_nParam;
  140. CObjectFactory *m_pOF;
  141. };
  142. /***************************************************************************
  143. ***************************************************************************/
  144. class COFDevice
  145. {
  146. public:
  147. COFDevice();
  148. virtual ~COFDevice();
  149. virtual int GetType() { return DT_NONE; };
  150. int GetIndex() { return m_nIndex; };
  151. void SetIndex( int nIndex );
  152. CString GetName() { return m_Name; };
  153. void SetName( const CString& name ) { m_Name = name; };
  154. CObjectFactory *GetOF() { return m_pOF; }
  155. virtual void Draw( CDC *pDC, BOOL bActive, CPoint shift, double scale );
  156. // CSize GetSize() { return CSize( 32,32 ); }
  157. public:
  158. void CreatePins( PIN_DESC* pPinDesc, int nCount );
  159. COFPin *GetPin( int nIndex ) { return nIndex < m_nPin ? &m_pPin[ nIndex ] : NULL; }
  160. int GetPinCount() { return m_nPin; }
  161. COFPin *GetFreePin( int nType, int nIndex = 0 );
  162. BOOL IsPossibleToConnect( COFDevice *pDevice );
  163. COFPin *m_pPin;
  164. int m_nPin;
  165. CString m_Name;
  166. CString m_DeviceName;
  167. public:
  168. virtual void Serialize(CArchive& ar);
  169. public:
  170. CLgDPoint m_Pos;
  171. // CPoint m_Pos;
  172. HICON m_hIcon[2];
  173. int m_nIndex;
  174. CObjectFactory *m_pOF;
  175. #ifndef SETUP_LGS_PROJECT
  176. CDevice *m_pDevice;
  177. CDevice *m_pDeviceDO;
  178. CVideoDevice *m_pVideoDevice[2];
  179. CSocket *m_pSocket;
  180. CDirectInput *m_pDI[100];
  181. CDirectOutput *m_pDO[100];
  182. CSensor *m_pSensor;
  183. #endif
  184. };
  185. /***************************************************************************
  186. ***************************************************************************/
  187. class COFDeviceCamera : public COFDevice
  188. {
  189. public:
  190. COFDeviceCamera();
  191. virtual ~COFDeviceCamera();
  192. virtual int GetType(){ return DT_CAMERA; }
  193. };
  194. /***************************************************************************
  195. ***************************************************************************/
  196. class COFDeviceSensor : public COFDevice
  197. {
  198. public:
  199. COFDeviceSensor();
  200. public:
  201. virtual void Serialize(CArchive& ar);
  202. public:
  203. int m_nAddressCCC;
  204. public:
  205. typedef struct TRANSFORM
  206. {
  207. double m_dX;
  208. double m_dY;
  209. double m_dZ;
  210. double m_dPsi;
  211. double m_dTheta;
  212. double m_dPhi;
  213. }TRANSFORM, *PTRANSFORM;
  214. public:
  215. BOOL m_bRemoteCamera;
  216. TRANSFORM m_Transform[2];
  217. enum { LGS_TILT_TABLE_SIZE = 10 };
  218. double m_dTiltTable[LGS_TILT_TABLE_SIZE];
  219. double m_dPanShift;
  220. public:
  221. int m_nImageCount;
  222. };
  223. /***************************************************************************
  224. ***************************************************************************/
  225. class COFDeviceLGS : public COFDeviceSensor
  226. {
  227. public:
  228. enum
  229. {
  230. LGS_CMD_CLEAR = 0,
  231. LGS_CMD_RESET = 1,
  232. LGS_CMD_HZ_1 = 2,
  233. LGS_CMD_HZ_2 = 3,
  234. LGS_CMD_HZ_3 = 4,
  235. LGS_CMD_HZ_4 = 5,
  236. LGS_CMD_HZ_5 = 6,
  237. LGS_EVT_ALARM = 0,
  238. LGS_EVT_POSTALARM = 1,
  239. LGS_EVT_NORMAL = 2,
  240. LGS_EVT_TIMEOUT = 3,
  241. LGS_EVT_HZ_1 = 4,
  242. LGS_EVT_HZ_2 = 5,
  243. LGS_EVT_HZ_3 = 6,
  244. LGS_EVT_HZ_4 = 7,
  245. LGS_EVT_HZ_5 = 8,
  246. };
  247. public:
  248. COFDeviceLGS();
  249. virtual ~COFDeviceLGS();
  250. virtual int GetType(){ return DT_LGS; }
  251. enum{ ST_MULTI, ST_SINGLE };
  252. void ChangeSubType( int nSubType );
  253. virtual void Serialize( CArchive& ar );
  254. public:
  255. virtual CHiddenZoneList *GetHiddenZoneList() { return &m_HiddenZoneList; }
  256. virtual CBorderLGS *GetBorderLGS() { return &m_BorderLGS; }
  257. virtual double GetCommonZero() { return m_dZeroShift; }
  258. void SetLaserData( int MasterOffset, int MasterDelta, int MasterWidth, int MasterOrder, int MasterSST, int MasterFlip,
  259. int SlaveOffset, int SlaveDelta, int SlaveWidth, int SlaveOrder, int SlaveSST, int SlaveFlip );
  260. void GetLaserData( int &MasterOffset, int &MasterDelta, int &MasterWidth, int &MasterOrder, int &MasterSST, int &MasterFlip,
  261. int &SlaveOffset, int &SlaveDelta, int &SlaveWidth, int &SlaveOrder, int &SlaveSST, int &SlaveFlip );
  262. public:
  263. int m_nSubType;
  264. int m_nAddress;
  265. double m_dZeroShift;
  266. double m_dRange;
  267. BOOL m_bZeroClockwise;
  268. protected:
  269. CHiddenZoneList m_HiddenZoneList;
  270. CBorderLGS m_BorderLGS;
  271. protected:
  272. int m_MasterOffset;
  273. int m_MasterDelta;
  274. int m_MasterWidth;
  275. int m_MasterOrder;
  276. int m_MasterSST;
  277. int m_MasterFlip;
  278. int m_SlaveOffset;
  279. int m_SlaveDelta;
  280. int m_SlaveWidth;
  281. int m_SlaveOrder;
  282. int m_SlaveSST;
  283. int m_SlaveFlip;
  284. public:
  285. CLgArray<CString> m_arrCalibrationName;
  286. };
  287. /***************************************************************************
  288. ***************************************************************************/
  289. class COFDeviceCLD :
  290. public COFDeviceSensor
  291. {
  292. public:
  293. enum
  294. {
  295. CLD_CMD_CLEAR = 0,
  296. CLD_CMD_RESET = 1,
  297. CLD_EVT_ALARM = 0,
  298. CLD_EVT_POSTALARM = 1,
  299. CLD_EVT_NORMAL = 2,
  300. CLD_EVT_TIMEOUT = 3,
  301. };
  302. public:
  303. COFDeviceCLD();
  304. virtual ~COFDeviceCLD();
  305. virtual int GetType(){ return DT_CLD; }
  306. virtual void Serialize( CArchive& ar );
  307. public:
  308. void SetParameters( int Offset, int Width, int Flip );
  309. void GetParameters( int& Offset, int& Width, int& Flip );
  310. public:
  311. double GetCommonZero() { return m_dCommonZero; }
  312. public:
  313. int m_nAddress;
  314. public:
  315. int m_nOffset;
  316. int m_nWidth;
  317. int m_nFlip;
  318. public:
  319. double m_dCommonZero;
  320. double m_dRange;
  321. };
  322. /***************************************************************************
  323. ***************************************************************************/
  324. class COFDeviceCameraPTZ :
  325. public COFDevice
  326. {
  327. public:
  328. COFDeviceCameraPTZ();
  329. virtual ~COFDeviceCameraPTZ();
  330. public:
  331. virtual int GetType() { return DT_CAMERA_PTZ; }
  332. virtual void Serialize( CArchive& ar );
  333. public:
  334. enum
  335. {
  336. PTZST_NONE = 0,
  337. PTZST_MIGVAN_878 = 1,
  338. PTZST_MIGVAN_KD6Z = 2,
  339. PTZST_MIC_1_300 = 3,
  340. PTZST_TK_S576 = 4,
  341. PTZST_PG3AD_NEW = 5,
  342. PTZST_VICON = 6,
  343. PTZST_HEBRON = 7,
  344. PTZST_3_TRACK = 8,
  345. PTZST_AMERICAN_DYNAMICS = 9,
  346. PTZST_PG3AD_OLD = 10
  347. };
  348. int GetSubType() { return m_nSubType; };
  349. void ChangeSubType( int nSubType );
  350. public:
  351. int m_nSubType;
  352. public:
  353. struct CAMERA_DATA
  354. {
  355. struct MIGVAN
  356. {
  357. BYTE pHardwareID[5];
  358. BOOL bAuto;
  359. }migvan;
  360. struct MIC_1_300
  361. {
  362. BYTE bAddress;
  363. }mic1300;
  364. struct TK_S_576
  365. {
  366. BYTE bAddress;
  367. }tks576;
  368. struct PG3AD
  369. {
  370. WORD bAddress;
  371. }pg3ad;
  372. struct VICON
  373. {
  374. BYTE bAddress;
  375. }vicon;
  376. struct HEBRON
  377. {
  378. BYTE bAddress;
  379. }hebron;
  380. struct TRI_TRACK
  381. {
  382. BYTE bAddress;
  383. INT nAngle;
  384. DWORD dwTimeout;
  385. }tri_track;
  386. struct AMERICAN_DYNAMICS
  387. {
  388. BYTE bAddress;
  389. }american_dynamics;
  390. }m_uData;
  391. public:
  392. enum { ZF_RANGE_TABLE_SIZE = 10 };
  393. double m_dZoomTable[ZF_RANGE_TABLE_SIZE];
  394. double m_dFocusTable[ZF_RANGE_TABLE_SIZE];
  395. };
  396. /***************************************************************************
  397. ***************************************************************************/
  398. class COFDeviceCameraLGS : public COFDeviceCameraPTZ
  399. {
  400. public:
  401. COFDeviceCameraLGS();
  402. virtual ~COFDeviceCameraLGS();
  403. public:
  404. virtual int GetType() { return DT_CAMERA_LGS; }
  405. };
  406. /***************************************************************************
  407. ***************************************************************************/
  408. class COFDeviceMigvan : public COFDevice
  409. {
  410. public:
  411. COFDeviceMigvan();
  412. virtual ~COFDeviceMigvan();
  413. virtual void Serialize( CArchive& ar );
  414. BYTE m_pHardwareID[5];
  415. BOOL m_bAuto;
  416. };
  417. /***************************************************************************
  418. ***************************************************************************/
  419. /*
  420. class COFDeviceMigvanCameraPTZ : public COFDeviceMigvan
  421. {
  422. public:
  423. COFDeviceMigvanCameraPTZ();
  424. virtual ~COFDeviceMigvanCameraPTZ();
  425. virtual int GetType(){ return DT_MIGVAN_CAMERA; }
  426. };
  427. */
  428. /***************************************************************************
  429. ***************************************************************************/
  430. class COFDeviceMigvanVM8x4 : public COFDeviceMigvan
  431. {
  432. public:
  433. COFDeviceMigvanVM8x4();
  434. virtual ~COFDeviceMigvanVM8x4();
  435. virtual int GetType() { return DT_MIGVAN_VM8X4; }
  436. };
  437. /***************************************************************************
  438. ***************************************************************************/
  439. class COFDeviceRabbit : public COFDevice
  440. {
  441. public:
  442. COFDeviceRabbit();
  443. virtual ~COFDeviceRabbit();
  444. virtual int GetType(){ return DT_RABBIT; }
  445. virtual void Serialize( CArchive& ar );
  446. int m_nAddress;
  447. };
  448. /***************************************************************************
  449. ***************************************************************************/
  450. class COFDevicePCI1762 : public COFDeviceSensor
  451. {
  452. public:
  453. COFDevicePCI1762();
  454. virtual ~COFDevicePCI1762();
  455. virtual int GetType(){ return DT_PCI_1762; }
  456. };
  457. /***************************************************************************
  458. ***************************************************************************/
  459. class COFDeviceRabbitCamera : public COFDevice
  460. {
  461. public:
  462. COFDeviceRabbitCamera();
  463. virtual ~COFDeviceRabbitCamera();
  464. virtual int GetType(){ return DT_RABBIT_CAMERA; }
  465. };
  466. /***************************************************************************
  467. ***************************************************************************/
  468. class COFDeviceSocket : public COFDevice
  469. {
  470. public:
  471. COFDeviceSocket();
  472. virtual ~COFDeviceSocket();
  473. virtual int GetType(){ return DT_SOCKET; }
  474. virtual void Serialize(CArchive& ar);
  475. enum{ ST_MD, ST_PTZ, ST_LGS, ST_VM, ST_DI, ST_MIC1300, ST_TKS576, ST_PG3AD, ST_CCC, ST_VICON, ST_AMERICAN_DYNAMICS };
  476. void ChangeSubType( int nSubType );
  477. public:
  478. int m_nSubType;
  479. CString m_Port;
  480. CString m_BaudRate;
  481. BOOL m_bSpyMode;
  482. BOOL m_bSelfTest;
  483. INT m_nSelfTest;
  484. };
  485. /***************************************************************************
  486. ***************************************************************************/
  487. class COFDeviceVideoIn : public COFDevice
  488. {
  489. public:
  490. COFDeviceVideoIn();
  491. virtual ~COFDeviceVideoIn();
  492. virtual int GetType(){ return DT_VIDEO_IN; }
  493. enum{ ST_GENERIC = 0, ST_NAMED = 1 };
  494. virtual void Serialize(CArchive& ar);
  495. public:
  496. int m_nSubType;
  497. int m_nStandard;
  498. };
  499. /***************************************************************************
  500. ***************************************************************************/
  501. class COFTemplateDCBit
  502. {
  503. public:
  504. COFTemplateDCBit() { m_Name = _T("Noname"); m_Pos.x = m_Pos.y = 0.0; }
  505. COFTemplateDCBit( COFTemplateDCBit& bit ) { m_Pos = bit.m_Pos; m_Name = bit.m_Name; }
  506. ~COFTemplateDCBit() {}
  507. public:
  508. void Serialize(CArchive& ar);
  509. public:
  510. void SetName( CString *pName ) { m_Name = *pName; }
  511. CString& GetName() { return m_Name; }
  512. public:
  513. void SetPos( CLgDPoint *pPoint ) { m_Pos = *pPoint; }
  514. CLgDPoint& GetPos() { return m_Pos; }
  515. public:
  516. CLgDPoint m_Pos; // contacts coordinate (relative to bitmap from 0.0 to 1.0 )
  517. CString m_Name;
  518. };
  519. class COFTemplateDC
  520. {
  521. public:
  522. COFTemplateDC();
  523. ~COFTemplateDC();
  524. public:
  525. static const double defQuality; // 5%
  526. int BitAdd( CLgDPoint *pPoint, CString *pName );
  527. BOOL BitDel( CLgDPoint *pPoint, double q = defQuality );
  528. BOOL BitDel( COFTemplateDCBit *pBit );
  529. BOOL BitDel( int nBit );
  530. BOOL BitGet( CLgDPoint *pPoint, int *pBit, double q = defQuality );
  531. int BitGetCount() const { return m_nCount; }
  532. COFTemplateDCBit *BitGet( int nBit ) { return (nBit<m_nCount) ? m_ppBit[nBit] : NULL; }
  533. CString& GetBG() { return m_NameBG; }
  534. void SetBG( CString& name ) { m_NameBG = name; }
  535. CString& GetName() { return m_Name; }
  536. void SetName( CString& name ) { m_Name = name; }
  537. public:
  538. void Serialize(CArchive& ar);
  539. public:
  540. CObjectFactory *GetOF() { return m_pOF; }
  541. public:
  542. COFTemplateDCBit **m_ppBit;
  543. int m_nCount;
  544. CString m_NameBG; // background name
  545. CString m_Name;
  546. CObjectFactory *m_pOF;
  547. };
  548. class COFDeviceDryContacts : public COFDeviceSensor
  549. {
  550. public:
  551. enum
  552. {
  553. DC_CMD_CLEAR = 0,
  554. DC_CMD_RESET = 1,
  555. DC_EVT_ALARM = 0,
  556. DC_EVT_POSTALARM = 1,
  557. DC_EVT_NORMAL = 2,
  558. DC_EVT_TIMEOUT = 3,
  559. };
  560. public:
  561. COFDeviceDryContacts();
  562. virtual ~COFDeviceDryContacts();
  563. virtual int GetType(){ return DT_DRY_CONTACTS; }
  564. public:
  565. void SetTemplate( int nTemplate );
  566. virtual void Serialize( CArchive& ar );
  567. int m_nTemplate; // index in template array
  568. double m_Pan, m_Tilt, m_Zoom;
  569. private:
  570. static PIN_DESC s_pPD[];
  571. };
  572. /***************************************************************************
  573. ***************************************************************************/
  574. class CObjectFactory
  575. {
  576. public:
  577. CObjectFactory();
  578. virtual ~CObjectFactory();
  579. public:
  580. struct OBJECT
  581. {
  582. int nType;
  583. int nCount;
  584. COFDevice **ppDevice;
  585. }m_pDevice[ DT_COUNT ];
  586. // CMetaFile m_MetaFile;
  587. CSize m_MapSize;
  588. CString m_FileNameBG;
  589. CLgUIMapBackground m_Background;
  590. public:
  591. void SetBackground( LPCTSTR pFileName, bool bNew );
  592. void DeviceDisconnect( COFDevice *pDevice );
  593. CSize *GetMapSize() { return &m_MapSize; }
  594. COFDevice *DeviceGet( CLgDRect &rect );
  595. BOOL ConnectionGet( CPoint p, COFPin **pPin1, COFPin **pPin2, double scale );
  596. COFDevice* DeviceAdd(double x, double y, int nType);
  597. void DeviceDelete( int nIndex, int nType );
  598. void DeviceDelete( COFDevice *pDevice );
  599. COFDevice *DeviceGet(int nIndex, int nType);
  600. void Draw( CDC *pDC, CPoint shift, double scale );
  601. void DrawLine( CDC *pDC, COFPin *pP1, COFPin *pP2, BOOL bActive, CPoint shift, double scale );
  602. void Serialize(CArchive& ar);
  603. void _Serialize(CArchive& ar);
  604. CLgFileGroup* FileGroupGet() { return &m_FileGroup; }
  605. CString FileGroupGetTemp( LPCTSTR pFileName ) { CString name; TCHAR pTemp[MAX_PATH]; m_FileGroup.GetTemp( pFileName, pTemp, MAX_PATH ); return (name = pTemp); }
  606. private:
  607. COFDevice* ClassCreate(int nType);
  608. int DeviceMove( COFDevice *pDevice, int nIndex );
  609. void DrawDevice( CDC *pDC, COFDevice *pDevice, CPoint shift, double scale );
  610. BOOL ConnectionGet( COFDevice *pD, CPoint p, COFPin **pPin1, COFPin **pPin2, double scale );
  611. public:
  612. void ConnectionDisconnect( COFPin *pPin1, COFPin *pPin2 );
  613. BOOL TemplateAdd( COFTemplateDC *pTemplate );
  614. BOOL TemplateDel( COFTemplateDC *pTemplate );
  615. BOOL TemplateDel( int nIndex );
  616. int TemplateGetCount() { return m_nTemplateCount; }
  617. COFTemplateDC* TemplateGet( int nIndex ) { return (nIndex < m_nTemplateCount && nIndex != -1 ) ? m_ppTemplate[nIndex] : NULL; }
  618. private:
  619. COFTemplateDC **m_ppTemplate;
  620. int m_nTemplateCount;
  621. static CString s_Version;
  622. CLgFileGroup m_FileGroup;
  623. public:
  624. BOOL SetProtectedString( CString& str );
  625. BOOL GetProtectedString( CString& str );
  626. BOOL SaveProtectedString( CArchive &ar );
  627. BOOL LoadProtectedString( CArchive &ar );
  628. private:
  629. enum{ MAX_UNIQUE_STRING_LENGTH = 1024 };
  630. INT m_nUniqueString;
  631. BYTE m_pUniqueString[MAX_UNIQUE_STRING_LENGTH];
  632. public:
  633. double& GetMeterScale() { return m_dMeterScale; }
  634. public:
  635. typedef struct SETTINGS
  636. {
  637. BOOL bTroubleWindowShowFirstImage;
  638. }SETTINGS;
  639. public:
  640. SETTINGS& GetSettings() { return m_Settings; }
  641. private:
  642. SETTINGS m_Settings;
  643. private:
  644. double m_dMeterScale;
  645. };
  646. }
  647. #endif