├── .gitattributes ├── .gitignore ├── CentralizedFA ├── Algorithm.cpp ├── Algorithm.h ├── MyBTree.h ├── OutLetSwitch.cpp ├── OutLetSwitch.h ├── SwitchNode.cpp └── SwitchNode.h ├── CommInterface ├── CommFactory.cpp ├── CommFactory.h ├── CommInterface.cpp ├── CommInterface.h ├── CommPara.cpp ├── CommPara.h ├── SerialPort.cpp ├── SerialPort.h ├── ServerInterface.cpp ├── ServerInterface.h ├── TcpClient.cpp ├── TcpClient.h ├── TcpServer.cpp ├── TcpServer.h ├── TcpSession.cpp ├── TcpSession.h ├── UartPort.cpp ├── UartPort.h ├── UdpClient.cpp ├── UdpClient.h ├── UdpServer.cpp ├── UdpServer.h ├── UdpSession.cpp └── UdpSession.h ├── DAT2C-Cywin.mak ├── DAT2C-Vb.mak ├── DAT2C-Vm.mak ├── DAT2C.mak ├── DataBase ├── BF533Terminal.cpp ├── BF533Terminal.h ├── CalcYxDB.cpp ├── CalcYxDB.h ├── CalcYxPoint.cpp ├── CalcYxPoint.h ├── CommPoint.cpp ├── CommPoint.h ├── CosPoint.cpp ├── CosPoint.h ├── CosRecord.cpp ├── CosRecord.h ├── DAOperate.cpp ├── DAOperate.h ├── DAOperateSub.cpp ├── DAOperateSub.h ├── DataRecord.cpp ├── DataRecord.h ├── FaultPoint.cpp ├── FaultPoint.h ├── FaultRecord.cpp ├── FaultRecord.h ├── Line.cpp ├── Line.h ├── LineDB.cpp ├── LineDB.h ├── PriStation.cpp ├── PriStation.h ├── SoePoint.cpp ├── SoePoint.h ├── SoeRecord.cpp ├── SoeRecord.h ├── SubStation.cpp ├── SubStation.h ├── Terminal.cpp ├── Terminal.h ├── TerminalFactroy.cpp ├── TerminalFactroy.h ├── YCPoint.cpp ├── YCPoint.h ├── YcDB.cpp ├── YcDB.h ├── YcHisRecord.cpp ├── YcHisRecord.h ├── YcStatRecord.cpp ├── YcStatRecord.h ├── YcVarPoint.cpp ├── YcVarPoint.h ├── YkCancelState.cpp ├── YkCancelState.h ├── YkDB.cpp ├── YkDB.h ├── YkExeState.cpp ├── YkExeState.h ├── YkPoint.H ├── YkPoint.cpp ├── YkReadyState.cpp ├── YkReadyState.h ├── YkRecord.cpp ├── YkRecord.h ├── YkSelState.cpp ├── YkSelState.h ├── YkState.cpp ├── YkState.h ├── YmDB.cpp ├── YmDB.h ├── YmPoint.cpp ├── YmPoint.h ├── YxDB.cpp ├── YxDB.h ├── YxPoint.cpp └── YxPoint.h ├── DigitalSignature ├── EccPrivateKey.cpp ├── EccPrivateKey.h ├── EccPublicKey.cpp ├── EccPublicKey.h ├── EvpKey.cpp ├── EvpKey.h ├── KeyFactory.cpp ├── KeyFactory.h ├── PrivateKey.cpp ├── PrivateKey.h ├── PublicKey.cpp ├── PublicKey.h ├── RsaPrivateKey.cpp ├── RsaPrivateKey.h ├── RsaPublicKey.cpp ├── RsaPublicKey.h ├── Sm2PrivateKey.cpp ├── Sm2PrivateKey.h ├── Sm2PublicKey.cpp ├── Sm2PublicKey.h ├── SpeEccPrivateKey.cpp ├── SpeEccPrivateKey.h ├── SpeEccPublicKey.cpp ├── SpeEccPublicKey.h └── sm2.h ├── DistributedFA ├── DistributedDA.cpp ├── DistributedDA.h ├── LinkNode.cpp ├── LinkNode.h ├── LoadSwtich.cpp ├── LoadSwtich.h ├── OperateNode.cpp ├── OperateNode.h ├── SWNode.cpp ├── SWNode.h ├── SelfNode.cpp ├── SelfNode.h ├── TieSwitch.cpp └── TieSwitch.h ├── EccSite.key ├── EccSite.pem ├── EccSite2.key ├── EccSite2.pem ├── FileSystem ├── BoostLog.cpp ├── BoostLog.h ├── FileHandle.cpp ├── FileHandle.h ├── Log.cpp ├── Log.h ├── LogFactory.cpp ├── LogFactory.h ├── Markup.cpp ├── Markup.h ├── TextLog.cpp ├── TextLog.h ├── XmlLog.cpp ├── XmlLog.h ├── XmlRecord.cpp └── XmlRecord.h ├── H101Cfg.xml ├── H101NRZBTJ.xml ├── H104Cfg.xml ├── LocalDrive ├── BatteryActive.cpp ├── BatteryActive.h ├── Bluetooth.cpp ├── Bluetooth.h ├── Bluetooth_BF518.cpp ├── Bluetooth_BF518.h ├── DIO.cpp ├── DIO.h ├── DIO_PCM82X.cpp ├── DIO_PCM82X.h ├── DIO_Virtual.cpp ├── DIO_Virtual.h ├── DioFactory.cpp ├── DioFactory.h ├── IEEE1588_TPE3000.cpp ├── IEEE1588_TPE3000.h ├── LightDriver_TPE3000.cpp ├── LightDriver_TPE3000.h ├── WatchDog.cpp ├── WatchDog.h ├── WatchDogFactory.cpp ├── WatchDogFactory.h ├── WatchDog_BF518.cpp ├── WatchDog_BF518.h ├── WatchDog_PCM82X.cpp ├── WatchDog_PCM82X.h ├── WatchDog_TPE3000.cpp ├── WatchDog_TPE3000.h ├── zktylib.h ├── zktylib_dio.h ├── zktylib_led.h └── zktywatchdog.h ├── PDZ800.mak ├── Protocol ├── BF533.cpp ├── BF533.h ├── BF533_CfgFile.cpp ├── BF533_CfgFile.h ├── BF533_DataBase.h ├── CmdQueue.cpp ├── CmdQueue.h ├── EqualComm.cpp ├── EqualComm.h ├── GB_T18657_1.cpp ├── GB_T18657_1.h ├── H101.cpp ├── H101.h ├── H101_B.cpp ├── H101_B.h ├── H101_Transmit.cpp ├── H101_Transmit.h ├── H103.cpp ├── H103.h ├── H103_DigiproII.cpp ├── H103_DigiproII.h ├── H103_MMP_CK.cpp ├── H103_MMP_CK.h ├── H103_MMP_LI.cpp ├── H103_MMP_LI.h ├── H103_NZ.cpp ├── H103_NZ.h ├── H103_NZ_UDP.cpp ├── H103_NZ_UDP.h ├── H104.H ├── H104.cpp ├── H104_Transmit.cpp ├── H104_Transmit.h ├── HCdt_Transmit.cpp ├── HCdt_Transmit.h ├── HTestProcotol.cpp ├── HTestprocotol.h ├── Modbus.cpp ├── Modbus.h ├── ModbusCMD.cpp ├── ModbusCMD.h ├── Protocol.cpp ├── Protocol.h ├── ProtocolFactory.cpp ├── ProtocolFactory.h ├── S101.cpp ├── S101.h ├── S101_518.cpp ├── S101_518.h ├── S101_B.cpp ├── S101_B.h ├── S101_Transmit.cpp ├── S101_Transmit.h ├── S104.cpp ├── S104.h ├── S104_518.cpp ├── S104_518.h ├── S104_Transmit.cpp ├── S104_Transmit.h ├── SCdt_Transmit.cpp ├── SCdt_Transmit.h ├── TestCommInterface.cpp └── TestCommInterface.h ├── PublicSupport ├── CalcPoint.h ├── CircBufDataBase.h ├── Dat2cPublicAPI.h ├── Dat2cTypeDef.h ├── DynamicArrayDataBase.h ├── EfficientRouteTab.cpp ├── EfficientRouteTab.h ├── LoopBuf.cpp ├── LoopBuf.h ├── SpaceRouteTab.cpp ├── SpaceRouteTab.h ├── ZdTimer.cpp ├── ZdTimer.h └── tick_count_timer.h ├── README.md ├── RsaSite.key ├── RsaSite.pem ├── SerialPort.xml ├── Sm2Site.pem ├── binary ├── DAT2C.LinuxX86 └── DAT2C.WIN32.exe ├── cfg ├── BF533Cfg.xml ├── H101_TransmitCfg.xml ├── H103Cfg.xml ├── H103Cfg9.xml ├── H103_NZCfg.xml ├── H103_NZ_UDPCfg.xml ├── H104Cfg.xml ├── H104_TransmitCfg.xml ├── ModbusCfg.xml ├── S101_TransmitCfg.xml ├── S104Cfg.xml ├── S104_TransmitCfg.xml ├── SerialPort.xml ├── SoeRecord.xml ├── VirtualDoCfg.xml ├── YkRecord.xml └── sub-1.xml ├── lib ├── boost_1_53_0_beta1.7z ├── libeay32.lib ├── libsm2.a ├── libzkty_dio-pcm82x.so ├── libzkty_dio.a ├── libzkty_dio.so ├── libzkty_dio.so-glibc2.4 ├── libzkty_led.a ├── openssl-1.0.1c.tar.gz └── zkty_dio.ko ├── posix_main.cpp ├── pubkey.bin ├── pubkey.dat ├── sub-yinc.xml ├── sub22.xml └── win_main.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | 165 | ############ 166 | ## SVN 167 | ############ 168 | .svn/ 169 | 170 | ############ 171 | ## User Specific 172 | ############ 173 | *.log 174 | *.sh 175 | *.backup 176 | DAT2C.idc 177 | DAT2C.rc 178 | DAT2C.vcproj 179 | DAT2C.vcxproj 180 | DAT2C.vcxproj.filters 181 | DAT2C.vpj 182 | DAT2C.vpw 183 | DAT2C.vpwhist 184 | DAT2C.vtg -------------------------------------------------------------------------------- /CentralizedFA/Algorithm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/Algorithm.cpp -------------------------------------------------------------------------------- /CentralizedFA/Algorithm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/Algorithm.h -------------------------------------------------------------------------------- /CentralizedFA/MyBTree.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/MyBTree.h -------------------------------------------------------------------------------- /CentralizedFA/OutLetSwitch.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/OutLetSwitch.cpp -------------------------------------------------------------------------------- /CentralizedFA/OutLetSwitch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/OutLetSwitch.h -------------------------------------------------------------------------------- /CentralizedFA/SwitchNode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/SwitchNode.cpp -------------------------------------------------------------------------------- /CentralizedFA/SwitchNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CentralizedFA/SwitchNode.h -------------------------------------------------------------------------------- /CommInterface/CommFactory.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/CommFactory.cpp -------------------------------------------------------------------------------- /CommInterface/CommFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace CommInterface { 5 | 6 | class CCommInterface; 7 | class CServerInterface; 8 | class CCommPara; 9 | 10 | //typedef boost::shared_ptr share_comm_ptr; 11 | 12 | class CCommFactory 13 | { 14 | public: 15 | ~CCommFactory(void); 16 | static CCommInterface * CreatCommInterface(CCommPara & para,boost::asio::io_service & io_service); 17 | static CServerInterface * CreateServerInterface(CCommPara & para,boost::asio::io_service & io_service); 18 | static bool CompareCommPara(CCommPara & srcPara,CCommPara & dstPara,bool & bServer); 19 | 20 | private: 21 | CCommFactory(void); 22 | static std::string TransCommChannelTypeToString(unsigned char val); 23 | static int TransCommChannelTypeFromString(std::string val); 24 | }; 25 | 26 | };//namespace CommInterface 27 | -------------------------------------------------------------------------------- /CommInterface/CommInterface.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/CommInterface.h -------------------------------------------------------------------------------- /CommInterface/CommPara.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/CommPara.cpp -------------------------------------------------------------------------------- /CommInterface/CommPara.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/CommPara.h -------------------------------------------------------------------------------- /CommInterface/SerialPort.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/SerialPort.cpp -------------------------------------------------------------------------------- /CommInterface/SerialPort.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/SerialPort.h -------------------------------------------------------------------------------- /CommInterface/ServerInterface.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "ServerInterface.h" 5 | #include "CommPara.h" 6 | 7 | namespace CommInterface { 8 | 9 | CServerInterface::CServerInterface(CCommPara & para,boost::asio::io_service& io_service) 10 | :para_(para), 11 | io_service_(io_service) 12 | { 13 | } 14 | 15 | CServerInterface::~CServerInterface(void) 16 | { 17 | } 18 | 19 | int CServerInterface::AddCommPoint(share_commpoint_ptr val) 20 | { 21 | commPoints_.push_back(weak_commpoint_ptr(val)); 22 | 23 | return 0; 24 | } 25 | 26 | int CServerInterface::DelCommPoint(int index) 27 | { 28 | if (index < 0 || index >= getCommPointSum()) 29 | { 30 | return -1; 31 | } 32 | 33 | commPoints_.erase(commPoints_.begin() + index); 34 | 35 | return 0; 36 | } 37 | 38 | weak_commpoint_ptr CServerInterface::getCommPoint(int index) 39 | { 40 | if (index < 0 || index >= getCommPointSum()) 41 | { 42 | throw PublicSupport::dat2def_exception()<, 10 | public CCommInterface 11 | { 12 | public: 13 | CUdpClient(CCommPara & para,boost::asio::io_service & io_service); 14 | virtual ~CUdpClient(void); 15 | 16 | virtual int InitConnect(void); 17 | virtual void UninitConnect(void); 18 | virtual int OpenConnect(void); 19 | virtual int CloseConnect(void); 20 | virtual int RetryConnect(void); 21 | virtual int WriteToConnect(const unsigned char * buf,size_t bytes_transferred); 22 | virtual bool getConnectAlive(void); 23 | 24 | int WriteToBroadCast(const unsigned char * buf,size_t bytes_transferred); 25 | 26 | private: 27 | virtual int ReadFromConnect(unsigned char * buf,size_t bytes_transferred = 0); 28 | void handle_read(unsigned char * buf,const boost::system::error_code& error,size_t bytes_transferred); 29 | void handle_write(const boost::system::error_code& error,size_t bytes_transferred); 30 | udp::endpoint getNextEndPoint(); 31 | 32 | void StartBind(); 33 | 34 | private: 35 | enum 36 | { 37 | max_length = MAX_IP_MTU, 38 | }; 39 | //unsigned short port_; 40 | udp::socket socket_; 41 | 42 | std::vector remoteEndPoints_; 43 | int remoteEndPointIndex_; 44 | 45 | boost::scoped_ptr broadcast_endpoint_; 46 | 47 | unsigned char recv_data_[max_length]; 48 | }; 49 | 50 | }; //namespace CommInterface 51 | -------------------------------------------------------------------------------- /CommInterface/UdpServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/UdpServer.cpp -------------------------------------------------------------------------------- /CommInterface/UdpServer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ServerInterface.h" 4 | 5 | namespace CommInterface { 6 | 7 | using boost::asio::ip::udp; 8 | 9 | class CUdpSession; 10 | 11 | typedef boost::shared_ptr udpsession_ptr; 12 | 13 | class CUdpServer 14 | :public CServerInterface 15 | { 16 | public: 17 | CUdpServer(CCommPara & para,boost::asio::io_service& io_service,unsigned short port); 18 | virtual ~CUdpServer(void); 19 | 20 | virtual int StartServer(); 21 | virtual int InitServer(share_commpoint_ptr comm_point = share_commpoint_ptr()); 22 | int StartReadConnect(); 23 | 24 | private: 25 | void StartBind(); 26 | void CloseSever(); 27 | int AddSession(udpsession_ptr val); 28 | int DelSession(int index); 29 | udpsession_ptr getSession(int index); 30 | int getSessionSum(); 31 | void ClearSessions(); 32 | 33 | void handle_read(unsigned char * buf,const boost::system::error_code& error,size_t bytes_transferred/*,boost::asio::ip::udp::endpoint & remote_endpoint*/); 34 | udpsession_ptr getSessionByIP(boost::asio::ip::address ipVal); 35 | 36 | private: 37 | enum 38 | { 39 | max_length = MAX_IP_MTU, 40 | }; 41 | 42 | size_t port_; 43 | udp::socket socket_; 44 | udp::endpoint remote_endpoint_; 45 | std::vector sessions_; 46 | 47 | unsigned char recv_data_[max_length]; 48 | 49 | 50 | }; 51 | 52 | }; //namespace CommInterface 53 | -------------------------------------------------------------------------------- /CommInterface/UdpSession.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/CommInterface/UdpSession.cpp -------------------------------------------------------------------------------- /CommInterface/UdpSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CommInterface.h" 3 | 4 | namespace CommInterface { 5 | 6 | using boost::asio::ip::udp; 7 | 8 | class CUdpSession : 9 | //public boost::enable_shared_from_this, 10 | public CCommInterface 11 | { 12 | public: 13 | CUdpSession(CCommPara & para,boost::asio::io_service& io_service,udp::socket & socket); 14 | 15 | virtual ~CUdpSession(void); 16 | 17 | virtual int InitConnect(void); 18 | virtual void UninitConnect(void); 19 | virtual int OpenConnect(void); 20 | virtual int CloseConnect(void); 21 | virtual int RetryConnect(void); 22 | virtual int WriteToConnect(const unsigned char * buf, size_t bytes_transferred); 23 | virtual int ReadFromConnect(unsigned char * buf, size_t bytes_transferred = 0); 24 | virtual bool getConnectAlive(void); 25 | 26 | int WriteToBroadCast(const unsigned char * buf,size_t bytes_transferred); 27 | 28 | bool MatchRemoteIP(boost::asio::ip::address ipVal); 29 | 30 | private: 31 | void handle_write(const boost::system::error_code& error,size_t bytes_transferred); 32 | udp::endpoint getNextEndPoint(); 33 | 34 | private: 35 | udp::socket & socket_; 36 | //boost::asio::ip::udp::endpoint remote_endpoint_; 37 | std::vector remoteEndPoints_; 38 | int remoteEndPointIndex_; 39 | 40 | boost::scoped_ptr broadcast_endpoint_; 41 | }; 42 | 43 | }; //namespace CommInterface 44 | -------------------------------------------------------------------------------- /DataBase/BF533Terminal.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/BF533Terminal.cpp -------------------------------------------------------------------------------- /DataBase/BF533Terminal.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/BF533Terminal.h -------------------------------------------------------------------------------- /DataBase/CalcYxDB.cpp: -------------------------------------------------------------------------------- 1 | #include "CalcYxDB.h" 2 | #include "CalcYxPoint.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CCalcYxDB::CCalcYxDB(void) 8 | { 9 | } 10 | 11 | CCalcYxDB::~CCalcYxDB(void) 12 | { 13 | } 14 | 15 | int CCalcYxDB::InitDataBase(FileSystem::CMarkup & xml) 16 | { 17 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 18 | } 19 | 20 | void CCalcYxDB::SaveXmlCfg(FileSystem::CMarkup & xml) 21 | { 22 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 23 | } 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/CalcYxDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CCalcYxPoint; 13 | 14 | class CCalcYxDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CCalcYxDB(void); 19 | ~CCalcYxDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | }; 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/CalcYxPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "CalcYxPoint.h" 2 | 3 | namespace DataBase { 4 | 5 | #define strEnableEvent "EnableEvent" 6 | 7 | CCalcYxPoint::CCalcYxPoint() 8 | { 9 | bEnableEffectEvent_ = false; 10 | } 11 | 12 | CCalcYxPoint::~CCalcYxPoint(void) 13 | { 14 | } 15 | 16 | typeYxval CCalcYxPoint::getOriYxVal() 17 | { 18 | lastVal_ = getPointVal(); 19 | return lastVal_; 20 | } 21 | 22 | typeYxval CCalcYxPoint::getFinalYxVal() 23 | { 24 | if (getYxPolar()) 25 | { 26 | return getOriYxVal(); 27 | } 28 | else 29 | { 30 | if (getYxType() == single_yx_point) 31 | { 32 | return (getOriYxVal() & 0xfe) | ((~getOriYxVal()) & 0x01); 33 | } 34 | else if (getYxType() == double_yx_point) 35 | { 36 | return (getOriYxVal() & 0xfc) | ((~getOriYxVal()) & 0x03); 37 | } 38 | else 39 | { 40 | return getOriYxVal(); 41 | } 42 | } 43 | } 44 | 45 | typeYxval CCalcYxPoint::getLastYxVal() 46 | { 47 | return lastVal_; 48 | } 49 | 50 | int CCalcYxPoint::setOriYxVal(typeYxval val) 51 | { 52 | return -1; 53 | } 54 | 55 | void CCalcYxPoint::SaveXmlCfg(FileSystem::CMarkup & xml) 56 | { 57 | if (bEnableEffectEvent_) 58 | { 59 | xml.AddElem(strEnableEvent,strboolTrue); 60 | } 61 | else 62 | { 63 | xml.AddElem(strEnableEvent,strboolFalse); 64 | } 65 | 66 | CYxPoint::SaveXmlCfg(xml); 67 | 68 | PublicSupport::CCalcPoint::SaveXmlCfg(xml); 69 | } 70 | 71 | int CCalcYxPoint::LoadXmlCfg(FileSystem::CMarkup & xml) 72 | { 73 | xml.ResetMainPos(); 74 | if (xml.FindElem(strEnableEvent)) 75 | { 76 | bEnableEffectEvent_ = false; 77 | 78 | std::string strTmp = xml.GetData(); 79 | boost::algorithm::trim(strTmp); 80 | if (boost::algorithm::iequals(strboolTrue,strTmp)) 81 | { 82 | bEnableEffectEvent_ = true; 83 | } 84 | } 85 | 86 | CYxPoint::LoadXmlCfg(xml); 87 | 88 | PublicSupport::CCalcPoint::LoadXmlCfg(xml); 89 | 90 | return 0; 91 | } 92 | 93 | bool CCalcYxPoint::getEnableEffectEvent() 94 | { 95 | return bEnableEffectEvent_; 96 | } 97 | 98 | }; //namespace DataBase 99 | 100 | -------------------------------------------------------------------------------- /DataBase/CalcYxPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "YxPoint.h" 3 | #include "../PublicSupport/CalcPoint.h" 4 | 5 | namespace DataBase { 6 | 7 | class CCalcYxPoint : 8 | public CYxPoint, 9 | public PublicSupport::CCalcPoint 10 | { 11 | public: 12 | CCalcYxPoint(); 13 | virtual ~CCalcYxPoint(void); 14 | 15 | typeYxval getOriYxVal(); 16 | typeYxval getFinalYxVal(); 17 | typeYxval getLastYxVal(); 18 | int setOriYxVal(typeYxval val); 19 | 20 | void SaveXmlCfg(FileSystem::CMarkup & xml); 21 | int LoadXmlCfg(FileSystem::CMarkup & xml); 22 | 23 | bool getEnableEffectEvent(); 24 | 25 | private: 26 | typeYxval lastVal_; 27 | bool bEnableEffectEvent_; 28 | 29 | }; 30 | 31 | }; //namespace DataBase 32 | 33 | -------------------------------------------------------------------------------- /DataBase/CommPoint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/CommPoint.cpp -------------------------------------------------------------------------------- /DataBase/CommPoint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/CommPoint.h -------------------------------------------------------------------------------- /DataBase/CosPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "CosPoint.h" 2 | #include "YxPoint.h" 3 | 4 | namespace DataBase { 5 | 6 | CCosPoint::CCosPoint(void) 7 | { 8 | setYxIndex(0); 9 | setYxVal(0); 10 | setYxType(single_yx_point); 11 | setYxQuality(0); 12 | 13 | } 14 | 15 | CCosPoint::CCosPoint(size_t yxIndex, 16 | typeYxval yxval, 17 | typeYxtype yxType, 18 | typeYxQuality yxQuality) 19 | { 20 | setYxIndex(yxIndex); 21 | setYxVal(yxval); 22 | setYxType(yxType); 23 | setYxQuality(yxQuality); 24 | } 25 | 26 | CCosPoint::~CCosPoint(void) 27 | { 28 | } 29 | 30 | size_t CCosPoint::getYxIndex() const 31 | { 32 | return yxIndex_; 33 | } 34 | 35 | int CCosPoint::setYxIndex(size_t val) 36 | { 37 | yxIndex_ = val; 38 | 39 | return 0; 40 | } 41 | 42 | typeYxval CCosPoint::getYxVal() const 43 | { 44 | return yxVal_ & 0x0f; 45 | } 46 | 47 | int CCosPoint::setYxVal(typeYxval val) 48 | { 49 | yxVal_ = (yxVal_ & 0xf0) | (val & 0x0f); 50 | 51 | return 0; 52 | } 53 | 54 | typeYxQuality CCosPoint::getYxQuality() const 55 | { 56 | return yxVal_ & 0xf0; 57 | } 58 | 59 | int CCosPoint::setYxQuality(typeYxQuality val) 60 | { 61 | yxVal_ = (yxVal_ & 0x0f) | (val & 0xf0); 62 | 63 | return 0; 64 | } 65 | 66 | typeYxtype CCosPoint::getYxType() const 67 | { 68 | return yxType_; 69 | } 70 | 71 | int CCosPoint::setYxType(typeYxtype val) 72 | { 73 | if (val == double_yx_point) 74 | { 75 | yxType_ = double_yx_point; 76 | } 77 | else 78 | { 79 | yxType_ = single_yx_point; 80 | } 81 | 82 | return 0; 83 | } 84 | 85 | }; //namespace DataBase 86 | 87 | 88 | -------------------------------------------------------------------------------- /DataBase/CosPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../PublicSupport/Dat2cTypeDef.h" 3 | 4 | namespace DataBase { 5 | 6 | class CCosPoint 7 | { 8 | public: 9 | CCosPoint(void); 10 | CCosPoint(size_t yxIndex,typeYxval yxval,typeYxtype yxType,typeYxQuality yxQuality); 11 | virtual ~CCosPoint(void); 12 | 13 | size_t getYxIndex() const; 14 | int setYxIndex(size_t val); 15 | typeYxval getYxVal() const; 16 | int setYxVal(typeYxval val); 17 | typeYxQuality getYxQuality() const; 18 | int setYxQuality(typeYxQuality val); 19 | typeYxtype getYxType() const; 20 | int setYxType(typeYxtype val); 21 | 22 | protected: 23 | size_t yxIndex_; 24 | typeYxval yxVal_; 25 | typeYxtype yxType_; 26 | }; 27 | 28 | }; //namespace DataBase 29 | -------------------------------------------------------------------------------- /DataBase/CosRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "CosRecord.h" 3 | #include "CosPoint.h" 4 | 5 | namespace DataBase { 6 | 7 | const std::string strYxIndex = "YxIndex"; 8 | const std::string strYxVal = "YxVal"; 9 | 10 | CCosRecord::CCosRecord(std::string id,int limit) 11 | :CDataRecord(id,limit) 12 | { 13 | } 14 | 15 | CCosRecord::CCosRecord(std::string id) 16 | :CDataRecord(id) 17 | { 18 | } 19 | 20 | CCosRecord::~CCosRecord(void) 21 | { 22 | } 23 | 24 | int CCosRecord::AddDataRecord(const CCosPoint & cos) 25 | { 26 | using namespace std; 27 | 28 | string YxIndex = boost::lexical_cast(cos.getYxIndex()); 29 | string YxVal = boost::lexical_cast((int)cos.getYxVal()); 30 | 31 | 32 | FileSystem::name_val_set set; 33 | set.push_back(FileSystem::name_val(strYxIndex,YxIndex)); 34 | set.push_back(FileSystem::name_val(strYxVal,YxVal)); 35 | 36 | return CDataRecord::AddDataRecord(set); 37 | } 38 | 39 | }; //namespace DataBase 40 | 41 | -------------------------------------------------------------------------------- /DataBase/CosRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | 4 | namespace DataBase { 5 | 6 | class CCosPoint; 7 | 8 | class CCosRecord : 9 | public CDataRecord 10 | { 11 | public: 12 | CCosRecord(std::string id,int limit); 13 | CCosRecord(std::string id); 14 | virtual ~CCosRecord(void); 15 | 16 | int AddDataRecord(const CCosPoint & cos); 17 | }; 18 | 19 | }; //namespace DataBase 20 | -------------------------------------------------------------------------------- /DataBase/DAOperate.cpp: -------------------------------------------------------------------------------- 1 | #include "DAOperate.h" 2 | 3 | namespace DataBase { 4 | 5 | CDAOperate::CDAOperate() 6 | { 7 | } 8 | 9 | CDAOperate::~CDAOperate(void) 10 | { 11 | } 12 | 13 | };//namespace DataBase 14 | 15 | 16 | -------------------------------------------------------------------------------- /DataBase/DAOperate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../PublicSupport/Dat2cTypeDef.h" 3 | 4 | namespace DataBase { 5 | 6 | class CDAOperate 7 | { 8 | public: 9 | CDAOperate(); 10 | virtual ~CDAOperate(void); 11 | 12 | virtual size_t getYxSum() = 0; 13 | virtual typeYxval getYxVal(size_t index) = 0; 14 | virtual typeYxtype getYxType(size_t index) = 0; 15 | 16 | virtual size_t getYkSum() = 0; 17 | virtual int AddYkSelCmd(size_t index,bool bCloseOrOpen) = 0; 18 | virtual int AddYkExeCmd(size_t index,bool bCloseOrOpen) = 0; 19 | 20 | virtual size_t getYcSum() = 0; 21 | virtual typeYcval getYcVal(size_t index) = 0; 22 | 23 | virtual SigConnection ConnectYkSig(CmdRecallSlotType slot) = 0; 24 | virtual void TrigCosEvent(size_t index,typeYxval val,bool bSingleType) = 0; 25 | //virtual int SaveOriYxVal(size_t index,typeYxval val,bool bSingleType) =0; 26 | }; 27 | 28 | };//namespace DataBase 29 | 30 | -------------------------------------------------------------------------------- /DataBase/DAOperateSub.cpp: -------------------------------------------------------------------------------- 1 | #include "DAOperateSub.h" 2 | #include "SubStation.h" 3 | #include "YkPoint.h" 4 | 5 | namespace DataBase { 6 | 7 | CDAOperateSub::CDAOperateSub(DataBase::CSubStation & sub) 8 | :sub_(sub) 9 | { 10 | } 11 | 12 | CDAOperateSub::~CDAOperateSub(void) 13 | { 14 | } 15 | 16 | size_t CDAOperateSub::getYxSum() 17 | { 18 | return sub_.getYxSum(); 19 | } 20 | 21 | typeYxval CDAOperateSub::getYxVal(size_t index) 22 | { 23 | return sub_.getFinalYxVal(index); 24 | } 25 | 26 | typeYxtype CDAOperateSub::getYxType(size_t index) 27 | { 28 | return sub_.getYxType(index); 29 | } 30 | 31 | size_t CDAOperateSub::getYkSum() 32 | { 33 | return sub_.getYkSum(); 34 | } 35 | 36 | int CDAOperateSub::AddYkSelCmd(size_t index,bool bCloseOrOpen) 37 | { 38 | if(!sub_.getYkPointPtr(index)->RecvSelEvent()) 39 | { 40 | return sub_.AddYkSelCmd(index,bCloseOrOpen); 41 | } 42 | 43 | return -1; 44 | } 45 | 46 | int CDAOperateSub::AddYkExeCmd(size_t index,bool bCloseOrOpen) 47 | { 48 | if(!sub_.getYkPointPtr(index)->RecvExeEvent()) 49 | { 50 | return sub_.AddYkExeCmd(index,bCloseOrOpen); 51 | } 52 | 53 | return -1; 54 | } 55 | 56 | SigConnection CDAOperateSub::ConnectYkSig(CmdRecallSlotType slot) 57 | { 58 | return sub_.ConnectSubTempSig(slot); 59 | } 60 | 61 | void CDAOperateSub::TrigCosEvent(size_t index,typeYxval val,bool bSingleType) 62 | { 63 | return sub_.TrigCosEvent(index,val,bSingleType); 64 | } 65 | 66 | //int CDAOperateSub::SaveOriYxVal(size_t index,typeYxval val,bool bSingleType) 67 | //{ 68 | // return sub_.setOriYxValDateUp(index,val); 69 | //} 70 | 71 | size_t CDAOperateSub::getYcSum() 72 | { 73 | return sub_.getYcSum(); 74 | } 75 | 76 | typeYcval CDAOperateSub::getYcVal(size_t index) 77 | { 78 | return sub_.getFinalYcVal(index); 79 | } 80 | 81 | }; //namespace DataBase 82 | -------------------------------------------------------------------------------- /DataBase/DAOperateSub.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DAOperate.h" 3 | 4 | namespace DataBase 5 | { 6 | class CSubStation; 7 | } 8 | 9 | namespace DataBase { 10 | 11 | class CDAOperateSub : 12 | public CDAOperate 13 | { 14 | public: 15 | CDAOperateSub(DataBase::CSubStation & sub); 16 | virtual ~CDAOperateSub(void); 17 | 18 | virtual size_t getYxSum(); 19 | virtual typeYxval getYxVal(size_t index); 20 | virtual typeYxtype getYxType(size_t index); 21 | 22 | virtual size_t getYkSum(); 23 | virtual int AddYkSelCmd(size_t index,bool bCloseOrOpen); 24 | virtual int AddYkExeCmd(size_t index,bool bCloseOrOpen); 25 | 26 | virtual size_t getYcSum(); 27 | virtual typeYcval getYcVal(size_t index); 28 | 29 | virtual SigConnection ConnectYkSig(CmdRecallSlotType slot); 30 | virtual void TrigCosEvent(size_t index,typeYxval val,bool bSingleType); 31 | //virtual int SaveOriYxVal(size_t index,typeYxval val,bool bSingleType); 32 | 33 | private: 34 | DataBase::CSubStation & sub_; 35 | }; 36 | 37 | };//namespace DataBase 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /DataBase/DataRecord.cpp: -------------------------------------------------------------------------------- 1 | #include "DataRecord.h" 2 | 3 | namespace DataBase { 4 | 5 | CDataRecord::CDataRecord(std::string id,int limit) 6 | :record_(id,limit) 7 | { 8 | } 9 | 10 | CDataRecord::CDataRecord(std::string id) 11 | :record_(id,default_limit) 12 | { 13 | } 14 | 15 | CDataRecord::~CDataRecord(void) 16 | { 17 | } 18 | 19 | int CDataRecord::AddDataRecord(FileSystem::name_val_set & val) 20 | { 21 | return record_.AddRecordWithSynT(val); 22 | } 23 | 24 | int CDataRecord::AddDataRecord(FileSystem::name_val_set & attrib,FileSystem::name_val_set & val) 25 | { 26 | return record_.AddRecordWithSynT(attrib,val); 27 | } 28 | 29 | std::string CDataRecord::getID() 30 | { 31 | return record_.getLogPath(); 32 | } 33 | 34 | int CDataRecord::getLimit() 35 | { 36 | return record_.getMaxCounter(); 37 | } 38 | 39 | }; //namespace DataBase 40 | 41 | -------------------------------------------------------------------------------- /DataBase/DataRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../FileSystem/XmlRecord.h" 3 | 4 | namespace DataBase { 5 | 6 | class CDataRecord 7 | { 8 | public: 9 | CDataRecord(std::string id,int limit); 10 | CDataRecord(std::string id); 11 | virtual ~CDataRecord(void); 12 | 13 | std::string getID(); 14 | int getLimit(); 15 | 16 | protected: 17 | int AddDataRecord(FileSystem::name_val_set & val); 18 | int AddDataRecord(FileSystem::name_val_set & attrib,FileSystem::name_val_set & val); 19 | 20 | private: 21 | enum 22 | { 23 | default_limit = 256, 24 | }; 25 | 26 | FileSystem::CXmlRecord record_; 27 | }; 28 | 29 | }; //namespace DataBase 30 | -------------------------------------------------------------------------------- /DataBase/FaultPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "FaultPoint.h" 2 | 3 | namespace DataBase { 4 | 5 | CFaultPoint::CFaultPoint(void) 6 | { 7 | } 8 | 9 | CFaultPoint::~CFaultPoint(void) 10 | { 11 | } 12 | 13 | unsigned short CFaultPoint::getFaultNO() const 14 | { 15 | return FaultNO_; 16 | } 17 | 18 | int CFaultPoint::setFaultNO(unsigned short val) 19 | { 20 | FaultNO_ = val; 21 | 22 | return 0; 23 | } 24 | 25 | typeYcval CFaultPoint::getFaultVal() const 26 | { 27 | return FaultVal_; 28 | } 29 | 30 | int CFaultPoint::setFaultVal(typeYcval val) 31 | { 32 | FaultVal_ = val; 33 | 34 | return 0; 35 | } 36 | 37 | boost::posix_time::ptime CFaultPoint::getFaultTime() const 38 | { 39 | return FaultTime_; 40 | } 41 | 42 | int CFaultPoint::setFaultTime(boost::posix_time::ptime val) 43 | { 44 | FaultTime_ = val; 45 | return 0; 46 | } 47 | }; //namespace DataBase 48 | -------------------------------------------------------------------------------- /DataBase/FaultPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../PublicSupport/Dat2cTypeDef.h" 4 | 5 | namespace DataBase { 6 | 7 | using namespace boost::posix_time; 8 | 9 | class CFaultPoint 10 | { 11 | public: 12 | CFaultPoint(void); 13 | ~CFaultPoint(void); 14 | 15 | unsigned short getFaultNO() const; 16 | int setFaultNO(unsigned short val); 17 | typeYcval getFaultVal() const; 18 | int setFaultVal(typeYcval val); 19 | boost::posix_time::ptime getFaultTime() const; 20 | int setFaultTime(boost::posix_time::ptime val); 21 | 22 | private: 23 | unsigned short FaultNO_; 24 | typeYcval FaultVal_; 25 | boost::posix_time::ptime FaultTime_; 26 | 27 | }; 28 | 29 | };//namespace DataBase 30 | -------------------------------------------------------------------------------- /DataBase/FaultRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "FaultRecord.h" 4 | #include "FaultPoint.h" 5 | 6 | namespace DataBase { 7 | 8 | const std::string strFaultNO = "FaultNO"; 9 | const std::string strFaultVal = "FaultVal"; 10 | const std::string strFaultTime = "FaultTime"; 11 | 12 | CFaultRecord::CFaultRecord(std::string id,int limit) 13 | :CDataRecord(id,limit) 14 | { 15 | } 16 | 17 | CFaultRecord::CFaultRecord(std::string id) 18 | :CDataRecord(id) 19 | { 20 | } 21 | 22 | CFaultRecord::~CFaultRecord(void) 23 | { 24 | } 25 | 26 | int CFaultRecord::AddDataRecord(const CFaultPoint & fault) 27 | { 28 | using namespace std; 29 | 30 | string FaultNO = boost::lexical_cast(fault.getFaultNO()); 31 | string FaultVal = boost::lexical_cast(fault.getFaultVal()); 32 | string FaultTime = boost::posix_time::to_simple_string(fault.getFaultTime()); 33 | 34 | FileSystem::name_val_set set; 35 | set.push_back(FileSystem::name_val(strFaultNO,FaultNO)); 36 | set.push_back(FileSystem::name_val(strFaultVal,FaultVal)); 37 | set.push_back(FileSystem::name_val(strFaultTime,FaultTime)); 38 | 39 | return CDataRecord::AddDataRecord(set); 40 | } 41 | 42 | }; //namespace DataBase 43 | 44 | -------------------------------------------------------------------------------- /DataBase/FaultRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | 4 | namespace DataBase { 5 | 6 | class CFaultPoint; 7 | 8 | class CFaultRecord : 9 | public CDataRecord 10 | { 11 | public: 12 | CFaultRecord(std::string id,int limit); 13 | CFaultRecord(std::string id); 14 | virtual ~CFaultRecord(void); 15 | 16 | int AddDataRecord(const CFaultPoint & fault); 17 | }; 18 | 19 | }; //namespace DataBase 20 | -------------------------------------------------------------------------------- /DataBase/Line.cpp: -------------------------------------------------------------------------------- 1 | #include "Line.h" 2 | #include "../FileSystem/Markup.h" 3 | 4 | namespace DataBase { 5 | 6 | CLine::CLine(void) 7 | { 8 | } 9 | 10 | 11 | CLine::~CLine(void) 12 | { 13 | } 14 | 15 | int CLine::LoadXmlCfg(FileSystem::CMarkup & xml) 16 | { 17 | return 0; 18 | } 19 | 20 | void CLine::SaveXmlCfg(FileSystem::CMarkup & xml) 21 | { 22 | 23 | } 24 | 25 | };//namespace DataBase 26 | -------------------------------------------------------------------------------- /DataBase/Line.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/Line.h -------------------------------------------------------------------------------- /DataBase/LineDB.cpp: -------------------------------------------------------------------------------- 1 | #include "LineDB.h" 2 | #include "Line.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CLineDB::CLineDB(void) 8 | { 9 | } 10 | 11 | CLineDB::~CLineDB(void) 12 | { 13 | } 14 | 15 | int CLineDB::InitDataBase(FileSystem::CMarkup & xml) 16 | { 17 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 18 | } 19 | 20 | void CLineDB::SaveXmlCfg(FileSystem::CMarkup & xml) 21 | { 22 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 23 | } 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/LineDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CLine; 13 | 14 | class CLineDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CLineDB(void); 19 | ~CLineDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | }; 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/PriStation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/PriStation.cpp -------------------------------------------------------------------------------- /DataBase/PriStation.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/PriStation.h -------------------------------------------------------------------------------- /DataBase/SoePoint.cpp: -------------------------------------------------------------------------------- 1 | #include "SoePoint.h" 2 | 3 | namespace DataBase { 4 | 5 | using namespace boost::posix_time; 6 | 7 | CSoePoint::CSoePoint(void) 8 | :CCosPoint() 9 | { 10 | } 11 | 12 | CSoePoint::CSoePoint(size_t yxIndex, 13 | typeYxval yxval, 14 | typeYxtype yxType, 15 | typeYxQuality yxQuality, 16 | ptime time) 17 | :yxTime_(time), 18 | CCosPoint(yxIndex,yxval,yxType,yxQuality) 19 | 20 | { 21 | 22 | } 23 | 24 | CSoePoint::~CSoePoint(void) 25 | { 26 | } 27 | 28 | ptime CSoePoint::getYxTime() const 29 | { 30 | return yxTime_; 31 | } 32 | 33 | int CSoePoint::setYxTime(ptime val) 34 | { 35 | yxTime_ = val; 36 | 37 | return 0; 38 | } 39 | 40 | }; //namespace DataBase 41 | 42 | 43 | -------------------------------------------------------------------------------- /DataBase/SoePoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "CosPoint.h" 4 | 5 | namespace DataBase { 6 | 7 | class CSoePoint 8 | :public CCosPoint 9 | { 10 | public: 11 | CSoePoint(void); 12 | CSoePoint(size_t yxIndex,typeYxval yxval,typeYxtype yxType,typeYxQuality yxQuality,boost::posix_time::ptime time); 13 | virtual ~CSoePoint(void); 14 | 15 | boost::posix_time::ptime getYxTime() const; 16 | int setYxTime(boost::posix_time::ptime val); 17 | 18 | protected: 19 | boost::posix_time::ptime yxTime_; 20 | }; 21 | 22 | }; //namespace DataBase 23 | -------------------------------------------------------------------------------- /DataBase/SoeRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "SoeRecord.h" 4 | #include "SoePoint.h" 5 | 6 | namespace DataBase { 7 | 8 | const std::string strYxIndex = "YxIndex"; 9 | const std::string strYxVal = "YxVal"; 10 | const std::string strSoeTime = "SoeTime"; 11 | 12 | CSoeRecord::CSoeRecord(std::string id,int limit) 13 | :CDataRecord(id,limit) 14 | { 15 | } 16 | 17 | CSoeRecord::CSoeRecord(std::string id) 18 | :CDataRecord(id) 19 | { 20 | } 21 | 22 | CSoeRecord::~CSoeRecord(void) 23 | { 24 | } 25 | 26 | int CSoeRecord::AddDataRecord(const CSoePoint & soe) 27 | { 28 | using namespace std; 29 | 30 | string YxIndex = boost::lexical_cast(soe.getYxIndex()); 31 | string YxVal = boost::lexical_cast((int)soe.getYxVal()); 32 | string SoeTime = boost::posix_time::to_simple_string(soe.getYxTime()); 33 | 34 | FileSystem::name_val_set set; 35 | set.push_back(FileSystem::name_val(strYxIndex,YxIndex)); 36 | set.push_back(FileSystem::name_val(strYxVal,YxVal)); 37 | set.push_back(FileSystem::name_val(strSoeTime,SoeTime)); 38 | 39 | return CDataRecord::AddDataRecord(set); 40 | } 41 | 42 | }; //namespace DataBase 43 | -------------------------------------------------------------------------------- /DataBase/SoeRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | 4 | namespace DataBase { 5 | 6 | class CSoePoint; 7 | 8 | class CSoeRecord 9 | :public CDataRecord 10 | { 11 | public: 12 | CSoeRecord(std::string id,int limit); 13 | CSoeRecord(std::string id); 14 | virtual ~CSoeRecord(void); 15 | 16 | int AddDataRecord(const CSoePoint & soe); 17 | }; 18 | 19 | }; //namespace DataBase 20 | 21 | -------------------------------------------------------------------------------- /DataBase/SubStation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/SubStation.cpp -------------------------------------------------------------------------------- /DataBase/SubStation.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/SubStation.h -------------------------------------------------------------------------------- /DataBase/Terminal.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/Terminal.cpp -------------------------------------------------------------------------------- /DataBase/Terminal.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/Terminal.h -------------------------------------------------------------------------------- /DataBase/TerminalFactroy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "TerminalFactroy.h" 3 | #include "BF533Terminal.h" 4 | #include "SubStation.h" 5 | 6 | namespace DataBase { 7 | 8 | const std::string strTerminal = "normal"; 9 | const std::string strBF533Terminal = "bf533"; 10 | 11 | CTerminalFactroy::CTerminalFactroy(void) 12 | { 13 | } 14 | 15 | CTerminalFactroy::~CTerminalFactroy(void) 16 | { 17 | } 18 | 19 | std::string CTerminalFactroy::TransTerminalTypeToString(unsigned short val) 20 | { 21 | std::string strTmp = strTerminal; 22 | 23 | switch(val) 24 | { 25 | case NormalTerminal: 26 | strTmp = strTerminal; 27 | break; 28 | 29 | case BF533Terminal: 30 | strTmp = strBF533Terminal; 31 | break; 32 | 33 | default: 34 | strTmp = strTerminal; 35 | break; 36 | } 37 | 38 | return strTerminal; 39 | } 40 | 41 | short CTerminalFactroy::TransTerminalTypeFromString( std::string val ) 42 | { 43 | short ret = NormalTerminal; 44 | 45 | if (boost::iequals(strTerminal,val)) 46 | { 47 | ret = NormalTerminal; 48 | } 49 | else if (boost::iequals(strBF533Terminal,val)) 50 | { 51 | ret = BF533Terminal; 52 | } 53 | else 54 | { 55 | ret = NormalTerminal; 56 | } 57 | 58 | return ret; 59 | } 60 | 61 | share_terminal_ptr CTerminalFactroy::CreateTerminal(std::string terminalType,boost::asio::io_service & io_service,CSubStation & sub) 62 | { 63 | int ret = TransTerminalTypeFromString(terminalType); 64 | 65 | switch(ret) 66 | { 67 | case NormalTerminal: 68 | return share_terminal_ptr(new CTerminal(io_service,sub)); 69 | break; 70 | 71 | case BF533Terminal: 72 | { 73 | share_bf533_ptr bf533 = share_bf533_ptr(CBF533Terminal::getMyInstance(io_service,sub)); 74 | sub.setBf533Terminal(bf533); 75 | return bf533; 76 | } 77 | break; 78 | 79 | default: 80 | return share_terminal_ptr(new CTerminal(io_service,sub)); 81 | break; 82 | } 83 | } 84 | 85 | }; //namespace DataBase 86 | -------------------------------------------------------------------------------- /DataBase/TerminalFactroy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace DataBase { 6 | 7 | class CTerminal; 8 | class CSubStation; 9 | 10 | typedef boost::shared_ptr share_terminal_ptr; 11 | 12 | class CTerminalFactroy 13 | { 14 | public: 15 | ~CTerminalFactroy(void); 16 | static share_terminal_ptr CreateTerminal(std::string terminalType,boost::asio::io_service & io_service,CSubStation & sub); 17 | static std::string TransTerminalTypeToString(unsigned short val); 18 | 19 | private: 20 | CTerminalFactroy(void); 21 | static short TransTerminalTypeFromString( std::string val ); 22 | }; 23 | 24 | }; //namespace DataBase 25 | -------------------------------------------------------------------------------- /DataBase/YCPoint.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/YCPoint.cpp -------------------------------------------------------------------------------- /DataBase/YCPoint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/YCPoint.h -------------------------------------------------------------------------------- /DataBase/YcDB.cpp: -------------------------------------------------------------------------------- 1 | #include "YcDB.h" 2 | #include "YCPoint.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CYcDB::CYcDB(void) 8 | { 9 | YcDead_ = CYcPoint::DefaultYcDead; 10 | YcPlus_ = CYcPoint::DefaultYcPlus; 11 | YcMul_ = CYcPoint::DefaultYcMul; 12 | } 13 | 14 | CYcDB::~CYcDB(void) 15 | { 16 | } 17 | 18 | int CYcDB::InitDataBase(FileSystem::CMarkup & xml) 19 | { 20 | LoadXmlAttrib(xml); 21 | 22 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 23 | } 24 | 25 | void CYcDB::SaveXmlCfg(FileSystem::CMarkup & xml) 26 | { 27 | SaveXmlAttrib(xml); 28 | 29 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 30 | } 31 | 32 | int CYcDB::InitDataNodes() 33 | { 34 | for (size_t i=0;isetYcDeadLimit(YcDead_); 39 | } 40 | 41 | if (YcPlus_ != CYcPoint::DefaultYcPlus) 42 | { 43 | getPointDataPtr(i)->setYcPlus(YcPlus_); 44 | } 45 | 46 | if (YcMul_ != CYcPoint::DefaultYcMul) 47 | { 48 | getPointDataPtr(i)->setYcMul(YcMul_); 49 | } 50 | } 51 | 52 | return 0; 53 | } 54 | 55 | int CYcDB::LoadXmlAttrib(FileSystem::CMarkup & xml) 56 | { 57 | std::string strTmp = xml.GetAttrib(strYcDeadLimit); 58 | boost::algorithm::trim(strTmp); 59 | try 60 | { 61 | YcDead_ = boost::lexical_cast(strTmp); 62 | } 63 | catch(boost::bad_lexical_cast & e) 64 | { 65 | //do nothing,just Ignore sum attrib. 66 | e.what(); 67 | YcDead_ = CYcPoint::DefaultYcDead; 68 | } 69 | 70 | strTmp = xml.GetAttrib(strYcPlus); 71 | boost::algorithm::trim(strTmp); 72 | try 73 | { 74 | YcPlus_ = boost::lexical_cast(strTmp); 75 | } 76 | catch(boost::bad_lexical_cast & e) 77 | { 78 | //do nothing,just Ignore sum attrib. 79 | e.what(); 80 | YcPlus_ = CYcPoint::DefaultYcPlus; 81 | } 82 | 83 | strTmp = xml.GetAttrib(strYcMul); 84 | boost::algorithm::trim(strTmp); 85 | try 86 | { 87 | YcMul_ = boost::lexical_cast(strTmp); 88 | } 89 | catch(boost::bad_lexical_cast & e) 90 | { 91 | //do nothing,just Ignore sum attrib. 92 | e.what(); 93 | YcMul_ = CYcPoint::DefaultYcMul; 94 | } 95 | 96 | return 0; 97 | } 98 | 99 | void CYcDB::SaveXmlAttrib(FileSystem::CMarkup & xml) 100 | { 101 | if (YcDead_ != CYcPoint::DefaultYcDead) 102 | { 103 | xml.AddAttrib(strYcDeadLimit,YcDead_); 104 | } 105 | 106 | if (YcPlus_ != CYcPoint::DefaultYcPlus) 107 | { 108 | xml.AddAttrib(strYcPlus,YcPlus_); 109 | } 110 | 111 | if (YcMul_ != CYcPoint::DefaultYcMul) 112 | { 113 | xml.AddAttrib(strYcMul,boost::lexical_cast(YcMul_)); 114 | } 115 | } 116 | 117 | };//namespace DataBase 118 | 119 | -------------------------------------------------------------------------------- /DataBase/YcDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CYcPoint; 13 | 14 | class CYcDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CYcDB(void); 19 | ~CYcDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | 24 | private: 25 | int LoadXmlAttrib(FileSystem::CMarkup & xml); 26 | void SaveXmlAttrib(FileSystem::CMarkup & xml); 27 | 28 | int InitDataNodes(); 29 | 30 | private: 31 | typeYcdead YcDead_; 32 | typeYcplus YcPlus_; 33 | typeYcmul YcMul_; 34 | }; 35 | 36 | };//namespace DataBase 37 | 38 | -------------------------------------------------------------------------------- /DataBase/YcHisRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "YcHisRecord.h" 3 | #include "YCPoint.h" 4 | 5 | namespace DataBase { 6 | 7 | const std::string strYcIndex = "YcIndex"; 8 | const std::string strYcVal = "YcVal"; 9 | 10 | CYcHisRecord::CYcHisRecord(std::string id,int limit) 11 | :CDataRecord(id,limit) 12 | { 13 | } 14 | 15 | CYcHisRecord::CYcHisRecord(std::string id) 16 | :CDataRecord(id) 17 | { 18 | } 19 | 20 | CYcHisRecord::~CYcHisRecord(void) 21 | { 22 | } 23 | 24 | int CYcHisRecord::AddDataRecord(PublicSupport::CDynamicArrayDataBase & ycDB) 25 | { 26 | using namespace std; 27 | 28 | FileSystem::name_val_set attrib_set; 29 | FileSystem::name_val_set val_set; 30 | for (int i=0;i<(int)ycDB.getDataBaseSum();i++) 31 | { 32 | string YcIndex = boost::lexical_cast(i); 33 | string YcVal = boost::lexical_cast(ycDB.getPointDataPtr(i)->getFinalYcVal()); 34 | 35 | attrib_set.push_back(FileSystem::name_val(strYcIndex,YcIndex)); 36 | val_set.push_back(FileSystem::name_val(strYcVal,YcVal)); 37 | } 38 | 39 | return CDataRecord::AddDataRecord(attrib_set,val_set); 40 | } 41 | 42 | //int CYcHisRecord::AddDataRecord(CSubStation & sub) 43 | //{ 44 | // using namespace std; 45 | // 46 | // FileSystem::name_val_set attrib_set; 47 | // FileSystem::name_val_set val_set; 48 | // for (int i=0;i<(int)sub.getYcSum();i++) 49 | // { 50 | // string YcIndex = boost::lexical_cast(i); 51 | // string YcVal = boost::lexical_cast(sub.getFinalYcVal(i)); 52 | // 53 | // attrib_set.push_back(FileSystem::name_val(strYcIndex,YcIndex)); 54 | // val_set.push_back(FileSystem::name_val(strYcVal,YcVal)); 55 | // } 56 | // 57 | // return CDataRecord::AddDataRecord(attrib_set,val_set); 58 | //} 59 | 60 | };//namespace DataBase 61 | -------------------------------------------------------------------------------- /DataBase/YcHisRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace DataBase { 6 | 7 | class CYcPoint; 8 | //class CSubStation; 9 | 10 | //typedef PublicSupport::CDynamicArrayDataBase ycDB; 11 | 12 | class CYcHisRecord : 13 | public CDataRecord 14 | { 15 | public: 16 | CYcHisRecord(std::string id,int limit); 17 | CYcHisRecord(std::string id); 18 | virtual ~CYcHisRecord(void); 19 | 20 | int AddDataRecord(PublicSupport::CDynamicArrayDataBase & ycDB); 21 | //int AddDataRecord(CSubStation & sub); 22 | }; 23 | 24 | };//namespace DataBase 25 | 26 | -------------------------------------------------------------------------------- /DataBase/YcStatRecord.cpp: -------------------------------------------------------------------------------- 1 | #include "YcStatRecord.h" 2 | #include "YCPoint.h" 3 | 4 | namespace DataBase { 5 | 6 | const std::string strYcIndex = "YcIndex"; 7 | const std::string strMaxYcVal = "MaxYcVal"; 8 | const std::string strMinYcVal = "MinYcVal"; 9 | 10 | CYcStatRecord::CYcStatRecord(std::string id,int limit) 11 | :CDataRecord(id,limit) 12 | { 13 | } 14 | 15 | CYcStatRecord::CYcStatRecord(std::string id) 16 | :CDataRecord(id) 17 | { 18 | } 19 | 20 | CYcStatRecord::~CYcStatRecord(void) 21 | { 22 | } 23 | 24 | int CYcStatRecord::AddDataRecord(PublicSupport::CDynamicArrayDataBase & ycDB) 25 | { 26 | using namespace std; 27 | 28 | FileSystem::name_val_set max_attrib_set; 29 | FileSystem::name_val_set max_val_set; 30 | FileSystem::name_val_set min_attrib_set; 31 | FileSystem::name_val_set min_val_set; 32 | 33 | for (int i=0;i<(int)ycDB.getDataBaseSum();i++) 34 | { 35 | string YcIndex = boost::lexical_cast(i); 36 | string MaxYcVal = boost::lexical_cast(ycDB.getPointDataPtr(i)->getYcMaxVal()); 37 | string MinYcVal = boost::lexical_cast(ycDB.getPointDataPtr(i)->getYcMinVal()); 38 | 39 | max_attrib_set.push_back(FileSystem::name_val(strYcIndex,YcIndex)); 40 | max_val_set.push_back(FileSystem::name_val(strMaxYcVal,MaxYcVal)); 41 | min_attrib_set.push_back(FileSystem::name_val(strYcIndex,YcIndex)); 42 | min_val_set.push_back(FileSystem::name_val(strMinYcVal,MinYcVal)); 43 | 44 | ycDB.getPointDataPtr(i)->ResetYcStatVal(); 45 | } 46 | 47 | CDataRecord::AddDataRecord(max_attrib_set,max_val_set); 48 | CDataRecord::AddDataRecord(min_attrib_set,min_val_set); 49 | 50 | return 0; 51 | } 52 | 53 | }; //namespace DataBase 54 | -------------------------------------------------------------------------------- /DataBase/YcStatRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace DataBase { 6 | 7 | class CYcPoint; 8 | 9 | class CYcStatRecord 10 | :public CDataRecord 11 | { 12 | public: 13 | CYcStatRecord(std::string id,int limit); 14 | CYcStatRecord(std::string id); 15 | virtual ~CYcStatRecord(void); 16 | 17 | int AddDataRecord(PublicSupport::CDynamicArrayDataBase & ycDB); 18 | }; 19 | 20 | }; //namespace DataBase 21 | -------------------------------------------------------------------------------- /DataBase/YcVarPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "YcVarPoint.h" 2 | 3 | namespace DataBase { 4 | 5 | CYcVarPoint::CYcVarPoint() 6 | { 7 | 8 | } 9 | 10 | CYcVarPoint::CYcVarPoint(size_t ycindex, 11 | typeYcval ycval, 12 | typeYcquality ycQuality, 13 | ptime time) 14 | :ycIndex_(ycindex), 15 | ycVal_(ycval), 16 | ycQuality_(ycQuality), 17 | ycTime_(time) 18 | { 19 | 20 | } 21 | 22 | CYcVarPoint::~CYcVarPoint(void) 23 | { 24 | } 25 | 26 | size_t CYcVarPoint::getYcIndex() 27 | { 28 | return ycIndex_; 29 | } 30 | 31 | int CYcVarPoint::setYcIndex(size_t val) 32 | { 33 | ycIndex_ = val; 34 | 35 | return 0; 36 | } 37 | 38 | typeYcval CYcVarPoint::getYcVal() 39 | { 40 | return ycVal_; 41 | } 42 | 43 | int CYcVarPoint::setYcVal(typeYcval val) 44 | { 45 | ycVal_ = val; 46 | 47 | return 0; 48 | } 49 | 50 | typeYcquality CYcVarPoint::getYcQuality() 51 | { 52 | return ycQuality_; 53 | } 54 | 55 | int CYcVarPoint::setYcQuality(typeYcquality val) 56 | { 57 | ycQuality_ = val; 58 | 59 | return 0; 60 | } 61 | 62 | ptime CYcVarPoint::getYcTime() 63 | { 64 | return ycTime_; 65 | } 66 | 67 | int CYcVarPoint::setYcTime(ptime val) 68 | { 69 | ycTime_ = val; 70 | 71 | return 0; 72 | } 73 | 74 | }; //namespace DataBase { 75 | -------------------------------------------------------------------------------- /DataBase/YcVarPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "../PublicSupport/Dat2cTypeDef.h" 4 | 5 | namespace DataBase { 6 | 7 | using namespace boost::posix_time; 8 | 9 | class CYcVarPoint 10 | { 11 | public: 12 | CYcVarPoint(); 13 | //CYcVarPoint(size_t ycindex,typeYcval ycval); 14 | CYcVarPoint(size_t ycindex,typeYcval ycval,typeYcquality ycQuality,ptime time); 15 | ~CYcVarPoint(void); 16 | 17 | size_t getYcIndex(); 18 | int setYcIndex(size_t val); 19 | typeYcval getYcVal(); 20 | int setYcVal(typeYcval val); 21 | typeYcquality getYcQuality(); 22 | int setYcQuality(typeYcquality val); 23 | ptime getYcTime(); 24 | int setYcTime(ptime val); 25 | 26 | protected: 27 | size_t ycIndex_; 28 | typeYcval ycVal_; 29 | typeYcquality ycQuality_; 30 | ptime ycTime_; 31 | }; 32 | 33 | }; //namespace DataBase 34 | -------------------------------------------------------------------------------- /DataBase/YkCancelState.cpp: -------------------------------------------------------------------------------- 1 | #include "YkCancelState.h" 2 | #include "YkReadyState.h" 3 | 4 | namespace DataBase { 5 | 6 | CYkCancelState::CYkCancelState(void) 7 | { 8 | } 9 | 10 | CYkCancelState::~CYkCancelState(void) 11 | { 12 | } 13 | 14 | int CYkCancelState::SendCancelEvent(CYkPoint & ykPoint) 15 | { 16 | return 0; 17 | } 18 | 19 | int CYkCancelState::BackCancelEvent(CYkPoint & ykPoint) 20 | { 21 | ChangeState(ykPoint,new CYkReadyState()); 22 | 23 | return 0; 24 | } 25 | 26 | int CYkCancelState::CancelResponEvent(CYkPoint & ykPoint) 27 | { 28 | return 0; 29 | } 30 | 31 | }; //namespace DataBase 32 | -------------------------------------------------------------------------------- /DataBase/YkCancelState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "YkState.h" 3 | 4 | namespace DataBase { 5 | 6 | class CYkCancelState : 7 | public CYkState 8 | { 9 | public: 10 | CYkCancelState(void); 11 | virtual ~CYkCancelState(void); 12 | 13 | virtual int SendCancelEvent(CYkPoint & ykPoint); 14 | virtual int BackCancelEvent(CYkPoint & ykPoint); 15 | virtual int CancelResponEvent(CYkPoint & ykPoint); 16 | }; 17 | 18 | }; //namespace DataBase 19 | -------------------------------------------------------------------------------- /DataBase/YkDB.cpp: -------------------------------------------------------------------------------- 1 | #include "YkDB.h" 2 | #include "YkPoint.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CYkDB::CYkDB(void) 8 | { 9 | ykDouble_ = CYkPoint::DefaultYkDouble; 10 | } 11 | 12 | CYkDB::~CYkDB(void) 13 | { 14 | } 15 | 16 | int CYkDB::InitDataBase(FileSystem::CMarkup & xml) 17 | { 18 | LoadXmlAttrib(xml); 19 | 20 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 21 | } 22 | 23 | void CYkDB::SaveXmlCfg(FileSystem::CMarkup & xml) 24 | { 25 | SaveXmlAttrib(xml); 26 | 27 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 28 | } 29 | 30 | int CYkDB::InitDataNodes() 31 | { 32 | for (size_t i=0;isetbHYkDouble(ykDouble_); 37 | } 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | int CYkDB::LoadXmlAttrib(FileSystem::CMarkup & xml) 44 | { 45 | std::string strTmp = xml.GetAttrib(strYkDouble); 46 | boost::algorithm::trim(strTmp); 47 | if (boost::algorithm::iequals(strboolFalse,strTmp)) 48 | { 49 | ykDouble_ = false; 50 | } 51 | else 52 | { 53 | ykDouble_ = true; 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | void CYkDB::SaveXmlAttrib(FileSystem::CMarkup & xml) 60 | { 61 | if (ykDouble_ != CYkPoint::DefaultYkDouble) 62 | { 63 | if (ykDouble_) 64 | { 65 | xml.AddAttrib(strYkDouble,strboolTrue); 66 | } 67 | else 68 | { 69 | xml.AddAttrib(strYkDouble,strboolFalse); 70 | } 71 | } 72 | } 73 | 74 | };//namespace DataBase 75 | 76 | -------------------------------------------------------------------------------- /DataBase/YkDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CYkPoint; 13 | 14 | class CYkDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CYkDB(void); 19 | ~CYkDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | 24 | int InitDataNodes(); 25 | 26 | private: 27 | int LoadXmlAttrib(FileSystem::CMarkup & xml); 28 | void SaveXmlAttrib(FileSystem::CMarkup & xml); 29 | 30 | private: 31 | bool ykDouble_; 32 | }; 33 | 34 | };//namespace DataBase 35 | 36 | -------------------------------------------------------------------------------- /DataBase/YkExeState.cpp: -------------------------------------------------------------------------------- 1 | #include "YkExeState.h" 2 | #include "YkCancelState.h" 3 | #include "YkReadyState.h" 4 | 5 | namespace DataBase { 6 | 7 | CYkExeState::CYkExeState(void) 8 | { 9 | } 10 | 11 | CYkExeState::~CYkExeState(void) 12 | { 13 | } 14 | 15 | int CYkExeState::SendExeEvent(CYkPoint & ykPoint) 16 | { 17 | return 0; 18 | } 19 | 20 | int CYkExeState::BackExeEvent(CYkPoint & ykPoint) 21 | { 22 | ChangeState(ykPoint,new CYkReadyState()); 23 | 24 | return 0; 25 | } 26 | 27 | int CYkExeState::ExeResponEvent(CYkPoint & ykPoint) 28 | { 29 | return 0; 30 | } 31 | 32 | int CYkExeState::RecvCancelEvent(CYkPoint & ykPoint) 33 | { 34 | ChangeState(ykPoint,new CYkCancelState()); 35 | 36 | return 0; 37 | } 38 | 39 | //int CYkExeState::OverYkEvent(CYkPoint & ykPoint) 40 | //{ 41 | // //ChangeState(ykPoint,new CYkReadyState()); 42 | // 43 | // return 0; 44 | //} 45 | 46 | }; //namespace DataBase 47 | -------------------------------------------------------------------------------- /DataBase/YkExeState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "YkState.h" 3 | 4 | namespace DataBase { 5 | 6 | class CYkExeState : 7 | public CYkState 8 | { 9 | public: 10 | CYkExeState(void); 11 | virtual ~CYkExeState(void); 12 | 13 | virtual int SendExeEvent(CYkPoint & ykPoint); 14 | virtual int BackExeEvent(CYkPoint & ykPoint); 15 | virtual int ExeResponEvent(CYkPoint & ykPoint); 16 | 17 | virtual int RecvCancelEvent(CYkPoint & ykPoint); 18 | 19 | //virtual int OverYkEvent(CYkPoint & ykPoint); 20 | }; 21 | 22 | }; //namespace DataBase 23 | -------------------------------------------------------------------------------- /DataBase/YkPoint.H: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/YkPoint.H -------------------------------------------------------------------------------- /DataBase/YkReadyState.cpp: -------------------------------------------------------------------------------- 1 | #include "YkReadyState.h" 2 | #include "YkSelState.h" 3 | 4 | namespace DataBase { 5 | 6 | CYkReadyState::CYkReadyState(void) 7 | { 8 | } 9 | 10 | CYkReadyState::~CYkReadyState(void) 11 | { 12 | } 13 | 14 | int CYkReadyState::RecvSelEvent( CYkPoint & ykPoint ) 15 | { 16 | ChangeState(ykPoint,new CYkSelState()); 17 | 18 | return 0; 19 | } 20 | 21 | int CYkReadyState::BackExeEvent(CYkPoint & ykPoint) 22 | { 23 | ChangeState(ykPoint,new CYkReadyState()); 24 | 25 | return 0; 26 | } 27 | 28 | int CYkReadyState::OverYkEvent(CYkPoint & ykPoint) 29 | { 30 | ChangeState(ykPoint,new CYkReadyState()); 31 | 32 | return 0; 33 | } 34 | 35 | }; //namespace DataBase 36 | -------------------------------------------------------------------------------- /DataBase/YkReadyState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "YkState.h" 3 | 4 | namespace DataBase { 5 | 6 | class CYkReadyState : 7 | public CYkState 8 | { 9 | public: 10 | CYkReadyState(void); 11 | virtual ~CYkReadyState(void); 12 | 13 | virtual int RecvSelEvent(CYkPoint & ykPoint); 14 | virtual int BackExeEvent(CYkPoint & ykPoint); 15 | virtual int OverYkEvent(CYkPoint & ykPoint); 16 | }; 17 | 18 | };//namespace DataBase 19 | -------------------------------------------------------------------------------- /DataBase/YkRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "YkRecord.h" 4 | 5 | namespace DataBase { 6 | 7 | const std::string strYkEvent = "YkEvent"; 8 | const std::string strYkSelEvent = "YkSelEvent"; 9 | const std::string strYkExeEvent = "YkExeEvent"; 10 | const std::string strYkCancelEvent = "YkCancelEvent"; 11 | const std::string strYkOverEvent = "YkOverEvent"; 12 | const std::string strYkSelFailEvent = "YkSelFailEvent"; 13 | const std::string strYkExeFailEvent = "YkExeFailEvent"; 14 | const std::string strYkCancelFailEvent = "YkCancelFailEvent"; 15 | const std::string strYkSelConEvent = "YkSelConEvent"; 16 | const std::string strYkExeConEvent = "YkExeConEvent"; 17 | const std::string strYkCancelConEvent = "YkCanceConlEvent"; 18 | const std::string strUndefineEvent = "UndefineEvent"; 19 | const std::string strYkNO = "YkNO"; 20 | const std::string strYkVal = "YkVal"; 21 | const std::string strYkClose = "Close"; 22 | const std::string strYkOpen = "Open"; 23 | 24 | CYkRecord::CYkRecord(std::string id,int limit) 25 | :CDataRecord(id,limit) 26 | { 27 | } 28 | 29 | CYkRecord::CYkRecord(std::string id) 30 | :CDataRecord(id) 31 | { 32 | } 33 | 34 | CYkRecord::~CYkRecord(void) 35 | { 36 | } 37 | 38 | int CYkRecord::AddDataRecord(unsigned char yk_event,int yk_no,bool bCloseOrOpen) 39 | { 40 | using namespace std; 41 | 42 | string ykEvent = strUndefineEvent; 43 | switch (yk_event) 44 | { 45 | case yk_sel: 46 | ykEvent = strYkSelEvent; 47 | break; 48 | 49 | case yk_exe: 50 | ykEvent = strYkExeEvent; 51 | break; 52 | 53 | case yk_cancel: 54 | ykEvent = strYkCancelEvent; 55 | break; 56 | 57 | case yk_over: 58 | ykEvent = strYkOverEvent; 59 | break; 60 | 61 | case yk_sel_fail: 62 | ykEvent = strYkSelFailEvent; 63 | break; 64 | 65 | case yk_exe_fail: 66 | ykEvent = strYkExeFailEvent; 67 | break; 68 | 69 | case yk_cancel_fail: 70 | ykEvent = strYkCancelFailEvent; 71 | break; 72 | 73 | case yk_sel_con: 74 | ykEvent = strYkSelConEvent; 75 | break; 76 | 77 | case yk_exe_con: 78 | ykEvent = strYkExeConEvent; 79 | break; 80 | 81 | case yk_cancel_con: 82 | ykEvent = strYkCancelConEvent; 83 | break; 84 | 85 | default: 86 | ykEvent = strUndefineEvent; 87 | break; 88 | } 89 | 90 | string no = boost::lexical_cast(yk_no); 91 | string YkVal; 92 | if (bCloseOrOpen) 93 | { 94 | YkVal = strYkClose; 95 | } 96 | else 97 | { 98 | YkVal = strYkOpen; 99 | } 100 | 101 | FileSystem::name_val_set set; 102 | set.push_back(FileSystem::name_val(strYkEvent,ykEvent)); 103 | set.push_back(FileSystem::name_val(strYkNO,no)); 104 | set.push_back(FileSystem::name_val(strYkVal,YkVal)); 105 | 106 | return CDataRecord::AddDataRecord(set); 107 | } 108 | 109 | }; //namespace DataBase 110 | -------------------------------------------------------------------------------- /DataBase/YkRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DataRecord.h" 3 | 4 | namespace DataBase { 5 | 6 | const unsigned char yk_sel = 1; 7 | const unsigned char yk_exe = 2; 8 | const unsigned char yk_cancel = 3; 9 | const unsigned char yk_over = 4; 10 | const unsigned char yk_sel_fail = 5; 11 | const unsigned char yk_exe_fail = 6; 12 | const unsigned char yk_cancel_fail = 7; 13 | const unsigned char yk_sel_con = 8; 14 | const unsigned char yk_exe_con = 9; 15 | const unsigned char yk_cancel_con = 10; 16 | 17 | class CYkRecord : 18 | public CDataRecord 19 | { 20 | public: 21 | CYkRecord(std::string id,int limit); 22 | CYkRecord(std::string id); 23 | virtual ~CYkRecord(void); 24 | 25 | int AddDataRecord(unsigned char yk_event,int yk_no,bool bCloseOrOpen); 26 | }; 27 | 28 | }; //namespace DataBase 29 | -------------------------------------------------------------------------------- /DataBase/YkSelState.cpp: -------------------------------------------------------------------------------- 1 | #include "YkSelState.h" 2 | #include "YkCancelState.h" 3 | #include "YkExeState.h" 4 | 5 | namespace DataBase { 6 | 7 | CYkSelState::CYkSelState(void) 8 | { 9 | } 10 | 11 | CYkSelState::~CYkSelState(void) 12 | { 13 | } 14 | 15 | int CYkSelState::SendSelEvent(CYkPoint & ykPoint) 16 | { 17 | return 0; 18 | } 19 | 20 | int CYkSelState::BackSelEvent(CYkPoint & ykPoint) 21 | { 22 | return 0; 23 | } 24 | 25 | int CYkSelState::SelResponEvent(CYkPoint & ykPoint) 26 | { 27 | return 0; 28 | } 29 | 30 | int CYkSelState::RecvExeEvent(CYkPoint & ykPoint) 31 | { 32 | ChangeState(ykPoint,new CYkExeState()); 33 | 34 | return 0; 35 | } 36 | 37 | int CYkSelState::RecvCancelEvent(CYkPoint & ykPoint) 38 | { 39 | ChangeState(ykPoint,new CYkCancelState()); 40 | 41 | return 0; 42 | } 43 | 44 | }; //namespace DataBase 45 | 46 | -------------------------------------------------------------------------------- /DataBase/YkSelState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "YkState.h" 3 | 4 | namespace DataBase { 5 | 6 | class CYkSelState : 7 | public CYkState 8 | { 9 | public: 10 | CYkSelState(void); 11 | virtual ~CYkSelState(void); 12 | 13 | virtual int SendSelEvent(CYkPoint & ykPoint); 14 | virtual int BackSelEvent(CYkPoint & ykPoint); 15 | virtual int SelResponEvent(CYkPoint & ykPoint); 16 | 17 | virtual int RecvExeEvent(CYkPoint & ykPoint); 18 | 19 | virtual int RecvCancelEvent(CYkPoint & ykPoint); 20 | }; 21 | 22 | };//namespace DataBase 23 | -------------------------------------------------------------------------------- /DataBase/YkState.cpp: -------------------------------------------------------------------------------- 1 | #include "YkReadyState.h" 2 | #include "YkPoint.h" 3 | 4 | namespace DataBase { 5 | 6 | CYkState::CYkState(void) 7 | { 8 | } 9 | 10 | CYkState::~CYkState(void) 11 | { 12 | } 13 | 14 | void CYkState::ChangeState( CYkPoint & point,CYkState * state ) 15 | { 16 | point.ChangeState(state); 17 | } 18 | 19 | int CYkState::RecvSelEvent( CYkPoint & ykPoint ) 20 | { 21 | ChangeState(ykPoint,new CYkReadyState()); 22 | 23 | return -1; 24 | } 25 | 26 | int CYkState::SendSelEvent( CYkPoint & ykPoint ) 27 | { 28 | ChangeState(ykPoint,new CYkReadyState()); 29 | 30 | return -1; 31 | } 32 | 33 | int CYkState::BackSelEvent( CYkPoint & ykPoint ) 34 | { 35 | ChangeState(ykPoint,new CYkReadyState()); 36 | 37 | return -1; 38 | } 39 | 40 | int CYkState::SelResponEvent( CYkPoint & ykPoint ) 41 | { 42 | ChangeState(ykPoint,new CYkReadyState()); 43 | 44 | return -1; 45 | } 46 | 47 | int CYkState::RecvExeEvent( CYkPoint & ykPoint ) 48 | { 49 | ChangeState(ykPoint,new CYkReadyState()); 50 | 51 | return -1; 52 | } 53 | 54 | int CYkState::SendExeEvent( CYkPoint & ykPoint ) 55 | { 56 | ChangeState(ykPoint,new CYkReadyState()); 57 | 58 | return -1; 59 | } 60 | 61 | int CYkState::BackExeEvent( CYkPoint & ykPoint ) 62 | { 63 | ChangeState(ykPoint,new CYkReadyState()); 64 | 65 | return -1; 66 | } 67 | 68 | int CYkState::ExeResponEvent( CYkPoint & ykPoint ) 69 | { 70 | ChangeState(ykPoint,new CYkReadyState()); 71 | 72 | return -1; 73 | } 74 | 75 | int CYkState::RecvCancelEvent( CYkPoint & ykPoint ) 76 | { 77 | ChangeState(ykPoint,new CYkReadyState()); 78 | 79 | return -1; 80 | } 81 | 82 | int CYkState::SendCancelEvent( CYkPoint & ykPoint ) 83 | { 84 | ChangeState(ykPoint,new CYkReadyState()); 85 | 86 | return -1; 87 | } 88 | 89 | int CYkState::BackCancelEvent( CYkPoint & ykPoint ) 90 | { 91 | ChangeState(ykPoint,new CYkReadyState()); 92 | 93 | return -1; 94 | } 95 | 96 | int CYkState::CancelResponEvent( CYkPoint & ykPoint ) 97 | { 98 | ChangeState(ykPoint,new CYkReadyState()); 99 | 100 | return -1; 101 | } 102 | 103 | int CYkState::OverYkEvent(CYkPoint & ykPoint) 104 | { 105 | ChangeState(ykPoint,new CYkReadyState()); 106 | 107 | return -1; 108 | } 109 | 110 | int CYkState::TimeOutEvent( CYkPoint & ykPoint ) 111 | { 112 | ChangeState(ykPoint,new CYkReadyState()); 113 | 114 | return 0; 115 | } 116 | 117 | }; //namespace DataBase 118 | -------------------------------------------------------------------------------- /DataBase/YkState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef YkState_H 3 | #define YkState_H 4 | 5 | namespace DataBase { 6 | 7 | class CYkPoint; 8 | 9 | class CYkState 10 | { 11 | public: 12 | CYkState(void); 13 | virtual ~CYkState(void); 14 | 15 | virtual int RecvSelEvent(CYkPoint & ykPoint); 16 | virtual int SendSelEvent(CYkPoint & ykPoint); 17 | virtual int BackSelEvent(CYkPoint & ykPoint); 18 | virtual int SelResponEvent(CYkPoint & ykPoint); 19 | 20 | virtual int RecvExeEvent(CYkPoint & ykPoint); 21 | virtual int SendExeEvent(CYkPoint & ykPoint); 22 | virtual int BackExeEvent(CYkPoint & ykPoint); 23 | virtual int ExeResponEvent(CYkPoint & ykPoint); 24 | 25 | virtual int RecvCancelEvent(CYkPoint & ykPoint); 26 | virtual int SendCancelEvent(CYkPoint & ykPoint); 27 | virtual int BackCancelEvent(CYkPoint & ykPoint); 28 | virtual int CancelResponEvent(CYkPoint & ykPoint); 29 | 30 | virtual int OverYkEvent(CYkPoint & ykPoint); 31 | 32 | virtual int TimeOutEvent(CYkPoint & ykPoint); 33 | 34 | protected: 35 | void ChangeState(CYkPoint & point,CYkState * state); 36 | }; 37 | 38 | };//namespace DataBase 39 | 40 | #endif //#ifndef YkState_H 41 | -------------------------------------------------------------------------------- /DataBase/YmDB.cpp: -------------------------------------------------------------------------------- 1 | #include "YmDB.h" 2 | #include "YmPoint.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CYmDB::CYmDB(void) 8 | { 9 | } 10 | 11 | CYmDB::~CYmDB(void) 12 | { 13 | } 14 | 15 | int CYmDB::InitDataBase(FileSystem::CMarkup & xml) 16 | { 17 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 18 | } 19 | 20 | void CYmDB::SaveXmlCfg(FileSystem::CMarkup & xml) 21 | { 22 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 23 | } 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/YmDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CYmPoint; 13 | 14 | class CYmDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CYmDB(void); 19 | ~CYmDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | }; 24 | 25 | };//namespace DataBase 26 | 27 | -------------------------------------------------------------------------------- /DataBase/YmPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "YmPoint.h" 2 | #include "../FileSystem/Markup.h" 3 | 4 | namespace DataBase { 5 | 6 | CYmPoint::CYmPoint(void) 7 | { 8 | ymVal_ = DefaultYmVal; 9 | } 10 | 11 | CYmPoint::CYmPoint(typeYmval ymval) 12 | :ymVal_(ymval) 13 | { 14 | 15 | } 16 | 17 | CYmPoint::~CYmPoint(void) 18 | { 19 | } 20 | 21 | typeYmval CYmPoint::getOriYmVal() 22 | { 23 | return ymVal_; 24 | } 25 | 26 | int CYmPoint::setOriYmVal(typeYmval val) 27 | { 28 | ymVal_ = val; 29 | 30 | return 0; 31 | } 32 | 33 | typeYmquality CYmPoint::getYmQuality() 34 | { 35 | return ymQuality_; 36 | } 37 | 38 | int CYmPoint::setYmQuality(typeYmquality val) 39 | { 40 | ymQuality_ = val; 41 | 42 | return 0; 43 | } 44 | 45 | //xml api 46 | void CYmPoint::SaveXmlCfg(FileSystem::CMarkup & xml) 47 | { 48 | } 49 | 50 | int CYmPoint::LoadXmlCfg(FileSystem::CMarkup & xml) 51 | { 52 | return 0; 53 | } 54 | 55 | }; //namespace DataBase 56 | -------------------------------------------------------------------------------- /DataBase/YmPoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../PublicSupport/Dat2cTypeDef.h" 3 | 4 | namespace FileSystem 5 | { 6 | class CMarkup; 7 | } 8 | 9 | namespace DataBase { 10 | 11 | class CYmPoint 12 | { 13 | public: 14 | CYmPoint(void); 15 | CYmPoint(typeYmval ymval); 16 | ~CYmPoint(void); 17 | 18 | typeYmval getOriYmVal(); 19 | int setOriYmVal(typeYmval val); 20 | typeYmquality getYmQuality(); 21 | int setYmQuality(typeYmquality val); 22 | 23 | //xml api 24 | void SaveXmlCfg(FileSystem::CMarkup & xml); 25 | int LoadXmlCfg(FileSystem::CMarkup & xml); 26 | 27 | protected: 28 | enum 29 | { 30 | DefaultYmVal = 0 31 | }; 32 | 33 | typeYmval ymVal_; 34 | typeYmquality ymQuality_; 35 | }; 36 | 37 | }; //namespace DataBase 38 | -------------------------------------------------------------------------------- /DataBase/YxDB.cpp: -------------------------------------------------------------------------------- 1 | #include "YxDB.h" 2 | #include "YxPoint.h" 3 | #include "../FileSystem/Markup.h" 4 | 5 | namespace DataBase { 6 | 7 | CYxDB::CYxDB(void) 8 | { 9 | yxPolar_ = CYxPoint::DefaultYxPolar; 10 | } 11 | 12 | CYxDB::~CYxDB(void) 13 | { 14 | } 15 | 16 | int CYxDB::InitDataBase(FileSystem::CMarkup & xml) 17 | { 18 | LoadXmlAttrib(xml); 19 | 20 | return PublicSupport::CDynamicArrayDataBase::InitDataBase(xml); 21 | } 22 | 23 | void CYxDB::SaveXmlCfg(FileSystem::CMarkup & xml) 24 | { 25 | SaveXmlAttrib(xml); 26 | 27 | PublicSupport::CDynamicArrayDataBase::SaveXmlCfg(xml); 28 | } 29 | 30 | int CYxDB::InitDataNodes(FileSystem::CMarkup & xml) 31 | { 32 | for (size_t i=0;isetYxPolar(yxPolar_); 37 | } 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | int CYxDB::LoadXmlAttrib(FileSystem::CMarkup & xml) 44 | { 45 | std::string strTmp = xml.GetAttrib(strYxPolar); 46 | boost::algorithm::trim(strTmp); 47 | if (boost::algorithm::iequals(strboolFalse,strTmp)) 48 | { 49 | yxPolar_ = false; 50 | } 51 | else 52 | { 53 | yxPolar_ = true; 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | void CYxDB::SaveXmlAttrib(FileSystem::CMarkup & xml) 60 | { 61 | if (yxPolar_ != CYxPoint::DefaultYxPolar) 62 | { 63 | if (yxPolar_) 64 | { 65 | xml.AddAttrib(strYxPolar,strboolTrue); 66 | } 67 | else 68 | { 69 | xml.AddAttrib(strYxPolar,strboolFalse); 70 | } 71 | } 72 | } 73 | 74 | };//namespace DataBase 75 | 76 | -------------------------------------------------------------------------------- /DataBase/YxDB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../PublicSupport/DynamicArrayDataBase.h" 4 | 5 | namespace FileSystem 6 | { 7 | class CMarkup; 8 | } 9 | 10 | namespace DataBase { 11 | 12 | class CYxPoint; 13 | 14 | class CYxDB 15 | :public PublicSupport::CDynamicArrayDataBase 16 | { 17 | public: 18 | CYxDB(void); 19 | ~CYxDB(void); 20 | 21 | int InitDataBase(FileSystem::CMarkup & xml); 22 | void SaveXmlCfg(FileSystem::CMarkup & xml); 23 | 24 | int InitDataNodes(FileSystem::CMarkup & xml); 25 | 26 | private: 27 | int LoadXmlAttrib(FileSystem::CMarkup & xml); 28 | void SaveXmlAttrib(FileSystem::CMarkup & xml); 29 | 30 | private: 31 | bool yxPolar_; 32 | }; 33 | 34 | };//namespace DataBase 35 | 36 | -------------------------------------------------------------------------------- /DataBase/YxPoint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DataBase/YxPoint.h -------------------------------------------------------------------------------- /DigitalSignature/EccPrivateKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/EccPrivateKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/EccPrivateKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/EccPrivateKey.h -------------------------------------------------------------------------------- /DigitalSignature/EccPublicKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/EccPublicKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/EccPublicKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/EccPublicKey.h -------------------------------------------------------------------------------- /DigitalSignature/EvpKey.cpp: -------------------------------------------------------------------------------- 1 | #include "EvpKey.h" 2 | #include 3 | 4 | namespace DigitalSignature { 5 | 6 | CEvpKey::CEvpKey(void) 7 | { 8 | } 9 | 10 | CEvpKey::~CEvpKey(void) 11 | { 12 | } 13 | 14 | int CEvpKey::encrypt(const unsigned char * src,int srcLength,unsigned char * dst) 15 | { 16 | memcpy(dst,src,srcLength); 17 | 18 | return srcLength; 19 | } 20 | 21 | int CEvpKey::decrypt(const unsigned char * src,int srcLength,unsigned char * dst) 22 | { 23 | memcpy(dst,src,srcLength); 24 | 25 | return srcLength; 26 | } 27 | 28 | };//namespace DigitalSignature 29 | -------------------------------------------------------------------------------- /DigitalSignature/EvpKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace DigitalSignature { 4 | 5 | class CEvpKey 6 | { 7 | public: 8 | CEvpKey(void); 9 | virtual ~CEvpKey(void); 10 | 11 | virtual int encrypt(const unsigned char * src,int srcLength,unsigned char * dst); 12 | virtual int decrypt(const unsigned char * src,int srcLength,unsigned char * dst); 13 | }; 14 | 15 | };//namespace DigitalSignature 16 | 17 | -------------------------------------------------------------------------------- /DigitalSignature/KeyFactory.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/KeyFactory.cpp -------------------------------------------------------------------------------- /DigitalSignature/KeyFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Protocol 5 | { 6 | class CProtocol; 7 | } 8 | 9 | namespace DigitalSignature { 10 | 11 | class CPrivateKey; 12 | class CPublicKey; 13 | class CEvpKey; 14 | 15 | class CKeyFactory 16 | { 17 | public: 18 | virtual ~CKeyFactory(void); 19 | static CPrivateKey * CreatePrivateKey(std::string keytype,std::string keypath); 20 | static CPublicKey * CreatePublicKey(std::string keytype,std::string keypath,Protocol::CProtocol & pl); 21 | static CEvpKey * CreateEvpKey(std::string keytype,std::string keypath); 22 | 23 | private: 24 | CKeyFactory(void); 25 | 26 | static std::string TransSecretKeyTypeToString(unsigned char val); 27 | static unsigned char TransSecretKeyTypeFromString(std::string val); 28 | 29 | static std::string TransEvpKeyTypeToString(unsigned char val); 30 | static unsigned char TransEvpKeyTypeFromString(std::string val); 31 | }; 32 | 33 | }; //namespace DigitalSignature 34 | -------------------------------------------------------------------------------- /DigitalSignature/PrivateKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/PrivateKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/PrivateKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/PrivateKey.h -------------------------------------------------------------------------------- /DigitalSignature/PublicKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/PublicKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/PublicKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/PublicKey.h -------------------------------------------------------------------------------- /DigitalSignature/RsaPrivateKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/RsaPrivateKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/RsaPrivateKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "PrivateKey.h" 4 | 5 | namespace DigitalSignature { 6 | 7 | class CRsaPrivateKey 8 | :public CPrivateKey 9 | { 10 | public: 11 | CRsaPrivateKey(std::string keypath, std::string passwd); 12 | CRsaPrivateKey(std::string keypath); 13 | virtual ~CRsaPrivateKey(void); 14 | 15 | virtual bool ValidKey(); 16 | 17 | private: 18 | virtual int getKeyLength(); 19 | virtual int Sign(const unsigned char *dgst, int dgstlen,unsigned char *sig, unsigned int *siglen); 20 | 21 | int LoadKey(std::string keypath, const char * passwd); 22 | int FreeKey(); 23 | 24 | private: 25 | RSA * key_; 26 | }; 27 | 28 | };//namespace DigitalSignature 29 | -------------------------------------------------------------------------------- /DigitalSignature/RsaPublicKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/RsaPublicKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/RsaPublicKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "PublicKey.h" 3 | #include 4 | 5 | namespace DigitalSignature { 6 | 7 | class CRsaPublicKey 8 | :public CPublicKey 9 | { 10 | public: 11 | CRsaPublicKey(std::string keypath); 12 | virtual ~CRsaPublicKey(void); 13 | 14 | virtual bool ValidKey(); 15 | virtual int getKeyLength(); 16 | 17 | private: 18 | virtual int Authentic(unsigned char *dgst, int dgstlen,unsigned char *sig, int siglen); 19 | 20 | int LoadKey(std::string keypath); 21 | int FreeKey(); 22 | 23 | private: 24 | EVP_PKEY * key_; 25 | }; 26 | 27 | };//namespace DigitalSignature 28 | 29 | -------------------------------------------------------------------------------- /DigitalSignature/Sm2PrivateKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/Sm2PrivateKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/Sm2PrivateKey.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "privatekey.h" 3 | 4 | namespace DigitalSignature { 5 | 6 | class CSm2PrivateKey : 7 | public CPrivateKey 8 | { 9 | public: 10 | CSm2PrivateKey(std::string keyPath, std::string passwd); 11 | CSm2PrivateKey(std::string keyPath); 12 | virtual ~CSm2PrivateKey(void); 13 | 14 | virtual bool ValidKey(); 15 | 16 | private: 17 | virtual int getKeyLength(); 18 | virtual int Sign(const unsigned char *dgst, int dgstlen,unsigned char *sig, unsigned int *siglen); 19 | 20 | int LoadKey(std::string strBigNum, const char * passwd); 21 | int FreeKey(); 22 | }; 23 | 24 | };//namespace DigitalSignature 25 | 26 | -------------------------------------------------------------------------------- /DigitalSignature/Sm2PublicKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/Sm2PublicKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/Sm2PublicKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/Sm2PublicKey.h -------------------------------------------------------------------------------- /DigitalSignature/SpeEccPrivateKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/SpeEccPrivateKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/SpeEccPrivateKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/SpeEccPrivateKey.h -------------------------------------------------------------------------------- /DigitalSignature/SpeEccPublicKey.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/SpeEccPublicKey.cpp -------------------------------------------------------------------------------- /DigitalSignature/SpeEccPublicKey.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DigitalSignature/SpeEccPublicKey.h -------------------------------------------------------------------------------- /DigitalSignature/sm2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sm2.h 3 | * edit : Kern 4 | * Created on: 2011-6-3 5 | * Author: zweib@sgepri.sgcc 6 | */ 7 | 8 | #ifndef HEADER_SM2_H 9 | #define HEADER_SM2_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | namespace DigitalSignature { 16 | 17 | #define ECCref_MAX_BITS 256 //该常量定义按照目前国内支持的ECC最大模长而定 18 | #define ECCref_MAX_LEN ((ECCref_MAX_BITS+7) / 8) 19 | 20 | typedef struct ECCrefPublicKey_st 21 | { 22 | unsigned int bits; 23 | unsigned char x[ECCref_MAX_LEN]; 24 | unsigned char y[ECCref_MAX_LEN]; 25 | } ECCrefPublicKey; 26 | 27 | typedef struct ECCrefPrivateKey_st 28 | { 29 | unsigned int bits; 30 | unsigned char D[ECCref_MAX_LEN]; 31 | } ECCrefPrivateKey; 32 | 33 | typedef struct ECCCipher_st 34 | { 35 | unsigned char x[ECCref_MAX_LEN]; 36 | unsigned char y[ECCref_MAX_LEN]; 37 | unsigned char C[ECCref_MAX_LEN]; 38 | unsigned char M[ECCref_MAX_LEN]; 39 | } ECCCipher; 40 | 41 | typedef struct ECCSignature_st 42 | { 43 | unsigned char r[ECCref_MAX_LEN]; 44 | unsigned char s[ECCref_MAX_LEN]; 45 | } ECCSignature; 46 | 47 | int SM2_Verify(unsigned char *pucDataInput, unsigned int uiInputLength, 48 | unsigned char *pucID, unsigned int uiIDLength, 49 | ECCrefPublicKey *pucPublicKey, ECCSignature *pucSignature); 50 | 51 | int SM2_Encrypt(unsigned char *pucDataInput, unsigned int uiInputLength, 52 | ECCrefPublicKey *pucPublicKey, unsigned char *pucRandom, 53 | unsigned int uiRandomLength, ECCCipher *pucEncData); 54 | 55 | int SM2_GenerateRandom(unsigned int uiLength, unsigned char *pucRandom); 56 | 57 | void sm2_init(); 58 | 59 | void sm2_final(); 60 | 61 | };//namespace DigitalSignature 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | #endif 67 | -------------------------------------------------------------------------------- /DistributedFA/DistributedDA.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DistributedDA.h" 3 | 4 | namespace DistributedFA { 5 | 6 | CDistributedDA::CDistributedDA(boost::asio::io_service & io_service,std::string id,DataBase::CDAOperate & da_op) 7 | :self_(da_op) 8 | { 9 | } 10 | 11 | CDistributedDA::~CDistributedDA(void) 12 | { 13 | } 14 | 15 | int CDistributedDA::ConnectSubAlgorithmSig(CmdRecallSignalType & sig) 16 | { 17 | SubAlgorithmSigConnection_ = sig.connect(boost::bind(&CDistributedDA::ProcessAlgorithmSig,this,_1,_2,_3,_4)); 18 | 19 | return 0; 20 | } 21 | 22 | int CDistributedDA::DisconnectSubAlgorithmSig() 23 | { 24 | SubAlgorithmSigConnection_.disconnect(); 25 | 26 | return 0; 27 | } 28 | 29 | void CDistributedDA::ProcessAlgorithmSig(typeCmd cmdType,unsigned char ReturnCode,share_commpoint_ptr point,boost::any val) 30 | { 31 | 32 | } 33 | 34 | }; //namespace DistributedFA 35 | -------------------------------------------------------------------------------- /DistributedFA/DistributedDA.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //#include 3 | //#include 4 | #include 5 | #include "SelfNode.h" 6 | #include "../PublicSupport/Dat2cTypeDef.h" 7 | 8 | namespace DataBase 9 | { 10 | class CDAOperate; 11 | } 12 | 13 | namespace DistributedFA { 14 | 15 | class CDistributedDA 16 | { 17 | public: 18 | CDistributedDA(boost::asio::io_service & io_service,std::string id,DataBase::CDAOperate & da_op); 19 | ~CDistributedDA(void); 20 | 21 | int start(CmdRecallSignalType & sig); 22 | void stop(); 23 | 24 | private: 25 | void ProcessAlgorithmSig(typeCmd cmdType,unsigned char ReturnCode,share_commpoint_ptr point,boost::any val); 26 | int ConnectSubAlgorithmSig(CmdRecallSignalType & sig); 27 | int DisconnectSubAlgorithmSig(); 28 | 29 | private: 30 | SigConnection SubAlgorithmSigConnection_; 31 | CSelfNode self_; 32 | }; 33 | 34 | }; //namespace DistributedFA 35 | -------------------------------------------------------------------------------- /DistributedFA/LinkNode.cpp: -------------------------------------------------------------------------------- 1 | #include "LinkNode.h" 2 | #include "../DataBase/DAOperate.h" 3 | 4 | namespace DistributedFA { 5 | 6 | CLinkNode::CLinkNode(boost::asio::io_service & io_service,DataBase::CDAOperate & da_op) 7 | :COperateNode(da_op), 8 | CCommPoint(io_service), 9 | da_op_(da_op) 10 | { 11 | } 12 | 13 | CLinkNode::~CLinkNode(void) 14 | { 15 | } 16 | 17 | //bool CLinkNode::getCommAlive() 18 | //{ 19 | // if(da_op_.getYxVal(getCommIndex())) 20 | // { 21 | // return true; 22 | // } 23 | // else 24 | // { 25 | // return false; 26 | // } 27 | //} 28 | 29 | //int CLinkNode::getCommIndex() 30 | //{ 31 | // return CommIndex_; 32 | //} 33 | // 34 | //int CLinkNode::setCommIndex(int val) 35 | //{ 36 | // CommIndex_ = val; 37 | // 38 | // return 0; 39 | //} 40 | 41 | int CLinkNode::getPosition() 42 | { 43 | if (getCommActive()) 44 | { 45 | return COperateNode::getPosition(); 46 | } 47 | 48 | return -1; 49 | } 50 | 51 | int CLinkNode::getProtect() 52 | { 53 | if (getCommActive()) 54 | { 55 | return COperateNode::getProtect(); 56 | } 57 | 58 | return -1; 59 | } 60 | 61 | int CLinkNode::OpenSwitchSel() 62 | { 63 | if (getCommActive()) 64 | { 65 | return COperateNode::OpenSwitchSel(); 66 | } 67 | 68 | return -1; 69 | } 70 | 71 | int CLinkNode::OpenSwitchExe() 72 | { 73 | if (getCommActive()) 74 | { 75 | return COperateNode::OpenSwitchExe(); 76 | } 77 | 78 | return -1; 79 | } 80 | 81 | int CLinkNode::CloseSwitchSel() 82 | { 83 | if (getCommActive()) 84 | { 85 | return COperateNode::CloseSwitchSel(); 86 | } 87 | 88 | return -1; 89 | } 90 | 91 | int CLinkNode::CloseSwitchExe() 92 | { 93 | if (getCommActive()) 94 | { 95 | return COperateNode::CloseSwitchExe(); 96 | } 97 | 98 | return -1; 99 | } 100 | 101 | share_commpoint_ptr CLinkNode::getSelfPtr() 102 | { 103 | return share_commpoint_ptr(this); 104 | } 105 | 106 | SigConnection CLinkNode::ConnectSubAliveSig(CmdRecallSlotType slotVal) 107 | { 108 | return da_op_.ConnectYkSig(slotVal); 109 | } 110 | 111 | SigConnection CLinkNode::ConnectSubTempSig(CmdRecallSlotType slotVal) 112 | { 113 | return SigConnection(); 114 | } 115 | 116 | int CLinkNode::LoadXmlCfg(FileSystem::CMarkup & xml) 117 | { 118 | int ret = DataBase::CCommPoint::LoadXmlCfg(xml); 119 | 120 | return ret; 121 | } 122 | 123 | void CLinkNode::SaveXmlCfg(FileSystem::CMarkup & xml) 124 | { 125 | DataBase::CCommPoint::SaveXmlCfg(xml); 126 | } 127 | 128 | }; //namespace DistributedFA 129 | 130 | -------------------------------------------------------------------------------- /DistributedFA/LinkNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DistributedFA/LinkNode.h -------------------------------------------------------------------------------- /DistributedFA/LoadSwtich.cpp: -------------------------------------------------------------------------------- 1 | #include "LoadSwtich.h" 2 | 3 | namespace DistributedFA { 4 | 5 | CLoadSwtich::CLoadSwtich(DataBase::CDAOperate & da_op) 6 | :COperateNode(da_op) 7 | { 8 | } 9 | 10 | CLoadSwtich::~CLoadSwtich(void) 11 | { 12 | } 13 | 14 | }; //namespace DistributedFA 15 | -------------------------------------------------------------------------------- /DistributedFA/LoadSwtich.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "OperateNode.h" 3 | 4 | namespace DistributedFA { 5 | 6 | class CLoadSwtich : 7 | public COperateNode 8 | { 9 | public: 10 | CLoadSwtich(DataBase::CDAOperate & da_op); 11 | virtual ~CLoadSwtich(void); 12 | }; 13 | 14 | };//namespace DistributedFA 15 | -------------------------------------------------------------------------------- /DistributedFA/OperateNode.cpp: -------------------------------------------------------------------------------- 1 | #include "OperateNode.h" 2 | #include "../DataBase/DAOperate.h" 3 | 4 | namespace DistributedFA { 5 | 6 | COperateNode::COperateNode(DataBase::CDAOperate & da_op) 7 | :da_op_(da_op) 8 | { 9 | } 10 | 11 | COperateNode::~COperateNode(void) 12 | { 13 | } 14 | 15 | int COperateNode::getPositionIndex() 16 | { 17 | return PositionYxIndex_; 18 | } 19 | 20 | int COperateNode::getProtectIndex() 21 | { 22 | return ProtectYxIndex_; 23 | } 24 | 25 | int COperateNode::setPositionIndex(int val) 26 | { 27 | PositionYxIndex_ = val; 28 | 29 | return 0; 30 | } 31 | 32 | int COperateNode::setProtectIndex(int val) 33 | { 34 | ProtectYxIndex_ = val; 35 | 36 | return 0; 37 | } 38 | 39 | int COperateNode::getPosition() 40 | { 41 | if(da_op_.getYxVal(getPositionIndex())) 42 | { 43 | return PositionClose; 44 | } 45 | else 46 | { 47 | return PositionOpen; 48 | } 49 | } 50 | 51 | int COperateNode::getProtect() 52 | { 53 | if(da_op_.getYxVal(getProtectIndex())) 54 | { 55 | return ProtectedPositive; 56 | } 57 | else 58 | { 59 | return ProtectedNagetive; 60 | } 61 | } 62 | 63 | int COperateNode::OpenSwitchSel() 64 | { 65 | return da_op_.AddYkSelCmd(PositionYkIndex_,false); 66 | } 67 | 68 | int COperateNode::OpenSwitchExe() 69 | { 70 | return da_op_.AddYkExeCmd(PositionYkIndex_,false); 71 | } 72 | 73 | int COperateNode::CloseSwitchSel() 74 | { 75 | return da_op_.AddYkSelCmd(PositionYkIndex_,true); 76 | } 77 | 78 | int COperateNode::CloseSwitchExe() 79 | { 80 | return da_op_.AddYkExeCmd(PositionYkIndex_,true); 81 | } 82 | 83 | }; //namespace DistributedFA 84 | -------------------------------------------------------------------------------- /DistributedFA/OperateNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DistributedFA/OperateNode.h -------------------------------------------------------------------------------- /DistributedFA/SWNode.cpp: -------------------------------------------------------------------------------- 1 | #include "SWNode.h" 2 | 3 | namespace DistributedFA { 4 | 5 | CSWNode::CSWNode(void) 6 | { 7 | } 8 | 9 | CSWNode::~CSWNode(void) 10 | { 11 | } 12 | 13 | }; //namespace DistributedFA 14 | -------------------------------------------------------------------------------- /DistributedFA/SWNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DistributedFA/SWNode.h -------------------------------------------------------------------------------- /DistributedFA/SelfNode.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DistributedFA/SelfNode.cpp -------------------------------------------------------------------------------- /DistributedFA/SelfNode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/DistributedFA/SelfNode.h -------------------------------------------------------------------------------- /DistributedFA/TieSwitch.cpp: -------------------------------------------------------------------------------- 1 | #include "TieSwitch.h" 2 | 3 | namespace DistributedFA { 4 | 5 | CTieSwitch::CTieSwitch(DataBase::CDAOperate & da_op) 6 | :COperateNode(da_op) 7 | { 8 | } 9 | 10 | CTieSwitch::~CTieSwitch(void) 11 | { 12 | } 13 | 14 | }; //namespace DistributedFA 15 | 16 | -------------------------------------------------------------------------------- /DistributedFA/TieSwitch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "OperateNode.h" 3 | 4 | namespace DistributedFA { 5 | 6 | class CTieSwitch : 7 | public COperateNode 8 | { 9 | public: 10 | CTieSwitch(DataBase::CDAOperate & da_op); 11 | virtual ~CTieSwitch(void); 12 | }; 13 | 14 | };//namespace DistributedFA 15 | -------------------------------------------------------------------------------- /EccSite.key: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIMqn89Ls/Oya63esdFNDza/K65kiPUnPVk4YVEIBM2rFoAoGCCqGSM49 6 | AwEHoUQDQgAE6PFSjfoiShlnkI7CcRCV6EL940vZOCr+O4w2F6NRVa0EyMIcb8m7 7 | bCT2VabRj3XQSnT/wVL7BKT34oeAakVrrw== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /EccSite.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBnjCCAUUCCQC9RDkp5CxncTAJBgcqhkjOPQQBMFgxCzAJBgNVBAYTAkNOMQsw 3 | CQYDVQQIEwJKUzEQMA4GA1UEBxMHTmFuamluZzEMMAoGA1UEChMDR0REMQ0wCwYD 4 | VQQLEwRuYXJpMQ0wCwYDVQQDEwR5b3lvMB4XDTEwMTEyNTA2MjI0OVoXDTIwMTEy 5 | MjA2MjI0OVowWDELMAkGA1UEBhMCQ04xCzAJBgNVBAgTAkpTMRAwDgYDVQQHEwdu 6 | YW5qaW5nMQwwCgYDVQQKEwNHREQxDTALBgNVBAsTBE5BUkkxDTALBgNVBAMTBHlv 7 | eW8wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATo8VKN+iJKGWeQjsJxEJXoQv3j 8 | S9k4Kv47jDYXo1FVrQTIwhxvybtsJPZVptGPddBKdP/BUvsEpPfih4BqRWuvMAkG 9 | ByqGSM49BAEDSAAwRQIgYISupDt5W7MXZAzU9dAEOxbCC5AXEN0ebC/aZ7l6VCIC 10 | IQCNqMefoU+A3mNx6ZJ3JSUAHr28WuSPOk/Xtxjewi9+5A== 11 | -----END CERTIFICATE----- 12 | -------------------------------------------------------------------------------- /EccSite2.key: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BggqhkjOPQMBBw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MHcCAQEEIDR7tmZhCCGzJlGyGeIpGyNu1LIRn9rsXCMKK8s/qqcOoAoGCCqGSM49 6 | AwEHoUQDQgAE9PPxqa//n9uc9UxTbM/rI+JqEkd1cTYXqEL51gHjQTdaqYgefd40 7 | /5yqpvJVnq8LivB0U4pIcOcdCRq47VX9CQ== 8 | -----END EC PRIVATE KEY----- 9 | -------------------------------------------------------------------------------- /EccSite2.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIB/DCCAaMCCQC6Qp20o3CbGDAJBgcqhkjOPQQBMIGGMQswCQYDVQQGEwJjbjEQ 3 | MA4GA1UECBMHamlhbmdzdTEPMA0GA1UEBxMGbmFuamluMQ0wCwYDVQQKEwRuYXJp 4 | MQ0wCwYDVQQLEwRuYXJpMRQwEgYDVQQDEwt6aGFuZ3poaWh1YTEgMB4GCSqGSIb3 5 | DQEJARYRenpoeWhoMTY5QHRvbS5jb20wHhcNMTEwNTA5MTIzMDI1WhcNMTEwNjA4 6 | MTIzMDI1WjCBhjELMAkGA1UEBhMCY24xEDAOBgNVBAgTB2ppYW5nc3UxDzANBgNV 7 | BAcTBm5hbmppbjENMAsGA1UEChMEbmFyaTENMAsGA1UECxMEbmFyaTEUMBIGA1UE 8 | AxMLemhhbmd6aGlodWExIDAeBgkqhkiG9w0BCQEWEXp6aHloaDE2OUB0b20uY29t 9 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9PPxqa//n9uc9UxTbM/rI+JqEkd1 10 | cTYXqEL51gHjQTdaqYgefd40/5yqpvJVnq8LivB0U4pIcOcdCRq47VX9CTAJBgcq 11 | hkjOPQQBA0gAMEUCIQCkh5XB4FcDnhqEbx/dKAYFOlXHDLY3uawF2qlKqWZ8AAIg 12 | WQjzLhlyn/Zj/KaaUF216mevTnZ4hsQlUmM024smiQI= 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /FileSystem/BoostLog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | //#include 10 | //#include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "BoostLog.h" 16 | 17 | namespace FileSystem { 18 | 19 | namespace logging = boost::log; 20 | namespace keywords = boost::log::keywords; 21 | namespace flt = boost::log::filters; 22 | namespace fmt = boost::log::formatters; 23 | namespace src = boost::log::sources; 24 | namespace sinks = boost::log::sinks; 25 | namespace attrs = boost::log::attributes; 26 | 27 | using boost::shared_ptr; 28 | 29 | CBoostLog::CBoostLog(std::string filename,std::string OpenMode,int limit) 30 | :CLog(filename,OpenMode) 31 | { 32 | InitSink(filename); 33 | } 34 | 35 | CBoostLog::CBoostLog(std::string filename,std::string OpenMode) 36 | :CLog(filename,OpenMode) 37 | { 38 | InitSink(filename); 39 | } 40 | 41 | CBoostLog::~CBoostLog(void) 42 | { 43 | } 44 | 45 | std::string CBoostLog::getFileType() 46 | { 47 | return strBoostLog; 48 | } 49 | 50 | int CBoostLog::AddRecord(std::string strval) 51 | { 52 | // Let's do a quick test and output something. We have to create a logger for this. 53 | //src::logger lg; 54 | src::channel_logger_mt<> lg(keywords::channel = strLogPath_); 55 | 56 | // And output... 57 | BOOST_LOG(lg) << strval; 58 | 59 | return 0; 60 | } 61 | 62 | int CBoostLog::AddRecordWithSynT(std::string strval) 63 | { 64 | // Let's do a quick test and output something. We have to create a logger for this. 65 | //src::logger lg; 66 | src::channel_logger_mt<> lg(keywords::channel = strLogPath_); 67 | 68 | // And output... 69 | BOOST_LOG(lg) << strval; 70 | 71 | return 0; 72 | } 73 | 74 | int CBoostLog::InitSink(std::string log_id) 75 | { 76 | try 77 | { 78 | boost::filesystem::path log_path(log_id); 79 | 80 | std::string extension_name = log_path.extension().string(); 81 | std::string parent_path = log_path.parent_path().string(); 82 | std::string stem = log_path.stem().string(); 83 | 84 | std::ostringstream ostr; 85 | if (parent_path.empty()) 86 | { 87 | ostr< file_sink; 96 | boost::shared_ptr sink(new file_sink( 97 | keywords::file_name = ostr.str(), // file name pattern 98 | keywords::rotation_size = 16384 // rotation size, in characters 99 | )); 100 | 101 | // Set up where the rotated files will be stored 102 | sink->locked_backend()->set_file_collector(sinks::file::make_collector( 103 | keywords::target = "logs", // where to store rotated files 104 | keywords::max_size = 16 * 1024 * 1024, // maximum total size of the stored files, in bytes 105 | keywords::min_free_space = 100 * 1024 * 1024 // minimum free space on the drive, in bytes 106 | )); 107 | 108 | // Upon restart, scan the target directory for files matching the file_name pattern 109 | sink->locked_backend()->scan_for_files(); 110 | 111 | sink->locked_backend()->set_formatter( 112 | fmt::format("%1%: [%2%] - %3%") 113 | % fmt::attr< unsigned int >("Line #") 114 | % fmt::date_time< boost::posix_time::ptime >("TimeStamp") 115 | % fmt::message() 116 | ); 117 | 118 | // Add it to the core 119 | logging::core::get()->add_sink(sink); 120 | 121 | // Add some attributes too 122 | boost::shared_ptr< logging::attribute > attr(new attrs::local_clock); 123 | logging::core::get()->add_global_attribute("TimeStamp", attr); 124 | attr.reset(new attrs::counter); 125 | logging::core::get()->add_global_attribute("Line #", attr); 126 | 127 | return 0; 128 | } 129 | catch (std::exception& e) 130 | { 131 | std::cout << "FAILURE: " << e.what() << std::endl; 132 | } 133 | 134 | return -1; 135 | } 136 | 137 | }; //namespace FileSystem 138 | -------------------------------------------------------------------------------- /FileSystem/BoostLog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "log.h" 3 | 4 | namespace FileSystem { 5 | 6 | class CBoostLog : 7 | public CLog 8 | { 9 | public: 10 | CBoostLog(std::string filename,std::string OpenMode,int limit); 11 | CBoostLog(std::string filename,std::string OpenMode); 12 | virtual ~CBoostLog(void); 13 | 14 | virtual std::string getFileType(); 15 | 16 | virtual int AddRecord(std::string strval); 17 | virtual int AddRecordWithSynT(std::string strval); 18 | 19 | private: 20 | int InitSink(std::string log_id); 21 | 22 | private: 23 | // Here we define our application severity levels. 24 | enum severity_level 25 | { 26 | normal, 27 | notification, 28 | warning, 29 | error, 30 | critical 31 | }; 32 | }; 33 | 34 | };//namespace FileSystem 35 | 36 | -------------------------------------------------------------------------------- /FileSystem/FileHandle.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/FileSystem/FileHandle.cpp -------------------------------------------------------------------------------- /FileSystem/FileHandle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define FILE_LENGTH 1024*100 5 | 6 | namespace FileSystem 7 | { 8 | class CFileHandle 9 | { 10 | public: 11 | CFileHandle(std::string filename); 12 | ~CFileHandle(void); 13 | 14 | public: 15 | 16 | unsigned long GetRemainLength(void); 17 | unsigned long GetTotalLength(void); 18 | unsigned int SetTotalLength(unsigned long Totallen); 19 | std::string GetFileName(void); 20 | 21 | int HandleWrite(void); 22 | int HandleWriteByByte(void); 23 | int HandleRead(void); 24 | int HandleReadFor533Pro(void); 25 | 26 | int OutFile(unsigned char * filedata,int length); 27 | int GetFile(unsigned char * filedata,int length); 28 | 29 | private: 30 | 31 | int WriteToFile(); 32 | int WriteToFileByByte(); 33 | int GetFromFile(); 34 | int GetFromFileFor533Pro(); 35 | char TransToChar(char data); 36 | 37 | protected: 38 | enum 39 | { 40 | 41 | }; 42 | 43 | private: 44 | unsigned char FileDataBuf[FILE_LENGTH]; 45 | 46 | std::string FileName; 47 | unsigned long FileLoadPtr_; 48 | unsigned long FileRemain_; 49 | unsigned long totallen_; 50 | }; 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /FileSystem/Log.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/FileSystem/Log.cpp -------------------------------------------------------------------------------- /FileSystem/Log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace FileSystem { 5 | 6 | const std::string strNoLog = "NoLog"; 7 | const std::string strTextLog = "TextLog"; 8 | const std::string strXmlLog = "XmlLog"; 9 | //const std::string strBoostLog = "BoostLog"; 10 | 11 | class CLog 12 | { 13 | public: 14 | CLog(std::string filename,std::string OpenMode); 15 | virtual ~CLog(void); 16 | virtual int AddRecord(std::string strval) = 0; 17 | virtual int AddRecordWithSynT(std::string strval) = 0; 18 | virtual std::string getFileType(); 19 | 20 | std::string getLogPath(); 21 | 22 | private: 23 | int GreateFilePath(std::string strFilePath); 24 | 25 | protected: 26 | std::string strLogPath_; 27 | std::string strMode_; 28 | }; 29 | 30 | }; //namespace FileSystem 31 | -------------------------------------------------------------------------------- /FileSystem/LogFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "LogFactory.h" 4 | #include "TextLog.h" 5 | #include "XmlLog.h" 6 | //#include "BoostLog.h" 7 | 8 | namespace FileSystem { 9 | 10 | const unsigned char NoLog = 0; 11 | const unsigned char TextLog = 1; 12 | const unsigned char XmlLog = 2; 13 | //const unsigned char BoostLog = 3; 14 | 15 | CLogFactory::CLogFactory(void) 16 | { 17 | } 18 | 19 | 20 | CLogFactory::~CLogFactory(void) 21 | { 22 | } 23 | 24 | CLog * CLogFactory::CreateLog(std::string log_id,std::string log_type,std::string log_limit /*="0"*/) 25 | { 26 | unsigned char ret = TransLogTypeFromString(log_type); 27 | 28 | int iLimit = -1; 29 | if (!log_limit.empty()) 30 | { 31 | try 32 | { 33 | iLimit = boost::lexical_cast(log_limit); 34 | } 35 | catch(boost::bad_lexical_cast& e) 36 | { 37 | std::cerr<<"CLogFactory::CreateLog "< 0) 51 | { 52 | retPtr = new CTextLog(log_id,"a",iLimit); 53 | } 54 | else 55 | { 56 | retPtr = new CTextLog(log_id,"a"); 57 | } 58 | break; 59 | 60 | case XmlLog: 61 | if (iLimit > 0) 62 | { 63 | retPtr = new CXmlLog(log_id,"",iLimit); 64 | } 65 | else 66 | { 67 | retPtr = new CXmlLog(log_id,""); 68 | } 69 | break; 70 | 71 | // case BoostLog: 72 | // if (iLimit > 0) 73 | // { 74 | // retPtr = new CBoostLog(log_id,"",iLimit); 75 | // } 76 | // else 77 | // { 78 | // retPtr = new CBoostLog(log_id,""); 79 | // } 80 | // break; 81 | 82 | default: 83 | retPtr = NULL; 84 | break; 85 | } 86 | 87 | return retPtr; 88 | } 89 | 90 | std::string CLogFactory::TransLogTypeToString(unsigned short val) 91 | { 92 | std::string ret = strNoLog; 93 | 94 | switch(val) 95 | { 96 | case TextLog: 97 | ret = strTextLog; 98 | break; 99 | 100 | case XmlLog: 101 | ret = strXmlLog; 102 | break; 103 | 104 | // case BoostLog: 105 | // ret = strBoostLog; 106 | // break; 107 | 108 | default: 109 | ret = strNoLog; 110 | break; 111 | } 112 | 113 | return ret; 114 | } 115 | 116 | unsigned char CLogFactory::TransLogTypeFromString( std::string val ) 117 | { 118 | unsigned char ret = NoLog; 119 | 120 | if (boost::iequals(strTextLog,val)) 121 | { 122 | ret = TextLog; 123 | } 124 | else if(boost::iequals(strXmlLog,val)) 125 | { 126 | ret = XmlLog; 127 | } 128 | // else if (boost::iequals(strBoostLog,val)) 129 | // { 130 | // ret = BoostLog; 131 | // } 132 | 133 | return ret; 134 | } 135 | 136 | }; //namespace FileSystem 137 | 138 | -------------------------------------------------------------------------------- /FileSystem/LogFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace FileSystem { 5 | 6 | class CLog; 7 | 8 | class CLogFactory 9 | { 10 | public: 11 | ~CLogFactory(void); 12 | static CLog * CreateLog(std::string log_id,std::string log_type,std::string log_limit = "0"); 13 | static std::string TransLogTypeToString(unsigned short val); 14 | 15 | private: 16 | CLogFactory(void); 17 | static unsigned char TransLogTypeFromString( std::string val ); 18 | }; 19 | 20 | };//namespace FileSystem 21 | -------------------------------------------------------------------------------- /FileSystem/TextLog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/FileSystem/TextLog.cpp -------------------------------------------------------------------------------- /FileSystem/TextLog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Log.h" 4 | 5 | namespace FileSystem { 6 | 7 | class CTextLog 8 | :public CLog 9 | { 10 | public: 11 | //CTextLog(void); 12 | CTextLog(std::string filename,std::string OpenMode,int limit); 13 | CTextLog(std::string filename,std::string OpenMode); 14 | virtual ~CTextLog(void); 15 | virtual std::string getFileType(); 16 | 17 | //int InitLog(std::string filename,std::string OpenMode); 18 | //int AddText(const char * fmt,...); 19 | //int AddTextWithSynT(const char * fmt,...); 20 | virtual int AddRecord(std::string strval); 21 | virtual int AddRecordWithSynT(std::string strval); 22 | // int setMaxCounter(size_t var); 23 | //std::string getLogPath(); 24 | 25 | private: 26 | int WriteToFile(const char * buf); 27 | int WriteToFileWithSynT(const char * buf); 28 | 29 | private: 30 | boost::mutex mutex_; 31 | }; 32 | 33 | }; //namespace PublicSupport 34 | -------------------------------------------------------------------------------- /FileSystem/XmlLog.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/FileSystem/XmlLog.cpp -------------------------------------------------------------------------------- /FileSystem/XmlLog.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/FileSystem/XmlLog.h -------------------------------------------------------------------------------- /FileSystem/XmlRecord.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "XmlRecord.h" 4 | #include "Markup.h" 5 | 6 | namespace FileSystem { 7 | 8 | const std::string strRecord = "Record"; 9 | const std::string strClock = "Time"; 10 | 11 | CXmlRecord::CXmlRecord(std::string filename,int limit) 12 | :CXmlLog(filename,"a",limit) 13 | { 14 | 15 | } 16 | CXmlRecord::CXmlRecord(std::string filename) 17 | :CXmlLog(filename,"a") 18 | { 19 | 20 | } 21 | 22 | CXmlRecord::~CXmlRecord(void) 23 | { 24 | } 25 | 26 | int CXmlRecord::AddRecord(name_val_set & val) 27 | { 28 | if (strLogPath_.empty()) 29 | { 30 | return -1; 31 | } 32 | 33 | return RecordData(val,false,xml_); 34 | } 35 | 36 | int CXmlRecord::AddRecord(name_val_set & attrib,name_val_set & val) 37 | { 38 | if (strLogPath_.empty()) 39 | { 40 | return -1; 41 | } 42 | 43 | return RecordData(attrib,val,false,xml_); 44 | } 45 | 46 | int CXmlRecord::AddRecordWithSynT(name_val_set & val) 47 | { 48 | if (strLogPath_.empty()) 49 | { 50 | return -1; 51 | } 52 | 53 | return RecordData(val,true,xml_); 54 | } 55 | 56 | int CXmlRecord::AddRecordWithSynT(name_val_set & attrib,name_val_set & val) 57 | { 58 | if (strLogPath_.empty()) 59 | { 60 | return -1; 61 | } 62 | 63 | return RecordData(attrib,val,true,xml_); 64 | } 65 | 66 | int CXmlRecord::RecordData(name_val_set & val,bool strSynT,CMarkup & xml) 67 | { 68 | CheckXmlLogExsit(strLogPath_,xml); 69 | 70 | xml.FindElem(); 71 | xml.IntoElem(); //into root 72 | 73 | xml.AddElem(strRecord); 74 | if (strSynT) 75 | { 76 | boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); 77 | std::string strTime = to_simple_string(now); 78 | xml.AddAttrib(strClock,strTime); 79 | } 80 | 81 | xml.IntoElem(); 82 | 83 | for (name_val_it it = val.begin();it != val.end();it++) 84 | { 85 | xml.AddElem(boost::tuples::get<0>(*it),boost::tuples::get<1>(*it)); 86 | } 87 | 88 | xml.OutOfElem(); 89 | 90 | return ResetRecordCounter(xml); 91 | } 92 | 93 | int CXmlRecord::RecordData(name_val_set & attrib,name_val_set & val,bool strSynT,CMarkup & xml) 94 | { 95 | CheckXmlLogExsit(strLogPath_,xml); 96 | 97 | xml.FindElem(); 98 | xml.IntoElem(); //into root 99 | 100 | xml.AddElem(strRecord); 101 | if (strSynT) 102 | { 103 | boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); 104 | std::string strTime = to_simple_string(now); 105 | xml.AddAttrib(strClock,strTime); 106 | } 107 | 108 | xml.IntoElem(); 109 | 110 | name_val_it itAttrib = attrib.begin(); 111 | for (name_val_it itVal = val.begin();itVal != val.end();itVal++) 112 | { 113 | xml.AddElem(boost::tuples::get<0>(*itVal),boost::tuples::get<1>(*itVal)); 114 | if (itAttrib != attrib.end()) 115 | { 116 | xml.AddAttrib(boost::tuples::get<0>(*itAttrib),boost::tuples::get<1>(*itAttrib)); 117 | } 118 | itAttrib ++; 119 | } 120 | 121 | xml.OutOfElem(); 122 | 123 | return ResetRecordCounter(xml); 124 | } 125 | 126 | }; //namespace FileSystem 127 | 128 | -------------------------------------------------------------------------------- /FileSystem/XmlRecord.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "XmlLog.h" 5 | 6 | namespace FileSystem { 7 | 8 | typedef boost::tuple name_val; 9 | typedef std::vector name_val_set; 10 | typedef std::vector::iterator name_val_it; 11 | 12 | class CXmlRecord : 13 | public CXmlLog 14 | { 15 | public: 16 | CXmlRecord(std::string filename,int limit); 17 | CXmlRecord(std::string filename); 18 | virtual ~CXmlRecord(void); 19 | 20 | int AddRecord(name_val_set & val); 21 | int AddRecord(name_val_set & attrib,name_val_set & val); 22 | int AddRecordWithSynT(name_val_set & val); 23 | int AddRecordWithSynT(name_val_set & attrib,name_val_set & val); 24 | 25 | protected: 26 | int RecordData(name_val_set & val,bool strSynT,CMarkup & xml); 27 | int RecordData(name_val_set & attrib,name_val_set & val,bool strSynT,CMarkup & xml); 28 | }; 29 | 30 | }; //namespace FileSystem 31 | -------------------------------------------------------------------------------- /H101Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | true 8 | 3 9 | 10 | -------------------------------------------------------------------------------- /H101NRZBTJ.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | true 8 | 20 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /H104Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /LocalDrive/BatteryActive.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/BatteryActive.cpp -------------------------------------------------------------------------------- /LocalDrive/BatteryActive.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "../PublicSupport/ZdTimer.h" 5 | 6 | namespace FileSystem 7 | { 8 | class CMarkup; 9 | } 10 | 11 | namespace DataBase 12 | { 13 | class CSubStation; 14 | } 15 | 16 | 17 | namespace PublicSupport 18 | { 19 | class CZdTimer; 20 | } 21 | 22 | namespace LocalDrive { 23 | 24 | class CBatteryActive 25 | { 26 | public: 27 | CBatteryActive(boost::asio::io_service & io_service,std::string strCfg,DataBase::CSubStation & sub); 28 | ~CBatteryActive(void); 29 | 30 | int run(); 31 | int stop(); 32 | int reset(); 33 | 34 | public: 35 | int LoadXml(std::string strCfg); 36 | void SaveXml(std::string strCfg); 37 | 38 | private: 39 | void handle_timerBatteryActive(const boost::system::error_code& error); 40 | void ResetTimerBatteryActive(bool bContinue,boost::posix_time::time_duration timeVal); 41 | boost::posix_time::time_duration getMinTimeFromNow(); 42 | int ActiveBattery(bool val); 43 | //void setEnableBA(bool val); 44 | //bool getEnableBA(); 45 | 46 | private: 47 | DataBase::CSubStation & sub_; 48 | //boost::asio::io_service & io_service_; 49 | //boost::asio::deadline_timer timerBatteryActive_; 50 | PublicSupport::CZdTimer zdtimer_; 51 | std::vector times_; 52 | }; 53 | 54 | }; //namespace LocalDrive 55 | -------------------------------------------------------------------------------- /LocalDrive/Bluetooth.cpp: -------------------------------------------------------------------------------- 1 | #include "Bluetooth.h" 2 | //#include "../FileSystem/TextLog.h" 3 | #include "../FileSystem/Log.h" 4 | #include "../FileSystem/LogFactory.h" 5 | 6 | namespace LocalDrive { 7 | 8 | const std::string filename = "Bluetooth.log"; 9 | 10 | CBluetooth::CBluetooth(bool bEnableLog) 11 | { 12 | if (bEnableLog) 13 | { 14 | Log_.reset(FileSystem::CLogFactory::CreateLog(filename,FileSystem::strTextLog)); 15 | } 16 | } 17 | 18 | CBluetooth::~CBluetooth(void) 19 | { 20 | } 21 | 22 | int CBluetooth::AddLogWithSynT(std::string strVal) 23 | { 24 | if (Log_) 25 | { 26 | return Log_->AddRecordWithSynT(strVal); 27 | } 28 | 29 | return -1; 30 | } 31 | 32 | }; //namespace LocalDrive 33 | -------------------------------------------------------------------------------- /LocalDrive/Bluetooth.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace FileSystem 6 | { 7 | class CLog; 8 | } 9 | 10 | namespace LocalDrive { 11 | 12 | class CBluetooth 13 | { 14 | public: 15 | CBluetooth(bool bEnableLog); 16 | virtual ~CBluetooth(void); 17 | 18 | virtual int run() = 0; 19 | virtual int stop() = 0; 20 | virtual int reset() = 0; 21 | 22 | protected: 23 | int AddLogWithSynT(std::string strVal); 24 | 25 | private: 26 | boost::scoped_ptr Log_; 27 | }; 28 | 29 | };//namespace LocalDrive 30 | 31 | 32 | -------------------------------------------------------------------------------- /LocalDrive/Bluetooth_BF518.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/Bluetooth_BF518.cpp -------------------------------------------------------------------------------- /LocalDrive/Bluetooth_BF518.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Bluetooth.h" 3 | #include "../PublicSupport/Dat2cTypeDef.h" 4 | 5 | //namespace DataBase 6 | //{ 7 | // class CSubStation; 8 | //} 9 | 10 | namespace LocalDrive { 11 | 12 | class CBluetooth_BF518 : 13 | public CBluetooth 14 | { 15 | public: 16 | CBluetooth_BF518(/*boost::asio::io_service & io_service,*/bool bEnableLog,/*DataBase::CSubStation & sub*/typeAddr addr); 17 | virtual ~CBluetooth_BF518(void); 18 | 19 | int run(); 20 | int stop(); 21 | int reset(); 22 | 23 | private: 24 | //int PortHandle_; 25 | //typeAddr Address_; 26 | //int NameLength_; 27 | 28 | int OpenBluetooth(); 29 | void CloseBluetooth(); 30 | int Set_ttyBF0(int fd, int speed); 31 | int GetNameBuf(); 32 | //unsigned int TransStringToInt(std::string id); 33 | 34 | //int FormatNameBuf(); 35 | //void handle_write(const boost::system::error_code& error,size_t bytes_transferred); 36 | 37 | 38 | //unsigned char NameBuf[12];//= {0x01,0xFC,0x12,0x0A,0x50,0x44,0x5a,0x38,0x30,0x30,0x2d,0x31};//PDZ800-0 39 | 40 | //boost::asio::io_service & io_service_; 41 | //boost::asio::serial_port serial_port_; 42 | 43 | private: 44 | //DataBase::CSubStation & sub_; 45 | std::string id_; 46 | char Name[15]; 47 | int Addr_; 48 | int BluetoothHandle_; 49 | }; 50 | 51 | }; //namespace LocalDrive 52 | -------------------------------------------------------------------------------- /LocalDrive/DIO.cpp: -------------------------------------------------------------------------------- 1 | #include "DIO.h" 2 | 3 | namespace LocalDrive { 4 | 5 | CDIO::CDIO(void) 6 | { 7 | } 8 | 9 | CDIO::~CDIO(void) 10 | { 11 | } 12 | 13 | };//namespace LocalDrive 14 | -------------------------------------------------------------------------------- /LocalDrive/DIO.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace LocalDrive { 4 | 5 | class CDIO 6 | { 7 | public: 8 | CDIO(void); 9 | virtual ~CDIO(void); 10 | 11 | virtual int open() = 0; 12 | virtual void close() = 0; 13 | 14 | virtual int check_di(int index) = 0; 15 | virtual int read_di(int index) = 0; 16 | virtual int check_do(int index) = 0; 17 | virtual unsigned char read_do(int index) = 0; 18 | virtual int write_do(int index,bool bCloseOrOpen) = 0; 19 | }; 20 | 21 | };//namespace LocalDrive 22 | -------------------------------------------------------------------------------- /LocalDrive/DIO_PCM82X.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DIO_PCM82X.h" 3 | #include "../PublicSupport/Dat2cTypeDef.h" 4 | 5 | #if defined(_PCM82X_) 6 | #include "zktylib.h" 7 | #endif //#if defined(_PCM82X_) 8 | 9 | namespace LocalDrive { 10 | 11 | CDIO_PCM82X::CDIO_PCM82X(void) 12 | { 13 | } 14 | 15 | CDIO_PCM82X::~CDIO_PCM82X(void) 16 | { 17 | } 18 | 19 | int CDIO_PCM82X::open() 20 | { 21 | return OpenDIO(); 22 | } 23 | 24 | void CDIO_PCM82X::close() 25 | { 26 | CloseDIO(); 27 | } 28 | 29 | int CDIO_PCM82X::OpenDIO() 30 | { 31 | #if defined(_PCM82X_) 32 | 33 | DIOHandle_ = zkty_deviceopen(0); 34 | if (DIOHandle_ < 0) 35 | { 36 | std::cerr<<"dio device open fail"<= 0) 52 | { 53 | zkty_deviceclose(DIOHandle_); 54 | DIOHandle_ = -1; 55 | } 56 | 57 | #endif //defined(_PCM82X_) 58 | } 59 | 60 | int CDIO_PCM82X::read_di(int index) 61 | { 62 | #if defined(_PCM82X_) 63 | 64 | if ((index < 0) || (index >= (int)Max_DI_Num) || (DIOHandle_ < 0)) 65 | { 66 | return -1; 67 | } 68 | 69 | unsigned char byteVal; 70 | int ret = zkty_diread(DIOHandle_,0,1,&byteVal); 71 | if (ret < 0) 72 | { 73 | return ret; 74 | } 75 | 76 | if((BYTE_CHECK_TRUE[index] & byteVal) > 0) 77 | { 78 | return 1; 79 | } 80 | else 81 | { 82 | return 0; 83 | } 84 | 85 | #endif //defined(_PCM82X_) 86 | 87 | return -1; 88 | } 89 | 90 | int CDIO_PCM82X::check_di(int index) 91 | { 92 | #if defined(_PCM82X_) 93 | 94 | if ((index < 0) || (index >= (int)Max_DI_Num) || (DIOHandle_ < 0)) 95 | { 96 | return -1; 97 | } 98 | 99 | return 0; 100 | 101 | #endif //defined(_PCM82X_) 102 | 103 | return -1; 104 | } 105 | 106 | int CDIO_PCM82X::check_do(int index) 107 | { 108 | #if defined(_PCM82X_) 109 | 110 | if ((index < 0) || (index >= (int)Max_DO_Num) || (DIOHandle_ < 0)) 111 | { 112 | return -1; 113 | } 114 | 115 | return 0; 116 | 117 | #endif //defined(_PCM82X_) 118 | 119 | return -1; 120 | } 121 | 122 | unsigned char CDIO_PCM82X::read_do(int index) 123 | { 124 | #if defined(_PCM82X_) 125 | 126 | if ((index < 0) || (index >= (int)Max_DO_Num) || (DIOHandle_ < 0)) 127 | { 128 | return -1; 129 | } 130 | 131 | unsigned char byteVal; 132 | zkty_doread(DIOHandle_,0,1,&byteVal); 133 | 134 | unsigned char ret; 135 | if((BYTE_CHECK_TRUE[index] & byteVal) > 0) 136 | { 137 | ret = 1; 138 | } 139 | else 140 | { 141 | ret = 0; 142 | } 143 | 144 | return ret; 145 | 146 | #endif //defined(_PCM82X_) 147 | 148 | return -1; 149 | } 150 | 151 | int CDIO_PCM82X::write_do(int index,bool bCloseOrOpen) 152 | { 153 | #if defined(_PCM82X_) 154 | 155 | if ((index < 0) || (index >= (int)Max_DO_Num) || (DIOHandle_ < 0)) 156 | { 157 | return -1; 158 | } 159 | 160 | unsigned char byteVal; 161 | int ret = zkty_doread(DIOHandle_,0,1,&byteVal); 162 | if (ret < 0) 163 | { 164 | return ret; 165 | } 166 | 167 | if (bCloseOrOpen) 168 | { 169 | byteVal = BYTE_CHECK_TRUE[index] | byteVal; 170 | } 171 | else 172 | { 173 | byteVal = BYTE_CHECK_FALSE[index] & byteVal; 174 | } 175 | 176 | ret = zkty_dowrite(DIOHandle_,0,1,&byteVal); 177 | 178 | return ret; 179 | 180 | #endif //defined(_PCM82X_) 181 | 182 | return -1; 183 | } 184 | 185 | } //namespace LocalPCM82X 186 | -------------------------------------------------------------------------------- /LocalDrive/DIO_PCM82X.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "DIO.h" 3 | 4 | namespace LocalDrive { 5 | 6 | class CDIO_PCM82X 7 | :public CDIO 8 | { 9 | public: 10 | CDIO_PCM82X(void); 11 | virtual ~CDIO_PCM82X(void); 12 | 13 | int open(); 14 | void close(); 15 | 16 | int check_di(int index); 17 | int read_di(int index); 18 | int check_do(int index); 19 | unsigned char read_do(int index); 20 | int write_do(int index,bool bCloseOrOpen); 21 | 22 | private: 23 | int OpenDIO(); 24 | void CloseDIO(); 25 | 26 | private: 27 | enum 28 | { 29 | Max_DI_Num = 8, 30 | Max_DO_Num = 4 31 | }; 32 | int DIOHandle_; 33 | }; 34 | 35 | } //namespace LocalPCM82X 36 | 37 | -------------------------------------------------------------------------------- /LocalDrive/DIO_Virtual.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/DIO_Virtual.cpp -------------------------------------------------------------------------------- /LocalDrive/DIO_Virtual.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "dio.h" 4 | 5 | namespace DataBase 6 | { 7 | class CSubStation; 8 | } 9 | 10 | namespace LocalDrive { 11 | 12 | class CDIO_Virtual : 13 | public CDIO 14 | { 15 | public: 16 | CDIO_Virtual(DataBase::CSubStation & sub); 17 | virtual ~CDIO_Virtual(void); 18 | 19 | int open(); 20 | void close(); 21 | 22 | int check_di(int index); 23 | int read_di(int index); 24 | int check_do(int index); 25 | unsigned char read_do(int index); 26 | int write_do(int index,bool bCloseOrOpen); 27 | 28 | private: 29 | int CheckAllIndex(); 30 | int ActiveBattery(bool val); 31 | int ResetDev(bool val); 32 | int ResetYkAllow(bool val); 33 | int ResetSubYkAllow(); 34 | 35 | int LoadXmlCfg(std::string filename); 36 | void SaveXmlCfg(std::string filename); 37 | 38 | bool getbAllowYk(); 39 | int setbAllowYk(bool val); 40 | int getActiveBatteryIndex(); 41 | int setActiveBattryIndex(int val); 42 | int getResetDevIndex(); 43 | int setResetDevIndex(int val); 44 | int getResetYkAllowIndex(); 45 | int setResetYkAllowIndex(int val); 46 | int getAllowYkNotifyIndex(); 47 | int setAllowYkNotifyIndex(int val); 48 | 49 | private: 50 | enum 51 | { 52 | DefaultActiveBatteryIndex = 0, 53 | DefaultResetDevIndex = 1, 54 | DefaultResetYkAllowIndex = 2, 55 | DefaultAllowYkNotifyIndex = 0 56 | }; 57 | 58 | DataBase::CSubStation & sub_; 59 | bool bAllowYk_; 60 | int MaxDoNum_; 61 | int MaxDiNum_; 62 | 63 | int ActiveBatteryIndex_; 64 | int ResetDevIndex_; 65 | int ResetYkAllowIndex_; 66 | int AllowYkNotifyIndex_; 67 | }; 68 | 69 | }; //namespace LocalDrive 70 | 71 | -------------------------------------------------------------------------------- /LocalDrive/DioFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "DioFactory.h" 3 | #include "DIO_PCM82X.h" 4 | #include "DIO_Virtual.h" 5 | 6 | namespace LocalDrive { 7 | 8 | #define strDIONull "DIONull" 9 | #define strDIOPCM82X "DIOPCM82X" 10 | #define strDIOVirtual "DIOVirtual" 11 | 12 | const unsigned char dio_null = 0; 13 | const unsigned char dio_pcm82x = 1; 14 | const unsigned char dio_virtual = 2; 15 | 16 | CDIOFactory::CDIOFactory(void) 17 | { 18 | } 19 | 20 | 21 | CDIOFactory::~CDIOFactory(void) 22 | { 23 | } 24 | 25 | unsigned char CDIOFactory::TransDIOTypeFromString(std::string val) 26 | { 27 | unsigned char ret = dio_null; 28 | 29 | if (boost::iequals(strDIOPCM82X,val)) 30 | { 31 | ret = dio_pcm82x; 32 | } 33 | 34 | if (boost::iequals(strDIOVirtual,val)) 35 | { 36 | ret = dio_virtual; 37 | } 38 | 39 | return ret; 40 | } 41 | 42 | std::string CDIOFactory::TransDIOTypeToString(unsigned char val) 43 | { 44 | std::string ret = strDIONull; 45 | 46 | switch(val) 47 | { 48 | case dio_pcm82x: 49 | ret = strDIOPCM82X; 50 | break; 51 | 52 | case dio_virtual: 53 | ret = strDIOVirtual; 54 | break; 55 | 56 | default: 57 | break; 58 | } 59 | 60 | return ret; 61 | } 62 | 63 | CDIO * CDIOFactory::CreateDIO(std::string dioType,DataBase::CSubStation & sub) 64 | { 65 | unsigned char ret = TransDIOTypeFromString(dioType); 66 | 67 | CDIO * retPtr = NULL; 68 | 69 | switch(ret) 70 | { 71 | case dio_pcm82x: 72 | retPtr = new CDIO_PCM82X(); 73 | break; 74 | 75 | case dio_virtual: 76 | retPtr = new CDIO_Virtual(sub); 77 | break; 78 | 79 | default: 80 | retPtr = NULL; 81 | break; 82 | } 83 | 84 | return retPtr; 85 | } 86 | 87 | };//namespace LocalDrive 88 | 89 | -------------------------------------------------------------------------------- /LocalDrive/DioFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace DataBase 4 | { 5 | class CSubStation; 6 | } 7 | 8 | namespace LocalDrive { 9 | 10 | class CDIO; 11 | 12 | class CDIOFactory 13 | { 14 | public: 15 | ~CDIOFactory(void); 16 | static std::string TransDIOTypeToString(unsigned char val); 17 | static CDIO * CreateDIO(std::string dioType,DataBase::CSubStation & sub); 18 | 19 | private: 20 | CDIOFactory(void); 21 | static unsigned char TransDIOTypeFromString(std::string val); 22 | }; 23 | 24 | }; //namespace LocalDrive 25 | 26 | -------------------------------------------------------------------------------- /LocalDrive/IEEE1588_TPE3000.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/IEEE1588_TPE3000.cpp -------------------------------------------------------------------------------- /LocalDrive/IEEE1588_TPE3000.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace LocalDrive { 5 | 6 | class CIEEE1588_TPE3000 7 | { 8 | public: 9 | CIEEE1588_TPE3000(boost::asio::io_service & io_service,unsigned short timeVal); 10 | ~CIEEE1588_TPE3000(void); 11 | int run(); 12 | int stop(); 13 | int reset(); 14 | 15 | private: 16 | void handle_timerWriteCmosClock(const boost::system::error_code& error,unsigned short timeVal); 17 | void ResetTimerWriteCmosClock(bool bContinue,unsigned short timeVal); 18 | 19 | private: 20 | unsigned short timeOutWriteCmosClock_; 21 | boost::asio::deadline_timer timerWriteCmosClock_; 22 | }; 23 | 24 | };//namespace LocalDrive 25 | 26 | -------------------------------------------------------------------------------- /LocalDrive/LightDriver_TPE3000.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/LightDriver_TPE3000.h -------------------------------------------------------------------------------- /LocalDrive/WatchDog.cpp: -------------------------------------------------------------------------------- 1 | #include "WatchDog.h" 2 | //#include "../FileSystem/TextLog.h" 3 | #include "../FileSystem/Log.h" 4 | #include "../FileSystem/LogFactory.h" 5 | 6 | namespace LocalDrive { 7 | 8 | const std::string filename = "WatchDog.log"; 9 | 10 | CWatchDog::CWatchDog(bool bEnableLog) 11 | { 12 | if (bEnableLog) 13 | { 14 | Log_.reset(FileSystem::CLogFactory::CreateLog(filename,FileSystem::strTextLog)); 15 | } 16 | } 17 | 18 | CWatchDog::~CWatchDog(void) 19 | { 20 | } 21 | 22 | int CWatchDog::AddLogWithSynT(std::string strVal) 23 | { 24 | if (Log_) 25 | { 26 | return Log_->AddRecordWithSynT(strVal); 27 | } 28 | 29 | return -1; 30 | } 31 | 32 | }; //namespace LocalDrive 33 | -------------------------------------------------------------------------------- /LocalDrive/WatchDog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //#include 3 | #include 4 | 5 | namespace FileSystem 6 | { 7 | class CLog; 8 | } 9 | 10 | namespace LocalDrive { 11 | 12 | class CWatchDog 13 | { 14 | public: 15 | CWatchDog(bool bEnableLog); 16 | virtual ~CWatchDog(void); 17 | 18 | virtual int run() = 0; 19 | virtual int stop() = 0; 20 | virtual int reset() = 0; 21 | 22 | protected: 23 | int AddLogWithSynT(std::string strVal); 24 | 25 | private: 26 | boost::scoped_ptr Log_; 27 | }; 28 | 29 | };//namespace LocalDrive 30 | -------------------------------------------------------------------------------- /LocalDrive/WatchDogFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "WatchDogFactory.h" 3 | #include "WatchDog_PCM82X.h" 4 | #include "WatchDog_TPE3000.h" 5 | #include "WatchDog_BF518.h" 6 | 7 | namespace LocalDrive { 8 | 9 | #define strWatchDogNull "WatchDogNull" 10 | #define strWatchDogPCM82X "WatchDogPCM82X" 11 | #define strWatchDogTPE3000 "WatchDogTPE3000" 12 | #define strWatchDogBF518 "WatchDogBF518" 13 | 14 | const unsigned char watchdog_null = 0; 15 | const unsigned char watchdog_pcm82x = 1; 16 | const unsigned char watchdog_tpe3000 = 2; 17 | const unsigned char watchdog_bf518 = 3; 18 | 19 | CWatchDogFactory::CWatchDogFactory(void) 20 | { 21 | } 22 | 23 | 24 | CWatchDogFactory::~CWatchDogFactory(void) 25 | { 26 | } 27 | 28 | CWatchDog * CWatchDogFactory::CreateWatchDog(std::string watchdogType,boost::asio::io_service & io_service,bool bEnableLog) 29 | { 30 | unsigned char ret = TransWatchDogTypeFromString(watchdogType); 31 | 32 | CWatchDog * retPtr = NULL; 33 | 34 | switch(ret) 35 | { 36 | case watchdog_pcm82x: 37 | retPtr = new CWatchDog_PCM82X(io_service,bEnableLog); 38 | break; 39 | 40 | case watchdog_tpe3000: 41 | retPtr = new CWatchDog_TPE3000(io_service,bEnableLog); 42 | break; 43 | 44 | case watchdog_bf518: 45 | retPtr = new CWatchDog_BF518(io_service,bEnableLog); 46 | break; 47 | 48 | default: 49 | retPtr = new CWatchDog_PCM82X(io_service,bEnableLog); 50 | break; 51 | } 52 | 53 | return retPtr; 54 | } 55 | 56 | std::string CWatchDogFactory::TransWatchDogTypeToString(unsigned short val) 57 | { 58 | std::string ret = strWatchDogNull; 59 | 60 | switch(val) 61 | { 62 | case watchdog_pcm82x: 63 | ret = strWatchDogPCM82X; 64 | break; 65 | 66 | case watchdog_tpe3000: 67 | ret = strWatchDogTPE3000; 68 | break; 69 | 70 | case watchdog_bf518: 71 | ret = strWatchDogBF518; 72 | break; 73 | 74 | default: 75 | break; 76 | } 77 | 78 | return ret; 79 | } 80 | 81 | unsigned char CWatchDogFactory::TransWatchDogTypeFromString( std::string val ) 82 | { 83 | unsigned char ret = watchdog_null; 84 | 85 | if (boost::iequals(strWatchDogPCM82X,val)) 86 | { 87 | ret = watchdog_pcm82x; 88 | } 89 | else if(boost::iequals(strWatchDogTPE3000,val)) 90 | { 91 | ret = watchdog_tpe3000; 92 | } 93 | else if(boost::iequals(strWatchDogBF518,val)) 94 | { 95 | ret = watchdog_bf518; 96 | } 97 | 98 | return ret; 99 | } 100 | 101 | }; //namespace LocalDrive 102 | 103 | -------------------------------------------------------------------------------- /LocalDrive/WatchDogFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace LocalDrive { 5 | 6 | class CWatchDog; 7 | 8 | class CWatchDogFactory 9 | { 10 | public: 11 | ~CWatchDogFactory(void); 12 | static CWatchDog * CreateWatchDog(std::string watchdogType,boost::asio::io_service & io_service,bool bEnableLog); 13 | static std::string TransWatchDogTypeToString(unsigned short val); 14 | 15 | private: 16 | CWatchDogFactory(void); 17 | static unsigned char TransWatchDogTypeFromString( std::string val ); 18 | }; 19 | 20 | };//namespace LocalDrive 21 | 22 | -------------------------------------------------------------------------------- /LocalDrive/WatchDog_BF518.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/LocalDrive/WatchDog_BF518.h -------------------------------------------------------------------------------- /LocalDrive/WatchDog_PCM82X.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "WatchDog_PCM82X.h" 4 | 5 | #if defined(_PCM82X_) 6 | #include "zktywatchdog.h" 7 | #endif //#if defined(_PCM82X_) 8 | 9 | namespace LocalDrive { 10 | 11 | CWatchDog_PCM82X::CWatchDog_PCM82X(boost::asio::io_service & io_service,bool bEnableLog) 12 | :CWatchDog(bEnableLog), 13 | io_service_(io_service), 14 | timerFeedWatchDog_(io_service) 15 | { 16 | feedCount_ = 0; 17 | WatchDogHandle_ = -1; 18 | WatchDogTimeOut_ = DefaultWatchDogTimeOut; 19 | WatchDogTimeFeed_ = DefaultWatchDogTimeFeed; 20 | } 21 | 22 | CWatchDog_PCM82X::~CWatchDog_PCM82X(void) 23 | { 24 | } 25 | 26 | /* 27 | int CWatchDog_PCM82X::AddLogWithSynT(std::string strVal) 28 | { 29 | if (Log_) 30 | { 31 | return Log_->AddRecordWithSynT(strVal); 32 | } 33 | 34 | return -1; 35 | } 36 | */ 37 | 38 | int CWatchDog_PCM82X::run() 39 | { 40 | return OpenWatchDog(); 41 | } 42 | 43 | int CWatchDog_PCM82X::stop() 44 | { 45 | CloseWatchDog(); 46 | 47 | return 0; 48 | } 49 | 50 | int CWatchDog_PCM82X::reset() 51 | { 52 | ResetTimerFeedWatchDog(true,0); 53 | 54 | return 0; 55 | } 56 | 57 | int CWatchDog_PCM82X::OpenWatchDog() 58 | { 59 | #if defined(_PCM82X_) 60 | 61 | WatchDogHandle_ = open("/dev/watchdog",O_RDWR | O_NONBLOCK); 62 | if(WatchDogHandle_ < 0) 63 | { 64 | std::ostringstream ostr; 65 | ostr<<"PCM82X watchdog device open fail"<= 0) 93 | { 94 | write(WatchDogHandle_,"V",1); 95 | close(WatchDogHandle_); 96 | WatchDogHandle_ = -1; 97 | 98 | std::ostringstream ostr; 99 | ostr<<"PCM82X close dog"<= 0) 114 | { 115 | std::ostringstream ostr; 116 | ostr<<"PCM82X feed dog on the "< 2 | #include 3 | #include "WatchDog_TPE3000.h" 4 | 5 | #if defined(_TPE3000_) 6 | #include 7 | #endif 8 | 9 | namespace LocalDrive { 10 | 11 | CWatchDog_TPE3000::CWatchDog_TPE3000(boost::asio::io_service & io_service,bool bEnableLog) 12 | :CWatchDog(bEnableLog), 13 | io_service_(io_service), 14 | timerFeedWatchDog_(io_service) 15 | { 16 | feedCount_ = 0; 17 | WatchDogHandle_ = -1; 18 | WatchDogTimeOut_ = DefaultWatchDogTimeOut; 19 | WatchDogTimeFeed_ = DefaultWatchDogTimeFeed; 20 | } 21 | 22 | CWatchDog_TPE3000::~CWatchDog_TPE3000(void) 23 | { 24 | } 25 | 26 | //int CWatchDog_TPE3000::AddLogWithSynT(std::string strVal) 27 | //{ 28 | // if (Log_) 29 | // { 30 | // return Log_->AddRecordWithSynT(strVal); 31 | // } 32 | // 33 | // return -1; 34 | //} 35 | 36 | int CWatchDog_TPE3000::run() 37 | { 38 | return OpenWatchDog(); 39 | } 40 | 41 | int CWatchDog_TPE3000::stop() 42 | { 43 | CloseWatchDog(); 44 | 45 | return 0; 46 | } 47 | 48 | int CWatchDog_TPE3000::reset() 49 | { 50 | ResetTimerFeedWatchDog(true,0); 51 | 52 | return 0; 53 | } 54 | 55 | int CWatchDog_TPE3000::OpenWatchDog() 56 | { 57 | #if defined(_TPE3000_) 58 | 59 | WatchDogHandle_ = open("/dev/watchdog",O_WRONLY); 60 | if(WatchDogHandle_ < 0) 61 | { 62 | std::ostringstream ostr; 63 | ostr<<"TPE3000 watchdog device open fail"<= 0) 71 | { 72 | int op = WDIOS_ENABLECARD; 73 | if(ioctl(WatchDogHandle_, WDIOC_SETOPTIONS, &op) >= 0) 74 | { 75 | ResetTimerFeedWatchDog(true,WatchDogTimeFeed_); 76 | 77 | std::ostringstream ostr; 78 | ostr<<"TPE3000 start dog"<= 0) 97 | { 98 | int op = WDIOS_DISABLECARD; 99 | ioctl(WatchDogHandle_, WDIOC_SETOPTIONS, &op); 100 | close(WatchDogHandle_); 101 | WatchDogHandle_ = -1; 102 | 103 | std::ostringstream ostr; 104 | ostr<<"TPE3000 close dog"<= 0) 119 | { 120 | std::ostringstream ostr; 121 | ostr<<"TPE3000 feed dog on the "< 10 | 11 | 12 | long zkty_deviceopen(long DevNum); 13 | void zkty_deviceclose(long hdevice); 14 | 15 | int zkty_diread(long hdevice,int port,int num,unsigned char* pbuf); 16 | int zkty_doread(long hdevice,int port,int num,unsigned char* pbuf); 17 | int zkty_dowrite(long hdevice,int port,int num,unsigned char* pbuf); 18 | 19 | unsigned char zkty_getkey(long hdevice); 20 | void zkty_initscr(long hdevice); 21 | void zkty_clrscr(long hdevice); 22 | void zkty_setcursor(long hdevice,unsigned char data); 23 | void zkty_scrmove(long hdevice,unsigned short x, unsigned short y); 24 | void zkty_scrdrawbyte(long hdevice,unsigned char data); 25 | void zkty_scrplotbyte(long hdevice,unsigned short x,unsigned short y,unsigned char data); 26 | 27 | /* int zkty_counterreset(long hdevice,int counter); */ 28 | /* int zkty_counterstart(long hdevice,int counter,int mode); */ 29 | /* int zkty_counterread(long hdevice,int counter); */ 30 | 31 | /* int zkty_enableintr(long hdevice,unsigned long eventtype); */ 32 | /* int zkty_disableintr(long hdevice,unsigned long eventtype); */ 33 | /* int zkty_checkintr(long hdevice,unsigned long * peventtype); */ 34 | 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /LocalDrive/zktylib_dio.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ZKTY_LIB_DIO_HEADER_ 3 | #define _ZKTY_LIB_DIO_HEADER_ 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | #include 10 | 11 | #define zkty_evt_diif0 0x1000 12 | #define zkty_evt_diif1 (zkty_evt_diif0 +1) 13 | #define zkty_evt_diif2 (zkty_evt_diif0 +2) 14 | #define zkty_evt_diif3 (zkty_evt_diif0 +3) 15 | #define zkty_evt_diif4 (zkty_evt_diif0 +4) 16 | #define zkty_evt_diif5 (zkty_evt_diif0 +5) 17 | #define zkty_evt_extif (zkty_evt_diif0 +6) 18 | #define zkty_evt_irigb (zkty_evt_diif0 +7) 19 | 20 | long zkty_dio_open(long DevNum); 21 | void zkty_dio_close(long hdevice); 22 | 23 | int zkty_diread(long hdevice,unsigned char* pbuf); 24 | int zkty_dowrite(long hdevice,unsigned char* pbuf); 25 | int zkty_enable_event(long hdevice,unsigned char* enable,unsigned char* threshold); 26 | int zkty_check_event(long hdevice,unsigned int EventType,unsigned int Milliseconds); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /LocalDrive/zktylib_led.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _ZKTY_LIB_LED_HEADER_ 3 | #define _ZKTY_LIB_LED_HEADER_ 4 | 5 | #ifdef __cplusplus 6 | extern "C" 7 | { 8 | #endif 9 | #include 10 | 11 | 12 | long zkty_led_open(long DevNum); 13 | void zkty_led_close(long hdevice); 14 | 15 | int zkty_ledread(long hdevice,int port,int num,unsigned char* pbuf); 16 | int zkty_ledwrite(long hdevice,int port,unsigned char* pbuf); 17 | 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LocalDrive/zktywatchdog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generic watchdog defines. Derived from.. 3 | * 4 | * Berkshire PC Watchdog Defines 5 | * by Ken Hollis 6 | * 7 | */ 8 | 9 | #ifndef _LINUX_WATCHDOG_H 10 | #define _LINUX_WATCHDOG_H 11 | 12 | #ifdef __linux__ 13 | #include 14 | #include 15 | 16 | #define WATCHDOG_IOCTL_BASE 'W' 17 | 18 | struct watchdog_info { 19 | __u32 options; /* Options the card/driver supports */ 20 | __u32 firmware_version; /* Firmware version of the card */ 21 | __u8 identity[32]; /* Identity of the board */ 22 | }; 23 | 24 | #endif /*__linux__*/ 25 | 26 | #define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) 27 | #define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) 28 | #define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) 29 | #define WDIOC_GETTEMP _IOR(WATCHDOG_IOCTL_BASE, 3, int) 30 | #define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int) 31 | #define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int) 32 | #define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) 33 | #define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) 34 | #define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int) 35 | #define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int) 36 | #define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int) 37 | #define WDIOC_GETTRIGFLAG _IOR(WATCHDOG_IOCTL_BASE, 11, int) 38 | 39 | #define WDIOF_UNKNOWN -1 /* Unknown flag error */ 40 | #define WDIOS_UNKNOWN -1 /* Unknown status error */ 41 | 42 | #define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ 43 | #define WDIOF_FANFAULT 0x0002 /* Fan failed */ 44 | #define WDIOF_EXTERN1 0x0004 /* External relay 1 */ 45 | #define WDIOF_EXTERN2 0x0008 /* External relay 2 */ 46 | #define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ 47 | #define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ 48 | #define WDIOF_POWEROVER 0x0040 /* Power over voltage */ 49 | #define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ 50 | #define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ 51 | #define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ 52 | #define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ 53 | 54 | #define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ 55 | #define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ 56 | #define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ 57 | 58 | #ifdef __KERNEL__ 59 | 60 | #ifdef CONFIG_WATCHDOG_NOWAYOUT 61 | #define WATCHDOG_NOWAYOUT 1 62 | #else 63 | #define WATCHDOG_NOWAYOUT 0 64 | #endif 65 | 66 | #endif /* __KERNEL__ */ 67 | 68 | #endif /* ifndef _LINUX_WATCHDOG_H */ 69 | -------------------------------------------------------------------------------- /Protocol/BF533.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/BF533.cpp -------------------------------------------------------------------------------- /Protocol/BF533.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/BF533.h -------------------------------------------------------------------------------- /Protocol/BF533_CfgFile.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/BF533_CfgFile.cpp -------------------------------------------------------------------------------- /Protocol/BF533_CfgFile.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/BF533_CfgFile.h -------------------------------------------------------------------------------- /Protocol/BF533_DataBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/BF533_DataBase.h -------------------------------------------------------------------------------- /Protocol/CmdQueue.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/CmdQueue.h -------------------------------------------------------------------------------- /Protocol/EqualComm.cpp: -------------------------------------------------------------------------------- 1 | #include "EqualComm.h" 2 | #include "../FileSystem/Markup.h" 3 | 4 | namespace Protocol { 5 | 6 | CEqualComm::CEqualComm(boost::asio::io_service & io_service) 7 | :CProtocol(io_service) 8 | { 9 | } 10 | 11 | CEqualComm::~CEqualComm(void) 12 | { 13 | } 14 | 15 | int CEqualComm::CheckFrameHead(unsigned char * buf,size_t & exceptedBytes) 16 | { 17 | exceptedBytes = getFrameBufLeft(); 18 | 19 | return 0; 20 | } 21 | 22 | int CEqualComm::CheckFrameTail(unsigned char * buf,size_t exceptedBytes) 23 | { 24 | return 0; 25 | } 26 | 27 | int CEqualComm::ParseFrameBody(unsigned char * buf,size_t exceptedBytes) 28 | { 29 | myframe frame; 30 | 31 | for (size_t i=0;i < exceptedBytes;i++) 32 | { 33 | frame.push_back(buf[i]); 34 | } 35 | 36 | CCmd TestCmd(TEST_CMD,TEST_CMD_PRIORITY,getFirstCommPoint(),frame); 37 | 38 | AddSendCmdVal(TestCmd); 39 | 40 | return 0; 41 | } 42 | 43 | int CEqualComm::AssembleFrameHead(size_t bufIndex, unsigned char * buf, CCmd & cmd) 44 | { 45 | size_t count = bufIndex; 46 | 47 | //buf[count++] = 0xff; 48 | //buf[count++] = 0x00; 49 | 50 | return count - bufIndex; 51 | } 52 | 53 | int CEqualComm::AssembleFrameBody(size_t bufIndex, unsigned char * buf, CCmd & cmd) 54 | { 55 | size_t count = bufIndex; 56 | 57 | myframe frame; 58 | 59 | try 60 | { 61 | frame = boost::any_cast(cmd.getVal()); 62 | } 63 | catch(const boost::bad_any_cast & e) 64 | { 65 | std::cerr<<"CTestCommInterface::AssembleFrameBody "< 3 | 4 | namespace Protocol { 5 | 6 | class CProtocol; 7 | 8 | class CProtocolFactory 9 | { 10 | public: 11 | virtual ~CProtocolFactory(void); 12 | static CProtocol * CreateProtocol(std::string protocolType,boost::asio::io_service & io_service); 13 | 14 | private: 15 | CProtocolFactory(void); 16 | static std::string TransProtocolTypeToString(unsigned short val); 17 | static short TransProtocolTyeFromString( std::string val ); 18 | }; 19 | 20 | }; //namespace Protocol 21 | -------------------------------------------------------------------------------- /Protocol/S101.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101.cpp -------------------------------------------------------------------------------- /Protocol/S101.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101.h -------------------------------------------------------------------------------- /Protocol/S101_518.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_518.cpp -------------------------------------------------------------------------------- /Protocol/S101_518.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_518.h -------------------------------------------------------------------------------- /Protocol/S101_B.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_B.cpp -------------------------------------------------------------------------------- /Protocol/S101_B.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_B.h -------------------------------------------------------------------------------- /Protocol/S101_Transmit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_Transmit.cpp -------------------------------------------------------------------------------- /Protocol/S101_Transmit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S101_Transmit.h -------------------------------------------------------------------------------- /Protocol/S104.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104.cpp -------------------------------------------------------------------------------- /Protocol/S104.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104.h -------------------------------------------------------------------------------- /Protocol/S104_518.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104_518.cpp -------------------------------------------------------------------------------- /Protocol/S104_518.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104_518.h -------------------------------------------------------------------------------- /Protocol/S104_Transmit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104_Transmit.cpp -------------------------------------------------------------------------------- /Protocol/S104_Transmit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/S104_Transmit.h -------------------------------------------------------------------------------- /Protocol/SCdt_Transmit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/SCdt_Transmit.cpp -------------------------------------------------------------------------------- /Protocol/SCdt_Transmit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/Protocol/SCdt_Transmit.h -------------------------------------------------------------------------------- /Protocol/TestCommInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "TestCommInterface.h" 2 | #include "../FileSystem/Markup.h" 3 | //#include "../PublicSupport/Dat2cTypeDef.h" 4 | 5 | namespace Protocol { 6 | 7 | CTestCommInterface::CTestCommInterface(boost::asio::io_service & io_service) 8 | :CProtocol(io_service) 9 | { 10 | SynCharNum_ = 1; 11 | } 12 | 13 | CTestCommInterface::~CTestCommInterface(void) 14 | { 15 | } 16 | 17 | int CTestCommInterface::CheckFrameHead(unsigned char * buf,size_t & exceptedBytes) 18 | { 19 | exceptedBytes = getFrameBufLeft(); 20 | 21 | return 0; 22 | } 23 | 24 | int CTestCommInterface::CheckFrameTail(unsigned char * buf,size_t exceptedBytes) 25 | { 26 | return 0; 27 | } 28 | 29 | int CTestCommInterface::ParseFrameBody(unsigned char * buf,size_t exceptedBytes) 30 | { 31 | myframe frame; 32 | 33 | for (size_t i=0;i < exceptedBytes;i++) 34 | { 35 | frame.push_back(buf[i]); 36 | } 37 | 38 | CCmd TestCmd(TEST_CMD,TEST_CMD_PRIORITY,getFirstCommPoint(),frame); 39 | 40 | AddSendCmdVal(TestCmd); 41 | 42 | return 0; 43 | } 44 | 45 | int CTestCommInterface::AssembleFrameHead(size_t bufIndex, unsigned char * buf, CCmd & cmd) 46 | { 47 | size_t count = bufIndex; 48 | 49 | //buf[count++] = 0xff; 50 | //buf[count++] = 0x00; 51 | 52 | return count - bufIndex; 53 | } 54 | 55 | int CTestCommInterface::AssembleFrameBody(size_t bufIndex, unsigned char * buf, CCmd & cmd) 56 | { 57 | size_t count = bufIndex; 58 | 59 | myframe frame; 60 | 61 | try 62 | { 63 | frame = boost::any_cast(cmd.getVal()); 64 | } 65 | catch(const boost::bad_any_cast & e) 66 | { 67 | std::cerr<<"CTestCommInterface::AssembleFrameBody "<= getDstPointNum()) 29 | { 30 | RouteTab_SrcToDst_.resize(DatabaseSum); 31 | for(size_t i=0;i= getSrcPointNum()) 57 | { 58 | return -1; 59 | } 60 | 61 | return RouteTab_SrcToDst_[srcNO]; 62 | } 63 | 64 | int CEfficientRouteTab::setSrcToDstIndex(size_t index, size_t val) 65 | { 66 | if (index < 0 || index >= getSrcPointNum()) 67 | { 68 | return -1; 69 | } 70 | 71 | if (val < 0 || val >= getDstPointNum()) 72 | { 73 | return -1; 74 | } 75 | 76 | RouteTab_SrcToDst_[index] = val; 77 | 78 | return 0; 79 | } 80 | 81 | }; //namespace PublicSupport 82 | 83 | 84 | -------------------------------------------------------------------------------- /PublicSupport/EfficientRouteTab.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "SpaceRouteTab.h" 3 | namespace FileSystem 4 | { 5 | class CMarkup; 6 | } 7 | 8 | namespace PublicSupport { 9 | 10 | class CEfficientRouteTab : 11 | public CSpaceRouteTab 12 | { 13 | public: 14 | CEfficientRouteTab(TransTerminalIndexFunCType val); 15 | virtual ~CEfficientRouteTab(void); 16 | 17 | size_t getSrcPointNum(); 18 | 19 | int InintRouteTab(FileSystem::CMarkup & xml,size_t DatabaseSum,bool bCountSrc = false); 20 | void UninitRouteTab(); 21 | 22 | int getDstIndexBySrcNO(size_t srcNO); 23 | int setSrcToDstIndex(size_t index, size_t val); 24 | 25 | protected: 26 | std::vector RouteTab_SrcToDst_; 27 | }; 28 | 29 | }; //namespace PublicSupport 30 | 31 | 32 | -------------------------------------------------------------------------------- /PublicSupport/LoopBuf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace PublicSupport { 5 | 6 | class CLoopBuf 7 | { 8 | public: 9 | CLoopBuf(size_t max_buff); 10 | ~CLoopBuf(void); 11 | 12 | public: 13 | int putBuf(unsigned char * src,int count); //data in, move ptr 14 | int getBuf(unsigned char * dst,int count); //data out, move ptr 15 | int copyBuf(unsigned char * dst,int count); //data out and do not move ptr; 16 | int popChar(unsigned char & popedChar); //a byte data out, move ptr 17 | int charNum(); //num of data left 18 | int getLoadPtr(); //for debug 19 | int getSavePtr(); //for debug 20 | 21 | private: 22 | //enum 23 | //{ 24 | // buffer_length = 4096 25 | //}; 26 | int savePtr_; 27 | int loadPtr_; 28 | //unsigned char buf[buffer_length]; 29 | size_t buffer_length_; 30 | boost::scoped_array buf_; 31 | }; 32 | 33 | }; //namespace PublicSupport 34 | -------------------------------------------------------------------------------- /PublicSupport/SpaceRouteTab.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/PublicSupport/SpaceRouteTab.cpp -------------------------------------------------------------------------------- /PublicSupport/SpaceRouteTab.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace FileSystem 7 | { 8 | class CMarkup; 9 | } 10 | 11 | namespace PublicSupport { 12 | 13 | typedef boost::function TransTerminalIndexFunCType; 14 | typedef int typeTabIndex; 15 | 16 | class CSpaceRouteTab 17 | { 18 | public: 19 | CSpaceRouteTab(); 20 | CSpaceRouteTab(TransTerminalIndexFunCType val); 21 | virtual ~CSpaceRouteTab(void); 22 | 23 | size_t getDstPointNum(); 24 | size_t getSrcPointNum(); 25 | 26 | int InintRouteTab(FileSystem::CMarkup & xml,size_t DatabaseSum,bool bCountSrc = false); 27 | void UninitRouteTab(); 28 | 29 | int getDstIndexBySrcNO(size_t srcNO); 30 | int getSrcIndexByDstNO(size_t dstNO); 31 | 32 | //bool getbEnableTab(); 33 | //int setbEnableTab(bool val); 34 | 35 | //xml api 36 | void SaveXmlCfg(FileSystem::CMarkup & xml); 37 | int LoadXmlCfg(FileSystem::CMarkup & xml,size_t DatabaseSum,bool bCountSrc = false); 38 | 39 | private: 40 | int getSrcIndexByXml(FileSystem::CMarkup & xml,int dstIndex); 41 | int setDstToSrcIndex(size_t index, size_t val); 42 | void addDstToSrcIndex(size_t val); 43 | 44 | int InitMaxSrcNum(); 45 | void ClearMaxSrcNum(); 46 | 47 | int checkDstToSrcIndex(int index,int val,size_t DatabaseSum,bool bCountSrc = false); 48 | 49 | TransTerminalIndexFunCType TransIndex; 50 | 51 | protected: 52 | //bool bEnableTab_; 53 | std::vector RouteTab_DstToSrc_; 54 | 55 | private: 56 | size_t MaxSrcNum_; 57 | }; 58 | 59 | }; //namespace PublicSupport 60 | -------------------------------------------------------------------------------- /PublicSupport/ZdTimer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/PublicSupport/ZdTimer.cpp -------------------------------------------------------------------------------- /PublicSupport/ZdTimer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/PublicSupport/ZdTimer.h -------------------------------------------------------------------------------- /PublicSupport/tick_count_timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // tick_count_timer.cpp 3 | // ~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #if defined(WIN32) 16 | # include 17 | #else 18 | # error This example is for Windows only! 19 | #endif 20 | 21 | namespace PublicSupport { 22 | 23 | struct tick_count_traits 24 | { 25 | // The time type. This type has no constructor that takes a unsigned long to ensure 26 | // that the timer can only be used with relative times. 27 | class time_type 28 | { 29 | public: 30 | time_type() : ticks_(0) {} 31 | private: 32 | friend struct tick_count_traits; 33 | unsigned long ticks_; 34 | }; 35 | 36 | // The duration type. 37 | class duration_type 38 | { 39 | public: 40 | duration_type() : ticks_(0) {} 41 | duration_type(unsigned long ticks) : ticks_(ticks) {} 42 | private: 43 | friend struct tick_count_traits; 44 | unsigned long ticks_; 45 | }; 46 | 47 | // Get the current time. 48 | static time_type now() 49 | { 50 | time_type result; 51 | result.ticks_ = ::GetTickCount(); 52 | return result; 53 | } 54 | 55 | // Add a duration to a time. 56 | static time_type add(const time_type& t, const duration_type& d) 57 | { 58 | time_type result; 59 | result.ticks_ = t.ticks_ + d.ticks_; 60 | return result; 61 | } 62 | 63 | // Subtract one time from another. 64 | static duration_type subtract(const time_type& t1, const time_type& t2) 65 | { 66 | return duration_type(t1.ticks_ - t2.ticks_); 67 | } 68 | 69 | // Test whether one time is less than another. 70 | static bool less_than(const time_type& t1, const time_type& t2) 71 | { 72 | // unsigned long tick count values wrap periodically, so we'll use a heuristic that 73 | // says that if subtracting t1 from t2 yields a value smaller than 2^31, 74 | // then t1 is probably less than t2. This means that we can't handle 75 | // durations larger than 2^31, which shouldn't be a problem in practice. 76 | return (t2.ticks_ - t1.ticks_) < static_cast(1 << 31); 77 | } 78 | 79 | // Convert to POSIX duration type. 80 | static boost::posix_time::time_duration to_posix_duration( 81 | const duration_type& d) 82 | { 83 | return boost::posix_time::milliseconds(d.ticks_); 84 | } 85 | }; 86 | 87 | typedef boost::asio::basic_deadline_timer tick_count_timer; 88 | 89 | };//namespace PublicSupport 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DAT2C 2 | ===== 3 | The project is a Telecommunications Substation in Distribution Automation, 4 | Including IEC60870-101, IEC60870-103, IEC60870-104, MODBUS, CDT and some individual power communication protocol. 5 | Power Communication via TCP/UDP, Serial Port and other channel. 6 | Including Feeder Automation and some other power automation. 7 | 8 | The project used some of the feature of boost and openssl. Need to add the include and lib path for both to compile. 9 | All required src fies, head files and libs are listed in a file called "DAT2C-Vm.mak". It's also a valid makefile to compile in Linux. 10 | The latest test was with Boost1.53.0 and OpenSSL1.0.1c on Windows with VS2012 and Linux with GCC4.6. 11 | 12 | There is two executable files in binary/ , they are compiled used static link for using conveniently. 13 | The size of executable file using dymanic link is less than 1M which is more fitted for Embedded system. 14 | 15 | The executable file need a xml file called "sub.xml" as the main config file to run, there is a sample called "sub-demo.xml" in cfg/ . 16 | -------------------------------------------------------------------------------- /RsaSite.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,6B7B12B2ECEE4A7F 4 | 5 | 2awMMVBdN7KeM6abu7ntswdHVJaXjzZghZjlduuaoDIlMQVo3mqbMOwDG0OR+sXw 6 | IK/72ljoYPP4dz/T1IV54itKBbFJdWEGCkxjXyFe7/D/cZuJOFD2hUw9JlTA1nEn 7 | KkpQZDgvgQG0YyB3rupOJe0bRPrutK5kjXr906lXzDdSdNE0kVvk0FGMy8kC/bzs 8 | VvA8IwxOrMDxMSJ4adjqt//X8VuhKffv1ql0DMkKjcAX/oYYoY/q0aI2D7hOm7ly 9 | vedOZL7jg77m6mntvqfL9lSxKzrce1pES3PuJRqbVg5/jKFi8CA0frkPVdamIz8S 10 | CNvE/5cKsMmHj6o1YSkQTmNwLBsYC5tZSKmMznMGNXveSGx5NgkQNNJptTkEFCVq 11 | X3toNuUsfLPywVVJZDlcvaTpfWh2jSoBtnwhls9iAJ+8bsVDH5eK9NjJqpZDxHgs 12 | DBRFg+bhIyR0mojPVrSSRBmFrcxOYD+6/fSokrdUZTM3i0EmcbSpPgUOUB+2OJK4 13 | 3Bro2K/kJ9HFzhExwndpjSiDeFy4/0TiDi3hqEzaUuqNY2ehflL3H8DFqlFN04nu 14 | xdnj7VUBt6cV7H9CJaf5BbZlGjjxVIyTggPcCmwDoKv3jigvnrlMKpeSLplFHX9W 15 | vqVBKF3fXGyDKUawKjiNwW2rEY16fnspjU2/25pZTmWBNQBfDGoXKJ6mBos4e5t/ 16 | pFTW7oN6AGOaCMnzshj2qaW0m7RsULo6dXSgxyNxRx+euvbB+JeEH9W/CH+MuEvm 17 | p2d/GFInyX/m+gerFAE6zh4UWwJn4avg+GZKrr5xbb+Hp2s/Ukg+vw== 18 | -----END RSA PRIVATE KEY----- 19 | -------------------------------------------------------------------------------- /RsaSite.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDUDCCArmgAwIBAgIBATANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJDTjEL 3 | MAkGA1UECBMCU0gxCzAJBgNVBAcTAlNIMQ8wDQYDVQQKEwZESUFPRFUxCzAJBgNV 4 | BAsTAkREMQ0wCwYDVQQDEwROQVJJMRswGQYJKoZIhvcNAQkBFgxOQVJJQDEyNi5j 5 | b20wHhcNMTAxMjAyMTEzMTM5WhcNMjAxMTI5MTEzMTM5WjBYMQswCQYDVQQGEwJD 6 | TjELMAkGA1UECBMCSlMxEDAOBgNVBAcTB25hbmppbmcxDDAKBgNVBAoTA0dERDEN 7 | MAsGA1UECxMETkFSSTENMAsGA1UEAxMEeW95bzCBnzANBgkqhkiG9w0BAQEFAAOB 8 | jQAwgYkCgYEAtcy5w8zxXRdjimZylUsuSE5P7xAWL3piC6FBcqkh+HyqJQPXZNXh 9 | wH3ph4lOYUN6qDrka9A73dwNX1cxxVzxonfwDMvV442vJS4okWiPSEfOOHLagQJz 10 | WmZqbzubZhjPCmogTQjtpptOCjQ11ri7IiFyxo5+so/HIm7qROrzwCECAwEAAaOC 11 | AQ8wggELMAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9wZW5TU0wgR2VuZXJh 12 | dGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBT7Jub9y9U+70TIAzs9gL51bRnTgTCB 13 | owYDVR0jBIGbMIGYgBSAj4rHQ+izAYYp1tPsZ02klKn1gKF1pHMwcTELMAkGA1UE 14 | BhMCQ04xCzAJBgNVBAgTAlNIMQswCQYDVQQHEwJTSDEPMA0GA1UEChMGRElBT0RV 15 | MQswCQYDVQQLEwJERDENMAsGA1UEAxMETkFSSTEbMBkGCSqGSIb3DQEJARYMTkFS 16 | SUAxMjYuY29tggkAhC5cVfxoo+EwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUA 17 | A4GBAJEwAAMNbo1VVMpROIRWbOnKfh4wA50k4FgRP5uxZ/fMRqlc/P0Rmbp8WNHD 18 | SC4I9CjTGxXNPcQLgDpusoX0AkPaBYMeF9WKm4sbo7jlh0c1mwDoXAeeVBTZ0gbC 19 | KyT2/iKz1MMvJzmfme/Bu605slNzIaEilINpIQPm1enf3S1k 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /SerialPort.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9600 5 | 6 | 7 | 9600 8 | 9 | 10 | 9600 11 | 12 | 13 | 9600 14 | 15 | 16 | 9600 17 | 18 | 19 | 9600 20 | 21 | 22 | 9600 23 | 24 | 25 | 9600 26 | 27 | 28 | 9600 29 | 30 | 31 | 9600 32 | 33 | 34 | 600 35 | 36 | -------------------------------------------------------------------------------- /Sm2Site.pem: -------------------------------------------------------------------------------- 1 | 2 | 3 | 2BEE27A2 4 | BCE1191B83A08F8A9F94C974D5E8ED080613CC54C85CC55A20030C86CC980386 5 | 7B24525D67DC59F25B885282CBDDDD70DE82575A1F6136D44339E83F5DEAD063 6 | 7 | -------------------------------------------------------------------------------- /binary/DAT2C.LinuxX86: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/binary/DAT2C.LinuxX86 -------------------------------------------------------------------------------- /binary/DAT2C.WIN32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/binary/DAT2C.WIN32.exe -------------------------------------------------------------------------------- /cfg/BF533Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | -------------------------------------------------------------------------------- /cfg/H101_TransmitCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | false 7 | 11 | 12 | -------------------------------------------------------------------------------- /cfg/H103Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TRUE 4 | 5 | 6 | 3 7 | NormalType 8 | 10 | 11 | 165 12 | 13 | 14 | 61 15 | 2 16 | 10 17 | 10 18 | 19 | 20 | -------------------------------------------------------------------------------- /cfg/H103Cfg9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | NZStatus.log 4 | NZFrame.log 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /cfg/H103_NZCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TRUE 4 | 6 | 7 | 8 | NoShortFrameType 9 | 10 | 0 11 | 0 12 | 13 | 14 | 30 15 | 16 | 17 | -------------------------------------------------------------------------------- /cfg/H103_NZ_UDPCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | -------------------------------------------------------------------------------- /cfg/H104Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /cfg/H104_TransmitCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | false 7 | 11 | 12 | -------------------------------------------------------------------------------- /cfg/ModbusCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ModbusStatus.log 4 | ModbusFrame.log 5 | 6 | 7 | 1 8 | 9 | 3 10 | 288 11 | 18 12 | YcDataType 13 | 0 14 | 15 | 16 | 2 17 | 128 18 | 2 19 | YxDataType 20 | 0 21 | 22 | 23 | 5 24 | 160 25 | 0 26 | YkDataType 27 | 0 28 | 29 | 30 | 16 31 | 176 32 | 4 33 | SynTimeType 34 | 0 35 | 36 | 37 | 38 | 1 39 | 40 | 3 41 | 288 42 | 18 43 | YcDataType 44 | 0 45 | 46 | 47 | 2 48 | 128 49 | 2 50 | YxDataType 51 | 0 52 | 53 | 54 | 5 55 | 160 56 | 0 57 | YkDataType 58 | 0 59 | 60 | 61 | 16 62 | 176 63 | 4 64 | SynTimeType 65 | 0 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /cfg/S101_TransmitCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | fasle 7 | 8 | Ecc 9 | EccSite.pem 10 | 11 | 12 | -------------------------------------------------------------------------------- /cfg/S104Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ./ProtocolLog/S104Status.log 4 | ./ProtocolLog/S104Frame.log 5 | true 6 | true 7 | 8 | Sm2 9 | Sm2Site.pem 10 | 11 | -------------------------------------------------------------------------------- /cfg/S104_TransmitCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | false 6 | false 7 | 8 | Sm2 9 | Sm2Site.pem 10 | 11 | 12 | -------------------------------------------------------------------------------- /cfg/SerialPort.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9600 5 | 6 | 7 | 9600 8 | 9 | 10 | 9600 11 | 12 | 13 | 9600 14 | 15 | 16 | 9600 17 | 18 | 19 | 9600 20 | 21 | 22 | 9600 23 | 24 | 25 | 9600 26 | 27 | 28 | 9600 29 | 30 | 31 | 9600 32 | 33 | -------------------------------------------------------------------------------- /cfg/SoeRecord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 4 | 5 | 40 6 | 0 7 | 2011-Sep-08 09:42:38.568729 8 | 9 | 10 | 40 11 | 0 12 | 2011-Sep-08 13:52:26.943015 13 | 14 | 15 | 40 16 | 0 17 | 2011-Sep-08 13:53:30.187632 18 | 19 | 20 | 40 21 | 0 22 | 2011-Sep-08 13:55:47.485485 23 | 24 | 25 | 40 26 | 0 27 | 2011-Sep-08 13:56:42.889654 28 | 29 | 30 | 40 31 | 0 32 | 2011-Sep-09 15:08:53.321672 33 | 34 | 35 | -------------------------------------------------------------------------------- /cfg/VirtualDoCfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TRUE 4 | 5 | -------------------------------------------------------------------------------- /cfg/YkRecord.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 4 | 5 | YkSelEvent 6 | 0 7 | Close 8 | 9 | 10 | YkExeEvent 11 | 0 12 | Close 13 | 14 | 15 | YkSelEvent 16 | 0 17 | Close 18 | 19 | 20 | YkCancelEvent 21 | 0 22 | Close 23 | 24 | 25 | -------------------------------------------------------------------------------- /cfg/sub-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WatchDogBF518 5 | ./InitLog/LoadSubCfg.log 6 | 7 | ./InitLog/InitComm.log 8 | 9 |
1
10 | 11 | 12 | H104_Transmit 13 | TcpClientChannel 14 | 2404 15 | 127.0.0.1 16 |
1
17 | false 18 | 19 | false 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 | 31 | 32 | S104_Transmit 33 | TcpServerChannel 34 | 2405 35 | 127.0.0.1 36 | 37 |
1
38 | true 39 | false 40 | 41 | false 42 | 43 | 44 | 45 | 46 | 47 |
48 |
49 |
50 | -------------------------------------------------------------------------------- /lib/boost_1_53_0_beta1.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/boost_1_53_0_beta1.7z -------------------------------------------------------------------------------- /lib/libeay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libeay32.lib -------------------------------------------------------------------------------- /lib/libsm2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libsm2.a -------------------------------------------------------------------------------- /lib/libzkty_dio-pcm82x.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libzkty_dio-pcm82x.so -------------------------------------------------------------------------------- /lib/libzkty_dio.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libzkty_dio.a -------------------------------------------------------------------------------- /lib/libzkty_dio.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libzkty_dio.so -------------------------------------------------------------------------------- /lib/libzkty_dio.so-glibc2.4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libzkty_dio.so-glibc2.4 -------------------------------------------------------------------------------- /lib/libzkty_led.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/libzkty_led.a -------------------------------------------------------------------------------- /lib/openssl-1.0.1c.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/openssl-1.0.1c.tar.gz -------------------------------------------------------------------------------- /lib/zkty_dio.ko: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunhouguo/DAT2C/2a12c45b986848d317f884b1bcce1bfe60f0e326/lib/zkty_dio.ko -------------------------------------------------------------------------------- /posix_main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "./DataBase/SubStation.h" 3 | 4 | #ifdef _PCM82X_ 5 | #define strDevType "PCM82X" 6 | #endif 7 | 8 | #ifdef _TPE3000_ 9 | #define strDevType "TPE3000" 10 | #endif 11 | 12 | #ifdef _BF518_ 13 | #define strDevType "BF518" 14 | #endif 15 | 16 | 17 | #if !defined(_WIN32) 18 | 19 | #ifndef strDevType 20 | #define strDevType "Unknown" 21 | #endif 22 | 23 | int main(int argc, char* argv[]) 24 | { 25 | for (;;) 26 | { 27 | DataBase::CSubStation sub; 28 | try 29 | { 30 | if(!sub.LoadXmlCfg(MainCfgFile)) 31 | { 32 | std::cout << "Program Type: "< 2 | #include "./DataBase/SubStation.h" 3 | 4 | #if defined(_WIN32) 5 | 6 | #define strDevType "WIN32" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | for (;;) 11 | { 12 | DataBase::CSubStation sub; 13 | try 14 | { 15 | if(!sub.LoadXmlCfg(MainCfgFile)) 16 | { 17 | std::cout << "Program Type: "<