Initial Commit
parent
028aef0ce7
commit
df99be7d50
@ -0,0 +1,31 @@
|
|||||||
|
d:\project\htslvservice\debug\vc120.pdb
|
||||||
|
d:\project\htslvservice\debug\vc120.idb
|
||||||
|
d:\project\htslvservice\debug\static_model.obj
|
||||||
|
d:\project\htslvservice\debug\htbusidatabase.obj
|
||||||
|
d:\project\htslvservice\debug\htconfig.obj
|
||||||
|
d:\project\htslvservice\debug\htdatabase.obj
|
||||||
|
d:\project\htslvservice\debug\htglobal.obj
|
||||||
|
d:\project\htslvservice\debug\htinitutils.obj
|
||||||
|
d:\project\htslvservice\debug\htlogger.obj
|
||||||
|
d:\project\htslvservice\debug\htmodbus.obj
|
||||||
|
d:\project\htslvservice\debug\htpublic.obj
|
||||||
|
d:\project\htslvservice\debug\htslvservice.obj
|
||||||
|
d:\project\htslvservice\debug\htstrconvert.obj
|
||||||
|
d:\project\htslvservice\debug\httcpsocket.obj
|
||||||
|
d:\project\htslvservice\debug\htthread.obj
|
||||||
|
d:\project\htslvservice\debug\htunit.obj
|
||||||
|
d:\project\htslvservice\debug\htxmlmethod.obj
|
||||||
|
d:\project\htslvservice\debug\htntptime.obj
|
||||||
|
d:\project\htslvservice\debug\htsntpc.obj
|
||||||
|
d:\project\htslvservice\debug\htsntpd.obj
|
||||||
|
d:\project\htslvservice\debug\htiec61850.obj
|
||||||
|
d:\project\htslvservice\debug\htiec61850thread.obj
|
||||||
|
d:\project\htslvservice\debug\htslvservice.ilk
|
||||||
|
d:\project\htslvservice\debug\htslvservice.exe
|
||||||
|
d:\project\htslvservice\debug\htslvservice.pdb
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\cl.command.1.tlog
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\cl.read.1.tlog
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\cl.write.1.tlog
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\link.command.1.tlog
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\link.read.1.tlog
|
||||||
|
d:\project\htslvservice\debug\htslvservice.tlog\link.write.1.tlog
|
@ -0,0 +1,35 @@
|
|||||||
|
Build started 10/26/2020 10:06:01 PM.
|
||||||
|
1>Project "D:\project\HTSLVService\HTSLVService.vcxproj" on node 2 (Build target(s)).
|
||||||
|
1>ClCompile:
|
||||||
|
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /Zi /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB_IEC_61850 /D _CRT_SECURE_NO_WARNINGS /D _WINSOCK_DEPRECATED_NO_WARNINGS /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt src\HTSLVService.cpp
|
||||||
|
HTSLVService.cpp
|
||||||
|
1>src\HTSLVService.cpp(169): warning C4566: character represented by universal-character-name '\u00B2' cannot be represented in the current code page (936)
|
||||||
|
1>src\HTSLVService.cpp(170): warning C4566: character represented by universal-character-name '\u00B2' cannot be represented in the current code page (936)
|
||||||
|
1>src\HTSLVService.cpp(171): warning C4566: character represented by universal-character-name '\u00B2' cannot be represented in the current code page (936)
|
||||||
|
Link:
|
||||||
|
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"D:\project\HTSLVService\Debug\HTSLVService.exe" /INCREMENTAL /NOLOGO modbus.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"D:\project\HTSLVService\Debug\HTSLVService.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:\project\HTSLVService\Debug\HTSLVService.lib" /MACHINE:X86 Debug\static_model.obj
|
||||||
|
Debug\HTBusiDatabase.obj
|
||||||
|
Debug\HTConfig.obj
|
||||||
|
Debug\HTDatabase.obj
|
||||||
|
Debug\HTGlobal.obj
|
||||||
|
Debug\HTIEC61850.obj
|
||||||
|
Debug\HTIEC61850Thread.obj
|
||||||
|
Debug\HTInitUtils.obj
|
||||||
|
Debug\HTLogger.obj
|
||||||
|
Debug\HTModbus.obj
|
||||||
|
Debug\HTPublic.obj
|
||||||
|
Debug\HTSLVService.obj
|
||||||
|
Debug\HTStrConvert.obj
|
||||||
|
Debug\HTTcpSocket.obj
|
||||||
|
Debug\HTThread.obj
|
||||||
|
Debug\HTUnit.obj
|
||||||
|
Debug\HTXmlMethod.obj
|
||||||
|
Debug\HTNtptime.obj
|
||||||
|
Debug\HTSntpc.obj
|
||||||
|
Debug\HTSntpd.obj
|
||||||
|
HTSLVService.vcxproj -> D:\project\HTSLVService\Debug\HTSLVService.exe
|
||||||
|
1>Done Building Project "D:\project\HTSLVService\HTSLVService.vcxproj" (Build target(s)).
|
||||||
|
|
||||||
|
Build succeeded.
|
||||||
|
|
||||||
|
Time Elapsed 00:00:01.57
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,2 @@
|
|||||||
|
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
|
||||||
|
Debug|Win32|D:\project\HTSLVService\|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,194 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\modbus">
|
||||||
|
<UniqueIdentifier>{eedfbae3-242c-489e-9caa-d123e952e0b6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files\sntp">
|
||||||
|
<UniqueIdentifier>{9a718709-95a2-4b36-af7b-cc8a025e8077}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Source Files\sntp">
|
||||||
|
<UniqueIdentifier>{32e10d27-9b7f-41a6-a19b-046f0a349bda}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="src\HTSLVService.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTConfig.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTDatabase.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTGlobal.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTInitUtils.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTLogger.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTPublic.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTStrConvert.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTThread.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTUnit.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTXmlMethod.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTTcpSocket.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTModbus.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\sntp\HTSntpc.cpp">
|
||||||
|
<Filter>Source Files\sntp</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\sntp\HTSntpd.cpp">
|
||||||
|
<Filter>Source Files\sntp</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\sntp\HTNtptime.cpp">
|
||||||
|
<Filter>Source Files\sntp</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTBusiDatabase.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTIEC61850.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="scl_tool\static_model.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\HTIEC61850Thread.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="include\HTConfig.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTConst.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTDatabase.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTError.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTGlobal.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTInitUtils.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTLogger.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTMutex.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTPublic.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTStrConvert.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTThread.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTType.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTUnit.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTXmlMethod.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTTcpSocket.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTVersion.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTModbus.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-private.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-rtu.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-rtu-private.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-tcp.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-tcp-private.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\modbus\modbus-version.h">
|
||||||
|
<Filter>Header Files\modbus</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\sntp\HTSntp.h">
|
||||||
|
<Filter>Header Files\sntp</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\sntp\HTNtptime.h">
|
||||||
|
<Filter>Header Files\sntp</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTBusiDatabase.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTIEC61850.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTDataStruct.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="scl_tool\static_model.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="include\HTIEC61850Thread.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="src\makefile">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="etc\htiecsvr.conf">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="etc\sjzd.cfg">
|
||||||
|
<Filter>Resource Files</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LocalDebuggerCommandArguments>start</LocalDebuggerCommandArguments>
|
||||||
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,144 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file HTYmodem.h
|
||||||
|
* @author XinLi
|
||||||
|
* @version v1.0
|
||||||
|
* @date 21-January-2018
|
||||||
|
* @brief Header file for Ymodem.cpp module.
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>Copyright © 2018 XinLi</center></h2>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HT_YMODEM_H
|
||||||
|
#define _HT_YMODEM_H
|
||||||
|
|
||||||
|
/* Header includes -----------------------------------------------------------*/
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* Macro definitions ---------------------------------------------------------*/
|
||||||
|
#define YMODEM_PACKET_HEADER (3)
|
||||||
|
#define YMODEM_PACKET_TRAILER (2)
|
||||||
|
#define YMODEM_PACKET_OVERHEAD (YMODEM_PACKET_HEADER + YMODEM_PACKET_TRAILER)
|
||||||
|
#define YMODEM_PACKET_SIZE (128)
|
||||||
|
#define YMODEM_PACKET_1K_SIZE (1024)
|
||||||
|
|
||||||
|
#define YMODEM_CODE_CAN_NUMBER (5)
|
||||||
|
|
||||||
|
/* Type definitions ----------------------------------------------------------*/
|
||||||
|
class Ymodem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum Code
|
||||||
|
{
|
||||||
|
CodeNone = 0x00,
|
||||||
|
CodeSoh = 0x01,
|
||||||
|
CodeStx = 0x02,
|
||||||
|
CodeEot = 0x04,
|
||||||
|
CodeAck = 0x06,
|
||||||
|
CodeNak = 0x15,
|
||||||
|
CodeCan = 0x18,
|
||||||
|
CodeC = 0x43,
|
||||||
|
CodeA1 = 0x41,
|
||||||
|
CodeA2 = 0x61
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Stage
|
||||||
|
{
|
||||||
|
StageNone,
|
||||||
|
StageEstablishing,
|
||||||
|
StageEstablished,
|
||||||
|
StageTransmitting,
|
||||||
|
StageFinishing,
|
||||||
|
StageFinished
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Status
|
||||||
|
{
|
||||||
|
StatusEstablish,
|
||||||
|
StatusTransmit,
|
||||||
|
StatusFinish,
|
||||||
|
StatusAbort,
|
||||||
|
StatusTimeout,
|
||||||
|
StatusError
|
||||||
|
};
|
||||||
|
|
||||||
|
Ymodem(uint32_t timeDivide = 499, uint32_t timeMax = 5, uint32_t errorMax = 999);
|
||||||
|
|
||||||
|
void setTimeDivide(uint32_t timeDivide);
|
||||||
|
uint32_t getTimeDivide();
|
||||||
|
|
||||||
|
void setTimeMax(uint32_t timeMax);
|
||||||
|
uint32_t getTimeMax();
|
||||||
|
|
||||||
|
void setErrorMax(uint32_t errorMax);
|
||||||
|
uint32_t getErrorMax();
|
||||||
|
|
||||||
|
void receive();
|
||||||
|
void transmit();
|
||||||
|
void abort();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Code receivePacket();
|
||||||
|
|
||||||
|
void receiveStageNone();
|
||||||
|
void receiveStageEstablishing();
|
||||||
|
void receiveStageEstablished();
|
||||||
|
void receiveStageTransmitting();
|
||||||
|
void receiveStageFinishing();
|
||||||
|
void receiveStageFinished();
|
||||||
|
|
||||||
|
void transmitStageNone();
|
||||||
|
void transmitStageEstablishing();
|
||||||
|
void transmitStageEstablished();
|
||||||
|
void transmitStageTransmitting();
|
||||||
|
void transmitStageFinishing();
|
||||||
|
void transmitStageFinished();
|
||||||
|
|
||||||
|
uint16_t crc16(uint8_t *buff, uint32_t len);
|
||||||
|
|
||||||
|
virtual Code callback(Status status, uint8_t *buff, uint32_t *len) = 0;
|
||||||
|
|
||||||
|
virtual uint32_t read(uint8_t *buff, uint32_t len) = 0;
|
||||||
|
virtual uint32_t write(uint8_t *buff, uint32_t len) = 0;
|
||||||
|
|
||||||
|
uint32_t timeDivide;
|
||||||
|
uint32_t timeMax;
|
||||||
|
uint32_t errorMax;
|
||||||
|
|
||||||
|
uint32_t timeCount;
|
||||||
|
uint32_t errorCount;
|
||||||
|
uint8_t dataCount;
|
||||||
|
|
||||||
|
Code code;
|
||||||
|
Stage stage;
|
||||||
|
|
||||||
|
uint8_t rxBuffer[YMODEM_PACKET_1K_SIZE + YMODEM_PACKET_OVERHEAD];
|
||||||
|
uint8_t txBuffer[YMODEM_PACKET_1K_SIZE + YMODEM_PACKET_OVERHEAD];
|
||||||
|
uint32_t rxLength;
|
||||||
|
uint32_t txLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Variable declarations -----------------------------------------------------*/
|
||||||
|
/* Variable definitions ------------------------------------------------------*/
|
||||||
|
/* Function declarations -----------------------------------------------------*/
|
||||||
|
/* Function definitions ------------------------------------------------------*/
|
||||||
|
|
||||||
|
#endif /* __YMODEM_H */
|
||||||
|
|
@ -0,0 +1,240 @@
|
|||||||
|
#include "HTYModemFileReceive.h"
|
||||||
|
|
||||||
|
#define READ_TIME_OUT (10)
|
||||||
|
#define WRITE_TIME_OUT (100)
|
||||||
|
|
||||||
|
YmodemFileReceive::YmodemFileReceive(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
file(new QFile),
|
||||||
|
readTimer(new QTimer),
|
||||||
|
writeTimer(new QTimer),
|
||||||
|
serialPort(new QSerialPort)
|
||||||
|
{
|
||||||
|
setTimeDivide(499);
|
||||||
|
setTimeMax(5);
|
||||||
|
setErrorMax(999);
|
||||||
|
|
||||||
|
serialPort->setPortName("COM1");
|
||||||
|
serialPort->setBaudRate(115200);
|
||||||
|
serialPort->setDataBits(QSerialPort::Data8);
|
||||||
|
serialPort->setStopBits(QSerialPort::OneStop);
|
||||||
|
serialPort->setParity(QSerialPort::NoParity);
|
||||||
|
serialPort->setFlowControl(QSerialPort::NoFlowControl);
|
||||||
|
|
||||||
|
connect(readTimer, SIGNAL(timeout()), this, SLOT(readTimeOut()));
|
||||||
|
connect(writeTimer, SIGNAL(timeout()), this, SLOT(writeTimeOut()));
|
||||||
|
}
|
||||||
|
|
||||||
|
YmodemFileReceive::~YmodemFileReceive()
|
||||||
|
{
|
||||||
|
delete file;
|
||||||
|
delete readTimer;
|
||||||
|
delete writeTimer;
|
||||||
|
delete serialPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::setFilePath(const QString &path)
|
||||||
|
{
|
||||||
|
filePath = path + "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::setPortName(const QString &name)
|
||||||
|
{
|
||||||
|
serialPort->setPortName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::setPortBaudRate(qint32 baudrate)
|
||||||
|
{
|
||||||
|
serialPort->setBaudRate(baudrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YmodemFileReceive::startReceive()
|
||||||
|
{
|
||||||
|
progress = 0;
|
||||||
|
status = StatusEstablish;
|
||||||
|
|
||||||
|
if(serialPort->open(QSerialPort::ReadWrite) == true)
|
||||||
|
{
|
||||||
|
readTimer->start(READ_TIME_OUT);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::stopReceive()
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
abort();
|
||||||
|
status = StatusAbort;
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int YmodemFileReceive::getReceiveProgress()
|
||||||
|
{
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ymodem::Status YmodemFileReceive::getReceiveStatus()
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::readTimeOut()
|
||||||
|
{
|
||||||
|
readTimer->stop();
|
||||||
|
|
||||||
|
receive();
|
||||||
|
|
||||||
|
if((status == StatusEstablish) || (status == StatusTransmit))
|
||||||
|
{
|
||||||
|
readTimer->start(READ_TIME_OUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileReceive::writeTimeOut()
|
||||||
|
{
|
||||||
|
writeTimer->stop();
|
||||||
|
serialPort->close();
|
||||||
|
receiveStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ymodem::Code YmodemFileReceive::callback(Status status, uint8_t *buff, uint32_t *len)
|
||||||
|
{
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case StatusEstablish:
|
||||||
|
{
|
||||||
|
if(buff[0] != 0)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
char name[128] = {0};
|
||||||
|
char size[128] = {0};
|
||||||
|
|
||||||
|
for(int j = 0; buff[i] != 0; i++, j++)
|
||||||
|
{
|
||||||
|
name[j] = buff[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
|
||||||
|
for(int j = 0; buff[i] != 0; i++, j++)
|
||||||
|
{
|
||||||
|
size[j] = buff[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName = QString::fromLocal8Bit(name);
|
||||||
|
fileSize = QString(size).toULongLong();
|
||||||
|
fileCount = 0;
|
||||||
|
|
||||||
|
file->setFileName(filePath + fileName);
|
||||||
|
|
||||||
|
if(file->open(QFile::WriteOnly) == true)
|
||||||
|
{
|
||||||
|
YmodemFileReceive::status = StatusEstablish;
|
||||||
|
|
||||||
|
receiveStatus(StatusEstablish);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YmodemFileReceive::status = StatusError;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YmodemFileReceive::status = StatusError;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusTransmit:
|
||||||
|
{
|
||||||
|
if((fileSize - fileCount) > *len)
|
||||||
|
{
|
||||||
|
file->write((char *)buff, *len);
|
||||||
|
|
||||||
|
fileCount += *len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
file->write((char *)buff, fileSize - fileCount);
|
||||||
|
|
||||||
|
fileCount += fileSize - fileCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress = (int)(fileCount * 100 / fileSize);
|
||||||
|
|
||||||
|
YmodemFileReceive::status = StatusTransmit;
|
||||||
|
|
||||||
|
receiveProgress(progress);
|
||||||
|
receiveStatus(StatusTransmit);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusFinish:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileReceive::status = StatusFinish;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusAbort:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileReceive::status = StatusAbort;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusTimeout:
|
||||||
|
{
|
||||||
|
YmodemFileReceive::status = StatusTimeout;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileReceive::status = StatusError;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t YmodemFileReceive::read(uint8_t *buff, uint32_t len)
|
||||||
|
{
|
||||||
|
return serialPort->read((char *)buff, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t YmodemFileReceive::write(uint8_t *buff, uint32_t len)
|
||||||
|
{
|
||||||
|
return serialPort->write((char *)buff, len);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef _HT_YMODEMFILERECEIVE_H
|
||||||
|
#define _HT_YMODEMFILERECEIVE_H
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSerialPort>
|
||||||
|
#include "HTYModem.h"
|
||||||
|
|
||||||
|
class YmodemFileReceive : public QObject, public Ymodem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit YmodemFileReceive(QObject *parent = 0);
|
||||||
|
~YmodemFileReceive();
|
||||||
|
|
||||||
|
void setFilePath(const QString &path);
|
||||||
|
|
||||||
|
void setPortName(const QString &name);
|
||||||
|
void setPortBaudRate(qint32 baudrate);
|
||||||
|
|
||||||
|
bool startReceive();
|
||||||
|
void stopReceive();
|
||||||
|
|
||||||
|
int getReceiveProgress();
|
||||||
|
Status getReceiveStatus();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void receiveProgress(int progress);
|
||||||
|
void receiveStatus(YmodemFileReceive::Status status);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void readTimeOut();
|
||||||
|
void writeTimeOut();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Code callback(Status status, uint8_t *buff, uint32_t *len);
|
||||||
|
|
||||||
|
uint32_t read(uint8_t *buff, uint32_t len);
|
||||||
|
uint32_t write(uint8_t *buff, uint32_t len);
|
||||||
|
|
||||||
|
QFile *file;
|
||||||
|
QTimer *readTimer;
|
||||||
|
QTimer *writeTimer;
|
||||||
|
QSerialPort *serialPort;
|
||||||
|
|
||||||
|
int progress;
|
||||||
|
Status status;
|
||||||
|
QString filePath;
|
||||||
|
QString fileName;
|
||||||
|
uint64_t fileSize;
|
||||||
|
uint64_t fileCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _HT_YMODEMFILERECEIVE_H
|
@ -0,0 +1,228 @@
|
|||||||
|
#include "YmodemFileTransmit.h"
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#define READ_TIME_OUT (10)
|
||||||
|
#define WRITE_TIME_OUT (100)
|
||||||
|
|
||||||
|
YmodemFileTransmit::YmodemFileTransmit(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
file(new QFile),
|
||||||
|
readTimer(new QTimer),
|
||||||
|
writeTimer(new QTimer),
|
||||||
|
serialPort(new QSerialPort)
|
||||||
|
{
|
||||||
|
setTimeDivide(499);
|
||||||
|
setTimeMax(5);
|
||||||
|
setErrorMax(999);
|
||||||
|
|
||||||
|
serialPort->setPortName("COM1");
|
||||||
|
serialPort->setBaudRate(115200);
|
||||||
|
serialPort->setDataBits(QSerialPort::Data8);
|
||||||
|
serialPort->setStopBits(QSerialPort::OneStop);
|
||||||
|
serialPort->setParity(QSerialPort::NoParity);
|
||||||
|
serialPort->setFlowControl(QSerialPort::NoFlowControl);
|
||||||
|
|
||||||
|
connect(readTimer, SIGNAL(timeout()), this, SLOT(readTimeOut()));
|
||||||
|
connect(writeTimer, SIGNAL(timeout()), this, SLOT(writeTimeOut()));
|
||||||
|
}
|
||||||
|
|
||||||
|
YmodemFileTransmit::~YmodemFileTransmit()
|
||||||
|
{
|
||||||
|
delete file;
|
||||||
|
delete readTimer;
|
||||||
|
delete writeTimer;
|
||||||
|
delete serialPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::setFileName(const QString &name)
|
||||||
|
{
|
||||||
|
file->setFileName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::setPortName(const QString &name)
|
||||||
|
{
|
||||||
|
serialPort->setPortName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::setPortBaudRate(qint32 baudrate)
|
||||||
|
{
|
||||||
|
serialPort->setBaudRate(baudrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YmodemFileTransmit::startTransmit()
|
||||||
|
{
|
||||||
|
progress = 0;
|
||||||
|
status = StatusEstablish;
|
||||||
|
|
||||||
|
if(serialPort->open(QSerialPort::ReadWrite) == true)
|
||||||
|
{
|
||||||
|
readTimer->start(READ_TIME_OUT);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::stopTransmit()
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
abort();
|
||||||
|
status = StatusAbort;
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int YmodemFileTransmit::getTransmitProgress()
|
||||||
|
{
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ymodem::Status YmodemFileTransmit::getTransmitStatus()
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::readTimeOut()
|
||||||
|
{
|
||||||
|
readTimer->stop();
|
||||||
|
|
||||||
|
transmit();
|
||||||
|
|
||||||
|
if((status == StatusEstablish) || (status == StatusTransmit))
|
||||||
|
{
|
||||||
|
readTimer->start(READ_TIME_OUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YmodemFileTransmit::writeTimeOut()
|
||||||
|
{
|
||||||
|
writeTimer->stop();
|
||||||
|
serialPort->close();
|
||||||
|
transmitStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ymodem::Code YmodemFileTransmit::callback(Status status, uint8_t *buff, uint32_t *len)
|
||||||
|
{
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case StatusEstablish:
|
||||||
|
{
|
||||||
|
if(file->open(QFile::ReadOnly) == true)
|
||||||
|
{
|
||||||
|
QFileInfo fileInfo(*file);
|
||||||
|
|
||||||
|
fileSize = fileInfo.size();
|
||||||
|
fileCount = 0;
|
||||||
|
|
||||||
|
strcpy((char *)buff, fileInfo.fileName().toLocal8Bit().data());
|
||||||
|
strcpy((char *)buff + fileInfo.fileName().toLocal8Bit().size() + 1, QByteArray::number(fileInfo.size()).data());
|
||||||
|
|
||||||
|
*len = YMODEM_PACKET_SIZE;
|
||||||
|
|
||||||
|
YmodemFileTransmit::status = StatusEstablish;
|
||||||
|
|
||||||
|
transmitStatus(StatusEstablish);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YmodemFileTransmit::status = StatusError;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusTransmit:
|
||||||
|
{
|
||||||
|
if(fileSize != fileCount)
|
||||||
|
{
|
||||||
|
if((fileSize - fileCount) > YMODEM_PACKET_SIZE)
|
||||||
|
{
|
||||||
|
fileCount += file->read((char *)buff, YMODEM_PACKET_1K_SIZE);
|
||||||
|
|
||||||
|
*len = YMODEM_PACKET_1K_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileCount += file->read((char *)buff, YMODEM_PACKET_SIZE);
|
||||||
|
|
||||||
|
*len = YMODEM_PACKET_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
progress = (int)(fileCount * 100 / fileSize);
|
||||||
|
|
||||||
|
YmodemFileTransmit::status = StatusTransmit;
|
||||||
|
|
||||||
|
transmitProgress(progress);
|
||||||
|
transmitStatus(StatusTransmit);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YmodemFileTransmit::status = StatusTransmit;
|
||||||
|
|
||||||
|
transmitStatus(StatusTransmit);
|
||||||
|
|
||||||
|
return CodeEot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusFinish:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileTransmit::status = StatusFinish;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeAck;
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusAbort:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileTransmit::status = StatusAbort;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
|
||||||
|
case StatusTimeout:
|
||||||
|
{
|
||||||
|
YmodemFileTransmit::status = StatusTimeout;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
file->close();
|
||||||
|
|
||||||
|
YmodemFileTransmit::status = StatusError;
|
||||||
|
|
||||||
|
writeTimer->start(WRITE_TIME_OUT);
|
||||||
|
|
||||||
|
return CodeCan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t YmodemFileTransmit::read(uint8_t *buff, uint32_t len)
|
||||||
|
{
|
||||||
|
return serialPort->read((char *)buff, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t YmodemFileTransmit::write(uint8_t *buff, uint32_t len)
|
||||||
|
{
|
||||||
|
return serialPort->write((char *)buff, len);
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef _HT_YMODEMFILETRANSMIT_H
|
||||||
|
#define _HT_YMODEMFILETRANSMIT_H
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QSerialPort>
|
||||||
|
#include "HTYModem.h"
|
||||||
|
|
||||||
|
class YmodemFileTransmit : public QObject, public Ymodem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit YmodemFileTransmit(QObject *parent = 0);
|
||||||
|
~YmodemFileTransmit();
|
||||||
|
|
||||||
|
void setFileName(const QString &name);
|
||||||
|
|
||||||
|
void setPortName(const QString &name);
|
||||||
|
void setPortBaudRate(qint32 baudrate);
|
||||||
|
|
||||||
|
bool startTransmit();
|
||||||
|
void stopTransmit();
|
||||||
|
|
||||||
|
int getTransmitProgress();
|
||||||
|
Status getTransmitStatus();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void transmitProgress(int progress);
|
||||||
|
void transmitStatus(YmodemFileTransmit::Status status);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void readTimeOut();
|
||||||
|
void writeTimeOut();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Code callback(Status status, uint8_t *buff, uint32_t *len);
|
||||||
|
|
||||||
|
uint32_t read(uint8_t *buff, uint32_t len);
|
||||||
|
uint32_t write(uint8_t *buff, uint32_t len);
|
||||||
|
|
||||||
|
QFile *file;
|
||||||
|
QTimer *readTimer;
|
||||||
|
QTimer *writeTimer;
|
||||||
|
QSerialPort *serialPort;
|
||||||
|
|
||||||
|
int progress;
|
||||||
|
Status status;
|
||||||
|
uint64_t fileSize;
|
||||||
|
uint64_t fileCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _HT_YMODEMFILETRANSMIT_H
|
@ -0,0 +1,40 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2018-01-20T23:00:46
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core gui
|
||||||
|
QT += serialport
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
|
TARGET = SerialPortYmodem
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
# The following define makes your compiler emit warnings if you use
|
||||||
|
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||||
|
# depend on your compiler). Please consult the documentation of the
|
||||||
|
# deprecated API in order to know how to port your code away from it.
|
||||||
|
DEFINES += QT_DEPRECATED_WARNINGS
|
||||||
|
|
||||||
|
# You can also make your code fail to compile if you use deprecated APIs.
|
||||||
|
# In order to do so, uncomment the following line.
|
||||||
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp\
|
||||||
|
widget.cpp \
|
||||||
|
HTYModemFileReceive.cpp \
|
||||||
|
HTYModem.cpp \
|
||||||
|
HTYModemFileTransmit.cpp
|
||||||
|
|
||||||
|
HEADERS += widget.h \
|
||||||
|
HTYModem.h \
|
||||||
|
HTYModemFileReceive.h \
|
||||||
|
HTYModemFileTransmit.h
|
||||||
|
|
||||||
|
FORMS += widget.ui
|
||||||
|
|
||||||
|
RC_ICONS = SerialPortYmodem.ico
|
@ -0,0 +1,11 @@
|
|||||||
|
#include "widget.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
Widget w;
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
@ -0,0 +1,400 @@
|
|||||||
|
#include "widget.h"
|
||||||
|
#include "ui_widget.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QSerialPortInfo>
|
||||||
|
|
||||||
|
Widget::Widget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::Widget),
|
||||||
|
serialPort(new QSerialPort),
|
||||||
|
ymodemFileTransmit(new YmodemFileTransmit),
|
||||||
|
ymodemFileReceive(new YmodemFileReceive)
|
||||||
|
{
|
||||||
|
transmitButtonStatus = false;
|
||||||
|
receiveButtonStatus = false;
|
||||||
|
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
QSerialPortInfo serialPortInfo;
|
||||||
|
|
||||||
|
foreach(serialPortInfo, QSerialPortInfo::availablePorts())
|
||||||
|
{
|
||||||
|
ui->comPort->addItem(serialPortInfo.portName());
|
||||||
|
}
|
||||||
|
|
||||||
|
serialPort->setPortName("COM1");
|
||||||
|
serialPort->setBaudRate(115200);
|
||||||
|
serialPort->setDataBits(QSerialPort::Data8);
|
||||||
|
serialPort->setStopBits(QSerialPort::OneStop);
|
||||||
|
serialPort->setParity(QSerialPort::NoParity);
|
||||||
|
serialPort->setFlowControl(QSerialPort::NoFlowControl);
|
||||||
|
|
||||||
|
connect(ymodemFileTransmit, SIGNAL(transmitProgress(int)), this, SLOT(transmitProgress(int)));
|
||||||
|
connect(ymodemFileReceive, SIGNAL(receiveProgress(int)), this, SLOT(receiveProgress(int)));
|
||||||
|
connect(ymodemFileTransmit, SIGNAL(transmitStatus(YmodemFileTransmit::Status)), this, SLOT(transmitStatus(YmodemFileTransmit::Status)));
|
||||||
|
connect(ymodemFileReceive, SIGNAL(receiveStatus(YmodemFileReceive::Status)), this, SLOT(receiveStatus(YmodemFileReceive::Status)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget::~Widget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
delete serialPort;
|
||||||
|
delete ymodemFileTransmit;
|
||||||
|
delete ymodemFileReceive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_comButton_clicked()
|
||||||
|
{
|
||||||
|
static bool button_status = false;
|
||||||
|
|
||||||
|
if(button_status == false)
|
||||||
|
{
|
||||||
|
serialPort->setPortName(ui->comPort->currentText());
|
||||||
|
serialPort->setBaudRate(ui->comBaudRate->currentText().toInt());
|
||||||
|
|
||||||
|
if(serialPort->open(QSerialPort::ReadWrite) == true)
|
||||||
|
{
|
||||||
|
button_status = true;
|
||||||
|
|
||||||
|
ui->comPort->setDisabled(true);
|
||||||
|
ui->comBaudRate->setDisabled(true);
|
||||||
|
ui->comButton->setText(u8"关闭串口");
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, u8"串口打开失败", u8"请检查串口是否已被占用!", u8"关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button_status = false;
|
||||||
|
|
||||||
|
serialPort->close();
|
||||||
|
|
||||||
|
ui->comPort->setEnabled(true);
|
||||||
|
ui->comBaudRate->setEnabled(true);
|
||||||
|
ui->comButton->setText(u8"打开串口");
|
||||||
|
|
||||||
|
ui->transmitBrowse->setDisabled(true);
|
||||||
|
ui->transmitButton->setDisabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setDisabled(true);
|
||||||
|
ui->receiveButton->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_transmitBrowse_clicked()
|
||||||
|
{
|
||||||
|
ui->transmitPath->setText(QFileDialog::getOpenFileName(this, u8"打开文件", ".", u8"任意文件 (*.*)"));
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->transmitButton->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_receiveBrowse_clicked()
|
||||||
|
{
|
||||||
|
ui->receivePath->setText(QFileDialog::getExistingDirectory(this, u8"选择目录", ".", QFileDialog::ShowDirsOnly));
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->receiveButton->setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_transmitButton_clicked()
|
||||||
|
{
|
||||||
|
if(transmitButtonStatus == false)
|
||||||
|
{
|
||||||
|
serialPort->close();
|
||||||
|
|
||||||
|
ymodemFileTransmit->setFileName(ui->transmitPath->text());
|
||||||
|
ymodemFileTransmit->setPortName(ui->comPort->currentText());
|
||||||
|
ymodemFileTransmit->setPortBaudRate(ui->comBaudRate->currentText().toInt());
|
||||||
|
|
||||||
|
if(ymodemFileTransmit->startTransmit() == true)
|
||||||
|
{
|
||||||
|
transmitButtonStatus = true;
|
||||||
|
|
||||||
|
ui->comButton->setDisabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setDisabled(true);
|
||||||
|
ui->receiveButton->setDisabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setDisabled(true);
|
||||||
|
ui->transmitButton->setText(u8"取消");
|
||||||
|
ui->transmitProgress->setValue(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件发送失败!", u8"关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ymodemFileTransmit->stopTransmit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_receiveButton_clicked()
|
||||||
|
{
|
||||||
|
if(receiveButtonStatus == false)
|
||||||
|
{
|
||||||
|
serialPort->close();
|
||||||
|
|
||||||
|
ymodemFileReceive->setFilePath(ui->receivePath->text());
|
||||||
|
ymodemFileReceive->setPortName(ui->comPort->currentText());
|
||||||
|
ymodemFileReceive->setPortBaudRate(ui->comBaudRate->currentText().toInt());
|
||||||
|
|
||||||
|
if(ymodemFileReceive->startReceive() == true)
|
||||||
|
{
|
||||||
|
receiveButtonStatus = true;
|
||||||
|
|
||||||
|
ui->comButton->setDisabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setDisabled(true);
|
||||||
|
ui->transmitButton->setDisabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setDisabled(true);
|
||||||
|
ui->receiveButton->setText(u8"取消");
|
||||||
|
ui->receiveProgress->setValue(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件接收失败!", u8"关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ymodemFileReceive->stopReceive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::transmitProgress(int progress)
|
||||||
|
{
|
||||||
|
ui->transmitProgress->setValue(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::receiveProgress(int progress)
|
||||||
|
{
|
||||||
|
ui->receiveProgress->setValue(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::transmitStatus(Ymodem::Status status)
|
||||||
|
{
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case YmodemFileTransmit::StatusEstablish:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileTransmit::StatusTransmit:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileTransmit::StatusFinish:
|
||||||
|
{
|
||||||
|
transmitButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
ui->transmitButton->setText(u8"发送");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"成功", u8"文件发送成功!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileTransmit::StatusAbort:
|
||||||
|
{
|
||||||
|
transmitButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
ui->transmitButton->setText(u8"发送");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件发送失败!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileTransmit::StatusTimeout:
|
||||||
|
{
|
||||||
|
transmitButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
ui->transmitButton->setText(u8"发送");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件发送失败!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
transmitButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->receivePath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->receiveButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
ui->transmitButton->setText(u8"发送");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件发送失败!", u8"关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::receiveStatus(YmodemFileReceive::Status status)
|
||||||
|
{
|
||||||
|
switch(status)
|
||||||
|
{
|
||||||
|
case YmodemFileReceive::StatusEstablish:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileReceive::StatusTransmit:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileReceive::StatusFinish:
|
||||||
|
{
|
||||||
|
receiveButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
ui->receiveButton->setText(u8"接收");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"成功", u8"文件接收成功!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileReceive::StatusAbort:
|
||||||
|
{
|
||||||
|
receiveButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
ui->receiveButton->setText(u8"接收");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件接收失败!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case YmodemFileReceive::StatusTimeout:
|
||||||
|
{
|
||||||
|
receiveButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
ui->receiveButton->setText(u8"接收");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件接收失败!", u8"关闭");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
receiveButtonStatus = false;
|
||||||
|
|
||||||
|
ui->comButton->setEnabled(true);
|
||||||
|
|
||||||
|
ui->transmitBrowse->setEnabled(true);
|
||||||
|
|
||||||
|
if(ui->transmitPath->text().isEmpty() != true)
|
||||||
|
{
|
||||||
|
ui->transmitButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->receiveBrowse->setEnabled(true);
|
||||||
|
ui->receiveButton->setText(u8"接收");
|
||||||
|
|
||||||
|
QMessageBox::warning(this, u8"失败", u8"文件接收失败!", u8"关闭");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef _HT_WIDGET_H
|
||||||
|
#define _HT_WIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "HTYModemFileTransmit.h"
|
||||||
|
#include "HTYModemFileReceive.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Widget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Widget(QWidget *parent = 0);
|
||||||
|
~Widget();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_comButton_clicked();
|
||||||
|
void on_transmitBrowse_clicked();
|
||||||
|
void on_receiveBrowse_clicked();
|
||||||
|
void on_transmitButton_clicked();
|
||||||
|
void on_receiveButton_clicked();
|
||||||
|
void transmitProgress(int progress);
|
||||||
|
void receiveProgress(int progress);
|
||||||
|
void transmitStatus(YmodemFileTransmit::Status status);
|
||||||
|
void receiveStatus(YmodemFileReceive::Status status);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::Widget *ui;
|
||||||
|
QSerialPort *serialPort;
|
||||||
|
YmodemFileTransmit *ymodemFileTransmit;
|
||||||
|
YmodemFileReceive *ymodemFileReceive;
|
||||||
|
|
||||||
|
bool transmitButtonStatus;
|
||||||
|
bool receiveButtonStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _HT_WIDGET_H
|
@ -0,0 +1,295 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Widget</class>
|
||||||
|
<widget class="QWidget" name="Widget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>444</width>
|
||||||
|
<height>255</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>444</width>
|
||||||
|
<height>255</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>444</width>
|
||||||
|
<height>255</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>SerialPortYmodem</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>串口配置</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>端口:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comPort">
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>波特率:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comBaudRate">
|
||||||
|
<property name="currentText">
|
||||||
|
<string>115200</string>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>921600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>460800</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>230400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>115200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>57600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>38400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>19200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>9600</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>4800</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>2400</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>1200</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="comButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>打开</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>文件发送</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>文件路径:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="transmitPath">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="transmitBrowse">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>浏览...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="transmitButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>发送</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>传输进度:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="transmitProgress">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
|
<string>文件接收</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>文件路径:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="receivePath">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="receiveBrowse">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>浏览...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="receiveButton">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>接收</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>传输进度:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="receiveProgress">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
|||||||
|
# temp configure
|
||||||
|
# is enable, true=enable false=disenable
|
||||||
|
Enable = true
|
||||||
|
# Mhz 采样频率
|
||||||
|
SmpProd = 10
|
||||||
|
# 采样间隔时间(h)
|
||||||
|
SmpInt = 2
|
||||||
|
# 采样起始时间(hm)
|
||||||
|
StartTime = 0800
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,67 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTBusiDatabase.h
|
||||||
|
** Description : busi app database api
|
||||||
|
** Create date : 2019.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2019 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2019.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_BUSI_DATABASE_H
|
||||||
|
#define __HT_BUSI_DATABASE_H
|
||||||
|
#pragma warning(disable: 4819)
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#pragma pack (push ,1)
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack (pop)
|
||||||
|
|
||||||
|
void vLoadCommunicationConf();
|
||||||
|
|
||||||
|
// 添加Ied不能连接的告警消息
|
||||||
|
void vSetIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime);
|
||||||
|
// 删除Ied服务不能连接的告警消息
|
||||||
|
void vDelIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime);
|
||||||
|
|
||||||
|
// 加载传感器基本信息
|
||||||
|
void vLoadBaseDeviceInfo();
|
||||||
|
|
||||||
|
// 加载通信参数配置
|
||||||
|
void vLoadCommunicationConf();
|
||||||
|
|
||||||
|
// 加载控制参数
|
||||||
|
void vLoadDeviceCtrlParam();
|
||||||
|
|
||||||
|
// 加载ICD配置节点与传感器绑定关系
|
||||||
|
void vLoadICDParameterBind();
|
||||||
|
|
||||||
|
// 加载阈值配置参数
|
||||||
|
void vLoadCenterDeviceThreshold();
|
||||||
|
void vLoadNoiseDeviceThreshold();
|
||||||
|
void vLoadAmpliDeviceThreshold();
|
||||||
|
|
||||||
|
// 显示阈值配置信息
|
||||||
|
void vPrtDeviceThresholdConf();
|
||||||
|
// 显示传感器控制参数
|
||||||
|
void vPrtDeviceCtrlParam();
|
||||||
|
// 显示传感器控制参数
|
||||||
|
void vPrtICDParameterBind();
|
||||||
|
|
||||||
|
// 插入数据
|
||||||
|
void vSetRealDevicesMoniMesg(ST_DB_BODY *pData);
|
||||||
|
// 添加传感器上传的告警消息
|
||||||
|
void vSetRealDevicesWarnMesg(ST_DB_WARN &stWarn);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* end __HT_BUSI_DATABASE_H */
|
||||||
|
|
@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTDatabase.h
|
||||||
|
** Description : define database api
|
||||||
|
** Create date : 2018.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2018.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_DATABASE_H
|
||||||
|
#define __HT_DATABASE_H
|
||||||
|
|
||||||
|
#include "HTPublic.h"
|
||||||
|
#include "mysql.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
//#pragma comment(lib,"ociliba.lib")
|
||||||
|
#pragma comment(lib,"libmysql.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef std::list<MYSQL *> CONNECTION_HANDLE_LIST;
|
||||||
|
typedef std::list<MYSQL *>::iterator ITER_CONNECTION_HANDLE_LIST;
|
||||||
|
|
||||||
|
#define CONNECTION_NUM 10 //同时打开的连接数
|
||||||
|
|
||||||
|
class CDBMySQL
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDBMySQL();
|
||||||
|
CDBMySQL(const char *host, const char *user, const char *password, const char *db, unsigned int port=3306);
|
||||||
|
virtual ~CDBMySQL();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool dbConnectPool(); //连接数据库
|
||||||
|
void dbFreeConnectPool() ; //释放链接资源
|
||||||
|
|
||||||
|
bool dbAutoCommit(MYSQL *pMysql, bool bStart); // 开始事务处理
|
||||||
|
bool dbCommit(MYSQL *pMysql);
|
||||||
|
bool InsertRecordBitch(const char pszSql[][256], int count);
|
||||||
|
bool AddInsertRecord(MYSQL *pHandle, const char *szSql);
|
||||||
|
|
||||||
|
MYSQL_RES* SelectRecord(const char *szSql); //选择记录,返回结果集
|
||||||
|
bool SelectDB(const char *szDB); //选择数据库
|
||||||
|
bool UpdateRecord(const char *szSql); //更新记录
|
||||||
|
bool InsertRecord(const char *szSql); //插入记录
|
||||||
|
bool DelRecord(const char *szSql); //删除记录
|
||||||
|
|
||||||
|
bool IsEnd(MYSQL_RES *myquery); //是否最后
|
||||||
|
void SeekData(MYSQL_RES *myquery, int offset); //查找指定数据
|
||||||
|
void FreeRecord(MYSQL_RES *myquery); //释放结果集
|
||||||
|
unsigned int GetFieldNum(MYSQL_RES *myquery); //得到字段数
|
||||||
|
MYSQL_ROW GetRecord(MYSQL_RES *myquery); //得到结果(一个记录)
|
||||||
|
my_ulonglong GetRowNum(MYSQL_RES *myquery); //得到记录数
|
||||||
|
char* getLastError(MYSQL* pMySql); //输出错误信息
|
||||||
|
|
||||||
|
char* GetState(); //服务器状态
|
||||||
|
char* GetServerInfo(); //服务器信息
|
||||||
|
int GetProtocolInfo(); //协议信息
|
||||||
|
char* GetHostInfo(); //主机信息
|
||||||
|
char* GetClientInfo(); //客户机信息
|
||||||
|
char* GetFieldName(MYSQL_RES *myquery, int FieldNum); //字段名
|
||||||
|
|
||||||
|
bool LockTable(const char *TableName, const char *Priority); //对特定表加锁
|
||||||
|
bool UnlockTable(); //解锁
|
||||||
|
bool SetCharset();
|
||||||
|
//int CreateDB(char *db); //创建数据库,返回错误信息
|
||||||
|
//int DropDB(char *db); //删除数据库,返回错误信息
|
||||||
|
|
||||||
|
MYSQL* GetIdleMySql(); //提取一个空闲句柄供使用
|
||||||
|
void SetIdleMysql(MYSQL* pMySql); //从使用队列中释放一个使用完毕的句柄,插入到空闲队列
|
||||||
|
static CDBMySQL* Instance();
|
||||||
|
|
||||||
|
public:
|
||||||
|
//MYSQL m_mysql; //数据库连接句柄
|
||||||
|
MYSQL_ROW m_row; //记录集(单行)
|
||||||
|
MYSQL_FIELD *m_field; //字段信息(结构体)
|
||||||
|
|
||||||
|
//创建两个队列
|
||||||
|
CONNECTION_HANDLE_LIST m_lsBusyList; //正在使用的连接句柄
|
||||||
|
CONNECTION_HANDLE_LIST m_lsIdleList; //未使用的连接句柄
|
||||||
|
|
||||||
|
mutex m_csList;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static CDBMySQL* p_dbHandle ;
|
||||||
|
|
||||||
|
char m_host[20]; //主机
|
||||||
|
char m_user[20]; //用户名
|
||||||
|
char m_password[20]; //密码
|
||||||
|
char m_db[20]; //数据库名
|
||||||
|
unsigned int m_port; //端口
|
||||||
|
unsigned int m_min; // 链接数
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __HT_DATABASE_H
|
@ -0,0 +1,44 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTError.h
|
||||||
|
** Description : define error code
|
||||||
|
** Create date : 2018.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2018.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_ERROR_H
|
||||||
|
#define __HT_ERROR_H
|
||||||
|
|
||||||
|
#define RET_OK 0
|
||||||
|
#define RET_FAIL -1
|
||||||
|
#define RET_IPPORT_INVALID -2 // IP地址或端口无效
|
||||||
|
#define RET_UDP_BIND_PORT -3 // UDP绑定端口错误
|
||||||
|
#define RET_LENGTH_INVALID -4 // 数据长度无效
|
||||||
|
#define RET_VALUE_INVALID -5 // 域值无效
|
||||||
|
#define RET_TYPE_INVALID -6 // 业务类型无效
|
||||||
|
#define RET_CALLOC_FAIL -7 // 申请内存失败
|
||||||
|
#define RET_SUB_ID_INVALID -8 // 域ID标识无效/不支持的ID标识码
|
||||||
|
#define RET_CALL_OCI_FAILED -9 // OCI调用失败
|
||||||
|
#define RET_NOT_FOUND_RECORD -10 // 无原请求业务流水
|
||||||
|
#define RET_ERROR_AUTHID -11 // 无效接入码
|
||||||
|
#define RET_UDP_STATUS_EXP -12 // UDP链接状态异常
|
||||||
|
#define RET_NOT_EXTERN_PACK -13 // 无扩展报文
|
||||||
|
#define RET_NOT_FOUND_ACCESSID -14 // 没有检索到接入码
|
||||||
|
#define RET_TERM_NOT_ONLINE -15 // 终端不在线
|
||||||
|
#define RET_SUB_COMMAND_INVALID -16 // 采集数据的子命令无效
|
||||||
|
#define RET_MAJOR_CONN_ERR -17 // TCP主链路状态错误
|
||||||
|
#define RET_NOT_FILE_EXIST -18 // 文件不存在
|
||||||
|
#define RET_NOT_DATA -19 // 采集行驶记录无数据
|
||||||
|
#define RET_SET_ERROR_PIC -20 // 插入拍照下发指令记录失败
|
||||||
|
#define RET_SERVER_ID_ERR -21 // 连接服务器名称无效
|
||||||
|
#define RET_JT809_VERSION -22 // 数据库配置了无效的JT809协议版本号
|
||||||
|
#define RET_JT808_VERSION -23 // 808内部报文协议类型无效
|
||||||
|
#define RET_JT809_CRC_ERROR -24 // CRC16校验错误
|
||||||
|
#define RET_LINK_CHECK_ERROR -25 // 链路校验码错误
|
||||||
|
#define RET_RECORD_ORG_ID_NULL -26 // 记录仪ID或企业ID为空
|
||||||
|
#endif // end __HT_ERROR_H
|
||||||
|
|
@ -0,0 +1,102 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTGolbal.h
|
||||||
|
** Description : global variable define
|
||||||
|
** Create date : 2018.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2018.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#pragma warning (disable:4786)
|
||||||
|
#ifndef __HT_GLOBAL_H
|
||||||
|
#define __HT_GLOBAL_H
|
||||||
|
|
||||||
|
#include "HTType.h"
|
||||||
|
#include "HTConst.h"
|
||||||
|
#include "HTMutex.h"
|
||||||
|
#include "HTPublic.h"
|
||||||
|
#include "HTLogger.h"
|
||||||
|
#include "HTConfig.h"
|
||||||
|
#include "HTDatabase.h"
|
||||||
|
#include "HTDataStruct.h"
|
||||||
|
#include "HTBusiDatabase.h"
|
||||||
|
#include "HTError.h"
|
||||||
|
#include "HTThread.h"
|
||||||
|
#include "HTInitUtils.h"
|
||||||
|
#include "HTTcpSocket.h"
|
||||||
|
#include "HTUnit.h"
|
||||||
|
#include "HTStrConvert.h"
|
||||||
|
#include "HTXmlMethod.h"
|
||||||
|
#include "HTVersion.h"
|
||||||
|
#include "HTModbus.h"
|
||||||
|
#include "HTIEC61850.h"
|
||||||
|
#include "HTIEC61850Thread.h"
|
||||||
|
//#include "HTMmslite.h"
|
||||||
|
#include "sntp/HTSntp.h"
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#if (defined(__UNIX__) || defined(UNIX) || defined(LINUX) || defined(linux))
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
//#define _CRT_SECURE_NO_WARNINGS 1
|
||||||
|
|
||||||
|
extern map<string,ST_IED_CONN_HANDLE> g_MapIedConn; // IED链接句柄
|
||||||
|
extern mutex g_MapIedConn_mutex;
|
||||||
|
|
||||||
|
extern int g_Running;
|
||||||
|
extern TConfig g_TConfig;
|
||||||
|
|
||||||
|
//extern map<string, ST_IMG_THRESHOLD> g_map_img_thres; // 图片识别阈值
|
||||||
|
//extern mutex g_map_img_thres_mutex;
|
||||||
|
|
||||||
|
extern list<ST_FILES_ATTRIB> g_list_comtrad_files; // 录播文件队列
|
||||||
|
extern mutex g_list_comtrad_files_mutex;
|
||||||
|
|
||||||
|
extern list<ST_DB_BODY> g_list_db_body; // 入库队列
|
||||||
|
extern mutex g_list_db_body_mutex;
|
||||||
|
|
||||||
|
extern list<ST_DB_WARN> g_list_db_warn; // 入库队列
|
||||||
|
extern mutex g_list_db_warn_mutex;
|
||||||
|
|
||||||
|
extern map<string, ST_DEVICE_INFO> g_map_device; // 装置设备缓存
|
||||||
|
extern mutex g_map_device_mutex;
|
||||||
|
|
||||||
|
extern map<string, ST_THRES_CONF> g_thres_conf; // 振动传感器阈值配置
|
||||||
|
extern mutex g_thres_conf_mutex;
|
||||||
|
|
||||||
|
extern map<string, ST_CONTROL_CONF> g_ctrl_conf; // 振动传感器控制参数配置
|
||||||
|
extern mutex g_ctrl_conf_mutex;
|
||||||
|
|
||||||
|
extern map<string, ST_HT_IEC61850> g_ied;
|
||||||
|
extern mutex g_ied_mutex;
|
||||||
|
|
||||||
|
extern map<string, ST_PARAM_BIND> g_map_parambind; // icd配置节点绑定关系,key=nodename
|
||||||
|
extern mutex g_map_parambind_mutex; // icd配置节点绑定关系,key=nodename
|
||||||
|
|
||||||
|
extern int g_seqno; // 交换的流水号
|
||||||
|
extern mutex g_seq_mutex; // 流水号
|
||||||
|
|
||||||
|
extern pthread_t thread_handle_cache_proc; // 内存数据同步线程句柄
|
||||||
|
extern pthread_t thread_handle_database_proc; // 入库线程句柄
|
||||||
|
extern pthread_t thread_handle_dbalarm_proc; // 入库线程句柄
|
||||||
|
extern pthread_t thread_handle_sntpd; // SNTP校时服务端线程句柄
|
||||||
|
extern pthread_t thread_handle_sntpc; // SNTP校时客户端线程句柄
|
||||||
|
extern pthread_t thread_handle_iec61850_manager_proc;
|
||||||
|
extern pthread_t thread_handle_modbus_service; //Modbus服务线程句柄
|
||||||
|
extern pthread_t thread_handle_modbus_recv; //Modbus接收线程句柄
|
||||||
|
extern pthread_t thread_handle_modbus_send; //Modbus发送线程句柄
|
||||||
|
|
||||||
|
extern pthread_t thread_handle_iec61850_service; //iec61850服务线程句柄
|
||||||
|
extern pthread_t thread_handle_iec61850_client; //iec61850接收线程句柄
|
||||||
|
extern pthread_t thread_handle_iec61850_server; //iec61850发送线程句柄
|
||||||
|
|
||||||
|
#endif // end __HT_GLOBAL_H
|
||||||
|
|
@ -0,0 +1,90 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTIEC61850.h
|
||||||
|
** Description : define iec 61850 network protocol api
|
||||||
|
** Create date : 2019.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2019 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2019.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_LIBIEC_61850_H
|
||||||
|
#define __HT_LIBIEC_61850_H
|
||||||
|
#include "HTGlobal.h"
|
||||||
|
#include "iec61850_client.h"
|
||||||
|
#include "iec61850_model.h"
|
||||||
|
#include "iec61850_dynamic_model.h"
|
||||||
|
#include "iec61850_config_file_parser.h"
|
||||||
|
|
||||||
|
#ifdef _SISCO_MMS_LITE
|
||||||
|
#pragma comment(lib,"acsi_ld.lib")
|
||||||
|
#pragma comment(lib,"mmslite_ld.lib")
|
||||||
|
#endif // _SISCO_MMS_LITE
|
||||||
|
|
||||||
|
#ifdef _LIB_IEC_61850
|
||||||
|
#pragma comment(lib,"iec61850.lib")
|
||||||
|
#endif // _LIB_IEC_61850
|
||||||
|
|
||||||
|
#pragma pack (push ,1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma pack (pop)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif /* defined (__cplusplus) */
|
||||||
|
|
||||||
|
// 获取错误消息
|
||||||
|
const char *getIedError(int error);
|
||||||
|
|
||||||
|
// 从远程IED获取模型配置
|
||||||
|
int vGetRemoteIEDModelConfig(IedConnection con);
|
||||||
|
|
||||||
|
// ICD文件解析
|
||||||
|
IedModel *LoadModelConfigFile(char *icd_file);
|
||||||
|
|
||||||
|
// 初始化61850链接环境参数
|
||||||
|
void vIedInitIedEvent();
|
||||||
|
|
||||||
|
// 释放链接及资源
|
||||||
|
void vIedFreeIedEvent(ST_IED_CONN_HANDLE &stIedHandle);
|
||||||
|
|
||||||
|
// 添加Ied不能连接的告警消息
|
||||||
|
void vSetIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime);
|
||||||
|
|
||||||
|
// 删除Ied服务不能连接的告警消息
|
||||||
|
void vDelIedDevicesWarnMesg(char *Ied_ip, int port, time_t altime);
|
||||||
|
|
||||||
|
// IED文件浏览
|
||||||
|
void showComtradeFile(IedConnection con, const char *pszDirName);
|
||||||
|
|
||||||
|
// 录播文件下载,解析入库线程
|
||||||
|
void vDownLoadComtradeFiles(/*void *arg*/ ST_IED_CONN_HANDLE &stIedCon);
|
||||||
|
|
||||||
|
// 上传文件--目前IED不支持上传文件
|
||||||
|
void setComtradeFile(IedConnection con, const char *filename);
|
||||||
|
|
||||||
|
// 解析下载的录播文件并入库
|
||||||
|
int unPackComtradeFile(char *pfile);
|
||||||
|
|
||||||
|
// 删除录播文件
|
||||||
|
void deleteComtradeFile(IedConnection con, const char *filename);
|
||||||
|
|
||||||
|
// 获取实时监测数据-遥测
|
||||||
|
void vGetFCMXData_YC(IedConnection conn);
|
||||||
|
|
||||||
|
// 获取实时监测数据-遥信
|
||||||
|
void vGetFCMXData_YX(IedConnection conn);
|
||||||
|
|
||||||
|
// 设置控制参数
|
||||||
|
void vSetFCSEData_CTRL(IedConnection conn);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* defined (__cplusplus) */
|
||||||
|
|
||||||
|
#endif /* __HT_LIBIEC_61850_H */
|
@ -0,0 +1,41 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTIEC61850Thread.h
|
||||||
|
** Description : define iec 61850 network protocol api
|
||||||
|
** Create date : 2019.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2019 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2019.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_LIBIEC_61850_THREAD_H
|
||||||
|
#define __HT_LIBIEC_61850_THREAD_H
|
||||||
|
#include "HTGlobal.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif /* defined (__cplusplus) */
|
||||||
|
|
||||||
|
void *thread_cache_proc(void *arg); // ͬ²½ÄÚ´æÊý¾ÝÏß³Ì
|
||||||
|
void *thread_iec61850_getcomtrade_files(void *arg);
|
||||||
|
void *thread_iec61850_client_proc(void *arg);
|
||||||
|
void *thread_iec61850_manager_proc(void *arg);
|
||||||
|
|
||||||
|
void* thread_database_proc(void * arg);
|
||||||
|
/***************************************************************************
|
||||||
|
** function name : thread_dbalarm_proc
|
||||||
|
** deacription : parser thread
|
||||||
|
** parameter : none
|
||||||
|
** return code : NULL
|
||||||
|
***************************************************************************/
|
||||||
|
void* thread_dbalarm_proc(void * arg);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif /* defined (__cplusplus) */
|
||||||
|
|
||||||
|
#endif /* __HT_LIBIEC_61850_THREAD_H */
|
@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** File name : HTIEEE1588V2.h
|
||||||
|
** Description : IEEE1588 v2 Ptp timer protoclo api
|
||||||
|
** Create date : 2019.09.01
|
||||||
|
** Auther by : Liuyx
|
||||||
|
** Version info : V1.0.01
|
||||||
|
** Copyright (C) 2002-2019 xi'an huatek, Inc Co., Ltd
|
||||||
|
** Update record:
|
||||||
|
** DATE AUTHER DESC
|
||||||
|
** -------------------------------------------------------------------------
|
||||||
|
** 2019.09.01 Liuyx first build
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef __HT_IEEE1588_V2_H
|
||||||
|
#define __HT_IEEE1588_V2_H
|
||||||
|
#include "HTGlobal.h"
|
||||||
|
/* ether_header */
|
||||||
|
//#include <netinet/if_ether.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
typedef struct ptp_header {
|
||||||
|
uint8_t ptp_ts : 4, /*transportSpecific*/
|
||||||
|
ptp_type : 4; /*messageType*/
|
||||||
|
uint8_t ptp_v; /*versionPTP (4 bits in size)*/
|
||||||
|
uint16_t ptp_ml; /*messageLength*/
|
||||||
|
uint8_t ptp_dn; /*domainNumber*/
|
||||||
|
uint8_t ptp_res; /*reserved*/
|
||||||
|
uint16_t ptp_flags; /*flags*/
|
||||||
|
uint64_t ptp_cf; /*correctionField*/
|
||||||
|
uint32_t ptp_res2; /*reserved*/
|
||||||
|
uint8_t ptp_src[10]; /*sourcePortIdentity,8 byte mac,2 byte portId*/
|
||||||
|
uint16_t ptp_sid; /*sequenceId*/
|
||||||
|
uint8_t ptp_ctlf; /*controlField*/
|
||||||
|
uint8_t ptp_lmi; /*logMessageInterval*/
|
||||||
|
} ST_PTP_HEADER; // __attribute__((__packed__));
|
||||||
|
|
||||||
|
typedef struct pkt_ptp {
|
||||||
|
//struct ether_header eh;
|
||||||
|
ST_PTP_HEADER ph;
|
||||||
|
uint64_t s : 48;
|
||||||
|
uint32_t ns;
|
||||||
|
} ST_PKT_PTPS; // __attribute__((__packed__));
|
||||||
|
|
||||||
|
enum ptp_msg_type
|
||||||
|
{
|
||||||
|
SYNC = 0x0,
|
||||||
|
DELAY_REQ = 0x1,
|
||||||
|
FOLLOW_UP = 0x8,
|
||||||
|
DELAY_RESP = 0x9,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* end __HT_IEEE1588_V2_H */
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue