From 5c663ac779dffbc8f392f4da39b68631782feae6 Mon Sep 17 00:00:00 2001 From: Michael Gafert Date: Fri, 13 Sep 2024 10:30:32 +0200 Subject: [PATCH] Change FBs of powerlink to be compatible with latest FORTE version (#171) * Reverted erroneous names, removed old powerlink FBs and added new powerlink FBs in new structure. * Added automatic download of tinyxml and openPOWERLINK (only posix) when FORTE_MODULE_POWERLINK is set but FORTE_MODULE_POWERLINK_LIB_DIR or FORTE_MODULE_POWERLINK_TINYXML_DIR are not set * Added X20DO9322 * Added abstraction for DI and DO powerlink nodes * Added powerlink to systemtests * Added abstract FBs for powerlink analog input, output and temperature input * Fix DEVLOG_DEBUG arguments * Downgrade to openPOWERLINK 1.8.0 which allows it to work with OPC UA * Added all other function blocks * Added copyright notice * Changed tabs to spaces * Turn interfacespec into a reference * Use DOWNLOAD_EXTRACT_TIMESTAMP as stated in the warning * Changed &scmFBInterfaceSpec to scmFBInterfaceSpec to fit core changes * Switch to range based loops * Renamed to fit coding style * Fixed copyright date * Convert idents to tabs * Reformated to 2 spaces * Removed type indicators --- .github/workflows/systemtests.yml | 6 + src/com/powerlink/CMakeLists.txt | 178 +++-- src/com/powerlink/EplWrapper.cpp | 702 +++++++++--------- src/com/powerlink/EplWrapper.h | 127 ++-- src/com/powerlink/EplXmlReader.cpp | 13 +- src/com/powerlink/ModuleList.cpp | 5 +- src/com/powerlink/ModuleList.h | 4 +- src/com/powerlink/POWERLINK_MN.cpp | 72 -- src/com/powerlink/POWERLINK_MN.h | 80 -- src/com/powerlink/ProcessImageMatrix.cpp | 3 - src/com/powerlink/X20AI4622.cpp | 106 --- src/com/powerlink/X20AI4622.h | 111 --- src/com/powerlink/X20AO4622.cpp | 105 --- src/com/powerlink/X20AO4622.h | 111 --- src/com/powerlink/X20AT2402.cpp | 107 --- src/com/powerlink/X20AT2402.h | 101 --- src/com/powerlink/X20AT4222.cpp | 106 --- src/com/powerlink/X20AT4222.h | 111 --- src/com/powerlink/X20DI4653.cpp | 105 --- src/com/powerlink/X20DI4653.h | 104 --- src/com/powerlink/X20DI9371.cpp | 97 --- src/com/powerlink/X20DI9371.h | 152 ---- src/com/powerlink/X20DI9372.cpp | 99 --- src/com/powerlink/X20DI9372.h | 151 ---- src/com/powerlink/X20DI937X.cpp | 98 --- src/com/powerlink/X20DI937X.h | 154 ---- src/com/powerlink/X20DO4623.cpp | 106 --- src/com/powerlink/X20DO4623.h | 103 --- src/com/powerlink/X20DO4649.cpp | 100 --- src/com/powerlink/X20DO4649.h | 111 --- src/com/powerlink/X20DO9321.cpp | 101 --- src/com/powerlink/X20DO9321.h | 151 ---- src/com/powerlink/X20DO9322.cpp | 99 --- src/com/powerlink/X20DO9322.h | 151 ---- src/com/powerlink/fb/POWERLINK_MN_fbt.cpp | 152 ++++ src/com/powerlink/fb/POWERLINK_MN_fbt.h | 98 +++ .../powerlink/fb/PowerlinkFunctionBlockAI.cpp | 85 +++ .../powerlink/fb/PowerlinkFunctionBlockAI.h | 45 ++ .../powerlink/fb/PowerlinkFunctionBlockAO.cpp | 87 +++ .../powerlink/fb/PowerlinkFunctionBlockAO.h | 45 ++ .../powerlink/fb/PowerlinkFunctionBlockAT.cpp | 87 +++ .../powerlink/fb/PowerlinkFunctionBlockAT.h | 45 ++ .../powerlink/fb/PowerlinkFunctionBlockDI.cpp | 80 ++ .../powerlink/fb/PowerlinkFunctionBlockDI.h | 45 ++ .../powerlink/fb/PowerlinkFunctionBlockDO.cpp | 81 ++ .../powerlink/fb/PowerlinkFunctionBlockDO.h | 45 ++ src/com/powerlink/fb/X20AI2622_fbt.cpp | 170 +++++ src/com/powerlink/fb/X20AI2622_fbt.h | 124 ++++ src/com/powerlink/fb/X20AI4622_fbt.cpp | 182 +++++ src/com/powerlink/fb/X20AI4622_fbt.h | 134 ++++ src/com/powerlink/fb/X20AO4622_fbt.cpp | 178 +++++ src/com/powerlink/fb/X20AO4622_fbt.h | 130 ++++ src/com/powerlink/fb/X20AT2402_fbt.cpp | 170 +++++ src/com/powerlink/fb/X20AT2402_fbt.h | 124 ++++ src/com/powerlink/fb/X20AT4222_fbt.cpp | 182 +++++ src/com/powerlink/fb/X20AT4222_fbt.h | 134 ++++ src/com/powerlink/fb/X20DI4653_fbt.cpp | 182 +++++ src/com/powerlink/fb/X20DI4653_fbt.h | 133 ++++ src/com/powerlink/fb/X20DI9371_fbt.cpp | 264 +++++++ src/com/powerlink/fb/X20DI9371_fbt.h | 188 +++++ src/com/powerlink/fb/X20DI9372_fbt.cpp | 230 ++++++ src/com/powerlink/fb/X20DI9372_fbt.h | 173 +++++ src/com/powerlink/fb/X20DO4623_fbt.cpp | 178 +++++ src/com/powerlink/fb/X20DO4623_fbt.h | 129 ++++ src/com/powerlink/fb/X20DO4649_fbt.cpp | 178 +++++ src/com/powerlink/fb/X20DO4649_fbt.h | 129 ++++ src/com/powerlink/fb/X20DO9321_fbt.cpp | 218 ++++++ src/com/powerlink/fb/X20DO9321_fbt.h | 161 ++++ src/com/powerlink/fb/X20DO9322_fbt.cpp | 252 +++++++ src/com/powerlink/fb/X20DO9322_fbt.h | 160 ++++ src/com/powerlink/readme.txt | 22 - src/com/powerlink/startup.cpp | 2 +- 72 files changed, 5534 insertions(+), 3418 deletions(-) delete mode 100644 src/com/powerlink/POWERLINK_MN.cpp delete mode 100644 src/com/powerlink/POWERLINK_MN.h delete mode 100644 src/com/powerlink/X20AI4622.cpp delete mode 100644 src/com/powerlink/X20AI4622.h delete mode 100644 src/com/powerlink/X20AO4622.cpp delete mode 100644 src/com/powerlink/X20AO4622.h delete mode 100644 src/com/powerlink/X20AT2402.cpp delete mode 100644 src/com/powerlink/X20AT2402.h delete mode 100644 src/com/powerlink/X20AT4222.cpp delete mode 100644 src/com/powerlink/X20AT4222.h delete mode 100644 src/com/powerlink/X20DI4653.cpp delete mode 100644 src/com/powerlink/X20DI4653.h delete mode 100644 src/com/powerlink/X20DI9371.cpp delete mode 100644 src/com/powerlink/X20DI9371.h delete mode 100644 src/com/powerlink/X20DI9372.cpp delete mode 100644 src/com/powerlink/X20DI9372.h delete mode 100644 src/com/powerlink/X20DI937X.cpp delete mode 100644 src/com/powerlink/X20DI937X.h delete mode 100644 src/com/powerlink/X20DO4623.cpp delete mode 100644 src/com/powerlink/X20DO4623.h delete mode 100644 src/com/powerlink/X20DO4649.cpp delete mode 100644 src/com/powerlink/X20DO4649.h delete mode 100644 src/com/powerlink/X20DO9321.cpp delete mode 100644 src/com/powerlink/X20DO9321.h delete mode 100644 src/com/powerlink/X20DO9322.cpp delete mode 100644 src/com/powerlink/X20DO9322.h create mode 100644 src/com/powerlink/fb/POWERLINK_MN_fbt.cpp create mode 100644 src/com/powerlink/fb/POWERLINK_MN_fbt.h create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAI.cpp create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAI.h create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAO.cpp create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAO.h create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAT.cpp create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockAT.h create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockDI.cpp create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockDI.h create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockDO.cpp create mode 100644 src/com/powerlink/fb/PowerlinkFunctionBlockDO.h create mode 100644 src/com/powerlink/fb/X20AI2622_fbt.cpp create mode 100644 src/com/powerlink/fb/X20AI2622_fbt.h create mode 100644 src/com/powerlink/fb/X20AI4622_fbt.cpp create mode 100644 src/com/powerlink/fb/X20AI4622_fbt.h create mode 100644 src/com/powerlink/fb/X20AO4622_fbt.cpp create mode 100644 src/com/powerlink/fb/X20AO4622_fbt.h create mode 100644 src/com/powerlink/fb/X20AT2402_fbt.cpp create mode 100644 src/com/powerlink/fb/X20AT2402_fbt.h create mode 100644 src/com/powerlink/fb/X20AT4222_fbt.cpp create mode 100644 src/com/powerlink/fb/X20AT4222_fbt.h create mode 100644 src/com/powerlink/fb/X20DI4653_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DI4653_fbt.h create mode 100644 src/com/powerlink/fb/X20DI9371_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DI9371_fbt.h create mode 100644 src/com/powerlink/fb/X20DI9372_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DI9372_fbt.h create mode 100644 src/com/powerlink/fb/X20DO4623_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DO4623_fbt.h create mode 100644 src/com/powerlink/fb/X20DO4649_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DO4649_fbt.h create mode 100644 src/com/powerlink/fb/X20DO9321_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DO9321_fbt.h create mode 100644 src/com/powerlink/fb/X20DO9322_fbt.cpp create mode 100644 src/com/powerlink/fb/X20DO9322_fbt.h delete mode 100644 src/com/powerlink/readme.txt diff --git a/.github/workflows/systemtests.yml b/.github/workflows/systemtests.yml index 7786c78d..60be5000 100644 --- a/.github/workflows/systemtests.yml +++ b/.github/workflows/systemtests.yml @@ -23,6 +23,11 @@ jobs: echo "source-dir=$GITHUB_WORKSPACE" >> "$GITHUB_OUTPUT" echo "build-dir=$GITHUB_WORKSPACE/build" >> "$GITHUB_OUTPUT" + - name: Install lipcap-dev + # libpcap-dev is required for the POWERLINK module + # TODO: Put this in 4diac-fortebuildcontainer + run: apt-get update && apt-get install -y libpcap-dev + - name: Configure CMake run: > cmake -S ${{ steps.strings.outputs.source-dir }} -B ${{ steps.strings.outputs.build-dir }} @@ -46,6 +51,7 @@ jobs: -DFORTE_MODULE_RT_Events=ON -DFORTE_MODULE_SIGNALPROCESSING=ON -DFORTE_MODULE_UTILS=ON + -DFORTE_MODULE_POWERLINK=ON -DFORTE_TESTS=ON -DFORTE_SYSTEM_TESTS=ON -DFORTE_TEST_SANITIZE=ON diff --git a/src/com/powerlink/CMakeLists.txt b/src/com/powerlink/CMakeLists.txt index 056ff8cf..c93c7a36 100644 --- a/src/com/powerlink/CMakeLists.txt +++ b/src/com/powerlink/CMakeLists.txt @@ -1,13 +1,14 @@ #******************************************************************************* -# Copyright (c) 2012 - 2014 AIT, fortiss GmbH +# Copyright (c) 2014 - 2024 AIT, fortiss GmbH # This program and the accompanying materials are made available under the # terms of the Eclipse Public License 2.0 which is available at # http://www.eclipse.org/legal/epl-2.0. # # SPDX-License-Identifier: EPL-2.0 -# +# # Contributors: # Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation +# Michael Gafert - automatic download and linking of openPOWERLINK and tinyXML # *******************************************************************************/ forte_add_module(POWERLINK OFF "openPOWERLINK Service Interface Function Blocks") @@ -16,69 +17,126 @@ forte_add_module(POWERLINK OFF "openPOWERLINK Service Interface Function Blocks" # COM Service Interface Function Blocks ############################################################################# -if("${FORTE_ARCHITECTURE}" STREQUAL "Win32") - forte_add_sourcefile_cpp(EplWrapper.cpp) - forte_add_definition( -D_CONSOLE -DWPCAP ) - - forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Target/X86/Windows/WpdPack/Include) +if (NOT "${FORTE_ARCHITECTURE}" STREQUAL "Win32" AND NOT "${FORTE_ARCHITECTURE}" STREQUAL "Posix") + MESSAGE(FATAL_ERROR "openPOWERLINK is only supported for FORTE on Windows and Linux platforms.") +endif () + +SET(FORTE_MODULE_POWERLINK_LIB_DIR "" CACHE PATH "Path to openPOWERLINK-V1.08 directory") +SET(FORTE_MODULE_POWERLINK_TINYXML_DIR "" CACHE PATH "Path to TinyXML directory") + +# Download tinyXML +if (NOT FORTE_MODULE_POWERLINK_TINYXML_DIR) + include(FetchContent) + FetchContent_Declare( + tinyxml + URL https://downloads.sourceforge.net/project/tinyxml/tinyxml/2.6.2/tinyxml_2_6_2.zip + URL_HASH SHA256=ac6bb9501c6f50cc922d22f26b02fab168db47521be5e845b83d3451a3e1d512 + DOWNLOAD_EXTRACT_TIMESTAMP true + ) + + FetchContent_Populate(tinyxml) + + message("Downloaded tinyXML in ${tinyxml_SOURCE_DIR}") + + set(FORTE_MODULE_POWERLINK_TINYXML_DIR ${tinyxml_SOURCE_DIR}) +endif () +if ("${FORTE_ARCHITECTURE}" STREQUAL "Win32") + forte_add_sourcefile_cpp(EplWrapper.cpp) + forte_add_definition(-D_CONSOLE -DWPCAP) + + forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Target/X86/Windows/WpdPack/Include) forte_add_link_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Target/X86/Windows/WpdPack/Lib) - forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/EplStack/trace.c) - + forte_add_link_library(openPOWERLINK.lib) forte_add_link_library(wpcap.lib) forte_add_link_library(iphlpapi.lib) +elseif ("${FORTE_ARCHITECTURE}" STREQUAL "Posix") + # Download and build openPOWERLINK only for posix as there are too many problems with the Windows build + if (NOT FORTE_MODULE_POWERLINK_LIB_DIR) + # Only V1.08 of openPOWERLINK is supported + FetchContent_Declare( + openpowerlink + URL https://downloads.sourceforge.net/project/openpowerlink/openPOWERLINK/V1.8.0/openPOWERLINK-V1.08.zip + URL_HASH MD5=7ae68359cbc9092d125d43c75b4794ad + DOWNLOAD_EXTRACT_TIMESTAMP true + ) + FetchContent_Populate(openpowerlink) + + message("Downloaded openPOWERLINK in ${openpowerlink_SOURCE_DIR}") + + # TODO: Pass target architecture to openPOWERLINK build, important for Windows as wpcap is only available for x86 + # TODO: Ninja generator does not work with openPOWERLINK build as in does not build the .lib file + execute_process( + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" CMakeLists.txt # -D CFG_X86_WINDOWS_DLL=ON (for Windows) + WORKING_DIRECTORY "${openpowerlink_SOURCE_DIR}" + ) + + execute_process( + COMMAND ${CMAKE_COMMAND} --build . --config Release + WORKING_DIRECTORY "${openpowerlink_SOURCE_DIR}" + ) + + # Move the openPOWERLINK library to the FORTE_MODULE_POWERLINK_LIB_DIR as expected + file(RENAME + "${openpowerlink_SOURCE_DIR}/Examples/X86/Generic/powerlink_user_lib/libpowerlink.a" + "${openpowerlink_SOURCE_DIR}/libpowerlink.a") + + set(FORTE_MODULE_POWERLINK_LIB_DIR "${openpowerlink_SOURCE_DIR}") + endif () -elseif("${FORTE_ARCHITECTURE}" STREQUAL "Posix") - forte_add_sourcefile_cpp(EplWrapper.cpp) forte_add_link_library(-lpowerlink -lpcap -lrt) -else() - MESSAGE("openPOWERLINK is only supported for FORTE on Windows and Linux platforms. Disabled Module!") - set(FORTE_MODULE_POWERLINK OFF) -endif() - -if(FORTE_MODULE_POWERLINK) - SET(FORTE_MODULE_POWERLINK_LIB_DIR "" CACHE PATH "Path to openPOWERLINK-V1.08.1 directory") - SET(FORTE_MODULE_POWERLINK_TINYXML_DIR "" CACHE PATH "Path to TinyXML directory") - - forte_add_sourcefile_hcpp( POWERLINK_MN - X20DO9321 - X20DO9322 - X20DI4653 - X20DI9371 - X20DI9372 - X20AI4622 - X20AO4622 - X20AT2402 - X20AT4222 - X20DO4649 - X20DO4623 - EplXmlReader - ModuleList - ProcessImageMatrix ) - - forte_add_sourcefile_h( EplWrapper.h ) - - forte_add_link_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}) - forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - - forte_add_startup_hook(powerlinkStartupHook) - forte_add_sourcefile_cpp(startup.cpp) - - forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Include) - forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/SharedBuff) - forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN) - forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Examples/X86/Generic/powerlink_user_lib) - forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN/EplApiProcessImageSetup.c) - forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/EplStack/EplTgtConio.c) - - forte_add_include_directories(${FORTE_MODULE_POWERLINK_TINYXML_DIR}) - forte_add_sourcefile_with_path_hcpp( ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinystr - ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxml ) - - forte_add_sourcefile_with_path_cpp( ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlerror.cpp - ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlparser.cpp ) - - forte_add_definition( -DCONFIG_POWERLINK_USERSTACK ) -endif(FORTE_MODULE_POWERLINK) +endif () + +forte_add_sourcefile_cpp(EplWrapper.cpp) +forte_add_sourcefile_h(EplWrapper.h) + +forte_add_sourcefile_hcpp( + fb/PowerlinkFunctionBlockDI + fb/PowerlinkFunctionBlockDO + fb/PowerlinkFunctionBlockAI + fb/PowerlinkFunctionBlockAO + fb/PowerlinkFunctionBlockAT + fb/POWERLINK_MN_fbt + fb/X20AI2622_fbt + fb/X20AI4622_fbt + fb/X20AO4622_fbt + fb/X20AT2402_fbt + fb/X20AT4222_fbt + fb/X20DI4653_fbt + fb/X20DI9371_fbt + fb/X20DI9372_fbt + fb/X20DO4623_fbt + fb/X20DO4649_fbt + fb/X20DO9321_fbt + fb/X20DO9322_fbt + EplXmlReader + ModuleList + ProcessImageMatrix) + +forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +forte_add_startup_hook(powerlinkStartupHook) +forte_add_sourcefile_cpp(startup.cpp) + +forte_add_link_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}) +forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Include) +forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/SharedBuff) +forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN) +forte_add_include_directories(${FORTE_MODULE_POWERLINK_LIB_DIR}/Examples/X86/Generic/powerlink_user_lib) +forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/ObjDicts/CiA302-4_MN/EplApiProcessImageSetup.c) +forte_add_sourcefile_with_path_cpp(${FORTE_MODULE_POWERLINK_LIB_DIR}/EplStack/EplTgtConio.c) + +forte_add_include_directories(${FORTE_MODULE_POWERLINK_TINYXML_DIR}) +forte_add_sourcefile_with_path_hcpp( + ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinystr + ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxml +) + +forte_add_sourcefile_with_path_cpp( + ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlerror.cpp + ${FORTE_MODULE_POWERLINK_TINYXML_DIR}/tinyxmlparser.cpp +) + +forte_add_definition(-DCONFIG_POWERLINK_USERSTACK) diff --git a/src/com/powerlink/EplWrapper.cpp b/src/com/powerlink/EplWrapper.cpp index 46b9b7ec..e96aa831 100644 --- a/src/com/powerlink/EplWrapper.cpp +++ b/src/com/powerlink/EplWrapper.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 - 2014 AIT, ACIN, fortiss + * Copyright (c) 2012 - 2024 AIT, ACIN, fortiss * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. @@ -8,6 +8,7 @@ * * Contributors: * Filip Andren, Alois Zoitl, Ewald Weinhandl - initial API and implementation and/or initial documentation + * Michael Gafert - renamed variables to match powerlink library *******************************************************************************/ #include "EplWrapper.h" #include "ProcessImageMatrix.h" @@ -88,13 +89,13 @@ void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p); const DWORD NODEID = 0xF0; //=> MN const DWORD IP_ADDR = 0xc0a86401; // 192.168.100.1 const DWORD SUBNET_MASK = 0xFFFFFF00; // 255.255.255.0 -const char* HOSTNAME = "EPL Stack"; +const char *HOSTNAME = "EPL Stack"; //--------------------------------------------------------------------------- // module global vars //--------------------------------------------------------------------------- -CONST BYTE abMacAddr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +CONST BYTE abMacAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static unsigned int uiNodeId_g = EPL_C_ADR_INVALID; @@ -104,8 +105,6 @@ static bool waitingUntilOperational; #ifdef CONFIG_POWERLINK_USERSTACK -//static char* pszCdcFilename_g = "mnobd.cdc"; - #else static pthread_t eventThreadId; @@ -125,18 +124,18 @@ void *powerlinkSyncThread(void * arg); // this function prototype here. If you want to use more than one Epl // instances then the function name of each object dictionary has to differ. -extern "C" tEplKernel PUBLIC EplObdInitRam (tEplObdInitParam MEM* pInitParam_p); +extern "C" tEplKernel PUBLIC EplObdInitRam(tEplObdInitParam MEM*paInitParam); -tEplKernel PUBLIC AppCbEvent( - tEplApiEventType EventType_p,// IN: event type (enum) - tEplApiEventArg* pEventArg_p,// IN: event argument (union) - void GENERIC* pUserArg_p); +tEplKernel PUBLIC appCbEvent( + tEplApiEventType paEventType, // IN: event type (enum) + tEplApiEventArg *paEventArg, // IN: event argument (union) + void GENERIC*paUserArg); -tEplKernel PUBLIC AppCbSync(void); +tEplKernel PUBLIC appCbSync(); -char* CEplStackWrapper::allocProcImage(unsigned int n_bytes){ - char* procImage = (char*) malloc(n_bytes); - for(unsigned int i = 0; i < n_bytes; i++){ +char *CEplStackWrapper::allocProcImage(unsigned int paNumOfBytes) { + auto procImage = static_cast(malloc(paNumOfBytes)); + for (unsigned int i = 0; i < paNumOfBytes; i++) { procImage[i] = 0x00; } @@ -151,9 +150,9 @@ char* CEplStackWrapper::allocProcImage(unsigned int n_bytes){ DEFINE_SINGLETON(CEplStackWrapper); -void CEplStackWrapper::eplMainInit(){ +void CEplStackWrapper::eplMainInit() { #if (TARGET_SYSTEM == _LINUX_) - sigset_t mask; + sigset_t mask; /* * We have to block the real time signals used by the timer modules so @@ -172,16 +171,16 @@ void CEplStackWrapper::eplMainInit(){ // // //=========================================================================// -CEplStackWrapper::CEplStackWrapper(){ +CEplStackWrapper::CEplStackWrapper() { } -CEplStackWrapper::~CEplStackWrapper(){ +CEplStackWrapper::~CEplStackWrapper() { } -int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEthDeviceName){ - tEplKernel EplRet; - static tEplApiInitParam EplApiInitParam; - const char* sHostname = HOSTNAME; +int CEplStackWrapper::eplStackInit(const char *paXmlFile, const char *paCdcFile, const char *paEthDeviceName) { + tEplKernel ret; + static tEplApiInitParam eplApiInitParam; + const char *hostname = HOSTNAME; // Read and process XML file CEplXmlReader xmlReader(&mProcMatrixIn, &mProcMatrixOut); @@ -190,8 +189,8 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth mProcInSize = mProcMatrixIn.getProcessImageSize(); mProcOutSize = mProcMatrixOut.getProcessImageSize(); - mAppProcessImageIn_g = allocProcImage(mProcInSize); - mAppProcessImageOut_g = allocProcImage(mProcOutSize); + mAppProcessImageIn = allocProcImage(mProcInSize); + mAppProcessImageOut = allocProcImage(mProcOutSize); #ifdef CONFIG_POWERLINK_USERSTACK #if (TARGET_SYSTEM == _LINUX_) @@ -199,7 +198,6 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth #endif // variables for Pcap - char sErr_Msg[PCAP_ERRBUF_SIZE]; pcap_if_t *alldevs; pcap_if_t *seldev; int i = 0; @@ -209,21 +207,21 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth #if (TARGET_SYSTEM == _LINUX_) /* adjust process priority */ - if(nice(-20) == -1) // push nice level in case we have no RTPreempt + if (nice(-20) == -1) // push nice level in case we have no RTPreempt { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) EPL_DBGLVL_ERROR_TRACE("%s() couldn't set nice value! (%s)\n", __func__, strerror(errno)); #else EPL_DBGLVL_ERROR_TRACE2("%s() couldn't set nice value! (%s)\n", __func__, strerror(errno)); #endif - } - schedParam.sched_priority = MAIN_THREAD_PRIORITY; - if(pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0){ -#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) + schedParam.__sched_priority = MAIN_THREAD_PRIORITY; + if (pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0) { +#if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) EPL_DBGLVL_ERROR_TRACE("%s() couldn't set thread scheduling parameters! %d\n", __func__, schedParam.__sched_priority); #else - EPL_DBGLVL_ERROR_TRACE2("%s() couldn't set thread scheduling parameters! %d\n", __func__, schedParam.__sched_priority); + EPL_DBGLVL_ERROR_TRACE2("%s() couldn't set thread scheduling parameters! %d\n", __func__, + schedParam.__sched_priority); #endif } @@ -240,10 +238,10 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth #endif // CONFIG_POWERLINK_USERSTACK /* Enabling ftrace for debugging */ FTRACE_OPEN(); - FTRACE_ENABLE (TRUE); + FTRACE_ENABLE(TRUE); - EPL_MEMSET(&EplApiInitParam, 0, sizeof(EplApiInitParam)); - EplApiInitParam.mSizeOfStruct = sizeof(EplApiInitParam); + EPL_MEMSET(&eplApiInitParam, 0, sizeof(eplApiInitParam)); + eplApiInitParam.m_uiSizeOfStruct = sizeof(eplApiInitParam); #ifdef CONFIG_POWERLINK_USERSTACK @@ -251,62 +249,57 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth // Find ETH card specified by user // //////////////////////////////////////////////////////////////////////////////// - bool macFound; char correctDevName[1024]; - - macFound = findMAC(paEthDeviceName, &correctDevName[0]); + bool macFound = findMAC(paEthDeviceName, &correctDevName[0]); /* Retrieve the device list on the local machine */ - if(pcap_findalldevs(&alldevs, sErr_Msg) == -1){ - fprintf(stderr, "Error in pcap_findalldevs: %s\n", sErr_Msg); - EplRet = kEplNoResource; - return EplRet; + if (char err[PCAP_ERRBUF_SIZE]; pcap_findalldevs(&alldevs, err) == -1) { + DEVLOG_ERROR("[powerlink] Error in pcap_findalldevs: %s\n", err); + ret = kEplNoResource; + return ret; } - printf("\n"); - for(seldev = alldevs, i = 0; seldev != nullptr; seldev = seldev->next, i++){ - if(seldev->description){ - printf("%d: %s\n %s\n", i, seldev->description, seldev->name); - } - else{ - printf("%d: %s\n", i, seldev->name); + for (seldev = alldevs, i = 0; seldev != nullptr; seldev = seldev->next, i++) { + if (seldev->description) { + DEVLOG_INFO("[powerlink] %d: %s\n %s\n", i, seldev->description, seldev->name); + } else { + DEVLOG_INFO("[powerlink] %d: %s\n", i, seldev->name); } - if(macFound){ - const char* userDescLoc = strstr(seldev->name, correctDevName); - if(userDescLoc != nullptr){ - if(seldev->description){ - printf("\nChosen Ethernet Card: %s\n %s\n", seldev->description, seldev->name); - } - else{ - printf("\nChosen Ethernet Card: %s\n", seldev->name); + if (macFound) { + const char *userDescLoc = strstr(seldev->name, correctDevName); + if (userDescLoc != nullptr) { + if (seldev->description) { + DEVLOG_INFO("[powerlink] Chosen Ethernet Card: %s\n %s\n", seldev->description, seldev->name); + } else { + DEVLOG_INFO("[powerlink] Chosen Ethernet Card: %s\n", seldev->name); } break; } } - if(seldev->description){ - const char* userDescLoc = strstr(seldev->description, paEthDeviceName); - if(userDescLoc != nullptr){ - printf("\nChosen Ethernet Card: %s\n", seldev->description); + if (seldev->description) { + const char *userDescLoc = strstr(seldev->description, paEthDeviceName); + if (userDescLoc != nullptr) { + DEVLOG_INFO("[powerlink] Chosen Ethernet Card: %s\n", seldev->description); break; } - } - else{ - const char* userDescLoc = strstr(seldev->name, paEthDeviceName); - if(userDescLoc != nullptr){ - printf("Chosen Ethernet Card: %s\n", seldev->name); + } else { + const char *userDescLoc = strstr(seldev->name, paEthDeviceName); + if (userDescLoc != nullptr) { + DEVLOG_INFO("[powerlink] Chosen Ethernet Card: %s\n", seldev->name); break; } } } // Check if a device was found, otherwise shutdown stack - if(!seldev){ - fprintf(stderr, "%s(Err/Warn): Invalid MAC address or device name specified. Shutting down Powerlink stack\n", __func__); - EplRet = kEplNoResource; - return EplRet; + if (!seldev) { + DEVLOG_ERROR("[powerlink] %s(Err/Warn): Invalid MAC address or device name specified. Shutting down Powerlink stack\n", + __func__); + ret = kEplNoResource; + return ret; } //////////////////////////////////////////////////////////////////////////////// @@ -316,128 +309,132 @@ int CEplStackWrapper::eplStackInit(char* paXmlFile, char* paCdcFile, char* paEth // pass selected device name to Edrv char devName[128]; strncpy(devName, seldev->name, 127); - EplApiInitParam.m_HwParam.mDevName = devName; + eplApiInitParam.m_HwParam.m_pszDevName = devName; #endif - EplApiInitParam.mNodeId = uiNodeId_g = NODEID; - EplApiInitParam.mIpAddress = (0xFFFFFF00 & IP_ADDR) | EplApiInitParam.mNodeId; + eplApiInitParam.m_uiNodeId = uiNodeId_g = NODEID; + eplApiInitParam.m_dwIpAddress = (0xFFFFFF00 & IP_ADDR) | eplApiInitParam.m_uiNodeId; /* write 00:00:00:00:00:00 to MAC address, so that the driver uses the real hardware address */ - EPL_MEMCPY(EplApiInitParam.mMacAddress, abMacAddr, sizeof(EplApiInitParam.mMacAddress)); - - EplApiInitParam.mAsyncOnly = FALSE; - - EplApiInitParam.mFeatureFlags = -1; - EplApiInitParam.mCycleLen = 10000; // required for error detection - EplApiInitParam.mIsochrTxMaxPayload = 256; // const - EplApiInitParam.mIsochrRxMaxPayload = 256; // const - EplApiInitParam.mPresMaxLatency = 50000; // const; only required for IdentRes - EplApiInitParam.mPreqActPayloadLimit = 36; // required for initialisation (+28 bytes) - EplApiInitParam.mPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes) - EplApiInitParam.mAsndMaxLatency = 150000; // const; only required for IdentRes - EplApiInitParam.mMultiplCycleCnt = 0; // required for error detection - EplApiInitParam.mAsyncMtu = 1500; // required to set up max frame size - EplApiInitParam.mPrescaler = 2; // required for sync - EplApiInitParam.mLossOfFrameTolerance = 500000; - EplApiInitParam.mAsyncSlotTimeout = 3000000; - EplApiInitParam.mWaitSocPreq = 150000; - EplApiInitParam.mDeviceType = -1; // NMT_DeviceType_U32 - EplApiInitParam.mVendorId = -1; // NMT_IdentityObject_REC.VendorId_U32 - EplApiInitParam.mProductCode = -1; // NMT_IdentityObject_REC.ProductCode_U32 - EplApiInitParam.mRevisionNumber = -1; // NMT_IdentityObject_REC.RevisionNo_U32 - EplApiInitParam.mSerialNumber = -1; // NMT_IdentityObject_REC.SerialNo_U32 - - EplApiInitParam.mSubnetMask = SUBNET_MASK; - EplApiInitParam.mDefaultGateway = 0; - EPL_MEMCPY(EplApiInitParam.mHostname, sHostname, sizeof(EplApiInitParam.mHostname)); - EplApiInitParam.mSyncNodeId = EPL_C_ADR_SYNC_ON_SOA; - EplApiInitParam.mSyncOnPrcNode = FALSE; + EPL_MEMCPY(eplApiInitParam.m_abMacAddress, abMacAddr, sizeof(eplApiInitParam.m_abMacAddress)); + + eplApiInitParam.m_fAsyncOnly = FALSE; + + eplApiInitParam.m_dwFeatureFlags = -1; + eplApiInitParam.m_dwCycleLen = 10000; // required for error detection + eplApiInitParam.m_uiIsochrTxMaxPayload = 256; // const + eplApiInitParam.m_uiIsochrRxMaxPayload = 256; // const + eplApiInitParam.m_dwPresMaxLatency = 50000; // const; only required for IdentRes + eplApiInitParam.m_uiPreqActPayloadLimit = 36; // required for initialisation (+28 bytes) + eplApiInitParam.m_uiPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes) + eplApiInitParam.m_dwAsndMaxLatency = 150000; // const; only required for IdentRes + eplApiInitParam.m_uiMultiplCycleCnt = 0; // required for error detection + eplApiInitParam.m_uiAsyncMtu = 1500; // required to set up max frame size + eplApiInitParam.m_uiPrescaler = 2; // required for sync + eplApiInitParam.m_dwLossOfFrameTolerance = 500000; + eplApiInitParam.m_dwAsyncSlotTimeout = 3000000; + eplApiInitParam.m_dwWaitSocPreq = 150000; + eplApiInitParam.m_dwDeviceType = -1; // NMT_DeviceType_U32 + eplApiInitParam.m_dwVendorId = -1; // NMT_IdentityObject_REC.VendorId_U32 + eplApiInitParam.m_dwProductCode = -1; // NMT_IdentityObject_REC.ProductCode_U32 + eplApiInitParam.m_dwRevisionNumber = -1; // NMT_IdentityObject_REC.RevisionNo_U32 + eplApiInitParam.m_dwSerialNumber = -1; // NMT_IdentityObject_REC.SerialNo_U32 + + eplApiInitParam.m_dwSubnetMask = SUBNET_MASK; + eplApiInitParam.m_dwDefaultGateway = 0; + EPL_MEMCPY(eplApiInitParam.m_sHostname, hostname, sizeof(eplApiInitParam.m_sHostname)); + eplApiInitParam.m_uiSyncNodeId = EPL_C_ADR_SYNC_ON_SOA; + eplApiInitParam.m_fSyncOnPrcNode = FALSE; // set callback functions - EplApiInitParam.mCbEvent = AppCbEvent; + eplApiInitParam.m_pfnCbEvent = appCbEvent; #ifdef CONFIG_POWERLINK_USERSTACK - EplApiInitParam.mObdInitRam = EplObdInitRam; - EplApiInitParam.mCbSync = AppCbSync; + eplApiInitParam.m_pfnObdInitRam = EplObdInitRam; + eplApiInitParam.m_pfnCbSync = appCbSync; #else - EplApiInitParam.mCbSync = nullptr; + EplApiInitParam.m_pfnCbSync = nullptr; #endif //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Initialize Powerlink Stack // //////////////////////////////////////////////////////////////////////////////// - printf("\n\n Powerlink %s running.\n (build: %s / %s)\n\n", (NODEID == EPL_C_ADR_MN_DEF_NODE_ID ? "Managing Node" : "Controlled Node"), __DATE__, __TIME__); + DEVLOG_INFO("[powerlink] Powerlink %s running. (build: %s / %s) \n", + (NODEID == EPL_C_ADR_MN_DEF_NODE_ID ? "Managing Node" : "Controlled Node"), __DATE__, __TIME__); // initialize POWERLINK stack - EplRet = EplApiInitialize(&EplApiInitParam); - if(EplRet != kEplSuccessful){ - return EplRet; + ret = EplApiInitialize(&eplApiInitParam); + if (ret != kEplSuccessful) { + DEVLOG_ERROR("[powerlink] Could not initialize POWERLINK stack at EplApiInitialize\n"); + return ret; } #ifdef CONFIG_POWERLINK_USERSTACK /* At this point, we don't need any more the device list. Free it */ pcap_freealldevs(alldevs); - EplRet = EplApiSetCdcFilename(paCdcFile); - if(EplRet != kEplSuccessful){ - return EplRet; + ret = EplApiSetCdcFilename(const_cast(paCdcFile)); + if (ret != kEplSuccessful) { + DEVLOG_ERROR("[powerlink] Could not set CDC filename at EplApiSetCdcFilename\n", paCdcFile); + return ret; } #else // create event thread if(pthread_create(&eventThreadId, nullptr, &powerlinkEventThread, nullptr) != 0){ - return EplRet; + return ret; } // create sync thread if(pthread_create(&syncThreadId, nullptr, &powerlinkSyncThread, nullptr) != 0){ - return EplRet; + return ret; } #endif - AppProcessImageCopyJob_g.mNonBlocking = FALSE; - AppProcessImageCopyJob_g.mPriority = 0; - AppProcessImageCopyJob_g.m_In.mPart = mAppProcessImageIn_g; - AppProcessImageCopyJob_g.m_In.mOffset = 0; - AppProcessImageCopyJob_g.m_In.mSize = mProcInSize; - AppProcessImageCopyJob_g.m_Out.mPart = mAppProcessImageOut_g; - AppProcessImageCopyJob_g.m_Out.mOffset = 0; - AppProcessImageCopyJob_g.m_Out.mSize = mProcOutSize; - - EplRet = EplApiProcessImageAlloc(mProcInSize, mProcOutSize, 2, 2); - if(EplRet != kEplSuccessful){ + AppProcessImageCopyJob_g.m_fNonBlocking = FALSE; + AppProcessImageCopyJob_g.m_uiPriority = 0; + AppProcessImageCopyJob_g.m_In.m_pPart = mAppProcessImageIn; + AppProcessImageCopyJob_g.m_In.m_uiOffset = 0; + AppProcessImageCopyJob_g.m_In.m_uiSize = mProcInSize; + AppProcessImageCopyJob_g.m_Out.m_pPart = mAppProcessImageOut; + AppProcessImageCopyJob_g.m_Out.m_uiOffset = 0; + AppProcessImageCopyJob_g.m_Out.m_uiSize = mProcOutSize; + + ret = EplApiProcessImageAlloc(mProcInSize, mProcOutSize, 2, 2); + if (ret != kEplSuccessful) { + DEVLOG_ERROR("[powerlink] Could not allocate process image at EplApiProcessImageAlloc\n"); eplStackShutdown(); } - EplRet = EplApiProcessImageSetup(); - if(EplRet != kEplSuccessful){ + ret = EplApiProcessImageSetup(); + if (ret != kEplSuccessful) { + DEVLOG_ERROR("[powerlink] Could not setup process image at EplApiProcessImageSetup\n"); eplStackShutdown(); } // start processing - EplRet = EplApiExecNmtCommand(kEplNmtEventSwReset); - if(EplRet != kEplSuccessful){ + ret = EplApiExecNmtCommand(kEplNmtEventSwReset); + if (ret != kEplSuccessful) { + DEVLOG_ERROR("[powerlink] Could not start processing at EplApiExecNmtCommand\n"); eplStackShutdown(); } waitingUntilOperational = false; - if(mWait == true){ - while(!waitingUntilOperational){ + if (mInitWait == true) { + while (!waitingUntilOperational) { // Waiting CThread::sleepThread(1); } } - return EplRet; + return ret; } //////////////////////////////////////////////////////////////////////////////// // Stop the stack // //////////////////////////////////////////////////////////////////////////////// -int CEplStackWrapper::eplStackShutdown(){ - tEplKernel EplRet; - +int CEplStackWrapper::eplStackShutdown() { // halt the NMT state machine // so the processing of POWERLINK frames stops EplApiExecNmtCommand(kEplNmtEventSwitchOff); @@ -446,59 +443,53 @@ int CEplStackWrapper::eplStackShutdown(){ EplApiProcessImageFree(); // delete instance for all modules - EplRet = EplApiShutdown(); - printf("EplApiShutdown(): 0x%X\n", EplRet); + tEplKernel eplRet = EplApiShutdown(); + DEVLOG_INFO("EplApiShutdown(): 0x%X\n", eplRet); mProcMatrixIn.clearAll(); mProcMatrixOut.clearAll(); mCallbackList.clearAll(); - free(mAppProcessImageIn_g); - free(mAppProcessImageOut_g); + free(mAppProcessImageIn); + free(mAppProcessImageOut); - return EplRet; + return eplRet; } -CProcessImageMatrix* CEplStackWrapper::getProcessImageMatrixIn(){ +CProcessImageMatrix *CEplStackWrapper::getProcessImageMatrixIn() { return &mProcMatrixIn; } -CProcessImageMatrix* CEplStackWrapper::getProcessImageMatrixOut(){ +CProcessImageMatrix *CEplStackWrapper::getProcessImageMatrixOut() { return &mProcMatrixOut; } -char* CEplStackWrapper::getProcImageIn(){ - return mAppProcessImageIn_g; +char *CEplStackWrapper::getProcImageIn() { + return mAppProcessImageIn; } -char* CEplStackWrapper::getProcImageOut(){ - return mAppProcessImageOut_g; +char *CEplStackWrapper::getProcImageOut() { + return mAppProcessImageOut; } -void CEplStackWrapper::waitUntilOperational(bool paWait){ - mWait = paWait; +void CEplStackWrapper::waitUntilOperational(bool paWait) { + mInitWait = paWait; } -void CEplStackWrapper::registerCallback(IEplCNCallback* paCallback){ +void CEplStackWrapper::registerCallback(IEplCNCallback *paCallback) { mSync.lock(); mCallbackList.pushBack(paCallback); mSync.unlock(); } -bool CEplStackWrapper::findMAC(const char* paUserMAC, char* paDeviceName){ +bool CEplStackWrapper::findMAC(const char *paUserMAC, char *paDeviceName) { //char* correctDevName; #if (TARGET_SYSTEM == _LINUX_) + int socketDescriptor; + struct ifreq ifReq; // Interface request + struct if_nameindex *ifList; // Ptr to interface name index + struct if_nameindex *listSave; // Ptr to interface name index - int nSD; // Socket descriptor - struct ifreq sIfReq; // Interface request - struct if_nameindex *pIfList; // Ptr to interface name index - struct if_nameindex *pListSave; // Ptr to interface name index - - // - // Initialize this function - // - pIfList = nullptr; - pListSave = nullptr; #ifndef SIOCGIFADDR // The kernel does not support the required ioctls return (false); @@ -507,32 +498,31 @@ bool CEplStackWrapper::findMAC(const char* paUserMAC, char* paDeviceName){ // // Create a socket that we can use for all of our ioctls // - nSD = socket(PF_INET, SOCK_STREAM, 0); - if(nSD < 0){ + socketDescriptor = socket(PF_INET, SOCK_STREAM, 0); + if (socketDescriptor < 0) { // Socket creation failed, this is a fatal error - printf("File %s: line %d: Socket failed\n", __FILE__, __LINE__); + DEVLOG_ERROR("File %s: line %d: Socket failed\n", __FILE__, __LINE__); return (0); } // // Obtain a list of dynamically allocated structures // - pIfList = pListSave = if_nameindex(); + ifList = listSave = if_nameindex(); // // Walk thru the array returned and query for each interface's // address // - for(; *(char *) pIfList != 0; pIfList++){ - - strncpy(sIfReq.ifr_name, pIfList->if_name, IF_NAMESIZE); + for (ifList; *(char *) ifList != 0; ifList++) { + strncpy(ifReq.ifr_name, ifList->if_name, IF_NAMESIZE); // // Get the MAC address for this interface // - if(ioctl(nSD, SIOCGIFHWADDR, &sIfReq) != 0){ + if (ioctl(socketDescriptor, SIOCGIFHWADDR, &ifReq) != 0) { // We failed to get the MAC address for the interface - printf("File %s: line %d: Ioctl failed\n", __FILE__, __LINE__); + DEVLOG_ERROR("File %s: line %d: Ioctl failed\n", __FILE__, __LINE__); return false; } @@ -541,16 +531,19 @@ bool CEplStackWrapper::findMAC(const char* paUserMAC, char* paDeviceName){ // are interested in // char chMAC[6 * 2 + 5 + 2]; - sprintf(chMAC, "%02X-%02X-%02X-%02X-%02X-%02X", (unsigned char) sIfReq.ifr_hwaddr.sa_data[0], (unsigned char) sIfReq.ifr_hwaddr.sa_data[1], (unsigned char) sIfReq.ifr_hwaddr.sa_data[2], (unsigned char) sIfReq.ifr_hwaddr.sa_data[3], (unsigned char) sIfReq.ifr_hwaddr.sa_data[4], (unsigned char) sIfReq.ifr_hwaddr.sa_data[5]); + sprintf(chMAC, "%02X-%02X-%02X-%02X-%02X-%02X", (unsigned char) ifReq.ifr_hwaddr.sa_data[0], + (unsigned char) ifReq.ifr_hwaddr.sa_data[1], (unsigned char) ifReq.ifr_hwaddr.sa_data[2], + (unsigned char) ifReq.ifr_hwaddr.sa_data[3], (unsigned char) ifReq.ifr_hwaddr.sa_data[4], + (unsigned char) ifReq.ifr_hwaddr.sa_data[5]); - if(compareMACs(chMAC, paUserMAC)){ - strncpy(paDeviceName, pIfList->if_name, IF_NAMESIZE); + if (compareMACs(chMAC, paUserMAC)) { + strncpy(paDeviceName, ifList->if_name, IF_NAMESIZE); // // Clean up things and return // - if_freenameindex(pListSave); - close(nSD); + if_freenameindex(listSave); + close(socketDescriptor); return true; } @@ -559,8 +552,8 @@ bool CEplStackWrapper::findMAC(const char* paUserMAC, char* paDeviceName){ // // Clean up things and return // - if_freenameindex(pListSave); - close(nSD); + if_freenameindex(listSave); + close(socketDescriptor); #elif (TARGET_SYSTEM == _WIN32_) @@ -574,50 +567,50 @@ bool CEplStackWrapper::findMAC(const char* paUserMAC, char* paDeviceName){ PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo;// Contains pointer to current adapter info do{ - char* chMAC = new char[6*2+5+1]; - BYTE *macAddr = pAdapterInfo->Address; - for (int i = 0; i < 6*2+5; i = i+2) - { - if (i>0){ - chMAC[i] = '-'; - i++; - } - sprintf(&chMAC[i],"%02x",*macAddr++); + char* chMAC = new char[6*2+5+1]; + BYTE *macAddr = pAdapterInfo->Address; + for (int i = 0; i < 6*2+5; i = i+2) + { + if (i>0){ + chMAC[i] = '-'; + i++; } + sprintf(&chMAC[i],"%02x",*macAddr++); + } - if (compareMACs(chMAC, paUserMAC)){ - //correctDevName = new char[strlen(pAdapterInfo->AdapterName)+1]; - strcpy(paDeviceName,pAdapterInfo->AdapterName); - delete chMAC; + if (compareMACs(chMAC, paUserMAC)){ + //correctDevName = new char[strlen(pAdapterInfo->AdapterName)+1]; + strcpy(paDeviceName,pAdapterInfo->AdapterName); + delete chMAC; - //paDeviceName = correctDevName; - return true; - } + //deviceName = correctDevName; + return true; + } - pAdapterInfo = pAdapterInfo->Next; // Progress through linked list - delete chMAC; + pAdapterInfo = pAdapterInfo->Next; // Progress through linked list + delete chMAC; } while(pAdapterInfo); // Terminate if last adapter #endif - //paDeviceName = nullptr; //No effect + //deviceName = nullptr; //No effect return false; } -bool CEplStackWrapper::compareMACs(const char* paMACa, const char* paMACb){ - if(strcmp(paMACa, paMACb) == 0){ +bool CEplStackWrapper::compareMACs(const char *paMacA, const char *paMacB) { + if (strcmp(paMacA, paMacB) == 0) { return true; } - char* macCopyA = new char[strlen(paMACa) + 1]; - strcpy(macCopyA, paMACa); - char* macCopyB = new char[strlen(paMACb) + 1]; - strcpy(macCopyB, paMACb); + auto *macCopyA = new char[strlen(paMacA) + 1]; + strcpy(macCopyA, paMacA); + auto *macCopyB = new char[strlen(paMacB) + 1]; + strcpy(macCopyB, paMacB); // Change to upper case - for(unsigned i = 0; i < strlen(paMACa); i++){ - switch (macCopyA[i]){ + for (int i = 0; i < strlen(paMacA); i++) { + switch (macCopyA[i]) { case 'a': macCopyA[i] = 'A'; break; @@ -638,8 +631,8 @@ bool CEplStackWrapper::compareMACs(const char* paMACa, const char* paMACb){ break; } } - for(unsigned i = 0; i < strlen(paMACb); i++){ - switch (macCopyB[i]){ + for (int i = 0; i < strlen(paMacB); i++) { + switch (macCopyB[i]) { case 'a': macCopyB[i] = 'A'; break; @@ -661,7 +654,7 @@ bool CEplStackWrapper::compareMACs(const char* paMACa, const char* paMACb){ } } - if(strcmp(macCopyA, macCopyB) == 0){ + if (strcmp(macCopyA, macCopyB) == 0) { delete[] macCopyA; delete[] macCopyB; return true; @@ -680,15 +673,15 @@ bool CEplStackWrapper::compareMACs(const char* paMACa, const char* paMACb){ //--------------------------------------------------------------------------- // -// Function: AppCbEvent +// Function: appCbEvent // // Description: event callback function called by EPL API layer within // user part (low priority). // -// Parameters: EventType_p = event type -// pEventArg_p = pointer to union, which describes +// Parameters: eventType = event type +// eventArg = pointer to union, which describes // the event in detail -// pUserArg_p = user specific argument +// userArg = user specific argument // // Returns: tEplKernel = error code, // kEplSuccessful = no error @@ -699,57 +692,51 @@ bool CEplStackWrapper::compareMACs(const char* paMACa, const char* paMACb){ // //--------------------------------------------------------------------------- -tEplKernel PUBLIC AppCbEvent( - tEplApiEventType EventType_p,// IN: event type (enum) - tEplApiEventArg* pEventArg_p,// IN: event argument (union) - void GENERIC* pUserArg_p) -{ - tEplKernel EplRet = kEplSuccessful; +tEplKernel PUBLIC appCbEvent( + tEplApiEventType paEventType, // IN: event type (enum) + tEplApiEventArg *paEventArg, // IN: event argument (union) + void GENERIC* paUserArg) { + tEplKernel ret = kEplSuccessful; - UNUSED_PARAMETER(pUserArg_p); + UNUSED_PARAMETER(userArg); // check if NMT_GS_OFF is reached - switch (EventType_p) - { - case kEplApiEventNmtStateChange: - { - switch (pEventArg_p->m_NmtStateChange.m_NewNmtState) - { - case kEplNmtGsOff: - { // NMT state machine was shut down, + switch (paEventType) { + case kEplApiEventNmtStateChange: { + switch (paEventArg->m_NmtStateChange.m_NewNmtState) { + case kEplNmtGsOff: { + // NMT state machine was shut down, // because of user signal (CTRL-C) or critical EPL stack error // -> also shut down EplApiProcess() and main() - EplRet = kEplShutdown; + ret = kEplShutdown; #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent); + DEVLOG_DEBUG("[powerlink] %s(kEplNmtGsOff) originating event = 0x%X\n", __func__, eventArg->m_NmtStateChange.m_NmtEvent); #else - PRINTF2("%s(kEplNmtGsOff) originating event = 0x%X\n", __func__, pEventArg_p->m_NmtStateChange.m_NmtEvent); + DEVLOG_DEBUG("[powerlink] %s(kEplNmtGsOff) originating event = 0x%X\n", __func__, + paEventArg->m_NmtStateChange.m_NmtEvent); #endif break; } - case kEplNmtGsResetCommunication: - { + case kEplNmtGsResetCommunication: { // continue } - case kEplNmtGsResetConfiguration: - { + case kEplNmtGsResetConfiguration: { // continue } - case kEplNmtMsPreOperational1: - { + case kEplNmtMsPreOperational1: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(0x%X) originating event = 0x%X\n", - __func__, - pEventArg_p->m_NmtStateChange.m_NewNmtState, - pEventArg_p->m_NmtStateChange.m_NmtEvent); + DEVLOG_DEBUG("[powerlink] %s(0x%X) originating event = 0x%X\n", + __func__, + eventArg->m_NmtStateChange.m_NewNmtState, + eventArg->m_NmtStateChange.m_NmtEvent); #else - PRINTF3("%s(0x%X) originating event = 0x%X\n", + DEVLOG_DEBUG("[powerlink] %s(0x%X) originating event = 0x%X\n", __func__, - pEventArg_p->m_NmtStateChange.m_NewNmtState, - pEventArg_p->m_NmtStateChange.m_NmtEvent); + paEventArg->m_NmtStateChange.m_NewNmtState, + paEventArg->m_NmtStateChange.m_NmtEvent); #endif // continue @@ -759,17 +746,14 @@ tEplKernel PUBLIC AppCbEvent( case kEplNmtGsResetApplication: case kEplNmtMsNotActive: case kEplNmtCsNotActive: - case kEplNmtCsPreOperational1: - { + case kEplNmtCsPreOperational1: { break; } case kEplNmtCsOperational: - case kEplNmtMsOperational: - { + case kEplNmtMsOperational: { break; } - default: - { + default: { break; } } @@ -778,64 +762,63 @@ tEplKernel PUBLIC AppCbEvent( } case kEplApiEventCriticalError: - case kEplApiEventWarning: - { // error or warning occured within the stack or the application + case kEplApiEventWarning: { + // error or warning occured within the stack or the application // on error the API layer stops the NMT state machine #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Err/Warn): Source=%02X EplError=0x%03X", - __func__, - pEventArg_p->m_InternalError.m_EventSource, - pEventArg_p->m_InternalError.m_EplError); + DEVLOG_DEBUG("[powerlink] %s(Err/Warn): Source=%02X EplError=0x%03X\n", + __func__, + eventArg->m_InternalError.m_EventSource, + eventArg->m_InternalError.m_EplError); #else - PRINTF3("%s(Err/Warn): Source=%02X EplError=0x%03X", + DEVLOG_DEBUG("[powerlink] %s(Err/Warn): Source=%02X EplError=0x%03X", __func__, - pEventArg_p->m_InternalError.m_EventSource, - pEventArg_p->m_InternalError.m_EplError); + paEventArg->m_InternalError.m_EventSource, + paEventArg->m_InternalError.m_EplError); #endif // check additional argument - switch (pEventArg_p->m_InternalError.m_EventSource) - { + switch (paEventArg->m_InternalError.m_EventSource) { case kEplEventSourceEventk: - case kEplEventSourceEventu: - { // error occured within event processing + case kEplEventSourceEventu: { + // error occured within event processing // either in kernel or in user part #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource); + DEVLOG_DEBUG(" OrgSource=%02X\n", eventArg->m_InternalError.m_Arg.m_EventSource); #else - PRINTF1(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource); + DEVLOG_DEBUG(" OrgSource=%02X\n", paEventArg->m_InternalError.m_Arg.m_EventSource); #endif break; } - case kEplEventSourceDllk: - { // error occured within the data link layer (e.g. interrupt processing) + case kEplEventSourceDllk: { + // error occured within the data link layer (e.g. interrupt processing) // the DWORD argument contains the DLL state and the NMT event #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.mArg); + DEVLOG_DEBUG(" val=%lX\n", eventArg->m_InternalError.m_Arg.m_dwArg); #else - PRINTF1(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.mArg); + DEVLOG_DEBUG(" val=%lX\n", paEventArg->m_InternalError.m_Arg.m_dwArg); #endif break; } case kEplEventSourceObdk: - case kEplEventSourceObdu: - { // error occured within OBD module + case kEplEventSourceObdu: { + // error occured within OBD module // either in kernel or in user part #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF(" Object=0x%04X/%u\n", pEventArg_p->m_InternalError.m_Arg.m_ObdError.mIndex, pEventArg_p->m_InternalError.m_Arg.m_ObdError.mSubIndex); + DEVLOG_DEBUG(" Object=0x%04X/%u\n", eventArg->m_InternalError.m_Arg.m_ObdError.m_uiIndex, eventArg->m_InternalError.m_Arg.m_ObdError.m_uiSubIndex); #else - PRINTF2(" Object=0x%04X/%u\n", pEventArg_p->m_InternalError.m_Arg.m_ObdError.mIndex, pEventArg_p->m_InternalError.m_Arg.m_ObdError.mSubIndex); + DEVLOG_DEBUG(" Object=0x%04X/%u\n", paEventArg->m_InternalError.m_Arg.m_ObdError.m_uiIndex, + paEventArg->m_InternalError.m_Arg.m_ObdError.m_uiSubIndex); #endif break; } - default: - { + default: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("\n"); + DEVLOG_DEBUG("\n"); #else - PRINTF0("\n"); + DEVLOG_DEBUG("\n"); #endif break; } @@ -843,84 +826,78 @@ tEplKernel PUBLIC AppCbEvent( break; } - case kEplApiEventHistoryEntry: - { // new history entry - PRINTF("%s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n", - __func__, - pEventArg_p->m_ErrHistoryEntry.mEntryType, - pEventArg_p->m_ErrHistoryEntry.mErrorCode, - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[0], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[1], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[2], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[3], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[4], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[5], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[6], - (WORD) pEventArg_p->m_ErrHistoryEntry.mAddInfo[7]); + case kEplApiEventHistoryEntry: { + // new history entry + DEVLOG_DEBUG("[powerlink] %s(HistoryEntry): Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)\n", + __func__, + paEventArg->m_ErrHistoryEntry.m_wEntryType, + paEventArg->m_ErrHistoryEntry.m_wErrorCode, + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[0], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[1], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[2], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[3], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[4], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[5], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[6], + (WORD) paEventArg->m_ErrHistoryEntry.m_abAddInfo[7]); break; } - case kEplApiEventNode: - { + case kEplApiEventNode: { // check additional argument - switch (pEventArg_p->m_Node.m_NodeEvent) - { - case kEplNmtNodeEventCheckConf: - { + switch (paEventArg->m_Node.m_NodeEvent) { + case kEplNmtNodeEventCheckConf: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, CheckConf)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CheckConf)\n", __func__, eventArg->m_Node.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, CheckConf)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CheckConf)\n", __func__, paEventArg->m_Node.m_uiNodeId); #endif break; } - case kEplNmtNodeEventUpdateConf: - { + case kEplNmtNodeEventUpdateConf: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, UpdateConf)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, UpdateConf)\n", __func__, eventArg->m_Node.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, UpdateConf)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, UpdateConf)\n", __func__, paEventArg->m_Node.m_uiNodeId); #endif break; } - case kEplNmtNodeEventNmtState: - { + case kEplNmtNodeEventNmtState: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, NmtState=0x%X)\n", __func__, pEventArg_p->m_Node.mNodeId, pEventArg_p->m_Node.m_NmtState); + DEVLOG_DEBUG("%s(Node=0x%X, NmtState=0x%X)\n", __func__, eventArg->m_Node.m_uiNodeId, eventArg->m_Node.m_NmtState); #else - PRINTF3("%s(Node=0x%X, NmtState=0x%X)\n", __func__, pEventArg_p->m_Node.mNodeId, pEventArg_p->m_Node.m_NmtState); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, NmtState=0x%X)\n", __func__, paEventArg->m_Node.m_uiNodeId, + paEventArg->m_Node.m_NmtState); #endif - if (pEventArg_p->m_Node.m_NmtState == kEplNmtCsOperational){ - printf("init finished\n"); + if (paEventArg->m_Node.m_NmtState == kEplNmtCsOperational) { + DEVLOG_INFO("[powerlink] Init finished\n"); waitingUntilOperational = true; } break; } - case kEplNmtNodeEventError: - { + case kEplNmtNodeEventError: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, Error=0x%X)\n", __func__, pEventArg_p->m_Node.mNodeId, pEventArg_p->m_Node.mErrorCode); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, Error=0x%X)\n", __func__, eventArg->m_Node.m_uiNodeId, eventArg->m_Node.m_wErrorCode); #else - PRINTF3("%s(Node=0x%X, Error=0x%X)\n", __func__, pEventArg_p->m_Node.mNodeId, pEventArg_p->m_Node.mErrorCode); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, Error=0x%X)\n", __func__, paEventArg->m_Node.m_uiNodeId, + paEventArg->m_Node.m_wErrorCode); #endif break; } - case kEplNmtNodeEventFound: - { + case kEplNmtNodeEventFound: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, Found)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, Found)\n", __func__, eventArg->m_Node.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, Found)\n", __func__, pEventArg_p->m_Node.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, Found)\n", __func__, paEventArg->m_Node.m_uiNodeId); #endif break; } - default: - { + default: { break; } } @@ -928,85 +905,78 @@ tEplKernel PUBLIC AppCbEvent( } #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFM)) != 0) - case kEplApiEventCfmProgress: - { + case kEplApiEventCfmProgress: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, pEventArg_p->m_CfmProgress.mNodeId, pEventArg_p->m_CfmProgress.mObjectIndex, pEventArg_p->m_CfmProgress.mObjectSubIndex); - PRINTF("%u/%u Bytes", pEventArg_p->m_CfmProgress.mBytesDownloaded, pEventArg_p->m_CfmProgress.mTotalNumberOfBytes); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, eventArg->m_CfmProgress.m_uiNodeId, eventArg->m_CfmProgress.m_uiObjectIndex, eventArg->m_CfmProgress.m_uiObjectSubIndex); + DEVLOG_DEBUG("%u/%u Bytes", eventArg->m_CfmProgress.m_dwBytesDownloaded, eventArg->m_CfmProgress.m_dwTotalNumberOfBytes); #else - PRINTF4("%s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, pEventArg_p->m_CfmProgress.mNodeId, pEventArg_p->m_CfmProgress.mObjectIndex, pEventArg_p->m_CfmProgress.mObjectSubIndex); - PRINTF2("%u/%u Bytes", pEventArg_p->m_CfmProgress.mBytesDownloaded, pEventArg_p->m_CfmProgress.mTotalNumberOfBytes); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CFM-Progress: Object 0x%X/%u, ", __func__, paEventArg->m_CfmProgress.m_uiNodeId, + paEventArg->m_CfmProgress.m_uiObjectIndex, paEventArg->m_CfmProgress.m_uiObjectSubIndex); + DEVLOG_DEBUG("%u/%u Bytes", paEventArg->m_CfmProgress.m_dwBytesDownloaded, + paEventArg->m_CfmProgress.m_dwTotalNumberOfBytes); #endif - if ((pEventArg_p->m_CfmProgress.mSdoAbortCode != 0) - || (pEventArg_p->m_CfmProgress.m_EplError != kEplSuccessful)) - { + if ((paEventArg->m_CfmProgress.m_dwSdoAbortCode != 0) + || (paEventArg->m_CfmProgress.m_EplError != kEplSuccessful)) { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF(" -> SDO Abort=0x%lX, Error=0x%X)\n", pEventArg_p->m_CfmProgress.mSdoAbortCode, pEventArg_p->m_CfmProgress.m_EplError); + DEVLOG_DEBUG(" -> SDO Abort=0x%lX, Error=0x%X)\n", eventArg->m_CfmProgress.m_dwSdoAbortCode, eventArg->m_CfmProgress.m_EplError); #else - PRINTF2(" -> SDO Abort=0x%lX, Error=0x%X)\n", pEventArg_p->m_CfmProgress.mSdoAbortCode, pEventArg_p->m_CfmProgress.m_EplError); + DEVLOG_DEBUG(" -> SDO Abort=0x%lX, Error=0x%X)\n", paEventArg->m_CfmProgress.m_dwSdoAbortCode, + paEventArg->m_CfmProgress.m_EplError); #endif - } - else - { + } else { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF(")\n"); + DEVLOG_DEBUG(")\n"); #else - PRINTF0(")\n"); + DEVLOG_DEBUG(")\n"); #endif } break; } - case kEplApiEventCfmResult: - { - switch (pEventArg_p->m_CfmResult.m_NodeCommand) - { - case kEplNmtNodeCommandConfOk: - { + case kEplApiEventCfmResult: { + switch (paEventArg->m_CfmResult.m_NodeCommand) { + case kEplNmtNodeCommandConfOk: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, ConfOk)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfOk)\n", __func__, eventArg->m_CfmResult.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, ConfOk)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfOk)\n", __func__, paEventArg->m_CfmResult.m_uiNodeId); #endif break; } - case kEplNmtNodeCommandConfErr: - { + case kEplNmtNodeCommandConfErr: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, ConfErr)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfErr)\n", __func__, eventArg->m_CfmResult.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, ConfErr)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfErr)\n", __func__, paEventArg->m_CfmResult.m_uiNodeId); #endif break; } - case kEplNmtNodeCommandConfReset: - { + case kEplNmtNodeCommandConfReset: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, ConfReset)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfReset)\n", __func__, eventArg->m_CfmResult.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, ConfReset)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfReset)\n", __func__, paEventArg->m_CfmResult.m_uiNodeId); #endif break; } - case kEplNmtNodeCommandConfRestored: - { + case kEplNmtNodeCommandConfRestored: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, ConfRestored)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfRestored)\n", __func__, eventArg->m_CfmResult.m_uiNodeId); #else - PRINTF2("%s(Node=0x%X, ConfRestored)\n", __func__, pEventArg_p->m_CfmResult.mNodeId); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, ConfRestored)\n", __func__, paEventArg->m_CfmResult.m_uiNodeId); #endif break; } - default: - { + default: { #if EPL_DEFINED_STACK_VERSION >= EPL_STACK_VERSION(1, 8, 2) - PRINTF("%s(Node=0x%X, CfmResult=0x%X)\n", __func__, pEventArg_p->m_CfmResult.mNodeId, pEventArg_p->m_CfmResult.m_NodeCommand); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CfmResult=0x%X)\n", __func__, eventArg->m_CfmResult.m_uiNodeId, pEventArg_p->m_CfmResult.m_NodeCommand); #else - PRINTF3("%s(Node=0x%X, CfmResult=0x%X)\n", __func__, pEventArg_p->m_CfmResult.mNodeId, pEventArg_p->m_CfmResult.m_NodeCommand); + DEVLOG_DEBUG("[powerlink] %s(Node=0x%X, CfmResult=0x%X)\n", __func__, paEventArg->m_CfmResult.m_uiNodeId, + paEventArg->m_CfmResult.m_NodeCommand); #endif break; } @@ -1016,10 +986,10 @@ tEplKernel PUBLIC AppCbEvent( #endif default: - break; + break; } - return EplRet; + return ret; } //--------------------------------------------------------------------------- @@ -1041,21 +1011,19 @@ tEplKernel PUBLIC AppCbEvent( // //--------------------------------------------------------------------------- -tEplKernel PUBLIC AppCbSync(){ - tEplKernel EplRet = kEplSuccessful; - - EplRet = EplApiProcessImageExchange(&AppProcessImageCopyJob_g); +tEplKernel PUBLIC appCbSync() { + tEplKernel ret = EplApiProcessImageExchange(&AppProcessImageCopyJob_g); // Loop through callback list and call each FB in the list CEplStackWrapper::getInstance().executeAllCallbacks(); - return EplRet; + return ret; } -void CEplStackWrapper::executeAllCallbacks(){ +void CEplStackWrapper::executeAllCallbacks() { mSync.lock(); - CSinglyLinkedList::Iterator itEnd = mCallbackList.end(); - for(CSinglyLinkedList::Iterator it = mCallbackList.begin(); it != itEnd; ++it){ + CSinglyLinkedList::Iterator itEnd = mCallbackList.end(); + for (CSinglyLinkedList::Iterator it = mCallbackList.begin(); it != itEnd; ++it) { it->cnSynchCallback(); } mSync.unlock(); @@ -1071,7 +1039,7 @@ void *powerlinkEventThread(void * arg __attribute__((unused))){ void *powerlinkSyncThread(void * arg __attribute__((unused))){ while(1){ - AppCbSync(); + AppCbSync(); } return nullptr; } diff --git a/src/com/powerlink/EplWrapper.h b/src/com/powerlink/EplWrapper.h index 91b6c37a..38d8ee37 100644 --- a/src/com/powerlink/EplWrapper.h +++ b/src/com/powerlink/EplWrapper.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 - 2104 AIT, ACIN, fortiss + * Copyright (c) 2012 - 2024 AIT, ACIN, fortiss * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. @@ -18,90 +18,93 @@ #include #include -struct SEplMapping{ - struct SEplMappingValues{ - unsigned int mDataSize; - unsigned int mPiOffset; - unsigned int mBitOffset; - char* mCurrentValue; - - SEplMappingValues(unsigned int paDataSize, unsigned int paPiOffset, unsigned int paBitOffset) : - mDataSize(paDataSize), mPiOffset(paPiOffset), mBitOffset(paBitOffset){ - mCurrentValue = new char[paDataSize]; - for(unsigned int i = 0; i < paDataSize; i++){ - mCurrentValue[i] = 0x00; - } - } - - ~SEplMappingValues(){ - delete[] mCurrentValue; - } - - private: - SEplMappingValues(const SEplMappingValues &obj); - SEplMappingValues& operator=(const SEplMappingValues &obj); - }; - - typedef CSinglyLinkedList TEplMappingList; - TEplMappingList mCurrentValues; - - ~SEplMapping(){ - while(!mCurrentValues.isEmpty()){ - delete *(TEplMappingList::Iterator) mCurrentValues.begin(); - mCurrentValues.popFront(); +struct EplMapping { + struct EplMappingValues { + unsigned int mDataSize; + unsigned int mPiOffset; + unsigned int mBitOffset; + char *mCurrentValue; + + EplMappingValues(unsigned int paDataSize, unsigned int paPiOffset, + unsigned int paBitOffset) : mDataSize(paDataSize), mPiOffset(paPiOffset), + mBitOffset(paBitOffset) { + mCurrentValue = new char[paDataSize]; + for (unsigned int i = 0; i < paDataSize; i++) { + mCurrentValue[i] = 0x00; } } + + ~EplMappingValues() { + delete[] mCurrentValue; + } + + private: + EplMappingValues(const EplMappingValues &paObj); + + EplMappingValues &operator=(const EplMappingValues &paObj); + }; + + typedef CSinglyLinkedList TEplMappingList; + TEplMappingList mCurrentValues; + + ~EplMapping() { + while (!mCurrentValues.isEmpty()) { + delete *(TEplMappingList::Iterator) mCurrentValues.begin(); + mCurrentValues.popFront(); + } + } }; // CEplStackWrapper implemented as class // cppcheck-suppress noConstructor -class CEplStackWrapper{ +class CEplStackWrapper { DECLARE_SINGLETON(CEplStackWrapper) - ; - public: - /*! \brief Blocking of real-time signals - * - * This must be called in main.cpp before the event execution thread is started - */ - static void eplMainInit(); - int eplStackInit(char* paXmlFile, char* paCdcFile, char* paEthDeviceName); +public: + /*! \brief Blocking of real-time signals + * + * This must be called in main.cpp before the event execution thread is started + */ + static void eplMainInit(); - int eplStackShutdown(); + int eplStackInit(const char *paXmlFile, const char *paCdcFile, const char *paEthDeviceName); - CProcessImageMatrix* getProcessImageMatrixIn(); - CProcessImageMatrix* getProcessImageMatrixOut(); + int eplStackShutdown(); - char* getProcImageIn(); - char* getProcImageOut(); + CProcessImageMatrix *getProcessImageMatrixIn(); - void waitUntilOperational(bool paWait); + CProcessImageMatrix *getProcessImageMatrixOut(); - void registerCallback(IEplCNCallback* paCallback); + char *getProcImageIn(); - void executeAllCallbacks(); + char *getProcImageOut(); - private: - char* allocProcImage(unsigned int n_bytes); + void waitUntilOperational(bool paWait); + + void registerCallback(IEplCNCallback *paCallback); + + void executeAllCallbacks(); - bool findMAC(const char* paUserMAC, char* paDevieName); +private: + char *allocProcImage(unsigned int paNumOfBytes); - bool compareMACs(const char* paMACa, const char* paMACb); + bool findMAC(const char *paUserMAC, char *paChDeviceName); - CProcessImageMatrix mProcMatrixIn; - CProcessImageMatrix mProcMatrixOut; + bool compareMACs(const char *paMacA, const char *paMacB); - unsigned int mProcInSize; - char* mAppProcessImageIn_g; - unsigned int mProcOutSize; - char* mAppProcessImageOut_g; + CProcessImageMatrix mProcMatrixIn; + CProcessImageMatrix mProcMatrixOut; - bool mWait; + unsigned int mProcInSize; + char *mAppProcessImageIn; + unsigned int mProcOutSize; + char *mAppProcessImageOut; - CSinglyLinkedList mCallbackList; + bool mInitWait; - CSyncObject mSync; + CSinglyLinkedList mCallbackList; + CSyncObject mSync; }; #endif diff --git a/src/com/powerlink/EplXmlReader.cpp b/src/com/powerlink/EplXmlReader.cpp index f45af9f6..9de13623 100644 --- a/src/com/powerlink/EplXmlReader.cpp +++ b/src/com/powerlink/EplXmlReader.cpp @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 - 2014 AIT, ACIN, fortiss GmbH + * Copyright (c) 2012 - 2024 AIT, ACIN, fortiss GmbH * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. @@ -8,6 +8,7 @@ * * Contributors: * Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation + * Michael Gafert - changed logging *******************************************************************************/ #include "EplXmlReader.h" @@ -16,6 +17,8 @@ #include #include #include + +#include "devlog.h" using namespace std; #include @@ -55,7 +58,7 @@ void CEplXmlReader::readXmlFile(const char* paFileName){ createProcImageIn(processImageIn); } else{ - cout << "ERROR: Could not open XML file" << endl; + DEVLOG_ERROR("[powerlink] Could not open file %s\n", paFileName); } } @@ -132,7 +135,7 @@ void CEplXmlReader::createProcImageOut(TiXmlNode* paProcessImage){ } - cout << "<< " << currentCnId << ", " << currentModuleNr << ", " << ioName << ", " << currentIoNr << ", " << dSize << ", " << piOffset << ", " << bitOffset << endl; + DEVLOG_DEBUG("[powerlink] << %d, %d, %d, %d, %d, %d, %d\n",currentCnId, currentModuleNr, ioName, currentIoNr, dSize, piOffset, bitOffset); delete[] nameStr; } @@ -217,7 +220,7 @@ void CEplXmlReader::createProcImageIn(TiXmlNode *paProcessImage){ } - cout << ">> " << currentCnId << ", " << currentModuleNr << ", " << ioName << ", " << currentIoNr << ", " << dSize << ", " << piOffset << ", " << bitOffset << endl; + DEVLOG_DEBUG("[powerlink] << %d, %d, %d, %d, %d, %d, %d\n",currentCnId, currentModuleNr, ioName, currentIoNr, dSize, piOffset, bitOffset); delete[] nameStr; } @@ -237,7 +240,7 @@ int CEplXmlReader::getModuleNr(const char* paIoId){ int occurences = mModuleListIn.getNrOfModules(dest); int modNr = mModuleListOut.getModuleNr(dest, occurences + 1); if(modNr == -1) { - cout << "ShouldNotHappenError" << endl; + DEVLOG_ERROR("[powerlink] Could not find module number for %s\n", dest); } return modNr; diff --git a/src/com/powerlink/ModuleList.cpp b/src/com/powerlink/ModuleList.cpp index 60125840..79f24e0a 100644 --- a/src/com/powerlink/ModuleList.cpp +++ b/src/com/powerlink/ModuleList.cpp @@ -13,7 +13,7 @@ #include CModuleList::IoModule::IoModule(const char* paName, unsigned int paPiOffset, unsigned int paBitOffset, unsigned int paModuleNr) : - mPiOffset(paPiOffset), mBitOffset(paBitOffset), mModuleNr(paModuleNr){ + mPiOffset(paPiOffset), mBitOffset(paBitOffset), mModuleNr(paModuleNr){ mName = new char[strlen(paName) + 1]; strcpy(mName, paName); @@ -25,13 +25,11 @@ CModuleList::IoModule::~IoModule(){ CModuleList::CModuleList() : mNumberOfModules(0){ - } CModuleList::~CModuleList(){ // Delete modules in list mModules.clearAll(); - } void CModuleList::addEntry(const char* paName, unsigned int paPiOffset, unsigned int paBitOffset, unsigned int paModuleNr){ @@ -41,7 +39,6 @@ void CModuleList::addEntry(const char* paName, unsigned int paPiOffset, unsigned } int CModuleList::getModuleNr(const char* paName, unsigned int paPiOffset, unsigned int paBitOffset){ - TModuleList::Iterator itEnd(mModules.end()); for(TModuleList::Iterator it(mModules.begin()); it != itEnd; ++it){ if(strcmp(it->mName, paName) == 0 && it->mPiOffset == paPiOffset && it->mBitOffset == paBitOffset){ diff --git a/src/com/powerlink/ModuleList.h b/src/com/powerlink/ModuleList.h index 949afa4a..1781207c 100644 --- a/src/com/powerlink/ModuleList.h +++ b/src/com/powerlink/ModuleList.h @@ -42,8 +42,8 @@ class CModuleList{ unsigned int mModuleNr; private: - IoModule(const IoModule& obj); - IoModule& operator=(const IoModule& obj); + IoModule(const IoModule& paObj); + IoModule& operator=(const IoModule& paObj); }; //std::vector mModules; diff --git a/src/com/powerlink/POWERLINK_MN.cpp b/src/com/powerlink/POWERLINK_MN.cpp deleted file mode 100644 index 1ccb358e..00000000 --- a/src/com/powerlink/POWERLINK_MN.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "POWERLINK_MN.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "POWERLINK_MN_gen.cpp" -#endif - -#include "EplWrapper.h" -#include - -DEFINE_FIRMWARE_FB(FORTE_POWERLINK_MN, g_nStringIdPOWERLINK_MN) - -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCDC_CFG, g_nStringIdAPP_CFG, g_nStringIdDEV_NAME }; - -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING }; - -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING }; - -const TForteInt16 FORTE_POWERLINK_MN::scmEIWithIndexes[] = { 0 }; -const TDataIOID FORTE_POWERLINK_MN::scmEIWith[] = { 0, 1, 2, 3, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmEventInputNames[] = { g_nStringIdINIT }; - -const TDataIOID FORTE_POWERLINK_MN::scmEOWith[] = { 0, 1, scmWithListDelimiter }; -const TForteInt16 FORTE_POWERLINK_MN::scmEOWithIndexes[] = { 0, -1 }; -const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmEventOutputNames[] = { g_nStringIdINITO }; - -const SFBInterfaceSpec FORTE_POWERLINK_MN::scmFBInterfaceSpec = { 1, scmEventInputNames, scmEIWith, scmEIWithIndexes, 1, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 4, scmDataInputNames, scmDataInputTypeIds, 2, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -FORTE_POWERLINK_MN::~FORTE_POWERLINK_MN(){ - shutdownStack(); -} - -void FORTE_POWERLINK_MN::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - - if(QI() == true){ - QO() = QI(); - - CEplStackWrapper* eplStack = &CEplStackWrapper::getInstance(); - - eplStack->waitUntilOperational(false); - eplStack->eplStackInit(APP_CFG().getValue(), CDC_CFG().getValue(), DEV_NAME().getValue()); - - //TODO check if error occured during initialization - - } - else if(QI() == false){ - QO() = QI(); - shutdownStack(); - } - - sendOutputEvent(scmEventINITOID, paECET); - break; - } -} - -void FORTE_POWERLINK_MN::shutdownStack(){ - CEplStackWrapper::getInstance().eplStackShutdown(); -} - diff --git a/src/com/powerlink/POWERLINK_MN.h b/src/com/powerlink/POWERLINK_MN.h deleted file mode 100644 index 1e4d2300..00000000 --- a/src/com/powerlink/POWERLINK_MN.h +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _POWERLINK_MN_H_ -#define _POWERLINK_MN_H_ - -#include - -class FORTE_POWERLINK_MN : public CFunctionBlock{ - DECLARE_FIRMWARE_FB(FORTE_POWERLINK_MN) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_STRING &CDC_CFG(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_STRING &APP_CFG(){ - return *static_cast(getDI(2)); - } - ; - - CIEC_STRING &DEV_NAME(){ - return *static_cast(getDI(3)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(1)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - void shutdownStack(); - - public: - FUNCTION_BLOCK_CTOR(FORTE_POWERLINK_MN){ - }; - - ~FORTE_POWERLINK_MN() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/ProcessImageMatrix.cpp b/src/com/powerlink/ProcessImageMatrix.cpp index 17f62b42..6c3b3ce4 100644 --- a/src/com/powerlink/ProcessImageMatrix.cpp +++ b/src/com/powerlink/ProcessImageMatrix.cpp @@ -12,10 +12,8 @@ #include "ProcessImageMatrix.h" CProcessImageMatrix::CProcessImageMatrix(){ - mBitSize = 0; mNumberOfEntries = 0; - } CProcessImageMatrix::~CProcessImageMatrix(){ @@ -23,7 +21,6 @@ CProcessImageMatrix::~CProcessImageMatrix(){ } void CProcessImageMatrix::addEntry(unsigned int paCN, unsigned int paModule, unsigned int paIoId, unsigned int paDataSize, unsigned int paPiOffset, unsigned int paBitOffset){ - mMatrix.pushBack(new SChannelEntry(paCN, paModule, paIoId, paDataSize, paPiOffset, paBitOffset)); // Check if 8, 16, 32 bit aligned diff --git a/src/com/powerlink/X20AI4622.cpp b/src/com/powerlink/X20AI4622.cpp deleted file mode 100644 index e3054898..00000000 --- a/src/com/powerlink/X20AI4622.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren, Thomas Strasser - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20AI4622.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20AI4622_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20AI4622, g_nStringIdX20AI4622) - -const CStringDictionary::TStringId FORTE_X20AI4622::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20AI4622::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20AI4622::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdAI01, g_nStringIdAI02, g_nStringIdAI03, g_nStringIdAI04 }; - -const CStringDictionary::TStringId FORTE_X20AI4622::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT }; - -const TForteInt16 FORTE_X20AI4622::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20AI4622::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20AI4622::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20AI4622::scmEOWith[] = { 0, 1, 2, scmWithListDelimiter, 2, 3, 4, 5, 6, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20AI4622::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20AI4622::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20AI4622::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 7, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20AI4622::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for inputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - short ioVal = 0x0000; - ioVal = *((short*) (it->mCurrentValue)); - *static_cast(getDO(i)) = ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20AI4622::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - short ioVal = 0x0000; - char lowByte; - char highByte; - lowByte = (eplStack.getProcImageOut()[it->mPiOffset] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - highByte = (eplStack.getProcImageOut()[it->mPiOffset + 1] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte); - - *((short*) (it->mCurrentValue)) = ioVal; - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20AI4622.h b/src/com/powerlink/X20AI4622.h deleted file mode 100644 index 9f7ab561..00000000 --- a/src/com/powerlink/X20AI4622.h +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20AI4622_H_ -#define _X20AI4622_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20AI4622 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20AI4622) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_INT &AI01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_INT &AI02(){ - return *static_cast(getDO(4)); - } - ; - - CIEC_INT &AI03(){ - return *static_cast(getDO(5)); - } - ; - - CIEC_INT &AI04(){ - return *static_cast(getDO(6)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20AI4622){ - }; - - ~FORTE_X20AI4622() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20AO4622.cpp b/src/com/powerlink/X20AO4622.cpp deleted file mode 100644 index 3b68d81d..00000000 --- a/src/com/powerlink/X20AO4622.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20AO4622.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20AO4622_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20AO4622, g_nStringIdX20AO4622) - -const CStringDictionary::TStringId FORTE_X20AO4622::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdAO01, g_nStringIdAO02, g_nStringIdAO03, g_nStringIdAO04 }; - -const CStringDictionary::TStringId FORTE_X20AO4622::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT }; - -const CStringDictionary::TStringId FORTE_X20AO4622::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_X20AO4622::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING }; - -const TForteInt16 FORTE_X20AO4622::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20AO4622::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20AO4622::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20AO4622::scmEOWith[] = { 0, 1, 2, scmWithListDelimiter, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20AO4622::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20AO4622::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20AO4622::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 7, scmDataInputNames, scmDataInputTypeIds, 3, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20AO4622::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Outputs (process inputs) always start with i = 0 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 0; i < moduleIOs->getNrOfEntries(); i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < scmFBInterfaceSpec.mNumDIs && it != itEnd; i++, ++it){ - short ioVal = *static_cast(getDI(i)); - *((short*) (it->mCurrentValue)) = ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20AO4622::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - short ioVal = *((short*) (it->mCurrentValue)); - char highByte = (char) ((ioVal & 0xFF00) >> 8); - char lowByte = (char) (ioVal & 0x00FF); - (eplStack.getProcImageIn())[it->mPiOffset] &= (~(0xFF << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset] |= (lowByte << (it->mBitOffset)); - - (eplStack.getProcImageIn())[it->mPiOffset + 1] &= (~(0xFF << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset + 1] |= (highByte << (it->mBitOffset)); - } - - mSync.unlock(); -} diff --git a/src/com/powerlink/X20AO4622.h b/src/com/powerlink/X20AO4622.h deleted file mode 100644 index 35ac1ae8..00000000 --- a/src/com/powerlink/X20AO4622.h +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20AO4622_H_ -#define _X20AO4622_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20AO4622 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20AO4622) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - CIEC_INT &AO01(){ - return *static_cast(getDI(3)); - } - ; - - CIEC_INT &AO02(){ - return *static_cast(getDI(4)); - } - ; - - CIEC_INT &AO03(){ - return *static_cast(getDI(5)); - } - ; - - CIEC_INT &AO04(){ - return *static_cast(getDI(6)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20AO4622){ - }; - - ~FORTE_X20AO4622() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20AT2402.cpp b/src/com/powerlink/X20AT2402.cpp deleted file mode 100644 index a753a4e4..00000000 --- a/src/com/powerlink/X20AT2402.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20AT2402.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20AT2402_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20AT2402, g_nStringIdX20AT2402) - -const CStringDictionary::TStringId FORTE_X20AT2402::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20AT2402::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20AT2402::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02 }; - -const CStringDictionary::TStringId FORTE_X20AT2402::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL }; - -const TForteInt16 FORTE_X20AT2402::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20AT2402::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20AT2402::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20AT2402::scmEOWith[] = { 0, 1, 2, scmWithListDelimiter, 2, 3, 4, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20AT2402::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20AT2402::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20AT2402::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 5, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20AT2402::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - short ioVal = *((short*) (it->mCurrentValue)); - TForteFloat ioValFloat = static_cast(ioVal); - *static_cast(getDO(i)) = ioValFloat / 10; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20AT2402::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - short ioVal = 0x0000; - char lowByte; - char highByte; - lowByte = (eplStack.getProcImageOut()[it->mPiOffset] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - highByte = (eplStack.getProcImageOut()[it->mPiOffset + 1] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte); - - *((short*) (it->mCurrentValue)) = ioVal; - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20AT2402.h b/src/com/powerlink/X20AT2402.h deleted file mode 100644 index 71e729a5..00000000 --- a/src/com/powerlink/X20AT2402.h +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20AT2402_H_ -#define _X20AT2402_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20AT2402 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20AT2402) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_REAL &T01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_REAL &T02(){ - return *static_cast(getDO(4)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20AT2402){ - }; - - ~FORTE_X20AT2402() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20AT4222.cpp b/src/com/powerlink/X20AT4222.cpp deleted file mode 100644 index d88a6bcb..00000000 --- a/src/com/powerlink/X20AT4222.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20AT4222.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20AT4222_gen.cpp" -#endif - -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20AT4222, g_nStringIdX20AT4222) - -const CStringDictionary::TStringId FORTE_X20AT4222::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20AT4222::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20AT4222::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02, g_nStringIdT03, g_nStringIdT04 }; - -const CStringDictionary::TStringId FORTE_X20AT4222::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL }; - -const TForteInt16 FORTE_X20AT4222::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20AT4222::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20AT4222::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20AT4222::scmEOWith[] = { 0, 1, 2, scmWithListDelimiter, 2, 3, 4, 0, 5, 6, scmWithListDelimiter }; -const TForteInt16 FORTE_X20AT4222::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20AT4222::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20AT4222::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 7, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20AT4222::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - short ioVal = *((short*) (it->mCurrentValue)); - TForteFloat ioValFloat = static_cast(ioVal); - *static_cast(getDO(i)) = ioValFloat / 10; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20AT4222::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - short ioVal = 0x0000; - char lowByte; - char highByte; - lowByte = (eplStack.getProcImageOut()[it->mPiOffset] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - highByte = (eplStack.getProcImageOut()[it->mPiOffset + 1] & (0xFF << it->mBitOffset)) >> it->mBitOffset; - ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte); - - *((short*) (it->mCurrentValue)) = ioVal; - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20AT4222.h b/src/com/powerlink/X20AT4222.h deleted file mode 100644 index 8ee1e953..00000000 --- a/src/com/powerlink/X20AT4222.h +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20AT4222_H_ -#define _X20AT4222_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20AT4222 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20AT4222) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_REAL &T01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_REAL &T02(){ - return *static_cast(getDO(4)); - } - ; - - CIEC_REAL &T03(){ - return *static_cast(getDO(5)); - } - ; - - CIEC_REAL &T04(){ - return *static_cast(getDO(6)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20AT4222){ - }; - - ~FORTE_X20AT4222() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DI4653.cpp b/src/com/powerlink/X20DI4653.cpp deleted file mode 100644 index 320cafa7..00000000 --- a/src/com/powerlink/X20DI4653.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DI4653.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DI4653_gen.cpp" -#endif - -DEFINE_FIRMWARE_FB(FORTE_X20DI4653, g_nStringIdX20DI4653) - -const CStringDictionary::TStringId FORTE_X20DI4653::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; - -const CStringDictionary::TStringId FORTE_X20DI4653::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; - -const CStringDictionary::TStringId FORTE_X20DI4653::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04}; - -const CStringDictionary::TStringId FORTE_X20DI4653::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; - -const TForteInt16 FORTE_X20DI4653::scmEIWithIndexes[] = {0, 4}; -const TDataIOID FORTE_X20DI4653::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; -const CStringDictionary::TStringId FORTE_X20DI4653::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; - -const TDataIOID FORTE_X20DI4653::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 2, 0, scmWithListDelimiter}; -const TForteInt16 FORTE_X20DI4653::scmEOWithIndexes[] = {0, 4, -1}; -const CStringDictionary::TStringId FORTE_X20DI4653::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; - -const SFBInterfaceSpec FORTE_X20DI4653::scmFBInterfaceSpec = { - 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, - 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, - 7, scmDataOutputNames, scmDataOutputTypeIds, - 0, 0 -}; - - -void FORTE_X20DI4653::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch(paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - *static_cast(getDO(i)) = ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DI4653::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = (eplStack.getProcImageOut()[it->mPiOffset] & (char) (0x01 << it->mBitOffset)) != 0x00; - *(it->mCurrentValue) = (char) ioVal; - } - - mSync.unlock(); -} - - - diff --git a/src/com/powerlink/X20DI4653.h b/src/com/powerlink/X20DI4653.h deleted file mode 100644 index 7c0422e6..00000000 --- a/src/com/powerlink/X20DI4653.h +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DI4653_H_ -#define _X20DI4653_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DI4653: public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DI4653) - -private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI() { - return *static_cast(getDI(0)); - }; - - CIEC_USINT &CNID() { - return *static_cast(getDI(1)); - }; - - CIEC_UINT &MODID() { - return *static_cast(getDI(2)); - }; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO() { - return *static_cast(getDO(0)); - }; - - CIEC_USINT &CNIDO() { - return *static_cast(getDO(1)); - }; - - CIEC_STRING &STATUS() { - return *static_cast(getDO(2)); - }; - - CIEC_BOOL &DI01() { - return *static_cast(getDO(3)); - }; - - CIEC_BOOL &DI02() { - return *static_cast(getDO(4)); - }; - - CIEC_BOOL &DI03() { - return *static_cast(getDO(5)); - }; - - CIEC_BOOL &DI04() { - return *static_cast(getDO(6)); - }; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - - SEplMapping mEplMapping; - CSyncObject mSync; - bool mInitOk; - // ... - -public: - FUNCTION_BLOCK_CTOR(FORTE_X20DI4653){ - }; - - ~FORTE_X20DI4653() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file - diff --git a/src/com/powerlink/X20DI9371.cpp b/src/com/powerlink/X20DI9371.cpp deleted file mode 100644 index c12a795f..00000000 --- a/src/com/powerlink/X20DI9371.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DI9371.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DI9371_gen.cpp" -#endif - -DEFINE_FIRMWARE_FB(FORTE_X20DI9371, g_nStringIdX20DI9371) - -const CStringDictionary::TStringId FORTE_X20DI9371::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20DI9371::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20DI9371::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 }; - -const CStringDictionary::TStringId FORTE_X20DI9371::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const TForteInt16 FORTE_X20DI9371::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20DI9371::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DI9371::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20DI9371::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DI9371::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20DI9371::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20DI9371::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 15, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DI9371::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - *static_cast(getDO(i)) = ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DI9371::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = (eplStack.getProcImageOut()[it->mPiOffset] & (char) (0x01 << it->mBitOffset)) != 0x00; - *(it->mCurrentValue) = (char) ioVal; - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20DI9371.h b/src/com/powerlink/X20DI9371.h deleted file mode 100644 index c7e8145e..00000000 --- a/src/com/powerlink/X20DI9371.h +++ /dev/null @@ -1,152 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DI9371_H_ -#define _X20DI9371_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DI9371 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DI9371) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_BOOL &DI01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_BOOL &DI02(){ - return *static_cast(getDO(4)); - } - ; - - CIEC_BOOL &DI03(){ - return *static_cast(getDO(5)); - } - ; - - CIEC_BOOL &DI04(){ - return *static_cast(getDO(6)); - } - ; - - CIEC_BOOL &DI05(){ - return *static_cast(getDO(7)); - } - ; - - CIEC_BOOL &DI06(){ - return *static_cast(getDO(8)); - } - ; - - CIEC_BOOL &DI07(){ - return *static_cast(getDO(9)); - } - ; - - CIEC_BOOL &DI08(){ - return *static_cast(getDO(10)); - } - ; - - CIEC_BOOL &DI09(){ - return *static_cast(getDO(11)); - } - ; - - CIEC_BOOL &DI10(){ - return *static_cast(getDO(12)); - } - ; - - CIEC_BOOL &DI11(){ - return *static_cast(getDO(13)); - } - ; - - CIEC_BOOL &DI12(){ - return *static_cast(getDO(14)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DI9371){ - }; - - ~FORTE_X20DI9371() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DI9372.cpp b/src/com/powerlink/X20DI9372.cpp deleted file mode 100644 index 19bcdd95..00000000 --- a/src/com/powerlink/X20DI9372.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DI9372.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DI9372_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20DI9372, g_nStringIdX20DI9372) - -const CStringDictionary::TStringId FORTE_X20DI9372::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20DI9372::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20DI9372::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 }; - -const CStringDictionary::TStringId FORTE_X20DI9372::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const TForteInt16 FORTE_X20DI9372::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20DI9372::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DI9372::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20DI9372::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DI9372::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20DI9372::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20DI9372::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 15, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DI9372::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for inputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - *static_cast(getDO(i)) = ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DI9372::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = (eplStack.getProcImageOut()[it->mPiOffset] & (char) (0x01 << it->mBitOffset)) != 0x00; - *(it->mCurrentValue) = (char) ioVal; - } - - mSync.unlock(); -} diff --git a/src/com/powerlink/X20DI9372.h b/src/com/powerlink/X20DI9372.h deleted file mode 100644 index 3bc19a5b..00000000 --- a/src/com/powerlink/X20DI9372.h +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DI9372_H_ -#define _X20DI9372_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DI9372 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DI9372) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_BOOL &DI01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_BOOL &DI02(){ - return *static_cast(getDO(4)); - } - ; - - CIEC_BOOL &DI03(){ - return *static_cast(getDO(5)); - } - ; - - CIEC_BOOL &DI04(){ - return *static_cast(getDO(6)); - } - ; - - CIEC_BOOL &DI05(){ - return *static_cast(getDO(7)); - } - ; - - CIEC_BOOL &DI06(){ - return *static_cast(getDO(8)); - } - ; - - CIEC_BOOL &DI07(){ - return *static_cast(getDO(9)); - } - ; - - CIEC_BOOL &DI08(){ - return *static_cast(getDO(10)); - } - ; - - CIEC_BOOL &DI09(){ - return *static_cast(getDO(11)); - } - ; - - CIEC_BOOL &DI10(){ - return *static_cast(getDO(12)); - } - ; - - CIEC_BOOL &DI11(){ - return *static_cast(getDO(13)); - } - ; - - CIEC_BOOL &DI12(){ - return *static_cast(getDO(14)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DI9372){ - }; - - ~FORTE_X20DI9372() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DI937X.cpp b/src/com/powerlink/X20DI937X.cpp deleted file mode 100644 index 7f2dfe37..00000000 --- a/src/com/powerlink/X20DI937X.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DI937X.h" - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20DI937X, g_nStringIdX20DI937X) - -const CStringDictionary::TStringId FORTE_X20DI937X::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID }; - -const CStringDictionary::TStringId FORTE_X20DI937X::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT }; - -const CStringDictionary::TStringId FORTE_X20DI937X::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 }; - -const CStringDictionary::TStringId FORTE_X20DI937X::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const TForteInt16 FORTE_X20DI937X::scmEIWithIndexes[] = { 0, -1, -1 }; -const TDataIOID FORTE_X20DI937X::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DI937X::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ, g_nStringIdRSP }; - -const TDataIOID FORTE_X20DI937X::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DI937X::scmEOWithIndexes[] = { 0, 4, 18, -1 }; -const CStringDictionary::TStringId FORTE_X20DI937X::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF, g_nStringIdIND }; - -const SFBInterfaceSpec FORTE_X20DI937X::scmFBInterfaceSpec = { 3, scmEventInputNames, scmEIWith, scmEIWithIndexes, 3, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 3, scmDataInputNames, scmDataInputTypeIds, 15, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DI937X::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: { - //#error add code for INIT event! - - EplStackWrapper &eplStack = EplStackWrapper::getInstance(); - - // Get settings for intputs - ProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries(CNID(), MODID()); - - // Inputs (process inputs) always start with i = 1 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mDataSizes[i] = moduleIOs->getEntry(i)[0]; - mEplMapping.mPiOffsets[i] = moduleIOs->getEntry(i)[1]; - mEplMapping.mBitOffsets[i] = moduleIOs->getEntry(i)[2]; - - char* newVal = new char[mEplMapping.mDataSizes[i]](); - mEplMapping.mCurrentValues.pushBack(newVal); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - } - case scmEventREQID: { - mSync.lock(); - CSinglyLinkedList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - CSinglyLinkedList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it){ - bool ioVal = (bool) **it; - *static_cast(getDO(i)) = ioVal; - } - mSync.unlock(); - - sendOutputEvent(scmEventCNFID, paECET); - break; - } - case scmEventRSPID: - break; - } -} - -void FORTE_X20DI937X::cnSynchCallback(){ - EplStackWrapper &eplStack = EplStackWrapper::getInstance(); - - mSync.lock(); - - CSinglyLinkedList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - CSinglyLinkedList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3, j = 1; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, j++, ++it){ - bool ioVal = (bool) (eplStack.getProcImageOut()[mEplMapping.mPiOffsets[j]] & (char) (0x01 << mEplMapping.mBitOffsets[j])); - **it = (char) ioVal; - } - - mSync.unlock(); -} diff --git a/src/com/powerlink/X20DI937X.h b/src/com/powerlink/X20DI937X.h deleted file mode 100644 index 78704100..00000000 --- a/src/com/powerlink/X20DI937X.h +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DI937X_H_ -#define _X20DI937X_H_ - -#include - -#include -#include "EplCNCallback.h" -#include "EplWrapper.h" - -class FORTE_X20DI937X : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DI937X) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - CIEC_BOOL &DI01(){ - return *static_cast(getDO(3)); - } - ; - - CIEC_BOOL &DI02(){ - return *static_cast(getDO(4)); - } - ; - - CIEC_BOOL &DI03(){ - return *static_cast(getDO(5)); - } - ; - - CIEC_BOOL &DI04(){ - return *static_cast(getDO(6)); - } - ; - - CIEC_BOOL &DI05(){ - return *static_cast(getDO(7)); - } - ; - - CIEC_BOOL &DI06(){ - return *static_cast(getDO(8)); - } - ; - - CIEC_BOOL &DI07(){ - return *static_cast(getDO(9)); - } - ; - - CIEC_BOOL &DI08(){ - return *static_cast(getDO(10)); - } - ; - - CIEC_BOOL &DI09(){ - return *static_cast(getDO(11)); - } - ; - - CIEC_BOOL &DI10(){ - return *static_cast(getDO(12)); - } - ; - - CIEC_BOOL &DI11(){ - return *static_cast(getDO(13)); - } - ; - - CIEC_BOOL &DI12(){ - return *static_cast(getDO(14)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TEventID scmEventRSPID = 2; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TEventID scmEventINDID = 2; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - - SEplMapping mEplMapping;CSyncObject mSync; - - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DI937X){ - }; - - ~FORTE_X20DI937X() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DO4623.cpp b/src/com/powerlink/X20DO4623.cpp deleted file mode 100644 index 6da3ed90..00000000 --- a/src/com/powerlink/X20DO4623.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DO4623.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DO4623_gen.cpp" -#endif - -DEFINE_FIRMWARE_FB(FORTE_X20DO4623, g_nStringIdX20DO4623) - -const CStringDictionary::TStringId FORTE_X20DO4623::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04}; - -const CStringDictionary::TStringId FORTE_X20DO4623::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; - -const CStringDictionary::TStringId FORTE_X20DO4623::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS}; - -const CStringDictionary::TStringId FORTE_X20DO4623::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING}; - -const TForteInt16 FORTE_X20DO4623::scmEIWithIndexes[] = {0, 4}; -const TDataIOID FORTE_X20DO4623::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter}; -const CStringDictionary::TStringId FORTE_X20DO4623::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; - -const TDataIOID FORTE_X20DO4623::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; -const TForteInt16 FORTE_X20DO4623::scmEOWithIndexes[] = {0, 4, -1}; -const CStringDictionary::TStringId FORTE_X20DO4623::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; - -const SFBInterfaceSpec FORTE_X20DO4623::scmFBInterfaceSpec = { - 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, - 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 7, scmDataInputNames, scmDataInputTypeIds, - 3, scmDataOutputNames, scmDataOutputTypeIds, - 0, 0 -}; - - -void FORTE_X20DO4623::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch(paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Outputs (process inputs) always start with i = 0 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it){ - bool ioVal = *static_cast(getDI(i)); - *(it->mCurrentValue) = (char) ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DO4623::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - (eplStack.getProcImageIn())[it->mPiOffset] &= (char) (~(0x01 << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset] |= (char) (ioVal << it->mBitOffset); - } - - mSync.unlock(); -} - - - diff --git a/src/com/powerlink/X20DO4623.h b/src/com/powerlink/X20DO4623.h deleted file mode 100644 index d2c52600..00000000 --- a/src/com/powerlink/X20DO4623.h +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DO4623_H_ -#define _X20DO4623_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DO4623: public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DO4623) - -private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI() { - return *static_cast(getDI(0)); - }; - - CIEC_USINT &CNID() { - return *static_cast(getDI(1)); - }; - - CIEC_UINT &MODID() { - return *static_cast(getDI(2)); - }; - - CIEC_BOOL &DO01() { - return *static_cast(getDI(3)); - }; - - CIEC_BOOL &DO02() { - return *static_cast(getDI(4)); - }; - - CIEC_BOOL &DO03() { - return *static_cast(getDI(5)); - }; - - CIEC_BOOL &DO04() { - return *static_cast(getDI(6)); - }; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO() { - return *static_cast(getDO(0)); - }; - - CIEC_USINT &CNIDO() { - return *static_cast(getDO(1)); - }; - - CIEC_STRING &STATUS() { - return *static_cast(getDO(2)); - }; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping; - CSyncObject mSync; - bool mInitOk; - // ... - -public: - FUNCTION_BLOCK_CTOR(FORTE_X20DO4623){ - }; - - ~FORTE_X20DO4623() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file - diff --git a/src/com/powerlink/X20DO4649.cpp b/src/com/powerlink/X20DO4649.cpp deleted file mode 100644 index 26ace0da..00000000 --- a/src/com/powerlink/X20DO4649.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DO4649.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DO4649_gen.cpp" -#endif - -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20DO4649, g_nStringIdX20DO4649) - -const CStringDictionary::TStringId FORTE_X20DO4649::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04 }; - -const CStringDictionary::TStringId FORTE_X20DO4649::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const CStringDictionary::TStringId FORTE_X20DO4649::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_X20DO4649::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING }; - -const TForteInt16 FORTE_X20DO4649::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20DO4649::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DO4649::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20DO4649::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DO4649::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20DO4649::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20DO4649::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 7, scmDataInputNames, scmDataInputTypeIds, 3, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DO4649::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Outputs (process inputs) always start with i = 0 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it){ - bool ioVal = *static_cast(getDI(i)); - *(it->mCurrentValue) = (char) ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DO4649::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - (eplStack.getProcImageIn())[it->mPiOffset] &= (char) (~(0x01 << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset] |= (char) (ioVal << it->mBitOffset); - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20DO4649.h b/src/com/powerlink/X20DO4649.h deleted file mode 100644 index 8d8e6f6f..00000000 --- a/src/com/powerlink/X20DO4649.h +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DO4649_H_ -#define _X20DO4649_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DO4649 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DO4649) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - CIEC_BOOL &DO01(){ - return *static_cast(getDI(3)); - } - ; - - CIEC_BOOL &DO02(){ - return *static_cast(getDI(4)); - } - ; - - CIEC_BOOL &DO03(){ - return *static_cast(getDI(5)); - } - ; - - CIEC_BOOL &DO04(){ - return *static_cast(getDI(6)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DO4649){ - }; - - ~FORTE_X20DO4649() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DO9321.cpp b/src/com/powerlink/X20DO9321.cpp deleted file mode 100644 index ac0b588d..00000000 --- a/src/com/powerlink/X20DO9321.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DO9321.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DO9321_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20DO9321, g_nStringIdX20DO9321) - -const CStringDictionary::TStringId FORTE_X20DO9321::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12 }; - -const CStringDictionary::TStringId FORTE_X20DO9321::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const CStringDictionary::TStringId FORTE_X20DO9321::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_X20DO9321::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING }; - -const TForteInt16 FORTE_X20DO9321::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20DO9321::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DO9321::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20DO9321::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DO9321::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20DO9321::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20DO9321::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 15, scmDataInputNames, scmDataInputTypeIds, 3, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DO9321::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for inputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Outputs (process inputs) always start with i = 0 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it){ - bool ioVal = *static_cast(getDI(i)); - *(it->mCurrentValue) = (char) ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DO9321::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - (eplStack.getProcImageIn())[it->mPiOffset] &= (char) (~(0x01 << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset] |= (char) (ioVal << it->mBitOffset); - } - - mSync.unlock(); -} - diff --git a/src/com/powerlink/X20DO9321.h b/src/com/powerlink/X20DO9321.h deleted file mode 100644 index a7d5e317..00000000 --- a/src/com/powerlink/X20DO9321.h +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DO9321_H_ -#define _X20DO9321_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DO9321 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DO9321) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - CIEC_BOOL &DO01(){ - return *static_cast(getDI(3)); - } - ; - - CIEC_BOOL &DO02(){ - return *static_cast(getDI(4)); - } - ; - - CIEC_BOOL &DO03(){ - return *static_cast(getDI(5)); - } - ; - - CIEC_BOOL &DO04(){ - return *static_cast(getDI(6)); - } - ; - - CIEC_BOOL &DO05(){ - return *static_cast(getDI(7)); - } - ; - - CIEC_BOOL &DO06(){ - return *static_cast(getDI(8)); - } - ; - - CIEC_BOOL &DO07(){ - return *static_cast(getDI(9)); - } - ; - - CIEC_BOOL &DO08(){ - return *static_cast(getDI(10)); - } - ; - - CIEC_BOOL &DO09(){ - return *static_cast(getDI(11)); - } - ; - - CIEC_BOOL &DO10(){ - return *static_cast(getDI(12)); - } - ; - - CIEC_BOOL &DO11(){ - return *static_cast(getDI(13)); - } - ; - - CIEC_BOOL &DO12(){ - return *static_cast(getDI(14)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DO9321){ - }; - - ~FORTE_X20DO9321() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/X20DO9322.cpp b/src/com/powerlink/X20DO9322.cpp deleted file mode 100644 index fe04c21c..00000000 --- a/src/com/powerlink/X20DO9322.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#include "X20DO9322.h" -#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP -#include "X20DO9322_gen.cpp" -#endif - -#include "EplWrapper.h" -#include "ProcessImageMatrix.h" - -DEFINE_FIRMWARE_FB(FORTE_X20DO9322, g_nStringIdX20DO9322) - -const CStringDictionary::TStringId FORTE_X20DO9322::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12 }; - -const CStringDictionary::TStringId FORTE_X20DO9322::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL }; - -const CStringDictionary::TStringId FORTE_X20DO9322::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_X20DO9322::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING }; - -const TForteInt16 FORTE_X20DO9322::scmEIWithIndexes[] = { 0, 4 }; -const TDataIOID FORTE_X20DO9322::scmEIWith[] = { 0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_X20DO9322::scmEventInputNames[] = { g_nStringIdINIT, g_nStringIdREQ }; - -const TDataIOID FORTE_X20DO9322::scmEOWith[] = { 0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter }; -const TForteInt16 FORTE_X20DO9322::scmEOWithIndexes[] = { 0, 4, -1 }; -const CStringDictionary::TStringId FORTE_X20DO9322::scmEventOutputNames[] = { g_nStringIdINITO, g_nStringIdCNF }; - -const SFBInterfaceSpec FORTE_X20DO9322::scmFBInterfaceSpec = { 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, 15, scmDataInputNames, scmDataInputTypeIds, 3, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; - -void FORTE_X20DO9322::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ - case scmEventINITID: - if(QI() == true){ - mInitOk = false; - - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - // Get settings for intputs - CProcessImageMatrix* moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries(CNID(), MODID()); - - if(moduleIOs){ - // Outputs (process inputs) always start with i = 0 - // Check xap.xml if a BitUnused is present - for(unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++){ - mEplMapping.mCurrentValues.pushBack(new SEplMapping::SEplMappingValues(moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); - } - delete moduleIOs; - - eplStack.registerCallback(static_cast(this)); - - mInitOk = true; - } - } - QO() = QI(); - CNIDO() = CNID(); - sendOutputEvent(scmEventINITOID, paECET); - break; - case scmEventREQID: - if(QI() == true && mInitOk){ - mSync.lock(); - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(int i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it){ - bool ioVal = *static_cast(getDI(i)); - *(it->mCurrentValue) = (char) ioVal; - } - mSync.unlock(); - } - QO() = QI(); - sendOutputEvent(scmEventCNFID, paECET); - break; - } -} - -void FORTE_X20DO9322::cnSynchCallback(){ - CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); - - mSync.lock(); - - SEplMapping::TEplMappingList::Iterator itEnd = mEplMapping.mCurrentValues.end(); - SEplMapping::TEplMappingList::Iterator it = mEplMapping.mCurrentValues.begin(); - for(; it != itEnd; ++it){ - bool ioVal = *(it->mCurrentValue) != 0x00; - (eplStack.getProcImageIn())[it->mPiOffset] &= (char) (~(0x01 << it->mBitOffset)); - (eplStack.getProcImageIn())[it->mPiOffset] |= (char) (ioVal << it->mBitOffset); - } - - mSync.unlock(); -} diff --git a/src/com/powerlink/X20DO9322.h b/src/com/powerlink/X20DO9322.h deleted file mode 100644 index 53298b15..00000000 --- a/src/com/powerlink/X20DO9322.h +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 AIT - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Filip Andren - initial API and implementation and/or initial documentation - *******************************************************************************/ -#ifndef _X20DO9322_H_ -#define _X20DO9322_H_ - -#include - -#include "EplCNCallback.h" -#include "EplWrapper.h" - -// cppcheck-suppress noConstructor -class FORTE_X20DO9322 : public CFunctionBlock, public IEplCNCallback{ - DECLARE_FIRMWARE_FB(FORTE_X20DO9322) - - private: - static const CStringDictionary::TStringId scmDataInputNames[]; - static const CStringDictionary::TStringId scmDataInputTypeIds[]; - CIEC_BOOL &QI(){ - return *static_cast(getDI(0)); - } - ; - - CIEC_USINT &CNID(){ - return *static_cast(getDI(1)); - } - ; - - CIEC_UINT &MODID(){ - return *static_cast(getDI(2)); - } - ; - - CIEC_BOOL &DO01(){ - return *static_cast(getDI(3)); - } - ; - - CIEC_BOOL &DO02(){ - return *static_cast(getDI(4)); - } - ; - - CIEC_BOOL &DO03(){ - return *static_cast(getDI(5)); - } - ; - - CIEC_BOOL &DO04(){ - return *static_cast(getDI(6)); - } - ; - - CIEC_BOOL &DO05(){ - return *static_cast(getDI(7)); - } - ; - - CIEC_BOOL &DO06(){ - return *static_cast(getDI(8)); - } - ; - - CIEC_BOOL &DO07(){ - return *static_cast(getDI(9)); - } - ; - - CIEC_BOOL &DO08(){ - return *static_cast(getDI(10)); - } - ; - - CIEC_BOOL &DO09(){ - return *static_cast(getDI(11)); - } - ; - - CIEC_BOOL &DO10(){ - return *static_cast(getDI(12)); - } - ; - - CIEC_BOOL &DO11(){ - return *static_cast(getDI(13)); - } - ; - - CIEC_BOOL &DO12(){ - return *static_cast(getDI(14)); - } - ; - - static const CStringDictionary::TStringId scmDataOutputNames[]; - static const CStringDictionary::TStringId scmDataOutputTypeIds[]; - CIEC_BOOL &QO(){ - return *static_cast(getDO(0)); - } - ; - - CIEC_USINT &CNIDO(){ - return *static_cast(getDO(1)); - } - ; - - CIEC_STRING &STATUS(){ - return *static_cast(getDO(2)); - } - ; - - static const TEventID scmEventINITID = 0; - static const TEventID scmEventREQID = 1; - static const TForteInt16 scmEIWithIndexes[]; - static const TDataIOID scmEIWith[]; - static const CStringDictionary::TStringId scmEventInputNames[]; - - static const TEventID scmEventINITOID = 0; - static const TEventID scmEventCNFID = 1; - static const TForteInt16 scmEOWithIndexes[]; - static const TDataIOID scmEOWith[]; - static const CStringDictionary::TStringId scmEventOutputNames[]; - - static const SFBInterfaceSpec scmFBInterfaceSpec; - - - void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; - - // Variables for mapping between inputs and POWERLINK stack - SEplMapping mEplMapping;CSyncObject mSync; - bool mInitOk; - // ... - - public: - FUNCTION_BLOCK_CTOR(FORTE_X20DO9322){ - }; - - ~FORTE_X20DO9322() override = default; - - void cnSynchCallback() override; - -}; - -#endif //close the ifdef sequence from the beginning of the file diff --git a/src/com/powerlink/fb/POWERLINK_MN_fbt.cpp b/src/com/powerlink/fb/POWERLINK_MN_fbt.cpp new file mode 100644 index 00000000..f1b6380f --- /dev/null +++ b/src/com/powerlink/fb/POWERLINK_MN_fbt.cpp @@ -0,0 +1,152 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - converted to new FB style + *******************************************************************************/ + +#include "POWERLINK_MN_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "POWERLINK_MN_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_POWERLINK_MN, g_nStringIdPOWERLINK_MN) + +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCDC_CFG, g_nStringIdAPP_CFG, g_nStringIdDEV_NAME}; +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdSTRING}; +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdSTRING}; +const TDataIOID FORTE_POWERLINK_MN::scmEIWith[] = {0, 1, 2, 3, scmWithListDelimiter}; +const TForteInt16 FORTE_POWERLINK_MN::scmEIWithIndexes[] = {0}; +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmEventInputNames[] = {g_nStringIdINIT}; +const TDataIOID FORTE_POWERLINK_MN::scmEOWith[] = {0, 1, scmWithListDelimiter}; +const TForteInt16 FORTE_POWERLINK_MN::scmEOWithIndexes[] = {0}; +const CStringDictionary::TStringId FORTE_POWERLINK_MN::scmEventOutputNames[] = {g_nStringIdINITO}; +const SFBInterfaceSpec FORTE_POWERLINK_MN::scmFBInterfaceSpec = { + 1, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 1, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 4, scmDataInputNames, scmDataInputTypeIds, + 2, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_POWERLINK_MN::FORTE_POWERLINK_MN(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_QI(nullptr), + conn_CDC_CFG(nullptr), + conn_APP_CFG(nullptr), + conn_DEV_NAME(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_STATUS(this, 1, &var_conn_STATUS) { +}; + +void FORTE_POWERLINK_MN::setInitialValues() { + var_QI = 0_BOOL; + var_CDC_CFG = ""_STRING; + var_APP_CFG = ""_STRING; + var_DEV_NAME = ""_STRING; + var_QO = 0_BOOL; + var_STATUS = ""_STRING; +} + +void FORTE_POWERLINK_MN::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + switch(paEIID) { + case scmEventINITID: + + CEplStackWrapper* eplStack = &CEplStackWrapper::getInstance(); + + eplStack->waitUntilOperational(false); + eplStack->eplStackInit(var_APP_CFG.c_str(), + var_CDC_CFG.c_str(), + var_DEV_NAME.c_str()); + + // TODO check if error occured during initialization + + sendOutputEvent(scmEventINITOID, paECET); + + break; + } +} + +void FORTE_POWERLINK_MN::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CDC_CFG, conn_CDC_CFG); + readData(2, var_APP_CFG, conn_APP_CFG); + readData(3, var_DEV_NAME, conn_DEV_NAME); + break; + } + default: + break; + } +} + +void FORTE_POWERLINK_MN::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_STATUS, conn_STATUS); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_POWERLINK_MN::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CDC_CFG; + case 2: return &var_APP_CFG; + case 3: return &var_DEV_NAME; + } + return nullptr; +} + +CIEC_ANY *FORTE_POWERLINK_MN::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_POWERLINK_MN::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + } + return nullptr; +} + +CDataConnection **FORTE_POWERLINK_MN::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CDC_CFG; + case 2: return &conn_APP_CFG; + case 3: return &conn_DEV_NAME; + } + return nullptr; +} + +CDataConnection *FORTE_POWERLINK_MN::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_STATUS; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/POWERLINK_MN_fbt.h b/src/com/powerlink/fb/POWERLINK_MN_fbt.h new file mode 100644 index 00000000..d9208b92 --- /dev/null +++ b/src/com/powerlink/fb/POWERLINK_MN_fbt.h @@ -0,0 +1,98 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - converted to new FB style + *******************************************************************************/ + +#pragma once + +#include "EplWrapper.h" + +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_POWERLINK_MN final : public CFunctionBlock { + DECLARE_FIRMWARE_FB(FORTE_POWERLINK_MN) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_POWERLINK_MN(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_STRING var_CDC_CFG; + CIEC_STRING var_APP_CFG; + CIEC_STRING var_DEV_NAME; + + CIEC_BOOL var_QO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + + CDataConnection *conn_QI; + CDataConnection *conn_CDC_CFG; + CDataConnection *conn_APP_CFG; + CDataConnection *conn_DEV_NAME; + + CDataConnection conn_QO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_STRING &paCDC_CFG, const CIEC_STRING &paAPP_CFG, const CIEC_STRING &paDEV_NAME, CIEC_BOOL &paQO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CDC_CFG = paCDC_CFG; + var_APP_CFG = paAPP_CFG; + var_DEV_NAME = paDEV_NAME; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_STRING &paCDC_CFG, const CIEC_STRING &paAPP_CFG, const CIEC_STRING &paDEV_NAME, CIEC_BOOL &paQO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCDC_CFG, paAPP_CFG, paDEV_NAME, paQO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAI.cpp b/src/com/powerlink/fb/PowerlinkFunctionBlockAI.cpp new file mode 100644 index 00000000..5a846d7d --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAI.cpp @@ -0,0 +1,85 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#include "PowerlinkFunctionBlockAI.h" + + +void PowerlinkFunctionBlockAI::cnSynchCallback() { + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + sync.lock(); + + const auto &procImageOut = eplStack.getProcImageOut(); + for (const auto &mappingValue : eplMapping.mCurrentValues) { + short ioVal = 0x0000; + char lowByte = (procImageOut[mappingValue->mPiOffset] & (0xFF << mappingValue->mBitOffset)) >> mappingValue->mBitOffset; + char highByte = (procImageOut[mappingValue->mPiOffset + 1] & (0xFF << mappingValue->mBitOffset)) >> mappingValue->mBitOffset; + ioVal = static_cast((0xFF00 & (highByte << 8)) | (0xFF & lowByte)); + + *reinterpret_cast(mappingValue->mCurrentValue) = ioVal; + } + + sync.unlock(); +} + +void PowerlinkFunctionBlockAI::executePowerlinkEvent(const TEventID paEIID, + CEventChainExecutionThread *const paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID) { + if (paEIID == scmEventINITID) { + if (var_QI == true) { + initOk = false; + + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + + CProcessImageMatrix *moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries( + var_CNID.getUnsignedValue(), var_MODID.getUnsignedValue()); + + if (moduleIOs) { + // Inputs (process inputs) always start with i = 1 + // Check xap.xml if a BitUnused is present + for (unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++) { + eplMapping.mCurrentValues.pushBack(new EplMapping::EplMappingValues( + moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); + } + + delete moduleIOs; + eplStack.registerCallback(this); + + initOk = true; + } else { + DEVLOG_ERROR("[powerlink] No module IOs"); + } + } + + sendOutputEvent(scmEventINITOID, paECET); + } else if (paEIID == scmEventREQID) { + if (var_QI == true && initOk) { + sync.lock(); + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (TPortId i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it) { + short ioVal = 0x0000; + ioVal = *reinterpret_cast(it->mCurrentValue); + *static_cast(getDO(i)) = CIEC_INT(ioVal); + } + sync.unlock(); + } + var_QO = var_QI; + sendOutputEvent(scmEventCNFID, paECET); + } +} diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAI.h b/src/com/powerlink/fb/PowerlinkFunctionBlockAI.h new file mode 100644 index 00000000..30e23ccb --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAI.h @@ -0,0 +1,45 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#ifndef POWERLINKFUNCTIONBLOCKAI_H +#define POWERLINKFUNCTIONBLOCKAI_H + +#include "funcbloc.h" +#include "forte_sync.h" + +#include "EplCNCallback.h" +#include "EplWrapper.h" + +class PowerlinkFunctionBlockAI : public CFunctionBlock, public IEplCNCallback { + EplMapping eplMapping; + CSyncObject sync; + bool initOk; + + void cnSynchCallback() override; + + using CFunctionBlock::CFunctionBlock; + +protected: + void executePowerlinkEvent(TEventID paEIID, + CEventChainExecutionThread *paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID); +}; + + +#endif //POWERLINKFUNCTIONBLOCKAI_H diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAO.cpp b/src/com/powerlink/fb/PowerlinkFunctionBlockAO.cpp new file mode 100644 index 00000000..b247a5d7 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAO.cpp @@ -0,0 +1,87 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#include "PowerlinkFunctionBlockAO.h" + + +void PowerlinkFunctionBlockAO::cnSynchCallback() { + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + sync.lock(); + + const auto &procImageIn = eplStack.getProcImageIn(); + for (const auto &mappingValue : eplMapping.mCurrentValues) { + short ioVal = *reinterpret_cast(mappingValue->mCurrentValue); + char highByte = static_cast((ioVal & 0xFF00) >> 8); + char lowByte = static_cast(ioVal & 0x00FF); + + procImageIn[mappingValue->mPiOffset] &= ~(0xFF << mappingValue->mBitOffset); + procImageIn[mappingValue->mPiOffset] |= (lowByte << mappingValue->mBitOffset); + + procImageIn[mappingValue->mPiOffset + 1] &= ~(0xFF << mappingValue->mBitOffset); + procImageIn[mappingValue->mPiOffset + 1] |= (highByte << mappingValue->mBitOffset); + } + + sync.unlock(); +} + +void PowerlinkFunctionBlockAO::executePowerlinkEvent(const TEventID paEIID, + CEventChainExecutionThread *const paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID) { + if (paEIID == scmEventINITID) { + if (var_QI == true) { + initOk = false; + + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + + CProcessImageMatrix *moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries( + var_CNID.getUnsignedValue(), var_MODID.getUnsignedValue()); + + if (moduleIOs) { + // Outputs (process inputs) always start with i = 0 + // Check xap.xml if a BitUnused is present + for (unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++) { + eplMapping.mCurrentValues.pushBack(new EplMapping::EplMappingValues( + moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); + } + + delete moduleIOs; + eplStack.registerCallback(this); + + initOk = true; + } else { + DEVLOG_ERROR("[powerlink] No module IOs"); + } + } + + sendOutputEvent(scmEventINITOID, paECET); + } else if (paEIID == scmEventREQID) { + if (var_QI == true && initOk) { + sync.lock(); + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (TPortId i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it) { + short ioVal = static_cast(getDI(i))->getSignedValue(); + *reinterpret_cast(it->mCurrentValue) = ioVal; + } + sync.unlock(); + } + var_QO = var_QI; + sendOutputEvent(scmEventCNFID, paECET); + } +} diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAO.h b/src/com/powerlink/fb/PowerlinkFunctionBlockAO.h new file mode 100644 index 00000000..cf1e7de4 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAO.h @@ -0,0 +1,45 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#ifndef POWERLINKFUNCTIONBLOCKAO_H +#define POWERLINKFUNCTIONBLOCKAO_H + +#include "funcbloc.h" +#include "forte_sync.h" + +#include "EplCNCallback.h" +#include "EplWrapper.h" + +class PowerlinkFunctionBlockAO : public CFunctionBlock, public IEplCNCallback { + EplMapping eplMapping; + CSyncObject sync; + bool initOk; + + void cnSynchCallback() override; + + using CFunctionBlock::CFunctionBlock; + +protected: + void executePowerlinkEvent(TEventID paEIID, + CEventChainExecutionThread *paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID); +}; + + +#endif //POWERLINKFUNCTIONBLOCKAO_H diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAT.cpp b/src/com/powerlink/fb/PowerlinkFunctionBlockAT.cpp new file mode 100644 index 00000000..86426c76 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAT.cpp @@ -0,0 +1,87 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#include "PowerlinkFunctionBlockAT.h" + + +void PowerlinkFunctionBlockAT::cnSynchCallback() { + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + sync.lock(); + + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (; it != itEnd; ++it) { + short ioVal = 0x0000; + char lowByte; + char highByte; + lowByte = (eplStack.getProcImageOut()[it->mPiOffset] & (0xFF << it->mBitOffset)) >> it->mBitOffset; + highByte = (eplStack.getProcImageOut()[it->mPiOffset + 1] & (0xFF << it->mBitOffset)) >> it->mBitOffset; + ioVal = (short) ((0xFF00 & (highByte << 8))) | (short) (0xFF & lowByte); + + *((short *) (it->mCurrentValue)) = ioVal; + } + + sync.unlock(); +} + +void PowerlinkFunctionBlockAT::executePowerlinkEvent(const TEventID paEIID, + CEventChainExecutionThread *const paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID) { + if (paEIID == scmEventINITID) { + if (var_QI == true) { + initOk = false; + + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + + CProcessImageMatrix *moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries( + var_CNID.getUnsignedValue(), var_MODID.getUnsignedValue()); + + if (moduleIOs) { + // Inputs (process inputs) always start with i = 1 + // Check xap.xml if a BitUnused is present + for (unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++) { + eplMapping.mCurrentValues.pushBack(new EplMapping::EplMappingValues( + moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); + } + + delete moduleIOs; + eplStack.registerCallback(this); + + initOk = true; + } else { + DEVLOG_ERROR("[powerlink] No module IOs"); + } + } + + sendOutputEvent(scmEventINITOID, paECET); + } else if (paEIID == scmEventREQID) { + if (var_QI == true && initOk) { + sync.lock(); + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (TPortId i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it) { + short ioVal = *reinterpret_cast(it->mCurrentValue); + *static_cast(getDO(i)) = CIEC_REAL(ioVal / 10); + } + sync.unlock(); + } + var_QO = var_QI; + sendOutputEvent(scmEventCNFID, paECET); + } +} diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockAT.h b/src/com/powerlink/fb/PowerlinkFunctionBlockAT.h new file mode 100644 index 00000000..96664d5d --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockAT.h @@ -0,0 +1,45 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#ifndef POWERLINKFUNCTIONBLOCKAT_H +#define POWERLINKFUNCTIONBLOCKAT_H + +#include "funcbloc.h" +#include "forte_sync.h" + +#include "EplCNCallback.h" +#include "EplWrapper.h" + +class PowerlinkFunctionBlockAT : public CFunctionBlock, public IEplCNCallback { + EplMapping eplMapping; + CSyncObject sync; + bool initOk; + + void cnSynchCallback() override; + + using CFunctionBlock::CFunctionBlock; + +protected: + void executePowerlinkEvent(TEventID paEIID, + CEventChainExecutionThread *paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID); +}; + + +#endif //POWERLINKFUNCTIONBLOCKAT_H diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockDI.cpp b/src/com/powerlink/fb/PowerlinkFunctionBlockDI.cpp new file mode 100644 index 00000000..67dd2f93 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockDI.cpp @@ -0,0 +1,80 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#include "PowerlinkFunctionBlockDI.h" + + +void PowerlinkFunctionBlockDI::cnSynchCallback() { + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + sync.lock(); + + const auto &procImageOut = eplStack.getProcImageOut(); + for (const auto &mappingValue : eplMapping.mCurrentValues) { + bool ioVal = (procImageOut[mappingValue->mPiOffset] & static_cast(0x01 << mappingValue->mBitOffset)) != 0x00; + *(mappingValue->mCurrentValue) = static_cast(ioVal); + } + + sync.unlock(); +} + +void PowerlinkFunctionBlockDI::executePowerlinkEvent(const TEventID paEIID, + CEventChainExecutionThread *const paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID) { + if (paEIID == scmEventINITID) { + if (var_QI == true) { + initOk = false; + + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + + CProcessImageMatrix *moduleIOs = eplStack.getProcessImageMatrixOut()->getModuleEntries( + var_CNID.getUnsignedValue(), var_MODID.getUnsignedValue()); + + if (moduleIOs) { + // Inputs (process inputs) always start with i = 1 + // Check xap.xml if a BitUnused is present + for (unsigned int i = 1; i < moduleIOs->getNrOfEntries() - 1; i++) { + eplMapping.mCurrentValues.pushBack(new EplMapping::EplMappingValues( + moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); + } + + delete moduleIOs; + eplStack.registerCallback(this); + + initOk = true; + } else { + DEVLOG_ERROR("[powerlink] No module IOs"); + } + } + + sendOutputEvent(scmEventINITOID, paECET); + } else if (paEIID == scmEventREQID) { + if (var_QI == true && initOk) { + sync.lock(); + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (int i = 3; i < getFBInterfaceSpec().mNumDOs && it != itEnd; i++, ++it) { + bool ioVal = *(it->mCurrentValue) != 0x00; + *static_cast(getDO(i)) = CIEC_BOOL(ioVal); + } + sync.unlock(); + } + var_QO = var_QI; + sendOutputEvent(scmEventCNFID, paECET); + } +} diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockDI.h b/src/com/powerlink/fb/PowerlinkFunctionBlockDI.h new file mode 100644 index 00000000..09a0e3d5 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockDI.h @@ -0,0 +1,45 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#ifndef POWERLINKFUNCTIONBLOCKDI_H +#define POWERLINKFUNCTIONBLOCKDI_H + +#include "funcbloc.h" +#include "forte_sync.h" + +#include "EplCNCallback.h" +#include "EplWrapper.h" + +class PowerlinkFunctionBlockDI : public CFunctionBlock, public IEplCNCallback { + EplMapping eplMapping; + CSyncObject sync; + bool initOk; + + void cnSynchCallback() override; + + using CFunctionBlock::CFunctionBlock; + +protected: + void executePowerlinkEvent(TEventID paEIID, + CEventChainExecutionThread *paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID); +}; + + +#endif //POWERLINKFUNCTIONBLOCKDI_H diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockDO.cpp b/src/com/powerlink/fb/PowerlinkFunctionBlockDO.cpp new file mode 100644 index 00000000..0c136aae --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockDO.cpp @@ -0,0 +1,81 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#include "PowerlinkFunctionBlockDO.h" + + +void PowerlinkFunctionBlockDO::cnSynchCallback() { + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + sync.lock(); + + const auto &procImageIn = eplStack.getProcImageIn(); + for (const auto &mappingValue : eplMapping.mCurrentValues) { + bool ioVal = *(mappingValue->mCurrentValue) != 0x00; + procImageIn[mappingValue->mPiOffset] &= static_cast(~(0x01 << mappingValue->mBitOffset)); + procImageIn[mappingValue->mPiOffset] |= static_cast(ioVal << mappingValue->mBitOffset); + } + + sync.unlock(); +} + +void PowerlinkFunctionBlockDO::executePowerlinkEvent(const TEventID paEIID, + CEventChainExecutionThread *const paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID) { + if (paEIID == scmEventINITID) { + if (var_QI == true) { + initOk = false; + + CEplStackWrapper &eplStack = CEplStackWrapper::getInstance(); + + CProcessImageMatrix *moduleIOs = eplStack.getProcessImageMatrixIn()->getModuleEntries( + var_CNID.getUnsignedValue(), var_MODID.getUnsignedValue()); + + if (moduleIOs) { + // Outputs (process inputs) always start with i = 0 + // Check xap.xml if a BitUnused is present + for (unsigned int i = 0; i < moduleIOs->getNrOfEntries() - 1; i++) { + eplMapping.mCurrentValues.pushBack(new EplMapping::EplMappingValues( + moduleIOs->getEntry(i)[0], moduleIOs->getEntry(i)[1], moduleIOs->getEntry(i)[2])); + } + + delete moduleIOs; + eplStack.registerCallback(this); + + initOk = true; + } else { + DEVLOG_ERROR("[powerlink] No module IOs"); + } + } + + sendOutputEvent(scmEventINITOID, paECET); + } else if (paEIID == scmEventREQID) { + if (var_QI == true && initOk) { + sync.lock(); + EplMapping::TEplMappingList::Iterator itEnd = eplMapping.mCurrentValues.end(); + EplMapping::TEplMappingList::Iterator it = eplMapping.mCurrentValues.begin(); + for (int i = 3; i < getFBInterfaceSpec().mNumDIs && it != itEnd; i++, ++it) { + bool ioVal = *static_cast(getDI(i)); + *(it->mCurrentValue) = static_cast(ioVal); + } + sync.unlock(); + } + var_QO = var_QI; + sendOutputEvent(scmEventCNFID, paECET); + } +} diff --git a/src/com/powerlink/fb/PowerlinkFunctionBlockDO.h b/src/com/powerlink/fb/PowerlinkFunctionBlockDO.h new file mode 100644 index 00000000..4a997701 --- /dev/null +++ b/src/com/powerlink/fb/PowerlinkFunctionBlockDO.h @@ -0,0 +1,45 @@ +/******************************************************************************* +* Copyright (c) 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Michael Gafert - abstracted functions for better reusability + *******************************************************************************/ + +#ifndef POWERLINKFUNCTIONBLOCKDO_H +#define POWERLINKFUNCTIONBLOCKDO_H + +#include "funcbloc.h" +#include "forte_sync.h" + +#include "EplCNCallback.h" +#include "EplWrapper.h" + +class PowerlinkFunctionBlockDO : public CFunctionBlock, public IEplCNCallback { + EplMapping eplMapping; + CSyncObject sync; + bool initOk; + + void cnSynchCallback() override; + + using CFunctionBlock::CFunctionBlock; + +protected: + void executePowerlinkEvent(TEventID paEIID, + CEventChainExecutionThread *paECET, + TEventID scmEventINITID, + TEventID scmEventREQID, + TEventID scmEventINITOID, + TEventID scmEventCNFID, + const CIEC_BOOL &var_QI, + CIEC_BOOL &var_QO, + const CIEC_USINT &var_CNID, + const CIEC_UINT &var_MODID); +}; + + +#endif //POWERLINKFUNCTIONBLOCKDO_H diff --git a/src/com/powerlink/fb/X20AI2622_fbt.cpp b/src/com/powerlink/fb/X20AI2622_fbt.cpp new file mode 100644 index 00000000..50d445a3 --- /dev/null +++ b/src/com/powerlink/fb/X20AI2622_fbt.cpp @@ -0,0 +1,170 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20AI2622_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20AI2622_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20AI2622, g_nStringIdX20AI2622) + +const CStringDictionary::TStringId FORTE_X20AI2622::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20AI2622::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20AI2622::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdAI01, g_nStringIdAI02}; +const CStringDictionary::TStringId FORTE_X20AI2622::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdINT, g_nStringIdINT}; +const TDataIOID FORTE_X20AI2622::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AI2622::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AI2622::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20AI2622::scmEOWith[] = {0, 1, 2, scmWithListDelimiter, 2, 3, 4, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AI2622::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AI2622::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20AI2622::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 5, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20AI2622::FORTE_X20AI2622(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockAI(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_AI01(var_AI01), + var_conn_AI02(var_AI02), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_AI01(this, 3, &var_conn_AI01), + conn_AI02(this, 4, &var_conn_AI02) { +}; + +void FORTE_X20AI2622::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_AI01 = 0_INT; + var_AI02 = 0_INT; +} + +void FORTE_X20AI2622::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20AI2622::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20AI2622::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_CNIDO, conn_CNIDO); + writeData(2, var_STATUS, conn_STATUS); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(3, var_AI01, conn_AI01); + writeData(4, var_AI02, conn_AI02); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20AI2622::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20AI2622::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_AI01; + case 4: return &var_AI02; + } + return nullptr; +} + +CEventConnection *FORTE_X20AI2622::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20AI2622::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20AI2622::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_AI01; + case 4: return &conn_AI02; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20AI2622_fbt.h b/src/com/powerlink/fb/X20AI2622_fbt.h new file mode 100644 index 00000000..df7fd6fc --- /dev/null +++ b/src/com/powerlink/fb/X20AI2622_fbt.h @@ -0,0 +1,124 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockAI.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "forte_int.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20AI2622 final : public PowerlinkFunctionBlockAI { + DECLARE_FIRMWARE_FB(FORTE_X20AI2622) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20AI2622(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_INT var_AI01; + CIEC_INT var_AI02; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_INT var_conn_AI01; + CIEC_INT var_conn_AI02; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_AI01; + CDataConnection conn_AI02; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paAI01 = var_AI01; + paAI02 = var_AI02; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paAI01 = var_AI01; + paAI02 = var_AI02; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paAI01, paAI02); + } +}; + + diff --git a/src/com/powerlink/fb/X20AI4622_fbt.cpp b/src/com/powerlink/fb/X20AI4622_fbt.cpp new file mode 100644 index 00000000..1488ff23 --- /dev/null +++ b/src/com/powerlink/fb/X20AI4622_fbt.cpp @@ -0,0 +1,182 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20AI4622_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20AI4622_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20AI4622, g_nStringIdX20AI4622) + +const CStringDictionary::TStringId FORTE_X20AI4622::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20AI4622::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20AI4622::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdAI01, g_nStringIdAI02, g_nStringIdAI03, g_nStringIdAI04}; +const CStringDictionary::TStringId FORTE_X20AI4622::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT}; +const TDataIOID FORTE_X20AI4622::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AI4622::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AI4622::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20AI4622::scmEOWith[] = {0, 1, 2, scmWithListDelimiter, 2, 3, 4, 5, 6, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AI4622::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AI4622::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20AI4622::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 7, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20AI4622::FORTE_X20AI4622(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockAI(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_AI01(var_AI01), + var_conn_AI02(var_AI02), + var_conn_AI03(var_AI03), + var_conn_AI04(var_AI04), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_AI01(this, 3, &var_conn_AI01), + conn_AI02(this, 4, &var_conn_AI02), + conn_AI03(this, 5, &var_conn_AI03), + conn_AI04(this, 6, &var_conn_AI04) { +}; + +void FORTE_X20AI4622::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_AI01 = 0_INT; + var_AI02 = 0_INT; + var_AI03 = 0_INT; + var_AI04 = 0_INT; +} + +void FORTE_X20AI4622::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20AI4622::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20AI4622::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_CNIDO, conn_CNIDO); + writeData(2, var_STATUS, conn_STATUS); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(3, var_AI01, conn_AI01); + writeData(4, var_AI02, conn_AI02); + writeData(5, var_AI03, conn_AI03); + writeData(6, var_AI04, conn_AI04); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20AI4622::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20AI4622::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_AI01; + case 4: return &var_AI02; + case 5: return &var_AI03; + case 6: return &var_AI04; + } + return nullptr; +} + +CEventConnection *FORTE_X20AI4622::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20AI4622::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20AI4622::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_AI01; + case 4: return &conn_AI02; + case 5: return &conn_AI03; + case 6: return &conn_AI04; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20AI4622_fbt.h b/src/com/powerlink/fb/X20AI4622_fbt.h new file mode 100644 index 00000000..181add5c --- /dev/null +++ b/src/com/powerlink/fb/X20AI4622_fbt.h @@ -0,0 +1,134 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockAI.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "forte_int.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20AI4622 final : public PowerlinkFunctionBlockAI { + DECLARE_FIRMWARE_FB(FORTE_X20AI4622) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20AI4622(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_INT var_AI01; + CIEC_INT var_AI02; + CIEC_INT var_AI03; + CIEC_INT var_AI04; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_INT var_conn_AI01; + CIEC_INT var_conn_AI02; + CIEC_INT var_conn_AI03; + CIEC_INT var_conn_AI04; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_AI01; + CDataConnection conn_AI02; + CDataConnection conn_AI03; + CDataConnection conn_AI04; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02, CIEC_INT &paAI03, CIEC_INT &paAI04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paAI01 = var_AI01; + paAI02 = var_AI02; + paAI03 = var_AI03; + paAI04 = var_AI04; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02, CIEC_INT &paAI03, CIEC_INT &paAI04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paAI01 = var_AI01; + paAI02 = var_AI02; + paAI03 = var_AI03; + paAI04 = var_AI04; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_INT &paAI01, CIEC_INT &paAI02, CIEC_INT &paAI03, CIEC_INT &paAI04) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paAI01, paAI02, paAI03, paAI04); + } +}; + + diff --git a/src/com/powerlink/fb/X20AO4622_fbt.cpp b/src/com/powerlink/fb/X20AO4622_fbt.cpp new file mode 100644 index 00000000..c125a304 --- /dev/null +++ b/src/com/powerlink/fb/X20AO4622_fbt.cpp @@ -0,0 +1,178 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20AO4622_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20AO4622_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20AO4622, g_nStringIdX20AO4622) + +const CStringDictionary::TStringId FORTE_X20AO4622::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdAO01, g_nStringIdAO02, g_nStringIdAO03, g_nStringIdAO04}; +const CStringDictionary::TStringId FORTE_X20AO4622::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT, g_nStringIdINT}; +const CStringDictionary::TStringId FORTE_X20AO4622::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_X20AO4622::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING}; +const TDataIOID FORTE_X20AO4622::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AO4622::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AO4622::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20AO4622::scmEOWith[] = {0, 1, 2, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AO4622::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AO4622::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20AO4622::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 7, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20AO4622::FORTE_X20AO4622(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockAO(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_AO01(nullptr), + conn_AO02(nullptr), + conn_AO03(nullptr), + conn_AO04(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS) { +}; + +void FORTE_X20AO4622::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_AO01 = 0_INT; + var_AO02 = 0_INT; + var_AO03 = 0_INT; + var_AO04 = 0_INT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; +} + +void FORTE_X20AO4622::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20AO4622::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(3, var_AO01, conn_AO01); + readData(4, var_AO02, conn_AO02); + readData(5, var_AO03, conn_AO03); + readData(6, var_AO04, conn_AO04); + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20AO4622::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_CNIDO, conn_CNIDO); + writeData(2, var_STATUS, conn_STATUS); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20AO4622::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + case 3: return &var_AO01; + case 4: return &var_AO02; + case 5: return &var_AO03; + case 6: return &var_AO04; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20AO4622::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_X20AO4622::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20AO4622::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + case 3: return &conn_AO01; + case 4: return &conn_AO02; + case 5: return &conn_AO03; + case 6: return &conn_AO04; + } + return nullptr; +} + +CDataConnection *FORTE_X20AO4622::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20AO4622_fbt.h b/src/com/powerlink/fb/X20AO4622_fbt.h new file mode 100644 index 00000000..cb5f5c80 --- /dev/null +++ b/src/com/powerlink/fb/X20AO4622_fbt.h @@ -0,0 +1,130 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockAO.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_int.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20AO4622 final : public PowerlinkFunctionBlockAO { + DECLARE_FIRMWARE_FB(FORTE_X20AO4622) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20AO4622(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + CIEC_INT var_AO01; + CIEC_INT var_AO02; + CIEC_INT var_AO03; + CIEC_INT var_AO04; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + CDataConnection *conn_AO01; + CDataConnection *conn_AO02; + CDataConnection *conn_AO03; + CDataConnection *conn_AO04; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_INT &paAO01, const CIEC_INT &paAO02, const CIEC_INT &paAO03, const CIEC_INT &paAO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_AO01 = paAO01; + var_AO02 = paAO02; + var_AO03 = paAO03; + var_AO04 = paAO04; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_INT &paAO01, const CIEC_INT &paAO02, const CIEC_INT &paAO03, const CIEC_INT &paAO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_AO01 = paAO01; + var_AO02 = paAO02; + var_AO03 = paAO03; + var_AO04 = paAO04; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_INT &paAO01, const CIEC_INT &paAO02, const CIEC_INT &paAO03, const CIEC_INT &paAO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCNID, paMODID, paAO01, paAO02, paAO03, paAO04, paQO, paCNIDO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/fb/X20AT2402_fbt.cpp b/src/com/powerlink/fb/X20AT2402_fbt.cpp new file mode 100644 index 00000000..435543e8 --- /dev/null +++ b/src/com/powerlink/fb/X20AT2402_fbt.cpp @@ -0,0 +1,170 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20AT2402_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20AT2402_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20AT2402, g_nStringIdX20AT2402) + +const CStringDictionary::TStringId FORTE_X20AT2402::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20AT2402::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20AT2402::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02}; +const CStringDictionary::TStringId FORTE_X20AT2402::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL}; +const TDataIOID FORTE_X20AT2402::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AT2402::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AT2402::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20AT2402::scmEOWith[] = {0, 1, 2, scmWithListDelimiter, 2, 3, 4, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AT2402::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AT2402::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20AT2402::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 5, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20AT2402::FORTE_X20AT2402(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockAT(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_T01(var_T01), + var_conn_T02(var_T02), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_T01(this, 3, &var_conn_T01), + conn_T02(this, 4, &var_conn_T02) { +}; + +void FORTE_X20AT2402::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_T01 = 0_REAL; + var_T02 = 0_REAL; +} + +void FORTE_X20AT2402::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20AT2402::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20AT2402::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_CNIDO, conn_CNIDO); + writeData(2, var_STATUS, conn_STATUS); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(3, var_T01, conn_T01); + writeData(4, var_T02, conn_T02); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20AT2402::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20AT2402::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_T01; + case 4: return &var_T02; + } + return nullptr; +} + +CEventConnection *FORTE_X20AT2402::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20AT2402::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20AT2402::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_T01; + case 4: return &conn_T02; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20AT2402_fbt.h b/src/com/powerlink/fb/X20AT2402_fbt.h new file mode 100644 index 00000000..38534951 --- /dev/null +++ b/src/com/powerlink/fb/X20AT2402_fbt.h @@ -0,0 +1,124 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockAT.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "forte_real.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20AT2402 final : public PowerlinkFunctionBlockAT { + DECLARE_FIRMWARE_FB(FORTE_X20AT2402) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20AT2402(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_REAL var_T01; + CIEC_REAL var_T02; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_REAL var_conn_T01; + CIEC_REAL var_conn_T02; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_T01; + CDataConnection conn_T02; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paT01 = var_T01; + paT02 = var_T02; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paT01 = var_T01; + paT02 = var_T02; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paT01, paT02); + } +}; + + diff --git a/src/com/powerlink/fb/X20AT4222_fbt.cpp b/src/com/powerlink/fb/X20AT4222_fbt.cpp new file mode 100644 index 00000000..5fb16490 --- /dev/null +++ b/src/com/powerlink/fb/X20AT4222_fbt.cpp @@ -0,0 +1,182 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20AT4222_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20AT4222_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20AT4222, g_nStringIdX20AT4222) + +const CStringDictionary::TStringId FORTE_X20AT4222::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20AT4222::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20AT4222::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdT01, g_nStringIdT02, g_nStringIdT03, g_nStringIdT04}; +const CStringDictionary::TStringId FORTE_X20AT4222::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL, g_nStringIdREAL}; +const TDataIOID FORTE_X20AT4222::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AT4222::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AT4222::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20AT4222::scmEOWith[] = {0, 1, 2, scmWithListDelimiter, 2, 3, 4, 0, 5, 6, scmWithListDelimiter}; +const TForteInt16 FORTE_X20AT4222::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20AT4222::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20AT4222::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 7, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20AT4222::FORTE_X20AT4222(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockAT(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_T01(var_T01), + var_conn_T02(var_T02), + var_conn_T03(var_T03), + var_conn_T04(var_T04), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_T01(this, 3, &var_conn_T01), + conn_T02(this, 4, &var_conn_T02), + conn_T03(this, 5, &var_conn_T03), + conn_T04(this, 6, &var_conn_T04) { +}; + +void FORTE_X20AT4222::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_T01 = 0_REAL; + var_T02 = 0_REAL; + var_T03 = 0_REAL; + var_T04 = 0_REAL; +} + +void FORTE_X20AT4222::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20AT4222::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20AT4222::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_CNIDO, conn_CNIDO); + writeData(2, var_STATUS, conn_STATUS); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(3, var_T01, conn_T01); + writeData(4, var_T02, conn_T02); + writeData(0, var_QO, conn_QO); + writeData(5, var_T03, conn_T03); + writeData(6, var_T04, conn_T04); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20AT4222::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20AT4222::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_T01; + case 4: return &var_T02; + case 5: return &var_T03; + case 6: return &var_T04; + } + return nullptr; +} + +CEventConnection *FORTE_X20AT4222::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20AT4222::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20AT4222::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_T01; + case 4: return &conn_T02; + case 5: return &conn_T03; + case 6: return &conn_T04; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20AT4222_fbt.h b/src/com/powerlink/fb/X20AT4222_fbt.h new file mode 100644 index 00000000..52cf2045 --- /dev/null +++ b/src/com/powerlink/fb/X20AT4222_fbt.h @@ -0,0 +1,134 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockAT.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "forte_real.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20AT4222 final : public PowerlinkFunctionBlockAT { + DECLARE_FIRMWARE_FB(FORTE_X20AT4222) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20AT4222(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_REAL var_T01; + CIEC_REAL var_T02; + CIEC_REAL var_T03; + CIEC_REAL var_T04; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_REAL var_conn_T01; + CIEC_REAL var_conn_T02; + CIEC_REAL var_conn_T03; + CIEC_REAL var_conn_T04; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_T01; + CDataConnection conn_T02; + CDataConnection conn_T03; + CDataConnection conn_T04; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02, CIEC_REAL &paT03, CIEC_REAL &paT04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paT01 = var_T01; + paT02 = var_T02; + paT03 = var_T03; + paT04 = var_T04; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02, CIEC_REAL &paT03, CIEC_REAL &paT04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paT01 = var_T01; + paT02 = var_T02; + paT03 = var_T03; + paT04 = var_T04; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_REAL &paT01, CIEC_REAL &paT02, CIEC_REAL &paT03, CIEC_REAL &paT04) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paT01, paT02, paT03, paT04); + } +}; + + diff --git a/src/com/powerlink/fb/X20DI4653_fbt.cpp b/src/com/powerlink/fb/X20DI4653_fbt.cpp new file mode 100644 index 00000000..c6910e99 --- /dev/null +++ b/src/com/powerlink/fb/X20DI4653_fbt.cpp @@ -0,0 +1,182 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DI4653_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DI4653_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DI4653, g_nStringIdX20DI4653) + +const CStringDictionary::TStringId FORTE_X20DI4653::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20DI4653::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20DI4653::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04}; +const CStringDictionary::TStringId FORTE_X20DI4653::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; +const TDataIOID FORTE_X20DI4653::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DI4653::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI4653::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DI4653::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DI4653::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI4653::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DI4653::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 7, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DI4653::FORTE_X20DI4653(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockDI(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_DI01(var_DI01), + var_conn_DI02(var_DI02), + var_conn_DI03(var_DI03), + var_conn_DI04(var_DI04), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_DI01(this, 3, &var_conn_DI01), + conn_DI02(this, 4, &var_conn_DI02), + conn_DI03(this, 5, &var_conn_DI03), + conn_DI04(this, 6, &var_conn_DI04) { +}; + +void FORTE_X20DI4653::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_DI01 = 0_BOOL; + var_DI02 = 0_BOOL; + var_DI03 = 0_BOOL; + var_DI04 = 0_BOOL; +} + +void FORTE_X20DI4653::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DI4653::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DI4653::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: { + writeData(3, var_DI01, conn_DI01); + writeData(4, var_DI02, conn_DI02); + writeData(5, var_DI03, conn_DI03); + writeData(6, var_DI04, conn_DI04); + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20DI4653::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20DI4653::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_DI01; + case 4: return &var_DI02; + case 5: return &var_DI03; + case 6: return &var_DI04; + } + return nullptr; +} + +CEventConnection *FORTE_X20DI4653::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20DI4653::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20DI4653::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_DI01; + case 4: return &conn_DI02; + case 5: return &conn_DI03; + case 6: return &conn_DI04; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20DI4653_fbt.h b/src/com/powerlink/fb/X20DI4653_fbt.h new file mode 100644 index 00000000..0a37f64d --- /dev/null +++ b/src/com/powerlink/fb/X20DI4653_fbt.h @@ -0,0 +1,133 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDI.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20DI4653 final : public PowerlinkFunctionBlockDI { + DECLARE_FIRMWARE_FB(FORTE_X20DI4653) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DI4653(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_BOOL var_DI01; + CIEC_BOOL var_DI02; + CIEC_BOOL var_DI03; + CIEC_BOOL var_DI04; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_BOOL var_conn_DI01; + CIEC_BOOL var_conn_DI02; + CIEC_BOOL var_conn_DI03; + CIEC_BOOL var_conn_DI04; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_DI01; + CDataConnection conn_DI02; + CDataConnection conn_DI03; + CDataConnection conn_DI04; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paDI01, paDI02, paDI03, paDI04); + } +}; + + diff --git a/src/com/powerlink/fb/X20DI9371_fbt.cpp b/src/com/powerlink/fb/X20DI9371_fbt.cpp new file mode 100644 index 00000000..f254b5c3 --- /dev/null +++ b/src/com/powerlink/fb/X20DI9371_fbt.cpp @@ -0,0 +1,264 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DI9371_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DI9371_fbt_gen.cpp" +#endif + +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DI9371, g_nStringIdX20DI9371) + +const CStringDictionary::TStringId FORTE_X20DI9371::scmDataInputNames[] = { + g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID +}; +const CStringDictionary::TStringId FORTE_X20DI9371::scmDataInputTypeIds[] = { + g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT +}; +const CStringDictionary::TStringId FORTE_X20DI9371::scmDataOutputNames[] = { + g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, + g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, + g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12 +}; +const CStringDictionary::TStringId FORTE_X20DI9371::scmDataOutputTypeIds[] = { + g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, + g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, + g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL +}; +const TDataIOID FORTE_X20DI9371::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DI9371::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI9371::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DI9371::scmEOWith[] = { + 0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, scmWithListDelimiter +}; +const TForteInt16 FORTE_X20DI9371::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI9371::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DI9371::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 15, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DI9371::FORTE_X20DI9371(const CStringDictionary::TStringId paInstanceNameId, + forte::core::CFBContainer& paContainer) : PowerlinkFunctionBlockDI(paContainer, + scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_DI01(var_DI01), + var_conn_DI02(var_DI02), + var_conn_DI03(var_DI03), + var_conn_DI04(var_DI04), + var_conn_DI05(var_DI05), + var_conn_DI06(var_DI06), + var_conn_DI07(var_DI07), + var_conn_DI08(var_DI08), + var_conn_DI09(var_DI09), + var_conn_DI10(var_DI10), + var_conn_DI11(var_DI11), + var_conn_DI12(var_DI12), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_DI01(this, 3, &var_conn_DI01), + conn_DI02(this, 4, &var_conn_DI02), + conn_DI03(this, 5, &var_conn_DI03), + conn_DI04(this, 6, &var_conn_DI04), + conn_DI05(this, 7, &var_conn_DI05), + conn_DI06(this, 8, &var_conn_DI06), + conn_DI07(this, 9, &var_conn_DI07), + conn_DI08(this, 10, &var_conn_DI08), + conn_DI09(this, 11, &var_conn_DI09), + conn_DI10(this, 12, &var_conn_DI10), + conn_DI11(this, 13, &var_conn_DI11), + conn_DI12(this, 14, &var_conn_DI12) +{ +}; + +void FORTE_X20DI9371::setInitialValues() +{ + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_DI01 = 0_BOOL; + var_DI02 = 0_BOOL; + var_DI03 = 0_BOOL; + var_DI04 = 0_BOOL; + var_DI05 = 0_BOOL; + var_DI06 = 0_BOOL; + var_DI07 = 0_BOOL; + var_DI08 = 0_BOOL; + var_DI09 = 0_BOOL; + var_DI10 = 0_BOOL; + var_DI11 = 0_BOOL; + var_DI12 = 0_BOOL; +} + +void FORTE_X20DI9371::executeEvent(const TEventID paEIID, CEventChainExecutionThread* const paECET) +{ + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DI9371::readInputData(const TEventID paEIID) +{ + switch (paEIID) + { + case scmEventINITID: + { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: + { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DI9371::writeOutputData(const TEventID paEIID) +{ + switch (paEIID) + { + case scmEventINITOID: + { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: + { + writeData(3, var_DI01, conn_DI01); + writeData(4, var_DI02, conn_DI02); + writeData(5, var_DI03, conn_DI03); + writeData(6, var_DI04, conn_DI04); + writeData(7, var_DI05, conn_DI05); + writeData(8, var_DI06, conn_DI06); + writeData(9, var_DI07, conn_DI07); + writeData(10, var_DI08, conn_DI08); + writeData(11, var_DI09, conn_DI09); + writeData(12, var_DI10, conn_DI10); + writeData(13, var_DI11, conn_DI11); + writeData(14, var_DI12, conn_DI12); + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY* FORTE_X20DI9371::getDI(const size_t paIndex) +{ + switch (paIndex) + { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY* FORTE_X20DI9371::getDO(const size_t paIndex) +{ + switch (paIndex) + { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_DI01; + case 4: return &var_DI02; + case 5: return &var_DI03; + case 6: return &var_DI04; + case 7: return &var_DI05; + case 8: return &var_DI06; + case 9: return &var_DI07; + case 10: return &var_DI08; + case 11: return &var_DI09; + case 12: return &var_DI10; + case 13: return &var_DI11; + case 14: return &var_DI12; + } + return nullptr; +} + +CEventConnection* FORTE_X20DI9371::getEOConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection** FORTE_X20DI9371::getDIConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection* FORTE_X20DI9371::getDOConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_DI01; + case 4: return &conn_DI02; + case 5: return &conn_DI03; + case 6: return &conn_DI04; + case 7: return &conn_DI05; + case 8: return &conn_DI06; + case 9: return &conn_DI07; + case 10: return &conn_DI08; + case 11: return &conn_DI09; + case 12: return &conn_DI10; + case 13: return &conn_DI11; + case 14: return &conn_DI12; + } + return nullptr; +} diff --git a/src/com/powerlink/fb/X20DI9371_fbt.h b/src/com/powerlink/fb/X20DI9371_fbt.h new file mode 100644 index 00000000..d0cea2cd --- /dev/null +++ b/src/com/powerlink/fb/X20DI9371_fbt.h @@ -0,0 +1,188 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDI.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" +#include "forte_sync.h" + + +class FORTE_X20DI9371 final : public PowerlinkFunctionBlockDI { + DECLARE_FIRMWARE_FB(FORTE_X20DI9371) + +private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + + void writeOutputData(TEventID paEIID) override; + + void setInitialValues() override; + +public: + FORTE_X20DI9371(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_BOOL var_DI01; + CIEC_BOOL var_DI02; + CIEC_BOOL var_DI03; + CIEC_BOOL var_DI04; + CIEC_BOOL var_DI05; + CIEC_BOOL var_DI06; + CIEC_BOOL var_DI07; + CIEC_BOOL var_DI08; + CIEC_BOOL var_DI09; + CIEC_BOOL var_DI10; + CIEC_BOOL var_DI11; + CIEC_BOOL var_DI12; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_BOOL var_conn_DI01; + CIEC_BOOL var_conn_DI02; + CIEC_BOOL var_conn_DI03; + CIEC_BOOL var_conn_DI04; + CIEC_BOOL var_conn_DI05; + CIEC_BOOL var_conn_DI06; + CIEC_BOOL var_conn_DI07; + CIEC_BOOL var_conn_DI08; + CIEC_BOOL var_conn_DI09; + CIEC_BOOL var_conn_DI10; + CIEC_BOOL var_conn_DI11; + CIEC_BOOL var_conn_DI12; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_DI01; + CDataConnection conn_DI02; + CDataConnection conn_DI03; + CDataConnection conn_DI04; + CDataConnection conn_DI05; + CDataConnection conn_DI06; + CDataConnection conn_DI07; + CDataConnection conn_DI08; + CDataConnection conn_DI09; + CDataConnection conn_DI10; + CDataConnection conn_DI11; + CDataConnection conn_DI12; + + CIEC_ANY *getDI(size_t) override; + + CIEC_ANY *getDO(size_t) override; + + CEventConnection *getEOConUnchecked(TPortId) override; + + CDataConnection **getDIConUnchecked(TPortId) override; + + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, + CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, + CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, + CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + paDI05 = var_DI05; + paDI06 = var_DI06; + paDI07 = var_DI07; + paDI08 = var_DI08; + paDI09 = var_DI09; + paDI10 = var_DI10; + paDI11 = var_DI11; + paDI12 = var_DI12; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, + CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, + CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, + CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + paDI05 = var_DI05; + paDI06 = var_DI06; + paDI07 = var_DI07; + paDI08 = var_DI08; + paDI09 = var_DI09; + paDI10 = var_DI10; + paDI11 = var_DI11; + paDI12 = var_DI12; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, + CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, + CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, + CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paDI01, paDI02, paDI03, paDI04, paDI05, paDI06, paDI07, + paDI08, paDI09, paDI10, paDI11, paDI12); + } +}; diff --git a/src/com/powerlink/fb/X20DI9372_fbt.cpp b/src/com/powerlink/fb/X20DI9372_fbt.cpp new file mode 100644 index 00000000..0fa05f70 --- /dev/null +++ b/src/com/powerlink/fb/X20DI9372_fbt.cpp @@ -0,0 +1,230 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DI9372_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DI9372_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DI9372, g_nStringIdX20DI9372) + +const CStringDictionary::TStringId FORTE_X20DI9372::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID}; +const CStringDictionary::TStringId FORTE_X20DI9372::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT}; +const CStringDictionary::TStringId FORTE_X20DI9372::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS, g_nStringIdDI01, g_nStringIdDI02, g_nStringIdDI03, g_nStringIdDI04, g_nStringIdDI05, g_nStringIdDI06, g_nStringIdDI07, g_nStringIdDI08, g_nStringIdDI09, g_nStringIdDI10, g_nStringIdDI11, g_nStringIdDI12}; +const CStringDictionary::TStringId FORTE_X20DI9372::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; +const TDataIOID FORTE_X20DI9372::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DI9372::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI9372::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DI9372::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DI9372::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DI9372::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DI9372::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 3, scmDataInputNames, scmDataInputTypeIds, + 15, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DI9372::FORTE_X20DI9372(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockDI(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + var_conn_DI01(var_DI01), + var_conn_DI02(var_DI02), + var_conn_DI03(var_DI03), + var_conn_DI04(var_DI04), + var_conn_DI05(var_DI05), + var_conn_DI06(var_DI06), + var_conn_DI07(var_DI07), + var_conn_DI08(var_DI08), + var_conn_DI09(var_DI09), + var_conn_DI10(var_DI10), + var_conn_DI11(var_DI11), + var_conn_DI12(var_DI12), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS), + conn_DI01(this, 3, &var_conn_DI01), + conn_DI02(this, 4, &var_conn_DI02), + conn_DI03(this, 5, &var_conn_DI03), + conn_DI04(this, 6, &var_conn_DI04), + conn_DI05(this, 7, &var_conn_DI05), + conn_DI06(this, 8, &var_conn_DI06), + conn_DI07(this, 9, &var_conn_DI07), + conn_DI08(this, 10, &var_conn_DI08), + conn_DI09(this, 11, &var_conn_DI09), + conn_DI10(this, 12, &var_conn_DI10), + conn_DI11(this, 13, &var_conn_DI11), + conn_DI12(this, 14, &var_conn_DI12) { +}; + +void FORTE_X20DI9372::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; + var_DI01 = 0_BOOL; + var_DI02 = 0_BOOL; + var_DI03 = 0_BOOL; + var_DI04 = 0_BOOL; + var_DI05 = 0_BOOL; + var_DI06 = 0_BOOL; + var_DI07 = 0_BOOL; + var_DI08 = 0_BOOL; + var_DI09 = 0_BOOL; + var_DI10 = 0_BOOL; + var_DI11 = 0_BOOL; + var_DI12 = 0_BOOL; +} + +void FORTE_X20DI9372::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DI9372::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DI9372::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: { + writeData(3, var_DI01, conn_DI01); + writeData(4, var_DI02, conn_DI02); + writeData(5, var_DI03, conn_DI03); + writeData(6, var_DI04, conn_DI04); + writeData(7, var_DI05, conn_DI05); + writeData(8, var_DI06, conn_DI06); + writeData(9, var_DI07, conn_DI07); + writeData(10, var_DI08, conn_DI08); + writeData(11, var_DI09, conn_DI09); + writeData(12, var_DI10, conn_DI10); + writeData(13, var_DI11, conn_DI11); + writeData(14, var_DI12, conn_DI12); + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20DI9372::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20DI9372::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + case 3: return &var_DI01; + case 4: return &var_DI02; + case 5: return &var_DI03; + case 6: return &var_DI04; + case 7: return &var_DI05; + case 8: return &var_DI06; + case 9: return &var_DI07; + case 10: return &var_DI08; + case 11: return &var_DI09; + case 12: return &var_DI10; + case 13: return &var_DI11; + case 14: return &var_DI12; + } + return nullptr; +} + +CEventConnection *FORTE_X20DI9372::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20DI9372::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + } + return nullptr; +} + +CDataConnection *FORTE_X20DI9372::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + case 3: return &conn_DI01; + case 4: return &conn_DI02; + case 5: return &conn_DI03; + case 6: return &conn_DI04; + case 7: return &conn_DI05; + case 8: return &conn_DI06; + case 9: return &conn_DI07; + case 10: return &conn_DI08; + case 11: return &conn_DI09; + case 12: return &conn_DI10; + case 13: return &conn_DI11; + case 14: return &conn_DI12; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20DI9372_fbt.h b/src/com/powerlink/fb/X20DI9372_fbt.h new file mode 100644 index 00000000..cc918126 --- /dev/null +++ b/src/com/powerlink/fb/X20DI9372_fbt.h @@ -0,0 +1,173 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDI.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20DI9372 final : public PowerlinkFunctionBlockDI { + DECLARE_FIRMWARE_FB(FORTE_X20DI9372) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DI9372(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + CIEC_BOOL var_DI01; + CIEC_BOOL var_DI02; + CIEC_BOOL var_DI03; + CIEC_BOOL var_DI04; + CIEC_BOOL var_DI05; + CIEC_BOOL var_DI06; + CIEC_BOOL var_DI07; + CIEC_BOOL var_DI08; + CIEC_BOOL var_DI09; + CIEC_BOOL var_DI10; + CIEC_BOOL var_DI11; + CIEC_BOOL var_DI12; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + CIEC_BOOL var_conn_DI01; + CIEC_BOOL var_conn_DI02; + CIEC_BOOL var_conn_DI03; + CIEC_BOOL var_conn_DI04; + CIEC_BOOL var_conn_DI05; + CIEC_BOOL var_conn_DI06; + CIEC_BOOL var_conn_DI07; + CIEC_BOOL var_conn_DI08; + CIEC_BOOL var_conn_DI09; + CIEC_BOOL var_conn_DI10; + CIEC_BOOL var_conn_DI11; + CIEC_BOOL var_conn_DI12; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + CDataConnection conn_DI01; + CDataConnection conn_DI02; + CDataConnection conn_DI03; + CDataConnection conn_DI04; + CDataConnection conn_DI05; + CDataConnection conn_DI06; + CDataConnection conn_DI07; + CDataConnection conn_DI08; + CDataConnection conn_DI09; + CDataConnection conn_DI10; + CDataConnection conn_DI11; + CDataConnection conn_DI12; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + paDI05 = var_DI05; + paDI06 = var_DI06; + paDI07 = var_DI07; + paDI08 = var_DI08; + paDI09 = var_DI09; + paDI10 = var_DI10; + paDI11 = var_DI11; + paDI12 = var_DI12; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + paDI01 = var_DI01; + paDI02 = var_DI02; + paDI03 = var_DI03; + paDI04 = var_DI04; + paDI05 = var_DI05; + paDI06 = var_DI06; + paDI07 = var_DI07; + paDI08 = var_DI08; + paDI09 = var_DI09; + paDI10 = var_DI10; + paDI11 = var_DI11; + paDI12 = var_DI12; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS, CIEC_BOOL &paDI01, CIEC_BOOL &paDI02, CIEC_BOOL &paDI03, CIEC_BOOL &paDI04, CIEC_BOOL &paDI05, CIEC_BOOL &paDI06, CIEC_BOOL &paDI07, CIEC_BOOL &paDI08, CIEC_BOOL &paDI09, CIEC_BOOL &paDI10, CIEC_BOOL &paDI11, CIEC_BOOL &paDI12) { + evt_INIT(paQI, paCNID, paMODID, paQO, paCNIDO, paSTATUS, paDI01, paDI02, paDI03, paDI04, paDI05, paDI06, paDI07, paDI08, paDI09, paDI10, paDI11, paDI12); + } +}; + + diff --git a/src/com/powerlink/fb/X20DO4623_fbt.cpp b/src/com/powerlink/fb/X20DO4623_fbt.cpp new file mode 100644 index 00000000..66c5d2fb --- /dev/null +++ b/src/com/powerlink/fb/X20DO4623_fbt.cpp @@ -0,0 +1,178 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DO4623_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DO4623_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DO4623, g_nStringIdX20DO4623) + +const CStringDictionary::TStringId FORTE_X20DO4623::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04}; +const CStringDictionary::TStringId FORTE_X20DO4623::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; +const CStringDictionary::TStringId FORTE_X20DO4623::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_X20DO4623::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING}; +const TDataIOID FORTE_X20DO4623::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO4623::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO4623::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DO4623::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO4623::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO4623::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DO4623::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 7, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DO4623::FORTE_X20DO4623(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockDO(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_DO01(nullptr), + conn_DO02(nullptr), + conn_DO03(nullptr), + conn_DO04(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS) { +}; + +void FORTE_X20DO4623::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_DO01 = 0_BOOL; + var_DO02 = 0_BOOL; + var_DO03 = 0_BOOL; + var_DO04 = 0_BOOL; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; +} + +void FORTE_X20DO4623::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DO4623::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(3, var_DO01, conn_DO01); + readData(4, var_DO02, conn_DO02); + readData(5, var_DO03, conn_DO03); + readData(6, var_DO04, conn_DO04); + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DO4623::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20DO4623::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + case 3: return &var_DO01; + case 4: return &var_DO02; + case 5: return &var_DO03; + case 6: return &var_DO04; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20DO4623::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_X20DO4623::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20DO4623::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + case 3: return &conn_DO01; + case 4: return &conn_DO02; + case 5: return &conn_DO03; + case 6: return &conn_DO04; + } + return nullptr; +} + +CDataConnection *FORTE_X20DO4623::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20DO4623_fbt.h b/src/com/powerlink/fb/X20DO4623_fbt.h new file mode 100644 index 00000000..d1f21883 --- /dev/null +++ b/src/com/powerlink/fb/X20DO4623_fbt.h @@ -0,0 +1,129 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDO.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20DO4623 final : public PowerlinkFunctionBlockDO { + DECLARE_FIRMWARE_FB(FORTE_X20DO4623) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DO4623(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + CIEC_BOOL var_DO01; + CIEC_BOOL var_DO02; + CIEC_BOOL var_DO03; + CIEC_BOOL var_DO04; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + CDataConnection *conn_DO01; + CDataConnection *conn_DO02; + CDataConnection *conn_DO03; + CDataConnection *conn_DO04; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCNID, paMODID, paDO01, paDO02, paDO03, paDO04, paQO, paCNIDO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/fb/X20DO4649_fbt.cpp b/src/com/powerlink/fb/X20DO4649_fbt.cpp new file mode 100644 index 00000000..aa89fece --- /dev/null +++ b/src/com/powerlink/fb/X20DO4649_fbt.cpp @@ -0,0 +1,178 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DO4649_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DO4649_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DO4649, g_nStringIdX20DO4649) + +const CStringDictionary::TStringId FORTE_X20DO4649::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04}; +const CStringDictionary::TStringId FORTE_X20DO4649::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; +const CStringDictionary::TStringId FORTE_X20DO4649::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_X20DO4649::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING}; +const TDataIOID FORTE_X20DO4649::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO4649::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO4649::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DO4649::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO4649::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO4649::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DO4649::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 7, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DO4649::FORTE_X20DO4649(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockDO(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_DO01(nullptr), + conn_DO02(nullptr), + conn_DO03(nullptr), + conn_DO04(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS) { +}; + +void FORTE_X20DO4649::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_DO01 = 0_BOOL; + var_DO02 = 0_BOOL; + var_DO03 = 0_BOOL; + var_DO04 = 0_BOOL; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; +} + +void FORTE_X20DO4649::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DO4649::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(3, var_DO01, conn_DO01); + readData(4, var_DO02, conn_DO02); + readData(5, var_DO03, conn_DO03); + readData(6, var_DO04, conn_DO04); + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DO4649::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20DO4649::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + case 3: return &var_DO01; + case 4: return &var_DO02; + case 5: return &var_DO03; + case 6: return &var_DO04; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20DO4649::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_X20DO4649::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20DO4649::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + case 3: return &conn_DO01; + case 4: return &conn_DO02; + case 5: return &conn_DO03; + case 6: return &conn_DO04; + } + return nullptr; +} + +CDataConnection *FORTE_X20DO4649::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20DO4649_fbt.h b/src/com/powerlink/fb/X20DO4649_fbt.h new file mode 100644 index 00000000..c71b8e99 --- /dev/null +++ b/src/com/powerlink/fb/X20DO4649_fbt.h @@ -0,0 +1,129 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDO.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20DO4649 final : public PowerlinkFunctionBlockDO { + DECLARE_FIRMWARE_FB(FORTE_X20DO4649) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DO4649(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + CIEC_BOOL var_DO01; + CIEC_BOOL var_DO02; + CIEC_BOOL var_DO03; + CIEC_BOOL var_DO04; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + CDataConnection *conn_DO01; + CDataConnection *conn_DO02; + CDataConnection *conn_DO03; + CDataConnection *conn_DO04; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCNID, paMODID, paDO01, paDO02, paDO03, paDO04, paQO, paCNIDO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/fb/X20DO9321_fbt.cpp b/src/com/powerlink/fb/X20DO9321_fbt.cpp new file mode 100644 index 00000000..1b6a8ebe --- /dev/null +++ b/src/com/powerlink/fb/X20DO9321_fbt.cpp @@ -0,0 +1,218 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DO9321_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DO9321_fbt_gen.cpp" +#endif + +#include "criticalregion.h" +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DO9321, g_nStringIdX20DO9321) + +const CStringDictionary::TStringId FORTE_X20DO9321::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12}; +const CStringDictionary::TStringId FORTE_X20DO9321::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL}; +const CStringDictionary::TStringId FORTE_X20DO9321::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_X20DO9321::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING}; +const TDataIOID FORTE_X20DO9321::scmEIWith[] = {0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO9321::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO9321::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DO9321::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO9321::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO9321::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DO9321::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 15, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DO9321::FORTE_X20DO9321(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + PowerlinkFunctionBlockDO(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_DO01(nullptr), + conn_DO02(nullptr), + conn_DO03(nullptr), + conn_DO04(nullptr), + conn_DO05(nullptr), + conn_DO06(nullptr), + conn_DO07(nullptr), + conn_DO08(nullptr), + conn_DO09(nullptr), + conn_DO10(nullptr), + conn_DO11(nullptr), + conn_DO12(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS) { +}; + +void FORTE_X20DO9321::setInitialValues() { + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_DO01 = 0_BOOL; + var_DO02 = 0_BOOL; + var_DO03 = 0_BOOL; + var_DO04 = 0_BOOL; + var_DO05 = 0_BOOL; + var_DO06 = 0_BOOL; + var_DO07 = 0_BOOL; + var_DO08 = 0_BOOL; + var_DO09 = 0_BOOL; + var_DO10 = 0_BOOL; + var_DO11 = 0_BOOL; + var_DO12 = 0_BOOL; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; +} + +void FORTE_X20DO9321::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DO9321::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: { + readData(3, var_DO01, conn_DO01); + readData(4, var_DO02, conn_DO02); + readData(5, var_DO03, conn_DO03); + readData(6, var_DO04, conn_DO04); + readData(7, var_DO05, conn_DO05); + readData(8, var_DO06, conn_DO06); + readData(9, var_DO07, conn_DO07); + readData(10, var_DO08, conn_DO08); + readData(11, var_DO09, conn_DO09); + readData(12, var_DO10, conn_DO10); + readData(13, var_DO11, conn_DO11); + readData(14, var_DO12, conn_DO12); + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DO9321::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: { + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_X20DO9321::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + case 3: return &var_DO01; + case 4: return &var_DO02; + case 5: return &var_DO03; + case 6: return &var_DO04; + case 7: return &var_DO05; + case 8: return &var_DO06; + case 9: return &var_DO07; + case 10: return &var_DO08; + case 11: return &var_DO09; + case 12: return &var_DO10; + case 13: return &var_DO11; + case 14: return &var_DO12; + } + return nullptr; +} + +CIEC_ANY *FORTE_X20DO9321::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_X20DO9321::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection **FORTE_X20DO9321::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + case 3: return &conn_DO01; + case 4: return &conn_DO02; + case 5: return &conn_DO03; + case 6: return &conn_DO04; + case 7: return &conn_DO05; + case 8: return &conn_DO06; + case 9: return &conn_DO07; + case 10: return &conn_DO08; + case 11: return &conn_DO09; + case 12: return &conn_DO10; + case 13: return &conn_DO11; + case 14: return &conn_DO12; + } + return nullptr; +} + +CDataConnection *FORTE_X20DO9321::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + } + return nullptr; +} + diff --git a/src/com/powerlink/fb/X20DO9321_fbt.h b/src/com/powerlink/fb/X20DO9321_fbt.h new file mode 100644 index 00000000..2649295c --- /dev/null +++ b/src/com/powerlink/fb/X20DO9321_fbt.h @@ -0,0 +1,161 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "PowerlinkFunctionBlockDO.h" +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" + + +class FORTE_X20DO9321 final : public PowerlinkFunctionBlockDO { + DECLARE_FIRMWARE_FB(FORTE_X20DO9321) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DO9321(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + CIEC_BOOL var_DO01; + CIEC_BOOL var_DO02; + CIEC_BOOL var_DO03; + CIEC_BOOL var_DO04; + CIEC_BOOL var_DO05; + CIEC_BOOL var_DO06; + CIEC_BOOL var_DO07; + CIEC_BOOL var_DO08; + CIEC_BOOL var_DO09; + CIEC_BOOL var_DO10; + CIEC_BOOL var_DO11; + CIEC_BOOL var_DO12; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + CDataConnection *conn_DO01; + CDataConnection *conn_DO02; + CDataConnection *conn_DO03; + CDataConnection *conn_DO04; + CDataConnection *conn_DO05; + CDataConnection *conn_DO06; + CDataConnection *conn_DO07; + CDataConnection *conn_DO08; + CDataConnection *conn_DO09; + CDataConnection *conn_DO10; + CDataConnection *conn_DO11; + CDataConnection *conn_DO12; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + var_DO05 = paDO05; + var_DO06 = paDO06; + var_DO07 = paDO07; + var_DO08 = paDO08; + var_DO09 = paDO09; + var_DO10 = paDO10; + var_DO11 = paDO11; + var_DO12 = paDO12; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + var_DO05 = paDO05; + var_DO06 = paDO06; + var_DO07 = paDO07; + var_DO08 = paDO08; + var_DO09 = paDO09; + var_DO10 = paDO10; + var_DO11 = paDO11; + var_DO12 = paDO12; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCNID, paMODID, paDO01, paDO02, paDO03, paDO04, paDO05, paDO06, paDO07, paDO08, paDO09, paDO10, paDO11, paDO12, paQO, paCNIDO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/fb/X20DO9322_fbt.cpp b/src/com/powerlink/fb/X20DO9322_fbt.cpp new file mode 100644 index 00000000..7b5abb56 --- /dev/null +++ b/src/com/powerlink/fb/X20DO9322_fbt.cpp @@ -0,0 +1,252 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#include "X20DO9322_fbt.h" +#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP +#include "X20DO9322_fbt_gen.cpp" +#endif + +#include "resource.h" + +DEFINE_FIRMWARE_FB(FORTE_X20DO9322, g_nStringIdX20DO9322) + +const CStringDictionary::TStringId FORTE_X20DO9322::scmDataInputNames[] = { + g_nStringIdQI, g_nStringIdCNID, g_nStringIdMODID, g_nStringIdDO01, g_nStringIdDO02, g_nStringIdDO03, + g_nStringIdDO04, g_nStringIdDO05, g_nStringIdDO06, g_nStringIdDO07, g_nStringIdDO08, g_nStringIdDO09, + g_nStringIdDO10, g_nStringIdDO11, g_nStringIdDO12 +}; +const CStringDictionary::TStringId FORTE_X20DO9322::scmDataInputTypeIds[] = { + g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdUINT, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, + g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, + g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL +}; +const CStringDictionary::TStringId FORTE_X20DO9322::scmDataOutputNames[] = { + g_nStringIdQO, g_nStringIdCNIDO, g_nStringIdSTATUS +}; +const CStringDictionary::TStringId FORTE_X20DO9322::scmDataOutputTypeIds[] = { + g_nStringIdBOOL, g_nStringIdUSINT, g_nStringIdSTRING +}; +const TDataIOID FORTE_X20DO9322::scmEIWith[] = { + 0, 1, 2, scmWithListDelimiter, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, scmWithListDelimiter +}; +const TForteInt16 FORTE_X20DO9322::scmEIWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO9322::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; +const TDataIOID FORTE_X20DO9322::scmEOWith[] = {0, 2, 1, scmWithListDelimiter, 2, 0, scmWithListDelimiter}; +const TForteInt16 FORTE_X20DO9322::scmEOWithIndexes[] = {0, 4}; +const CStringDictionary::TStringId FORTE_X20DO9322::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; +const SFBInterfaceSpec FORTE_X20DO9322::scmFBInterfaceSpec = { + 2, scmEventInputNames, scmEIWith, scmEIWithIndexes, + 2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, + 15, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; + +FORTE_X20DO9322::FORTE_X20DO9322(const CStringDictionary::TStringId paInstanceNameId, + forte::core::CFBContainer& paContainer) : + PowerlinkFunctionBlockDO(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_conn_QO(var_QO), + var_conn_CNIDO(var_CNIDO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_CNF(this, 1), + conn_QI(nullptr), + conn_CNID(nullptr), + conn_MODID(nullptr), + conn_DO01(nullptr), + conn_DO02(nullptr), + conn_DO03(nullptr), + conn_DO04(nullptr), + conn_DO05(nullptr), + conn_DO06(nullptr), + conn_DO07(nullptr), + conn_DO08(nullptr), + conn_DO09(nullptr), + conn_DO10(nullptr), + conn_DO11(nullptr), + conn_DO12(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_CNIDO(this, 1, &var_conn_CNIDO), + conn_STATUS(this, 2, &var_conn_STATUS) +{ +}; + +void FORTE_X20DO9322::setInitialValues() +{ + var_QI = 0_BOOL; + var_CNID = 0_USINT; + var_MODID = 0_UINT; + var_DO01 = 0_BOOL; + var_DO02 = 0_BOOL; + var_DO03 = 0_BOOL; + var_DO04 = 0_BOOL; + var_DO05 = 0_BOOL; + var_DO06 = 0_BOOL; + var_DO07 = 0_BOOL; + var_DO08 = 0_BOOL; + var_DO09 = 0_BOOL; + var_DO10 = 0_BOOL; + var_DO11 = 0_BOOL; + var_DO12 = 0_BOOL; + var_QO = 0_BOOL; + var_CNIDO = 0_USINT; + var_STATUS = ""_STRING; +} + +void FORTE_X20DO9322::executeEvent(const TEventID paEIID, CEventChainExecutionThread* const paECET) +{ + executePowerlinkEvent(paEIID, + paECET, + scmEventINITID, + scmEventREQID, + scmEventINITOID, + scmEventCNFID, + var_QI, + var_QO, + var_CNID, + var_MODID); +} + +void FORTE_X20DO9322::readInputData(const TEventID paEIID) +{ + switch (paEIID) + { + case scmEventINITID: + { + readData(0, var_QI, conn_QI); + readData(1, var_CNID, conn_CNID); + readData(2, var_MODID, conn_MODID); + break; + } + case scmEventREQID: + { + readData(3, var_DO01, conn_DO01); + readData(4, var_DO02, conn_DO02); + readData(5, var_DO03, conn_DO03); + readData(6, var_DO04, conn_DO04); + readData(7, var_DO05, conn_DO05); + readData(8, var_DO06, conn_DO06); + readData(9, var_DO07, conn_DO07); + readData(10, var_DO08, conn_DO08); + readData(11, var_DO09, conn_DO09); + readData(12, var_DO10, conn_DO10); + readData(13, var_DO11, conn_DO11); + readData(14, var_DO12, conn_DO12); + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_X20DO9322::writeOutputData(const TEventID paEIID) +{ + switch (paEIID) + { + case scmEventINITOID: + { + writeData(0, var_QO, conn_QO); + writeData(2, var_STATUS, conn_STATUS); + writeData(1, var_CNIDO, conn_CNIDO); + break; + } + case scmEventCNFID: + { + writeData(2, var_STATUS, conn_STATUS); + writeData(0, var_QO, conn_QO); + break; + } + default: + break; + } +} + +CIEC_ANY* FORTE_X20DO9322::getDI(const size_t paIndex) +{ + switch (paIndex) + { + case 0: return &var_QI; + case 1: return &var_CNID; + case 2: return &var_MODID; + case 3: return &var_DO01; + case 4: return &var_DO02; + case 5: return &var_DO03; + case 6: return &var_DO04; + case 7: return &var_DO05; + case 8: return &var_DO06; + case 9: return &var_DO07; + case 10: return &var_DO08; + case 11: return &var_DO09; + case 12: return &var_DO10; + case 13: return &var_DO11; + case 14: return &var_DO12; + } + return nullptr; +} + +CIEC_ANY* FORTE_X20DO9322::getDO(const size_t paIndex) +{ + switch (paIndex) + { + case 0: return &var_QO; + case 1: return &var_CNIDO; + case 2: return &var_STATUS; + } + return nullptr; +} + +CEventConnection* FORTE_X20DO9322::getEOConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_INITO; + case 1: return &conn_CNF; + } + return nullptr; +} + +CDataConnection** FORTE_X20DO9322::getDIConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_QI; + case 1: return &conn_CNID; + case 2: return &conn_MODID; + case 3: return &conn_DO01; + case 4: return &conn_DO02; + case 5: return &conn_DO03; + case 6: return &conn_DO04; + case 7: return &conn_DO05; + case 8: return &conn_DO06; + case 9: return &conn_DO07; + case 10: return &conn_DO08; + case 11: return &conn_DO09; + case 12: return &conn_DO10; + case 13: return &conn_DO11; + case 14: return &conn_DO12; + } + return nullptr; +} + +CDataConnection* FORTE_X20DO9322::getDOConUnchecked(const TPortId paIndex) +{ + switch (paIndex) + { + case 0: return &conn_QO; + case 1: return &conn_CNIDO; + case 2: return &conn_STATUS; + } + return nullptr; +} diff --git a/src/com/powerlink/fb/X20DO9322_fbt.h b/src/com/powerlink/fb/X20DO9322_fbt.h new file mode 100644 index 00000000..4d18055b --- /dev/null +++ b/src/com/powerlink/fb/X20DO9322_fbt.h @@ -0,0 +1,160 @@ +/******************************************************************************* +* Copyright (c) 2012 - 2024 AIT + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Filip Andren - initial API and implementation and/or initial documentation + * Michael Gafert - moved common functions to super class, changed to new FB style + *******************************************************************************/ + +#pragma once + +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_usint.h" +#include "forte_uint.h" +#include "forte_string.h" +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" +#include "PowerlinkFunctionBlockDO.h" + +class FORTE_X20DO9322 final : public PowerlinkFunctionBlockDO { + DECLARE_FIRMWARE_FB(FORTE_X20DO9322) + + private: + static const CStringDictionary::TStringId scmDataInputNames[]; + static const CStringDictionary::TStringId scmDataInputTypeIds[]; + static const CStringDictionary::TStringId scmDataOutputNames[]; + static const CStringDictionary::TStringId scmDataOutputTypeIds[]; + static const TEventID scmEventINITID = 0; + static const TEventID scmEventREQID = 1; + static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; + static const CStringDictionary::TStringId scmEventInputNames[]; + static const TEventID scmEventINITOID = 0; + static const TEventID scmEventCNFID = 1; + static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; + static const CStringDictionary::TStringId scmEventOutputNames[]; + + static const SFBInterfaceSpec scmFBInterfaceSpec; + + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; + + void readInputData(TEventID paEIID) override; + void writeOutputData(TEventID paEIID) override; + void setInitialValues() override; + + public: + FORTE_X20DO9322(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_USINT var_CNID; + CIEC_UINT var_MODID; + CIEC_BOOL var_DO01; + CIEC_BOOL var_DO02; + CIEC_BOOL var_DO03; + CIEC_BOOL var_DO04; + CIEC_BOOL var_DO05; + CIEC_BOOL var_DO06; + CIEC_BOOL var_DO07; + CIEC_BOOL var_DO08; + CIEC_BOOL var_DO09; + CIEC_BOOL var_DO10; + CIEC_BOOL var_DO11; + CIEC_BOOL var_DO12; + + CIEC_BOOL var_QO; + CIEC_USINT var_CNIDO; + CIEC_STRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_USINT var_conn_CNIDO; + CIEC_STRING var_conn_STATUS; + + CEventConnection conn_INITO; + CEventConnection conn_CNF; + + CDataConnection *conn_QI; + CDataConnection *conn_CNID; + CDataConnection *conn_MODID; + CDataConnection *conn_DO01; + CDataConnection *conn_DO02; + CDataConnection *conn_DO03; + CDataConnection *conn_DO04; + CDataConnection *conn_DO05; + CDataConnection *conn_DO06; + CDataConnection *conn_DO07; + CDataConnection *conn_DO08; + CDataConnection *conn_DO09; + CDataConnection *conn_DO10; + CDataConnection *conn_DO11; + CDataConnection *conn_DO12; + + CDataConnection conn_QO; + CDataConnection conn_CNIDO; + CDataConnection conn_STATUS; + + CIEC_ANY *getDI(size_t) override; + CIEC_ANY *getDO(size_t) override; + CEventConnection *getEOConUnchecked(TPortId) override; + CDataConnection **getDIConUnchecked(TPortId) override; + CDataConnection *getDOConUnchecked(TPortId) override; + + void evt_INIT(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + var_DO05 = paDO05; + var_DO06 = paDO06; + var_DO07 = paDO07; + var_DO08 = paDO08; + var_DO09 = paDO09; + var_DO10 = paDO10; + var_DO11 = paDO11; + var_DO12 = paDO12; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void evt_REQ(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + var_QI = paQI; + var_CNID = paCNID; + var_MODID = paMODID; + var_DO01 = paDO01; + var_DO02 = paDO02; + var_DO03 = paDO03; + var_DO04 = paDO04; + var_DO05 = paDO05; + var_DO06 = paDO06; + var_DO07 = paDO07; + var_DO08 = paDO08; + var_DO09 = paDO09; + var_DO10 = paDO10; + var_DO11 = paDO11; + var_DO12 = paDO12; + executeEvent(scmEventREQID, nullptr); + paQO = var_QO; + paCNIDO = var_CNIDO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_USINT &paCNID, const CIEC_UINT &paMODID, const CIEC_BOOL &paDO01, const CIEC_BOOL &paDO02, const CIEC_BOOL &paDO03, const CIEC_BOOL &paDO04, const CIEC_BOOL &paDO05, const CIEC_BOOL &paDO06, const CIEC_BOOL &paDO07, const CIEC_BOOL &paDO08, const CIEC_BOOL &paDO09, const CIEC_BOOL &paDO10, const CIEC_BOOL &paDO11, const CIEC_BOOL &paDO12, CIEC_BOOL &paQO, CIEC_USINT &paCNIDO, CIEC_STRING &paSTATUS) { + evt_INIT(paQI, paCNID, paMODID, paDO01, paDO02, paDO03, paDO04, paDO05, paDO06, paDO07, paDO08, paDO09, paDO10, paDO11, paDO12, paQO, paCNIDO, paSTATUS); + } +}; + + diff --git a/src/com/powerlink/readme.txt b/src/com/powerlink/readme.txt deleted file mode 100644 index c1b83526..00000000 --- a/src/com/powerlink/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -openPOWERLINK interface for FORTE - -Instructions - -Prerequisits -The following is needed in order to use openPOWERLINK with FORTE: - - - openPOWERLINK V1.8.0 - - TinyXML - -To use openPOWERLINK download openPOWERLINK V1.8.0 from Sourceforge (http://sourceforge.net/projects/openpowerlink/). The stack should be compiled using at least the following options in CMake: - - - CFG_POWERLINK_CHM - - CFG_POWERLINK_PROCESS_IMAGE - - CFG_X86_WINDOWS_DLL (only available on Windows) - -If compiled on Windows the resulting DLL and LIB must be copied to the main openPOWERLINK-V1.8.0 folder. - -TinyXML can be downloaded from http://sourceforge.net/projects/tinyxml/. - -Configure FORTE -Check FORTE_MODULE_POWERLINK and set FORTE_MODULE_POWERLINK_LIB_DIR to [OPENPOWERLINK-V1.08.0_HOME] and FORTE_MODULE_POWERLINK_TINYXML_DIR to the directory where you unpacked TinyXML. diff --git a/src/com/powerlink/startup.cpp b/src/com/powerlink/startup.cpp index ec43786c..effcad30 100644 --- a/src/com/powerlink/startup.cpp +++ b/src/com/powerlink/startup.cpp @@ -12,6 +12,6 @@ #include -void powerlinkStartupHook(int argc, char *arg[]){ +void powerlinkStartupHook([[maybe_unused]] int paArgc, [[maybe_unused]] char *paArg[]){ CEplStackWrapper::eplMainInit(); }