0822 Does not work

master
Oleg 7 months ago
commit a1981564a3

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?ccsproject version="1.0"?>
<projectOptions>
<deviceVariant value="TMS320C28XX.TMS320F28335"/>
<deviceFamily value="C2000"/>
<codegenToolVersion value="6.2.0"/>
<isElfFormat value="false"/>
<linkerCommandFile value="28335_RAM_lnk.cmd"/>
<rts value="libc.a"/>
<templateProperties value="id=com.ti.common.project.core.emptyProjectTemplate,"/>
<isTargetManual value="false"/>
<origin value="C:/CCSWorkSpaces/temp/DVRFramework"/>
<connection value="common/targetdb/connections/TIXDS100v3_Dot7_Connection.xml"/>
</projectOptions>

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule configRelations="2" moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.ti.ccstudio.buildDefinitions.C2000.Debug.2040603795">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.C2000.Debug.2040603795" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.LinkErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.AsmErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="out" artifactName="${SRC_ROOT}/sys/build/Debug/framework" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.C2000.Debug.2040603795" name="Debug" parent="com.ti.ccstudio.buildDefinitions.C2000.Debug">
<folderInfo id="com.ti.ccstudio.buildDefinitions.C2000.Debug.2040603795." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.DebugToolchain.830787211" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.linkerDebug.1778512584">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.1197154302" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=TMS320C28XX.TMS320F28335"/>
<listOptionValue builtIn="false" value="DEVICE_CORE_ID=C2800"/>
<listOptionValue builtIn="false" value="DEVICE_ENDIANNESS=little"/>
<listOptionValue builtIn="false" value="OUTPUT_FORMAT=COFF"/>
<listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>
<listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>
<listOptionValue builtIn="false" value="LINK_ORDER=F28335.cmd;-lrts2800_fpu32.lib;"/>
<listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=28335_RAM_lnk.cmd"/>
<listOptionValue builtIn="false" value="OUTPUT_TYPE=executable"/>
<listOptionValue builtIn="false" value="PRODUCTS="/>
<listOptionValue builtIn="false" value="PRODUCT_MACRO_IMPORTS={}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.624589266" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="21.6.0.LTS" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.targetPlatformDebug.1195867980" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.targetPlatformDebug"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.builderDebug.1484000353" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.builderDebug"/>
<tool id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.compilerDebug.1731246565" name="C2000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.compilerDebug">
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.LARGE_MEMORY_MODEL.2072485324" name="Option deprecated, set by default (--large_memory_model, -ml)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.LARGE_MEMORY_MODEL" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.UNIFIED_MEMORY.2020368090" name="Unified memory (--unified_memory, -mt)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.UNIFIED_MEMORY" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.SILICON_VERSION.200319597" name="Processor version (--silicon_version, -v)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.SILICON_VERSION.28" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FLOAT_SUPPORT.1002982879" name="Specify floating point support (--float_support)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FLOAT_SUPPORT" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FLOAT_SUPPORT.fpu32" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_LEVEL.158333741" name="Optimization level (--opt_level, -O)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_LEVEL" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_LEVEL.4" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_FOR_SPEED.1189713323" name="Speed vs. size trade-offs (--opt_for_speed, -mf)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_FOR_SPEED" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.OPT_FOR_SPEED.5" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FP_MODE.597990472" name="Floating Point mode (--fp_mode)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FP_MODE" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.FP_MODE.relaxed" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.INCLUDE_PATH.910773204" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="${SRC_ROOT}/sys/include"/>
<listOptionValue builtIn="false" value="${SRC_ROOT}/DSP2833x_headers/include"/>
<listOptionValue builtIn="false" value="${SRC_ROOT}/DSP2833x_common/include"/>
<listOptionValue builtIn="false" value="${WORKSPACE_LOC}/FLOATPOINTLIB"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ADVICE__PERFORMANCE.1890281965" name="Provide advice on optimization techniques (--advice:performance)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ADVICE__PERFORMANCE" value="--advice:performance=all" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DEFINE.1385179336" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DEFINE" valueType="definedSymbols">
<listOptionValue builtIn="false" value="_DEBUG"/>
<listOptionValue builtIn="false" value="LARGE_MODEL"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DEBUGGING_MODEL.451239249" name="Debugging model" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DEBUGGING_MODEL" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DEBUGGING_MODEL.SYMDEBUG__DWARF" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DIAG_WRAP.44979444" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DISPLAY_ERROR_NUMBER.320946418" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ISSUE_REMARKS.1678891727" name="Issue remarks (--issue_remarks, -pdr)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ISSUE_REMARKS" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.QUIET_LEVEL.1661022843" name="Quiet Level" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.QUIET_LEVEL" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.QUIET_LEVEL.QUIET" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ABI.2128235277" name="Application binary interface [See 'General' page to edit] (--abi)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ABI" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ABI.coffabi" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ASM_LISTING.1104407996" name="Generate listing file (--asm_listing, -al)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.ASM_LISTING" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DISABLE_INLINING.31466939" name="Disable inlining (--disable_inlining)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compilerID.DISABLE_INLINING" value="false" valueType="boolean"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__C_SRCS.423959130" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__CPP_SRCS.447191296" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__ASM_SRCS.1088389375" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__ASM2_SRCS.274059361" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.linkerDebug.1778512584" name="C2000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exe.linkerDebug">
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.STACK_SIZE.1215847210" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.STACK_SIZE" value="0x100" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.MAP_FILE.569103737" name="Link information (map) listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.MAP_FILE" value="&quot;${SRC_ROOT}/sys/build/Debug/framework.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.OUTPUT_FILE.167409769" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.OUTPUT_FILE" value="${SRC_ROOT}/sys/build/Debug/framework.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.HEAP_SIZE.60955433" name="Heap size for C/C++ dynamic memory allocation (--heap_size, -heap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.HEAP_SIZE" value="0x100" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.LIBRARY.1339269017" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.LIBRARY" valueType="libs">
<listOptionValue builtIn="false" value="libc.a"/>
<listOptionValue builtIn="false" value="${UTILITIES}/flash_api/2833x/28335/v210/lib/Flash28335_API_V210.lib"/>
<listOptionValue builtIn="false" value="rts2800_fpu32.lib"/>
<listOptionValue builtIn="false" value="rts2800_fpu32_fast_supplement.lib"/>
<listOptionValue builtIn="false" value="${WORKSPACE_LOC}/FLOATPOINTLIB/Debug/FLOATPOINTLIB.lib"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.SEARCH_PATH.345223286" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/lib"/>
<listOptionValue builtIn="false" value="${UTILITIES}/flash_api/2833x/28335/v210/lib"/>
<listOptionValue builtIn="false" value="${CG_TOOL_ROOT}/include"/>
<listOptionValue builtIn="false" value="${PROJECT_ROOT}"/>
<listOptionValue builtIn="false" value="${SRC_ROOT}/sys/build"/>
<listOptionValue builtIn="false" value="${SRC_ROOT}/DSP2833x_headers/include"/>
<listOptionValue builtIn="false" value="${FAST_FPU32_SUPPLEMENT}/lib"/>
<listOptionValue builtIn="false" value="${WORKSPACE_LOC}/FLOATPOINTLIB/Debug"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.DIAG_WRAP.1827120485" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.DISPLAY_ERROR_NUMBER.728966569" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.XML_LINK_INFO.689360326" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__CMD_SRCS.1717731033" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__CMD_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__CMD2_SRCS.1965417765" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__CMD2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__GEN_CMDS.1435745153" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.exeLinker.inputType__GEN_CMDS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.C2000_21.6.hex.1661532341" name="C2000 Hex Utility" superClass="com.ti.ccstudio.buildDefinitions.C2000_21.6.hex"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="SYSCTRL/AlgorithmWorkEntry.cpp|spi_rom_interface.c|digital_io.c|analog_in.c|pwm_interface.c|hsm.c|app_main.c|cmd/F28335.cmd|modbus_slave.c|analog_out.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.ti.ccstudio.buildDefinitions.C2000.Release.1688218530">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.ti.ccstudio.buildDefinitions.C2000.Release.1688218530" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings/>
<extensions>
<extension id="com.ti.ccstudio.binaryparser.CoffParser" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="com.ti.ccstudio.errorparser.CoffErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.LinkErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="com.ti.ccstudio.errorparser.AsmErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.C2000.Release.1688218530" name="Release" parent="com.ti.ccstudio.buildDefinitions.C2000.Release">
<folderInfo id="com.ti.ccstudio.buildDefinitions.C2000.Release.1688218530." name="/" resourcePath="">
<toolChain id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.ReleaseToolchain.1897835650" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.ReleaseToolchain" targetTool="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.linkerRelease.114937104">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.116122469" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
<listOptionValue builtIn="false" value="DEVICE_CONFIGURATION_ID=TMS320C28XX.TMS320F28335"/>
<listOptionValue builtIn="false" value="OUTPUT_FORMAT=COFF"/>
<listOptionValue builtIn="false" value="CCS_MBS_VERSION=5.5.0"/>
<listOptionValue builtIn="false" value="LINKER_COMMAND_FILE=28335_RAM_lnk.cmd"/>
<listOptionValue builtIn="false" value="RUNTIME_SUPPORT_LIBRARY=libc.a"/>
<listOptionValue builtIn="false" value="OUTPUT_TYPE=executable"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION.116123921" name="Compiler version" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_CODEGEN_VERSION" value="6.2.0" valueType="string"/>
<targetPlatform id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.targetPlatformRelease.1291109672" name="Platform" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.targetPlatformRelease"/>
<builder buildPath="${BuildDirectory}" id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.builderRelease.1360820187" keepEnvironmentInBuildfile="false" name="GNU Make" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.builderRelease"/>
<tool id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.compilerRelease.486955678" name="C2000 Compiler" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.compilerRelease">
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.LARGE_MEMORY_MODEL.258118407" name="Use large memory model (--large_memory_model, -ml)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.LARGE_MEMORY_MODEL" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.UNIFIED_MEMORY.685177003" name="Unified memory (--unified_memory, -mt)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.UNIFIED_MEMORY" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.SILICON_VERSION.1089679905" name="Processor version (--silicon_version, -v)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.SILICON_VERSION" value="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.SILICON_VERSION.28" valueType="enumerated"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.FLOAT_SUPPORT.330649707" name="Specify floating point support (--float_support)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.FLOAT_SUPPORT" value="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.FLOAT_SUPPORT.fpu32" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DIAG_WARNING.202516022" name="Treat diagnostic &lt;id&gt; as warning (--diag_warning, -pdsw)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DIAG_WARNING" valueType="stringList">
<listOptionValue builtIn="false" value="225"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DISPLAY_ERROR_NUMBER.861584018" name="Emit diagnostic identifier numbers (--display_error_number, -pden)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DIAG_WRAP.4729059" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.INCLUDE_PATH.277004018" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>
</option>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__C_SRCS.1379003288" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__C_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__CPP_SRCS.1178256257" name="C++ Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__CPP_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__ASM_SRCS.103330727" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__ASM_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__ASM2_SRCS.1730673654" name="Assembly Sources" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.compiler.inputType__ASM2_SRCS"/>
</tool>
<tool id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.linkerRelease.114937104" name="C2000 Linker" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exe.linkerRelease">
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.STACK_SIZE.835162724" name="Set C system stack size (--stack_size, -stack)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.STACK_SIZE" value="0x300" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.OUTPUT_FILE.1105468446" name="Specify output file name (--output_file, -o)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.OUTPUT_FILE" useByScannerDiscovery="false" value="${ProjName}.out" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.MAP_FILE.1415258391" name="Input and output sections listed into &lt;file&gt; (--map_file, -m)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.MAP_FILE" value="&quot;${ProjName}.map&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.XML_LINK_INFO.1998060963" name="Detailed link information data-base into &lt;file&gt; (--xml_link_info, -xml_link_info)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.XML_LINK_INFO" value="&quot;${ProjName}_linkInfo.xml&quot;" valueType="string"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.DISPLAY_ERROR_NUMBER.1519711672" name="Emit diagnostic identifier numbers (--display_error_number)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.DISPLAY_ERROR_NUMBER" value="true" valueType="boolean"/>
<option id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.DIAG_WRAP.1448229379" name="Wrap diagnostic messages (--diag_wrap)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.DIAG_WRAP" value="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.DIAG_WRAP.off" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.SEARCH_PATH.1579599178" name="Add &lt;dir&gt; to library search path (--search_path, -i)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.SEARCH_PATH" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/lib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.LIBRARY.117696091" name="Include library file or command file as input (--library, -l)" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.linkerID.LIBRARY" valueType="libs">
<listOptionValue builtIn="false" value="&quot;libc.a&quot;"/>
</option>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__CMD_SRCS.1278335248" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__CMD_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__CMD2_SRCS.81365331" name="Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__CMD2_SRCS"/>
<inputType id="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__GEN_CMDS.1350236437" name="Generated Linker Command Files" superClass="com.ti.ccstudio.buildDefinitions.C2000_6.2.exeLinker.inputType__GEN_CMDS"/>
</tool>
</toolChain>
</folderInfo>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="Framework.com.ti.ccstudio.buildDefinitions.C2000.ProjectType.1226128593" name="C2000" projectType="com.ti.ccstudio.buildDefinitions.C2000.ProjectType"/>
</storageModule>
<storageModule moduleId="scannerConfiguration"/>
<storageModule moduleId="org.eclipse.cdt.core.language.mapping">
<project-mappings>
<content-type-mapping configuration="" content-type="org.eclipse.cdt.core.asmSource" language="com.ti.ccstudio.core.TIASMLanguage"/>
<content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cHeader" language="com.ti.ccstudio.core.TIGCCLanguage"/>
<content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cSource" language="com.ti.ccstudio.core.TIGCCLanguage"/>
<content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cxxHeader" language="com.ti.ccstudio.core.TIGPPLanguage"/>
<content-type-mapping configuration="" content-type="org.eclipse.cdt.core.cxxSource" language="com.ti.ccstudio.core.TIGPPLanguage"/>
</project-mappings>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="null.endianPreference"/>
<storageModule moduleId="cpuFamily"/>
</cproject>

32
.gitignore vendored

@ -0,0 +1,32 @@
# Created by https://www.gitignore.io/api/codecomposerstudio
# Edit at https://www.gitignore.io/?templates=codecomposerstudio
### CodeComposerStudio ###
tmp/
*.tmp
*.bak
# Generated build artifact directories
Debug/
Release/
Flash/
RAM/
# Generated build artifacts
makefile
*.map
*.mk
*.opt
*.pp
*.xml
# Generated directories
.config/
.launches/
# Generated file used to help display error messages in the problems view
.xdchelp
# Uniflash session files
*.uniflashsession
.settings/
targetConfigs/
# End of https://www.gitignore.io/api/codecomposerstudio

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DVR500Framework</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.ti.ccstudio.core.ccsNature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>app_main.c</name>
<type>1</type>
<locationURI>PARENT-2-ORIGINAL_PROJECT_ROOT/source/app_main.c</locationURI>
</link>
<link>
<name>Debug/framework.out</name>
<type>1</type>
<locationURI>EXTERNAL_BUILD_ARTIFACT</locationURI>
</link>
<link>
<name>F28335/DSP2833x_ADC_cal.asm</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_ADC_cal.asm</locationURI>
</link>
<link>
<name>F28335/DSP2833x_CodeStartBranch.asm</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_CodeStartBranch.asm</locationURI>
</link>
<link>
<name>F28335/DSP2833x_CpuTimers.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_CpuTimers.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_ECan.c</name>
<type>1</type>
<locationURI>PARENT-2-ORIGINAL_PROJECT_ROOT/source/DSP2833x_ECan.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_ECap.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_ECap.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_EPwm.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_EPwm.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_EQep.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_EQep.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_GlobalVariableDefs.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_headers/source/DSP2833x_GlobalVariableDefs.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_MemCopy.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_MemCopy.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_PieCtrl.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_PieCtrl.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_PieVect.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_PieVect.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_SWPrioritizedDefaultIsr.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_SWPrioritizedDefaultIsr.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_Sci.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_Sci.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_SysCtrl.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_SysCtrl.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_Xintf.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_Xintf.c</locationURI>
</link>
<link>
<name>F28335/DSP2833x_usDelay.asm</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/DSP2833x_usDelay.asm</locationURI>
</link>
<link>
<name>F28335/Date_ComBoard.c</name>
<type>1</type>
<locationURI>PARENT-2-ORIGINAL_PROJECT_ROOT/source/Date_ComBoard.c</locationURI>
</link>
<link>
<name>F28335/Ecap2.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/Ecap2.c</locationURI>
</link>
<link>
<name>F28335/Gpio.c</name>
<type>1</type>
<locationURI>PARENT-3-ORIGINAL_PROJECT_ROOT/DSP2833x_common/source/Gpio.c</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>FAST_FPU32_SUPPLEMENT</name>
<value>file:/C:/ti/controlSUITE/libs/math/FPUfastRTS/V100</value>
</variable>
<variable>
<name>ORIGINAL_PROJECT_ROOT</name>
<value>file:/C:/CCSWorkSpaces/Framework_500_Hz/sys/build/framework</value>
</variable>
<variable>
<name>SRC_ROOT</name>
<value>$%7BPARENT-3-ORIGINAL_PROJECT_ROOT%7D</value>
</variable>
<variable>
<name>UTILITIES</name>
<value>file:/C:/ti/controlSUITE/libs/utilities</value>
</variable>
</variableList>
</projectDescription>

@ -0,0 +1,37 @@
/*
* AlertBase.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/AlertBase.h"
namespace ALERT
{
//CONSTRUCTOR
AlertBase::AlertBase():
//m_mode(ALERT::AlertBase::UNDEFINED),
m_time_sample(-1.0),
m_level(FP_ZERO),
m_period(FP_ZERO),
m_timer(FP_ZERO)
//
{}//CONSTRUCTOR
/*
AlertBase::mode_t AlertBase::get_mode() const
{
return m_mode;
//
}//get_mode()
//
bool AlertBase::compare(mode_t mode) const
{
return m_mode == mode;
//
}//compare()
//
*/
} /* namespace ALERT */

@ -0,0 +1,62 @@
/*
* AlertBase.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef ALERT_ALARMBASE_H_
#define ALERT_ALARMBASE_H_
namespace ALERT
{
struct AlertBaseConfiguration
{
float level;
float period;
AlertBaseConfiguration():
level(-1.0),
period(-1.0)
{}
};//AlertBaseConfiguration
class AlertBase
{
//public:
// enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
//protected:
// mode_t m_mode;
protected:
float m_time_sample;
protected:
float m_level;
protected:
float m_period;
float m_timer;
//public:
// mode_t mode;
public:
AlertBase();
virtual void setup(float time_sample) = 0;
virtual void configure(const AlertBaseConfiguration& config) = 0;
//public:
//mode_t get_mode() const;
//bool compare(mode_t mode) const;
public:
virtual void reset() = 0;
virtual void execute(float reference) = 0;
protected:
virtual void _execute_undef(float reference) = 0;
virtual void _execute_operational(float reference) = 0;
//
};//AlertBase
//
} /* namespace ALERT */
//
#endif /* ALERT_ALARMBASE_H_ */

@ -0,0 +1,96 @@
/*
* FaultDecrease.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/FaultDecrease.h"
namespace ALERT
{
//CONSTRUCTOR
FaultDecrease::FaultDecrease():
ALERT::AlertBase(),
// m_state(ALERT::FaultDecrease::UNKNOWN),
m_fault(false),
fault(false),
_execute(&ALERT::FaultDecrease::_execute_undef)
//
{}//CONSTRUCTOR
//
void FaultDecrease::setup(float time_sample)
{
m_time_sample = time_sample;
//
}//setup()
//
void FaultDecrease::configure(const ALERT::AlertBaseConfiguration& config)
{
m_level = config.level;
m_period = config.period;
m_timer = FP_ZERO;
//
m_fault = false;
fault = false;
//
if((m_time_sample > FP_ZERO) && (m_period > m_time_sample) && (m_level >= FP_ZERO))
{
_execute = &ALERT::FaultDecrease::_execute_operational;
}
//
}//configure()
//
//
#pragma CODE_SECTION("ramfuncs");
void FaultDecrease::reset()
{
m_fault = false;
fault = false;
m_timer = FP_ZERO;
//
}//reset()
//
#pragma CODE_SECTION("ramfuncs");
void FaultDecrease::execute(float reference)
{
(this->*_execute)(reference);
//
}//execute()
//
void FaultDecrease::_execute_undef(float reference)
{
//
}//_execute_undef()
//
#pragma CODE_SECTION("ramfuncs");
void FaultDecrease::_execute_operational(float reference)
{
if(reference <= m_level)
{
if(m_timer >= m_period)
{
m_fault = true;
fault = true;
}
else
{
m_timer += m_time_sample;
m_fault = false;
fault = false;
//
}//
//
}
else
{
m_timer = FP_ZERO;
m_fault = false;
fault = false;
//
}//
//
}//_execute_operational_warning()
//
} /* namespace ALERT */

@ -0,0 +1,46 @@
/*
* FaultDecrease.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/AlertBase.h"
#ifndef ALERT_FAULTDECREASE_H_
#define ALERT_FAULTDECREASE_H_
namespace ALERT
{
class FaultDecrease: public ALERT::AlertBase
{
public:
// enum state_t {UNKNOWN, NORMAL, FAULT};
private:
// state_t m_state;
bool m_fault;
public:
bool fault;
public:
FaultDecrease();
void setup(float time_sample);
void configure(const ALERT::AlertBaseConfiguration& config);
public:
// state_t get_state() const;
// bool compare_state(state_t state) const;
// bool is_fault();
public:
void reset();
public:
void execute(float reference);
private:
void (FaultDecrease::*_execute)(float reference);
void _execute_undef(float reference);
void _execute_operational(float reference);
//
};//FaultDecrease()
} /* namespace ALERT */
#endif /* ALERT_FAULTDECREASE_H_ */

@ -0,0 +1,92 @@
/*
* FaultExceed.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/FaultExceed.h"
namespace ALERT
{
//CONSTRUCTOR
FaultExceed::FaultExceed():
ALERT::AlertBase(),
m_fault(false),
fault(false),
_execute(&ALERT::FaultExceed::_execute_undef)
//
{}//CONSTRUCTOR
//
void FaultExceed::setup(float time_sample)
{
m_time_sample = time_sample;
//
}//setup()
//
void FaultExceed::configure(const AlertBaseConfiguration& config)
{
m_level = config.level;
m_period = config.period;
//
m_fault = false;
fault = false;
//
if((m_time_sample > FP_ZERO) && (m_period >= m_time_sample)&&(m_level > FP_ZERO))
{
_execute = &ALERT::FaultExceed::_execute_operational;
//
}//if
//
}//configure()
//
#pragma CODE_SECTION("ramfuncs");
void FaultExceed::reset()
{
m_fault = false;
fault = false;
m_timer = FP_ZERO;
//
}//reset()
//
void FaultExceed::execute(float reference)
{
(this->*_execute)(reference);
//
}//execute()
//
void FaultExceed::_execute_undef(float reference)
{}//
//
#pragma CODE_SECTION("ramfuncs");
void FaultExceed::_execute_operational(float reference)
{
if(reference >= m_level)
{
if(m_timer >= m_period)
{
m_fault = true;
fault = true;
}
else
{
m_timer += m_time_sample;
m_fault = false;
fault = false;
//
}//if else
//
}
else
{
m_timer = FP_ZERO;
m_fault = false;
fault = false;
//
}//if else
//
}//
//
} /* namespace ALERT */

@ -0,0 +1,39 @@
/*
* FaultExceed.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/AlertBase.h"
#ifndef ALERT_FAULTEXCEED_H_
#define ALERT_FAULTEXCEED_H_
namespace ALERT
{
class FaultExceed: public ALERT::AlertBase
{
private:
bool m_fault;
public:
bool fault;
public:
FaultExceed();
void setup(float time_sample);
void configure(const AlertBaseConfiguration& config);
public:
void reset();
public:
void execute(float reference);
private:
void (FaultExceed::*_execute)(float reference);
void _execute_undef(float reference);
void _execute_operational(float reference);
//
};//FaultExceed()
} /* namespace ALERT */
#endif /* ALERT_FAULTEXCEED_H_ */

@ -0,0 +1,88 @@
/*
* WarningDecrease.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/WarningDecrease.h"
namespace ALERT
{
//CONSTRUCTOR
WarningDecrease::WarningDecrease():
ALERT::AlertBase(),
m_warning(false),
warning(false),
_execute(&ALERT::WarningDecrease::_execute_undef)
{}//CONSTRUCTOR
//
void WarningDecrease::setup(float time_sample)
{
m_time_sample = time_sample;
//
}//setup()
//
void WarningDecrease::configure(const AlertBaseConfiguration& config)
{
m_level = config.level;
m_period = config.period;
//
m_warning = false;
//
if((m_time_sample > FP_ZERO) && (m_period >= m_time_sample) && (m_level > FP_ZERO))
{
_execute = &ALERT::WarningDecrease::_execute_operational;
//
}//if
//
}//configure()
//
#pragma CODE_SECTION("ramfuncs");
void WarningDecrease::reset()
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//reset()
//
void WarningDecrease::execute(float reference)
{
(this->*_execute)(reference);
//
}//execute()
//
void WarningDecrease::_execute_undef(float reference)
{}//
//
#pragma CODE_SECTION("ramfuncs");
void WarningDecrease::_execute_operational(float reference)
{
//
if(reference <= m_level)
{
if(m_timer >= m_period)
{
m_warning = true;
warning = true;
}
else
{
m_timer += m_time_sample;
m_warning = false;
warning = false;
//
}//if else
}
else
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//else if
//
}//_execute_operational()
//
} /* namespace ALERT */

@ -0,0 +1,39 @@
/*
* WarningDecrease.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/AlertBase.h"
#ifndef ALERT_WARNINGDECREASE_H_
#define ALERT_WARNINGDECREASE_H_
namespace ALERT
{
class WarningDecrease: public ALERT::AlertBase
{
private:
bool m_warning;
public:
bool warning;
public:
WarningDecrease();
void setup(float time_sample);
void configure(const AlertBaseConfiguration& config);
public:
void reset();
public:
void execute(float reference);
private:
void (WarningDecrease::*_execute)(float reference);
void _execute_undef(float reference);
void _execute_operational(float reference);
//
};//
} /* namespace ALERT */
#endif /* ALERT_WARNINGDECREASE_H_ */

@ -0,0 +1,96 @@
/*
* WarningExceed.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/WarningExceed.h"
namespace ALERT
{
//CONSTRUCTOR
WarningExceed::WarningExceed():
ALERT::AlertBase(),
m_warning(false),
warning(false),
_execute(&ALERT::WarningExceed::_execute_undef)
{}//CONSTRUCTOR
//
void WarningExceed::setup(float time_sample)
{
m_time_sample = time_sample;
//
}//setup()
//
void WarningExceed::configure(const AlertBaseConfiguration& config)
{
m_level = config.level;
m_period = config.period;
//
m_warning = false;
//
if((m_time_sample > FP_ZERO)&&(m_period > m_time_sample)&&(m_level >= FP_ZERO))
{
_execute = &ALERT::WarningExceed::_execute_operational;
//
}//if
//
}//configure()
//
//
//
//
#pragma CODE_SECTION("ramfuncs");
void WarningExceed::reset()
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//reset()
//
void WarningExceed::execute(float reference)
{
(this->*_execute)(reference);
//
}//execute()
//
void WarningExceed::_execute_undef(float reference)
{}//
//
#pragma CODE_SECTION("ramfuncs");
void WarningExceed::_execute_operational(float reference)
{
//
if(reference >= m_level)
{
if(m_timer >= m_period)
{
m_warning = true;
warning = true;
}
else
{
m_timer += m_time_sample;
m_warning = false;
warning = false;
//
}//if else
}
else
{
m_warning = false;
warning = false;
m_timer = FP_ZERO;
//
}//else if
//
}//_execute_operational()
//
} /* namespace ALERT */

@ -0,0 +1,38 @@
/*
* WarningExceed.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "Alert/AlertBase.h"
#ifndef ALERT_WARNINGEXCEED_H_
#define ALERT_WARNINGEXCEED_H_
namespace ALERT
{
class WarningExceed: public ALERT::AlertBase
{
private:
bool m_warning;
public:
bool warning;
public:
WarningExceed();
void setup(float time_sample);
void configure(const AlertBaseConfiguration& config);
public:
void reset();
public:
void execute(float reference);
private:
void (WarningExceed::*_execute)(float reference);
void _execute_undef(float reference);
void _execute_operational(float reference);
};
} /* namespace ALERT */
#endif /* ALERT_WARNINGEXCEED_H_ */

@ -0,0 +1,22 @@
//###########################################################################
//
// FILE: DSP28x_Project.h
//
// TITLE: DSP28x Project Headerfile and Examples Include File
//
//###########################################################################
// $TI Release: F2833x/F2823x Header Files and Peripheral Examples V142 $
// $Release Date: November 1, 2016 $
// $Copyright: Copyright (C) 2007-2016 Texas Instruments Incorporated -
// http://www.ti.com/ ALL RIGHTS RESERVED $
//###########################################################################
#ifndef DSP28x_PROJECT_H
#define DSP28x_PROJECT_H
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File
#endif // end of DSP28x_PROJECT_H definition

@ -0,0 +1,80 @@
// TI File $Revision: /main/2 $
// Checkin $Date: June 22, 2007 13:11:24 $
//###########################################################################
//
// FILE: Flash2833x_API_Config.h
//
// TITLE: F2833x Flash Algo's - User Settings
//
// NOTE: This file contains user defined settings that
// are used by the F2833x Flash APIs.
//
//###########################################################################
// $TI Release:$
// $Release Date:$
//###########################################################################
#ifndef FLASH2833X_API_CONFIG_H
#define FLASH2833X_API_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
// Variables that can be configured by the user.
/*-----------------------------------------------------------------------------
1. Specify the device.
Define the device to be programmed as "1" (no quotes).
Define all other devices as "0" (no quotes).
-----------------------------------------------------------------------------*/
#define FLASH_F28335 1
#define FLASH_F28334 0
#define FLASH_F28332 0
/*-----------------------------------------------------------------------------
2. Specify the clock rate of the CPU (SYSCLKOUT) in nS.
Take into account the input clock frequency and the PLL multiplier
that your application will use.
Use one of the values provided, or define your own.
The trailing L is required tells the compiler to treat
the number as a 64-bit value.
Only one statement should be uncommented.
Example: CLKIN is a 30MHz crystal.
If the application will set PLLCR = 0xA then the CPU clock
will be 150Mhz (SYSCLKOUT = 150MHz).
In this case, the CPU_RATE will be 6.667L
Uncomment the line: #define CPU_RATE 6.667L
-----------------------------------------------------------------------------*/
#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 10.000L // for a 100MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 13.330L // for a 75MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 41.667L // for a 24MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 50.000L // for a 20MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 66.667L // for a 15MHz CPU clock speed (SYSCLKOUT)
//#define CPU_RATE 100.000L // for a 10MHz CPU clock speed (SYSCLKOUT)
//----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// **** DO NOT modify the code below this line ****
//-----------------------------------------------------------------------------
#define SCALE_FACTOR 1048576.0L*( (200L/CPU_RATE) ) // IQ20
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // -- end FLASH2833X_API_CONFIG_H

@ -0,0 +1,272 @@
// TI File $Revision: /main/3 $
// Checkin $Date: February 5, 2008 11:10:02 $
//###########################################################################
//
// FILE: Flash2833x_API_Library.h
//
// TITLE: F2833x Flash Algo's main include file
//
// DESCRIPTION:
//
// This file should be included in any project that uses any of the
// the F2833x flash APIs.
//
//###########################################################################
// $TI Release:$
// $Release Date:$
//###########################################################################
#ifndef FLASH2833X_API_LIBRARY_H
#define FLASH2833X_API_LIBRARY_H
#include <F28335/Flash2833x_API_Config.h>
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------------
28x Datatypes
For Portability, User Is Recommended To Use Following Data Type Size
Definitions For 16/32/64-Bit Signed/Unsigned Integers and floating point
variables:
---------------------------------------------------------------------------*/
#ifndef DSP28_DATA_TYPES
#define DSP28_DATA_TYPES
typedef int int16;
typedef long int32;
typedef long long int64;
typedef unsigned int Uint16;
typedef unsigned long Uint32;
typedef unsigned long long Uint64;
typedef float float32;
typedef long double float64;
#endif
/*---------------------------------------------------------------------------
API Status Messages
The following status values are returned from the API to the calling
program. These can be used to determine if the API function passed
or failed.
---------------------------------------------------------------------------*/
// Operation passed, no errors were flagged
#define STATUS_SUCCESS 0
// The CSM is preventing the function from performing its operation
#define STATUS_FAIL_CSM_LOCKED 10
// Device REVID does not match that required by the API
#define STATUS_FAIL_REVID_INVALID 11
// Invalid address passed to the API
#define STATUS_FAIL_ADDR_INVALID 12
// Incorrect PARTID
// For example the F2806 API was used on a F2808 device.
#define STATUS_FAIL_INCORRECT_PARTID 13
// API/Silicon missmatch. An old version of the
// API is being used on silicon it is not valid for
// Please update to the latest API.
#define STATUS_FAIL_API_SILICON_MISMATCH 14
// ---- Erase Specific errors ----
#define STATUS_FAIL_NO_SECTOR_SPECIFIED 20
#define STATUS_FAIL_PRECONDITION 21
#define STATUS_FAIL_ERASE 22
#define STATUS_FAIL_COMPACT 23
#define STATUS_FAIL_PRECOMPACT 24
// ---- Program Specific errors ----
#define STATUS_FAIL_PROGRAM 30
#define STATUS_FAIL_ZERO_BIT_ERROR 31
// ---- Verify Specific errors ----
#define STATUS_FAIL_VERIFY 40
// Busy is set by each API function before it determines
// a pass or fail condition for that operation.
// The calling function will will not receive this
// status condition back from the API
#define STATUS_BUSY 999
/*---------------------------------------------------------------------------
Flash sector mask definitions
The following macros can be used to form a mask specifying which sectors
will be erased by the erase API function.
Bit0 = Sector A
Bit1 = Sector B
Bit2 = Sector C
Bit3 = Sector D
Bit4 = Sector E
Bit5 = Sector F
Bit6 = Sector G
Bit7 = Sector H
---------------------------------------------------------------------------*/
#define SECTORA (Uint16)0x0001
#define SECTORB (Uint16)0x0002
#define SECTORC (Uint16)0x0004
#define SECTORD (Uint16)0x0008
#define SECTORE (Uint16)0x0010
#define SECTORF (Uint16)0x0020
#define SECTORG (Uint16)0x0040
#define SECTORH (Uint16)0x0080
#if FLASH_F28335
// All sectors on an F28335 - Sectors A - H
#define SECTOR_F28335 (SECTORA|SECTORB|SECTORC|\
SECTORD|SECTORE|SECTORF|\
SECTORG|SECTORH)
#endif // -- end FLASH_F28335
#if FLASH_F28334
// All sectors on an F28334 - Sectors A - H
#define SECTOR_F28334 (SECTORA|SECTORB|SECTORC|\
SECTORD|SECTORE|SECTORF|\
SECTORG|SECTORH)
#endif // -- end FLASH_F28334
#if FLASH_F28332
// All sectors on an F28332 - Sectors A - D
#define SECTOR_F28332 (SECTORA|SECTORB|SECTORC|\
SECTORD)
#endif // -- end FLASH_F28332
/*---------------------------------------------------------------------------
API Status Structure
This structure is used to pass debug data back to the calling routine.
Note that the Erase API function has 3 parts: precondition, erase and
and compaction. Erase and compaction failures will not populate
the expected and actual data fields.
---------------------------------------------------------------------------*/
typedef struct {
Uint32 FirstFailAddr;
Uint16 ExpectedData;
Uint16 ActualData;
}FLASH_ST;
/*---------------------------------------------------------------------------
Interface Function prototypes
For each 28x Flash API library, the function names are of the form:
Flash<DeviceNum>_<Operation>()
Where <DeviceNum> is the device: ie 2808, 2806, 2801
<Operation> is the operation such as Erase, Program...
For portability for users who may move between the F2808, F2806 and
F2801, the following macro definitions are supplied.
Using these macro definitions, the user can use instead make a generic
call: Flash_<Operation> and the macro will map the call to the proper
device function
Note except for the toggle test function, all of the function prototypes
are compatible with F281x devices as well.
---------------------------------------------------------------------------*/
#if FLASH_F28335
#define Flash_Erase(a,b) Flash28335_Erase(a,b)
#define Flash_Program(a,b,c,d) Flash28335_Program(a,b,c,d)
#define Flash_Verify(a,b,c,d) Flash28335_Verify(a,b,c,d)
#define Flash_ToggleTest(a,b) Flash28335_ToggleTest(a,b)
#define Flash_DepRecover() Flash28335_DepRecover()
#define Flash_APIVersionHex() Flash28335_APIVersionHex()
#define Flash_APIVersion() Flash28335_APIVersion()
#endif
#if FLASH_F28334
#define Flash_Erase(a,b) Flash28334_Erase(a,b)
#define Flash_Program(a,b,c,d) Flash28334_Program(a,b,c,d)
#define Flash_Verify(a,b,c,d) Flash28334_Verify(a,b,c,d)
#define Flash_ToggleTest(a,b) Flash28334_ToggleTest(a,b)
#define Flash_DepRecover() Flash28334_DepRecover()
#define Flash_APIVersionHex() Flash28334_APIVersionHex()
#define Flash_APIVersion() Flash28334_APIVersion()
#endif
#if FLASH_F28332
#define Flash_Erase(a,b) Flash28332_Erase(a,b)
#define Flash_Program(a,b,c,d) Flash28332_Program(a,b,c,d)
#define Flash_Verify(a,b,c,d) Flash28332_Verify(a,b,c,d)
#define Flash_ToggleTest(a,b) Flash28332_ToggleTest(a,b)
#define Flash_DepRecover() Flash28332_DepRecover()
#define Flash_APIVersionHex() Flash28332_APIVersionHex()
#define Flash_APIVersion() Flash28332_APIVersion()
#endif
extern Uint16 Flash_Erase(Uint16 SectorMask, FLASH_ST *FEraseStat);
extern Uint16 Flash_Program(Uint16 *FlashAddr, Uint16 *BufAddr, Uint32 Length, FLASH_ST *FProgStatus);
extern Uint16 Flash_Verify(Uint16 *StartAddr, Uint16 *BufAddr, Uint32 Length, FLASH_ST *FVerifyStat);
extern void Flash_ToggleTest(volatile Uint32 *ToggleReg, Uint32 Mask);
extern Uint16 Flash_DepRecover();
extern float32 Flash_APIVersion();
extern Uint16 Flash_APIVersionHex();
/*---------------------------------------------------------------------------
Frequency Scale factor:
The calling program must provide this global parameter used
for frequency scaling the algo's.
----------------------------------------------------------------------------*/
extern Uint32 Flash_CPUScaleFactor;
/*---------------------------------------------------------------------------
Callback Function Pointer:
A callback function can be specified. This function will be called
at safe times during erase, program and verify. This function can
then be used to service an external watchdog or send a communications
packet.
Note:
THE FLASH AND OTP ARE NOT AVAILABLE DURING THIS FUNCTION CALL.
THE FLASH/OTP CANNOT BE READ NOR CAN CODE EXECUTE FROM IT DURING THIS CALL
DO NOT CALL ANY OF THE THE FLASH API FUNCTIONS DURING THIS CALL
----------------------------------------------------------------------------*/
extern void (*Flash_CallbackPtr) (void);
/*---------------------------------------------------------------------------
API load/run symbols:
These symbols are defined by the linker during the link. Refer to the
Flash28_API section in the example .cmd file:
Flash28_API:
{
Flash28335_API_Library.lib(.econst)
Flash28335_API_Library.lib(.text)
} LOAD = FLASH,
RUN = SARAM,
LOAD_START(_Flash28_API_LoadStart),
LOAD_END(_Flash28_API_LoadEnd),
RUN_START(_Flash28_API_RunStart),
PAGE = 0
These are used to copy the flash API from flash to SARAM
----------------------------------------------------------------------------*/
extern Uint16 Flash28_API_LoadStart;
extern Uint16 Flash28_API_LoadEnd;
extern Uint16 Flash28_API_RunStart;
#ifdef __cplusplus
}
#endif /* extern "C" */
#endif // -- end FLASH2833x_API_LIBRARY_H
// --------- END OF FILE ----------------------------------

@ -0,0 +1,118 @@
/*
* FRAMBuffer.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/FRAMBuffer.h"
namespace FRAM
{
//CONSTRUCTOR
FRAMBuffer::FRAMBuffer():
m_header(),
m_config(),
m_footer()
//
{}//CONSTRUCTOR
void FRAMBuffer::update(const FRAM::FRAMHeader& header, const SYSCTRL::SystemControlConfiguration& config, const FRAM::FRAMFooter& footer)
{
m_header = header;
m_config = config;
m_footer = footer;
//
}//
//
bool FRAMBuffer::verify_header_and_footer(const FRAM::FRAMHeader& header, const FRAM::FRAMFooter& footer)
{
if((m_header.class_id == 0xFFFF)
&& (m_header.part_id == 0xFFFF)
&& (m_header.software_version == 0xFFFF)
&& (m_header.size_of_fram_data == 0xFFFF)
&& (m_footer.foot == 0xFFFF))
{
return false;
//
}else{
if(m_header.class_id != header.class_id)
{
return false;
//
}else{
if(m_header.part_id != header.part_id)
{
return false;
//
}else{
if(m_header.software_version != header.software_version)
{
return false;
//
}else{
if(m_header.size_of_fram_data != header.size_of_fram_data)
{
return false;
//
}else{
if(m_footer.foot != footer.foot)
{
return false;
//
}else{
return true;
//
}
}
}
}
}
}
}//
//
void FRAMBuffer::extract(FRAM::FRAMHeader& header, SYSCTRL::SystemControlConfiguration& config, FRAM::FRAMFooter& footer)
{
header = m_header;
footer = m_footer;
config = m_config;
//
}//
//
void FRAMBuffer::extract_header(FRAMHeader& header)
{
header = m_header;
//
}//
//
FRAM::FRAMHeader FRAMBuffer::get_header()
{
return m_header;
//
}//
//
void FRAMBuffer::extract_footer(FRAMFooter& footer)
{
footer = m_footer;
//
}//
//
FRAM::FRAMFooter FRAMBuffer::get_footer()
{
return m_footer;
//
}//
//
void FRAMBuffer::extract_system_configuration(SYSCTRL::SystemControlConfiguration& config)
{
config = m_config;
//
}//
//
} /* namespace FRAM */

@ -0,0 +1,65 @@
/*
* FRAMBuffer.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <stdint.h>
#include "SYSCTRL/TypeControl.h"
#include "SYSCTRL/SystemConfigurator.h"
#ifndef FRAM_FRAMBUFFER_H_
#define FRAM_FRAMBUFFER_H_
namespace FRAM
{
struct FRAMHeader
{
int16_t class_id;
int16_t part_id;
int16_t software_version;
int16_t size_of_fram_data;
FRAMHeader():
class_id(0x0FFFF),
part_id(0x0FFFF),
software_version(0x0FFFF),
size_of_fram_data(0x0FFFF)
{}
};//FRAMHeader
struct FRAMFooter
{
int16_t foot;
FRAMFooter():
foot(0x0FFFF)
{}
};//FRAMFooter
class FRAMBuffer
{
private:
FRAMHeader m_header;
SYSCTRL::SystemControlConfiguration m_config;
FRAMFooter m_footer;
public:
FRAMBuffer();
public:
void update(const FRAM::FRAMHeader& header, const SYSCTRL::SystemControlConfiguration& config, const FRAM::FRAMFooter& footer);
bool verify_header_and_footer(const FRAM::FRAMHeader& header, const FRAM::FRAMFooter& footer);
void extract(FRAM::FRAMHeader& header, SYSCTRL::SystemControlConfiguration& config, FRAM::FRAMFooter& footer);
void extract_header(FRAMHeader& header);
FRAM::FRAMHeader get_header();
void extract_footer(FRAMFooter& footer);
FRAM::FRAMFooter get_footer();
void extract_system_configuration(SYSCTRL::SystemControlConfiguration& config);
};
} /* namespace FRAM */
#endif /* FRAM_FRAMBUFFER_H_ */

@ -0,0 +1,446 @@
/*
* FRAMConfigurationParameters.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/FRAMDATABASE.h"
namespace FRAM
{
void FRAMDATABASE::register_configuration_parameters(SYSCTRL::SystemControlConfiguration *sys_config)
{
m_fram_object_index = 0;
m_fram_object_address = 0;
m_fram_object_last_address = 0;
//add_register_float(uint8_t readonly, float* pParam, float default_value);
//add_register_int(uint8_t readonly, int16_t* pParam, int16_t default_value);
//
//
// References
//
add_float( 0, &sys_config->reference_current_limit_rms, CURRENT_LIMIT_RMS);
add_float( 0, &sys_config->reference_current_pfc_rms, CURRENT_PFC_RMS);
add_float( 0, &sys_config->reference_voltage_rms, GRID_VOLTAGE_REFERENCE);
add_float( 0, &sys_config->reference_voltage_high_limit_rms, GRID_VOLTAGE_HIGH_LIMIT);
add_float( 0, &sys_config->reference_voltage_dc, CELL_DC_VOLTAGE_REFERENCE);
//<>
//
// Algorithm Control Register
add_uint16(0, &sys_config->algorithm_control.all, ENABLE_CONTROL_BIT);
//<>
//
// High Voltage Cell
//
add_uint16(0, &sys_config->hardware.cell_level, 4);
add_uint16(0, &sys_config->hardware.version.pwm, 210);
add_uint16(0, &sys_config->hardware.version.cell, 211);
add_uint32(0, &sys_config->hardware.version.cpu_cpld, 202);
//<>
add_float( 0, &sys_config->minimal_input_voltage_level, 10.0);
//<>
//
// Scale Analog Signals
//
add_float( 0, &sys_config->scale_voltage_input_a, 0.166324854);//0.0227386411//0.0233486816;
add_float( 0, &sys_config->scale_voltage_input_b, 0.166955084);//0.0227597337//0.0234651081;
add_float( 0, &sys_config->scale_voltage_input_c, 0.170290515);//0.02278281//0.0236082859;
//
add_float( 0, &sys_config->scale_current_input_a, 0.0057266783);
add_float( 0, &sys_config->scale_current_input_b, 0.00571648451);
add_float( 0, &sys_config->scale_current_input_c, 0.00571565609);
//
add_float( 0, &sys_config->scale_current_cell_a, 0.0095403092);//0.00665648002;
add_float( 0, &sys_config->scale_current_cell_b, 0.00967073813);//0.00667640707;
add_float( 0, &sys_config->scale_current_cell_c, 0.00962774921);//0.00666095456;
//
add_float( 0, &sys_config->scale_voltage_load_a, 0.168764219);//0.0227408651//0.0232194811;
add_float( 0, &sys_config->scale_voltage_load_b, 0.167528242);//0.0227707103//0.0233941432;
add_float( 0, &sys_config->scale_voltage_load_c, 0.171417475);//0.0229060184//0.0234934501;
//
add_float( 0, &sys_config->scale_current_load_a, 0.00949461199);//0.00668919506;
add_float( 0, &sys_config->scale_current_load_b, 0.00953965727);//0.00669770781;
add_float( 0, &sys_config->scale_current_load_c, 0.00959520414);//0.00670575583;
//
add_float( 0, &sys_config->scale_current_bypass_a, 0.00953388773);
add_float( 0, &sys_config->scale_current_bypass_b, 0.00956917088);
add_float( 0, &sys_config->scale_current_bypass_c, 0.00956158526);
//<>
//
// Amplitude Filter Parameters
//
add_float( 0, &sys_config->ampl_filter_current.time, 20.0e-3);
add_float( 0, &sys_config->ampl_filter_current.a3, 2.61313);
add_float( 0, &sys_config->ampl_filter_current.a2, 3.41422);
add_float( 0, &sys_config->ampl_filter_current.a1, 2.61313);
//<>
//
// RMS Filter Parameters
//
add_float( 0, &sys_config->rms_filter_analog_signal.time, 10.0e-3);
add_float( 0, &sys_config->rms_filter_analog_signal.a3, 2.61313);
add_float( 0, &sys_config->rms_filter_analog_signal.a2, 3.41422);
add_float( 0, &sys_config->rms_filter_analog_signal.a1, 2.61313);
//<>
//
// Zero Drift Current Input
//
add_float( 0, &sys_config->zero_filter.time, 1.333);
//<>
//
// Cell DC Voltage Filter
//
add_float( 0, &sys_config->cell_dc_voltage_filter.time, 3.0e-3);
add_float( 0, &sys_config->cell_dc_voltage_filter.a3, 2.61313);
add_float( 0, &sys_config->cell_dc_voltage_filter.a2, 3.41422);
add_float( 0, &sys_config->cell_dc_voltage_filter.a1, 2.61313);
//<>
//
// Signal Decompose
//
add_float( 0, &sys_config->signal_decompose.projection_filter.time, 10.0e-3);
add_float( 0, &sys_config->signal_decompose.projection_filter.a3, 2.61313);
add_float( 0, &sys_config->signal_decompose.projection_filter.a2, 3.41422);
add_float( 0, &sys_config->signal_decompose.projection_filter.a1, 2.61313);
//<>
//
// Relative
//
add_float( 0, &sys_config->relative_voltage_input.minimal_amplitude_level, 0.1);
add_float( 0, &sys_config->relative_voltage_input.limit_relative_high, 1.1);
add_float( 0, &sys_config->relative_voltage_input.limit_relative_low, -1.1);
add_float( 0, &sys_config->relative_voltage_input.amplitude_filter.time, (float)(1.0/2.0/FP_PI/10.0));
add_float( 0, &sys_config->relative_voltage_input.amplitude_filter.a3, 2.61313);
add_float( 0, &sys_config->relative_voltage_input.amplitude_filter.a2, 3.41422);
add_float( 0, &sys_config->relative_voltage_input.amplitude_filter.a1, 2.61313);
//<>
//
// Voltage PLL-ABC Parameters
//
add_float( 0, &sys_config->pll_abc_input_voltage.frequency_nominal, PLLABC_FREQUENCY_NOMINAL);
add_float( 0, &sys_config->pll_abc_input_voltage.filter.time, 1.0/PLLABC_FREQUENCY_CUT);
add_float( 0, &sys_config->pll_abc_input_voltage.controller.gain, PLLABC_FREQUENCY_CUT/2.0);
add_float( 0, &sys_config->pll_abc_input_voltage.controller.time, 4.0/PLLABC_FREQUENCY_CUT);
add_float( 0, &sys_config->pll_abc_input_voltage.controller.low_saturation, PLLABC_FREQUENCY_LIMIT_LOW);
add_float( 0, &sys_config->pll_abc_input_voltage.controller.high_saturation, PLLABC_FREQUENCY_LIMIT_HI);
add_float( 0, &sys_config->pll_abc_input_voltage.position.time, 1.0);
add_float( 0, &sys_config->pll_abc_input_voltage.position.low_saturation, FP_ZERO);
add_float( 0, &sys_config->pll_abc_input_voltage.position.high_saturation, 2.0 * FP_PI);
//<>
//
// System Alarm
//
// exceed voltage level 1
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_1.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 + (PROTECTION_EXCEED_VOLTAGE_LEVEL_1_PERCENT / (float)100.0)));//253.0;
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_1.period, 10.0);
//
// exceed voltage level 2
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_2.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 + (PROTECTION_EXCEED_VOLTAGE_LEVEL_2_PERCENT / (float)100.0)));//264.5;
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_2.period, 5.0);
//
// exceed voltage level 3
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_3.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 + (PROTECTION_EXCEED_VOLTAGE_LEVEL_3_PERCENT / (float)100.0)));//276.0;
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_3.period, 2.0);
//
// exceed voltage level 4
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_4.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 + (PROTECTION_EXCEED_VOLTAGE_LEVEL_4_PERCENT / (float)100.0)));
add_float( 0, &sys_config->phase_alert_monitor.voltage_exceed_level_4.period, 0.004);//1.0;
//
// decrease voltage level 1
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_1.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 - (PROTECTION_DECREASE_VOLTAGE_LEVEL_1_PERCENT / (float)100.0)));//218.5;//195.5;
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_1.period, 10.0);
//
// decrease voltage level 2
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_2.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 - (PROTECTION_DECREASE_VOLTAGE_LEVEL_2_PERCENT / (float)100.0)));//207.0;//172.5;
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_2.period, 5.0);
//
// decrease voltage level 3
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_3.level, NOMINAL_GRID_VOLTAGE * ((float)1.0 - (PROTECTION_DECREASE_VOLTAGE_LEVEL_3_PERCENT / (float)100.0)));
add_float( 0, &sys_config->phase_alert_monitor.voltage_decrease_level_3.period, 2.0);
//
// current overload level 1 120% 60s
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_1.level, 30.0 * 14.4);
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_1.period, 60.0);
//
// current overload level 2 130% 10s
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_2.level, 30.0 * 15.6);//30.0*15.6
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_2.period, 10.0);
//
// current overload level 3 150% 1ms
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_3.level, 30.0 * 18.0);
add_float( 0, &sys_config->phase_alert_monitor.current_overload_level_3.period, 0.004);
//
// current invertor overload level 1 110% 60s
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_1.level, 13.2);
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_1.period, 60.0);
//
// current invertor overload level 2 130% 10s
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_2.level, 15.6);
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_2.period, 10.0);
//
// current invertor overload level 3 150% 1ms
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_3.level, 18.0);
add_float( 0, &sys_config->phase_alert_monitor.current_invertor_overload_level_3.period, 0.004);
//
// current input overload level 1 110% 60s
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_1.level, 99.0);
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_1.period, 60.0);
//
// current input overload level 2 130% 10s
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_2.level, 117.0);
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_2.period, 10.0);
//
// current input overload level 3 150% 1ms
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_3.level, 135.0);
add_float( 0, &sys_config->phase_alert_monitor.current_input_overload_level_3.period, 0.004);
//<>
//
// DIGITAL INPUTS
//
add_float( 0, &sys_config->digital_input_config.period, 50.0e-3); //3001 - 3020
//<>
//
// FAN CONTROL
//
add_float( 0, &sys_config->fan_control.timer_period, 5.0*60.0);
//<>
//
// Generator ABC
//
add_float( 0, &sys_config->generator_abc.amplitude, 1.0);
add_float( 0, &sys_config->generator_abc.frequency, 2.0*FP_PI*50.0);
add_float( 0, &sys_config->generator_abc.phase_shift, 0.0);
//<>
//
// Reference PWM-Generator
//
//add_float( 0, &sys_config->generator_pwm.frequency, 2.0*FP_PI*1.0);
//add_float( 0, &sys_config->generator_abc.phase_shift, 0.0);
//add_float( 0, &sys_config->gen_inp_volt.amplitude.direct.d, 220.0);
//
//add_float( 0, &sys_config->gen_out_volt.amplitude.direct.d, 220.0);
//add_float( 0, &sys_config->gen_out_volt.phase.direct.phase, 0.122756);//FP_PI/4.0);
//
//add_float( 0, &sys_config->gen_out_current.amplitude.direct.d, 50.0);
//add_float( 0, &sys_config->gen_out_current.phase.direct.phase, 0.122756);//FP_PI/3.0;
//<>
//
// AlgorithmGeneratorReferences
//
add_float( 0, &sys_config->algorithm_source_references.voltage, 0.0);
add_float( 0, &sys_config->algorithm_source_references.phase_shift, 0.0);
//
// Harmonica Analyzer
//
add_float( 0, &sys_config->ph_harmonica_5.time, 50.0e-3);
add_float( 0, &sys_config->ph_harmonica_5.a3, 2.61313);
add_float( 0, &sys_config->ph_harmonica_5.a2, 3.41422);
add_float( 0, &sys_config->ph_harmonica_5.a1, 2.61313);
//<>
//
// Reference Intensity Idref Iqref in Start Mode
//
add_float( 0, &sys_config->intensity_id_iq_references.damp_factor, 0.7071);
add_float( 0, &sys_config->intensity_id_iq_references.time, 20.0e-3);
//<>
//
// Regulators
//
#if TYPECONTROL == VECTORCONTROL
//
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_PII
add_float( 0, &sys_config->regulator_voltage_load_dq.gain, 1.0);
add_float( 0, &sys_config->regulator_voltage_load_dq.time, 1.6e-3);
add_float( 0, &sys_config->regulator_voltage_load_dq.high_saturation, 4500.0);
add_float( 0, &sys_config->regulator_voltage_load_dq.low_saturation, -4500.0);
//
add_float( 0, &sys_config->integrator_voltage_dq.time, 2.0e-3);
add_float( 0, &sys_config->integrator_voltage_dq.high_saturation, 4500.0);
add_float( 0, &sys_config->integrator_voltage_dq.low_saturation, -4500.0);
//
add_float( 0, &sys_config->reference_voltage_dq_intensity.time, 200.0e-3);
//
#endif
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_I
add_float( 0, &sys_config->regulator_voltage_load_dq.gain, 0.4);
add_float( 0, &sys_config->regulator_voltage_load_dq.time, 1600.0e-6);
add_float( 0, &sys_config->regulator_voltage_load_dq.high_saturation, 4500.0);
add_float( 0, &sys_config->regulator_voltage_load_dq.low_saturation, -4500.0);
//
add_float( 0, &sys_config->integrator_voltage_dq.time, 4.0e-3); // 4.0e-3 for single winding; 2.0e-3 for double winding
add_float( 0, &sys_config->integrator_voltage_dq.high_saturation, 4500.0);
add_float( 0, &sys_config->integrator_voltage_dq.low_saturation, -4500.0);
//
add_float( 0, &sys_config->reference_voltage_dq_intensity.time, 200.0e-3);
//
#endif
//
//add_float( 0, &sys_config->regulator_current_limit.gain, 1.0);
add_float( 0, &sys_config->regulator_current_limit.time, 140.0e-3);
add_float( 0, &sys_config->regulator_current_limit.high_saturation, REGULATOR_CURRENT_LIMIT_HIGH_SATURATION);
add_float( 0, &sys_config->regulator_current_limit.low_saturation, REGULATOR_CURRENT_LIMIT_LOW_SATURATION);
//
add_float( 0, &sys_config->regulator_current_pfc.gain, 0.25);
add_float( 0, &sys_config->regulator_current_pfc.time, 800.0e-3);
add_float( 0, &sys_config->regulator_current_pfc.high_saturation, REGULATOR_CURRENT_PFC_HIGH_SATURATION);
add_float( 0, &sys_config->regulator_current_pfc.low_saturation, REGULATOR_CURRENT_PFC_LOW_SATURATION);
//
#if TYPECURRENTCONTROLLER == CURRENTCONTROLLER_PI
add_float( 0, &sys_config->regulator_current_load_dq.gain, 8.0); // 4.0 for single winding; 8.0 for double winding
add_float( 0, &sys_config->regulator_current_load_dq.time, 6.4e-3);
add_float( 0, &sys_config->regulator_current_load_dq.high_saturation, 500.0);
add_float( 0, &sys_config->regulator_current_load_dq.low_saturation, -500.0);
#endif
#if TYPECURRENTCONTROLLER == CURRENTCONTROLLER_P
add_float( 0, &sys_config->regulator_current_load_dq.gain, 8.0);
add_float( 0, &sys_config->regulator_current_load_dq.high_saturation, 500.0);
add_float( 0, &sys_config->regulator_current_load_dq.low_saturation, -500.0);
#endif
//
add_float( 0, &sys_config->referencer_current_bypass_dq.time, 25.6e-3);
add_float( 0, &sys_config->referencer_current_bypass_dq.high_saturation, 240.0);
add_float( 0, &sys_config->referencer_current_bypass_dq.low_saturation, -240.0);
//
#endif
#if TYPECONTROL == SCALARCONTROL
add_float( 0, &sys_config->regulator_voltage_load_active_reactive.gain, 0.04);
add_float( 0, &sys_config->regulator_voltage_load_active_reactive.time, 10.0e-3);
add_float( 0, &sys_config->regulator_voltage_load_active_reactive.high_saturation, 4500.0);
add_float( 0, &sys_config->regulator_voltage_load_active_reactive.low_saturation, -4500.0);
//
add_float( 0, &sys_config->regulator_current_limit.gain, 1.0);
add_float( 0, &sys_config->regulator_current_limit.time, 5.0);
add_float( 0, &sys_config->regulator_current_limit.high_saturation, GRID_VOLTAGE_REFERENCE * 0.57735);
add_float( 0, &sys_config->regulator_current_limit.low_saturation, FP_ZERO);
//
add_float( 0, &sys_config->regulator_current_pfc.gain, 0.25);
add_float( 0, &sys_config->regulator_current_pfc.time, 800.0e-3);
add_float( 0, &sys_config->regulator_current_pfc.high_saturation, GRID_VOLTAGE_REFERENCE * 0.57735);
add_float( 0, &sys_config->regulator_current_pfc.low_saturation, -GRID_VOLTAGE_REFERENCE * 0.57735);
//
add_float( 0, &sys_config->current_regulator_active.gain, 0.17); // 0.34 for single winding
add_float( 0, &sys_config->current_regulator_active.time, 0.04);
add_float( 0, &sys_config->current_regulator_active.high_saturation, 500.0);
add_float( 0, &sys_config->current_regulator_active.low_saturation, -500.0);
//
add_float( 0, &sys_config->current_regulator_reactive.gain, 0.17); // 0.34 for single winding
add_float( 0, &sys_config->current_regulator_reactive.time, 0.04);
add_float( 0, &sys_config->current_regulator_reactive.high_saturation, 500.0);
add_float( 0, &sys_config->current_regulator_reactive.low_saturation, -500.0);
//
add_float( 0, &sys_config->current_referencer.gain, 1.0);
add_float( 0, &sys_config->current_referencer.time, 0.160);
add_float( 0, &sys_config->current_referencer.high_saturation, 20.0);
add_float( 0, &sys_config->current_referencer.low_saturation, -20.0);
//
add_float( 0, &sys_config->regulator_dc_voltage.gain, 0.05);
add_float( 0, &sys_config->regulator_dc_voltage.time, 800.0e-3);
add_float( 0, &sys_config->regulator_dc_voltage.high_saturation, FP_ZERO);
add_float( 0, &sys_config->regulator_dc_voltage.low_saturation, -GRID_VOLTAGE_REFERENCE * 0.57735);
#endif
//<>
#if TYPECONTROL == DIRECTREVERSECONTROL
//
add_float( 0, &sys_config->drc_voltage_decomposer.filter.time, 31.83e-3); //31.83e-3//6.366e-3//3.183e-3
//
add_float( 0, &sys_config->drc_voltage_controller.gain, 0.4); //0.4 - for single winding; 0.7958 - for double winding. //7.958//1.592//0.7958
add_float( 0, &sys_config->drc_voltage_controller.time, 3.2e-3); //31.83e-3//6.366e-3//3.183e-3
add_float( 0, &sys_config->drc_voltage_controller.high_saturation, 4500.0);
add_float( 0, &sys_config->drc_voltage_controller.low_saturation, -4500.0);
//
add_float( 0, &sys_config->drc_reference_voltage_direct_intensity.time, 333.0e-3);
add_float( 0, &sys_config->drc_reference_voltage_direct_intensity.damp_factor, 0.9);
//
add_float( 0, &sys_config->drc_regulator_current_load.gain, 4.0);// 4.0 - for single winding; 8.0 - for double winding
add_float( 0, &sys_config->drc_regulator_current_load.time, 6.4e-3);
add_float( 0, &sys_config->drc_regulator_current_load.high_saturation, 500.0);
add_float( 0, &sys_config->drc_regulator_current_load.low_saturation, -500.0);
//
add_float( 0, &sys_config->drc_referencer_current_bypass.time, 25.6e-3);
add_float( 0, &sys_config->drc_referencer_current_bypass.high_saturation, 240.0);
add_float( 0, &sys_config->drc_referencer_current_bypass.low_saturation, -240.0);
//
add_float( 0, &sys_config->drc_regulator_current_limit.time, 140.0e-3);
add_float( 0, &sys_config->drc_regulator_current_limit.high_saturation, REGULATOR_CURRENT_LIMIT_HIGH_SATURATION);
add_float( 0, &sys_config->drc_regulator_current_limit.low_saturation, REGULATOR_CURRENT_LIMIT_LOW_SATURATION);
//
add_float( 0, &sys_config->drc_regulator_current_pfc.gain, 0.25);
add_float( 0, &sys_config->drc_regulator_current_pfc.time, 800.0e-3);
add_float( 0, &sys_config->drc_regulator_current_pfc.high_saturation, REGULATOR_CURRENT_PFC_HIGH_SATURATION);
add_float( 0, &sys_config->drc_regulator_current_pfc.low_saturation, REGULATOR_CURRENT_PFC_LOW_SATURATION);
//
#endif
//<>
//
// Timers
//
add_float( 0, &sys_config->timer_start.period, 5.0);
add_float( 0, &sys_config->timer_stop.period, 5.0);
//<>
//
// Contactor Control Fault
//
add_float( 0, &sys_config->contactor.period, 0.4);
}//
} /* namespace FRAM */

@ -0,0 +1,439 @@
/*
* FRAMDATABASE.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/FRAMDATABASE.h"
namespace FRAM
{
FRAMDATABASE::FRAMDATABASE():
m_mode(),
m_state(),
m_fram_data_buffer(),
m_buffer_pointer((uint16_t*)&m_fram_data_buffer),
m_fram_object(),
m_fram_size(FRAM_FRAM_SIZE),
m_fram_object_index(0),
m_fram_object_address(0),
m_fram_object_last_address(0),
m_fram_rw_index(0),
m_header(),
m_footer(),
m_verify(false)
{
m_header.class_id = HEADER_CLASS_ID;
m_header.part_id = HEADER_PART_ID;
m_header.software_version = HEADER_SOFTWARE_VERSION;
m_header.size_of_fram_data = sizeof(m_fram_data_buffer);
m_footer.foot = FOOTER_FOOT;
}
//
FRAM::FRAMDATABASE::mode_t FRAMDATABASE::get_mode()
{
return m_mode;
//
}//
//
bool FRAMDATABASE::compare_mode(FRAM::FRAMDATABASE::mode_t mode)
{
return mode == m_mode;
//
}//
//
FRAM::FRAMDATABASE::state_t FRAMDATABASE::get_state()
{
return m_state;
//
}//
//
bool FRAMDATABASE::compare_state(FRAM::FRAMDATABASE::state_t state)
{
return state == m_state;
//
}//
//
bool FRAMDATABASE::is_free()
{
return m_state == FRAM::FRAMDATABASE::FREE;
}//
//
bool FRAMDATABASE::is_busy()
{
return m_state == FRAM::FRAMDATABASE::BUSY;
}//
//
bool FRAMDATABASE::is_read()
{
return m_mode == FRAM::FRAMDATABASE::READ;
}//
//
bool FRAMDATABASE::is_burn()
{
return m_mode == FRAM::FRAMDATABASE::BURN;
}//
//
bool FRAMDATABASE::is_erase()
{
return m_mode == FRAM::FRAMDATABASE::ERASE;
}//
//
bool FRAMDATABASE::is_restore()
{
return m_mode == FRAM::FRAMDATABASE::RESTORE;
}//
//
bool FRAMDATABASE::is_verify()
{
return m_mode == FRAM::FRAMDATABASE::VERIFY;
}//
//
void FRAMDATABASE::set_read()
{
m_state = FRAM::FRAMDATABASE::BUSY;
m_mode = FRAM::FRAMDATABASE::READ;
m_fram_rw_index = 0;
//
}//
//
void FRAMDATABASE::set_burn()
{
m_state = FRAM::FRAMDATABASE::BUSY;
m_mode = FRAM::FRAMDATABASE::BURN;
m_fram_rw_index = 0;
//
}//
//
void FRAMDATABASE::set_erase()
{
m_state = FRAM::FRAMDATABASE::BUSY;
m_mode = FRAM::FRAMDATABASE::ERASE;
m_fram_rw_index = 0;
//
}//
//
void FRAMDATABASE::set_verify()
{
m_state = FRAM::FRAMDATABASE::BUSY;
m_mode = FRAM::FRAMDATABASE::VERIFY;
m_fram_rw_index = 0;
//
}//
//
void FRAMDATABASE::set_restore()
{
m_state = FRAM::FRAMDATABASE::BUSY;
m_mode = FRAM::FRAMDATABASE::RESTORE;
m_fram_rw_index = 0;
//
}//
//
void FRAMDATABASE::set_break()
{
m_state = FRAM::FRAMDATABASE::FREE;
m_mode = FRAM::FRAMDATABASE::WAIT;
m_fram_rw_index = 0;
//
}//
//
FRAM::FRAMHeader FRAMDATABASE::get_header()
{
return m_header;
//
}//
//
FRAM::FRAMFooter FRAMDATABASE::get_footer()
{
return m_footer;
//
}//
//
void FRAMDATABASE::extract_system_configuration(SYSCTRL::SystemControlConfiguration *sys_config)
{
m_fram_data_buffer.extract_system_configuration(*sys_config);
//
}//
//
void FRAMDATABASE::implement_dafault_configuration()
{
for(uint16_t i = 0; i < m_fram_object_index; i++)
{
FRAM::FRAMDataObjects& o = m_fram_object[i];
o.restore_default_value();
//
}//for
//
}//
//
void FRAMDATABASE::upload_configuration(SYSCTRL::SystemControlConfiguration *sys_config)
{
register_configuration_parameters(sys_config);
//implement_dafault_configuration();
read_from_fram_to_buffer();
m_verify = m_fram_data_buffer.verify_header_and_footer(m_header, m_footer);
//m_verify = false;
if(m_verify)
{
extract_system_configuration(sys_config);
}
else
{
erase_fram_buffer();
implement_dafault_configuration();
m_fram_data_buffer.update(m_header, *sys_config, m_footer);
write_to_fram_from_buffer();
//
}//if else
}//
//
void FRAMDATABASE::update_buffer(const SYSCTRL::SystemControlConfiguration *sys_config)
{
m_fram_data_buffer.update(m_header, *sys_config, m_footer);
//
}//
//
void FRAMDATABASE::erase_fram_index()
{
if(m_mode == FRAM::FRAMDATABASE::ERASE)
{
if(m_fram_rw_index < sizeof(m_fram_data_buffer))
{
writeint(0xFFFF, m_fram_rw_index << 1);
m_fram_rw_index++;
}
else
{
set_break();
//
}//if else
}//if
//
}//
//
void FRAMDATABASE::verify_fram_index()
{
if(m_mode == FRAM::FRAMDATABASE::VERIFY)
{
if(m_fram_rw_index < sizeof(m_fram_data_buffer))
{
m_fram_rw_index++;
}
else
{
set_break();
//
}//if else
}//if
//
}//
//
void FRAMDATABASE::write_fram_index()
{
if(m_mode == FRAM::FRAMDATABASE::BURN)
{
if(m_fram_rw_index < sizeof(m_fram_data_buffer))
{
writeint((*(m_buffer_pointer + m_fram_rw_index)), m_fram_rw_index << 1);
m_fram_rw_index++;
}
else
{
set_break();
//
}//if else
}//if
//
}//
//
void FRAMDATABASE::read_fram_index()
{
if(m_mode == FRAM::FRAMDATABASE::READ)
{
if(m_fram_rw_index < sizeof(m_fram_data_buffer))
{
*(m_buffer_pointer + m_fram_rw_index) = readint(m_fram_rw_index << 1);
m_fram_rw_index++;
}
else
{
set_break();
//
}//if else
}//if
//
}//
//
void FRAMDATABASE::restore_fram_index()
{
if(m_mode == FRAM::FRAMDATABASE::RESTORE)
{
if(m_fram_rw_index < sizeof(m_fram_data_buffer))
{
writeint((*(m_buffer_pointer + m_fram_rw_index)), m_fram_rw_index << 1);
m_fram_rw_index++;
}
else
{
set_break();
//
}//if else
}//if
//
}//
//
void FRAMDATABASE::read_from_fram_to_buffer()
{
set_read();
for(m_fram_rw_index = 0; m_fram_rw_index < sizeof(m_fram_data_buffer); m_fram_rw_index++)
{
*(m_buffer_pointer + m_fram_rw_index) = readint(m_fram_rw_index << 1);
//
}//for
//
m_mode = FRAM::FRAMDATABASE::READ;
m_state = FRAMDATABASE::BUSY;
set_break();
//
}//
//
void FRAMDATABASE::write_to_fram_from_buffer()
{
set_burn();
for(m_fram_rw_index = 0; m_fram_rw_index < sizeof(m_fram_data_buffer); m_fram_rw_index++)
{
writeint((*(m_buffer_pointer + m_fram_rw_index)), m_fram_rw_index << 1);
//
}//for
//
set_break();
//
}//
//
void FRAMDATABASE::erase_fram_buffer()
{
set_verify();
for(m_fram_rw_index = 0; m_fram_rw_index < sizeof(m_fram_data_buffer); m_fram_rw_index++)
{
writeint(0xFFFF, m_fram_rw_index << 1);
*(m_buffer_pointer + m_fram_rw_index) = readint(m_fram_rw_index << 1);
//
}//for
//
set_break();
//
}//
//
void FRAMDATABASE::add_float(uint8_t readonly, float* pParam, float default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(float)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_float(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += (sizeof(float) << 1);
m_fram_object_last_address = m_fram_object_address;
//
}//if
//
}//
//
void FRAMDATABASE::add_int16(uint8_t readonly, int16_t* pParam, int16_t default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(uint16_t)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_int16(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += sizeof(int16_t) << 1;
m_fram_object_last_address = m_fram_object_address;
//
}//if
//
}//
//
void FRAMDATABASE::add_int32(uint8_t readonly, int32_t* pParam, int32_t default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(int32_t)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_int32(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += (sizeof(int32_t) << 1);
m_fram_object_last_address = m_fram_object_address;
//
}//if
}//
//
void FRAMDATABASE::add_uint16(uint8_t readonly, uint16_t* pParam, uint16_t default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(uint16_t)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_uint16(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += sizeof(uint16_t) << 1;
m_fram_object_last_address = m_fram_object_address;
//
}//if
//
}//
//
void FRAMDATABASE::add_uint32(uint8_t readonly, uint32_t* pParam, uint32_t default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(uint32_t)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_uint32(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += (sizeof(uint32_t) << 1);
m_fram_object_last_address = m_fram_object_address;
//
}//if
}//
//
void FRAMDATABASE::add_bool(uint8_t readonly, bool* pParam, bool default_value)
{
if((m_fram_object_index < NUMBER_FRAM_PARAMETERS)&&
(((m_fram_object_address + (sizeof(uint16_t)<<1)) < m_fram_size)))
{
FRAM::FRAMDataObjects& object = m_fram_object[m_fram_object_index];
object.add_register_bool(m_fram_object_address, readonly, pParam, default_value);
m_fram_object_index++;
m_fram_object_address += sizeof(int16_t) << 1;
m_fram_object_last_address = m_fram_object_address;
//
}//if
//
}//
//
} /* namespace FRAM */

@ -0,0 +1,101 @@
/*
* FRAMDATABASE.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "FRAM/FRAMDefinitions.h"
#include "FRAM/FRAMBuffer.h"
#include "FRAM/FRAMDataObjects.h"
#include "FRAM/FRAMVariant.h"
#include "SYSCTRL/SystemConfigurator.h"
#include "SYSCTRL/SystemDefinitions.h"
#ifndef FRAM_FRAMDATABASE_H_
#define FRAM_FRAMDATABASE_H_
namespace FRAM
{
class FRAMDATABASE
{
public:
enum mode_t {WAIT, READ, BURN, ERASE, VERIFY, RESTORE};
enum state_t {BUSY, FREE};
private:
mode_t m_mode;
state_t m_state;
private:
FRAM::FRAMBuffer m_fram_data_buffer;
uint16_t *m_buffer_pointer;
FRAM::FRAMDataObjects m_fram_object[NUMBER_FRAM_PARAMETERS];
uint16_t m_fram_size;
uint16_t m_fram_object_index;
uint16_t m_fram_object_address;
uint16_t m_fram_object_last_address;
uint16_t m_fram_rw_index;
FRAM::FRAMHeader m_header;
FRAM::FRAMFooter m_footer;
bool m_verify;
public:
FRAMDATABASE();
public:
mode_t get_mode();
bool compare_mode(mode_t mode);
state_t get_state();
bool compare_state(state_t state);
public:
bool is_free();
bool is_busy();
bool is_read();
bool is_burn();
bool is_erase();
bool is_restore();
bool is_verify();
public:
void set_read();
void set_burn();
void set_erase();
void set_verify();
void set_restore();
void set_break();
public:
void upload_configuration(SYSCTRL::SystemControlConfiguration *sys_config);
void update_buffer(const SYSCTRL::SystemControlConfiguration *sys_config);
void erase_fram_index();
void verify_fram_index();
void write_fram_index();
void read_fram_index();
void restore_fram_index();
void read_from_fram_to_buffer();
void write_to_fram_from_buffer();
void erase_fram_buffer();
public:
FRAM::FRAMHeader get_header();
FRAM::FRAMFooter get_footer();
void extract_system_configuration(SYSCTRL::SystemControlConfiguration *sys_config);
void implement_dafault_configuration();
//
//
private:
void add_float(uint8_t readonly, float* pParam, float default_value);
void add_int16(uint8_t readonly, int16_t* pParam, int16_t default_value);
void add_int32(uint8_t readonly, int32_t* pParam, int32_t default_value);
void add_uint16(uint8_t readonly, uint16_t* pParam, uint16_t default_value);
void add_uint32(uint8_t readonly, uint32_t* pParam, uint32_t default_value);
void add_bool(uint8_t readonly, bool* pParam, bool default_value);
public:
void register_configuration_parameters(SYSCTRL::SystemControlConfiguration *sys_config);
};//class FRAMDATABASE
} /* namespace FRAM */
#endif /* FRAM_FRAMDATABASE_H_ */

@ -0,0 +1,201 @@
/*
* FRAMDataObjects.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/FRAMDataObjects.h"
namespace FRAM
{
FRAMDataObjects::FRAMDataObjects():
m_address(0),
m_is_read_only(false),
m_pParam(0),
m_default_value()
//
{}//CONSTRUCTOR
//
void FRAMDataObjects::restore_default_value()
{
if(m_pParam != 0)
{
switch(m_default_value.get_type())
{
case FRAM::FRAM_VARIANT_FLOAT: { *((float*) m_pParam) = m_default_value.get_float(); break;}
case FRAM::FRAM_VARIANT_INT16: { *((int16_t*) m_pParam) = m_default_value.get_int16(); break;}
case FRAM::FRAM_VARIANT_INT32: { *((int32_t*) m_pParam) = m_default_value.get_int32(); break;}
case FRAM::FRAM_VARIANT_UINT16: { *((uint16_t*) m_pParam) = m_default_value.get_uint16(); break;}
case FRAM::FRAM_VARIANT_UINT32: { *((uint32_t*) m_pParam) = m_default_value.get_uint32(); break;}
case FRAM::FRAM_VARIANT_BOOL: { *((bool*) m_pParam) = m_default_value.get_bool(); break;}
default: {break;}
}//switch
}//if
}//
//
void FRAMDataObjects::add_register_float(uint16_t address, uint8_t readonly, float* pParam, float default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_float(default_value);
//
}//
//
void FRAMDataObjects::add_register_int16(uint16_t address, uint8_t readonly, int16_t* pParam, int16_t default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_int16(default_value);
//
}//
//
void FRAMDataObjects::add_register_int32(uint16_t address, uint8_t readonly, int32_t* pParam, int32_t default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_int32(default_value);
//
}//
//
void FRAMDataObjects::add_register_uint16(uint16_t address, uint8_t readonly, uint16_t* pParam, uint16_t default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_uint16(default_value);
//
}//
//
void FRAMDataObjects::add_register_uint32(uint16_t address, uint8_t readonly, uint32_t* pParam, uint32_t default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_uint32(default_value);
//
}//
//
void FRAMDataObjects::add_register_bool(uint16_t address, uint8_t readonly, bool* pParam, bool default_value)
{
m_address = address;
m_is_read_only = 0 != readonly ? true : false;
m_pParam = pParam;
m_default_value.set_bool(default_value);
//
}//
//
uint16_t FRAMDataObjects::get_address() const
{
return m_address;
//
}//
//
void FRAMDataObjects::write_parameter(const void *pBuffer, uint8_t buffer_size)
{
if((m_pParam != 0)&&
(pBuffer != 0) &&
(buffer_size > 0) &&
(m_is_read_only != true))
{
switch(m_default_value.get_type())
{
case FRAM::FRAM_VARIANT_FLOAT: { if(4 == buffer_size) *((float*) m_pParam) = *((float*) pBuffer); break;}
case FRAM::FRAM_VARIANT_INT16: { if(2 == buffer_size) *((int16_t*) m_pParam) = *((int16_t*) pBuffer); break;}
default: {break;}
}//switch
//
}//if
//
}//
//
void FRAMDataObjects::read_parameter(void *pBuffer, uint8_t buffer_size) const
{
if((m_pParam != 0) &&
(pBuffer != 0) &&
(buffer_size > 0))
{
switch(m_default_value.get_type())
{
case FRAM::FRAM_VARIANT_FLOAT: {if(4 == buffer_size) *((float*) pBuffer) = *((float*) m_pParam); break;}
case FRAM::FRAM_VARIANT_INT16: {if(2 == buffer_size) *((int16_t*) pBuffer) = *((int16_t*) m_pParam); break;}
default: {break;}
}//switch
//
}//if
}//
void FRAMDataObjects::fram_write_parameter()
{
if(m_pParam != 0)
{
switch(m_default_value.get_type())
{
case FRAM::FRAM_VARIANT_FLOAT:
{
writefloat(*((float*) m_pParam), m_address);
break;
}
case FRAM::FRAM_VARIANT_INT16:
{
writeint(*((int16_t*) m_pParam), m_address);
break;
}
default: {break;}
}//switch
//
}//if
}//
//
void FRAMDataObjects::fram_read_parameter()
{
if(m_pParam != 0)
{
switch(m_default_value.get_type())
{
case FRAM::FRAM_VARIANT_FLOAT:
{
*((float*) m_pParam) = readfloat(m_address);
break;
}
case FRAM::FRAM_VARIANT_INT16:
{
*((int16_t*) m_pParam) = readint(m_address);
break;
}
default: {break;}
}//switch
//
}//if
//
}//
//
void FRAMDataObjects::write_to_fram_data(Uint16 *Dest, Uint32 Length)
{
for(Uint16 i = 0; i < Length; i++)
{
writeint((*Dest++),i);
//
}//for
//
}//
//
void FRAMDataObjects::read_from_fram_data(Uint16 *BuffAddr, Uint32 Length)
{
for(Uint16 i = 0; i < Length; i++)
{
(*BuffAddr++) = readint(i);
//
}//for
//
}//
//
//
} /* namespace FRAM */

@ -0,0 +1,49 @@
/*
* FRAMACCESS.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <stdint.h>
#include "framework.h"
#include "FRAM/FRAMVariant.h"
#ifndef FRAM_FRAMDATAOBJECTS_H_
#define FRAM_FRAMDATAOBJECTS_H_
namespace FRAM
{
class FRAMDataObjects
{
private:
uint16_t m_address;
bool m_is_read_only;
void* m_pParam;
FRAM::FRAMVariant m_default_value;
public:
FRAMDataObjects();
void restore_default_value();
void add_register_float(uint16_t address, uint8_t readonly, float* pParam, float default_value);
void add_register_int16(uint16_t address, uint8_t readonly, int16_t* pParam, int16_t default_value);
void add_register_int32(uint16_t address, uint8_t readonly, int32_t* pParam, int32_t default_value);
void add_register_uint16(uint16_t address, uint8_t readonly, uint16_t* pParam, uint16_t default_value);
void add_register_uint32(uint16_t address, uint8_t readonly, uint32_t* pParam, uint32_t default_value);
void add_register_bool(uint16_t address, uint8_t readonly, bool* pParam, bool default_value);
public:
uint16_t get_address() const;
void write_parameter(const void *pBuffer, uint8_t buffer_size);
void read_parameter(void *pBuffer, uint8_t buffer_size) const;
public:
void fram_write_parameter();
void fram_read_parameter();
public:
void write_to_fram_data(Uint16 *Dest, Uint32 Length);
void read_from_fram_data(Uint16 *BufAddr, Uint32 Length);
};
} /* namespace FRAM */
#endif /* FRAM_FRAMDATAOBJECTS_H_ */

@ -0,0 +1,19 @@
/*
* FRAMDefinitions.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef FRAM_FRAMDEFINITIONS_H_
#define FRAM_FRAMDEFINITIONS_H_
namespace FRAM
{
//
//
#define FRAM_FRAM_SIZE ((uint16_t)(8192))
//
} /* namespace FRAM */
#endif /* FRAM_FRAMDEFINITIONS_H_ */

@ -0,0 +1,112 @@
/*
* FRAMVariant.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/FRAMVariant.h"
namespace FRAM
{
//CONSTRUCTOR
FRAMVariant::FRAMVariant():
t(FRAM::FRAM_VARIANT_UNDEFINED),
f(0)
//
{}//CONSTRUCTOR
//
FRAM::fram_variant_type_t FRAMVariant::get_type() const
{
return t;
//
}//
//
void FRAMVariant::set_float(float v)
{
f = v;
t = FRAM::FRAM_VARIANT_FLOAT;
//
}//
//
void FRAMVariant::set_int16(int16_t v)
{
i16 = v;
t = FRAM::FRAM_VARIANT_INT16;
//
}//
//
void FRAMVariant::set_int32(int32_t v)
{
i32 = v;
t = FRAM::FRAM_VARIANT_INT32;
//
}//
//
void FRAMVariant::set_uint16(uint16_t v)
{
u16 = v;
t = FRAM::FRAM_VARIANT_UINT16;
//
}//
//
void FRAMVariant::set_uint32(uint32_t v)
{
u32 = v;
t = FRAM::FRAM_VARIANT_UINT32;
//
}//
//
void FRAMVariant::set_bool(bool v)
{
b = v;
t = FRAM::FRAM_VARIANT_BOOL;
//
}//
//
float FRAMVariant::get_float() const
{
return f;
//
}//
//
int16_t FRAMVariant::get_int16() const
{
return i16;
//
}//
//
int32_t FRAMVariant::get_int32() const
{
return i32;
//
}//
//
uint16_t FRAMVariant::get_uint16() const
{
return u16;
//
}//
//
uint32_t FRAMVariant::get_uint32() const
{
return u32;
//
}//
//
bool FRAMVariant::get_bool() const
{
return b;
}//
//
}/* namespace FRAM */

@ -0,0 +1,60 @@
/*
* FRAMVariant.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <stdint.h>
#include "SYSCTRL/SystemDefinitions.h"
#ifndef FRAM_FRAMVARIANT_H_
#define FRAM_FRAMVARIANT_H_
namespace FRAM
{
typedef unsigned char uint8_t;
enum fram_variant_type_t {FRAM_VARIANT_UNDEFINED, FRAM_VARIANT_FLOAT, FRAM_VARIANT_INT16, FRAM_VARIANT_INT32, FRAM_VARIANT_UINT16, FRAM_VARIANT_UINT32, FRAM_VARIANT_BOOL};
class FRAMVariant
{
private:
union
{
float f;
int16_t i16;
int32_t i32;
uint16_t u16;
uint32_t u32;
bool b;
SYSCTRL::Register16 r16;
SYSCTRL::Register32 r32;
};
private:
fram_variant_type_t t;
public:
FRAMVariant();
fram_variant_type_t get_type() const;
//setters
void set_float(float v);
void set_int16(int16_t v);
void set_int32(int32_t v);
void set_uint16(uint16_t v);
void set_uint32(uint32_t v);
void set_bool(bool v);
//getters
float get_float() const;
int16_t get_int16() const;
int32_t get_int32() const;
uint16_t get_uint16() const;
uint32_t get_uint32() const;
bool get_bool() const;
//
};//class fram_variant_t
//
}/* namespace FRAM */
#endif /* FRAM_FRAMVARIANT_H_ */

@ -0,0 +1,18 @@
/*
* FRAMheaders.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef FRAM_FRAMHEADERS_H_
#define FRAM_FRAMHEADERS_H_
#include "FRAM/FRAMBuffer.h"
#include "FRAM/FRAMDATABASE.h"
#include "FRAM/FRAMDataObjects.h"
#include "FRAM/FRAMVariant.h"
#endif /* FRAM_FRAMHEADERS_H_ */

@ -0,0 +1,132 @@
/*
* ROM.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "FRAM/ROM.h"
namespace FRAM
{
//CONSTRUCTOR
ROM::ROM():
m_mode(FRAM::ROM::UNDEFINED),
m_header(),
m_footer(),
m_int_last_address(0),
m_flt_last_address(0),
_write_float(&FRAM::ROM::_write_float_undef),
_read_float(&FRAM::ROM::_read_float_undef),
_write_int(&FRAM::ROM::_write_int_undef),
_read_int(&FRAM::ROM::_read_int_undef)
{}
//CONSTRUCTOR
//
void ROM::setup(const ROMSetup setup)
{
static bool _status = true;
if(m_mode == FRAM::ROM::UNDEFINED)
{
m_header = setup.header;
m_footer = setup.footer;
//
_status &= m_header.class_id != 0 ? true : false;
_status &= m_header.part_id != 0 ? true : false;
_status &= m_header.rom_size != 0 ? true : false;
_status &= m_header.software_version != 0 ? true : false;
_status &= m_footer.magic != 0 ? true : false;
//
if(_status)
{
m_mode = FRAM::ROM::OPERATIONAL;
//
_write_float = &FRAM::ROM::_write_float_undef;
_read_float = &FRAM::ROM::_read_float_undef;
_write_int = &FRAM::ROM::_write_int_undef;
_read_int = &FRAM::ROM::_read_int_undef;
//
}//if
//
}//if
//
}//
//
FRAM::ROM::mode_t ROM::get_mode()
{
return m_mode;
//
}//
//
bool ROM::compare(FRAM::ROM::mode_t mode)
{
return m_mode == mode;
//
}//
//
void ROM::write_float(float data, int16_t addr)
{
(this->*_write_float)(data, addr);
//
}//
//
float ROM::read_float(int16_t addr)
{
return (this->*_read_float)(addr);
//
}//
//
void ROM::write_int(int16_t data, int16_t addr)
{
(this->*_write_int)(data, addr);
//
}//
//
int16_t ROM::read_int(int16_t addr)
{
return (this->*_read_int)(addr);
//
}//
//
void ROM::_write_float_undef(float data, int16_t addr)
{}//
//
void ROM::_write_float_operate(float data, int16_t addr)
{
writefloat(data, addr);
//
}//
//
float ROM::_read_float_undef(int16_t addr)
{
return (float)0.0;
}//
//
float ROM::_read_float_operate(int16_t addr)
{
return readfloat(addr);
//
}//
//
void ROM::_write_int_undef(int16_t data, int16_t addr)
{}//
//
void ROM::_write_int_operate(int16_t data, int16_t addr)
{
writeint(data, addr);
//
}//
//
int16_t ROM::_read_int_undef(int16_t addr)
{
return 0;
}//
//
int16_t ROM::_read_int_operate(int16_t addr)
{
return readint(addr);
//
}//
//
} /* namespace FRAM */

@ -0,0 +1,97 @@
/*
* ROM.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "framework.h"
#ifndef FRAM_ROM_H_
#define FRAM_ROM_H_
namespace FRAM
{
struct ROMHeader
{
uint16_t class_id;
uint16_t part_id;
uint16_t software_version;
uint16_t rom_size;
ROMHeader():
class_id(0),
part_id(0),
software_version(0),
rom_size(0)
{}
};//ROMHeader
struct ROMFooter
{
uint16_t magic;
ROMFooter():
magic(0)
{}
};//ROMFooter
struct ROMSetup
{
ROMHeader header;
ROMFooter footer;
ROMSetup():
header(),
footer()
{}
};//ROMSetup
class ROM
{
public:
enum mode_t {UNDEFINED, OPERATIONAL};
private:
mode_t m_mode;
private:
ROMHeader m_header;
ROMFooter m_footer;
uint16_t m_int_last_address;
uint16_t m_flt_last_address;
public:
ROM();
void setup(const ROMSetup setup);
public:
mode_t get_mode();
bool compare(mode_t mode);
public:
void write_float(float data, int16_t addr);
float read_float(int16_t addr);
void write_int(int16_t data, int16_t addr);
int16_t read_int(int16_t addr);
private:
void (ROM::*_write_float)(float data, int16_t addr);
void _write_float_undef(float data, int16_t addr);
void _write_float_operate(float data, int16_t addr);
private:
float (ROM::*_read_float)(int16_t addr);
float _read_float_undef(int16_t addr);
float _read_float_operate(int16_t addr);
private:
void (ROM::*_write_int)(int16_t data, int16_t addr);
void _write_int_undef(int16_t data, int16_t addr);
void _write_int_operate(int16_t data, int16_t addr);
private:
int16_t (ROM::*_read_int)(int16_t addr);
int16_t _read_int_undef(int16_t addr);
int16_t _read_int_operate(int16_t addr);
//
};// class ROM
} /* namespace FRAM */
#endif /* FRAM_ROM_H_ */

Binary file not shown.

@ -0,0 +1,209 @@
/*****************************************************************************
* File Name:framework.c
* Author:Zhangdi
* Brief:
* Note:
* Last Updated for Version:
* Date of the Last Update:
*****************************************************************************/
#include"framework.h"
/*****************************************************************************
** Constants
*****************************************************************************/
/*****************************************************************************
** Maco Define
*****************************************************************************/
/*****************************************************************************
** Data Type Define
*****************************************************************************/
/*****************************************************************************
** Global Variable Declare
*****************************************************************************/
BaudRate comModbusBaudRateSet;
Uint16 comModbusADDRSet;
ParityMode comModbusParitySet;
Uint16 cpuCpldVersion;
/*****************************************************************************
* Brief: Analog input
* Note:
*****************************************************************************/
AnalogInput analogInput = { 0 };
/*****************************************************************************
* Brief: Analog output
* Note:
*****************************************************************************/
Uint16 a2001_2005 = 0;
Uint16 a2002_2006 = 0;
Uint16 a2003_2007 = 0;
Uint16 a2004_2008 = 0;
/*****************************************************************************
* Brief: Digital input interface
* Note:
*****************************************************************************/
DigitalInput digitalInput = { 0 };
/*****************************************************************************
* Brief: Digital output interface
* Note:
*****************************************************************************/
DigitalOuput digitalOutput = { 0xffff };
/*****************************************************************************
* Brief: modbus output coils buffer
* Note:
*****************************************************************************/
Uint16 readCoils[300] = { 0 };
/*****************************************************************************
* Brief: modbus input coils buffer
* Note:
*****************************************************************************/
Uint16 writeCoils[300] = { 0 };
/*****************************************************************************
* Brief: modbus output registers buffer
* Note:
*****************************************************************************/
Uint16 readRegisters[300] = { 0 };
/*****************************************************************************
* Brief: modbus input registers buffer
* Note:
*****************************************************************************/
Uint16 writeRegisters[300] = { 0 };
/*****************************************************************************
* Brief: Event for modbus state machine
* Note:
*****************************************************************************/
hsmEvent etmp;
/*****************************************************************************
* Brief: modbus object
* Note:
*****************************************************************************/
MODBUS_RTU_SLAVE modbusHMI;
/*****************************************************************************
* Brief: modbus event list
* Note:
*****************************************************************************/
hsmEvent eBufferHMI[50];
/*****************************************************************************
* Brief: modbus port object
* Note:
*****************************************************************************/
MODBUS_RTU_PORT_INFOR modbusHMIPort = { 5, B9600, NO_PARITY,
&(ScibRegs.SCIRXBUF.all), &(ScibRegs.SCITXBUF), 21, &(ScibRegs) };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from cpu to communication
* board.
* Note: These data used for communication board modbus output coils.
*****************************************************************************/
Uint16 canData_cpu2com_coils[16] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from cpu to communication
* board.
* Note: These data used for communication board modbus output registers.
*****************************************************************************/
Uint16 canData_cpu2com_registers[50] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from communication board to
* cpu board.
* Note: These data are input coils data received by communication board modbus.
*****************************************************************************/
Uint16 canData_com2cpu_coils[16] = { 0 };
/*****************************************************************************
* Brief: Ecan data buffer. These data transport from communication board to
* cpu board.
* Note: These data are input registers data received by communication board
* modbus.
*****************************************************************************/
Uint16 canData_com2cpu_registers[50] = { 0 };
/*****************************************************************************
** Global Function Declare
*****************************************************************************/
void frameworkDataInit(void)
{
Uint32 i;
int16 *p;
p = (int16 *)&analogInput;
for(i = 0; i < sizeof(analogInput) / sizeof(int16); i++)
{
p[i] = 0;
}
a2001_2005 = 0;
a2002_2006 = 0;
a2003_2007 = 0;
a2004_2008 = 0;
digitalInput.all = 0xffffffff;
digitalOutput.all = 0xffffffff;
p = (int16 *)readCoils;
for(i = 0; i < sizeof(readCoils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)writeCoils;
for(i = 0; i < sizeof(writeCoils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)readRegisters;
for(i = 0; i < sizeof(readRegisters) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)writeRegisters;
for(i = 0; i < sizeof(writeRegisters) / sizeof(Uint16); i++)
{
p[i] = 0;
}
etmp.signal = 0;
p = (int16 *)canData_cpu2com_coils;
for(i = 0; i < sizeof(canData_cpu2com_coils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_cpu2com_registers;
for(i = 0; i < sizeof(canData_cpu2com_registers) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_com2cpu_coils;
for(i = 0; i < sizeof(canData_com2cpu_coils) / sizeof(Uint16); i++)
{
p[i] = 0;
}
p = (int16 *)canData_com2cpu_registers;
for(i = 0; i < sizeof(canData_com2cpu_registers) / sizeof(Uint16); i++)
{
p[i] = 0;
}
}
/*****************************************************************************
** Local Function Declare
*****************************************************************************/

@ -0,0 +1,33 @@
/*
* HALBase.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "HAL/HALBase.h"
namespace HAL
{
//CONSTRUCTOR
HALBase::HALBase():
m_mode(HAL::HALBase::UNDEFINED),
m_status(false)
//
{}//end CONSTRUCTOR
//
HAL::HALBase::mode_t HAL::HALBase::get_mode() const
{
return m_mode;
//
}//end
//
bool HAL::HALBase::compare(HAL::HALBase::mode_t mode) const
{
return m_mode == mode;
//
}//end
//
} /* namespace HAL */

@ -0,0 +1,48 @@
/*
* HALBase.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
//
#include "F28335/DSP28x_Project.h"
#ifndef HAL_HALVIRTUAL_H_
#define HAL_HALVIRTUAL_H_
namespace HAL
{
typedef void (*pGPIO_FUNCTION)();
struct HALSetup
{
pGPIO_FUNCTION gpio_setup;
HALSetup():
gpio_setup(0)
{}
};//HALSetup
class HALBase
{
public:
enum mode_t {UNDEFINED=0, OPERATIONAL=1};
protected:
mode_t m_mode;
bool m_status;
public:
HALBase();
public:
mode_t get_mode() const;
bool compare(mode_t mode) const;
//
};//end class HALVirtual
} /* namespace HAL */
#endif /* HAL_HALVIRTUAL_H_ */

@ -0,0 +1,28 @@
/*
* RUBUS.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "MODBUSRTU/RUBUS.h"
namespace MODBUSRTU
{
//CONSTRUCTOR
RUBUS::RUBUS(uint16_t len):
mode(MODBUSRTU::RUBUS::RUBUS_RESET),
size(len),
accepted(),
response_shadow(),
response(),
mask(),
m_cell(),
cell_data(0)
//
{}//CONSTRUCTOR
//
//
//
} /* namespace MODBUSRTU */

@ -0,0 +1,103 @@
/*
* RUBUS.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUS_H_
#define MODBUSRTU_RUBUS_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "SYSCTRL/SystemEnvironment.h"
#include "MODBUSRTU/RUBUSRegister.h"
#include "MODBUSRTU/RUBUSTypes.h"
namespace MODBUSRTU
{
struct RUBUS_ACCEPTED_DATA
{
RUBUS_REGISTER_16 command_start;
RUBUS_REGISTER_16 command_end;
uint16_t index;
RUBUS_REGISTER_16 id;
RUBUS_REGISTER_16 com;
RUBUS_REGISTER_32 data;
RUBUS_ACCEPTED_DATA():
command_start(0),
command_end(0),
index(0),
id(0),
com(0),
data(0)
{}
};//RUBUS_ACCEPTED_DATA
struct RUBUS_MASK
{
RUBUS_REGISTER_16 error_response;
RUBUS_REGISTER_16 rubus_bool;
RUBUS_REGISTER_16 rubus_float;
RUBUS_REGISTER_16 rubus_uint8;
RUBUS_REGISTER_16 rubus_uint16;
RUBUS_REGISTER_16 rubus_uint32;
RUBUS_REGISTER_16 rubus_int8;
RUBUS_REGISTER_16 rubus_int16;
RUBUS_REGISTER_16 rubus_int32;
RUBUS_MASK():
error_response(0x80),
rubus_bool(0x0000),
rubus_float(0x0002),
rubus_uint8(0x0004),
rubus_uint16(0x0006),
rubus_uint32(0x0008),
rubus_int8(0x000A),
rubus_int16(0x00C),
rubus_int32(0x000E)
{}
};//RUBUS_MASK
struct RUBUS_RESPONSE
{
RUBUS_REGISTER_16 command;
uint16_t index;
RUBUS_REGISTER_32 data;
RUBUS_RESPONSE():
command(0),
index(0),
data(0)
{}
};//RUBUS_RESPONSE
struct RUBUS
{
enum mode_rubus_t {RUBUS_RESET, RUBUS_READ, RUBUS_WRITE, RUBUS_ERROR};
mode_rubus_t mode;
uint16_t size;
RUBUS_ACCEPTED_DATA accepted;
RUBUS_RESPONSE response_shadow;
RUBUS_RESPONSE response;
const RUBUS_MASK mask;
MODBUSRTU::RUBUSRegister m_cell;
RUBUS_REGISTER_32 cell_data;
RUBUS(uint16_t size);
};
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUS_H_ */

@ -0,0 +1,19 @@
/*
* RUBUSCOPE.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "MODBUSRTU/RUBUSCOPE.h"
namespace MODBUSRTU
{
//CONSTRUCTOR
RUBUSCOPE::RUBUSCOPE(SYSCTRL::SystemEnvironment& env):
m_env(env),
m_len(RUBUSCOPEARRAYLEN),
m_channels()
{}//CONSTRUCTOR
} /* namespace MODBUSRTU */

@ -0,0 +1,49 @@
/*
* RUBUSCOPE.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUSCOPE_H_
#define MODBUSRTU_RUBUSCOPE_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "SYSCTRL/SystemEnvironment.h"
#include "MODBUSRTU/RUBUSRegister.h"
#include "MODBUSRTU/RUBUSTypes.h"
namespace MODBUSRTU
{
#define RUBUSCOPEARRAYLEN 100
struct RUBUSCOPEVariables
{
uint16_t command;
uint16_t response;
uint16_t channel;
uint16_t pointer;
float data;
RUBUSCOPEVariables(){}
};//RUBUSCOPEVariables
class RUBUSCOPE
{
private:
SYSCTRL::SystemEnvironment& m_env;
uint16_t m_len;
float m_channels[9][RUBUSCOPEARRAYLEN];
public:
RUBUSCOPE(SYSCTRL::SystemEnvironment& env);
};
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUSCOPE_H_ */

@ -0,0 +1,565 @@
/*
* RUBUSDataBase.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "MODBUSRTU/RUBUSDataBase.h"
namespace MODBUSRTU
{
RUBUSDataBase::RUBUSDataBase():
m_cell(),
m_current_index_cell(0),
m_index_cell(0),
m_counter_cell(0),
m_size_cell(NUMBER_RUBUSCELLS)
{}//
void RUBUSDataBase::add_register_bool (uint16_t index, uint16_t readonly, bool* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bool(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_float (uint16_t index, uint16_t readonly, float* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_float(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_uint8 (uint16_t index, uint16_t readonly, uint8_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_uint8(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_uint16(uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_uint16(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_uint32(uint16_t index, uint16_t readonly, uint32_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_uint32(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_int8 (uint16_t index, uint16_t readonly, int8_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_int8(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_int16 (uint16_t index, uint16_t readonly, int16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_int16(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_int32 (uint16_t index, uint16_t readonly, int32_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_int32(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
void RUBUSDataBase::add_register_bit0 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit0(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit1 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit1(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit2 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit2(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit3 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit3(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit4 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit4(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit5 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit5(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit6 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit6(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit7 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit7(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit8 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit8(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit9 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit9(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit10 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit10(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit11 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit11(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit12 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit12(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit13 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit13(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit14 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit14(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit15 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit15(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit16 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit16(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit17 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit17(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit18 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit18(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit19 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit19(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit20 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit20(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit21 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit21(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit22 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit22(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit23 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit23(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit24 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit24(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit25 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit25(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit26 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit26(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit27 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit27(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit28 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit28(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit29 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit29(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit30 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit30(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
void RUBUSDataBase::add_register_bit31 (uint16_t index, uint16_t readonly, uint16_t* param)
{
if(m_counter_cell < m_size_cell)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_counter_cell];
cell.register_bit31(index, readonly, param);
m_counter_cell++;
//
}//if
//
}//
//
//#pragma CODE_SECTION("ramfuncs");
MODBUSRTU::RUBUSRegister& RUBUSDataBase::get_register(uint16_t index)
{
m_current_index_cell = 0;
for(m_index_cell = 0; m_index_cell < m_counter_cell; m_index_cell++)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_index_cell];
if(cell.get_index() == index)
{
m_current_index_cell = m_index_cell;
break;
//
}//if
//
}//for
//
return m_cell[m_current_index_cell];
//
}//
//
//#pragma CODE_SECTION("ramfuncs");
void RUBUSDataBase::read_register(uint16_t index, RUBUS_REGISTER_32& data)
{
m_current_index_cell = 0;
for(m_index_cell = 0; m_index_cell < m_counter_cell; m_index_cell++)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_index_cell];
if(cell.get_index() == index)
{
m_current_index_cell = m_index_cell;
break;
//
}//if
//
}//for
//
data.all = m_cell[m_current_index_cell].read_register().all;
//
}//
//
//#pragma CODE_SECTION("ramfuncs");
uint16_t RUBUSDataBase::write_register(uint16_t index, RUBUS_REGISTER_32 data)
{
m_current_index_cell = 0;
for(m_index_cell = 0; m_index_cell < m_counter_cell; m_index_cell++)
{
MODBUSRTU::RUBUSRegister& cell = m_cell[m_index_cell];
if(cell.get_index() == index)
{
m_current_index_cell = m_index_cell;
break;
//
}//if
//
}//for
//
return m_cell[m_current_index_cell].write_register(data.all);
//
}//
//
} /* namespace MODBUSRTU */

@ -0,0 +1,88 @@
/*
* RUBUSDataBase.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUSDATABASE_H_
#define MODBUSRTU_RUBUSDATABASE_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "SYSCTRL/SystemEnvironment.h"
#include "MODBUSRTU/RUBUSTypes.h"
#include "MODBUSRTU/RUBUSRegister.h"
namespace MODBUSRTU
{
#define NUMBER_RUBUSCELLS ((uint16_t)(420))
class RUBUSDataBase
{
private:
MODBUSRTU::RUBUSRegister m_cell[NUMBER_RUBUSCELLS];
uint16_t m_current_index_cell;
uint16_t m_index_cell;
uint16_t m_counter_cell;
uint16_t m_size_cell;
public:
RUBUSDataBase();
public:
void configurate();
public:
void add_register_bool (uint16_t index, uint16_t readonly, bool* param);
void add_register_float (uint16_t index, uint16_t readonly, float* param);
void add_register_uint8 (uint16_t index, uint16_t readonly, uint8_t* param);
void add_register_uint16(uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_uint32(uint16_t index, uint16_t readonly, uint32_t* param);
void add_register_int8 (uint16_t index, uint16_t readonly, int8_t* param);
void add_register_int16 (uint16_t index, uint16_t readonly, int16_t* param);
void add_register_int32 (uint16_t index, uint16_t readonly, int32_t* param);
void add_register_bit0 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit1 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit2 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit3 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit4 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit5 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit6 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit7 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit8 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit9 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit10 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit11 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit12 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit13 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit14 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit15 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit16 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit17 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit18 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit19 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit20 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit21 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit22 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit23 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit24 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit25 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit26 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit27 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit28 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit29 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit30 (uint16_t index, uint16_t readonly, uint16_t* param);
void add_register_bit31 (uint16_t index, uint16_t readonly, uint16_t* param);
public:
MODBUSRTU::RUBUSRegister& get_register(uint16_t index);
void read_register(uint16_t index, RUBUS_REGISTER_32& data);
uint16_t write_register(uint16_t index, RUBUS_REGISTER_32 data);
};
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUSDATABASE_H_ */

@ -0,0 +1,862 @@
/*
* RUBUSCell.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "MODBUSRTU/RUBUSRegister.h"
namespace MODBUSRTU
{
//CONSTRUCTOR
RUBUSRegister::RUBUSRegister():
m_index(0),
m_is_read_only(true),
m_param(0),
m_type(MODBUSRTU::RUBUS_UNDEFINED)
{}//CONSTRUCTOR
RUBUSRegister::RUBUSRegister(const RUBUSRegister& copyregister):
m_index(copyregister.m_index),
m_is_read_only(copyregister.m_is_read_only),
m_param(copyregister.m_param),
m_type(copyregister.m_type)
{}
void RUBUSRegister::register_bool (uint16_t index, uint16_t readonly, bool* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BOOL;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_float (uint16_t index, uint16_t readonly, float* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_FLOAT;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_uint8 (uint16_t index, uint16_t readonly, uint8_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_UINT8;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_uint16(uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_UINT16;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_uint32(uint16_t index, uint16_t readonly, uint32_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_UINT32;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_int8 (uint16_t index, uint16_t readonly, int8_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_INT8;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_int16 (uint16_t index, uint16_t readonly, int16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_INT16;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_int32 (uint16_t index, uint16_t readonly, int32_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_INT32;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit0 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT0;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit1 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT1;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit2 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT2;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit3 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT3;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit4 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT4;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit5 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT5;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit6 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT6;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit7 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT7;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit8 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT8;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit9 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT9;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit10 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT10;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit11 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT11;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit12 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT12;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit13 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT13;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit14 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT14;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit15 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT15;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit16 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT16;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit17 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT17;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit18 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT18;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit19 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT19;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit20 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT20;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit21 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT21;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit22 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT22;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit23 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT23;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit24 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT24;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit25 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT25;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit26 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT26;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit27 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT27;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit28 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT28;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit29 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT29;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit30 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT30;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
void RUBUSRegister::register_bit31 (uint16_t index, uint16_t readonly, uint16_t* param)
{
m_index = index;
m_param = param;
m_type = MODBUSRTU::RUBUS_BIT31;
m_is_read_only = readonly == 0 ? false : true;
//
}//
//
uint16_t RUBUSRegister::get_index()
{
return m_index;
//
}//
//
bool RUBUSRegister::is_read_only()
{
return m_is_read_only;
}//
//
MODBUSRTU::rubus_variant_type_t RUBUSRegister::get_type()
{
return m_type;
//
}//
//
MODBUSRTU::RUBUS_REGISTER_32 RUBUSRegister::read_register()
{
MODBUSRTU::RUBUS_REGISTER_32 _temp = MODBUSRTU::RUBUS_REGISTER_32(0);
_temp.word.wL.all = 0x0000;
_temp.word.wH.all = 0x0000;
switch(m_type)
{
case MODBUSRTU::RUBUS_BOOL: { _temp.b = *((bool*) m_param); break;}
case MODBUSRTU::RUBUS_FLOAT: { _temp.f = *((float*) m_param); break;}
case MODBUSRTU::RUBUS_UINT8: { _temp.u8 = *((uint8_t*) m_param); break;}
case MODBUSRTU::RUBUS_UINT16: { _temp.u16 = *((uint16_t*) m_param); break;}
case MODBUSRTU::RUBUS_UINT32: { _temp.u32 = *((uint32_t*) m_param); break;}
case MODBUSRTU::RUBUS_INT8: { _temp.i8 = *((int8_t*) m_param); break;}
case MODBUSRTU::RUBUS_INT16: { _temp.i16 = *((int16_t*) m_param); break;}
case MODBUSRTU::RUBUS_INT32: { _temp.i32 = *((int32_t*) m_param); break;}
case MODBUSRTU::RUBUS_BIT0:
{
_read_bit(_temp.word.wL.all, 0x0001);
break;
}
case MODBUSRTU::RUBUS_BIT1:
{
_read_bit(_temp.word.wL.all, 0x0002);
break;
}
case MODBUSRTU::RUBUS_BIT2:
{
_read_bit(_temp.word.wL.all, 0x0004);
break;
}
case MODBUSRTU::RUBUS_BIT3:
{
_read_bit(_temp.word.wL.all, 0x0008);
break;
}
case MODBUSRTU::RUBUS_BIT4:
{
_read_bit(_temp.word.wL.all, 0x0010);
break;
}
case MODBUSRTU::RUBUS_BIT5:
{
_read_bit(_temp.word.wL.all, 0x0020);
break;
}
case MODBUSRTU::RUBUS_BIT6:
{
_read_bit(_temp.word.wL.all, 0x0040);
break;
}
case MODBUSRTU::RUBUS_BIT7:
{
_read_bit(_temp.word.wL.all, 0x0080);
break;
}
case MODBUSRTU::RUBUS_BIT8:
{
_read_bit(_temp.word.wL.all, 0x0100);
break;
}
case MODBUSRTU::RUBUS_BIT9:
{
_read_bit(_temp.word.wL.all, 0x0200);
break;
}
case MODBUSRTU::RUBUS_BIT10:
{
_read_bit(_temp.word.wL.all, 0x0400);
break;
}
case MODBUSRTU::RUBUS_BIT11:
{
_read_bit(_temp.word.wL.all, 0x0800);
break;
}
case MODBUSRTU::RUBUS_BIT12:
{
_read_bit(_temp.word.wL.all, 0x1000);
break;
}
case MODBUSRTU::RUBUS_BIT13:
{
_read_bit(_temp.word.wL.all, 0x2000);
break;
}
case MODBUSRTU::RUBUS_BIT14:
{
_read_bit(_temp.word.wL.all, 0x4000);
break;
}
case MODBUSRTU::RUBUS_BIT15:
{
_read_bit(_temp.word.wL.all, 0x8000);
break;
}
case MODBUSRTU::RUBUS_BIT16:
{
_read_bit(_temp.word.wH.all, 0x0001);
break;
}
case MODBUSRTU::RUBUS_BIT17:
{
_read_bit(_temp.word.wH.all, 0x0002);
break;
}
case MODBUSRTU::RUBUS_BIT18:
{
_read_bit(_temp.word.wH.all, 0x0004);
break;
}
case MODBUSRTU::RUBUS_BIT19:
{
_read_bit(_temp.word.wH.all, 0x0008);
break;
}
case MODBUSRTU::RUBUS_BIT20:
{
_read_bit(_temp.word.wH.all, 0x0010);
break;
}
case MODBUSRTU::RUBUS_BIT21:
{
_read_bit(_temp.word.wH.all, 0x0020);
break;
}
case MODBUSRTU::RUBUS_BIT22:
{
_read_bit(_temp.word.wH.all, 0x0040);
break;
}
case MODBUSRTU::RUBUS_BIT23:
{
_read_bit(_temp.word.wH.all, 0x0080);
break;
}
case MODBUSRTU::RUBUS_BIT24:
{
_read_bit(_temp.word.wH.all, 0x0100);
break;
}
case MODBUSRTU::RUBUS_BIT25:
{
_read_bit(_temp.word.wH.all, 0x0200);
break;
}
case MODBUSRTU::RUBUS_BIT26:
{
_read_bit(_temp.word.wH.all, 0x0400);
break;
}
case MODBUSRTU::RUBUS_BIT27:
{
_read_bit(_temp.word.wH.all, 0x0800);
break;
}
case MODBUSRTU::RUBUS_BIT28:
{
_read_bit(_temp.word.wH.all, 0x1000);
break;
}
case MODBUSRTU::RUBUS_BIT29:
{
_read_bit(_temp.word.wH.all, 0x2000);
break;
}
case MODBUSRTU::RUBUS_BIT30:
{
_read_bit(_temp.word.wH.all, 0x4000);
break;
}
case MODBUSRTU::RUBUS_BIT31:
{
_read_bit(_temp.word.wH.all, 0x8000);
break;
}
}//switch
//
return _temp.all;
//
}//
//
uint16_t RUBUSRegister::write_register(MODBUSRTU::RUBUS_REGISTER_32 data)
{
MODBUSRTU::RUBUS_REGISTER_32 _temp = MODBUSRTU::RUBUS_REGISTER_32(0);
_temp.word.wL.all = 0x0000;
_temp.word.wH.all = 0x0000;
if(m_is_read_only)
{
// register is read only
// write operation is not allowed
return 0x0040;
}
else
{
// writeable register
switch(m_type)
{
case MODBUSRTU::RUBUS_BOOL: { *((bool*) m_param) = data.b; break;}
case MODBUSRTU::RUBUS_FLOAT: { *((float*) m_param) = data.f; break;}
case MODBUSRTU::RUBUS_UINT8: { *((uint8_t*) m_param) = data.u8; break;}
case MODBUSRTU::RUBUS_UINT16: { *((uint16_t*) m_param) = data.u16; break;}
case MODBUSRTU::RUBUS_UINT32: { *((uint32_t*) m_param) = data.u32; break;}
case MODBUSRTU::RUBUS_INT8: { *((int8_t*) m_param) = data.i8; break;}
case MODBUSRTU::RUBUS_INT16: { *((int16_t*) m_param) = data.i16; break;}
case MODBUSRTU::RUBUS_INT32: { *((int32_t*) m_param) = data.i32; break;}
case MODBUSRTU::RUBUS_BIT0:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b00 = data.bit16.b00;
*((uint16_t*) m_param) = data.u16;
break;
}
case MODBUSRTU::RUBUS_BIT1:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b01 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT2:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b02 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT3:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b03 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT4:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b04 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT5:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b05 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT6:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b06 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT7:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b07 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT8:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b08 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT9:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b09 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT10:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b10 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT11:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b11 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT12:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b12 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT13:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b13 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT14:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b14 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT15:
{
_temp.u16 = *((uint16_t*) m_param);
_temp.bit16.b15 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.u16;
break;
}
case MODBUSRTU::RUBUS_BIT16:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b16 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT17:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b17 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT18:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b18 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT19:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b19 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT20:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b20 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT21:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b21 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT22:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b22 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT23:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b23 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT24:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b24 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT25:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b25 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT26:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b26 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT27:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b27 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT28:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b28 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT29:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b29 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT30:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b30 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
case MODBUSRTU::RUBUS_BIT31:
{
_temp.word.wH.all = *((uint16_t*) m_param);
_temp.bit32.b31 = data.bit16.b00;
*((uint16_t*) m_param) = _temp.word.wH.all;
break;
}
}//switch
//
return 0;
//
}//if else
//
}//
//
inline void RUBUSRegister::_read_bit(uint16_t& auxreg, uint16_t mask)
{
auxreg = *((uint16_t*) m_param);
auxreg &= mask;
auxreg = auxreg == 0 ? 0 : 1;
//
}//
//
//
} /* namespace MODBUSRTU */

@ -0,0 +1,89 @@
/*
* RUBUSCell.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUSREGISTER_H_
#define MODBUSRTU_RUBUSREGISTER_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "SYSCTRL/SystemEnvironment.h"
#include "MODBUSRTU/RUBUSTypes.h"
namespace MODBUSRTU
{
class RUBUSRegister
{
private:
uint16_t m_index;
bool m_is_read_only;
void* m_param;
rubus_variant_type_t m_type;
public:
RUBUSRegister();
RUBUSRegister(const RUBUSRegister& cell);
public:
void register_bool (uint16_t index, uint16_t readonly, bool* param);
void register_float (uint16_t index, uint16_t readonly, float* param);
void register_uint8 (uint16_t index, uint16_t readonly, uint8_t* param);
void register_uint16(uint16_t index, uint16_t readonly, uint16_t* param);
void register_uint32(uint16_t index, uint16_t readonly, uint32_t* param);
void register_int8 (uint16_t index, uint16_t readonly, int8_t* param);
void register_int16 (uint16_t index, uint16_t readonly, int16_t* param);
void register_int32 (uint16_t index, uint16_t readonly, int32_t* param);
void register_bit0 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit1 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit2 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit3 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit4 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit5 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit6 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit7 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit8 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit9 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit10 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit11 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit12 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit13 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit14 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit15 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit16 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit17 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit18 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit19 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit20 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit21 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit22 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit23 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit24 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit25 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit26 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit27 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit28 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit29 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit30 (uint16_t index, uint16_t readonly, uint16_t* param);
void register_bit31 (uint16_t index, uint16_t readonly, uint16_t* param);
public:
uint16_t get_index();
bool is_read_only();
MODBUSRTU::rubus_variant_type_t get_type();
public:
MODBUSRTU::RUBUS_REGISTER_32 read_register();
uint16_t write_register(MODBUSRTU::RUBUS_REGISTER_32 data);
private:
inline void _read_bit(uint16_t& auxreg, uint16_t mask);
//
};//
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUSREGISTER_H_ */

@ -0,0 +1,197 @@
/*
* RUBUSTypes.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef MODBUSRTU_RUBUSTYPES_H_
#define MODBUSRTU_RUBUSTYPES_H_
#include <math.h>
#include <stdint.h>
#include "framework.h"
namespace MODBUSRTU
{
typedef unsigned char uint8_t;
typedef signed char int8_t;
enum rubus_variant_type_t { RUBUS_UNDEFINED,
RUBUS_BOOL,
RUBUS_FLOAT,
RUBUS_UINT8,
RUBUS_UINT16,
RUBUS_UINT32,
RUBUS_INT8,
RUBUS_INT16,
RUBUS_INT32,
RUBUS_BIT0,
RUBUS_BIT1,
RUBUS_BIT2,
RUBUS_BIT3,
RUBUS_BIT4,
RUBUS_BIT5,
RUBUS_BIT6,
RUBUS_BIT7,
RUBUS_BIT8,
RUBUS_BIT9,
RUBUS_BIT10,
RUBUS_BIT11,
RUBUS_BIT12,
RUBUS_BIT13,
RUBUS_BIT14,
RUBUS_BIT15,
RUBUS_BIT16,
RUBUS_BIT17,
RUBUS_BIT18,
RUBUS_BIT19,
RUBUS_BIT20,
RUBUS_BIT21,
RUBUS_BIT22,
RUBUS_BIT23,
RUBUS_BIT24,
RUBUS_BIT25,
RUBUS_BIT26,
RUBUS_BIT27,
RUBUS_BIT28,
RUBUS_BIT29,
RUBUS_BIT30,
RUBUS_BIT31};
struct RUBUS_REGISTER_16_BIT_FIELD
{
uint16_t b00: 1;
uint16_t b01: 1;
uint16_t b02: 1;
uint16_t b03: 1;
uint16_t b04: 1;
uint16_t b05: 1;
uint16_t b06: 1;
uint16_t b07: 1;
uint16_t b08: 1;
uint16_t b09: 1;
uint16_t b10: 1;
uint16_t b11: 1;
uint16_t b12: 1;
uint16_t b13: 1;
uint16_t b14: 1;
uint16_t b15: 1;
};//RUBUS_REGISTER_16_BIT_FIELD
struct RUBUS_REGISTER_32_BIT_FIELD
{
uint32_t b00: 1;
uint32_t b01: 1;
uint32_t b02: 1;
uint32_t b03: 1;
uint32_t b04: 1;
uint32_t b05: 1;
uint32_t b06: 1;
uint32_t b07: 1;
uint32_t b08: 1;
uint32_t b09: 1;
uint32_t b10: 1;
uint32_t b11: 1;
uint32_t b12: 1;
uint32_t b13: 1;
uint32_t b14: 1;
uint32_t b15: 1;
uint32_t b16: 1;
uint32_t b17: 1;
uint32_t b18: 1;
uint32_t b19: 1;
uint32_t b20: 1;
uint32_t b21: 1;
uint32_t b22: 1;
uint32_t b23: 1;
uint32_t b24: 1;
uint32_t b25: 1;
uint32_t b26: 1;
uint32_t b27: 1;
uint32_t b28: 1;
uint32_t b29: 1;
uint32_t b30: 1;
uint32_t b31: 1;
};//RUBUS_REGISTER_32_BIT_FIELD
struct RUBUS_REGISTER_16_BYTE_FIELD
{
uint16_t bt0 :8;
uint16_t bt1 :8;
};//RUBUS_REGISTER_16_BYTE_FIELD
union RUBUS_REGISTER_16
{
uint16_t all;
RUBUS_REGISTER_16_BIT_FIELD bit;
RUBUS_REGISTER_16_BYTE_FIELD byte;
RUBUS_REGISTER_16(uint16_t val):
all(val)
{}
};//RUBUS_REGISTER_16
struct RUBUS_REGISTER_32_BYTE_FIELD
{
uint16_t bt0 :8;
uint16_t bt1 :8;
uint16_t bt2 :8;
uint16_t bt3 :8;
};//RUBUS_REGISTER_32_BYTE_FIELD
union RUBUS_REGISTER_16_WORD
{
uint16_t all;
RUBUS_REGISTER_16_BIT_FIELD bit;
RUBUS_REGISTER_16_BYTE_FIELD byte;
};//RUBUS_REGISTER_16_WORD
struct RUBUS_REGISTER_32_WORD_FIELD
{
RUBUS_REGISTER_16_WORD wL;
RUBUS_REGISTER_16_WORD wH;
};//RUBUS_REGISTER_32_WORD_FIELD
union RUBUS_REGISTER_32
{
uint32_t all;
bool b;
float f;
uint8_t u8;
uint16_t u16;
uint32_t u32;
int8_t i8;
int16_t i16;
int32_t i32;
RUBUS_REGISTER_16_BIT_FIELD bit16;
RUBUS_REGISTER_32_BIT_FIELD bit32;
RUBUS_REGISTER_32_WORD_FIELD word;
RUBUS_REGISTER_32_BYTE_FIELD byte;
RUBUS_REGISTER_32():
all((uint32_t)0)
{};
RUBUS_REGISTER_32(uint32_t val):
all(val)
{}
};//RUBUS_REGISTER_32
} /* namespace MODBUSRTU */
#endif /* MODBUSRTU_RUBUSTYPES_H_ */

@ -0,0 +1,18 @@
/*
* ALERTHeaders.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef ALERT_ALERTHEADERS_H_
#define ALERT_ALERTHEADERS_H_
#include "Alert/AlertBase.h"
#include "Alert/FaultDecrease.h"
#include "Alert/FaultExceed.h"
#include "Alert/WarningDecrease.h"
#include "Alert/WarningExceed.h"
#endif /* ALERT_ALERTHEADERS_H_ */

@ -0,0 +1,32 @@
/*
* AlgorithmBase.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmBase.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmBase::AlgorithmBase():
m_voltage_a(FP_ZERO),
m_voltage_b(FP_ZERO),
m_voltage_c(FP_ZERO)
//
{}//CONSTRUCTOR
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmBase::get_ref_invertor_voltage(float& volt_a, float& volt_b, float& volt_c)
{
volt_a = m_voltage_a;
volt_b = m_voltage_b;
volt_c = m_voltage_c;
//
}//end
//
void AlgorithmBase::_execute_undef(){}
//
} /* namespace SYSCTRL */

@ -0,0 +1,43 @@
/*
* AlgorithmBase.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/SystemEnvironment.h"
#ifndef SYSCTRL_ALGORITHMBASE_H_
#define SYSCTRL_ALGORITHMBASE_H_
namespace SYSCTRL
{
class AlgorithmBase
{
protected:
float m_voltage_a;
float m_voltage_b;
float m_voltage_c;
public:
AlgorithmBase();
public:
virtual void setup() = 0;
public:
virtual void reset() = 0;
public:
void get_ref_invertor_voltage(float& volt_a, float& volt_b, float& volt_c);
public:
virtual void execute() = 0;
protected:
void _execute_undef();
virtual void _execute_run() = 0;
//
};//AlgorithmBase
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMBASE_H_ */

@ -0,0 +1,701 @@
/*
* AlgorithmContext.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmContext.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmContext::AlgorithmContext(SYSCTRL::SystemEnvironment& env):
m_mode(SYSCTRL::AlgorithmContext::UNDEFINED),
m_algorithm(SYSCTRL::AlgorithmContext::UNKNOWN),
m_algorithm_previous(SYSCTRL::AlgorithmContext::UNKNOWN),
m_env(env),
m_algorithm_pointer(&m_off),
m_fault(env),
m_work(env),
m_stop(env),
m_start(env),
m_off(env),
m_source(env),
_strategy(&SYSCTRL::AlgorithmContext::_strategy_undef),
_set_fault(&SYSCTRL::AlgorithmContext::_set_empty_exe),
_set_work(&SYSCTRL::AlgorithmContext::_set_empty_exe),
_set_stop(&SYSCTRL::AlgorithmContext::_set_empty_exe),
_set_start(&SYSCTRL::AlgorithmContext::_set_empty_exe),
_set_off(&SYSCTRL::AlgorithmContext::_set_empty_exe),
_set_source(&SYSCTRL::AlgorithmContext::_set_empty_exe)
//
{}//CONSTRUCTOR
void AlgorithmContext::setup()
{
static bool status = true;
if(m_mode == SYSCTRL::AlgorithmContext::UNDEFINED)
{
m_algorithm = SYSCTRL::AlgorithmContext::UNKNOWN;
m_algorithm_previous = SYSCTRL::AlgorithmContext::UNKNOWN;
m_fault.setup();
m_work.setup();
m_stop.setup();
m_start.setup();
m_off.setup();
m_source.setup();
_strategy = &SYSCTRL::AlgorithmContext::_strategy_undef;
_set_fault = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_empty_exe;
if(status)
{
m_mode = SYSCTRL::AlgorithmContext::CONFIGURATE;
//
}//if
//
}//if
//
}//
//
void AlgorithmContext::configure()
{
static bool status = true;
if(m_mode == SYSCTRL::AlgorithmContext::CONFIGURATE)
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_off;
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
if(status)
{
m_algorithm = SYSCTRL::AlgorithmContext::OFF;
m_algorithm_previous = SYSCTRL::AlgorithmContext::OFF;
m_mode = SYSCTRL::AlgorithmContext::OPERATIONAL;
set_strategy_off();
set_off();
//
}//if
//
}//if
//
}//
//
SYSCTRL::AlgorithmContext::mode_t AlgorithmContext::get_mode()
{
return m_mode;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
SYSCTRL::AlgorithmContext::algorithm_t AlgorithmContext::get_algorithm()
{
return m_algorithm;
}//
//
bool AlgorithmContext::compare(const SYSCTRL::AlgorithmContext::mode_t mode)
{
return mode == m_mode;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool AlgorithmContext::compare_algorithm(const SYSCTRL::AlgorithmContext::algorithm_t algorithm)
{
return algorithm == m_algorithm;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::get_ref_invertor_voltage(float& volt_a, float& volt_b, float& volt_c)
{
m_algorithm_pointer->get_ref_invertor_voltage(volt_a, volt_b, volt_c);
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::strategy()
{
(this->*_strategy)();
//
}//
//
void AlgorithmContext::_strategy_undef()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_fault()
{
if((!m_env.system_fault.boolbit.b0)&&(m_env.system_reset.boolbit.b0))
{
set_strategy_off();
set_off();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_work()
{
if(m_env.system_fault.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_fault();
set_fault();
}
else
{
//
if(!m_env.enable_work.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_off();
set_off();
//
}else{
if((m_env.local_remote.state.signal.is_off & m_env.remote_stop.state.signal.is_switched_on) |
((m_env.local_remote.state.signal.is_on & m_env.external_stop.signal.is_on)))
{
//m_env.reference_intensity_voltage_load_direct.set_output(m_env.voltage_load_active);
//m_env.reference_intensity_voltage_load_quadrature.set_output(m_env.voltage_load_reactive);
set_strategy_stop();
set_stop();
//
}//if
}
//
}//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_stop()
{
if(m_env.system_fault.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_fault();
set_fault();
}
else
{
if(!m_env.enable_work.boolbit.b0 |
//(m_env.local_remote.state.signal.is_off & m_env.remote_stop.state.signal.is_switched_on) |
//(m_env.local_remote.state.signal.is_on & m_env.external_stop.signal.is_on)
m_env.auxiliary_km2.state.signal.is_on
)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_off();
set_off();
//
}
//
}//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_start()
{
if(m_env.system_fault.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_fault();
set_fault();
}
else
{
if(!m_env.enable_work.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_off();
set_off();
//
}
else
{
if((m_env.local_remote.state.signal.is_off & m_env.remote_stop.state.signal.is_switched_on) |
((m_env.local_remote.state.signal.is_on & m_env.external_stop.signal.is_on))
)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_off();
set_off();
//
}//if
if(m_env.auxiliary_km2.state.signal.is_off)
{
//m_env.regulator_voltage_load_a.set_output(m_env.reference.start.voltage_a);
//m_env.regulator_voltage_load_b.set_output(m_env.reference.start.voltage_b);
//m_env.regulator_voltage_load_c.set_output(m_env.reference.start.voltage_c);
//
//m_env.current_regulator_active.reset();
//m_env.current_regulator_reactive.reset();
//
set_strategy_work();
set_work();
//
//set_strategy_stop();
//set_stop();
//
}//if
//
}//if else
//
}//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_off()
{
if(m_env.system_fault.boolbit.b0)
{
set_strategy_fault();
set_fault();
}
else
{
if(m_env.enable_work_is_on.boolbit.b0)
{
set_strategy_start();
set_start();
//
//set_strategy_source();
//set_source();
//
//set_strategy_stop();
//set_stop();
//
}//if
//
}//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_strategy_source()
{
if(m_env.system_fault.boolbit.b0)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_fault();
set_fault();
}
else
{
//
if((!m_env.enable_work.boolbit.b0) |
(m_env.local_remote.state.signal.is_off & m_env.remote_stop.state.signal.is_switched_on) |
((m_env.local_remote.state.signal.is_on & m_env.external_stop.signal.is_on))
)
{
m_env.enable_work_reset.boolbit.b0 = true;
set_strategy_off();
set_off();
//
}//if
//
}//if else
//
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_fault()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_fault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_work()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_work;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_stop()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_stop;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_start()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_start;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_off()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_off;
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_strategy_source()
{
_strategy = &SYSCTRL::AlgorithmContext::_strategy_source;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_fault()
{
(this->*_set_fault)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_work()
{
(this->*_set_work)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_stop()
{
(this->*_set_stop)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_start()
{
(this->*_set_start)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_off()
{
(this->*_set_off)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::set_source()
{
(this->*_set_source)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::execute()
{
m_algorithm_pointer->execute();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_fault_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::FAULT;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
//
m_env.timer_start.reset();
m_env.timer_stop.reset();
//
m_algorithm_pointer = &m_fault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_work_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::WORK;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
//
//
#if TYPECONTROL == VECTORCONTROL
//
m_env.regulator_voltage_load_direct.reset();
m_env.regulator_voltage_load_quadrature.reset();
//
m_env.integrator_direct.reset();
m_env.integrator_quadrature.reset();
//
m_env.regulator_current_limit.set_to_low_saturation();
m_env.regulator_current_pfc.reset();
//
#endif
#if TYPECONTROL == SCALARCONTROL
//
m_env.regulator_dc_a.reset();
m_env.regulator_dc_b.reset();
m_env.regulator_dc_c.reset();
//
m_env.regulator_current_limit_a.set_to_high_saturation();
m_env.regulator_current_pfc_a.reset();
m_env.regulator_current_limit_b.set_to_high_saturation();
m_env.regulator_current_pfc_b.reset();
m_env.regulator_current_limit_c.set_to_high_saturation();
m_env.regulator_current_pfc_c.reset();
m_env.regulator_voltage_load_a_active.reset();
m_env.regulator_voltage_load_a_reactive.reset();
m_env.regulator_voltage_load_b_active.reset();
m_env.regulator_voltage_load_b_reactive.reset();
m_env.regulator_voltage_load_c_active.reset();
m_env.regulator_voltage_load_c_reactive.reset();
//
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
m_env.drc_positive_voltage_controller_direct.reset();
m_env.drc_positive_voltage_controller_quadrature.reset();
m_env.drc_negative_voltage_controller_direct.reset();
m_env.drc_negative_voltage_controller_quadrature.reset();
//
m_env.drc_regulator_current_limit.set_to_low_saturation();
m_env.drc_regulator_current_pfc.reset();
m_env.drc_reference_voltage_direct_intensity.set_output(m_env.drc_voltage_grid_direct);
m_work.reset_switcher();
//
#endif
//
m_env.timer_start.reset();
m_env.timer_stop.reset();
//
m_algorithm_pointer = &m_work;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_stop_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::STOP;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
//
#if TYPECONTROL == VECTORCONTROL
m_env.reference_voltage_direct_intensity.set_output(m_env.regulator_current_limit.get_output());
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
//m_env.drc_reference_voltage_direct_intensity.set_output(m_env.drc_voltage_grid_direct);
m_env.drc_reference_voltage_direct_intensity.set_output(m_env.drc_regulator_current_limit.get_output());
#endif
//
//
/* FOR DEBUG ONLY!!!! */
/*
m_env.regulator_voltage_load_a_active.reset();
m_env.regulator_voltage_load_a_reactive.reset();
m_env.regulator_voltage_load_b_active.reset();
m_env.regulator_voltage_load_b_reactive.reset();
m_env.regulator_voltage_load_c_active.reset();
m_env.regulator_voltage_load_c_reactive.reset();
*/
/* FOR DEBUG ONLY!!!! */
/* VECTOR CONTROL */
/*
m_env.regulator_voltage_load_direct.reset();
m_env.regulator_voltage_load_quadrature.reset();
//
m_env.integrator_direct.reset();
m_env.integrator_quadrature.reset();
*/
//
m_env.timer_start.reset();
m_env.timer_stop.start();
//
m_algorithm_pointer = &m_stop;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_start_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::START;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
//
#if TYPECONTROL == VECTORCONTROL
//
m_env.regulator_current_load_direct.reset();
m_env.regulator_current_load_quadrature.reset();
//
m_env.referencer_current_bypass_direct.reset();
m_env.referencer_current_bypass_quadrature.reset();
//
#endif
//
#if TYPECONTROL == SCALARCONTROL
//
m_env.current_referencer_a_active.reset();
m_env.current_referencer_a_reactive.reset();
m_env.current_referencer_b_active.reset();
m_env.current_referencer_b_reactive.reset();
m_env.current_referencer_c_active.reset();
m_env.current_referencer_c_reactive.reset();
//
m_env.current_regulator_a_active.reset();
m_env.current_regulator_a_reactive.reset();
m_env.current_regulator_b_active.reset();
m_env.current_regulator_b_reactive.reset();
m_env.current_regulator_c_active.reset();
m_env.current_regulator_c_reactive.reset();
//
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
//
m_env.drc_regulator_current_load_direct.reset();
m_env.drc_regulator_current_load_quadrature.reset();
//
m_env.drc_referencer_current_bypass_direct.reset();
m_env.drc_referencer_current_bypass_quadrature.reset();
//
m_env.drc_positive_voltage_cell_direct = FP_ZERO;
m_env.drc_positive_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_direct = FP_ZERO;
m_env.drc_negative_voltage_cell_quadrature = FP_ZERO;
//
m_env.drc_positive_voltage_cell_alpha = FP_ZERO;
m_env.drc_positive_voltage_cell_beta = FP_ZERO;
m_env.drc_negative_voltage_cell_alpha = FP_ZERO;
m_env.drc_negative_voltage_cell_beta = FP_ZERO;
//
m_env.drc_positive_voltage_cell_a = FP_ZERO;
m_env.drc_positive_voltage_cell_b = FP_ZERO;
m_env.drc_positive_voltage_cell_c = FP_ZERO;
//
m_env.drc_negative_voltage_cell_a = FP_ZERO;
m_env.drc_negative_voltage_cell_b = FP_ZERO;
m_env.drc_negative_voltage_cell_c = FP_ZERO;
//
#endif
//
m_env.timer_start.start();
m_env.timer_stop.reset();
//
m_algorithm_pointer = &m_start;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_off_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::OFF;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_empty_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_source_exe;
//
m_env.timer_start.reset();
m_env.timer_stop.reset();
//
m_algorithm_pointer = &m_off;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmContext::_set_source_exe()
{
//
m_algorithm_previous = m_algorithm;
m_algorithm = SYSCTRL::AlgorithmContext::SOURCE;
//
_set_fault = &SYSCTRL::AlgorithmContext::_set_fault_exe;
_set_work = &SYSCTRL::AlgorithmContext::_set_work_exe;
_set_stop = &SYSCTRL::AlgorithmContext::_set_stop_exe;
_set_start = &SYSCTRL::AlgorithmContext::_set_start_exe;
_set_off = &SYSCTRL::AlgorithmContext::_set_off_exe;
_set_source = &SYSCTRL::AlgorithmContext::_set_empty_exe;
//
m_env.timer_start.reset();
m_env.timer_stop.reset();
//
m_algorithm_pointer = &m_source;
//
}//
//
void AlgorithmContext::_set_empty_exe()
{
//
}//
//
//
} /* namespace SYSCTRL */

@ -0,0 +1,114 @@
/*
* AlgorithmContext.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/AlgorithmFault.h"
#include "SYSCTRL/AlgorithmOff.h"
#include "SYSCTRL/AlgorithmSource.h"
#include "SYSCTRL/AlgorithmStart.h"
#include "SYSCTRL/AlgorithmStop.h"
#include "SYSCTRL/AlgorithmWork.h"
#include "SYSCTRL/AlgorithmZero.h"
#include "SYSCTRL/SystemEnvironment.h"
#ifndef SYSCTRL_ALGORITHMCONTEXT_H_
#define SYSCTRL_ALGORITHMCONTEXT_H_
namespace SYSCTRL
{
class AlgorithmContext
{
private:
friend class SYSCTRL::AlgorithmBase;
friend class SYSCTRL::AlgorithmFault;
friend class SYSCTRL::AlgorithmWork;
friend class SYSCTRL::AlgorithmStop;
friend class SYSCTRL::AlgorithmStart;
friend class SYSCTRL::AlgorithmOff;
friend class SYSCTRL::AlgorithmSource;
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
enum algorithm_t {UNKNOWN, OFF, START, ENTRY, WORK, STOP, FAULT, SOURCE};
private:
mode_t m_mode;
algorithm_t m_algorithm;
algorithm_t m_algorithm_previous;
private:
SYSCTRL::SystemEnvironment& m_env;
private:
SYSCTRL::AlgorithmBase* m_algorithm_pointer;
SYSCTRL::AlgorithmFault m_fault;
SYSCTRL::AlgorithmWork m_work;
SYSCTRL::AlgorithmStop m_stop;
SYSCTRL::AlgorithmStart m_start;
SYSCTRL::AlgorithmOff m_off;
SYSCTRL::AlgorithmSource m_source;
public:
AlgorithmContext(SYSCTRL::SystemEnvironment& env);
void setup();
void configure();
public:
mode_t get_mode();
algorithm_t get_algorithm();
bool compare(const mode_t mode);
bool compare_algorithm(const algorithm_t algorithm);
public:
void get_ref_invertor_voltage(float& volt_a, float& volt_b, float& volt_c);
public:
void strategy();
private:
void (AlgorithmContext::*_strategy)();
void _strategy_undef();
void _strategy_fault();
void _strategy_work();
void _strategy_stop();
void _strategy_start();
void _strategy_off();
void _strategy_source();
public:
void set_strategy_fault();
void set_strategy_work();
void set_strategy_stop();
void set_strategy_start();
void set_strategy_off();
void set_strategy_source();
public:
void execute();
public:
void set_fault();
void set_work();
void set_stop();
void set_start();
void set_off();
void set_source();
private:
void (AlgorithmContext::*_set_fault)();
void (AlgorithmContext::*_set_work)();
void (AlgorithmContext::*_set_stop)();
void (AlgorithmContext::*_set_start)();
void (AlgorithmContext::*_set_off)();
void (AlgorithmContext::*_set_source)();
void _set_fault_exe();
void _set_work_exe();
void _set_stop_exe();
void _set_start_exe();
void _set_off_exe();
void _set_source_exe();
void _set_empty_exe();
//
};//class AlgorithmContext
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMCONTEXT_H_ */

@ -0,0 +1,49 @@
/*
* AlgorithmFault.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmFault.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmFault::AlgorithmFault(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
_execute(&SYSCTRL::AlgorithmFault::_execute_undef)
//
{}//CONSTRUCTOR
//
void AlgorithmFault::setup()
{
_execute = &SYSCTRL::AlgorithmFault::_execute_run;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmFault::reset()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmFault::execute()
{
(this->*_execute)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmFault::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,40 @@
/*
* AlgorithmFault.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITHMFAULT_H_
#define SYSCTRL_ALGORITHMFAULT_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmFault: public AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmFault(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmFault::*_execute)();
void _execute_run();
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMFAULT_H_ */

@ -0,0 +1,78 @@
/*
* AlgoritmOff.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmOff.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmOff::AlgorithmOff(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
_execute(&SYSCTRL::AlgorithmOff::_execute_undef)
//
{}//CONSTRUCTOR
//
void AlgorithmOff::setup()
{
_execute = &SYSCTRL::AlgorithmOff::_execute_run;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmOff::reset()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmOff::execute()
{
(this->*_execute)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmOff::_execute_run()
{
static bool _high_level = true;
_high_level = true;
if(m_env.system_reset.boolbit.b0)
{
m_env.hardware.ref_control_order = ORDER_RESET;
//
}
else
{
for(Uint16 cellnum = 0; cellnum < m_env.hardware.level; cellnum++)
{
_high_level &= m_env.hardware.hvcell.dc_voltage[0][cellnum] > m_env.hardware.dc_voltage_low_level ? true : false;
_high_level &= m_env.hardware.hvcell.dc_voltage[1][cellnum] > m_env.hardware.dc_voltage_low_level ? true : false;
_high_level &= m_env.hardware.hvcell.dc_voltage[2][cellnum] > m_env.hardware.dc_voltage_low_level ? true : false;
//
}//for
//
if(!_high_level & m_env.hardware.low_level())
{
m_env.hardware.ref_control_order = ORDER_RESET;
m_env.hardware.fault_low_level = false;
}
else
{
m_env.hardware.ref_control_order = ORDER_START;
}
//
}//if else
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,41 @@
/*
* AlgoritmOff.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITMSTOPPED_H_
#define SYSCTRL_ALGORITMSTOPPED_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmOff: public AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmOff(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmOff::*_execute)();
void _execute_run();
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITMSTOPPED_H_ */

@ -0,0 +1,73 @@
/*
* AlgorithmSource.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmSource.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmSource::AlgorithmSource(SYSCTRL::SystemEnvironment& env):
AlgorithmBase(),
m_env(env),
m_voltage_direct(FP_ZERO),
m_voltage_quadrature(FP_ZERO),
m_voltage_alpha(FP_ZERO),
m_voltage_beta(FP_ZERO),
m_voltage_a_gen(FP_ZERO),
m_voltage_b_gen(FP_ZERO),
m_voltage_c_gen(FP_ZERO),
m_voltage_a_relative(FP_ZERO),
m_voltage_b_relative(FP_ZERO),
m_voltage_c_relative(FP_ZERO),
m_ort_alpha(FP_ZERO),
m_ort_beta(FP_ZERO),
_execute(&SYSCTRL::AlgorithmSource::_execute_undef)
//
{}//CONSTRUCTOR
//
void AlgorithmSource::setup()
{
_execute = &SYSCTRL::AlgorithmSource::_execute_run;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmSource::reset()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmSource::execute()
{
(this->*_execute)();
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmSource::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
m_voltage_direct = m_env.algorithm_source_references.voltage * cosf(m_env.algorithm_source_references.phase_shift);
m_voltage_quadrature = m_env.algorithm_source_references.voltage * sinf(m_env.algorithm_source_references.phase_shift);
//
m_ort_alpha = m_env.main_ab_orts.active;
m_ort_beta = m_env.main_ab_orts.reactive;
//
FLTSYSLIB::Transformation::park_inverse(m_ort_alpha, m_ort_beta, m_voltage_direct, m_voltage_quadrature, m_voltage_alpha, m_voltage_beta);
FLTSYSLIB::Transformation::clarke_inverse(m_voltage_alpha, m_voltage_beta, m_voltage_a_gen, m_voltage_b_gen, m_voltage_c_gen);
//
m_voltage_a_relative = m_voltage_a_gen * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b_relative = m_voltage_b_gen * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c_relative = m_voltage_c_gen * m_env.cell_dc_voltage_c_reciprocal;
//
m_voltage_a = m_voltage_a_relative;
m_voltage_b = m_voltage_b_relative;
m_voltage_c = m_voltage_c_relative;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,54 @@
/*
* AlgorithmSource.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGIRITHMSOURCE_H_
#define SYSCTRL_ALGIRITHMSOURCE_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmSource: public AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
private:
float m_voltage_direct;
float m_voltage_quadrature;
float m_voltage_alpha;
float m_voltage_beta;
float m_voltage_a_gen;
float m_voltage_b_gen;
float m_voltage_c_gen;
float m_voltage_a_relative;
float m_voltage_b_relative;
float m_voltage_c_relative;
float m_ort_alpha;
float m_ort_beta;
public:
AlgorithmSource(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmSource::*_execute)();
void _execute_run();
//
};//class AlgirithmSource
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGIRITHMSOURCE_H_ */

@ -0,0 +1,291 @@
/*
* AlgoritmStart.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmStart.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmStart::AlgorithmStart(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
#if TYPECONTROL == VECTORCONTROL
m_reference_zero(FP_ZERO),
m_reference_current_cell_direct(FP_ZERO),
m_reference_current_cell_quadrature(FP_ZERO),
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
m_reference_zero(FP_ZERO),
m_reference_current_cell_direct(FP_ZERO),
m_reference_current_cell_quadrature(FP_ZERO),
#endif
_execute(&SYSCTRL::AlgorithmStart::_execute_undef)
{}//CONSTRUCTOR
//
void AlgorithmStart::setup()
{
_execute = &SYSCTRL::AlgorithmStart::_execute_run;
//
}//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStart::reset()
{
#if TYPECONTROL == VECTORCONTROL
//
m_env.regulator_current_load_direct.reset();
m_env.regulator_current_load_quadrature.reset();
//
m_env.referencer_current_bypass_direct.reset();
m_env.referencer_current_bypass_quadrature.reset();
//
#endif
#if TYPECONTROL == SCALARCONTROL
m_env.current_referencer_a_active.reset();
m_env.current_referencer_a_reactive.reset();
m_env.current_referencer_b_active.reset();
m_env.current_referencer_b_reactive.reset();
m_env.current_referencer_c_active.reset();
m_env.current_referencer_c_reactive.reset();
m_env.current_regulator_a_active.reset();
m_env.current_regulator_a_reactive.reset();
m_env.current_regulator_b_active.reset();
m_env.current_regulator_b_reactive.reset();
m_env.current_regulator_c_active.reset();
m_env.current_regulator_c_reactive.reset();
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
//
m_env.drc_regulator_current_load_direct.reset();
m_env.drc_regulator_current_load_quadrature.reset();
//
m_env.drc_referencer_current_bypass_direct.reset();
m_env.drc_referencer_current_bypass_quadrature.reset();
//
#endif
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStart::execute()
{
(this->*_execute)();
//
}//
//
#if TYPECONTROL == VECTORCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStart::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_start.execute();
//
m_reference_current_cell_direct = m_env.referencer_current_bypass_direct.execute(m_reference_zero, m_env.current_bypass_direct);
m_reference_current_cell_quadrature = m_env.referencer_current_bypass_quadrature.execute(m_reference_zero, m_env.current_bypass_quadrature);
//
m_env.voltage_cell_direct = m_env.regulator_current_load_direct.execute(m_env.current_cell_direct, m_reference_current_cell_direct);
m_env.voltage_cell_quadrature = m_env.regulator_current_load_quadrature.execute(m_env.current_cell_quadrature, m_reference_current_cell_quadrature);
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.voltage_cell_direct,
m_env.voltage_cell_quadrature,
m_env.voltage_cell_alpha,
m_env.voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.voltage_cell_alpha,
m_env.voltage_cell_beta,
m_env.voltage_cell_a,
m_env.voltage_cell_b,
m_env.voltage_cell_c);
//
m_voltage_a = m_env.voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//
#endif
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStart::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_start.execute();
//**** Phase A ***
//-reference constructor
//m_env.start_control.phase_a.reference.current_bypass_active = FP_ZERO;
//m_env.start_control.phase_a.reference.current_bypass_reactive = FP_ZERO;
//
m_env.start_control.phase_a.reference.current_bypass_active = m_env.start_control.common_ref.active;
m_env.start_control.phase_a.reference.current_bypass_reactive = m_env.start_control.common_ref.reactive;
//
//m_env.start_control.phase_a.test_ref = m_env.start_control.common_ref;
//-feedback constructor
m_env.start_control.phase_a.feedback.current_bypass_active = m_env.projection_current_bypass_a.active;
m_env.start_control.phase_a.feedback.current_bypass_reactive = m_env.projection_current_bypass_a.reactive;
//
m_env.start_control.phase_a.feedback.current_cell_active = m_env.projection_current_cell_a.active;
m_env.start_control.phase_a.feedback.current_cell_reactive = m_env.projection_current_cell_a.reactive;
//
//-control
_execute_single_phase(m_env.start_control.phase_a,
m_env.main_abc_orts.phase_a,
m_env.cell_dc_voltage_a_reciprocal,
m_env.current_referencer_a_active,
m_env.current_referencer_a_reactive,
m_env.current_regulator_a_active,
m_env.current_regulator_a_reactive);
//<>
//**** Phase B ***
//-reference constructor
//m_env.start_control.phase_b.reference.current_bypass_active = FP_ZERO;
//m_env.start_control.phase_b.reference.current_bypass_reactive = FP_ZERO;
//
m_env.start_control.phase_b.reference.current_bypass_active = m_env.start_control.common_ref.active;
m_env.start_control.phase_b.reference.current_bypass_reactive = m_env.start_control.common_ref.reactive;
//
//m_env.start_control.phase_b.test_ref = m_env.start_control.common_ref;
//-feedback constructor
m_env.start_control.phase_b.feedback.current_bypass_active = m_env.projection_current_bypass_b.active;
m_env.start_control.phase_b.feedback.current_bypass_reactive = m_env.projection_current_bypass_b.reactive;
//
m_env.start_control.phase_b.feedback.current_cell_active = m_env.projection_current_cell_b.active;
m_env.start_control.phase_b.feedback.current_cell_reactive = m_env.projection_current_cell_b.reactive;
//
//-control
_execute_single_phase(m_env.start_control.phase_b,
m_env.main_abc_orts.phase_b,
m_env.cell_dc_voltage_b_reciprocal,
m_env.current_referencer_b_active,
m_env.current_referencer_b_reactive,
m_env.current_regulator_b_active,
m_env.current_regulator_b_reactive);
//<>
//**** Phase C ***
//-reference constructor
//m_env.start_control.phase_c.reference.current_bypass_active = FP_ZERO;
//m_env.start_control.phase_c.reference.current_bypass_reactive = FP_ZERO;
//
m_env.start_control.phase_c.reference.current_bypass_active = m_env.start_control.common_ref.active;
m_env.start_control.phase_c.reference.current_bypass_reactive = m_env.start_control.common_ref.reactive;
//
//m_env.start_control.phase_c.test_ref = m_env.start_control.common_ref;
//-feedback constructor
m_env.start_control.phase_c.feedback.current_bypass_active = m_env.projection_current_bypass_c.active;
m_env.start_control.phase_c.feedback.current_bypass_reactive = m_env.projection_current_bypass_c.reactive;
//
m_env.start_control.phase_c.feedback.current_cell_active = m_env.projection_current_cell_c.active;
m_env.start_control.phase_c.feedback.current_cell_reactive = m_env.projection_current_cell_c.reactive;
//
//-control
_execute_single_phase(m_env.start_control.phase_c,
m_env.main_abc_orts.phase_c,
m_env.cell_dc_voltage_c_reciprocal,
m_env.current_referencer_c_active,
m_env.current_referencer_c_reactive,
m_env.current_regulator_c_active,
m_env.current_regulator_c_reactive);
//<>
m_voltage_a = m_env.start_control.phase_a.reference.voltage_cell_relative;
m_voltage_b = m_env.start_control.phase_b.reference.voltage_cell_relative;
m_voltage_c = m_env.start_control.phase_c.reference.voltage_cell_relative;
//
}//
#endif
//
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
inline void AlgorithmStart::_execute_single_phase(SYSCTRL::AlgorithmStartSinglePhaseControl& phase,
SYSCTRL::VectorOrthogonalProjection& orts,
float dc_voltage_reciprocal,
FLTSYSLIB::PIController& referencer_active,
FLTSYSLIB::PIController& referencer_reactive,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive)
{
//
phase.reference.current_cell_active = referencer_active.execute(phase.reference.current_bypass_active, phase.feedback.current_bypass_active);
phase.reference.current_cell_reactive = referencer_reactive.execute(phase.reference.current_bypass_reactive, phase.feedback.current_bypass_reactive);
//
phase.reference.voltage_cell_ampl_active = regulator_active.execute(phase.feedback.current_cell_active, phase.reference.current_cell_active);
phase.reference.voltage_cell_ampl_reactive = regulator_reactive.execute(phase.feedback.current_cell_reactive, phase.reference.current_cell_reactive);
//
//phase.reference.voltage_cell_ampl_active = regulator_active.execute(phase.feedback.current_cell_active, phase.test_ref.active);
//phase.reference.voltage_cell_ampl_reactive = regulator_reactive.execute(phase.feedback.current_cell_reactive, phase.test_ref.reactive);
//
phase.reference.voltage_cell_active = phase.reference.voltage_cell_ampl_active * orts.active;
phase.reference.voltage_cell_reactive = phase.reference.voltage_cell_ampl_reactive * orts.reactive;
//
phase.reference.voltage_cell = phase.reference.voltage_cell_active - phase.reference.voltage_cell_reactive;
phase.reference.voltage_cell_relative = phase.reference.voltage_cell * dc_voltage_reciprocal;
//
}//
#endif
//
#if TYPECONTROL == DIRECTREVERSECONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStart::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_start.execute();
//
m_reference_current_cell_direct = m_env.drc_referencer_current_bypass_direct.execute(m_reference_zero, m_env.drc_current_bypass_direct);
m_reference_current_cell_quadrature = m_env.drc_referencer_current_bypass_quadrature.execute(m_reference_zero, m_env.drc_current_bypass_quadrature);
//
m_env.drc_positive_voltage_cell_direct = m_env.drc_regulator_current_load_direct.execute(m_env.drc_current_cell_direct, m_reference_current_cell_direct);
m_env.drc_positive_voltage_cell_quadrature = m_env.drc_regulator_current_load_quadrature.execute(m_env.drc_current_cell_quadrature, m_reference_current_cell_quadrature);
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.drc_positive_voltage_cell_direct,
m_env.drc_positive_voltage_cell_quadrature,
m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta,
m_env.drc_positive_voltage_cell_a,
m_env.drc_positive_voltage_cell_b,
m_env.drc_positive_voltage_cell_c);
//
m_env.drc_voltage_cell_a = m_env.drc_positive_voltage_cell_a;
m_env.drc_voltage_cell_b = m_env.drc_positive_voltage_cell_b;
m_env.drc_voltage_cell_c = m_env.drc_positive_voltage_cell_c;
//
m_voltage_a = m_env.drc_voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.drc_voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.drc_voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//
//
#endif
} /* namespace SYSCTRL */

@ -0,0 +1,66 @@
/*
* AlgoritmStart.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITMPRESTART_H_
#define SYSCTRL_ALGORITMPRESTART_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmStart: public SYSCTRL::AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
#if TYPECONTROL == VECTORCONTROL
private:
float m_reference_zero;
float m_reference_current_cell_direct;
float m_reference_current_cell_quadrature;
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
float m_reference_zero;
float m_reference_current_cell_direct;
float m_reference_current_cell_quadrature;
#endif
public:
AlgorithmStart(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmStart::*_execute)();
void _execute_run();
#if TYPECONTROL == SCALARCONTROL
private:
inline void _execute_single_phase(SYSCTRL::AlgorithmStartSinglePhaseControl& phase,
SYSCTRL::VectorOrthogonalProjection& orts,
float dc_voltage_reciprocal,
FLTSYSLIB::PIController& referencer_active,
FLTSYSLIB::PIController& referencer_reactive,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive);
#endif
//
};//AlgoritmPrestart
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITMPRESTART_H_ */

@ -0,0 +1,247 @@
/*
* AlgorithmStop.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmStop.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmStop::AlgorithmStop(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
_execute(&SYSCTRL::AlgorithmStop::_execute_undef)
//
{}//CONSTRUCTOR
//
void AlgorithmStop::setup()
{
_execute = &SYSCTRL::AlgorithmStop::_execute_run;
//
}//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStop::reset()
{
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStop::execute()
{
(this->*_execute)();
//
}//
//
#if TYPECONTROL == VECTORCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStop::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_stop.execute();
//
if(m_env.timer_stop.is_finished()){
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}else{
//
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_PII
m_env.voltage_reference_load_direct = m_env.reference_voltage_direct_intensity.execute(m_env.voltage_grid_direct);
//m_env.voltage_reference_load_direct = 0.33333*(m_env.rms_voltage_input_a + m_env.rms_voltage_input_b + m_env.rms_voltage_input_c);
//m_env.voltage_reference_load_quadrature = m_env.voltage_grid_quadrature;
m_env.voltage_reference_load_quadrature = FP_ZERO;
m_env.voltage_pi_reg_out_direct = m_env.regulator_voltage_load_direct.execute(m_env.voltage_reference_load_direct, m_env.voltage_load_direct);
//m_env.voltage_pi_reg_out_quadrature = m_env.regulator_voltage_load_quadrature.execute(m_env.voltage_reference_load_quadrature, m_env.voltage_load_quadrature);
m_env.voltage_pi_reg_out_quadrature = FP_ZERO;
//
m_env.voltage_cell_direct = m_env.integrator_direct.execute(m_env.voltage_pi_reg_out_direct);
//m_env.voltage_cell_quadrature = m_env.integrator_quadrature.execute(m_env.voltage_pi_reg_out_quadrature);
m_env.voltage_cell_quadrature = FP_ZERO;
#endif
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_I
m_env.voltage_reference_load_direct = m_env.reference_voltage_direct_intensity.execute(m_env.voltage_grid_direct);
m_env.voltage_reference_load_quadrature = FP_ZERO;
m_env.voltage_cell_direct = m_env.integrator_direct.execute(m_env.voltage_reference_load_direct - m_env.voltage_load_direct);
m_env.voltage_cell_quadrature = FP_ZERO;
#endif
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.voltage_cell_direct,
m_env.voltage_cell_quadrature,
m_env.voltage_cell_alpha,
m_env.voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.voltage_cell_alpha,
m_env.voltage_cell_beta,
m_env.voltage_cell_a,
m_env.voltage_cell_b,
m_env.voltage_cell_c);
//
m_voltage_a = m_env.voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//if else
//
//
}//
#endif
//
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStop::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_stop.execute();
//
//
//reference constructor
// m_env.phase_control.common_ref.voltage_rms_real = m_env.phase_control.common_ref.voltage_module_rms;
//m_env.phase_control.common_ref.voltage_rms_jm = FP_ZERO;
// m_env.phase_control.phase_a.reference.voltage_ampl_real_const = m_env.phase_control.common_ref.voltage_rms_real;
//m_env.phase_control.phase_a.reference.voltage_ampl_jm_const = m_env.phase_control.common_ref.voltage_rms_jm;
// m_env.phase_control.phase_a.reference.voltage_ampl_jm_const = m_env.projection_voltage_input_a.reactive;
// m_env.phase_control.phase_b.reference.voltage_ampl_real_const = m_env.phase_control.common_ref.voltage_rms_real;
//m_env.phase_control.phase_b.reference.voltage_ampl_jm_const = m_env.phase_control.common_ref.voltage_rms_jm;
// m_env.phase_control.phase_b.reference.voltage_ampl_jm_const = m_env.projection_voltage_input_b.reactive;
// m_env.phase_control.phase_c.reference.voltage_ampl_real_const = m_env.phase_control.common_ref.voltage_rms_real;
//m_env.phase_control.phase_c.reference.voltage_ampl_jm_const = m_env.phase_control.common_ref.voltage_rms_jm;
// m_env.phase_control.phase_c.reference.voltage_ampl_jm_const = m_env.projection_voltage_input_c.reactive;
//
//m_env.phase_control.phase_a.reference.voltage_ampl_real = m_env.phase_control.phase_a.reference.voltage_ampl_real_const;
//m_env.phase_control.phase_a.reference.voltage_ampl_jm = m_env.phase_control.phase_a.reference.voltage_ampl_jm_const;
//m_env.phase_control.phase_b.reference.voltage_ampl_real = m_env.phase_control.phase_b.reference.voltage_ampl_real_const;
//m_env.phase_control.phase_b.reference.voltage_ampl_jm = m_env.phase_control.phase_b.reference.voltage_ampl_jm_const;
//m_env.phase_control.phase_c.reference.voltage_ampl_real = m_env.phase_control.phase_c.reference.voltage_ampl_real_const;
//m_env.phase_control.phase_c.reference.voltage_ampl_jm = m_env.phase_control.phase_c.reference.voltage_ampl_jm_const;
m_env.phase_control.phase_a.reference.voltage_ampl_real = m_env.projection_voltage_input_a.active;
m_env.phase_control.phase_a.reference.voltage_ampl_jm = m_env.projection_voltage_input_a.reactive;
m_env.phase_control.phase_b.reference.voltage_ampl_real = m_env.projection_voltage_input_b.active;
m_env.phase_control.phase_b.reference.voltage_ampl_jm = m_env.projection_voltage_input_b.reactive;
m_env.phase_control.phase_c.reference.voltage_ampl_real = m_env.projection_voltage_input_c.active;
m_env.phase_control.phase_c.reference.voltage_ampl_jm = m_env.projection_voltage_input_c.reactive;
//
//control execute
_execute_single_phase(m_env.phase_control.phase_a,
m_env.main_abc_orts.phase_a,
m_env.regulator_voltage_load_a_active,
m_env.regulator_voltage_load_a_reactive);
//
_execute_single_phase(m_env.phase_control.phase_b,
m_env.main_abc_orts.phase_b,
m_env.regulator_voltage_load_b_active,
m_env.regulator_voltage_load_b_reactive);
//
_execute_single_phase(m_env.phase_control.phase_c,
m_env.main_abc_orts.phase_c,
m_env.regulator_voltage_load_c_active,
m_env.regulator_voltage_load_c_reactive);
//
if(m_env.timer_stop.is_finished()){
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
}else{
m_voltage_a = m_env.phase_control.phase_a.reference.voltage_cell_relative;
m_voltage_b = m_env.phase_control.phase_b.reference.voltage_cell_relative;
m_voltage_c = m_env.phase_control.phase_c.reference.voltage_cell_relative;
}
//
}//
#endif
//
//
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
inline void AlgorithmStop::_execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& phase,
SYSCTRL::VectorOrthogonalProjection& orts,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive)
{
phase.reference.voltage_cell_ampl_real = regulator_active.execute(phase.reference.voltage_ampl_real, phase.feedback.voltage_ampl_real);
phase.reference.voltage_cell_ampl_jm = regulator_reactive.execute(phase.reference.voltage_ampl_jm, phase.feedback.voltage_ampl_jm);
//
phase.reference.voltage_cell_real = phase.reference.voltage_cell_ampl_real * orts.active;
phase.reference.voltage_cell_jm = phase.reference.voltage_cell_ampl_jm * orts.reactive;
phase.reference.voltage_cell = phase.reference.voltage_cell_real - phase.reference.voltage_cell_jm;
//
phase.reference.voltage_cell_relative = phase.reference.voltage_cell * phase.feedback.voltage_cell_dc_reciprocal;
//
}//
#endif
//
#if TYPECONTROL == DIRECTREVERSECONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmStop::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_stop.execute();
//
if(m_env.timer_stop.is_finished()){
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}else{
//
m_env.drc_voltage_reference_load_direct = m_env.drc_reference_voltage_direct_intensity.execute(m_env.drc_voltage_grid_direct);
m_env.drc_voltage_reference_load_quadrature = FP_ZERO;
//
m_env.drc_positive_voltage_cell_direct = m_env.drc_positive_voltage_controller_direct.execute(m_env.drc_voltage_reference_load_direct, m_env.drc_positive_voltage_load_direct);
m_env.drc_positive_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_direct = FP_ZERO;
m_env.drc_negative_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_alpha = FP_ZERO;
m_env.drc_negative_voltage_cell_beta = FP_ZERO;
m_env.drc_negative_voltage_cell_a = FP_ZERO;
m_env.drc_negative_voltage_cell_b = FP_ZERO;
m_env.drc_negative_voltage_cell_c = FP_ZERO;
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.drc_positive_voltage_cell_direct,
m_env.drc_positive_voltage_cell_quadrature,
m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta,
m_env.drc_positive_voltage_cell_a,
m_env.drc_positive_voltage_cell_b,
m_env.drc_positive_voltage_cell_c);
//
m_env.drc_voltage_cell_a = m_env.drc_positive_voltage_cell_a;
m_env.drc_voltage_cell_b = m_env.drc_positive_voltage_cell_b;
m_env.drc_voltage_cell_c = m_env.drc_positive_voltage_cell_c;
//
m_voltage_a = m_env.drc_voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.drc_voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.drc_voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//if else
//
}//
#endif
} /* namespace SYSCTRL */

@ -0,0 +1,48 @@
/*
* AlgorithmStop.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITHMSTOP_H_
#define SYSCTRL_ALGORITHMSTOP_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmStop: public SYSCTRL::AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmStop(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmStop::*_execute)();
void _execute_run();
#if TYPECONTROL == SCALARCONTROL
private:
inline void _execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& phase,
SYSCTRL::VectorOrthogonalProjection& orts,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive);
#endif
//
};//AlgorithmPrestop
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMSTOP_H_ */

@ -0,0 +1,407 @@
/*
* AlgorithmWork.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmWork.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmWork::AlgorithmWork(SYSCTRL::SystemEnvironment& env):
AlgorithmBase(),
m_env(env),
m_reference_switcher(false),
_execute(&SYSCTRL::AlgorithmWork::_execute_undef)
//
{}//CONSTRUCTOR
//
void AlgorithmWork::setup()
{
_execute = &SYSCTRL::AlgorithmWork::_execute_run;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::reset()
{
#if TYPECONTROL == VECTORCONTROL
//
m_env.regulator_voltage_load_direct.reset();
m_env.regulator_voltage_load_quadrature.reset();
//
m_env.integrator_direct.reset();
m_env.integrator_quadrature.reset();
//
m_env.regulator_current_limit.set_to_high_saturation();
m_env.regulator_current_pfc.reset();
//
#endif
#if TYPECONTROL == SCALARCONTROL
//
m_env.regulator_current_limit_a.set_to_high_saturation();
m_env.regulator_current_pfc_a.reset();
m_env.regulator_current_limit_b.set_to_high_saturation();
m_env.regulator_current_pfc_b.reset();
m_env.regulator_current_limit_c.set_to_high_saturation();
m_env.regulator_current_pfc_c.reset();
m_env.regulator_voltage_load_a_active.reset();
m_env.regulator_voltage_load_a_reactive.reset();
m_env.regulator_voltage_load_b_active.reset();
m_env.regulator_voltage_load_b_reactive.reset();
m_env.regulator_voltage_load_c_active.reset();
m_env.regulator_voltage_load_c_reactive.reset();
//
#endif
#if TYPECONTROL == DIRECTREVERSECONTROL
m_env.drc_positive_voltage_controller_direct.reset();
m_env.drc_positive_voltage_controller_quadrature.reset();
m_env.drc_negative_voltage_controller_direct.reset();
m_env.drc_negative_voltage_controller_quadrature.reset();
//
m_env.drc_reference_voltage_direct_intensity.reset();
//
m_env.drc_regulator_current_load_direct.reset();
m_env.drc_regulator_current_load_quadrature.reset();
//
m_env.drc_referencer_current_bypass_direct.reset();
m_env.drc_referencer_current_bypass_quadrature.reset();
//
m_env.drc_regulator_current_limit.set_to_low_saturation();
m_env.drc_regulator_current_pfc.reset();
//
m_reference_switcher = false;
//
#endif
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::reset_switcher()
{
m_reference_switcher = false;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::execute()
{
(this->*_execute)();
//
}//
//
#if TYPECONTROL == VECTORCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
//if(m_env.algorithm_control.signal.enable_current_limit)
if(false)
{
m_env.voltage_reference_load_direct = m_env.regulator_current_limit.execute(m_env.rms_current_load_module, m_env.current_reference_limit);
}
else
{
m_env.regulator_current_limit.set_to_low_saturation();
m_env.voltage_reference_load_direct = m_env.regulator_current_limit.get_output();
}
//
//if(m_env.algorithm_control.signal.enable_pfc)
if(false)
{
m_env.regulator_current_pfc.reset();
m_env.voltage_reference_load_quadrature = m_env.regulator_current_pfc.get_output();
}
else
{
m_env.regulator_current_pfc.reset();
m_env.voltage_reference_load_quadrature = m_env.regulator_current_pfc.get_output();
}
//
// for PII-Controller
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_PII
m_env.voltage_pi_reg_out_direct = m_env.regulator_voltage_load_direct.execute(m_env.voltage_reference_load_direct, m_env.voltage_load_direct);
//m_env.voltage_pi_reg_out_quadrature = m_env.regulator_voltage_load_quadrature.execute(m_env.voltage_reference_load_quadrature, m_env.voltage_load_quadrature);
m_env.voltage_pi_reg_out_quadrature = FP_ZERO;
m_env.voltage_cell_direct = m_env.integrator_direct.execute(m_env.voltage_pi_reg_out_direct);
//m_env.voltage_cell_quadrature = m_env.integrator_quadrature.execute(m_env.voltage_pi_reg_out_quadrature);
m_env.voltage_cell_quadrature = FP_ZERO;
#endif
// for I-Controller
#if TYPE_VOLTAGE_CONTROLLER == VOLTAGE_CONTROLLER_I
m_env.voltage_cell_direct = m_env.integrator_direct.execute(m_env.voltage_reference_load_direct - m_env.voltage_load_direct);
m_env.voltage_cell_quadrature = FP_ZERO;
#endif
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.voltage_cell_direct,
m_env.voltage_cell_quadrature,
m_env.voltage_cell_alpha,
m_env.voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.voltage_cell_alpha,
m_env.voltage_cell_beta,
m_env.voltage_cell_a,
m_env.voltage_cell_b,
m_env.voltage_cell_c);
//
m_voltage_a = m_env.voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//
//
#endif
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
m_env.phase_control.phase_a.reference.voltage_dc = m_env.phase_control.common_ref.voltage_dc;
m_env.phase_control.phase_b.reference.voltage_dc = m_env.phase_control.common_ref.voltage_dc;
m_env.phase_control.phase_c.reference.voltage_dc = m_env.phase_control.common_ref.voltage_dc;
m_env.phase_control.phase_a.reference.current_ampl_limit_const = m_env.phase_control.common_ref.current_limit_rms;
m_env.phase_control.phase_b.reference.current_ampl_limit_const = m_env.phase_control.common_ref.current_limit_rms;
m_env.phase_control.phase_c.reference.current_ampl_limit_const = m_env.phase_control.common_ref.current_limit_rms;
m_env.phase_control.phase_a.reference.current_ampl_pfc_const = m_env.phase_control.common_ref.current_pfc_rms;
m_env.phase_control.phase_b.reference.current_ampl_pfc_const = m_env.phase_control.common_ref.current_pfc_rms;
m_env.phase_control.phase_c.reference.current_ampl_pfc_const = m_env.phase_control.common_ref.current_pfc_rms;
_execute_single_phase(m_env.phase_control.phase_a,
m_env.projection_voltage_input_a,
m_env.main_abc_orts.phase_a,
m_env.regulator_current_limit_a,
m_env.regulator_current_pfc_a,
m_env.regulator_dc_a,
m_env.cell_dc_voltage_a,
m_env.regulator_voltage_load_a_active,
m_env.regulator_voltage_load_a_reactive);
_execute_single_phase(m_env.phase_control.phase_b,
m_env.projection_voltage_input_b,
m_env.main_abc_orts.phase_b,
m_env.regulator_current_limit_b,
m_env.regulator_current_pfc_b,
m_env.regulator_dc_b,
m_env.cell_dc_voltage_b,
m_env.regulator_voltage_load_b_active,
m_env.regulator_voltage_load_b_reactive);
_execute_single_phase(m_env.phase_control.phase_c,
m_env.projection_voltage_input_c,
m_env.main_abc_orts.phase_c,
m_env.regulator_current_limit_c,
m_env.regulator_current_pfc_c,
m_env.regulator_dc_c,
m_env.cell_dc_voltage_c,
m_env.regulator_voltage_load_c_active,
m_env.regulator_voltage_load_c_reactive);
m_voltage_a = m_env.phase_control.phase_a.reference.voltage_cell_relative;
m_voltage_b = m_env.phase_control.phase_b.reference.voltage_cell_relative;
m_voltage_c = m_env.phase_control.phase_c.reference.voltage_cell_relative;
//
}//
#endif
//
#if TYPECONTROL == SCALARCONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::_execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& phase,
SYSCTRL::ProjectionAnalogSignalStructure& projection,
SYSCTRL::VectorOrthogonalProjection& orts,
FLTSYSLIB::PIController& regulator_limit,
FLTSYSLIB::PIController& regulator_pfc,
FLTSYSLIB::PIController& regulator_dc,
float& dc_volatage,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive)
{
if(phase.control_bit.signal.enable_current_limit)
{
phase.reference.voltage_limit = regulator_limit.execute(phase.reference.current_ampl_limit_const, phase.feedback.current_ampl_real);
if(phase.control_bit.signal.enable_pfc)
{
phase.reference.voltage_pfc = regulator_pfc.execute(phase.reference.current_ampl_pfc_const, phase.feedback.current_ampl_jm) +
regulator_dc.execute(phase.reference.voltage_dc, dc_volatage);
}
else
{
regulator_pfc.reset();
phase.reference.voltage_pfc = projection.reactive;
//
}//if else
}
else
{
regulator_limit.set_to_high_saturation();
phase.reference.voltage_limit = regulator_limit.get_output();
//
regulator_pfc.reset();
phase.reference.voltage_pfc = projection.reactive;
//
}//if else
if(phase.control_bit.signal.enable_pfc)
{
phase.reference.voltage_ampl_real = sqrtf(phase.reference.voltage_limit * phase.reference.voltage_limit - phase.reference.voltage_pfc * phase.reference.voltage_pfc);
phase.reference.voltage_ampl_jm = phase.reference.voltage_pfc;
//
}
else
{
phase.reference.voltage_ampl_real = phase.reference.voltage_limit;
phase.reference.voltage_ampl_jm = phase.reference.voltage_pfc;
//
}//if else
//
phase.reference.voltage_cell_ampl_real = regulator_active.execute(phase.reference.voltage_ampl_real, phase.feedback.voltage_ampl_real);
//
if(phase.control_bit.signal.enable_pfc)
{
phase.reference.voltage_cell_ampl_jm = regulator_reactive.execute(phase.reference.voltage_ampl_jm, phase.feedback.voltage_ampl_jm);
//
}
else
{
phase.reference.voltage_cell_ampl_jm = FP_ZERO;
//
}//if
//
phase.reference.voltage_cell_real = phase.reference.voltage_cell_ampl_real * orts.active;
phase.reference.voltage_cell_jm = phase.reference.voltage_cell_ampl_jm * orts.reactive;
phase.reference.voltage_cell = phase.reference.voltage_cell_real - phase.reference.voltage_cell_jm;
//
phase.reference.voltage_cell_relative = phase.reference.voltage_cell * phase.feedback.voltage_cell_dc_reciprocal;
//
}//
#endif
//
#if TYPECONTROL == DIRECTREVERSECONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWork::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
if(m_reference_switcher)
{
//if(m_env.algorithm_control.signal.enable_current_limit)
if(false)
{
m_env.drc_voltage_reference_load_direct = m_env.drc_regulator_current_limit.execute(m_env.rms_current_load_module, m_env.drc_current_reference_limit);
}
else
{
m_env.drc_regulator_current_limit.set_to_low_saturation();
m_env.drc_voltage_reference_load_direct = m_env.drc_regulator_current_limit.get_output();
}
}
else
{
m_env.drc_voltage_reference_load_direct = m_env.drc_reference_voltage_direct_intensity.execute(m_env.drc_regulator_current_limit.get_output());
//
if(m_env.drc_voltage_reference_load_direct >= m_env.drc_regulator_current_limit.get_output())
{
m_reference_switcher = true;
}
}
//
//if(m_env.algorithm_control.signal.enable_pfc)
if(false)
{
m_env.drc_regulator_current_pfc.reset();
m_env.drc_voltage_reference_load_quadrature = m_env.drc_regulator_current_pfc.get_output();
}
else
{
m_env.drc_regulator_current_pfc.reset();
m_env.drc_voltage_reference_load_quadrature = m_env.drc_regulator_current_pfc.get_output();
}
//
m_env.drc_positive_voltage_cell_direct = m_env.drc_positive_voltage_controller_direct.execute(m_env.drc_voltage_reference_load_direct, m_env.drc_positive_voltage_load_direct);
//m_env.drc_positive_voltage_cell_quadrature = m_env.drc_positive_voltage_controller_quadrature.execute(m_env.drc_voltage_reference_load_quadrature, m_env.drc_positive_voltage_load_quadrature);
m_env.drc_positive_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_direct = m_env.drc_negative_voltage_controller_direct.execute(m_env.drc_voltage_reference_zero, m_env.drc_negaative_voltage_load_direct);
m_env.drc_negative_voltage_cell_quadrature = m_env.drc_negative_voltage_controller_quadrature.execute(m_env.drc_voltage_reference_zero, m_env.drc_negative_voltage_load_quadrature);
//m_env.drc_negative_voltage_cell_direct = FP_ZERO;
//m_env.drc_negative_voltage_cell_quadrature = FP_ZERO;
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.drc_positive_voltage_cell_direct,
m_env.drc_positive_voltage_cell_quadrature,
m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta);
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.drc_negative_voltage_cell_direct,
m_env.drc_negative_voltage_cell_quadrature,
m_env.drc_negative_voltage_cell_alpha,
m_env.drc_negative_voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta,
m_env.drc_positive_voltage_cell_a,
m_env.drc_positive_voltage_cell_b,
m_env.drc_positive_voltage_cell_c);
//
FLTSYSLIB::Transformation::clarke_inverse_back_order(m_env.drc_negative_voltage_cell_alpha,
m_env.drc_negative_voltage_cell_beta,
m_env.drc_negative_voltage_cell_a,
m_env.drc_negative_voltage_cell_b,
m_env.drc_negative_voltage_cell_c);
//
m_env.drc_voltage_cell_a = m_env.drc_positive_voltage_cell_a + m_env.drc_negative_voltage_cell_a;
m_env.drc_voltage_cell_b = m_env.drc_positive_voltage_cell_b + m_env.drc_negative_voltage_cell_b;
m_env.drc_voltage_cell_c = m_env.drc_positive_voltage_cell_c + m_env.drc_negative_voltage_cell_c;
//
m_voltage_a = m_env.drc_voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.drc_voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.drc_voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//
#endif
//
} /* namespace SYSCTRL */

@ -0,0 +1,55 @@
/*
* AlgorithmWork.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITHMNORMAL_H_
#define SYSCTRL_ALGORITHMNORMAL_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmWork: public SYSCTRL::AlgorithmBase
{
private:
bool m_reference_switcher;
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmWork(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
void reset_switcher();
public:
void execute();
private:
void (AlgorithmWork::*_execute)();
void _execute_run();
#if TYPECONTROL == SCALARCONTROL
private:
void _execute_single_phase(SYSCTRL::AlgorithmSinglePhaseControl& phase,
SYSCTRL::ProjectionAnalogSignalStructure& projection,
SYSCTRL::VectorOrthogonalProjection& orts,
FLTSYSLIB::PIController& regulator_limit,
FLTSYSLIB::PIController& regulator_pfc,
FLTSYSLIB::PIController& regulator_dc,
float& dc_volatage,
FLTSYSLIB::PIController& regulator_active,
FLTSYSLIB::PIController& regulator_reactive);
#endif
};//AlgorithmNormal
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMNORMAL_H_ */

@ -0,0 +1,112 @@
/*
* AlgorithmWorkEntry.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/AlgorithmWorkEntry.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmWorkEntry::AlgorithmWorkEntry(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
_execute(&SYSCTRL::AlgorithmWorkEntry::_execute_undef)
{}//CONSTRUCTOR
void AlgorithmWorkEntry::setup()
{
_execute = &SYSCTRL::AlgorithmWorkEntry::_execute_run;
//
}//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWorkEntry::reset()
{
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWorkEntry::execute()
{
(this->*_execute)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool AlgorithmWorkEntry::compare_mode(mode_t mode)
{
return m_mode == mode;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWorkEntry::set_mode(mode_t mode)
{
m_mode = mode;
//
}//
//
#if TYPECONTROL == DIRECTREVERSECONTROL
#pragma CODE_SECTION("ramfuncs");
void AlgorithmWorkEntry::_execute_run()
{
m_env.hardware.ref_control_order = ORDER_START;
//
m_env.timer_stop.execute();
//
if(m_env.timer_stop.is_finished()){
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}else{
//
m_env.drc_voltage_reference_load_direct = m_env.drc_reference_voltage_direct_intensity.execute(m_env.drc_voltage_grid_direct);
m_env.drc_voltage_reference_load_quadrature = FP_ZERO;
//
m_env.drc_positive_voltage_cell_direct = m_env.drc_positive_voltage_controller_direct.execute(m_env.drc_voltage_reference_load_direct, m_env.drc_positive_voltage_load_direct);
m_env.drc_positive_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_direct = FP_ZERO;
m_env.drc_negative_voltage_cell_quadrature = FP_ZERO;
m_env.drc_negative_voltage_cell_alpha = FP_ZERO;
m_env.drc_negative_voltage_cell_beta = FP_ZERO;
m_env.drc_negative_voltage_cell_a = FP_ZERO;
m_env.drc_negative_voltage_cell_b = FP_ZERO;
m_env.drc_negative_voltage_cell_c = FP_ZERO;
//
FLTSYSLIB::Transformation::park_inverse(m_env.main_ab_orts.active,
m_env.main_ab_orts.reactive,
m_env.drc_positive_voltage_cell_direct,
m_env.drc_positive_voltage_cell_quadrature,
m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta);
//
FLTSYSLIB::Transformation::clarke_inverse(m_env.drc_positive_voltage_cell_alpha,
m_env.drc_positive_voltage_cell_beta,
m_env.drc_positive_voltage_cell_a,
m_env.drc_positive_voltage_cell_b,
m_env.drc_positive_voltage_cell_c);
//
m_env.drc_voltage_cell_a = m_env.drc_positive_voltage_cell_a;
m_env.drc_voltage_cell_b = m_env.drc_positive_voltage_cell_b;
m_env.drc_voltage_cell_c = m_env.drc_positive_voltage_cell_c;
//
m_voltage_a = m_env.drc_voltage_cell_a * m_env.cell_dc_voltage_a_reciprocal;
m_voltage_b = m_env.drc_voltage_cell_b * m_env.cell_dc_voltage_b_reciprocal;
m_voltage_c = m_env.drc_voltage_cell_c * m_env.cell_dc_voltage_c_reciprocal;
//
}//if else
//
}//
#endif
} /* namespace SYSCTRL */

@ -0,0 +1,41 @@
/*
* AlgorithmWorkEntry.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITHMWORKENTRY_H_
#define SYSCTRL_ALGORITHMWORKENTRY_H_
#include "SYSCTRL/AlgorithmBase.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
namespace SYSCTRL
{
class AlgorithmWorkEntry: public AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmWorkEntry(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmWorkEntry::*_execute)();
void _execute_run();
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMWORKENTRY_H_ */

@ -0,0 +1,50 @@
/*
* AlgorithmZero.cpp
*
* Created on: 20 ìàÿ 2022 ã.
* Author: geras
*/
#include "SYSCTRL/AlgorithmZero.h"
namespace SYSCTRL
{
//CONSTRUCTOR
AlgorithmZero::AlgorithmZero(SYSCTRL::SystemEnvironment& env):
SYSCTRL::AlgorithmBase(),
m_env(env),
_execute(&SYSCTRL::AlgorithmZero::_execute_undef)
{}//CONSTRUCTOR
void AlgorithmZero::setup()
{
_execute = &SYSCTRL::AlgorithmZero::_execute_run;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmZero::reset()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmZero::execute()
{
(this->*_execute)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void AlgorithmZero::_execute_run()
{
//
m_env.hardware.ref_control_order = ORDER_START;
//
m_voltage_a = FP_ZERO;
m_voltage_b = FP_ZERO;
m_voltage_c = FP_ZERO;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,38 @@
/*
* AlgorithmZero.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ALGORITHMZERO_H_
#define SYSCTRL_ALGORITHMZERO_H_
#include "SYSCTRL/AlgorithmBase.h"
namespace SYSCTRL
{
class AlgorithmZero: public AlgorithmBase
{
private:
SYSCTRL::SystemEnvironment& m_env;
public:
AlgorithmZero(SYSCTRL::SystemEnvironment& env);
public:
void setup();
public:
void reset();
public:
void execute();
private:
void (AlgorithmZero::*_execute)();
void _execute_run();
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ALGORITHMZERO_H_ */

@ -0,0 +1,33 @@
/*
* BaseComponent.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/BaseComponent.h"
namespace SYSCTRL
{
//CONSTRUCTOR
BaseComponent::BaseComponent():
m_mode(SYSCTRL::BaseComponent::UNDEFINED),
m_time_sample(-1.0)
//
{}//CONSTRUCTOR
//
#pragma CODE_SECTION("ramfuncs");
SYSCTRL::BaseComponent::mode_t BaseComponent::get_mode()
{
return m_mode;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool BaseComponent::compare(SYSCTRL::BaseComponent::mode_t mode)
{
return m_mode == mode;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,34 @@
/*
* BaseComponent.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_BASECOMPONENT_H_
#define SYSCTRL_BASECOMPONENT_H_
namespace SYSCTRL
{
class BaseComponent
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
protected:
mode_t m_mode;
protected:
float m_time_sample;
public:
BaseComponent();
public:
mode_t get_mode();
bool compare(mode_t mode);
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_BASECOMPONENT_H_ */

@ -0,0 +1,89 @@
/*
* ContactorFault.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/ContactorFault.h"
namespace SYSCTRL
{
//CONSTRUCTOR
ContactorFault::ContactorFault():
m_time_sample(-1.0),
m_period(-1.0),
m_counter(FP_ZERO),
m_status(),
status(),
_execute(&SYSCTRL::ContactorFault::_execute_undef)
{}
//end CONSTRUCTOR
void ContactorFault::setup(float time_sample)
{
m_time_sample = time_sample;
_execute = &SYSCTRL::ContactorFault::_execute_undef;
//
}//
//
void ContactorFault::configure(ContactorFaultConfiguration& config)
{
m_period = config.period;
if((m_time_sample > FP_ZERO) && (m_period > m_time_sample))
{
_execute = &SYSCTRL::ContactorFault::_execute_operational;
}
//
}//
//
//#pragma CODE_SECTION("ramfuncs");
void ContactorFault::reset(bool ref)
{
m_status.signal.fault &= !ref;
status.all = m_status.all;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void ContactorFault::execute(bool ref, bool current)
{
(this->*_execute)(ref, current);
//
}//
//
void ContactorFault::_execute_undef(bool ref, bool current)
{
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void ContactorFault::_execute_operational(bool ref, bool current)
{
if(!m_status.signal.fault)
{
if(ref == current)
{
m_counter = FP_ZERO;
}else{
if(m_counter >= m_period)
{
m_status.signal.fault = 1;
m_counter = FP_ZERO;
}else{
m_counter += m_time_sample;
}
}
}
status.all = m_status.all;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,69 @@
/*
* ContactorFault.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/BaseComponent.h"
#ifndef SYSCTRL_CONTACTORFAULT_H_
#define SYSCTRL_CONTACTORFAULT_H_
namespace SYSCTRL
{
struct ContactorFaultConfiguration
{
float period;
ContactorFaultConfiguration():
period(-1.0)
{}
};
struct ContactorFaultBitField
{
uint16_t fault: 1;
};
union ContactorFaultRegister
{
uint16_t all;
ContactorFaultBitField signal;
ContactorFaultRegister():
all((uint16_t)0)
{}
};
class ContactorFault
{
private:
float m_time_sample;
float m_period;
float m_counter;
ContactorFaultRegister m_status;
public:
ContactorFaultRegister status;
public:
ContactorFault();
void setup(float time_sample);
void configure(ContactorFaultConfiguration& config);
public:
void reset(bool ref);
public:
void execute(bool ref, bool current);
private:
void (ContactorFault::*_execute)(bool ref, bool current);
void _execute_undef(bool ref, bool current);
void _execute_operational(bool ref, bool current);
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_CONTACTORFAULT_H_ */

@ -0,0 +1,101 @@
/*
* DRCDecomposer.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/DRCDecomposer.h"
namespace SYSCTRL
{
//CONSTRUCTOR
DRCDecomposer::DRCDecomposer():
m_time_sample(-1.0),
m_filter_direct(),
m_filter_quadrature(),
_aux_reg(FP_ZERO),
direct(FP_ZERO),
quadrature(FP_ZERO),
_execute(&SYSCTRL::DRCDecomposer::_execute_undef)
{}//CONSTRUCTOR
void DRCDecomposer::setup(float time_sample)
{
if(time_sample > FP_ZERO)
{
m_time_sample = time_sample;
m_filter_direct.setup(m_time_sample);
m_filter_quadrature.setup(m_time_sample);
}
//
}//
//
void DRCDecomposer::configure(const DRCDecomposerConfiguration& config)
{
if(m_time_sample > FP_ZERO)
{
m_filter_direct.configure(config.filter);
m_filter_quadrature.configure(config.filter);
if(m_filter_direct.compare(FLTSYSLIB::Filter::OPERATIONAL) && m_filter_quadrature.compare(FLTSYSLIB::Filter::OPERATIONAL))
//if(m_filter_direct.compare(FLTSYSLIB::FilterSecond::OPERATIONAL) && m_filter_quadrature.compare(FLTSYSLIB::FilterSecond::OPERATIONAL))
{
_execute = &SYSCTRL::DRCDecomposer::_execute_operational;
//
}//if
//
}//if
//
}//
//
void DRCDecomposer::reset()
{
m_filter_direct.reset();
m_filter_quadrature.reset();
this->direct = FP_ZERO;
this->quadrature = FP_ZERO;
//
}//
//
void DRCDecomposer::get_outputs(float& outd, float& outq)
{
this->direct = m_filter_direct.get_output();
this->quadrature = m_filter_quadrature.get_output();
outd = this->direct;
outq = this->quadrature;
//
}//
//
void DRCDecomposer::execute(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c)
{
(this->*_execute)(in_a, in_b, in_c,
ort_direct_a, ort_direct_b, ort_direct_c,
ort_orthogonal_a, ort_orthogonal_b, ort_orthogonal_c);
//
}//
//
void DRCDecomposer::_execute_undef(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c)
{
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void DRCDecomposer::_execute_operational(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c)
{
_aux_reg = (0.4714045)*(in_a * ort_direct_a + in_b * ort_direct_b + in_c * ort_direct_c);
direct = m_filter_direct.execute(_aux_reg);
_aux_reg = (-0.4714045)*(in_a * ort_orthogonal_a + in_b * ort_orthogonal_b + in_c * ort_orthogonal_c);
quadrature = m_filter_quadrature.execute(_aux_reg);
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,85 @@
/*
* DRCDecomposer.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/BaseComponent.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
#ifndef SYSCTRL_DRCDECOMPOSER_H_
#define SYSCTRL_DRCDECOMPOSER_H_
namespace SYSCTRL
{
struct DRCDecomposerStructure
{
float direct;
float quadrature;
void reset()
{
direct = FP_ZERO;
quadrature = FP_ZERO;
}
DRCDecomposerStructure():
direct(FP_ZERO),
quadrature(FP_ZERO)
{}
};//DRCDecomposerStructure
struct DRCDecomposerConfiguration
{
FLTSYSLIB::FilterConfiguration filter;
//FLTSYSLIB::FilterSecondConfiguration filter;
DRCDecomposerConfiguration():
filter()
{}
};//DRCDecomposerConfiguration
class DRCDecomposer
{
private:
float m_time_sample;
private:
FLTSYSLIB::Filter m_filter_direct;
FLTSYSLIB::Filter m_filter_quadrature;
//FLTSYSLIB::FilterSecond m_filter_direct;
//FLTSYSLIB::FilterSecond m_filter_quadrature;
private:
float _aux_reg;
public:
float direct;
float quadrature;
public:
DRCDecomposer();
void setup(float time_sample);
void configure(const DRCDecomposerConfiguration& config);
public:
void reset();
void get_outputs(float& d, float& q);
public:
void execute(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c);
private:
void (DRCDecomposer::*_execute)(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c);
void _execute_undef(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c);
void _execute_operational(float in_a, float in_b, float in_c,
float ort_direct_a, float ort_direct_b, float ort_direct_c,
float ort_orthogonal_a, float ort_orthogonal_b, float ort_orthogonal_c);
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_DRCDECOMPOSER_H_ */

@ -0,0 +1,199 @@
/*
* FanControl.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/FanControl.h"
#define KM11_TURN_OFF (Uint16)0
#define KM11_TURN_ON (Uint16)1
namespace SYSCTRL
{
//CONSTRUCTOR
FanControl::FanControl():
m_mode(SYSCTRL::FanControl::UNDEFINED),
m_time_sample(-1.0),
m_contact_bounce_period(FP_ZERO),
m_voltage_level_on(FP_ZERO),
m_voltage_level_off(FP_ZERO),
m_km11_control(0),
m_km11t_control(0),
m_fan_state(false),
m_fault(false),
m_voltage_relay(),
m_delay_off_timer(),
m_control_state_timer(),
_execute(&SYSCTRL::FanControl::_execute_undef)
//
{}//CONSTRUCTOR
void FanControl::setup(float time_sample)
{
static bool status = true;
if(m_mode == SYSCTRL::FanControl::UNDEFINED)
{
m_time_sample = time_sample;
m_delay_off_timer.setup(m_time_sample);
m_control_state_timer.setup(m_time_sample);
status &= m_time_sample > FP_ZERO ? true : false;
status &= m_delay_off_timer.compare(FLTSYSLIB::FTimer::CONFIGURATE);
status &= m_control_state_timer.compare(FLTSYSLIB::FTimer::CONFIGURATE);
if(status)
{
m_mode = SYSCTRL::FanControl::CONFIGURATE;
//
}//if
//
}//if
//
}//setup()
//
void FanControl::configure(const FanControlConfiguration& config)
{
static bool status = true;
if(m_mode == SYSCTRL::FanControl::CONFIGURATE)
{
m_voltage_level_on = config.voltage_level_on;
m_voltage_level_off = config.voltage_level_off;
FLTSYSLIB::HysteresisConfiguration hyst_config;
hyst_config.level_high = 1.0;
hyst_config.level_low = FP_ZERO;
hyst_config.off = m_voltage_level_off;
hyst_config.on = m_voltage_level_on;
m_voltage_relay.configure(hyst_config);
FLTSYSLIB::FTimerConfiguration tm_config;
tm_config.period = config.delay_off_timer;
m_delay_off_timer.configure(tm_config);
tm_config.period = config.control_state_timer;
m_control_state_timer.configure(tm_config);
status &= m_voltage_relay.compare(FLTSYSLIB::Hysteresis::OPERATIONAL);
status &= m_delay_off_timer.compare(FLTSYSLIB::FTimer::OPERATIONAL);
status &= m_control_state_timer.compare(FLTSYSLIB::FTimer::OPERATIONAL);
if(status)
{
m_mode = SYSCTRL::FanControl::OPERATIONAL;
_execute = &SYSCTRL::FanControl::_execute_undef;
//
}//if
//
}//if
//
}//configure()
//
#pragma CODE_SECTION("ramfuncs");
SYSCTRL::FanControl::mode_t FanControl::get_mode()
{
return m_mode;
//
}//get_mode()
//
#pragma CODE_SECTION("ramfuncs");
bool FanControl::compare(SYSCTRL::FanControl::mode_t mode)
{
return m_mode == mode;
//
}//compare()
//
#pragma CODE_SECTION("ramfuncs");
Uint16 FanControl::get_km11_control()
{
return m_km11_control;
//
}//get_km11_control()
//
#pragma CODE_SECTION("ramfuncs");
Uint16 FanControl::get_km11t_control()
{
return m_km11t_control;
//
}//get_km11t_control()
//
#pragma CODE_SECTION("ramfuncs");
bool FanControl::is_on()
{
return m_fan_state;
//
}//is_on()
//
#pragma CODE_SECTION("ramfuncs");
bool FanControl::is_off()
{
return !m_fan_state;
//
}//is_off()
//
#pragma CODE_SECTION("ramfuncs");
bool FanControl::is_fault()
{
return m_fault;
//
}//get_fault()
//
#pragma CODE_SECTION("ramfuncs");
void FanControl::execute(float voltage, FLTSYSLIB::DigitalInput& aux_km)
{
(this->*_execute)(voltage, aux_km);
//
}//execute()
//
#pragma CODE_SECTION("ramfuncs");
void FanControl::_execute_undef(float voltage, FLTSYSLIB::DigitalInput& aux_km)
{
//
}//_execute_undef()
//
#pragma CODE_SECTION("ramfuncs");
void FanControl::_execute_operational(float voltage, FLTSYSLIB::DigitalInput& aux_km)
{
m_fan_state = aux_km.is_on();
m_voltage_relay.execute(voltage);
m_delay_off_timer.execute();
m_control_state_timer.execute();
if(m_voltage_relay.is_on())
{
m_km11_control = KM11_TURN_ON;
m_km11t_control = KM11_TURN_OFF;
m_delay_off_timer.reset();
}
else
{
if((m_delay_off_timer.is_running()) || (m_voltage_relay.is_switched_to_off()))
{
m_km11_control = KM11_TURN_OFF;
m_km11t_control = KM11_TURN_ON;
//
}//if
//
if(m_voltage_relay.is_switched_to_off())
{
m_delay_off_timer.start();
}//if
if(m_delay_off_timer.is_finished())
{
m_km11_control = KM11_TURN_OFF;
m_km11t_control = KM11_TURN_OFF;
//
}//if
//
}//if else
//
}//_execute_operational()
//
} /* namespace SYSCTRL */

@ -0,0 +1,85 @@
/*
* FanControl.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "DSP2833x_Device.h"
#include "FLTSYSLIB/Hysteresis.h"
#include "FLTSYSLIB/DigitalInput.h"
#include "FLTSYSLIB/FTimer.h"
#include "FLTSYSLIB/Relay.h"
#ifndef SYSCTRL_FANCONTROL_H_
#define SYSCTRL_FANCONTROL_H_
namespace SYSCTRL
{
struct FanControlConfiguration
{
float delay_off_timer;
float control_state_timer;
float voltage_level_on;
float voltage_level_off;
FanControlConfiguration():
delay_off_timer(FP_ZERO),
control_state_timer(FP_ZERO),
voltage_level_on(FP_ZERO),
voltage_level_off(FP_ZERO)
{}
//
};//FanControlConfiguration
class FanControl
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
private:
mode_t m_mode;
private:
float m_time_sample;
float m_contact_bounce_period;
float m_voltage_level_on;
float m_voltage_level_off;
private:
Uint16 m_km11_control;
Uint16 m_km11t_control;
bool m_fan_state;// false - is off, true - is on
bool m_fault;
FLTSYSLIB::Hysteresis m_voltage_relay;
FLTSYSLIB::FTimer m_delay_off_timer;
FLTSYSLIB::FTimer m_control_state_timer;
public:
FanControl();
void setup(float time_sample);
void configure(const FanControlConfiguration& config);
public:
mode_t get_mode();
bool compare(mode_t mode);
public:
Uint16 get_km11_control();
Uint16 get_km11t_control();
bool is_on();
bool is_off();
bool is_fault();
public:
void execute(float voltage, FLTSYSLIB::DigitalInput& aux_km);
private:
void (FanControl::*_execute)(float voltage, FLTSYSLIB::DigitalInput& aux_km);
void _execute_undef(float voltage, FLTSYSLIB::DigitalInput& aux_km);
void _execute_operational(float voltage, FLTSYSLIB::DigitalInput& aux_km);
//
};//FanControl
} /* namespace SYSCTRL */
#endif /* SYSCTRL_FANCONTROL_H_ */

@ -0,0 +1,135 @@
/*
* FanTimerControl.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/FanTimerControl.h"
namespace SYSCTRL
{
FanTimerControl::FanTimerControl():
m_mode(SYSCTRL::FanTimerControl::UNDEFINED),
m_time_sample(-1.0),
m_timer_counter(FP_ZERO),
m_timer_period(FP_ZERO),
m_state(false),
_execute(&SYSCTRL::FanTimerControl::_execute_undef)
{}//
void FanTimerControl::setup(float time_sample)
{
if(m_mode == SYSCTRL::FanTimerControl::UNDEFINED)
{
if(time_sample >= FP_ZERO)
{
m_time_sample = time_sample;
m_mode = SYSCTRL::FanTimerControl::CONFIGURATE;
//
}//if
//
}//if
//
}//
//
void FanTimerControl::configure(const FanTimerControlConfiguration& config)
{
if(compare(SYSCTRL::FanTimerControl::CONFIGURATE))
{
if(config.timer_period > m_time_sample)
{
m_timer_period = config.timer_period;
m_timer_counter = config.timer_period;
m_mode = SYSCTRL::FanTimerControl::OPERATIONAL;
_execute = &SYSCTRL::FanTimerControl::_execute_operational;
//
}//if
//
}//if
//
//
}//
//
FanTimerControl::mode_t FanTimerControl::get_mode()
{
return m_mode;
//
}//
//
bool FanTimerControl::compare(mode_t mode)
{
return m_mode == mode;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool FanTimerControl::is_on()
{
return m_state;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool FanTimerControl::is_off()
{
return !m_state;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void FanTimerControl::execute(bool is_switched_on, bool is_switched_off)
{
(this->*_execute)(is_switched_on, is_switched_off);
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void FanTimerControl::_execute_undef(bool is_switched_on, bool is_switched_off)
{
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void FanTimerControl::_execute_operational(bool is_switched_on, bool is_switched_off)
{
if(m_state)
{
// is on
if(m_timer_counter >= FP_ZERO)
{
m_timer_counter -= m_time_sample;
}
else
{
m_state = false;
m_timer_counter = m_timer_period;
}
}
else
{
// is off
if(is_switched_off)
{
m_state = true;
}
else
{
m_timer_counter = m_timer_period;
}
}
//
if(is_switched_on)
{
m_state = false;
m_timer_counter = m_timer_period;
}
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,62 @@
/*
* FanTimerControl.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_FANTIMERCONTROL_H_
#define SYSCTRL_FANTIMERCONTROL_H_
namespace SYSCTRL
{
struct FanTimerControlConfiguration
{
float timer_period;
FanTimerControlConfiguration():
timer_period(-1.0)
{}
//
};//FanTimerControlConfiguration
class FanTimerControl
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
private:
mode_t m_mode;
private:
float m_time_sample;
private:
float m_timer_counter;
float m_timer_period;
bool m_state;
public:
FanTimerControl();
void setup(float time_sample);
void configure(const FanTimerControlConfiguration& config);
public:
mode_t get_mode();
bool compare(mode_t mode);
public:
bool is_on();
bool is_off();
public:
void execute(bool is_switched_on, bool is_switched_off);
private:
void (FanTimerControl::*_execute)(bool is_switched_on, bool is_switched_off);
void _execute_undef(bool is_switched_on, bool is_switched_off);
void _execute_operational(bool is_switched_on, bool is_switched_off);
};
} /* namespace SYSCTRL */
#endif /* SYSCTRL_FANTIMERCONTROL_H_ */

@ -0,0 +1,81 @@
/*
* GeneratorSymmetricalComponents.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/GeneratorSymmetricalComponents.h"
namespace SYSCTRL
{
//CONSTRUCTOR
GeneratorSymmetricalComponents::GeneratorSymmetricalComponents():
m_amplitude(),
m_phase(),
m_ort_direct_alpha(FP_ZERO),
m_ort_direct_beta(FP_ZERO),
m_ort_inverse_alpha(FP_ZERO),
m_ort_inverse_beta(FP_ZERO),
m_direct_alpha(FP_ZERO),
m_direct_beta(FP_ZERO),
m_inverse_alpha(FP_ZERO),
m_inverse_beta(FP_ZERO),
m_direct_a(FP_ZERO),
m_direct_b(FP_ZERO),
m_direct_c(FP_ZERO),
m_inverse_a(FP_ZERO),
m_inverse_b(FP_ZERO),
m_inverse_c(FP_ZERO),
m_out_a(FP_ZERO),
m_out_b(FP_ZERO),
m_out_c(FP_ZERO)
//
{}//CONSTRUCTOR
#pragma CODE_SECTION("ramfuncs");
void GeneratorSymmetricalComponents::configure(GeneratorSymmetricalComponentsConfiguration& config)
{
m_amplitude = config.amplitude;
m_phase = config.phase;
//
}//
#pragma CODE_SECTION("ramfuncs");
void GeneratorSymmetricalComponents::execute(float ort_alpha, float ort_beta)
{
m_phase.direct.cos_phase = cosf(m_phase.direct.phase);
m_phase.direct.sin_phase = sinf(m_phase.direct.phase);
m_phase.inverse.cos_phase = cosf(m_phase.inverse.phase);
m_phase.inverse.sin_phase = sinf(m_phase.inverse.phase);
//
m_ort_direct_alpha = ort_alpha * m_phase.direct.cos_phase - ort_beta * m_phase.direct.sin_phase;
m_ort_direct_beta = ort_alpha * m_phase.direct.sin_phase + ort_beta * m_phase.direct.cos_phase;
//
m_ort_inverse_alpha = ort_alpha * m_phase.inverse.cos_phase + ort_beta * m_phase.inverse.sin_phase;
m_ort_inverse_beta = ort_alpha * m_phase.inverse.sin_phase - ort_beta * m_phase.inverse.cos_phase;
//
FLTSYSLIB::Transformation::park_inverse(m_ort_direct_alpha, m_ort_direct_beta, m_amplitude.direct.d, m_amplitude.direct.q, m_direct_alpha, m_direct_beta);
FLTSYSLIB::Transformation::park_inverse(m_ort_inverse_alpha, m_ort_inverse_beta, m_amplitude.inverse.d, m_amplitude.inverse.q, m_inverse_alpha, m_inverse_beta);
FLTSYSLIB::Transformation::clarke_inverse(m_direct_alpha, m_direct_beta, m_direct_a, m_direct_b, m_direct_c);
FLTSYSLIB::Transformation::clarke_inverse(m_inverse_alpha, m_inverse_beta, m_inverse_a, m_inverse_b, m_inverse_c);
//
m_out_a = m_direct_a + m_inverse_a + m_amplitude.zero_a;
m_out_b = m_direct_b + m_inverse_b + m_amplitude.zero_b;
m_out_c = m_direct_c + m_inverse_c + m_amplitude.zero_c;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void GeneratorSymmetricalComponents::get_output(float& out_a, float& out_b, float& out_c)
{
out_a = m_out_a;
out_b = m_out_b;
out_c = m_out_c;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,123 @@
/*
* GeneratorSymmetricalComponents.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef SYSCTRL_GENERATORSYMMETRICALCOMPONENTS_H_
#define SYSCTRL_GENERATORSYMMETRICALCOMPONENTS_H_
#include <math.h>
#include <stdint.h>
//#include "SYSCTRL/HeadersFLTSYSLIB.h"
#include "FLTSYSLIB/Transformation.h"
namespace SYSCTRL
{
struct GeneratorPhase
{
float phase;
float cos_phase;
float sin_phase;
GeneratorPhase():
phase(FP_ZERO),
cos_phase(FP_ZERO),
sin_phase(FP_ZERO)
{}
};//GeneratorPhase
struct GeneratorSymmetricalComponentsPhase
{
GeneratorPhase direct;
GeneratorPhase inverse;
GeneratorSymmetricalComponentsPhase():
direct(),
inverse()
{}
};//GeneratorSymmetricalComponentsPhase
struct GeneratorAmplitude
{
float d;
float q;
GeneratorAmplitude():
d(FP_ZERO),
q(FP_ZERO)
{}
};//GeneratorAmplitude
struct GeneratorSymmetricalComponentsAmplitude
{
GeneratorAmplitude direct;
GeneratorAmplitude inverse;
float zero_a;
float zero_b;
float zero_c;
GeneratorSymmetricalComponentsAmplitude():
direct(),
inverse(),
zero_a(FP_ZERO),
zero_b(FP_ZERO),
zero_c(FP_ZERO)
{}
};//GeneratorSymmetricalComponentsAmplitude
struct GeneratorSymmetricalComponentsConfiguration
{
GeneratorSymmetricalComponentsAmplitude amplitude;
GeneratorSymmetricalComponentsPhase phase;
GeneratorSymmetricalComponentsConfiguration():
amplitude(),
phase()
{}
};//GeneratorSymmetricalComponentsConfiguration
class GeneratorSymmetricalComponents
{
private:
GeneratorSymmetricalComponentsAmplitude m_amplitude;
GeneratorSymmetricalComponentsPhase m_phase;
private:
float m_ort_direct_alpha;
float m_ort_direct_beta;
float m_ort_inverse_alpha;
float m_ort_inverse_beta;
private:
float m_direct_alpha;
float m_direct_beta;
float m_inverse_alpha;
float m_inverse_beta;
private:
float m_direct_a;
float m_direct_b;
float m_direct_c;
float m_inverse_a;
float m_inverse_b;
float m_inverse_c;
private:
float m_out_a;
float m_out_b;
float m_out_c;
public:
GeneratorSymmetricalComponents();
public:
void configure(GeneratorSymmetricalComponentsConfiguration& config);
public:
void execute(float ort_alpha, float ort_beta);
void get_output(float& out_a, float& out_b, float& out_c);
};//GeneratorSymmetricalComponents
} /* namespace SYSCTRL */
#endif /* SYSCTRL_GENERATORSYMMETRICALCOMPONENTS_H_ */

@ -0,0 +1,243 @@
/*
* CELL.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/HVCELL.h"
namespace SYSCTRL
{
HVCELL::HVCELL():
m_mode(SYSCTRL::HVCELL::UNDEFINED),
m_control_order(ORDER_STOP),
//m_switching_freq(SWITCHING_FREQ_2500),
m_cell_level(0),
m_cell_error(0),
m_pwm_version(),
m_cell_state(),
m_cell_dc_voltage(),
m_cell_version(),
m_cpu_cpld_version(0),
m_data_u(FP_ZERO),
m_data_v(FP_ZERO),
m_data_w(FP_ZERO),
//
m_dc_voltage_a(FP_ZERO),
m_dc_voltage_b(FP_ZERO),
m_dc_voltage_c(FP_ZERO),
//
m_fault_cell(false),
m_cell_error_fault(0),
m_cell_state_fault(),
//
p_send_syn_signal(&SYSCTRL::HVCELL::_empty),
p_send_control_order(&SYSCTRL::HVCELL::_empty),
p_set_cell_level(&SYSCTRL::HVCELL::_empty),
p_get_pwm_version(&SYSCTRL::HVCELL::_empty),
p_get_cell_state(&SYSCTRL::HVCELL::_empty),
p_get_cell_dc_voltage(&SYSCTRL::HVCELL::_empty),
p_get_cell_version(&SYSCTRL::HVCELL::_empty),
p_send_modulate_data(&SYSCTRL::HVCELL::_empty),
p_get_cpu_cpld_version(&SYSCTRL::HVCELL::_empty)
{}
#pragma CODE_SECTION("ramfuncs");
void HVCELL::configure(HVCELLConfiguration& config)
{
static bool status = true;
if(m_mode == SYSCTRL::HVCELL::UNDEFINED)
{
m_cell_level = config.cell_level;
//m_switching_freq = config.switching_freq;
status &= (m_cell_level >= 1)&&(m_cell_level <= 8) ? true : false;
if(status)
{
m_mode = SYSCTRL::HVCELL::OPERATIONAL;
//
p_send_syn_signal = &SYSCTRL::HVCELL::_send_syn_signal;
p_send_control_order = &SYSCTRL::HVCELL::_send_control_order;
p_set_cell_level = &SYSCTRL::HVCELL::_set_cell_level;
p_get_pwm_version = &SYSCTRL::HVCELL::_get_pwm_version;
p_get_cell_state = &SYSCTRL::HVCELL::_get_cell_state;
p_get_cell_dc_voltage = &SYSCTRL::HVCELL::_get_cell_dc_voltage;
p_get_cell_version = &SYSCTRL::HVCELL::_get_cell_version;
p_send_modulate_data = &SYSCTRL::HVCELL::_send_modulate_data;
p_get_cpu_cpld_version = &SYSCTRL::HVCELL::_get_cpu_cpld_version;
//
}//if
//
}//if
//
}//configure()
//
#pragma CODE_SECTION("ramfuncs");
SYSCTRL::HVCELL::mode_t HVCELL::get_mode()
{
return m_mode;
//
}//get_mode()
//
#pragma CODE_SECTION("ramfuncs");
bool HVCELL::compare(SYSCTRL::HVCELL::mode_t mode)
{
return m_mode == mode;
//
}//compare()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::send_syn_signal()
{
(this->*p_send_syn_signal)();
//
}//send_syn_signal()
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_send_syn_signal()
{
sendSynSignal();
//
}//_send_syn_signal()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::send_control_order()
{
(this->*p_send_control_order)();
//
}//send_control_order_start()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_send_control_order()
{
sendControlOrder(m_control_order);
//
}//_send_control_order()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::set_cell_level()
{
(this->*p_set_cell_level)();
//
}//set_cell_level()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_set_cell_level()
{
//m_cell_error = setCellLevel(m_cell_level, m_switching_freq);
m_cell_error = setCellLevel(m_cell_level);
//
}//_set_cell_level()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::get_pwm_version()
{
(this->*p_get_pwm_version)();
//
}//get_pwm_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_get_pwm_version()
{
getPwmVersion(m_pwm_version);
//
}//_get_pwm_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::get_cell_state()
{
(this->*p_get_cell_state)();
//
}//get_cell_state()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_get_cell_state()
{
getCellState(m_cell_level, m_cell_state);
//
}//_get_cell_state()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::get_cell_dc_voltage()
{
(this->*p_get_cell_dc_voltage)();
//
}//get_cell_dc_voltage()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_get_cell_dc_voltage()
{
static float aux_a, aux_b, aux_c;
getCellDCVoltage(m_cell_level, m_cell_dc_voltage);
aux_a = FP_ZERO;
aux_b = FP_ZERO;
aux_c = FP_ZERO;
//
for(Uint16 cellnum = 0; cellnum < m_cell_level; cellnum++)
{
aux_a += m_cell_dc_voltage[0][cellnum];
aux_b += m_cell_dc_voltage[1][cellnum];
aux_c += m_cell_dc_voltage[2][cellnum];
//
}//for
//
m_dc_voltage_a = aux_a;
m_dc_voltage_b = aux_b;
m_dc_voltage_c = aux_c;
//
}//_get_cell_dc_voltage()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::get_cell_version()
{
(this->*p_get_cell_version)();
//
}//get_cell_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_get_cell_version()
{
getCellVersion(m_cell_level, m_cell_version);
//
}//get_cell_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::send_modulate_data()
{
(this->*p_send_modulate_data)();
//
}//send_modulate_data()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_send_modulate_data()
{
//sendModulateData(m_data_u, m_data_v, m_data_w, m_switching_freq);
sendModulateData(m_data_u, m_data_v, m_data_w);
//
}//_send_modulate_data()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::get_cpu_cpld_version()
{
(this->*p_get_cpu_cpld_version)();
//
}//get_cpu_cpld_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_get_cpu_cpld_version()
{
m_cpu_cpld_version = getCpuCpldVersion();
//
}//_get_cpu_cpld_version()
//
#pragma CODE_SECTION("ramfuncs");
void HVCELL::_empty()
{}//_empty()
//
} /* namespace SYSCTRL */

@ -0,0 +1,100 @@
/*
* HVCELL.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
#ifndef SYSCTRL_HVCELL_H_
#define SYSCTRL_HVCELL_H_
namespace SYSCTRL
{
struct HVCELLConfiguration
{
Uint16 cell_level;
//UnitSwitchingFreq switching_freq;
HVCELLConfiguration():
cell_level(0)
//switching_freq(SWITCHING_FREQ_2500)
{}
};//HVCELLConfiguration
class HVCELL
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
private:
mode_t m_mode;
private:
ControlOrder m_control_order;
//UnitSwitchingFreq m_switching_freq;
Uint16 m_cell_level;
Uint16 m_cell_error;
Uint16 m_pwm_version[3];
CellState m_cell_state[3][13];
float m_cell_dc_voltage[3][13];
Uint16 m_cell_version[3][13];
Uint32 m_cpu_cpld_version;
float m_data_u;
float m_data_v;
float m_data_w;
private:
float m_dc_voltage_a;
float m_dc_voltage_b;
float m_dc_voltage_c;
bool m_fault_cell;
Uint16 m_cell_error_fault;
CellState m_cell_state_fault[3][13];
public:
HVCELL();
void configure(HVCELLConfiguration& config);
mode_t get_mode();
bool compare(mode_t mode);
public:
void send_syn_signal();
void send_control_order();
void set_cell_level();
void get_pwm_version();
void get_cell_state();
void get_cell_dc_voltage();
void get_cell_version();
void send_modulate_data();
void get_cpu_cpld_version();
private:
void (HVCELL::*p_send_syn_signal)();
void _send_syn_signal();
void (HVCELL::*p_send_control_order)();
void _send_control_order();
void (HVCELL::*p_set_cell_level)();
void _set_cell_level();
void (HVCELL::*p_get_pwm_version)();
void _get_pwm_version();
void (HVCELL::*p_get_cell_state)();
void _get_cell_state();
void (HVCELL::*p_get_cell_dc_voltage)();
void _get_cell_dc_voltage();
void (HVCELL::*p_get_cell_version)();
void _get_cell_version();
void (HVCELL::*p_send_modulate_data)();
void _send_modulate_data();
void (HVCELL::*p_get_cpu_cpld_version)();
void _get_cpu_cpld_version();
void _empty();
//
};//class HVCELL
} /* namespace SYSCTRL */
#endif /* SYSCTRL_HVCELL_H_ */

@ -0,0 +1,238 @@
/*
* HardWare.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/HardWare.h"
namespace SYSCTRL
{
//CONSTRUCTOR
HardWare::HardWare():
enable(true),
fault(false),
fault_low_level(false),
level((Uint16)0),
error((Uint16)0),
//switching_freq(SWITCHING_FREQ_2500),
dc_voltage_low_level(500.0),
control_order_cell(ORDER_STOP),
ref_control_order(ORDER_STOP),
pwm_version(),
cpu_cpld_version((Uint32)0),
hvcell(),
disable_hw(),
disable_a_cells(),
disable_b_cells(),
disable_c_cells(),
version_default()
{
for(Uint16 phase = 0; phase < 3; phase++)
{
for(Uint16 cellnum = 0; cellnum < 13; cellnum++)
{
hvcell.dc_voltage[phase][cellnum] = FP_ZERO;
hvcell.state[phase][cellnum].all = 0;
hvcell.version[phase][cellnum] = 0;
//
}//for
//
}//for
//
}//CONSTRUCTOR
void HardWare::configure(const HardWareConfiguration config)
{
//switching_freq = config.switching_freq;
level = config.cell_level;
version_default = config.version;
disable_hw.all = (uint16_t)0;
disable_a_cells.all = (uint32_t)0;
disable_b_cells.all = (uint32_t)0;
disable_c_cells.all = (uint32_t)0;
//
}//
#pragma CODE_SECTION("ramfuncs");
void HardWare::check_status()
{
if(cpu_cpld_version != version_default.cpu_cpld)
{
disable_hw.bits.cpu_cpld = 1;
}
else
{
disable_hw.bits.cpu_cpld = 0;
//
}//if else
//
if(pwm_version[0] != version_default.pwm)
{
disable_hw.bits.pwm_a = 1;
}
else
{
disable_hw.bits.pwm_a = 0;
//
}//if else
//
if(pwm_version[1] != version_default.pwm)
{
disable_hw.bits.pwm_b = 1;
}
else
{
disable_hw.bits.pwm_b = 0;
//
}//if else
//
if(pwm_version[2] != version_default.pwm)
{
disable_hw.bits.pwm_c = 1;
}
else
{
disable_hw.bits.pwm_c = 0;
//
}//if else
static uint32_t mask = (uint32_t)0;
static uint32_t auxreg_0 = (uint32_t)0;
static uint32_t auxreg_1 = (uint32_t)0;
static uint32_t auxreg_2 = (uint32_t)0;
auxreg_0 = (uint32_t)0;
auxreg_1 = (uint32_t)0;
auxreg_2 = (uint32_t)0;
for(Uint16 cellnum = 0; cellnum < level; cellnum++)
{
mask = (uint32_t)0;
if(hvcell.version[0][cellnum] != version_default.cell)
{
mask = (uint32_t)0;
mask = 1 << (cellnum);
auxreg_0 |= mask;
}
else
{
mask = (uint32_t)0;
mask = 1 << (cellnum);
mask = (uint32_t)((uint32_t)0xFFFFFFFF ^ (uint32_t)mask);
auxreg_0 &= mask;
//
}//if
//
mask = (uint32_t)0;
if(hvcell.version[1][cellnum] != version_default.cell)
{
mask = 1 << (cellnum);
auxreg_1 |= mask;
}
else
{
mask = 1 << (cellnum);
mask = (uint32_t)((uint32_t)0xFFFFFFFF ^ (uint32_t)mask);
auxreg_1 &= mask;
//
}//if
//
mask = (uint32_t)0;
if(hvcell.version[2][cellnum] != version_default.cell)
{
mask = 1 << (cellnum);
auxreg_2 |= mask;
}
else
{
mask = 1 << (cellnum);
mask = (uint32_t)((uint32_t)0xFFFFFFFF ^ (uint32_t)mask);
auxreg_2 &= mask;
//
}//if
//
}//for
//
disable_a_cells.all = (uint32_t)auxreg_0;
disable_c_cells.all = (uint32_t)auxreg_1;
disable_b_cells.all = (uint32_t)auxreg_2;
//
static bool tmp_enable = true;
tmp_enable = true;
// tmp_enable &= disable_hw.all == 0 ? true : false;
// tmp_enable &= disable_a_cells.all == 0 ? true : false;
// tmp_enable &= disable_b_cells.all == 0 ? true : false;
// tmp_enable &= disable_c_cells.all == 0 ? true : false;
enable = tmp_enable;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool HardWare::is_enable()
{
//
return enable;
//
}//
#pragma CODE_SECTION("ramfuncs");
void HardWare::check_faults(mode_fault_t fmode)
{
for(Uint16 cellnum = 0; cellnum < level; cellnum++)
{
for(Uint16 phasenum = 0; phasenum < 3; phasenum++)
{
if(SYSCTRL::HardWare::COMPLETE == fmode)
{
if(((Uint16)(MASK_CELL_STATE_FAULTS & hvcell.state[phasenum][cellnum].all)) != (Uint16)0)
{
fault = true;
//
}//
}
else
{
if(((Uint16)(MASK_CELL_STATE_FAULTS_SHORT & hvcell.state[phasenum][cellnum].all)) != (Uint16)0)
{
fault = true;
//
}//
}
if(((Uint16)(MASK_CELL_LOW_LEVEL & hvcell.state[phasenum][cellnum].all)) != (Uint16)0)
{
fault_low_level = true;
}
//
};//for
//
}//for
//
}//
#pragma CODE_SECTION("ramfuncs");
bool HardWare::is_fault()
{
return fault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
bool HardWare::low_level()
{
return fault_low_level;
//
}//
#pragma CODE_SECTION("ramfuncs");
void HardWare::reset()
{
fault = false;
fault_low_level = false;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,194 @@
/*
* HardWare.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "framework.h"
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
#ifndef SYSCTRL_HARDWARE_H_
#define SYSCTRL_HARDWARE_H_
namespace SYSCTRL
{
#define MASK_CELL_STATE_DOWN_COMM (Uint16)0x0001
#define MASK_CELL_STATE_UP_COMM (Uint16)0x0002
#define MASK_CELL_STATE_RESERVED_1 (Uint16)0x0004
#define MASK_CELL_STATE_RUNNING (Uint16)0x0008
//
#define MASK_CELL_STATE_IGBT4_FAULT (Uint16)0x0010
#define MASK_CELL_STATE_IGBT3_FAULT (Uint16)0x0020
#define MASK_CELL_STATE_IGBT2_FAULT (Uint16)0x0040
#define MASK_CELL_STATE_IGBT1_FAULT (Uint16)0x0080
//
#define MASK_CELL_STATE_RESERVED_2 (Uint16)0x0100
#define MASK_CELL_STATE_TEMP_OVER (Uint16)0x0200
#define MASK_CELL_STATE_UNDER_VOLTAGE (Uint16)0x0400
#define MASK_CELL_STATE_OVER_VOLTAGE (Uint16)0x0800
//
#define MASK_CELL_STATE_RESERVED_3 (Uint16)0x0F800
#define MASK_CELL_STATE_FAULTS (Uint16)(MASK_CELL_STATE_DOWN_COMM |\
MASK_CELL_STATE_UP_COMM |\
MASK_CELL_STATE_IGBT4_FAULT |\
MASK_CELL_STATE_IGBT3_FAULT |\
MASK_CELL_STATE_IGBT2_FAULT |\
MASK_CELL_STATE_IGBT1_FAULT |\
MASK_CELL_STATE_TEMP_OVER |\
MASK_CELL_STATE_UNDER_VOLTAGE |\
MASK_CELL_STATE_OVER_VOLTAGE)
#define MASK_CELL_STATE_FAULTS_SHORT (Uint16)(MASK_CELL_STATE_IGBT4_FAULT |\
MASK_CELL_STATE_IGBT3_FAULT |\
MASK_CELL_STATE_IGBT2_FAULT |\
MASK_CELL_STATE_IGBT1_FAULT |\
MASK_CELL_STATE_TEMP_OVER |\
MASK_CELL_STATE_OVER_VOLTAGE)
#define MASK_CELL_LOW_LEVEL (Uint16)(MASK_CELL_STATE_DOWN_COMM |\
MASK_CELL_STATE_UP_COMM |\
MASK_CELL_STATE_UNDER_VOLTAGE)
struct HardWareVersion
{
uint16_t pwm;
uint16_t cell;
uint32_t cpu_cpld;
HardWareVersion():
pwm(uint16_t(0)),
cell(uint16_t(0)),
cpu_cpld(uint32_t(0))
{}
};//HardWareVersion
struct HardWareConfiguration
{
uint16_t cell_level;
//UnitSwitchingFreq switching_freq;
SYSCTRL::HardWareVersion version;
HardWareConfiguration():
cell_level(0),
//switching_freq(SWITCHING_FREQ_2500),
version()
{}
};//HardWareConfiguration
struct Cell
{
CellState state[3][13];
float dc_voltage[3][13];
uint16_t version[3][13];
float data_u;
float data_v;
float data_w;
Cell():
state(),
dc_voltage(),
version(),
data_u(FP_ZERO),
data_v(FP_ZERO),
data_w(FP_ZERO)
{}
};//Cell
struct HVCellDisableBit
{
uint32_t cell_1: 1;
uint32_t cell_2: 1;
uint32_t cell_3: 1;
uint32_t cell_4: 1;
uint32_t cell_5: 1;
uint32_t cell_6: 1;
uint32_t cell_7: 1;
uint32_t cell_8: 1;
uint32_t cell_9: 1;
uint32_t cell_10: 1;
uint32_t cell_11: 1;
uint32_t cell_12: 1;
uint32_t cell_13: 1;
uint32_t cell_14: 1;
uint32_t cell_15: 1;
uint32_t cell_16: 1;
uint32_t cell_17: 1;
uint32_t cell_18: 1;
};//HVCellDisableBit
union HVCellDisableRegister
{
uint32_t all;
HVCellDisableBit bits;
HVCellDisableRegister():
all((uint32_t)0)
{}
};//HVCellDisableRegister
struct HardWareDisableBit
{
uint16_t cpu_cpld: 1;
uint16_t pwm_a: 1;
uint16_t pwm_b: 1;
uint16_t pwm_c: 1;
};//HardWareDisableBit
union HardWareDisableRegister
{
uint16_t all;
HardWareDisableBit bits;
HardWareDisableRegister():
all((uint16_t)0)
{}
};//HardWareDisable
class HardWare
{
public:
enum mode_fault_t {SHORT, COMPLETE};
public:
bool enable;
bool fault;
bool fault_low_level;
//UnitSwitchingFreq switching_freq;
float dc_voltage_low_level;
uint16_t level;
uint16_t error;
ControlOrder control_order_cell;
ControlOrder ref_control_order;
uint16_t pwm_version[3];
uint32_t cpu_cpld_version;
Cell hvcell;
HardWareDisableRegister disable_hw;
HVCellDisableRegister disable_a_cells;
HVCellDisableRegister disable_b_cells;
HVCellDisableRegister disable_c_cells;
HardWareVersion version_default;
public:
HardWare();
void configure(const HardWareConfiguration config);
void check_status();
void check_faults(mode_fault_t fmode);
bool is_enable();
bool is_fault();
bool low_level();
void reset();
//
};//class HardWare
} /* namespace SYSCTRL */
#endif /* SYSCTRL_HARDWARE_H_ */

@ -0,0 +1,358 @@
/*
* Hardcode.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/SystemControl.h"
namespace SYSCTRL
{
void SystemControl::get_hard_code_setup()
{
m_system_setup.time_sample_control = 400.0e-6;
m_system_setup.time_prescale_slow = 5;
m_system_setup.time_prescale_additional = 1;
//
// Relative
//
m_system_setup.relative_voltage_input.time_sample = m_system_setup.time_sample_control;
//
}//hard_code_setup()
//
void SystemControl::upload_configuration()
{
m_fram_db.upload_configuration(&m_system_configuration);
//m_system_configuration.selfupdata();
//
}//
//
void SystemControl::get_hard_code_configuration()
{
//
// References
//
m_system_configuration.reference_current_limit_rms = 100.0;
m_system_configuration.reference_current_pfc_rms = 0.0;
m_system_configuration.reference_voltage_rms = 240.0;
m_system_configuration.reference_voltage_dc = 900.0;
m_system_configuration.algorithm_control.signal.enable_current_limit = true;
m_system_configuration.algorithm_control.signal.enable_pfc = false;
m_system_configuration.algorithm_control.signal.enable_harmonica = false;
m_system_configuration.algorithm_control.signal.enable_auto_offset = true;
//
// High Voltage Cell
//
//m_system_configuration.hardware.switching_freq = SWITCHING_FREQ_2500;
m_system_configuration.hardware.cell_level = 1;
m_system_configuration.hardware.version.pwm = 210;
m_system_configuration.hardware.version.cell = 211;
m_system_configuration.hardware.version.cpu_cpld = 202;
//
m_system_configuration.minimal_input_voltage_level = 10.0;
//
// Scale Analog Signals
//
m_system_configuration.scale_voltage_input_a = 0.0227386411;//0.0233486816;
m_system_configuration.scale_voltage_input_b = 0.0227597337;//0.0234651081;
m_system_configuration.scale_voltage_input_c = 0.02278281;//0.0236082859;
//
m_system_configuration.scale_current_input_a = 0.00666328007;
m_system_configuration.scale_current_input_b = 0.00667025521;
m_system_configuration.scale_current_input_c = 0.00665952405;
//
m_system_configuration.scale_current_cell_a = 0.0123311505;//0.00665648002;
m_system_configuration.scale_current_cell_b = 0.0123670474;//0.00667640707;
m_system_configuration.scale_current_cell_c = 0.0124070868;//0.00666095456;
//
m_system_configuration.scale_voltage_load_a = 0.0227408651;//0.0232194811;
m_system_configuration.scale_voltage_load_b = 0.0227707103;//0.0233941432;
m_system_configuration.scale_voltage_load_c = 0.0229060184;//0.0234934501;
//
m_system_configuration.scale_current_load_a = 0.00622544903;//0.00668919506;
m_system_configuration.scale_current_load_b = 0.00623486936;//0.00669770781;
m_system_configuration.scale_current_load_c = 0.00624710508;//0.00670575583;
//
m_system_configuration.scale_current_bypass_a = 0.0063;
m_system_configuration.scale_current_bypass_b = 0.0063;
m_system_configuration.scale_current_bypass_c = 0.0063;
//
// Amplitude Filter Parameters
//
m_system_configuration.ampl_filter_current.time = 20.0e-3;
m_system_configuration.ampl_filter_current.a3 = 3.0;
m_system_configuration.ampl_filter_current.a2 = 4.25;
m_system_configuration.ampl_filter_current.a1 = 3.0;
//
// RMS Filter Parameters
//
m_system_configuration.rms_filter_analog_signal.time = 10.0e-3;
m_system_configuration.rms_filter_analog_signal.a3 = 3.0;
m_system_configuration.rms_filter_analog_signal.a2 = 4.25;
m_system_configuration.rms_filter_analog_signal.a1 = 3.0;
//
// Zero Drift Current Input
//
m_system_configuration.zero_filter.time = 1333.0e-3;
//
// Cell DC Voltage Filter
//
m_system_configuration.cell_dc_voltage_filter.time = 3.0e-3;
m_system_configuration.cell_dc_voltage_filter.a3 = 3.0;
m_system_configuration.cell_dc_voltage_filter.a2 = 4.25;
m_system_configuration.cell_dc_voltage_filter.a1 = 3.0;
//
// Signal Decompose
//
m_system_configuration.signal_decompose.projection_filter.time = 10.0e-3;
m_system_configuration.signal_decompose.projection_filter.a3 = 2.61313;//3.0;
m_system_configuration.signal_decompose.projection_filter.a2 = 3.41422;//4.25;
m_system_configuration.signal_decompose.projection_filter.a1 = 2.61313;//3.0;
//
// Relative
//
m_system_configuration.relative_voltage_input.minimal_amplitude_level = 0.1;
m_system_configuration.relative_voltage_input.limit_relative_high = 1.1;
m_system_configuration.relative_voltage_input.limit_relative_low = -1.1;
m_system_configuration.relative_voltage_input.amplitude_filter.time = (float)(1.0/2.0/FP_PI/10.0);
m_system_configuration.relative_voltage_input.amplitude_filter.a3 = 3.0;
m_system_configuration.relative_voltage_input.amplitude_filter.a2 = 4.25;
m_system_configuration.relative_voltage_input.amplitude_filter.a1 = 3.0;
//
// Voltage PLL-ABC Parameters
//
#define PLLABC_FREQUENCY_NOMINAL (float)(2.0*FP_PI*50.0)
#define PLLABC_FREQUENCY_CUT (float)(2.0*FP_PI*10.0)
#define PLLABC_FREQUENCY_LIMIT_HI PLLABC_FREQUENCY_CUT
#define PLLABC_FREQUENCY_LIMIT_LOW -PLLABC_FREQUENCY_CUT
m_system_configuration.pll_abc_input_voltage.frequency_nominal = PLLABC_FREQUENCY_NOMINAL;
m_system_configuration.pll_abc_input_voltage.filter.time = 1.0/PLLABC_FREQUENCY_CUT;
m_system_configuration.pll_abc_input_voltage.controller.gain = PLLABC_FREQUENCY_CUT/2.0;
m_system_configuration.pll_abc_input_voltage.controller.time = 4.0/PLLABC_FREQUENCY_CUT;
m_system_configuration.pll_abc_input_voltage.controller.low_saturation = PLLABC_FREQUENCY_LIMIT_LOW;
m_system_configuration.pll_abc_input_voltage.controller.high_saturation = PLLABC_FREQUENCY_LIMIT_HI;
m_system_configuration.pll_abc_input_voltage.position.time = 1.0;
m_system_configuration.pll_abc_input_voltage.position.low_saturation = FP_ZERO;
m_system_configuration.pll_abc_input_voltage.position.high_saturation = 2.0 * FP_PI;
//
// System Alarm
//
// exceed voltage level 1
m_system_configuration.phase_alert_monitor.voltage_exceed_level_1.level = 264.5;//253.0;
m_system_configuration.phase_alert_monitor.voltage_exceed_level_1.period = 10.0;
//
// exceed voltage level 2
m_system_configuration.phase_alert_monitor.voltage_exceed_level_2.level = 276.0;//264.5;
m_system_configuration.phase_alert_monitor.voltage_exceed_level_2.period = 5.0;
//
// exceed voltage level 3
m_system_configuration.phase_alert_monitor.voltage_exceed_level_3.level = 290.0;//276.0;
m_system_configuration.phase_alert_monitor.voltage_exceed_level_3.period = 2.0;
//
// exceed voltage level 4
m_system_configuration.phase_alert_monitor.voltage_exceed_level_4.level = 345.0;
m_system_configuration.phase_alert_monitor.voltage_exceed_level_4.period = 0.001;//1.0;
//
// decrease voltage level 1
m_system_configuration.phase_alert_monitor.voltage_decrease_level_1.level = 200.0;//218.5;//195.5;
m_system_configuration.phase_alert_monitor.voltage_decrease_level_1.period = 10.0;
//
// decrease voltage level 2
m_system_configuration.phase_alert_monitor.voltage_decrease_level_2.level = 170.0;//207.0;//172.5;
m_system_configuration.phase_alert_monitor.voltage_decrease_level_2.period = 5.0;
//
// decrease voltage level 3
m_system_configuration.phase_alert_monitor.voltage_decrease_level_3.level = 149.5;
m_system_configuration.phase_alert_monitor.voltage_decrease_level_3.period = 2.0;
//
// current overload level 1 120% 60s
m_system_configuration.phase_alert_monitor.current_overload_level_1.level = 3.0 * 14.4;
m_system_configuration.phase_alert_monitor.current_overload_level_1.period = 60.0;
//
// current overload level 2 130% 10s
m_system_configuration.phase_alert_monitor.current_overload_level_2.level = 3.0 * 15.6;
m_system_configuration.phase_alert_monitor.current_overload_level_2.period = 10.0;
//
// current overload level 3 150% 1ms
m_system_configuration.phase_alert_monitor.current_overload_level_3.level = 3.0 * 18.0;
m_system_configuration.phase_alert_monitor.current_overload_level_3.period = 0.001;
//
// current invertor overload level 1 110% 60s
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_1.level = 13.2;
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_1.period = 60.0;
//
// current invertor overload level 2 130% 10s
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_2.level = 15.6;
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_2.period = 10.0;
//
// current invertor overload level 3 150% 1ms
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_3.level = 18.0;
m_system_configuration.phase_alert_monitor.current_invertor_overload_level_3.period = 0.001;
//
//DIGITAL INPUTS
//
m_system_configuration.digital_input_config.period = 200.0e-3; //3001 - 3020
//
// FAN CONTROL
//
m_system_configuration.fan_control.timer_period = 5.0*60.0;
//
// Generator ABC
//
m_system_configuration.generator_abc.amplitude = 1.0;
m_system_configuration.generator_abc.frequency = 2.0*FP_PI*50.0;
m_system_configuration.generator_abc.phase_shift = 0.0;
//
// Reference PWM-Generator
//
//m_system_configuration.generator_pwm.frequency = 2.0*FP_PI*1.0;
//m_system_configuration.generator_abc.phase_shift = 0.0;
//m_system_configuration.gen_inp_volt.amplitude.direct.d = 220.0;
//
//m_system_configuration.gen_out_volt.amplitude.direct.d = 220.0;
//m_system_configuration.gen_out_volt.phase.direct.phase = 0.122756;//FP_PI/4.0;
//
//m_system_configuration.gen_out_current.amplitude.direct.d = 50.0;
//m_system_configuration.gen_out_current.phase.direct.phase = 0.122756;//FP_PI/3.0;
//
// Harmonica Analyzer
//
m_system_configuration.ph_harmonica_5.time = 50.0e-3;
m_system_configuration.ph_harmonica_5.a3 = 3.0;
m_system_configuration.ph_harmonica_5.a2 = 4.25;
m_system_configuration.ph_harmonica_5.a1 = 3.0;
//
// Reference Intensity Idref Iqref in Start Mode
//
m_system_configuration.intensity_id_iq_references.damp_factor = 0.7071;
m_system_configuration.intensity_id_iq_references.time = 20.0e-3;
//
// Regulators
//
#if TYPECONTROL == VECTORCONTROL
//
m_system_configuration.regulator_voltage_load_dq.gain = 0.25;
m_system_configuration.regulator_voltage_load_dq.time = 40.0e-3;
m_system_configuration.regulator_voltage_load_dq.high_saturation = 950.0;
m_system_configuration.regulator_voltage_load_dq.low_saturation = -950.0;
//
//m_system_configuration. = 1.0;
m_system_configuration.integrator_voltage_dq.time = 1.0;
m_system_configuration.integrator_voltage_dq.high_saturation = 1.0;;
m_system_configuration.integrator_voltage_dq.low_saturation = -1.0;
//
//m_system_configuration. = 1.0;
//m_system_configuration. = 1.0;
//m_system_configuration. = 1.0;
//m_system_configuration. = -1.0;
//
m_system_configuration.regulator_current_load_dq.gain = 1.0;
// m_system_configuration.regulator_current_load_dq.time = 0.016;
m_system_configuration.regulator_current_load_dq.high_saturation = 200.0;
m_system_configuration.regulator_current_load_dq.low_saturation = -200.0;
//
//m_system_configuration. = 1.0;
//m_system_configuration. = 0.016;
//m_system_configuration. = 200.0;
//m_system_configuration. = -200.0;
//
//m_system_configuration. = 1.0;
m_system_configuration.referencer_current_bypass_dq.time = 0.016;
m_system_configuration.referencer_current_bypass_dq.high_saturation = 200.0;
m_system_configuration.referencer_current_bypass_dq.low_saturation = -200.0;
//
#endif
#if TYPECONTROL == SCALARCONTROL
//
m_system_configuration.regulator_voltage_load_active_reactive.gain = 0.25;
m_system_configuration.regulator_voltage_load_active_reactive.time = 40.0e-3;
m_system_configuration.regulator_voltage_load_active_reactive.high_saturation = 950.0;
m_system_configuration.regulator_voltage_load_active_reactive.low_saturation = -950.0;
//
m_system_configuration.regulator_current_limit.gain = 1.0;
m_system_configuration.regulator_current_limit.time = 1.0;
m_system_configuration.regulator_current_limit.high_saturation = 1.0;;
m_system_configuration.regulator_current_limit.low_saturation = -1.0;
//
m_system_configuration.regulator_current_pfc.gain = 1.0;
m_system_configuration.regulator_current_pfc.time = 1.0;
m_system_configuration.regulator_current_pfc.high_saturation = 1.0;
m_system_configuration.regulator_current_pfc.low_saturation = -1.0;
//
m_system_configuration.current_regulator_active.gain = 1.0;
m_system_configuration.current_regulator_active.time = 0.016;
m_system_configuration.current_regulator_active.high_saturation = 200.0;
m_system_configuration.current_regulator_active.low_saturation = -200.0;
//
m_system_configuration.current_regulator_reactive.gain = 1.0;
m_system_configuration.current_regulator_reactive.time = 0.016;
m_system_configuration.current_regulator_reactive.high_saturation = 200.0;
m_system_configuration.current_regulator_reactive.low_saturation = -200.0;
//
m_system_configuration.current_referencer.gain = 1.0;
m_system_configuration.current_referencer.time = 0.016;
m_system_configuration.current_referencer.high_saturation = 200.0;
m_system_configuration.current_referencer.low_saturation = -200.0;
//
#endif
//<>
//
// Timers
//
m_system_configuration.timer_start.period = 2.0;
m_system_configuration.timer_stop.period = 2.0;
//
}//hard_code_configuration()
//
} /* namespace SYSCTRL */

@ -0,0 +1,48 @@
/*
* FLTSYSLIBheaders.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef FLTSYSLIB_FLTSYSLIBHEADERS_H_
#define FLTSYSLIB_FLTSYSLIBHEADERS_H_
#include "FLTSYSLIB/AMPL.h"
#include "FLTSYSLIB/AMPLFSO.h"
#include "FLTSYSLIB/AMPLF4O.h"
#include "FLTSYSLIB/Contactor.h"
#include "FLTSYSLIB/DigitalInput.h"
#include "FLTSYSLIB/DigitalInputAntiNoise.h"
#include "FLTSYSLIB/DiscreteInput.h"
#include "FLTSYSLIB/DiscreteOutput.h"
#include "FLTSYSLIB/Filter.h"
#include "FLTSYSLIB/FilterSecond.h"
#include "FLTSYSLIB/FilterForth.h"
#include "FLTSYSLIB/FilterThird.h"
#include "FLTSYSLIB/FTimer.h"
#include "FLTSYSLIB/GeneratorABC.h"
#include "FLTSYSLIB/HarmonicaFilter4Order.h"
#include "FLTSYSLIB/HarmonicaFilterBase.h"
#include "FLTSYSLIB/Hysteresis.h"
#include "FLTSYSLIB/IController.h"
#include "FLTSYSLIB/Integrator.h"
#include "FLTSYSLIB/PController.h"
#include "FLTSYSLIB/PIController.h"
#include "FLTSYSLIB/PLLABC.h"
#include "FLTSYSLIB/PLLABCDVR.h"
#include "FLTSYSLIB/PLLABCreduced.h"
#include "FLTSYSLIB/PLLEQEP.h"
#include "FLTSYSLIB/Position.h"
#include "FLTSYSLIB/Relay.h"
#include "FLTSYSLIB/RMS.h"
#include "FLTSYSLIB/RMSF4O.h"
#include "FLTSYSLIB/RMSFFO.h"
#include "FLTSYSLIB/RMSFSO.h"
#include "FLTSYSLIB/Transformation.h"
#include "FLTSYSLIB/UNIPWM.h"
#include "FLTSYSLIB/ZeroDriftSecond.h"
#endif /* FLTSYSLIB_FLTSYSLIBHEADERS_H_ */

@ -0,0 +1,18 @@
/*
* HeadersMODBUSRTU.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#ifndef SYSCTRL_HEADERSMODBUSRTU_H_
#define SYSCTRL_HEADERSMODBUSRTU_H_
#include "MODBUSRTU/RUBUS.h"
#include "MODBUSRTU/RUBUSCOPE.h"
#include "MODBUSRTU/RUBUSDataBase.h"
#include "MODBUSRTU/RUBUSRegister.h"
#include "MODBUSRTU/RUBUSTypes.h"
#endif /* SYSCTRL_HEADERSMODBUSRTU_H_ */

@ -0,0 +1,59 @@
/*
* TimeStartStop.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/MeasureTimeInterval.h"
namespace SYSCTRL
{
//Constructor
MeasureTimeInterval::MeasureTimeInterval(CPUTIMER_VARS& CPUTimer, Uint32 magic):
m_CPUTimer(CPUTimer),
m_timer_result((Uint32)0),
m_timer_result_previous((Uint32)0),
m_magic_number((Uint32)magic),
m_period((Uint32)0),
m_tim((Uint32)0),
m_counter((Uint32)0)
{}//end Constructor
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimeInterval::start(void)
{
m_CPUTimer.RegsAddr->TCR.bit.TSS = 1; // Stop CPU Timer
m_CPUTimer.RegsAddr->TCR.bit.TRB = 1; // Reload CPU Timer
m_CPUTimer.RegsAddr->TCR.bit.TSS = 0; // Start CPU Timer
//
}//end
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimeInterval::stop(void)
{
m_CPUTimer.RegsAddr->TCR.bit.TSS = 1; // Stop CPU Timer
//
m_timer_result_previous = m_timer_result;
m_period = (Uint32)m_CPUTimer.RegsAddr->PRD.all;
m_tim = (Uint32)m_CPUTimer.RegsAddr->TIM.all;
//m_timer_result = m_CPUTimer.RegsAddr->PRD.all - m_CPUTimer.RegsAddr->TIM.all - m_magic_number;
m_timer_result = (Uint32)((Uint32)m_period - (Uint32)m_tim - (Uint32)m_magic_number);
m_counter++;
//
}//end
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimeInterval::reset(void)
{
m_CPUTimer.RegsAddr->TCR.bit.TSS = 1; // Stop CPU Timer
m_CPUTimer.RegsAddr->PRD.all = 0xFFFFFFFF;
m_CPUTimer.RegsAddr->TCR.bit.TRB = 1; // Reload CPU Timer
//
}//end
} /* namespace SYSCTRL */

@ -0,0 +1,38 @@
/*
* TimeStartStop.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
#ifndef SYSCTRL_TIMEINTERVAL_H_
#define SYSCTRL_TIMEINTERVAL_H_
namespace SYSCTRL
{
class MeasureTimeInterval
{
private:
CPUTIMER_VARS& m_CPUTimer;
Uint32 m_timer_result;
Uint32 m_timer_result_previous;
Uint32 m_magic_number;
Uint32 m_period;
Uint32 m_tim;
Uint32 m_counter;
public:
MeasureTimeInterval(CPUTIMER_VARS& CPUTimer, Uint32 magic);
public:
void start(void);
void stop(void);
void reset(void);
//
};//end class MeasureTimeStartStop
} /* namespace SYSCTRL */
#endif /* SYSCTRL_TIMEINTERVAL_H_ */

@ -0,0 +1,79 @@
/*
* MeasureTimePeriod.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/MeasureTimePeriod.h"
namespace SYSCTRL
{
//Constructor
MeasureTimePeriod::MeasureTimePeriod(CPUTIMER_REGS& CPUTimer, Uint32 magic):
m_CPUTimer(CPUTimer),
m_timer_result((Uint32)0),
m_timer_result_previous((Uint32)0),
m_magic_number((Uint32)magic),
m_period((Uint32)0),
m_tim((Uint32)0),
m_counter((Uint32)0),
_execute(&SYSCTRL::MeasureTimePeriod::_execute_start)
//
{}//end Constructor
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimePeriod::execute(void)
{
(this->*_execute)();
//
}//end
//
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimePeriod::reset(void)
{
m_CPUTimer.TCR.bit.TSS = 1; // Stop CPU Timer
m_CPUTimer.PRD.all = (Uint32)0xFFFFFFFF;
m_CPUTimer.TCR.bit.TRB = 1; // Reload CPU Timer
//
_execute = &SYSCTRL::MeasureTimePeriod::_execute_start;
//
}//end
//
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimePeriod::_execute_start(void)
{
_execute = &SYSCTRL::MeasureTimePeriod::_execute_scan;
//
m_CPUTimer.TCR.bit.TSS = 1; // Stop CPU Timer
m_CPUTimer.TCR.bit.TRB = 1; // Reload CPU Timer
m_CPUTimer.TCR.bit.TSS = 0; // Start CPU Timer
//
//
}//end
//
//#pragma CODE_SECTION(".TI.ramfunc");
#pragma CODE_SECTION("ramfuncs");
void MeasureTimePeriod::_execute_scan(void)
{
m_CPUTimer.TCR.bit.TSS = 1; // Stop CPU Timer
//
m_timer_result_previous = (Uint32)m_timer_result;
m_period = (Uint32)m_CPUTimer.PRD.all;
m_tim = (Uint32)m_CPUTimer.TIM.all;
m_timer_result = (Uint32)((Uint32)m_CPUTimer.PRD.all - (Uint32)m_CPUTimer.TIM.all - (Uint32)m_magic_number);
//
m_CPUTimer.TCR.bit.TRB = 1; // Reload CPU Timer
m_CPUTimer.TCR.bit.TSS = 0; // Start CPU Timer
//
m_counter++;
//
}//end
//
} /* namespace SYSCTRL */

@ -0,0 +1,41 @@
/*
* MeasureTimePeriod.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"
#ifndef SYSCTRL_MEASURETIMEPERIOD_H_
#define SYSCTRL_MEASURETIMEPERIOD_H_
namespace SYSCTRL
{
class MeasureTimePeriod
{
private:
CPUTIMER_REGS& m_CPUTimer;
//CPUTIMER_VARS& m_CPUTimer;
Uint32 m_timer_result;
Uint32 m_timer_result_previous;
Uint32 m_magic_number;
Uint32 m_period;
Uint32 m_tim;
Uint32 m_counter;
public:
MeasureTimePeriod(CPUTIMER_REGS& pCPUTimer, Uint32 magic);
void execute(void);
void reset(void);
private:
void (MeasureTimePeriod::*_execute)(void);
void _execute_start(void);
void _execute_scan(void);
//
};//end class MeasureTimePeriod
} /* namespace SYSCTRL */
#endif /* SYSCTRL_MEASURETIMEPERIOD_H_ */

@ -0,0 +1,49 @@
/*
* MonitorDigitalInputSignal.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/MonitorDigitalInputSignal.h"
namespace SYSCTRL
{
//CONSTRUCTOR
MonitorDigitalInputSignal::MonitorDigitalInputSignal()
{}//CONSTRUCTOR
//
#pragma CODE_SECTION("ramfuncs");
void MonitorDigitalInputSignal::implement(bool input, MonitorDigitalInputSignalRegister& state)
{
state.signal.privious = state.signal.state;
state.signal.state = input;
state.signal.is_on = state.signal.state;
state.signal.is_off = !state.signal.state;
state.signal.is_switched_on = state.signal.state & !state.signal.privious;
state.signal.is_switched_off = !state.signal.state & state.signal.privious;
//
}//
#pragma CODE_SECTION("ramfuncs");
void MonitorDigitalInputSignal::preset(bool input, MonitorDigitalInputSignalRegister& state)
{
state.signal.privious = input;
state.signal.state = input;
state.signal.is_on = input;
state.signal.is_off = !input;
state.signal.is_switched_on = !state.signal.state & state.signal.privious;
state.signal.is_switched_off = state.signal.state & !state.signal.privious;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void MonitorDigitalInputSignal::reset(MonitorDigitalInputSignalRegister& state)
{
state.all = 0x0008;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,57 @@
/*
* MonitorDigitalInputSignal.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/SystemDefinitions.h"
#ifndef SYSCTRL_MONITORDIGITALINPUTSIGNAL_H_
#define SYSCTRL_MONITORDIGITALINPUTSIGNAL_H_
namespace SYSCTRL
{
struct MonitorDigitalInputSignalBitFiled
{
uint16_t state:1;
uint16_t privious:1;
uint16_t is_on:1;
uint16_t is_off:1;
uint16_t is_switched_on:1;
uint16_t is_switched_off:1;
//
};//
union MonitorDigitalInputSignalRegister
{
uint16_t all;
Register16BitField bit;
MonitorDigitalInputSignalBitFiled signal;
MonitorDigitalInputSignalRegister():
all(uint16_t(0))
{}
MonitorDigitalInputSignalRegister(uint16_t val):
all(val)
{}
};//MonitorDigitalInputSignalRegister
class MonitorDigitalInputSignal
{
public:
MonitorDigitalInputSignal();
public:
static void implement(bool input, MonitorDigitalInputSignalRegister& state);
static void preset(bool input, MonitorDigitalInputSignalRegister& state);
static void reset(MonitorDigitalInputSignalRegister& state);
//
};//MonitorDigitalInputSignal
} /* namespace SYSCTRL */
#endif /* SYSCTRL_MONITORDIGITALINPUTSIGNAL_H_ */

@ -0,0 +1,430 @@
/*
* PhaseAlertMonitor.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/PhaseAlertMonitor.h"
namespace SYSCTRL
{
//CONSTRUCTOR
PhaseAlertMonitor::PhaseAlertMonitor():
m_time_sample(-1.0),
m_fault(false),
m_warning(false),
m_monitor(),
status(),
fault(false),
warning(false),
m_voltage_ab_exceed_level_1(),
m_voltage_bc_exceed_level_1(),
m_voltage_ca_exceed_level_1(),
m_voltage_ab_exceed_level_2(),
m_voltage_bc_exceed_level_2(),
m_voltage_ca_exceed_level_2(),
m_voltage_ab_exceed_level_3(),
m_voltage_bc_exceed_level_3(),
m_voltage_ca_exceed_level_3(),
m_voltage_ab_exceed_level_4(),
m_voltage_bc_exceed_level_4(),
m_voltage_ca_exceed_level_4(),
m_voltage_ab_decrease_level_1(),
m_voltage_bc_decrease_level_1(),
m_voltage_ca_decrease_level_1(),
m_voltage_ab_decrease_level_2(),
m_voltage_bc_decrease_level_2(),
m_voltage_ca_decrease_level_2(),
m_voltage_ab_decrease_level_3(),
m_voltage_bc_decrease_level_3(),
m_voltage_ca_decrease_level_3(),
m_current_a_overload_level_1(),
m_current_b_overload_level_1(),
m_current_c_overload_level_1(),
m_current_a_overload_level_2(),
m_current_b_overload_level_2(),
m_current_c_overload_level_2(),
m_current_a_overload_level_3(),
m_current_b_overload_level_3(),
m_current_c_overload_level_3(),
//
m_current_invertor_a_overload_level_1(),
m_current_invertor_b_overload_level_1(),
m_current_invertor_c_overload_level_1(),
m_current_invertor_a_overload_level_2(),
m_current_invertor_b_overload_level_2(),
m_current_invertor_c_overload_level_2(),
m_current_invertor_a_overload_level_3(),
m_current_invertor_b_overload_level_3(),
m_current_invertor_c_overload_level_3(),
//
m_current_input_a_overload_level_1(),
m_current_input_b_overload_level_1(),
m_current_input_c_overload_level_1(),
m_current_input_a_overload_level_2(),
m_current_input_b_overload_level_2(),
m_current_input_c_overload_level_2(),
m_current_input_a_overload_level_3(),
m_current_input_b_overload_level_3(),
m_current_input_c_overload_level_3(),
//
_execute(&SYSCTRL::PhaseAlertMonitor::_execute_undef)
//
{}//CONSTRUCTOR
void PhaseAlertMonitor::setup(float time_sample)
{
m_time_sample = time_sample;
m_voltage_ab_exceed_level_1.setup(m_time_sample);
m_voltage_bc_exceed_level_1.setup(m_time_sample);
m_voltage_ca_exceed_level_1.setup(m_time_sample);
m_voltage_ab_exceed_level_2.setup(m_time_sample);
m_voltage_bc_exceed_level_2.setup(m_time_sample);
m_voltage_ca_exceed_level_2.setup(m_time_sample);
m_voltage_ab_exceed_level_3.setup(m_time_sample);
m_voltage_bc_exceed_level_3.setup(m_time_sample);
m_voltage_ca_exceed_level_3.setup(m_time_sample);
m_voltage_ab_exceed_level_4.setup(m_time_sample);
m_voltage_bc_exceed_level_4.setup(m_time_sample);
m_voltage_ca_exceed_level_4.setup(m_time_sample);
m_voltage_ab_decrease_level_1.setup(m_time_sample);
m_voltage_bc_decrease_level_1.setup(m_time_sample);
m_voltage_ca_decrease_level_1.setup(m_time_sample);
m_voltage_ab_decrease_level_2.setup(m_time_sample);
m_voltage_bc_decrease_level_2.setup(m_time_sample);
m_voltage_ca_decrease_level_2.setup(m_time_sample);
m_voltage_ab_decrease_level_3.setup(m_time_sample);
m_voltage_bc_decrease_level_3.setup(m_time_sample);
m_voltage_ca_decrease_level_3.setup(m_time_sample);
m_current_a_overload_level_1.setup(m_time_sample);
m_current_b_overload_level_1.setup(m_time_sample);
m_current_c_overload_level_1.setup(m_time_sample);
m_current_a_overload_level_2.setup(m_time_sample);
m_current_b_overload_level_2.setup(m_time_sample);
m_current_c_overload_level_2.setup(m_time_sample);
m_current_a_overload_level_3.setup(m_time_sample);
m_current_b_overload_level_3.setup(m_time_sample);
m_current_c_overload_level_3.setup(m_time_sample);
m_current_invertor_a_overload_level_1.setup(m_time_sample);
m_current_invertor_b_overload_level_1.setup(m_time_sample);
m_current_invertor_c_overload_level_1.setup(m_time_sample);
m_current_invertor_a_overload_level_2.setup(m_time_sample);
m_current_invertor_b_overload_level_2.setup(m_time_sample);
m_current_invertor_c_overload_level_2.setup(m_time_sample);
m_current_invertor_a_overload_level_3.setup(m_time_sample);
m_current_invertor_b_overload_level_3.setup(m_time_sample);
m_current_invertor_c_overload_level_3.setup(m_time_sample);
m_current_input_a_overload_level_1.setup(m_time_sample);
m_current_input_b_overload_level_1.setup(m_time_sample);
m_current_input_c_overload_level_1.setup(m_time_sample);
m_current_input_a_overload_level_2.setup(m_time_sample);
m_current_input_b_overload_level_2.setup(m_time_sample);
m_current_input_c_overload_level_2.setup(m_time_sample);
m_current_input_a_overload_level_3.setup(m_time_sample);
m_current_input_b_overload_level_3.setup(m_time_sample);
m_current_input_c_overload_level_3.setup(m_time_sample);
//
}//setup()
//
void PhaseAlertMonitor::configure(const PhaseAlertConfiguration& config)
{
m_voltage_ab_exceed_level_1.configure(config.voltage_exceed_level_1);
m_voltage_bc_exceed_level_1.configure(config.voltage_exceed_level_1);
m_voltage_ca_exceed_level_1.configure(config.voltage_exceed_level_1);
m_voltage_ab_exceed_level_2.configure(config.voltage_exceed_level_2);
m_voltage_bc_exceed_level_2.configure(config.voltage_exceed_level_2);
m_voltage_ca_exceed_level_2.configure(config.voltage_exceed_level_2);
m_voltage_ab_exceed_level_3.configure(config.voltage_exceed_level_3);
m_voltage_bc_exceed_level_3.configure(config.voltage_exceed_level_3);
m_voltage_ca_exceed_level_3.configure(config.voltage_exceed_level_3);
m_voltage_ab_exceed_level_4.configure(config.voltage_exceed_level_4);
m_voltage_bc_exceed_level_4.configure(config.voltage_exceed_level_4);
m_voltage_ca_exceed_level_4.configure(config.voltage_exceed_level_4);
m_voltage_ab_decrease_level_1.configure(config.voltage_decrease_level_1);
m_voltage_bc_decrease_level_1.configure(config.voltage_decrease_level_1);
m_voltage_ca_decrease_level_1.configure(config.voltage_decrease_level_1);
m_voltage_ab_decrease_level_2.configure(config.voltage_decrease_level_2);
m_voltage_bc_decrease_level_2.configure(config.voltage_decrease_level_2);
m_voltage_ca_decrease_level_2.configure(config.voltage_decrease_level_2);
m_voltage_ab_decrease_level_3.configure(config.voltage_decrease_level_3);
m_voltage_bc_decrease_level_3.configure(config.voltage_decrease_level_3);
m_voltage_ca_decrease_level_3.configure(config.voltage_decrease_level_3);
m_current_a_overload_level_1.configure(config.current_overload_level_1);
m_current_b_overload_level_1.configure(config.current_overload_level_1);
m_current_c_overload_level_1.configure(config.current_overload_level_1);
m_current_a_overload_level_2.configure(config.current_overload_level_2);
m_current_b_overload_level_2.configure(config.current_overload_level_2);
m_current_c_overload_level_2.configure(config.current_overload_level_2);
m_current_a_overload_level_3.configure(config.current_overload_level_3);
m_current_b_overload_level_3.configure(config.current_overload_level_3);
m_current_c_overload_level_3.configure(config.current_overload_level_3);
//
m_current_invertor_a_overload_level_1.configure(config.current_invertor_overload_level_1);
m_current_invertor_b_overload_level_1.configure(config.current_invertor_overload_level_1);
m_current_invertor_c_overload_level_1.configure(config.current_invertor_overload_level_1);
m_current_invertor_a_overload_level_2.configure(config.current_invertor_overload_level_2);
m_current_invertor_b_overload_level_2.configure(config.current_invertor_overload_level_2);
m_current_invertor_c_overload_level_2.configure(config.current_invertor_overload_level_2);
m_current_invertor_a_overload_level_3.configure(config.current_invertor_overload_level_3);
m_current_invertor_b_overload_level_3.configure(config.current_invertor_overload_level_3);
m_current_invertor_c_overload_level_3.configure(config.current_invertor_overload_level_3);
//
m_current_input_a_overload_level_1.configure(config.current_input_overload_level_1);
m_current_input_b_overload_level_1.configure(config.current_input_overload_level_1);
m_current_input_c_overload_level_1.configure(config.current_input_overload_level_1);
m_current_input_a_overload_level_2.configure(config.current_input_overload_level_2);
m_current_input_b_overload_level_2.configure(config.current_input_overload_level_2);
m_current_input_c_overload_level_2.configure(config.current_input_overload_level_2);
m_current_input_a_overload_level_3.configure(config.current_input_overload_level_3);
m_current_input_b_overload_level_3.configure(config.current_input_overload_level_3);
m_current_input_c_overload_level_3.configure(config.current_input_overload_level_3);
if((m_time_sample > FP_ZERO))
{
_execute = &SYSCTRL::PhaseAlertMonitor::_execute_operational;
//
}//if
//
}//configure()
//
#pragma CODE_SECTION("ramfuncs");
void PhaseAlertMonitor::get_faults(PhaseFaultRegister& ph_a, PhaseFaultRegister& ph_b, PhaseFaultRegister& ph_c)
{
ph_a.all = m_monitor.phase_a.fault.all;
ph_b.all = m_monitor.phase_b.fault.all;
ph_c.all = m_monitor.phase_c.fault.all;
//
}//
//
//
#pragma CODE_SECTION("ramfuncs");
void PhaseAlertMonitor::reset()
{
m_monitor.phase_a.warning.all = (uint16_t)0;
m_monitor.phase_a.fault.all = (uint16_t)0;
m_monitor.phase_b.warning.all = (uint16_t)0;
m_monitor.phase_b.fault.all = (uint16_t)0;
m_monitor.phase_c.warning.all = (uint16_t)0;
m_monitor.phase_c.fault.all = (uint16_t)0;
//
m_monitor.phase_a.warning.all = (uint16_t)0;
m_monitor.phase_a.fault.all = (uint16_t)0;
m_monitor.phase_b.warning.all = (uint16_t)0;
m_monitor.phase_b.fault.all = (uint16_t)0;
m_monitor.phase_c.warning.all = (uint16_t)0;
m_monitor.phase_c.fault.all = (uint16_t)0;
//
m_voltage_ab_exceed_level_1.reset();
m_voltage_bc_exceed_level_1.reset();
m_voltage_ca_exceed_level_1.reset();
m_voltage_ab_exceed_level_2.reset();
m_voltage_bc_exceed_level_2.reset();
m_voltage_ca_exceed_level_2.reset();
m_voltage_ab_exceed_level_3.reset();
m_voltage_bc_exceed_level_3.reset();
m_voltage_ca_exceed_level_3.reset();
m_voltage_ab_exceed_level_4.reset();
m_voltage_bc_exceed_level_4.reset();
m_voltage_ca_exceed_level_4.reset();
m_voltage_ab_decrease_level_1.reset();
m_voltage_bc_decrease_level_1.reset();
m_voltage_ca_decrease_level_1.reset();
m_voltage_ab_decrease_level_2.reset();
m_voltage_bc_decrease_level_2.reset();
m_voltage_ca_decrease_level_2.reset();
m_voltage_ab_decrease_level_3.reset();
m_voltage_bc_decrease_level_3.reset();
m_voltage_ca_decrease_level_3.reset();
m_current_a_overload_level_1.reset();
m_current_b_overload_level_1.reset();
m_current_c_overload_level_1.reset();
m_current_a_overload_level_2.reset();
m_current_b_overload_level_2.reset();
m_current_c_overload_level_2.reset();
m_current_a_overload_level_3.reset();
m_current_b_overload_level_3.reset();
m_current_c_overload_level_3.reset();
m_current_invertor_a_overload_level_1.reset();
m_current_invertor_b_overload_level_1.reset();
m_current_invertor_c_overload_level_1.reset();
m_current_invertor_a_overload_level_2.reset();
m_current_invertor_b_overload_level_2.reset();
m_current_invertor_c_overload_level_2.reset();
m_current_invertor_a_overload_level_3.reset();
m_current_invertor_b_overload_level_3.reset();
m_current_invertor_c_overload_level_3.reset();
//
m_fault = false;
m_warning = false;
warning = m_warning;
fault = m_fault;
status = m_monitor;
//
}//reset()
//
#pragma CODE_SECTION("ramfuncs");
void PhaseAlertMonitor::execute(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inprmsb, float inprmsc)
{
(this->*_execute)(urmsa, urmsb, urmsc, irmsa, irmsb, irmsc, invrmsa, invrmsb, invrmsc, inprmsa, inprmsb, inprmsc);
//
}//execute()
//
#pragma CODE_SECTION("ramfuncs");
void PhaseAlertMonitor::_execute_undef(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inprmsb, float inprmsc)
{
//
}//_execute_undef()
//
#pragma CODE_SECTION("ramfuncs");
void PhaseAlertMonitor::_execute_operational(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inprmsb, float inprmsc)
{
static bool _warning = false;
_warning = false;
m_monitor.phase_a.warning.all = (uint16_t)0;
m_monitor.phase_a.fault.all = (uint16_t)0;
m_monitor.phase_b.warning.all = (uint16_t)0;
m_monitor.phase_b.fault.all = (uint16_t)0;
m_monitor.phase_c.warning.all = (uint16_t)0;
m_monitor.phase_c.fault.all = (uint16_t)0;
//
m_voltage_ab_exceed_level_1.execute(urmsa);
m_voltage_bc_exceed_level_1.execute(urmsb);
m_voltage_ca_exceed_level_1.execute(urmsc);
m_voltage_ab_exceed_level_2.execute(urmsa);
m_voltage_bc_exceed_level_2.execute(urmsb);
m_voltage_ca_exceed_level_2.execute(urmsc);
m_voltage_ab_exceed_level_3.execute(urmsa);
m_voltage_bc_exceed_level_3.execute(urmsb);
m_voltage_ca_exceed_level_3.execute(urmsc);
m_voltage_ab_exceed_level_4.execute(urmsa);
m_voltage_bc_exceed_level_4.execute(urmsb);
m_voltage_ca_exceed_level_4.execute(urmsc);
/*
m_voltage_a_decrease_level_1.execute(urmsa);
m_voltage_b_decrease_level_1.execute(urmsb);
m_voltage_c_decrease_level_1.execute(urmsc);
m_voltage_a_decrease_level_2.execute(urmsa);
m_voltage_b_decrease_level_2.execute(urmsb);
m_voltage_c_decrease_level_2.execute(urmsc);
m_voltage_a_decrease_level_3.execute(urmsa);
m_voltage_b_decrease_level_3.execute(urmsb);
m_voltage_c_decrease_level_3.execute(urmsc);
*/
m_current_a_overload_level_1.execute(irmsa);
m_current_b_overload_level_1.execute(irmsb);
m_current_c_overload_level_1.execute(irmsc);
m_current_a_overload_level_2.execute(irmsa);
m_current_b_overload_level_2.execute(irmsb);
m_current_c_overload_level_2.execute(irmsc);
m_current_a_overload_level_3.execute(irmsa);
m_current_b_overload_level_3.execute(irmsb);
m_current_c_overload_level_3.execute(irmsc);
m_current_invertor_a_overload_level_1.execute(invrmsa);
m_current_invertor_b_overload_level_1.execute(invrmsb);
m_current_invertor_c_overload_level_1.execute(invrmsc);
m_current_invertor_a_overload_level_2.execute(invrmsa);
m_current_invertor_b_overload_level_2.execute(invrmsb);
m_current_invertor_c_overload_level_2.execute(invrmsc);
m_current_invertor_a_overload_level_3.execute(invrmsa);
m_current_invertor_b_overload_level_3.execute(invrmsb);
m_current_invertor_c_overload_level_3.execute(invrmsc);
//
m_current_input_a_overload_level_1.execute(inprmsa);
m_current_input_b_overload_level_1.execute(inprmsb);
m_current_input_c_overload_level_1.execute(inprmsc);
m_current_input_a_overload_level_2.execute(inprmsa);
m_current_input_b_overload_level_2.execute(inprmsb);
m_current_input_c_overload_level_2.execute(inprmsc);
m_current_input_a_overload_level_3.execute(inprmsa);
m_current_input_b_overload_level_3.execute(inprmsb);
m_current_input_c_overload_level_3.execute(inprmsc);
//
// set flags
m_monitor.phase_a.warning.bit.exceed_voltage_level_1 = m_voltage_ab_exceed_level_1.warning;
m_monitor.phase_a.warning.bit.exceed_voltage_level_2 = m_voltage_ab_exceed_level_2.warning;
m_monitor.phase_a.fault.bit.exceed_voltage_level_3 = m_voltage_ab_exceed_level_3.fault;
m_monitor.phase_a.fault.bit.exceed_voltage_level_4 = m_voltage_ab_exceed_level_4.fault;
m_monitor.phase_a.warning.bit.decrease_voltage_level_1 = m_voltage_ab_decrease_level_1.warning;
m_monitor.phase_a.warning.bit.decrease_voltage_level_2 = m_voltage_ab_decrease_level_2.warning;
m_monitor.phase_a.fault.bit.decrease_voltage_level_3 = m_voltage_ab_decrease_level_3.fault;
m_monitor.phase_a.fault.bit.overload_current_level_1 = m_current_a_overload_level_1.fault;
m_monitor.phase_a.fault.bit.overload_current_level_2 = m_current_a_overload_level_2.fault;
m_monitor.phase_a.fault.bit.overload_current_level_3 = m_current_a_overload_level_3.fault;
m_monitor.phase_a.fault.bit.overload_invertor_current_level_1 = m_current_invertor_a_overload_level_1.fault;
m_monitor.phase_a.fault.bit.overload_invertor_current_level_2 = m_current_invertor_a_overload_level_2.fault;
m_monitor.phase_a.fault.bit.overload_invertor_current_level_3 = m_current_invertor_a_overload_level_3.fault;
m_monitor.phase_a.fault.bit.overload_input_current_level_1 = m_current_input_a_overload_level_1.fault;
m_monitor.phase_a.fault.bit.overload_input_current_level_2 = m_current_input_a_overload_level_2.fault;
m_monitor.phase_a.fault.bit.overload_input_current_level_3 = m_current_input_a_overload_level_3.fault;
//
m_monitor.phase_b.warning.bit.exceed_voltage_level_1 = m_voltage_bc_exceed_level_1.warning;
m_monitor.phase_b.warning.bit.exceed_voltage_level_2 = m_voltage_bc_exceed_level_2.warning;
m_monitor.phase_b.fault.bit.exceed_voltage_level_3 = m_voltage_bc_exceed_level_3.fault;
m_monitor.phase_b.fault.bit.exceed_voltage_level_4 = m_voltage_bc_exceed_level_4.fault;
m_monitor.phase_b.warning.bit.decrease_voltage_level_1 = m_voltage_bc_decrease_level_1.warning;
m_monitor.phase_b.warning.bit.decrease_voltage_level_2 = m_voltage_bc_decrease_level_2.warning;
m_monitor.phase_b.fault.bit.decrease_voltage_level_3 = m_voltage_bc_decrease_level_3.fault;
m_monitor.phase_b.fault.bit.overload_current_level_1 = m_current_b_overload_level_1.fault;
m_monitor.phase_b.fault.bit.overload_current_level_2 = m_current_b_overload_level_2.fault;
m_monitor.phase_b.fault.bit.overload_current_level_3 = m_current_b_overload_level_3.fault;
m_monitor.phase_b.fault.bit.overload_invertor_current_level_1 = m_current_invertor_b_overload_level_1.fault;
m_monitor.phase_b.fault.bit.overload_invertor_current_level_2 = m_current_invertor_b_overload_level_2.fault;
m_monitor.phase_b.fault.bit.overload_invertor_current_level_3 = m_current_invertor_b_overload_level_3.fault;
m_monitor.phase_b.fault.bit.overload_input_current_level_1 = m_current_input_b_overload_level_1.fault;
m_monitor.phase_b.fault.bit.overload_input_current_level_2 = m_current_input_b_overload_level_2.fault;
m_monitor.phase_b.fault.bit.overload_input_current_level_3 = m_current_input_b_overload_level_3.fault;
//
m_monitor.phase_c.warning.bit.exceed_voltage_level_1 = m_voltage_ca_exceed_level_1.warning;
m_monitor.phase_c.warning.bit.exceed_voltage_level_2 = m_voltage_ca_exceed_level_2.warning;
m_monitor.phase_c.fault.bit.exceed_voltage_level_3 = m_voltage_ca_exceed_level_3.fault;
m_monitor.phase_c.fault.bit.exceed_voltage_level_4 = m_voltage_ca_exceed_level_4.fault;
m_monitor.phase_c.warning.bit.decrease_voltage_level_1 = m_voltage_ca_decrease_level_1.warning;
m_monitor.phase_c.warning.bit.decrease_voltage_level_2 = m_voltage_ca_decrease_level_2.warning;
m_monitor.phase_c.fault.bit.decrease_voltage_level_3 = m_voltage_ca_decrease_level_3.fault;
m_monitor.phase_c.fault.bit.overload_current_level_1 = m_current_c_overload_level_1.fault;
m_monitor.phase_c.fault.bit.overload_current_level_2 = m_current_c_overload_level_2.fault;
m_monitor.phase_c.fault.bit.overload_current_level_3 = m_current_c_overload_level_3.fault;
m_monitor.phase_c.fault.bit.overload_invertor_current_level_1 = m_current_invertor_c_overload_level_1.fault;
m_monitor.phase_c.fault.bit.overload_invertor_current_level_2 = m_current_invertor_c_overload_level_2.fault;
m_monitor.phase_c.fault.bit.overload_invertor_current_level_3 = m_current_invertor_c_overload_level_3.fault;
m_monitor.phase_c.fault.bit.overload_input_current_level_1 = m_current_input_c_overload_level_1.fault;
m_monitor.phase_c.fault.bit.overload_input_current_level_2 = m_current_input_c_overload_level_2.fault;
m_monitor.phase_c.fault.bit.overload_input_current_level_3 = m_current_input_c_overload_level_3.fault;
//
status = m_monitor;
//
if(m_monitor.phase_a.fault.all != (uint16_t)0){ m_fault = true;}
if(m_monitor.phase_b.fault.all != (uint16_t)0){ m_fault = true;}
if(m_monitor.phase_c.fault.all != (uint16_t)0){ m_fault = true;}
//
if(m_monitor.phase_a.warning.all != (uint16_t)0){ _warning = true;}
if(m_monitor.phase_b.warning.all != (uint16_t)0){ _warning = true;}
if(m_monitor.phase_c.warning.all != (uint16_t)0){ _warning = true;}
m_warning = _warning;
warning = m_warning;
fault = m_fault;
//
}//_execute_operational()
} /* namespace SYSCTRL */

@ -0,0 +1,242 @@
/*
* PhaseAlertMonitor.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/ALERTHeaders.h"
#ifndef SYSCTRL_PHASEALERTMONITOR_H_
#define SYSCTRL_PHASEALERTMONITOR_H_
namespace SYSCTRL
{
struct PhaseAlertConfiguration
{
ALERT::AlertBaseConfiguration voltage_exceed_level_1;
ALERT::AlertBaseConfiguration voltage_exceed_level_2;
ALERT::AlertBaseConfiguration voltage_exceed_level_3;
ALERT::AlertBaseConfiguration voltage_exceed_level_4;
ALERT::AlertBaseConfiguration voltage_decrease_level_1;
ALERT::AlertBaseConfiguration voltage_decrease_level_2;
ALERT::AlertBaseConfiguration voltage_decrease_level_3;
ALERT::AlertBaseConfiguration current_overload_level_1;
ALERT::AlertBaseConfiguration current_overload_level_2;
ALERT::AlertBaseConfiguration current_overload_level_3;
ALERT::AlertBaseConfiguration current_invertor_overload_level_1;
ALERT::AlertBaseConfiguration current_invertor_overload_level_2;
ALERT::AlertBaseConfiguration current_invertor_overload_level_3;
ALERT::AlertBaseConfiguration current_input_overload_level_1;
ALERT::AlertBaseConfiguration current_input_overload_level_2;
ALERT::AlertBaseConfiguration current_input_overload_level_3;
PhaseAlertConfiguration():
voltage_exceed_level_1(),
voltage_exceed_level_2(),
voltage_exceed_level_3(),
voltage_exceed_level_4(),
voltage_decrease_level_1(),
voltage_decrease_level_2(),
voltage_decrease_level_3(),
current_overload_level_1(),
current_overload_level_2(),
current_overload_level_3(),
current_invertor_overload_level_1(),
current_invertor_overload_level_2(),
current_invertor_overload_level_3(),
current_input_overload_level_1(),
current_input_overload_level_2(),
current_input_overload_level_3()
{}
//
};//SystemAlertConfiguration
struct PhaseWarningBit
{
uint16_t exceed_voltage_level_1 :1;
uint16_t exceed_voltage_level_2 :1;
uint16_t decrease_voltage_level_1 :1;
uint16_t decrease_voltage_level_2 :1;
//
};//PhaseWarningBit
struct PhaseFaultBit
{
uint16_t exceed_voltage_level_3 :1; // 0
uint16_t exceed_voltage_level_4 :1; // 1
uint16_t decrease_voltage_level_3 :1; // 2
uint16_t phase_lost :1; // 3
//
uint16_t short_circuit :1; // 4
uint16_t high_current :1; // 5
uint16_t overload_current_level_1 :1; // 6
uint16_t overload_current_level_2 :1; // 7
//
uint16_t overload_current_level_3 :1; // 8
uint16_t overload_invertor_current_level_1 :1; // 9
uint16_t overload_invertor_current_level_2 :1; // 10
uint16_t overload_invertor_current_level_3 :1; // 11
//
uint16_t overload_input_current_level_1 :1; // 12
uint16_t overload_input_current_level_2 :1; // 13
uint16_t overload_input_current_level_3 :1; // 14
uint16_t reserved_15 :1; // 15
};//PhaseFaultBit
union PhaseWarningRegister
{
uint16_t all;
struct PhaseWarningBit bit;
PhaseWarningRegister():
all(uint16_t(0))
{}
//
};//PhaseWarningRegister
union PhaseFaultRegister
{
uint16_t all;
struct PhaseFaultBit bit;
PhaseFaultRegister():
all(uint16_t(0))
{}
};//PhaseFaultRegister
struct PhaseAlertStatusRegister
{
union PhaseWarningRegister warning;
union PhaseFaultRegister fault;
PhaseAlertStatusRegister():
warning(),
fault()
{}
};//PhaseAlertStatusRegister
struct PhaseAlertRegister
{
struct PhaseAlertStatusRegister phase_a;
struct PhaseAlertStatusRegister phase_b;
struct PhaseAlertStatusRegister phase_c;
PhaseAlertRegister():
phase_a(),
phase_b(),
phase_c()
{}
//
};//PhaseAlertRegister
class PhaseAlertMonitor
{
private:
float m_time_sample;
bool m_fault;
bool m_warning;
private:
PhaseAlertRegister m_monitor;
public:
PhaseAlertRegister status;
bool fault;
bool warning;
private:
ALERT::WarningExceed m_voltage_ab_exceed_level_1;
ALERT::WarningExceed m_voltage_bc_exceed_level_1;
ALERT::WarningExceed m_voltage_ca_exceed_level_1;
//
ALERT::WarningExceed m_voltage_ab_exceed_level_2;
ALERT::WarningExceed m_voltage_bc_exceed_level_2;
ALERT::WarningExceed m_voltage_ca_exceed_level_2;
//
ALERT::FaultExceed m_voltage_ab_exceed_level_3;
ALERT::FaultExceed m_voltage_bc_exceed_level_3;
ALERT::FaultExceed m_voltage_ca_exceed_level_3;
//
ALERT::FaultExceed m_voltage_ab_exceed_level_4;
ALERT::FaultExceed m_voltage_bc_exceed_level_4;
ALERT::FaultExceed m_voltage_ca_exceed_level_4;
//
ALERT::WarningDecrease m_voltage_ab_decrease_level_1;
ALERT::WarningDecrease m_voltage_bc_decrease_level_1;
ALERT::WarningDecrease m_voltage_ca_decrease_level_1;
//
ALERT::WarningDecrease m_voltage_ab_decrease_level_2;
ALERT::WarningDecrease m_voltage_bc_decrease_level_2;
ALERT::WarningDecrease m_voltage_ca_decrease_level_2;
//
ALERT::FaultDecrease m_voltage_ab_decrease_level_3;
ALERT::FaultDecrease m_voltage_bc_decrease_level_3;
ALERT::FaultDecrease m_voltage_ca_decrease_level_3;
//
ALERT::FaultExceed m_current_a_overload_level_1;
ALERT::FaultExceed m_current_b_overload_level_1;
ALERT::FaultExceed m_current_c_overload_level_1;
//
ALERT::FaultExceed m_current_a_overload_level_2;
ALERT::FaultExceed m_current_b_overload_level_2;
ALERT::FaultExceed m_current_c_overload_level_2;
//
ALERT::FaultExceed m_current_a_overload_level_3;
ALERT::FaultExceed m_current_b_overload_level_3;
ALERT::FaultExceed m_current_c_overload_level_3;
//
ALERT::FaultExceed m_current_invertor_a_overload_level_1;
ALERT::FaultExceed m_current_invertor_b_overload_level_1;
ALERT::FaultExceed m_current_invertor_c_overload_level_1;
//
ALERT::FaultExceed m_current_invertor_a_overload_level_2;
ALERT::FaultExceed m_current_invertor_b_overload_level_2;
ALERT::FaultExceed m_current_invertor_c_overload_level_2;
//
ALERT::FaultExceed m_current_invertor_a_overload_level_3;
ALERT::FaultExceed m_current_invertor_b_overload_level_3;
ALERT::FaultExceed m_current_invertor_c_overload_level_3;
ALERT::FaultExceed m_current_input_a_overload_level_1;
ALERT::FaultExceed m_current_input_b_overload_level_1;
ALERT::FaultExceed m_current_input_c_overload_level_1;
//
ALERT::FaultExceed m_current_input_a_overload_level_2;
ALERT::FaultExceed m_current_input_b_overload_level_2;
ALERT::FaultExceed m_current_input_c_overload_level_2;
//
ALERT::FaultExceed m_current_input_a_overload_level_3;
ALERT::FaultExceed m_current_input_b_overload_level_3;
ALERT::FaultExceed m_current_input_c_overload_level_3;
public:
PhaseAlertMonitor();
void setup(float time_sample);
void configure(const PhaseAlertConfiguration& config);
public:
void get_faults(PhaseFaultRegister& ph_a, PhaseFaultRegister& ph_b, PhaseFaultRegister& ph_c);
void reset();
public:
void execute(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inmrmsb, float inmrmsc);
private:
void (PhaseAlertMonitor::*_execute)(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inmrmsb, float inmrmsc);
void _execute_undef(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inmrmsb, float inmrmsc);
void _execute_operational(float urmsa, float urmsb, float urmsc,
float irmsa, float irmsb, float irmsc,
float invrmsa, float invrmsb, float invrmsc,
float inprmsa, float inmrmsb, float inmrmsc);
//
};//PhaseAlertMonitor
} /* namespace SYSCTRL */
#endif /* SYSCTRL_PHASEALERTMONITOR_H_ */

@ -0,0 +1,49 @@
/*
* AnalogSignalStructure.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_ANALOGSIGNALSTRUCTURE_H_
#define SYSCTRL_ANALOGSIGNALSTRUCTURE_H_
namespace SYSCTRL
{
struct ProjectionAnalogSignalStructure
{
float active;
float reactive;
ProjectionAnalogSignalStructure():
active(FP_ZERO),
reactive(FP_ZERO)
{}
};//ProjectionAnalogSignalStructure
struct RelativeAnalogSignalStructure
{
float amplitude;
float relative;
void reset()
{
amplitude = FP_ZERO;
relative = FP_ZERO;
}
RelativeAnalogSignalStructure():
amplitude(FP_ZERO),
relative(FP_ZERO)
{}
};//AnalogSignalStructure
} /* namespace SYSCTRL */
#endif /* SYSCTRL_ANALOGSIGNALSTRUCTURE_H_ */

@ -0,0 +1,663 @@
/*
* SYSRestart.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/SYSRestart.h"
namespace SYSCTRL
{
//CONSTRUCTOR
SYSRestart::SYSRestart(SYSCTRL::SystemEnvironment& env):
m_env(env),
m_mode(SYSCTRL::SYSRestart::UNDEFINED),
m_state(SYSCTRL::SYSRestart::EMPTY),
m_state_bit_field(),
m_time_sample(-1.0),
m_config(),
m_registers(),
status(),
_execute(&SYSCTRL::SYSRestart::_execute_undef),
_state_run(&SYSCTRL::SYSRestart::_state_empty)
//
{}//CONSTRUCTOR
void SYSRestart::setup(float time_sample)
{
if(m_mode == SYSCTRL::SYSRestart::UNDEFINED)
{
if(time_sample > FP_ZERO)
{
m_time_sample = time_sample;
m_mode = SYSCTRL::SYSRestart::CONFIGURATE;
//
}//if
//
}//if
//
}//
//
void SYSRestart::configure(SYSRestartConfiguration& config)
{
bool _status = true;
if(m_mode == SYSCTRL::SYSRestart::CONFIGURATE)
{
m_config = config;
if((m_config.enable.equipment.all != (uint16_t)0)||
(m_config.enable.phase_a.all != (uint16_t)0)||
(m_config.enable.phase_b.all != (uint16_t)0)||
(m_config.enable.phase_c.all != (uint16_t)0))
{
_status &= m_config.period_timer_hold_fault > m_time_sample ? true : false;
_status &= m_config.period_timer_selfclear_attempts > m_time_sample ? true : false;
_status &= m_config.period_timer_turnon_switch > m_time_sample ? true : false;
_status &= m_config.attempts > 0 ? true : false;
}//if
//
m_registers.counter_attempts = 0;
m_registers.counter_timer = FP_ZERO;
m_registers.counter_timer_selfclear_attempts = FP_ZERO;
m_registers.status.all = 0;
//
if(_status)
{
m_mode = SYSCTRL::SYSRestart::OPERATIONAL;
_execute = &SYSCTRL::SYSRestart::_execute_operational;
if((m_config.restart_enable.signal.enable)&&
((m_config.enable.equipment.all != (uint16_t)0)||
(m_config.enable.phase_a.all != (uint16_t)0)||
(m_config.enable.phase_b.all != (uint16_t)0)||
(m_config.enable.phase_c.all != (uint16_t)0)))
{
_state_run = &SYSCTRL::SYSRestart::_state_free;
m_state = SYSCTRL::SYSRestart::FREE;
}
else
{
_state_run = &SYSCTRL::SYSRestart::_state_empty;
m_state = SYSCTRL::SYSRestart::EMPTY;
//
}// if else
//
}//if
//
}//if
//
}//
//
SYSRestart::mode_t SYSRestart::get_mode()
{
return m_mode;
//
}//
//
SYSRestart::state_t SYSRestart::get_state()
{
return m_state;
}//
//
#pragma CODE_SECTION("ramfuncs");
uint16_t SYSRestart::get_state_steps()
{
return m_state_bit_field.all;
//
}//
//
uint16_t SYSRestart::get_attempts()
{
return m_registers.counter_attempts;
//
}//
//
bool SYSRestart::compare(SYSCTRL::SYSRestart::mode_t mode)
{
return mode == m_mode;
//
}//
//
bool SYSRestart::compare_state(SYSRestart::SYSRestart::state_t state)
{
return state == m_state;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::execute()
{
(this->*_execute)();
}//
//
void SYSRestart::_execute_undef()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_execute_operational()
{
if(m_config.restart_enable.signal.enable)
{
m_registers.status_fault_register.equipment.all = m_config.enable.equipment.all & m_env.system_faults_register.equipment.all;
m_registers.status_fault_register.phase_a.all = m_config.enable.phase_a.all & m_env.system_faults_register.phase_a.all;
m_registers.status_fault_register.phase_b.all = m_config.enable.phase_b.all & m_env.system_faults_register.phase_b.all;
m_registers.status_fault_register.phase_c.all = m_config.enable.phase_c.all & m_env.system_faults_register.phase_c.all;
//
m_registers.status.signal.fault = m_registers.status_fault_register.equipment.all == (uint16_t)0 ? false : true;
m_registers.status.signal.fault |= m_registers.status_fault_register.phase_a.all == (uint16_t)0 ? false : true;
m_registers.status.signal.fault |= m_registers.status_fault_register.phase_b.all == (uint16_t)0 ? false : true;
m_registers.status.signal.fault |= m_registers.status_fault_register.phase_c.all == (uint16_t)0 ? false : true;
//
if(m_registers.counter_attempts != 0)
{
if(m_registers.counter_timer_selfclear_attempts < m_config.period_timer_selfclear_attempts)
{
m_registers.counter_timer_selfclear_attempts += m_time_sample;
}
else
{
m_registers.counter_attempts = 0;
m_registers.counter_timer_selfclear_attempts = FP_ZERO;
}
}
//
SYSCTRL::MonitorDigitalInputSignal::implement(m_registers.status.signal.fault, m_registers.monitor_fault);
//
_state_execute();
//
}
else
{
_set_state_free();
//
}//if else
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_empty()
{
m_state = SYSCTRL::SYSRestart::EMPTY;
m_state_bit_field.all = 0;
m_state_bit_field.signal.empty = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
status.all = m_registers.status.all;
//
SYSCTRL::MonitorDigitalInputSignal::preset(false, m_registers.monitor_fault);
//
_state_run = &SYSCTRL::SYSRestart::_state_empty;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_free()
{
m_state = SYSCTRL::SYSRestart::FREE;
m_state_bit_field.all = 0;
m_state_bit_field.signal.free = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_free;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_holdfault()
{
m_state = SYSCTRL::SYSRestart::HOLDFAULT;
m_state_bit_field.signal.free = 0;
m_state_bit_field.signal.holdfault = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_holdfault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_resetfault()
{
m_state = SYSCTRL::SYSRestart::RESETFAULT;
m_state_bit_field.signal.resetfault = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 1;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_resetfault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_freezefault()
{
m_state = SYSCTRL::SYSRestart::FREEZEFAULT;
m_state_bit_field.all = 0;
m_state_bit_field.signal.freezefault = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 1;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_freezefault;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_holdstop()
{
m_state = SYSCTRL::SYSRestart::HOLDSTOP;
m_state_bit_field.signal.holdstop = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_holdstop;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_turnon_q1()
{
m_state = SYSCTRL::SYSRestart::TURNONQ1;
m_state_bit_field.signal.turnonq1 = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 1;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_turnon_q1;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_turnon_km1()
{
m_state = SYSCTRL::SYSRestart::TURNONKM1;
m_state_bit_field.signal.turnonkm1 = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 1;
m_registers.status.signal.turnon_km3 = 0;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_turnon_km1;
//
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_turnon_km3()
{
m_state = SYSCTRL::SYSRestart::TURNONKM3;
m_state_bit_field.signal.turnonkm3 = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 0;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 1;
//
status.all = m_registers.status.all;
//
_state_run = &SYSCTRL::SYSRestart::_state_turnon_km3;
//
//
}//
//
#pragma CODE_SECTION("ramfuncs");
inline void SYSRestart::_set_state_startup()
{
m_state = SYSCTRL::SYSRestart::STARTUP;
m_state_bit_field.signal.turnonq1 = 1;
m_state_bit_field.signal.turnonkm1 = 1;
m_state_bit_field.signal.turnonkm3 = 1;
m_state_bit_field.signal.startup = 1;
//
m_registers.counter_timer = FP_ZERO;
//
m_registers.status.signal.resetfault = 0;
m_registers.status.signal.freezefault = 0;
m_registers.status.signal.startup = 1;
m_registers.status.signal.turnon_q1 = 0;
m_registers.status.signal.turnon_km1 = 0;
m_registers.status.signal.turnon_km3 = 0;
status.all = m_registers.status.all;
//
m_registers.counter_attempts++;
//
_state_run = &SYSCTRL::SYSRestart::_state_startup;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_execute()
{
(this->*_state_run)();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_empty()
{}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_free()
{
// Change State if appropriate conditions was happened
if(m_registers.monitor_fault.signal.is_on)
{
_set_state_holdfault();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_holdfault()
{
// Change State if appropriate conditions was happened
if(m_registers.counter_timer < m_config.period_timer_hold_fault)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(!m_env.system_fault.boolbit.b0)
{
_set_state_free();
//
}//if
if(m_registers.counter_attempts >= m_config.attempts)
{
_set_state_freezefault();
//
}//if
if(m_env.system_fault.boolbit.b0 & (m_registers.counter_timer >= m_config.period_timer_hold_fault))
{
_set_state_resetfault();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_resetfault()
{
// Change State if appropriate conditions was happened
if(m_registers.counter_timer < m_config.period_timer_reset)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(!m_env.system_fault.boolbit.b0)
{
_set_state_holdstop();
//
}//if
if(m_env.system_fault.boolbit.b0 & (m_registers.counter_timer >= m_config.period_timer_reset))
{
_set_state_freezefault();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_freezefault()
{
// Change State if appropriate conditions was happened
if(!m_env.system_fault.boolbit.b0)
{
_set_state_free();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_holdstop()
{
// Change State if appropriate conditions was happened
if(m_registers.counter_timer < m_config.period_timer_hold_stop)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(m_env.system_fault.boolbit.b0 |
(!m_env.system_fault.boolbit.b0 & m_env.remote_stop.state.signal.is_on)
)
{
_set_state_free();
//
}//if
if(!m_env.system_fault.boolbit.b0 &
!m_env.system_ready.boolbit.b0 &
(m_registers.counter_timer >= m_config.period_timer_hold_stop)
)
{
_set_state_turnon_q1();
//
}//if
if(!m_env.system_fault.boolbit.b0 & m_env.system_ready.boolbit.b0)
{
_set_state_startup();
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_turnon_q1()
{
if(m_registers.counter_timer < m_config.period_timer_turnon_switch)
{
m_registers.counter_timer += m_time_sample;
//
}//if
//
if(m_env.system_fault.boolbit.b0 |
(m_registers.counter_timer >= m_config.period_timer_turnon_switch)
)
{
_set_state_free();
//
}//if
//
if(!m_env.system_fault.boolbit.b0 & m_env.input_discrete.signal.auxiliary_q1)
{
_set_state_turnon_km1();
//
}//if
if(!m_env.system_fault.boolbit.b0 & m_env.system_ready.boolbit.b0)
{
_set_state_startup();
//
}//if
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_turnon_km1()
{
if(m_registers.counter_timer < m_config.period_timer_turnon_switch)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(m_env.system_fault.boolbit.b0 |
(m_registers.counter_timer >= m_config.period_timer_turnon_switch)
)
{
_set_state_free();
//
}//if
//
//
if(!m_env.system_fault.boolbit.b0 & m_env.input_discrete.signal.auxiliary_km1)
{
_set_state_turnon_km3();
//
}//if
if(!m_env.system_fault.boolbit.b0 & m_env.system_ready.boolbit.b0)
{
_set_state_startup();
//
}//if
}//
//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_turnon_km3()
{
if(m_registers.counter_timer < m_config.period_timer_turnon_switch)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(m_env.system_fault.boolbit.b0 |
(m_registers.counter_timer >= m_config.period_timer_turnon_switch)
)
{
_set_state_free();
//
}//if
//
if(!m_env.system_fault.boolbit.b0 & m_env.system_ready.boolbit.b0)
{
_set_state_startup();
//
}//if
}//
#pragma CODE_SECTION("ramfuncs");
void SYSRestart::_state_startup()
{
// Change State if appropriate conditions was happened
if(m_registers.counter_timer < m_config.period_timer_startup)
{
m_registers.counter_timer += m_time_sample;
//
}//if
if(m_env.system_fault.boolbit.b0 |
(m_registers.counter_timer >= m_config.period_timer_startup) |
(m_env.enable_work.boolbit.b0) |
(m_env.remote_stop.state.signal.is_on)
)
{
_set_state_free();
//
}//if
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,200 @@
/*
* SYSRestart.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/MonitorDigitalInputSignal.h"
#include "SYSCTRL/SystemDefinitions.h"
#include "SYSCTRL/PhaseAlertMonitor.h"
#include "SYSCTRL/SystemEnvironment.h"
#ifndef SYSCTRL_SYSRESTART_H_
#define SYSCTRL_SYSRESTART_H_
namespace SYSCTRL
{
struct SYSRestartEnableBitField
{
uint16_t enable: 1;
};//SYSRestartEnableBitField
union SYSRestartEnableRegister
{
uint16_t all;
struct SYSRestartEnableBitField signal;
SYSRestartEnableRegister():
all((uint16_t)0)
{}
};//SYSRestartEnableRegister
struct SYSRestartStatusBitField
{
uint16_t fault : 1;
uint16_t resetfault : 1;
uint16_t freezefault : 1;
uint16_t startup : 1;
uint16_t turnon_q1 : 1;
uint16_t turnon_km1 : 1;
uint16_t turnon_km3 : 1;
};//SYSRestartStatusBitField
//
union SYSRestartStatusRegister
{
uint16_t all;
struct SYSRestartStatusBitField signal;
SYSRestartStatusRegister():
all((uint16_t)0)
{}
};//SYSRestartStatusRegister
struct SYSRestartRegisters
{
float counter_timer;
float counter_timer_selfclear_attempts;
uint16_t counter_attempts;
SYSCTRL::SystemFaultsRegister status_fault_register;
SYSCTRL::MonitorDigitalInputSignalRegister monitor_fault;
SYSCTRL::MonitorDigitalInputSignalRegister monitor_resetfault;
SYSCTRL::MonitorDigitalInputSignalRegister monitor_startup;
SYSRestartStatusRegister status;
SYSRestartRegisters():
counter_timer(FP_ZERO),
counter_timer_selfclear_attempts(FP_ZERO),
counter_attempts(0),
status_fault_register(),
monitor_fault(),
monitor_resetfault(),
monitor_startup(),
status()
{}
};//SYSRestartRegisters
struct SYSRestartConfiguration
{
SYSRestartEnableRegister restart_enable;
float period_timer_hold_fault;
float period_timer_reset;
float period_timer_hold_stop;
float period_timer_turnon_switch;
float period_timer_startup;
float period_timer_selfclear_attempts;
uint16_t attempts;
SYSCTRL::SystemFaultsRegister enable;
SYSRestartConfiguration():
restart_enable(),
period_timer_hold_fault(-1.0),
period_timer_reset(-1.0),
period_timer_hold_stop(-1.0),
period_timer_turnon_switch(-1.0),
period_timer_startup(-1.0),
period_timer_selfclear_attempts(-1.0),
attempts(0),
enable()
{}
};//SYSRestartConfiguration
struct SYSRestartStateBitField
{
uint16_t free : 1; // bit 0
uint16_t holdfault : 1; // bit 1
uint16_t resetfault : 1; // bit 2
uint16_t holdstop : 1; // bit 3
uint16_t turnonq1 : 1; // bit 4
uint16_t turnonkm1 : 1; // bit 5
uint16_t turnonkm3 : 1; // bit 6
uint16_t startup : 1; // bit 7
uint16_t freezefault: 1; // bit 8
uint16_t empty : 1; // bit 9
//
};//SYSRestartStateBitField
union SYSRestartStateRegister
{
uint16_t all;
SYSRestartStateBitField signal;
SYSRestartStateRegister():
all(0)
{}
};
class SYSRestart
{
public:
enum mode_t {UNDEFINED, CONFIGURATE, OPERATIONAL};
enum state_t {FREE, HOLDFAULT, RESETFAULT, HOLDSTOP, TURNONQ1, TURNONKM1, TURNONKM3, STARTUP, FREEZEFAULT, EMPTY};
private:
SYSCTRL::SystemEnvironment& m_env;
private:
mode_t m_mode;
state_t m_state;
SYSRestartStateRegister m_state_bit_field;
// Setup parameters
float m_time_sample;
// Configuration parameters
SYSCTRL::SYSRestartConfiguration m_config;
//
SYSCTRL::SYSRestartRegisters m_registers;
public:
SYSRestartStatusRegister status;
public:
SYSRestart(SYSCTRL::SystemEnvironment& m_env);
void setup(float time_sample);
void configure(SYSRestartConfiguration& config);
public:
mode_t get_mode();
state_t get_state();
uint16_t get_state_steps();
uint16_t get_attempts();
bool compare(mode_t mode);
bool compare_state(state_t state);
public:
void execute();
private:
void (SYSRestart::*_execute)();
void _execute_undef();
void _execute_operational();
private:
inline void _set_state_empty();
inline void _set_state_free();
inline void _set_state_holdfault();
inline void _set_state_resetfault();
inline void _set_state_freezefault();
inline void _set_state_holdstop();
inline void _set_state_turnon_q1();
inline void _set_state_turnon_km1();
inline void _set_state_turnon_km3();
inline void _set_state_startup();
private:
void _state_execute();
void (SYSRestart::*_state_run)();
void _state_empty();
void _state_free();
void _state_holdfault();
void _state_resetfault();
void _state_freezefault();
void _state_holdstop();
void _state_turnon_q1();
void _state_turnon_km1();
void _state_turnon_km3();
void _state_startup();
//
};// SYSRestart
} /* namespace SYSCTRL */
#endif /* SYSCTRL_SYSRESTART_H_ */

@ -0,0 +1,94 @@
/*
* ScaleCompute.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/ScaleCompute.h"
namespace SYSCTRL
{
//CONSTRUCTOR
ScaleCompute::ScaleCompute(float& phase_a, float& phase_b, float& phase_c, float& scale_a, float& scale_b, float& scale_c):
m_command(),
m_enable(),
//
m_reference_value(FP_ZERO),
//
m_p_phase_a(phase_a),
m_p_phase_b(phase_b),
m_p_phase_c(phase_c),
//
m_p_scale_a(scale_a),
m_p_scale_b(scale_b),
m_p_scale_c(scale_c),
//
m_value_phase_a(FP_ZERO),
m_value_phase_b(FP_ZERO),
m_value_phase_c(FP_ZERO),
//
m_scale_phase_a(FP_ZERO),
m_scale_phase_b(FP_ZERO),
m_scale_phase_c(FP_ZERO)
{}//CONSTRUCTOR
#pragma CODE_SECTION("ramfuncs");
void ScaleCompute::set_reference(float reference)
{
m_reference_value = reference;
//
}//
#pragma CODE_SECTION("ramfuncs");
void ScaleCompute::set_enable()
{
m_enable.bit.enable = 1;
//
}//
#pragma CODE_SECTION("ramfuncs");
void ScaleCompute::clear_enable()
{
m_enable.bit.enable = 0;
//
}//
#pragma CODE_SECTION("ramfuncs");
void ScaleCompute::fix()
{
if(m_enable.bit.enable == 1)
{
m_value_phase_a = m_p_phase_a;
m_value_phase_b = m_p_phase_b;
m_value_phase_c = m_p_phase_c;
//
m_scale_phase_a = new_scale_compute(m_reference_value, m_value_phase_a, m_p_scale_a);
m_scale_phase_b = new_scale_compute(m_reference_value, m_value_phase_b, m_p_scale_b);
m_scale_phase_c = new_scale_compute(m_reference_value, m_value_phase_c, m_p_scale_c);
//
m_p_scale_a = m_scale_phase_a;
m_p_scale_b = m_scale_phase_b;
m_p_scale_c = m_scale_phase_c;
//
}//if
}//
#pragma CODE_SECTION("ramfuncs");
inline float ScaleCompute::new_scale_compute(float ref, float value, float scale)
{
//
if((value != FP_ZERO) && (ref != FP_ZERO))
{
return ref * scale / value;
//
}
else
{
return scale;
//
}//if else
//
}//
} /* namespace SYSCTRL */

@ -0,0 +1,79 @@
/*
* ScaleCompute.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#ifndef SYSCTRL_SCALECOMPUTE_H_
#define SYSCTRL_SCALECOMPUTE_H_
namespace SYSCTRL
{
struct ScaleComputeEnableBit
{
uint16_t enable: 1;
};//ScaleComputeEnableBit
union ScaleComputeEnableRegister
{
uint16_t all;
ScaleComputeEnableBit bit;
};//ScaleComputeEnableRegister
struct ScaleComputeCommandBit
{
uint16_t start: 1;
};//ScaleComputeCommandBit
union ScaleComputeCommandRegister
{
uint16_t all;
ScaleComputeCommandBit bit;
};//ScaleComputeCommandRegister
class ScaleCompute
{
private:
ScaleComputeCommandRegister m_command;
ScaleComputeEnableRegister m_enable;
float m_reference_value;
//
float& m_p_phase_a;
float& m_p_phase_b;
float& m_p_phase_c;
//
float& m_p_scale_a;
float& m_p_scale_b;
float& m_p_scale_c;
//
float m_value_phase_a;
float m_value_phase_b;
float m_value_phase_c;
//
float m_scale_phase_a;
float m_scale_phase_b;
float m_scale_phase_c;
public:
ScaleCompute(float& phase_a, float& phase_b, float& phase_c, float& scale_a, float& scale_b, float& scale_c);
void set_reference(float reference);
void set_enable();
void clear_enable();
void fix();
private:
inline float new_scale_compute(float ref, float value, float scale);
//
};//class ScaleCompute
} /* namespace SYSCTRL */
#endif /* SYSCTRL_SCALECOMPUTE_H_ */

@ -0,0 +1,86 @@
/*
* SignalDecompose.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/SignalDecompose.h"
namespace SYSCTRL
{
//CONSTRUCTOR
SignalDecompose::SignalDecompose():
m_time_sample(-1.0),
m_projection_active(),
m_projection_reactive(),
m_projection_filter_active(),
m_projection_filter_reactive(),
_execute(&SYSCTRL::SignalDecompose::_execute_undef)
//
{}//CONSTRUCTOR
void SignalDecompose::setup(float time_sample)
{
m_time_sample = time_sample;
m_projection_filter_active.setup(m_time_sample);
m_projection_filter_reactive.setup(m_time_sample);
//
}//
//
void SignalDecompose::configure(const SignalDecomposeConfiguration& config)
{
m_projection_filter_active.configure(config.projection_filter);
m_projection_filter_reactive.configure(config.projection_filter);
//
if((m_time_sample > FP_ZERO) && (config.projection_filter.time > m_time_sample))
{
_execute = &SYSCTRL::SignalDecompose::_execute_operational;
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalDecompose::reset()
{
m_projection_active = FP_ZERO;
m_projection_reactive = FP_ZERO;
m_projection_filter_active.reset();
m_projection_filter_reactive.reset();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalDecompose::get_outputs(float& projection_active, float& projection_reactive)
{
projection_active = m_projection_active;
projection_reactive = m_projection_reactive;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalDecompose::execute(float reference, float ort_cos, float ort_sin)
{
(this->*_execute)(reference, ort_cos, ort_sin);
//
}//
//
void SignalDecompose::_execute_undef(float reference, float ort_cos, float ort_sin)
{
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalDecompose::_execute_operational(float reference, float ort_cos, float ort_sin)
{
//
m_projection_active = m_projection_filter_active.execute(1.4142 * reference * ort_cos);
//
m_projection_reactive = m_projection_filter_reactive.execute(-(1.4142 * reference * ort_sin));
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,74 @@
/*
* SignalDecompose.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/BaseComponent.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
#ifndef SYSCTRL_SIGNALDECOMPOSE_H_
#define SYSCTRL_SIGNALDECOMPOSE_H_
namespace SYSCTRL
{
struct SignalDecomposeStructure
{
float projection_active;
float projection_reactive;
void reset()
{
projection_active = FP_ZERO;
projection_reactive = FP_ZERO;
}
SignalDecomposeStructure():
projection_active(FP_ZERO),
projection_reactive(FP_ZERO)
{}
};//
struct SignalDecomposeConfiguration
{
FLTSYSLIB::FilterForthConfiguration projection_filter;
SignalDecomposeConfiguration():
projection_filter()
{}
};//SignalDecomposeConfiguration
class SignalDecompose
{
private:
float m_time_sample;
private:
float m_projection_active;
float m_projection_reactive;
FLTSYSLIB::FilterForth m_projection_filter_active;
FLTSYSLIB::FilterForth m_projection_filter_reactive;
public:
SignalDecompose();
void setup(float time_sample);
void configure(const SignalDecomposeConfiguration& config);
public:
void reset();
void get_outputs(float& projection_active, float& projection_reactive);
public:
void execute(float reference, float ort_cos, float ort_sin);
private:
void (SignalDecompose::*_execute)(float reference, float ort_cos, float ort_sin);
void _execute_undef(float reference, float ort_cos, float ort_sin);
void _execute_operational(float reference, float ort_cos, float ort_sin);
//
};//SignalDecompose
} /* namespace SYSCTRL */
#endif /* SYSCTRL_SIGNALDECOMPOSE_H_ */

@ -0,0 +1,134 @@
/*
* RelativeSignal.cpp
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include "SYSCTRL/SignalRelative.h"
namespace SYSCTRL
{
//CONSTRUCTOR
SignalRelative::SignalRelative():
BaseComponent(),
m_amplitude(FP_ZERO),
m_relative(FP_ZERO),
m_limit_relative_high(FP_ZERO),
m_limit_relative_low(FP_ZERO),
m_minimal_amplitude_level(FP_ZERO),
m_ampl_filter(),
_execute(&SYSCTRL::SignalRelative::_execute_undef)
{}//CONSTRUCTOR
//
void SignalRelative::setup(const SignalRelativeSetup& setup)
{
static bool status = true;
if(m_mode == SYSCTRL::SignalRelative::UNDEFINED)
{
m_time_sample = setup.time_sample;
m_ampl_filter.setup(m_time_sample);
status &= m_time_sample > FP_ZERO ? true : false;
status &= m_ampl_filter.compare(FLTSYSLIB::AMPL::CONFIGURATE);
if(status)
{
m_mode = SYSCTRL::SignalRelative::CONFIGURATE;
//
}//if
//
}//if
//
}//
//
void SignalRelative::configure(const SignalRelativeConfiguration& config)
{
static bool status = true;
if(m_mode == SYSCTRL::SignalRelative::CONFIGURATE)
{
m_limit_relative_high = config.limit_relative_high;
m_limit_relative_low = config.limit_relative_low;
m_minimal_amplitude_level = config.minimal_amplitude_level;
m_ampl_filter.configure(config.amplitude_filter);
status &= m_limit_relative_high > m_limit_relative_low ? true : false;
status &= m_minimal_amplitude_level > FP_ZERO ? true : false;
status &= m_ampl_filter.compare(FLTSYSLIB::AMPL::OPERATIONAL);
if(status)
{
m_mode = SYSCTRL::SignalRelative::OPERATIONAL;
_execute = &SYSCTRL::SignalRelative::_execute_operational;
//
}//if
//
}//if
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalRelative::reset()
{
m_amplitude = FP_ZERO;
m_relative = FP_ZERO;
m_ampl_filter.reset();
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalRelative::get_outputs(float& amplitude, float& relative)
{
amplitude = m_amplitude;
relative = m_relative;
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalRelative::execute(float reference)
{
(this->*_execute)(reference);
//
}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalRelative::_execute_undef(float reference)
{}//
//
#pragma CODE_SECTION("ramfuncs");
void SignalRelative::_execute_operational(float reference)
{
static float _relative = FP_ZERO;
m_amplitude = m_ampl_filter.execute(reference);
if(m_amplitude > m_minimal_amplitude_level)
{
//
_relative = reference / m_amplitude;
//
if(_relative > m_limit_relative_high)
{
_relative = m_limit_relative_high;
//
}//if
//
if(_relative < m_limit_relative_low)
{
_relative = m_limit_relative_low;
//
}//if
//
}
else
{
_relative = FP_ZERO;
//
}// if else
//
m_relative = _relative;
//
}//
//
} /* namespace SYSCTRL */

@ -0,0 +1,74 @@
/*
* RelativeSignal.h
*
* Author: Aleksey Gerasimenko
* gerasimenko.aleksey.n@gmail.com
*/
#include <math.h>
#include <stdint.h>
#include "SYSCTRL/BaseComponent.h"
#include "SYSCTRL/HeadersFLTSYSLIB.h"
#ifndef SYSCTRL_RELATIVESIGNAL_H_
#define SYSCTRL_RELATIVESIGNAL_H_
namespace SYSCTRL
{
struct SignalRelativeSetup
{
float time_sample;
SignalRelativeSetup():
time_sample(-1.0)
{}
};//SignalRelativeSetup
struct SignalRelativeConfiguration
{
float limit_relative_high;
float limit_relative_low;
float minimal_amplitude_level;
FLTSYSLIB::AMPLF4OConfiguration amplitude_filter;
SignalRelativeConfiguration():
limit_relative_high(1.0),
limit_relative_low(-1.0),
minimal_amplitude_level(0.1),
amplitude_filter()
{}
};//SignalRelativeConfiguration
class SignalRelative: public BaseComponent
{
private:
float m_amplitude;
float m_relative;
private:
float m_limit_relative_high;
float m_limit_relative_low;
float m_minimal_amplitude_level;
private:
FLTSYSLIB::AMPLF4O m_ampl_filter;
public:
SignalRelative();
void setup(const SignalRelativeSetup& setup);
void configure(const SignalRelativeConfiguration& config);
public:
void reset();
void get_outputs(float& amplitude, float& relative);
public:
void execute(float reference);
private:
void (SignalRelative::*_execute)(float reference);
void _execute_undef(float reference);
void _execute_operational(float reference);
//
};//RelativeSignal
} /* namespace SYSCTRL */
#endif /* SYSCTRL_RELATIVESIGNAL_H_ */

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save