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.

825 lines
20 KiB

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