From cd4a79ed87464a41504878e81225dfcfa21f4dcf Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 15 Nov 2023 21:01:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 4 +- Makefile | 625 +++++++++++++++++++++++++++++++++++++++++++++++++ commport.cpp | 343 +++++++++++++-------------- netport.cpp | 4 +- portconfig.ini | 166 ++++++------- widgets.cpp | 3 +- widgets.sln | 31 +++ 7 files changed, 917 insertions(+), 259 deletions(-) create mode 100644 Makefile create mode 100644 widgets.sln diff --git a/CMakeLists.txt b/CMakeLists.txt index f39ce03..a00e7d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -# CMakeList.txt : CMake project for iec103, include source and define +# CMakeList.txt : CMake project for iec103, include source and define # project specific logic here. # -cmake_minimum_required (VERSION 3.8) +cmake_minimum_required (VERSION 2.8) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED On) set(CMAKE_CXX_EXTENSIONS Off) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cbcf69c --- /dev/null +++ b/Makefile @@ -0,0 +1,625 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.8 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canonical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# Escaping for special characters. +EQUALS = = + +# The program to use to edit the cache. +CMAKE_EDIT_COMMAND = /usr/bin/ccmake + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /home/shxy/iec103 + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /home/shxy/iec103 + +#============================================================================= +# Targets provided globally by CMake. + +# Special rule for the target edit_cache +edit_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." + /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : edit_cache + +# Special rule for the target edit_cache +edit_cache/fast: edit_cache +.PHONY : edit_cache/fast + +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache +.PHONY : rebuild_cache/fast + +# The main all target +all: cmake_check_build_system + $(CMAKE_COMMAND) -E cmake_progress_start /home/shxy/iec103/CMakeFiles /home/shxy/iec103/CMakeFiles/progress.marks + $(MAKE) -f CMakeFiles/Makefile2 all + $(CMAKE_COMMAND) -E cmake_progress_start /home/shxy/iec103/CMakeFiles 0 +.PHONY : all + +# The main clean target +clean: + $(MAKE) -f CMakeFiles/Makefile2 clean +.PHONY : clean + +# The main clean target +clean/fast: clean +.PHONY : clean/fast + +# Prepare targets for installation. +preinstall: all + $(MAKE) -f CMakeFiles/Makefile2 preinstall +.PHONY : preinstall + +# Prepare targets for installation. +preinstall/fast: + $(MAKE) -f CMakeFiles/Makefile2 preinstall +.PHONY : preinstall/fast + +# clear depends +depend: + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 +.PHONY : depend + +#============================================================================= +# Target rules for targets named iec103 + +# Build rule for target. +iec103: cmake_check_build_system + $(MAKE) -f CMakeFiles/Makefile2 iec103 +.PHONY : iec103 + +# fast build rule for target. +iec103/fast: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/build +.PHONY : iec103/fast + +DSFileSystem.o: DSFileSystem.cpp.o +.PHONY : DSFileSystem.o + +# target to build an object file +DSFileSystem.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/DSFileSystem.cpp.o +.PHONY : DSFileSystem.cpp.o + +DSFileSystem.i: DSFileSystem.cpp.i +.PHONY : DSFileSystem.i + +# target to preprocess a source file +DSFileSystem.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/DSFileSystem.cpp.i +.PHONY : DSFileSystem.cpp.i + +DSFileSystem.s: DSFileSystem.cpp.s +.PHONY : DSFileSystem.s + +# target to generate assembly for a file +DSFileSystem.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/DSFileSystem.cpp.s +.PHONY : DSFileSystem.cpp.s + +Inifile.o: Inifile.cpp.o +.PHONY : Inifile.o + +# target to build an object file +Inifile.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Inifile.cpp.o +.PHONY : Inifile.cpp.o + +Inifile.i: Inifile.cpp.i +.PHONY : Inifile.i + +# target to preprocess a source file +Inifile.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Inifile.cpp.i +.PHONY : Inifile.cpp.i + +Inifile.s: Inifile.cpp.s +.PHONY : Inifile.s + +# target to generate assembly for a file +Inifile.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Inifile.cpp.s +.PHONY : Inifile.cpp.s + +Profile_Hash.o: Profile_Hash.cpp.o +.PHONY : Profile_Hash.o + +# target to build an object file +Profile_Hash.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Profile_Hash.cpp.o +.PHONY : Profile_Hash.cpp.o + +Profile_Hash.i: Profile_Hash.cpp.i +.PHONY : Profile_Hash.i + +# target to preprocess a source file +Profile_Hash.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Profile_Hash.cpp.i +.PHONY : Profile_Hash.cpp.i + +Profile_Hash.s: Profile_Hash.cpp.s +.PHONY : Profile_Hash.s + +# target to generate assembly for a file +Profile_Hash.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/Profile_Hash.cpp.s +.PHONY : Profile_Hash.cpp.s + +basefunc.o: basefunc.cpp.o +.PHONY : basefunc.o + +# target to build an object file +basefunc.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/basefunc.cpp.o +.PHONY : basefunc.cpp.o + +basefunc.i: basefunc.cpp.i +.PHONY : basefunc.i + +# target to preprocess a source file +basefunc.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/basefunc.cpp.i +.PHONY : basefunc.cpp.i + +basefunc.s: basefunc.cpp.s +.PHONY : basefunc.s + +# target to generate assembly for a file +basefunc.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/basefunc.cpp.s +.PHONY : basefunc.cpp.s + +buban103.o: buban103.cpp.o +.PHONY : buban103.o + +# target to build an object file +buban103.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban103.cpp.o +.PHONY : buban103.cpp.o + +buban103.i: buban103.cpp.i +.PHONY : buban103.i + +# target to preprocess a source file +buban103.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban103.cpp.i +.PHONY : buban103.cpp.i + +buban103.s: buban103.cpp.s +.PHONY : buban103.s + +# target to generate assembly for a file +buban103.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban103.cpp.s +.PHONY : buban103.cpp.s + +buban104.o: buban104.cpp.o +.PHONY : buban104.o + +# target to build an object file +buban104.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban104.cpp.o +.PHONY : buban104.cpp.o + +buban104.i: buban104.cpp.i +.PHONY : buban104.i + +# target to preprocess a source file +buban104.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban104.cpp.i +.PHONY : buban104.cpp.i + +buban104.s: buban104.cpp.s +.PHONY : buban104.s + +# target to generate assembly for a file +buban104.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/buban104.cpp.s +.PHONY : buban104.cpp.s + +chainlist.o: chainlist.cpp.o +.PHONY : chainlist.o + +# target to build an object file +chainlist.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/chainlist.cpp.o +.PHONY : chainlist.cpp.o + +chainlist.i: chainlist.cpp.i +.PHONY : chainlist.i + +# target to preprocess a source file +chainlist.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/chainlist.cpp.i +.PHONY : chainlist.cpp.i + +chainlist.s: chainlist.cpp.s +.PHONY : chainlist.s + +# target to generate assembly for a file +chainlist.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/chainlist.cpp.s +.PHONY : chainlist.cpp.s + +commport.o: commport.cpp.o +.PHONY : commport.o + +# target to build an object file +commport.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/commport.cpp.o +.PHONY : commport.cpp.o + +commport.i: commport.cpp.i +.PHONY : commport.i + +# target to preprocess a source file +commport.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/commport.cpp.i +.PHONY : commport.cpp.i + +commport.s: commport.cpp.s +.PHONY : commport.s + +# target to generate assembly for a file +commport.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/commport.cpp.s +.PHONY : commport.cpp.s + +conf_close.o: conf_close.cpp.o +.PHONY : conf_close.o + +# target to build an object file +conf_close.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_close.cpp.o +.PHONY : conf_close.cpp.o + +conf_close.i: conf_close.cpp.i +.PHONY : conf_close.i + +# target to preprocess a source file +conf_close.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_close.cpp.i +.PHONY : conf_close.cpp.i + +conf_close.s: conf_close.cpp.s +.PHONY : conf_close.s + +# target to generate assembly for a file +conf_close.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_close.cpp.s +.PHONY : conf_close.cpp.s + +conf_open.o: conf_open.cpp.o +.PHONY : conf_open.o + +# target to build an object file +conf_open.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_open.cpp.o +.PHONY : conf_open.cpp.o + +conf_open.i: conf_open.cpp.i +.PHONY : conf_open.i + +# target to preprocess a source file +conf_open.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_open.cpp.i +.PHONY : conf_open.cpp.i + +conf_open.s: conf_open.cpp.s +.PHONY : conf_open.s + +# target to generate assembly for a file +conf_open.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_open.cpp.s +.PHONY : conf_open.cpp.s + +conf_read_key.o: conf_read_key.cpp.o +.PHONY : conf_read_key.o + +# target to build an object file +conf_read_key.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_read_key.cpp.o +.PHONY : conf_read_key.cpp.o + +conf_read_key.i: conf_read_key.cpp.i +.PHONY : conf_read_key.i + +# target to preprocess a source file +conf_read_key.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_read_key.cpp.i +.PHONY : conf_read_key.cpp.i + +conf_read_key.s: conf_read_key.cpp.s +.PHONY : conf_read_key.s + +# target to generate assembly for a file +conf_read_key.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_read_key.cpp.s +.PHONY : conf_read_key.cpp.s + +conf_write_key.o: conf_write_key.cpp.o +.PHONY : conf_write_key.o + +# target to build an object file +conf_write_key.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_write_key.cpp.o +.PHONY : conf_write_key.cpp.o + +conf_write_key.i: conf_write_key.cpp.i +.PHONY : conf_write_key.i + +# target to preprocess a source file +conf_write_key.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_write_key.cpp.i +.PHONY : conf_write_key.cpp.i + +conf_write_key.s: conf_write_key.cpp.s +.PHONY : conf_write_key.s + +# target to generate assembly for a file +conf_write_key.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/conf_write_key.cpp.s +.PHONY : conf_write_key.cpp.s + +display.o: display.cpp.o +.PHONY : display.o + +# target to build an object file +display.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/display.cpp.o +.PHONY : display.cpp.o + +display.i: display.cpp.i +.PHONY : display.i + +# target to preprocess a source file +display.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/display.cpp.i +.PHONY : display.cpp.i + +display.s: display.cpp.s +.PHONY : display.s + +# target to generate assembly for a file +display.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/display.cpp.s +.PHONY : display.cpp.s + +list_entry.o: list_entry.cpp.o +.PHONY : list_entry.o + +# target to build an object file +list_entry.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/list_entry.cpp.o +.PHONY : list_entry.cpp.o + +list_entry.i: list_entry.cpp.i +.PHONY : list_entry.i + +# target to preprocess a source file +list_entry.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/list_entry.cpp.i +.PHONY : list_entry.cpp.i + +list_entry.s: list_entry.cpp.s +.PHONY : list_entry.s + +# target to generate assembly for a file +list_entry.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/list_entry.cpp.s +.PHONY : list_entry.cpp.s + +netport.o: netport.cpp.o +.PHONY : netport.o + +# target to build an object file +netport.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/netport.cpp.o +.PHONY : netport.cpp.o + +netport.i: netport.cpp.i +.PHONY : netport.i + +# target to preprocess a source file +netport.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/netport.cpp.i +.PHONY : netport.cpp.i + +netport.s: netport.cpp.s +.PHONY : netport.s + +# target to generate assembly for a file +netport.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/netport.cpp.s +.PHONY : netport.cpp.s + +os_heap.o: os_heap.cpp.o +.PHONY : os_heap.o + +# target to build an object file +os_heap.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/os_heap.cpp.o +.PHONY : os_heap.cpp.o + +os_heap.i: os_heap.cpp.i +.PHONY : os_heap.i + +# target to preprocess a source file +os_heap.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/os_heap.cpp.i +.PHONY : os_heap.cpp.i + +os_heap.s: os_heap.cpp.s +.PHONY : os_heap.s + +# target to generate assembly for a file +os_heap.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/os_heap.cpp.s +.PHONY : os_heap.cpp.s + +scadaprotect.o: scadaprotect.cpp.o +.PHONY : scadaprotect.o + +# target to build an object file +scadaprotect.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/scadaprotect.cpp.o +.PHONY : scadaprotect.cpp.o + +scadaprotect.i: scadaprotect.cpp.i +.PHONY : scadaprotect.i + +# target to preprocess a source file +scadaprotect.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/scadaprotect.cpp.i +.PHONY : scadaprotect.cpp.i + +scadaprotect.s: scadaprotect.cpp.s +.PHONY : scadaprotect.s + +# target to generate assembly for a file +scadaprotect.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/scadaprotect.cpp.s +.PHONY : scadaprotect.cpp.s + +widgets.o: widgets.cpp.o +.PHONY : widgets.o + +# target to build an object file +widgets.cpp.o: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/widgets.cpp.o +.PHONY : widgets.cpp.o + +widgets.i: widgets.cpp.i +.PHONY : widgets.i + +# target to preprocess a source file +widgets.cpp.i: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/widgets.cpp.i +.PHONY : widgets.cpp.i + +widgets.s: widgets.cpp.s +.PHONY : widgets.s + +# target to generate assembly for a file +widgets.cpp.s: + $(MAKE) -f CMakeFiles/iec103.dir/build.make CMakeFiles/iec103.dir/widgets.cpp.s +.PHONY : widgets.cpp.s + +# Help Target +help: + @echo "The following are some of the valid targets for this Makefile:" + @echo "... all (the default if no target is provided)" + @echo "... clean" + @echo "... depend" + @echo "... edit_cache" + @echo "... iec103" + @echo "... rebuild_cache" + @echo "... DSFileSystem.o" + @echo "... DSFileSystem.i" + @echo "... DSFileSystem.s" + @echo "... Inifile.o" + @echo "... Inifile.i" + @echo "... Inifile.s" + @echo "... Profile_Hash.o" + @echo "... Profile_Hash.i" + @echo "... Profile_Hash.s" + @echo "... basefunc.o" + @echo "... basefunc.i" + @echo "... basefunc.s" + @echo "... buban103.o" + @echo "... buban103.i" + @echo "... buban103.s" + @echo "... buban104.o" + @echo "... buban104.i" + @echo "... buban104.s" + @echo "... chainlist.o" + @echo "... chainlist.i" + @echo "... chainlist.s" + @echo "... commport.o" + @echo "... commport.i" + @echo "... commport.s" + @echo "... conf_close.o" + @echo "... conf_close.i" + @echo "... conf_close.s" + @echo "... conf_open.o" + @echo "... conf_open.i" + @echo "... conf_open.s" + @echo "... conf_read_key.o" + @echo "... conf_read_key.i" + @echo "... conf_read_key.s" + @echo "... conf_write_key.o" + @echo "... conf_write_key.i" + @echo "... conf_write_key.s" + @echo "... display.o" + @echo "... display.i" + @echo "... display.s" + @echo "... list_entry.o" + @echo "... list_entry.i" + @echo "... list_entry.s" + @echo "... netport.o" + @echo "... netport.i" + @echo "... netport.s" + @echo "... os_heap.o" + @echo "... os_heap.i" + @echo "... os_heap.s" + @echo "... scadaprotect.o" + @echo "... scadaprotect.i" + @echo "... scadaprotect.s" + @echo "... widgets.o" + @echo "... widgets.i" + @echo "... widgets.s" +.PHONY : help + + + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/commport.cpp b/commport.cpp index 41fa4c0..00dfae7 100644 --- a/commport.cpp +++ b/commport.cpp @@ -93,7 +93,7 @@ u_long GetPrivateProString(const char *section, const char *entry, const char *d result, len); } - else //ʹϰ취 + else //其它情况使用老办法读配置 { #ifdef _WIN32 GetPrivateProfileString((LPWSTR)section, (LPWSTR)entry, (LPWSTR)defaultstr, (LPWSTR)result, len, (LPWSTR)inifile); @@ -184,7 +184,7 @@ u_long GetPrivateProString2(const char *section, const char *entry, const char * rlen = (len < MAX_STRING_LEN) ? len : MAX_STRING_LEN; rlen--; - // ȱʡֵijȴڷص󳤶 + // 如果缺省值的长度大于返回的最大长度 if(!defaultstr) { retstr[0] = 0; @@ -207,7 +207,7 @@ u_long GetPrivateProString2(const char *section, const char *entry, const char * } } - // ȽֵֵΪȱʡֵҽڴ˸ֵȱʡֵ + // 首先将返回值赋值为缺省值,有且仅有在此赋值缺省值 strcpy(result, retstr); if(NULL == hFile) @@ -217,7 +217,7 @@ u_long GetPrivateProString2(const char *section, const char *entry, const char * sprintf(istring, "[%s]", section); - // ǰļݶȡ + // 清除当前文件数据读取计数 DSfseek(hFile, 0, SEEK_CLR_RCNT); SectionOk = DSHaveSection(istring, hFile); if(DS_SECTION_SEARCH == SectionOk) @@ -282,7 +282,7 @@ u_long GetPrivateProString2(const char *section, const char *entry, const char * if(DSfgets(fstring, sizeof(fstring)-1, hFile) == NULL) { - // һöΣ[]ı߽ + // 最后一个配置段,不存在[]的边界 if(DSfeob(hFile) == 0) { break; @@ -400,14 +400,14 @@ u_long GetPrivateProString2(const char *section, const char *entry, const char * } } - // ҵʵƥֱ˳ + // 找到合适的匹配项,直接退出 retstr[rlen] = 0; strcpy(result, retstr); goto ExitFlag2; } } - // ûҵʵĿʹȱʡֵ + // 没有找到合适的项目,使用缺省值 ExitFlag2: #if 0 @@ -538,16 +538,16 @@ void GetCommMode(int port, u_char *str) switch(*ptr) { case 'o': - case 'O': // У + case 'O': // 奇校验 SioParam[port].m_psSerial->CommMode &= ~PARITYMASK; SioParam[port].m_psSerial->CommMode |= PARITYODD; break; case 'e': - case 'E': // У + case 'E': // 奇校验 SioParam[port].m_psSerial->CommMode &= ~PARITYMASK; SioParam[port].m_psSerial->CommMode |= PARITYEVE; break; - default: // У + default: // 无校验 SioParam[port].m_psSerial->CommMode &= ~PARITYMASK; SioParam[port].m_psSerial->CommMode |= PARITYNONE; break; @@ -665,17 +665,17 @@ void ReadPortConfigInfo(u_short netport) #endif memset((char*)SioParam, 0, sizeof(SIO_PARAM_DEF)*MaxPortNum); - // ˿Ϣ + // 读端口信息 for (i = 0; i < MaxPortNum; i++) { // wen test debug #ifdef _OS_WINDOWS_DEBUG_ - //sprintf(szbuf, "ʼ˿%d... ...\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%d... ...\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d... ...\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d... ...\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); #elif _DEBUG - printf("ʼ˿%d... ...\n", i+1); + printf("初始化端口%d... ...\n", i+1); #endif SioParam[i].m_psBaoHu = (SIO_PARAM_BAOHU_DEF *)malloc(sizeof(SIO_PARAM_BAOHU_DEF)); @@ -695,7 +695,7 @@ void ReadPortConfigInfo(u_short netport) StringToUpper(szbuf); SioParam[i].ByPassFlag = CmpString((u_char*)szbuf, (u_char*)"bypass"); - // ж˿ + // 串行端口 if (i < MaxSerialPortNum) { SioParam[i].m_psSerial->Baud = DEFAULT_BAUD; @@ -743,9 +743,9 @@ void ReadPortConfigInfo(u_short netport) SioParam[i].m_psSerial->XonChar2 = SioParam[i].m_psSerial->XonChar1; SioParam[i].m_psSerial->XoffChar2 = SioParam[i].m_psSerial->XoffChar1; - // ǶʽϵͳУдݴǷḶ̌ݴʱ - // õʣֻڴͨѶдڣݴ̲д - // ͨѶָϢҪڴ¸ֵһΡ + // 在嵌入式系统中,读、写、数据处理是分离的进程,但是数据处理时会 + // 用到波特率,而波特率只有在串口通讯中存在,数据处理进程不含有串 + // 口通讯指针信息,所以需要在此重新赋值一次。 SioParam[i].m_psBaoHu->Baud = SioParam[i].m_psSerial->Baud; } else @@ -795,7 +795,7 @@ void ReadPortConfigInfo(u_short netport) SioParam[i].NetType = TCP_C_COMM; } - // ˿ڲ + // 读端口测点数量 GetPrivateProString(entry, "AiNum", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->AiNum = atoi(szbuf); GetPrivateProString(entry, "DiNum", "0", szbuf, 120, szPortConfig); @@ -803,7 +803,7 @@ void ReadPortConfigInfo(u_short netport) GetPrivateProString(entry, "PiNum", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->PiNum = atoi(szbuf); - // Poll Command ʱ䳣 + // 读 Poll Command 时间常数 GetPrivateProString(entry, "Retry", "", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->Retry = (u_long)atoi(szbuf); GetPrivateProString(entry, "RetryTime", "3", szbuf, 120, szPortConfig); @@ -811,7 +811,7 @@ void ReadPortConfigInfo(u_short netport) GetPrivateProString(entry, "WaitTime", "", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->WaitTime = (u_long)((atof(szbuf) * 1000) / TIMER_CNT); - // wen 2004.10.26 ݵڴ(ȷɽչԼڴ) + // wen 2004.10.26 增加数据点的内存分配(先分配成接收规约内存区) //PortMemoryMalloc(i, RECV_PROTOCOL); GetPrivateProString(entry, "PortType", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->PortType = (u_char)atoi(szbuf); @@ -823,8 +823,8 @@ void ReadPortConfigInfo(u_short netport) else SioParam[i].m_psBaoHu->CheckTime = 0; - // wen 2005.03.01 ңңת - //"ProvYkYtTimeOut"="תңسʱʱ" + // wen 2005.03.01 增加遥控遥调转发处理 + //"ProvYkYtTimeOut"="转发遥控超时时间" #ifdef _WIN32 GetPrivateProfileString((LPWSTR)entry, (LPWSTR)"ProvYkYtTimeOut", (LPWSTR)"10", (LPWSTR)szbuf, 120, (LPWSTR)szPortConfig); #else @@ -834,14 +834,14 @@ void ReadPortConfigInfo(u_short netport) #ifdef _OS_WINDOWS_DEBUG_ GetLocalTime(&sm); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ڴ%dʼ\n", sm.wDay, sm.wHour, + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 内存分配%d开始\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); #endif - // ݿڴ + // 数据库点内存分配 PortMemoryMalloc(i, SioParam[i].m_psBaoHu->PortType, SioParam[i].m_psBaoHu); - // Լ + // 读规约配置 if (FunCallPtr[SioParam[i].ProtocolIdx].ReadConfig) { FunCallPtr[SioParam[i].ProtocolIdx].ReadConfig(i); @@ -850,13 +850,13 @@ void ReadPortConfigInfo(u_short netport) #ifdef _OS_WINDOWS_DEBUG_ GetLocalTime(&sm); // wen test debug - //sprintf(szbuf, "ʼ˿%dɹ\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%dɹ\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d成功\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d成功\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); OutputDebugString((LPCWSTR)"\n"); #elif _OS_WINDOWS_DEBUG_ - printf("ʼ˿%dɹ\n", i+1); + printf("初始化端口%d成功\n", i+1); #endif } } @@ -893,17 +893,17 @@ void ReadPortConfigInfoEx(u_short netport) #endif memset((char*)SioParam, 0, sizeof(SIO_PARAM_DEF)*MaxPortNum); - // ˿Ϣ + // 读端口信息 for (i = 0; i < MaxPortNum; i++) { // wen test debug #ifdef _OS_WINDOWS_DEBUG_ - //sprintf(szbuf, "ʼ˿%d... ...\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%d... ...\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d... ...\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d... ...\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); #elif _OS_WINDOWS_DEBUG_ - printf("ʼ˿%d... ...\n", i+1); + printf("初始化端口%d... ...\n", i+1); #endif SioParam[i].m_psBaoHu = (SIO_PARAM_BAOHU_DEF *)malloc(sizeof(SIO_PARAM_BAOHU_DEF)); @@ -923,7 +923,7 @@ void ReadPortConfigInfoEx(u_short netport) StringToUpper(szbuf); SioParam[i].ByPassFlag = CmpString((u_char*)szbuf, (u_char*)"bypass"); - // ж˿ + // 串行端口 if (i < MaxSerialPortNum) { SioParam[i].m_psSerial->Baud = DEFAULT_BAUD; @@ -971,9 +971,9 @@ void ReadPortConfigInfoEx(u_short netport) SioParam[i].m_psSerial->XonChar2 = SioParam[i].m_psSerial->XonChar1; SioParam[i].m_psSerial->XoffChar2 = SioParam[i].m_psSerial->XoffChar1; - // ǶʽϵͳУдݴǷḶ̌ݴʱ - // õʣֻڴͨѶдڣݴ̲д - // ͨѶָϢҪڴ¸ֵһΡ + // 在嵌入式系统中,读、写、数据处理是分离的进程,但是数据处理时会 + // 用到波特率,而波特率只有在串口通讯中存在,数据处理进程不含有串 + // 口通讯指针信息,所以需要在此重新赋值一次。 SioParam[i].m_psBaoHu->Baud = SioParam[i].m_psSerial->Baud; } else @@ -1034,7 +1034,7 @@ void ReadPortConfigInfoEx(u_short netport) mallocdbflag: - // ˿ڲ + // 读端口测点数量 GetPrivateProString(entry, "AiNum", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->AiNum = atoi(szbuf); GetPrivateProString(entry, "DiNum", "0", szbuf, 120, szPortConfig); @@ -1042,7 +1042,7 @@ mallocdbflag: GetPrivateProString(entry, "PiNum", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->PiNum = atoi(szbuf); - // Poll Command ʱ䳣 + // 读 Poll Command 时间常数 GetPrivateProString(entry, "Retry", "", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->Retry = (u_long)atoi(szbuf); GetPrivateProString(entry, "RetryTime", "3", szbuf, 120, szPortConfig); @@ -1050,7 +1050,7 @@ mallocdbflag: GetPrivateProString(entry, "WaitTime", "", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->WaitTime = (u_long)((atof(szbuf) * 1000) / TIMER_CNT); - // wen 2004.10.26 ݵڴ(ȷɽչԼڴ) + // wen 2004.10.26 增加数据点的内存分配(先分配成接收规约内存区) //PortMemoryMalloc(i, RECV_PROTOCOL); GetPrivateProString(entry, "PortType", "0", szbuf, 120, szPortConfig); SioParam[i].m_psBaoHu->PortType = (u_char)atoi(szbuf); @@ -1062,8 +1062,8 @@ mallocdbflag: else SioParam[i].m_psBaoHu->CheckTime = 0; - // wen 2005.03.01 ңңת - //"ProvYkYtTimeOut"="תңسʱʱ" + // wen 2005.03.01 增加遥控遥调转发处理 + //"ProvYkYtTimeOut"="转发遥控超时时间" #ifdef _WIN32 GetPrivateProfileString((LPWSTR)entry, (LPWSTR)"ProvYkYtTimeOut", (LPWSTR)"10", (LPWSTR)szbuf, 120, (LPWSTR)szPortConfig); #else @@ -1073,14 +1073,14 @@ mallocdbflag: #ifdef _OS_WINDOWS_DEBUG_ GetLocalTime(&sm); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ڴ%dʼ\n", sm.wDay, sm.wHour, + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 内存分配%d开始\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); #endif - // ݿڴ + // 数据库点内存分配 PortMemoryMallocEx(i, SioParam[i].m_psBaoHu->PortType, SioParam[i].m_psBaoHu); - // Լ + // 读规约配置 if (FunCallPtr[SioParam[i].ProtocolIdx].ReadConfig) { FunCallPtr[SioParam[i].ProtocolIdx].ReadConfig(i); @@ -1089,13 +1089,13 @@ mallocdbflag: #ifdef _OS_WINDOWS_DEBUG_ GetLocalTime(&sm); // wen test debug - //sprintf(szbuf, "ʼ˿%dɹ\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%dɹ\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d成功\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d成功\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); OutputDebugString((LPCWSTR)"\n"); #elif _OS_WINDOWS_DEBUG_ - printf("ʼ˿%dɹ\n", i+1); + printf("初始化端口%d成功\n", i+1); #endif } @@ -1103,25 +1103,25 @@ mallocdbflag: for(i = 0; i < MaxPortNum; i++) { #ifdef _OS_WINDOWS_DEBUG_ - //sprintf(szbuf, "ʼ˿%d... ...\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%dݿ... ...\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d... ...\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d数据库... ...\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); #elif _OS_WINDOWS_DEBUG_ - printf("ʼ˿%dݿ... ...\n", i+1); + printf("初始化端口%d数据库... ...\n", i+1); #endif PortDataPntInit(i, SioParam[i].m_psBaoHu->PortType, SioParam[i].m_psBaoHu); #ifdef _OS_WINDOWS_DEBUG_ GetLocalTime(&sm); // wen test debug - //sprintf(szbuf, "ʼ˿%dɹ\n", i+1); - sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d ʼ˿%dݿɹ\n", sm.wDay, sm.wHour, + //sprintf(szbuf, "初始化端口%d成功\n", i+1); + sprintf(szbuf, "%02d_%02d:%02d:%02d.%03d 初始化端口%d数据库成功\n", sm.wDay, sm.wHour, sm.wMinute, sm.wSecond, sm.wMilliseconds, i+1); OutputDebugString((LPCWSTR)szbuf); OutputDebugString((LPCWSTR)"\n"); #elif _OS_WINDOWS_DEBUG_ - printf("ʼ˿%dݿɹ\n", i+1); + printf("初始化端口%d数据库成功\n", i+1); #endif } } @@ -1147,7 +1147,7 @@ void OpenAllPort(void) { int i; - // ֻЧʹõĶ˿ڣԼΪ"none"ΪЧ˿ + // 只打开有效使用的端口,规约为"none"的视为无效端口 for (i = 0; i < MaxPortNum; i++) { //commid = ValidPort[i]; @@ -1167,7 +1167,7 @@ void OpenAllPort(void) continue; } - // Ӷ˿10ӲϵĴʽ10û֮ + // 增加端口连续10次连接不上的处理方式,如果10次没有连接上则等两分钟之后重新连接 /*if ((SioParam[commid].iCreateFailCnt > 10) && (SioParam[commid].iCreateFailCnt < 120)) { SioParam[commid].iCreateFailCnt++; @@ -1184,7 +1184,7 @@ void CloseOnePort(int commid) { SioParam[commid].OpenFlag = 0; - // wen 2004.10.26 ɾڴռ + // wen 2004.10.26 删除分配的内存空间 //PortMemoryFree(commid); PortMemoryFree(commid, &SioParam[commid]); } @@ -1198,7 +1198,7 @@ void CloseAllPort(void) } //******************************************************************* -// ͨѶ * +// 通讯程序 * //******************************************************************* int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) @@ -1263,7 +1263,7 @@ int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) { aiptr[point].RawValue = aipntmsg->RawValue; aiptr[point].State = 1; -// ǰû +// 定义前置机功能 #ifdef FUNCTION_FEND WriteChangeData(port, point, aipntmsg, AI_PNT_TYPE); #endif @@ -1282,18 +1282,18 @@ int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) { aiprovptr = (PROV_AI_PNT*)SioParam[j].m_psBaoHu->AiPtr; aiprovptr[k].ChangeFlag = 1; - // wen 2004.11.19 ң仯ݵĴ + // wen 2004.11.19 增加遥测变化数据的处理 SioParam[j].m_psBaoHu->AiChange = TRUE; } } } - // wen 2004.11.19 ң仯ݵĴ + // wen 2004.11.19 增加遥测变化数据的处理 SioParam[port].m_psBaoHu->AiChange = TRUE; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.12.15 õֵʱԼ˿״̬ + // wen 2005.12.15 增加设置点数据值时,可以激活端口状态 SioParam[port].LineCommCnt = 0; SioParam[port].Status = TRUE; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1364,12 +1364,12 @@ int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) case PNT_SOE_TIME: memmove((char*)&diptr[point].SoeTime, (char*)&dipntmsg->SoeTime, sizeof(DAY_TIME)); - // wen 2004.11.16 soeݵת洢(Ƿsoe???) + // wen 2004.11.16 增加soe数据的转发存储(是否增加soe点的配置???) memset((void *)&SoeData, 0, sizeof(SOE_DEF)); memcpy((void *)&SoeData.SoeTime, (void*)&dipntmsg->SoeTime, sizeof(DAY_TIME)); SoeData.bStatus = dipntmsg->Status; - // һΪASDU1, չֽ + // 一般为ASDU1, 即扩展字节无意义 SoeData.u8Type = 1; for(i=0; iDiPtr; diprovptr[k].ChangeFlag = 1; - // wen 2004.11.19 ңű仯ݵĴ + // wen 2004.11.19 增加遥信变化数据的处理 SioParam[j].m_psBaoHu->DiChange = TRUE; } } } - // wen 2004.11.19 ңű仯ݵĴ + // wen 2004.11.19 增加遥信变化数据的处理 SioParam[port].m_psBaoHu->DiChange = TRUE; -// ǰû +// 定义前置机功能 #ifdef FUNCTION_FEND WriteChangeData(port, point, dipntmsg, DI_PNT_TYPE); #endif @@ -1467,7 +1467,7 @@ int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) diptr[point].State = 1; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.12.15 õֵʱԼ˿״̬ + // wen 2005.12.15 增加设置点数据值时,可以激活端口状态 SioParam[port].LineCommCnt = 0; SioParam[port].Status = TRUE; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1562,20 +1562,20 @@ int SetPntMsg(int port, int point, void *pntmsg, BYTE type, BYTE attr) piprovptr = (PROV_PI_PNT*)SioParam[j].m_psBaoHu->PiPtr; piprovptr[k].ChangeFlag = 1; - // wen 2004.11.19 ӵȱ仯ݵĴ + // wen 2004.11.19 增加电度变化数据的处理 // SioParam[j].m_psBaoHu->PiChange = TRUE; } } } -// ǰû +// 定义前置机功能 #ifdef FUNCTION_FEND WriteChangeData(port, point, pipntmsg, PI_PNT_TYPE); #endif } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.12.15 õֵʱԼ˿״̬ + // wen 2005.12.15 增加设置点数据值时,可以激活端口状态 SioParam[port].LineCommCnt = 0; SioParam[port].Status = TRUE; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1980,7 +1980,7 @@ int PutPollCmdToBuf(int port, int type, WORD wait, char *buf, int len) if (len == 0) return 0; - // wen 2004.10.25 ˿δ򿪣򷵻0 + // wen 2004.10.25 如果端口未打开,则返回0 //if(!SioParam[port].OpenFlag) if(!ShmGetPortFlag(port, FLAG_OPEN)) return 0; @@ -1991,7 +1991,7 @@ int PutPollCmdToBuf(int port, int type, WORD wait, char *buf, int len) szbuf[0] = HIBYTE(len+2); szbuf[1] = LOBYTE(len+2); - // ȴʱΪһִ洢 + // 将等待时间作为命令的一部分存储 szbuf[2] = HIBYTE(wait); szbuf[3] = LOBYTE(wait); memmove((char*)&szbuf[4], buf, len); @@ -2003,7 +2003,7 @@ int PutPollCmdToBuf(int port, int type, WORD wait, char *buf, int len) return false; } -// wen 2005.09.08 ָеָ +// wen 2005.09.08 清空指令缓冲区中的所有指令 void ClearAllCmdFromPollCmdBuf(int port) { int i; @@ -2038,7 +2038,7 @@ void ClearCmdFormPollCmdBuf(int port) len = BYTE1(szbuf[0]) + BYTE0(szbuf[1]); GetDataFormBuf(&SioParam[port].m_psBaoHu->PollCmd[idx], szbuf, len, true); - // wen 2005.09.20 ޸ָ·ʶ + // wen 2005.09.20 修改清除指令下发标识 ClearCmdAllFlag(port); } @@ -2064,7 +2064,7 @@ void ClearCmdFormPollCmdBufEx( int port, char *file, int line ) len = BYTE1(szbuf[0]) + BYTE0(szbuf[1]); GetDataFormBuf(&SioParam[port].m_psBaoHu->PollCmd[idx], (u_char *)szbuf, len, true); - // wen 2005.09.20 ޸ָ·ʶ + // wen 2005.09.20 修改清除指令下发标识 ClearCmdAllFlag(port); } @@ -2170,7 +2170,7 @@ void SendCmdFormPollCmdBuf(int port) SioParam[port].m_psBaoHu->ForceWaitCnt--; if (SioParam[port].m_psBaoHu->ForceWaitCnt == 0) { - ClearCmdFormPollCmdBuf(port); // ǰ + ClearCmdFormPollCmdBuf(port); // 清除当前命令 //ClearCmdAllFlag(port); } } @@ -2202,7 +2202,7 @@ void SendCmdFormPollCmdBuf(int port) if (SioParam[port].m_psBaoHu->SendCmdFlag && SioParam[port].m_psBaoHu->RevCmdFlag) { - ClearCmdFormPollCmdBuf(port); // ǰ + ClearCmdFormPollCmdBuf(port); // 清除当前命令 //ClearCmdAllFlag(port); } @@ -2250,8 +2250,8 @@ void SendCmdFormPollCmdBuf(int port) SioParam[port].m_psBaoHu->ForceWaitFlag = 1; else { - ClearCmdFormPollCmdBuf(port); // ǰ - //ClearCmdAllFlag(port); // ǰ + ClearCmdFormPollCmdBuf(port); // 清除当前命令 + //ClearCmdAllFlag(port); // 清除当前命令 } } #endif @@ -2270,7 +2270,7 @@ void TimerProc(void) continue; } - // wen 2004.10.25 ԱԼģƷʱ + // wen 2004.10.25 以便规约模块控制发送时序 if (FunCallPtr[SioParam[i].ProtocolIdx].Timer) FunCallPtr[SioParam[i].ProtocolIdx].Timer(i); else @@ -2309,7 +2309,7 @@ void SystemRtuTime(void) if (!FunCallPtr[SioParam[i].ProtocolIdx].SendSystemTime) continue; - // ¶ʱ + // 下对时 if(SioParam[i].m_psBaoHu->CheckTime == 2) FunCallPtr[SioParam[i].ProtocolIdx].SendSystemTime(i); } @@ -2329,7 +2329,7 @@ void PortRecvDataProcess(void) if (FLAG_OPEN == SioParam[i].OpenFlag && (SioParam[i].RecvBuf.MsgCnt > 0)) { - // ϸжϻ + // 严格判断缓冲区长度 if (SioParam[i].RecvBuf.MsgCnt > sizeof(SioParam[i].RecvBuf.MsgData)) { printf("WARN(%04d): RecvBuf is confusional(MsgCnt=%d, MaxLen=%d).\n", @@ -2348,35 +2348,35 @@ void PortRecvDataProcess(void) FunCallPtr[SioParam[i].ProtocolIdx].RecvData(i, SioParam[i].RecvBuf.MsgData, SioParam[i].RecvBuf.MsgCnt); - // ˿ڽյݱ־Ӧ yizhonghu 20071029 + // 端口接收到数据标志应该在这里清零 yizhonghu 20071029 //SioParam[i].PortNoDataCnt = 0; - // wen 2005.03.22 ¼˿ڶȡ + // wen 2005.03.22 记录端口读取数据 //RecordData(i, RECORD_RO_BUF,SioParam[i].RecvBuf.MsgData,SioParam[i].RecvBuf.MsgCnt); SioParam[i].RecvCharNum += SioParam[i].RecvBuf.MsgCnt; //+++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.10.14 Ӷ˿״̬ + // wen 2005.10.14 增加端口状态设置 //SioParam[i].Status = TRUE; //----------------------------------------------------- - // ڹԼΪbypassʱΪ + // 对于规约为bypass时,不标记为运行正常 if (SioParam[i].ProtocolIdx > 1) { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2006.04.24 ǽյݣΪ˿״̬Ϊ - // ޸ݿΪǶ˿վ⡣ + // wen 2006.04.24 如果仅仅是接收到数据,不认为端口状态为正常, + // 必须是修改了数据库点才认为是端口正常。子站除外。 //SioParam[i].Status = TRUE; //============================================================= //TimeEx(&SioParam[i].dLineCommTime); SioParam[i].Status = TRUE; /*if (SioParam[i].m_psBaoHu) { - // Ϊվ + // 如果为子站 //if(SioParam[i].m_psBaoHu->PortType) //{ //if(1 == i) - // printf("ö˿%d˿״̬ΪTRUE\n", i+1); + // printf("设置端口%d端口状态为TRUE\n", i+1); SioParam[i].Status = TRUE; //} } @@ -2408,7 +2408,7 @@ void BaohuLibMain(int netportnum) msec = 0; - // ˿Ϣ6˿ + // 读端口配置信息并设置6个网络端口 //ReadPortConfigInfo(netportnum); ReadPortConfigInfoEx(netportnum); @@ -2417,7 +2417,8 @@ void BaohuLibMain(int netportnum) //msec = (msec + TIMER_CNT) % 1000; - struct tm* ptm = localtime(NULL); + time_t stm=time(NULL); + struct tm* ptm = localtime(&stm); DayTime.Year = ptm->tm_year + 1900; DayTime.Month = ptm->tm_mon + 1; @@ -2427,17 +2428,17 @@ void BaohuLibMain(int netportnum) DayTime.Sec = ptm->tm_sec; DayTime.mSec = 0; Sleep(100); - // ˿д + // 网络端口写 //SetUdpRecv(); - // ж˿ڶʱ + // 所有端口定时器处理 TimerProc(); - // wen 2004.10.25 ´timerprocУԱԼģƷʱ + // wen 2004.10.25 以下代码放入timerproc中,以便规约模块控制发送时序 //for (i = 0; i < MaxPortNum; i++) //{ // SendCmdFormPollCmdBuf(i); //} - // ж˿ڽݴ + // 所有端口接收数据处理 PortRecvDataProcess(); PollAllPort(); @@ -2451,7 +2452,7 @@ void BaohuLibMain(int netportnum) if (tmp1 < 0) tmp1 += 3600; - // ÿ300RTUʱһ + // 每300秒RTU对时一次 if ((tmp1 > SYSTEM_TIME) && (tmp2 != systimecnt)) { systimecnt = tmp2; @@ -2466,10 +2467,10 @@ int GetMaxPort() } //******************************************************************** -//* 洢תsoeݺ * -//*int provport : ת˿ * -//* SOE_DEF *ptrSoe : 洢soe * -//*ֵint retval : soe * +//* 存储转发soe数据函数 * +//*参数:int provport : 转发端口 * +//* SOE_DEF *ptrSoe : 待存储的soe数据 * +//*返回值:int retval : soe数据数量 * //******************************************************************** int ProvWriteSoeData(int provport, SOE_DEF *ptrSoe) { @@ -2507,10 +2508,10 @@ int ProvWriteSoeData(int provport, SOE_DEF *ptrSoe) } //******************************************************************** -//* ʼݶ庯 * -//*int provport : ת˿ * -//* SOE_DEF *ptrSoe : ȡsoeݵĻ * -//*ֵint retval : ʣsoe * +//* 初始化组数据定义函数 * +//*参数:int provport : 转发端口 * +//* SOE_DEF *ptrSoe : 获取soe数据的缓冲区 * +//*返回值:int retval : 剩余soe数据数量 * //******************************************************************** int ProvAndDelGetSoeData(int provport, SOE_DEF *ptrSoe) { @@ -2537,8 +2538,8 @@ int ProvAndDelGetSoeData(int provport, SOE_DEF *ptrSoe) } //******************************************************************** -//* ת˿Ƿsoeݺ * -//*int provport : ת˿ * +//* 转发端口是否含有soe数据函数 * +//*参数:int provport : 转发端口 * //******************************************************************** int ProvHaveSoeData(int provport) { @@ -2549,16 +2550,16 @@ int ProvHaveSoeData(int provport) } //******************************************************************** -//* ݺ * -//* int commid : ˿ں * -//* char *buf : ݻ * -//* int len : ݳ * -//*ֵ * +//* 发送数据函数 * +//*参数: int commid : 端口号 * +//* char *buf : 发送数据缓存区 * +//* int len : 发送数据长度 * +//*返回值:无 * //******************************************************************** void SendDataToPort(int commid, char *buf, int len) { #ifdef FUNCTION_FEND - // ǰûΪûʱ˿·ݴʽ + // 前置机为备用机时,端口下发数据处理方式 if(!IsSendDatatoPort(commid)) { return; @@ -2569,39 +2570,39 @@ void SendDataToPort(int commid, char *buf, int len) AddNode(commid, (char *)buf, len); #else // FillAndSendCmd(0, commid, SDS_SIO_SEND_DATA, (u_char*)buf, len); - // wen 2004.12.21 ͼѾڷʱ˼ + // wen 2004.12.21 发送计数已经在发送时做了计算 SioParam[commid].SendCharNum += len; #endif } //******************************************************************** -//* ңңݺ * -//* int commid : ˿ں * -//* char *buf : ݻ * -//* int len : ݳ * -//*ֵ * -//*˵ scadaϵͳ(server)ңң * +//* 发送遥控遥调数据函数 * +//*参 数:int commid : 端口号 * +//* char *buf : 发送数据缓存区 * +//* int len : 发送数据长度 * +//*返回值:无 * +//*说 明:发送来自scada系统(server)的遥控遥调命令 * //******************************************************************** void SendYkYtCommand(int commid, char *buf, int len) { - // buf[0] --- ˿ں(=commid) + // buf[0] --- 端口号(=commid) // buf[1] // buf[2] // buf[3] - // buf[4] --- ص + // buf[4] --- 控点号 // buf[5] // buf[6] // buf[7] - // buf[8] --- (ң:1=ѡ,2=ִ,3=ȡ,7=ֱ; - // ң:4=ѡ,5=ִ,6=ȡ,8=ͣ) - // buf[9] --- ״̬(1=ֵϣ2=ϵ) - // (λΪ1ʱΪУ, 1=غ, 2=ط, 3=ʧ) + // buf[8] --- 操作类型(遥控:1=选择,2=执行,3=取消,7=直控; + // 遥调:4=选择,5=执行,6=取消,8=急停) + // buf[9] --- 控制状态(1=分到合,2=合到分) + // (最高位为1时,为返校命令, 1=控合, 2=控分, 3=失败) DAY_TIME stime; - // ж˿ + // 串行端口 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.10.10 ޸Ŀnetport· + // wen 2005.10.10 修改可以在netport下发 //if(commid < MaxSerialPortNum) if(commid < MaxPortNum) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -2616,13 +2617,13 @@ void SendYkYtCommand(int commid, char *buf, int len) { if((buf[9] & 0x80) == 0) { - // ңز + // 保存遥控参数及环境变量 GetLocalTimeEx(&stime); memcpy((void *)&SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_sDayTime, (void *)&stime, sizeof(DAY_TIME)); SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iYkYtStep = buf[8]; - // ýṹԱ͵(תң) + // 该结构成员是用来保存操作类型的(不仅仅针对转发遥控) SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iYkYtOperate = buf[9]; SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iCmdFrom = YKYT_CMD_FROM_SCADA; } @@ -2633,33 +2634,33 @@ void SendYkYtCommand(int commid, char *buf, int len) } //******************************************************************** -//* ңңݺ * -//* int commid : ˿ں * -//* PROV_YKYT_PARAM *pParam : ңң * -//*ֵBOOL retval : Ƿת˿ * -//*˵ ת˿ڵңң * +//* 发送遥控遥调数据函数 * +//*参 数:int commid : 端口号 * +//* PROV_YKYT_PARAM *pParam : 遥控遥调参数 * +//*返回值:BOOL retval : 是否转发端口数据 * +//*说 明:发送来自转发端口的遥控遥调命令 * //******************************************************************** BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) { DAY_TIME stime; char Val[20]; int iRealCommid; - // Val[0] --- ˿ں(=commid) + // Val[0] --- 端口号(=commid) // Val[1] // Val[2] // Val[3] - // Val[4] --- ص + // Val[4] --- 控点号 // Val[5] // Val[6] // Val[7] - // Val[8] --- (ң:1=ѡ,2=ִ,3=ȡ,7=ֱ; - // ң:4=ѡ,5=ִ,6=ȡ,8=ͣ) - // Val[9] --- ״̬(1=ֵϣ2=ϵ) - // (λΪ1ʱΪУ, 1=غ, 2=ط, 3=ʧ) + // Val[8] --- 操作类型(遥控:1=选择,2=执行,3=取消,7=直控; + // 遥调:4=选择,5=执行,6=取消,8=急停) + // Val[9] --- 控制状态(1=分到合,2=合到分) + // (最高位为1时,为返校命令, 1=控合, 2=控分, 3=失败) - // ж˿ + // 串行端口 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.10.10 ޸Ŀnetport· + // wen 2005.10.10 修改可以在netport下发 //if(commid >= MaxSerialPortNum) //{ // return FALSE; @@ -2672,7 +2673,7 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) memset(Val, 0, sizeof(Val)); - // ת + // 非转发数据 if(YKYT_SEND_DOWN == pParam->m_iYkYtUpDown) { iRealCommid = commid; @@ -2697,7 +2698,7 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) if(YKYT_CMD_FROM_SCADA == SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iCmdFrom) { - // wen 2005.10.08 תݣӶ͸scada + // wen 2005.10.08 非转发数据,从而上送给scada服务器 Val[0] = LOBYTE(pParam->m_iYkYtPnt); Val[1] = HIBYTE(pParam->m_iYkYtPnt); if(pParam->m_iYkYtOperate == 3) @@ -2717,12 +2718,12 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) { iRealCommid = SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iProvPortIdx; - // תվ + // 转发站号 Val[0] = (BYTE)iRealCommid; Val[1] = (BYTE)((iRealCommid & 0xFF00) >> 8); Val[2] = (BYTE)((iRealCommid & 0xFF0000) >> 16); Val[3] = (BYTE)((iRealCommid & 0xFF000000) >> 24); - // תص + // 转发控点号 Val[4] = (BYTE)SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iProvYkYtPointIdx; Val[5] = (BYTE)((SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iProvYkYtPointIdx & 0xFF00) >> 8); Val[6] = (BYTE)((SioParam[commid].m_psBaoHu->ProvYkYtMsg.m_iProvYkYtPointIdx & 0xFF0000) >> 16); @@ -2732,7 +2733,7 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) Val[9] = (BYTE)(pParam->m_iYkYtOperate); Val[9] |= 0x80; } - else// 쳣 + else// 异常数据 { return FALSE; } @@ -2744,7 +2745,7 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) { if(YKYT_SEND_UP != pParam->m_iYkYtUpDown) { - // ңز + // 保存遥控参数及环境变量 GetLocalTimeEx(&stime); memcpy((void *)&SioParam[iRealCommid].m_psBaoHu->ProvYkYtMsg.m_sDayTime, (void *)&stime, sizeof(DAY_TIME)); @@ -2761,11 +2762,11 @@ BOOL SendYkYtCommand2(int commid, YKYT_PARAM *pParam) } //******************************************************************** -//* תصת㺯 * -//* int commid : ת˿ں * -//* int ykytpnt: תңң * -//* SIO_PARAM_BAOHU_DEF *pBaohuParam :ת˿ڱ * -//*ֵint retval : Ӧʵת * +//* 查找转发控点的转发点函数 * +//*参数: int commid : 转发端口号 * +//* int ykytpnt: 转发的遥控遥调点 * +//* SIO_PARAM_BAOHU_DEF *pBaohuParam :转发端口保护参数 * +//*返回值:int retval : 对应的实际转发点号 * //******************************************************************** int FindProvPntFromYkYtPnt(int commid, int ykytpnt, SIO_PARAM_BAOHU_DEF *pBaohuParam) { @@ -3057,7 +3058,7 @@ void PortMemoryMalloc(int commid, int type, SIO_PARAM_BAOHU_DEF *pBaohuParam) GetPrivateProString(entry, section, "", szbuf, 120, szPortConfig); if (strlen(szbuf) == 0) { - // wen 2005.09.28 ȱʡΪ1 + // wen 2005.09.28 缺省设置为1 aipntmsg.Polar = 1; SetPntMsg(commid, i, (void*)&aipntmsg, AI_PNT_TYPE, PNT_POLAR); continue; @@ -3066,14 +3067,14 @@ void PortMemoryMalloc(int commid, int type, SIO_PARAM_BAOHU_DEF *pBaohuParam) aipntmsg.Polar = atoi(szbuf) ? 1 : 0; SetPntMsg(commid, i, (void*)&aipntmsg, AI_PNT_TYPE, PNT_POLAR); - // wen 2005.09.13 ˳ + // wen 2005.09.13 增加顺序增加配置 sprintf(section, "Ai%dInc", i+1); GetPrivateProString(entry, section, "", szbuf, 120, szPortConfig); if(strlen(szbuf) == 0) continue; increase = atoi(szbuf); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.12.01 ޸ӵĶȡ + // wen 2005.12.01 修改连续增加的读取 //if(increase > 0) //{ // for(k=i+1; k= 0) { diprovpnt.ControlNo++; @@ -3793,7 +3794,7 @@ BOOL PortDataPntInit(int commid, int type, SIO_PARAM_BAOHU_DEF *pBaohuParam) GetPrivateProString(entry, section, "", szbuf, 120, szPortConfig); if (strlen(szbuf) == 0) { - // wen 2005.09.28 ȱʡΪ1 + // wen 2005.09.28 缺省设置为1 aipntmsg.Polar = 1; SetPntMsg(commid, i, (void*)&aipntmsg, AI_PNT_TYPE, PNT_POLAR); continue; @@ -3802,14 +3803,14 @@ BOOL PortDataPntInit(int commid, int type, SIO_PARAM_BAOHU_DEF *pBaohuParam) aipntmsg.Polar = atoi(szbuf) ? 1 : 0; SetPntMsg(commid, i, (void*)&aipntmsg, AI_PNT_TYPE, PNT_POLAR); - // wen 2005.09.13 ˳ + // wen 2005.09.13 增加顺序增加配置 sprintf(section, "Ai%dInc", i+1); GetPrivateProString(entry, section, "", szbuf, 120, szPortConfig); if(strlen(szbuf) == 0) continue; increase = atoi(szbuf); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - // wen 2005.12.01 ޸ӵĶȡ + // wen 2005.12.01 修改连续增加的读取 //if(increase > 0) //{ // for(k=i+1; k= 0) { diprovpnt.ControlNo++; @@ -4145,7 +4146,7 @@ void PortMemoryFree(int commid, SIO_PARAM_DEF *pGenParam) if (pGenParam->ExtInfo) { - // wen 2005.04.13 Լʱͷڴ + // wen 2005.04.13 规约结束时释放内存 if (FunCallPtr[SioParam[commid].ProtocolIdx].ProtocolExit) { FunCallPtr[SioParam[commid].ProtocolIdx].ProtocolExit(commid); @@ -4382,7 +4383,7 @@ int SetDispFlag(int iFlag) return RealDataDispFlag; } -// ȡȫֱ +// 获取全局变量 SIO_PARAM_DEF *GetSioParamPtr() { return SioParam; diff --git a/netport.cpp b/netport.cpp index f285814..1c7e81c 100644 --- a/netport.cpp +++ b/netport.cpp @@ -669,8 +669,8 @@ void TcpAccept(int commid, int lisfds) // 多客户端向服务端连接时判断客户端来自的端口号 yizhonghu 20070704 for(i=MaxSerialPortNum; i