From eed1c218f2a0e1252ef611c46a1819215515153a Mon Sep 17 00:00:00 2001 From: Moritz Ortmeier Date: Sun, 23 Feb 2025 20:54:36 +0100 Subject: [PATCH] Generated ADS fbt files from IDE to also use EInit Generated ADS_SERVER_CONFIG from IDE to also use EInit Generated SET_LOCAL_ADS_ADDRESS from IDE to also use EInit remove Tab --- src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp | 159 +++++++++++++---- src/modules/ads/ADS_SERVER_CONFIG_fbt.h | 107 ++++++++--- src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.cpp | 166 ++++++++++++++---- src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.h | 99 ++++++++--- 4 files changed, 423 insertions(+), 108 deletions(-) diff --git a/src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp b/src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp index 160f47762..c5be8faad 100644 --- a/src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp +++ b/src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp @@ -1,47 +1,90 @@ -/******************************************************************************* - * Copyright (c) 2018 TU Wien/ACIN - * - * 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: - * Martin Melik-Merkumians - initial contribution - *******************************************************************************/ +/************************************************************************* + *** Copyright (c) 2018 TU Vienna/ACIN + *** + *** This program and the accompanying materials are made + *** available under the terms of the Eclipse Public License 2.0 + *** which is available at https://www.eclipse.org/legal/epl-2.0/ + *** + *** SPDX-License-Identifier: EPL-2.0 + *** + *** FORTE Library Element + *** + *** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! + *** + *** Name: ADS_SERVER_CONFIG + *** Description: Service Interface Function Block Type + *** Version: + *** 1.0: 2018-08-28/Martin Melik Merkumians - TU Vienna/ACIN - initial contribution + *************************************************************************/ #include "ADS_SERVER_CONFIG_fbt.h" #ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP #include "ADS_SERVER_CONFIG_fbt_gen.cpp" #endif +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" #include "CAdsConnectionManager.h" DEFINE_FIRMWARE_FB(FORTE_ADS_SERVER_CONFIG, g_nStringIdADS_SERVER_CONFIG) -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataInputNames[] = { g_nStringIdQI, g_nStringIdFRIENDLY_NAME, g_nStringIdSERVER_ADS_ADDRESS, g_nStringIdADS_PORT, g_nStringIdSERVER_IPV4_OR_HOSTNAME }; - -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING, g_nStringIdSTRING, g_nStringIdUINT, g_nStringIdSTRING }; - -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS }; - -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdWSTRING }; - -const TForteInt16 FORTE_ADS_SERVER_CONFIG::scmEIWithIndexes[] = { 0 }; -const TDataIOID FORTE_ADS_SERVER_CONFIG::scmEIWith[] = { 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventInputNames[] = { g_nStringIdINIT }; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdFRIENDLY_NAME, g_nStringIdSERVER_ADS_ADDRESS, g_nStringIdADS_PORT, g_nStringIdSERVER_IPV4_OR_HOSTNAME}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdWSTRING, g_nStringIdWSTRING, g_nStringIdUINT, g_nStringIdWSTRING}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdSTATUS}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdWSTRING}; +const TDataIOID FORTE_ADS_SERVER_CONFIG::scmEIWith[] = {0, scmWithListDelimiter}; +const TForteInt16 FORTE_ADS_SERVER_CONFIG::scmEIWithIndexes[] = {0}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventInputNames[] = {g_nStringIdINIT}; const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventInputTypeIds[] = {g_nStringIdEInit}; +const TDataIOID FORTE_ADS_SERVER_CONFIG::scmEOWith[] = {0, 1, scmWithListDelimiter}; +const TForteInt16 FORTE_ADS_SERVER_CONFIG::scmEOWithIndexes[] = {0, -1}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventOutputNames[] = {g_nStringIdINITO}; +const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventOutputTypeIds[] = {g_nStringIdEInit}; +const SFBInterfaceSpec FORTE_ADS_SERVER_CONFIG::scmFBInterfaceSpec = { + 1, scmEventInputNames, scmEventInputTypeIds, scmEIWith, scmEIWithIndexes, + 1, scmEventOutputNames, scmEventOutputTypeIds, scmEOWith, scmEOWithIndexes, + 5, scmDataInputNames, scmDataInputTypeIds, + 2, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; -const TDataIOID FORTE_ADS_SERVER_CONFIG::scmEOWith[] = { 0, 1, scmWithListDelimiter }; -const TForteInt16 FORTE_ADS_SERVER_CONFIG::scmEOWithIndexes[] = { 0, -1 }; -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventOutputNames[] = { g_nStringIdINITO }; -const CStringDictionary::TStringId FORTE_ADS_SERVER_CONFIG::scmEventOutputTypeIds[] = {g_nStringIdEvent}; +FORTE_ADS_SERVER_CONFIG::FORTE_ADS_SERVER_CONFIG(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_QI(0_BOOL), + var_FRIENDLY_NAME(u""_WSTRING), + var_SERVER_ADS_ADDRESS(u""_WSTRING), + var_ADS_PORT(0_UINT), + var_SERVER_IPV4_OR_HOSTNAME(u""_WSTRING), + var_QO(0_BOOL), + var_STATUS(u""_WSTRING), + var_conn_QO(var_QO), + var_conn_STATUS(var_STATUS), + conn_INITO(this, 0), + conn_QI(nullptr), + conn_FRIENDLY_NAME(nullptr), + conn_SERVER_ADS_ADDRESS(nullptr), + conn_ADS_PORT(nullptr), + conn_SERVER_IPV4_OR_HOSTNAME(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_STATUS(this, 1, &var_conn_STATUS) { +}; -const SFBInterfaceSpec FORTE_ADS_SERVER_CONFIG::scmFBInterfaceSpec = { 1, scmEventInputNames, scmEventInputTypeIds, scmEIWith, scmEIWithIndexes, 1, scmEventOutputNames, scmEventOutputTypeIds, scmEOWith, scmEOWithIndexes, 5, scmDataInputNames, scmDataInputTypeIds, 2, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; +void FORTE_ADS_SERVER_CONFIG::setInitialValues() { + var_QI = 0_BOOL; + var_FRIENDLY_NAME = u""_WSTRING; + var_SERVER_ADS_ADDRESS = u""_WSTRING; + var_ADS_PORT = 0_UINT; + var_SERVER_IPV4_OR_HOSTNAME = u""_WSTRING; + var_QO = 0_BOOL; + var_STATUS = u""_WSTRING; +} -void FORTE_ADS_SERVER_CONFIG::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ +void FORTE_ADS_SERVER_CONFIG::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + switch(paEIID) { case scmEventINITID: if(QI()) { QO() = CIEC_BOOL(forte::ads::CAdsConnectionManager::getInstance().addConnection(FRIENDLY_NAME().getStorage().c_str(), SERVER_ADS_ADDRESS().getStorage().c_str(), static_cast(ADS_PORT()), SERVER_IPV4_OR_HOSTNAME().getStorage().c_str())); @@ -54,3 +97,59 @@ void FORTE_ADS_SERVER_CONFIG::executeEvent(TEventID paEIID, CEventChainExecution } } +void FORTE_ADS_SERVER_CONFIG::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_ADS_SERVER_CONFIG::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_FRIENDLY_NAME; + case 2: return &var_SERVER_ADS_ADDRESS; + case 3: return &var_ADS_PORT; + case 4: return &var_SERVER_IPV4_OR_HOSTNAME; + } + return nullptr; +} + +CIEC_ANY *FORTE_ADS_SERVER_CONFIG::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_STATUS; + } + return nullptr; +} + +CEventConnection *FORTE_ADS_SERVER_CONFIG::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + } + return nullptr; +} + +CDataConnection **FORTE_ADS_SERVER_CONFIG::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_FRIENDLY_NAME; + case 2: return &conn_SERVER_ADS_ADDRESS; + case 3: return &conn_ADS_PORT; + case 4: return &conn_SERVER_IPV4_OR_HOSTNAME; + } + return nullptr; +} + +CDataConnection *FORTE_ADS_SERVER_CONFIG::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_STATUS; + } + return nullptr; +} diff --git a/src/modules/ads/ADS_SERVER_CONFIG_fbt.h b/src/modules/ads/ADS_SERVER_CONFIG_fbt.h index de22a760d..0712fdd55 100644 --- a/src/modules/ads/ADS_SERVER_CONFIG_fbt.h +++ b/src/modules/ads/ADS_SERVER_CONFIG_fbt.h @@ -1,26 +1,39 @@ -/******************************************************************************* - * Copyright (c) 2018 TU Wien/ACIN - * 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: - * Martin Melik-Merkumians - initial contribution - *******************************************************************************/ +/************************************************************************* + *** Copyright (c) 2018 TU Vienna/ACIN + *** + *** This program and the accompanying materials are made + *** available under the terms of the Eclipse Public License 2.0 + *** which is available at https://www.eclipse.org/legal/epl-2.0/ + *** + *** SPDX-License-Identifier: EPL-2.0 + *** + *** FORTE Library Element + *** + *** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! + *** + *** Name: ADS_SERVER_CONFIG + *** Description: Service Interface Function Block Type + *** Version: + *** 1.0: 2018-08-28/Martin Melik Merkumians - TU Vienna/ACIN - initial contribution + *************************************************************************/ + +#pragma once #ifndef _ADS_SERVER_CONFIG_H_ #define _ADS_SERVER_CONFIG_H_ -#include -#include -#include -#include -#include +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_uint.h" +#include "forte_wstring.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_ADS_SERVER_CONFIG : public CFunctionBlock{ - DECLARE_FIRMWARE_FB (FORTE_ADS_SERVER_CONFIG) +class FORTE_ADS_SERVER_CONFIG final : public CFunctionBlock { + DECLARE_FIRMWARE_FB(FORTE_ADS_SERVER_CONFIG) private: static const CStringDictionary::TStringId scmDataInputNames[]; @@ -56,27 +69,73 @@ class FORTE_ADS_SERVER_CONFIG : public CFunctionBlock{ }; static const TEventID scmEventINITID = 0; - static const TForteInt16 scmEIWithIndexes[]; static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; static const CStringDictionary::TStringId scmEventInputNames[]; static const CStringDictionary::TStringId scmEventInputTypeIds[]; - static const TEventID scmEventINITOID = 0; - static const TForteInt16 scmEOWithIndexes[]; static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; static const CStringDictionary::TStringId scmEventOutputNames[]; static const CStringDictionary::TStringId scmEventOutputTypeIds[]; 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: FUNCTION_BLOCK_CTOR (FORTE_ADS_SERVER_CONFIG) { }; - ~FORTE_ADS_SERVER_CONFIG() override = default; - + + FORTE_ADS_SERVER_CONFIG(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_WSTRING var_FRIENDLY_NAME; + CIEC_WSTRING var_SERVER_ADS_ADDRESS; + CIEC_UINT var_ADS_PORT; + CIEC_WSTRING var_SERVER_IPV4_OR_HOSTNAME; + + CIEC_BOOL var_QO; + CIEC_WSTRING var_STATUS; + + CIEC_BOOL var_conn_QO; + CIEC_WSTRING var_conn_STATUS; + + CEventConnection conn_INITO; + + CDataConnection *conn_QI; + CDataConnection *conn_FRIENDLY_NAME; + CDataConnection *conn_SERVER_ADS_ADDRESS; + CDataConnection *conn_ADS_PORT; + CDataConnection *conn_SERVER_IPV4_OR_HOSTNAME; + + 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_WSTRING &paFRIENDLY_NAME, const CIEC_WSTRING &paSERVER_ADS_ADDRESS, const CIEC_UINT &paADS_PORT, const CIEC_WSTRING &paSERVER_IPV4_OR_HOSTNAME, CIEC_BOOL &paQO, CIEC_WSTRING &paSTATUS) { + var_QI = paQI; + var_FRIENDLY_NAME = paFRIENDLY_NAME; + var_SERVER_ADS_ADDRESS = paSERVER_ADS_ADDRESS; + var_ADS_PORT = paADS_PORT; + var_SERVER_IPV4_OR_HOSTNAME = paSERVER_IPV4_OR_HOSTNAME; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paSTATUS = var_STATUS; + } + + void operator()(const CIEC_BOOL &paQI, const CIEC_WSTRING &paFRIENDLY_NAME, const CIEC_WSTRING &paSERVER_ADS_ADDRESS, const CIEC_UINT &paADS_PORT, const CIEC_WSTRING &paSERVER_IPV4_OR_HOSTNAME, CIEC_BOOL &paQO, CIEC_WSTRING &paSTATUS) { + evt_INIT(paQI, paFRIENDLY_NAME, paSERVER_ADS_ADDRESS, paADS_PORT, paSERVER_IPV4_OR_HOSTNAME, paQO, paSTATUS); + } }; #endif //close the ifdef sequence from the beginning of the file diff --git a/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.cpp b/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.cpp index a4703d0d5..4c369f4d8 100644 --- a/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.cpp +++ b/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.cpp @@ -1,48 +1,86 @@ -/******************************************************************************* - * Copyright (c) 2018 TU Wien/ACIN - * 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: - * Martin Melik-Merkumians - initial contribution - *******************************************************************************/ +/************************************************************************* + *** Copyright (c) 2018 TU Vienna/ACIN + *** + *** This program and the accompanying materials are made + *** available under the terms of the Eclipse Public License 2.0 + *** which is available at https://www.eclipse.org/legal/epl-2.0/ + *** + *** SPDX-License-Identifier: EPL-2.0 + *** + *** FORTE Library Element + *** + *** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! + *** + *** Name: SET_LOCAL_ADS_ADDRESS + *** Description: Service Interface Function Block Type + *** Version: + *** 1.0: 2018-08-31/Martin Melik Merkumians - TU Vienna/ACIN - initial contribution + *************************************************************************/ #include "SET_LOCAL_ADS_ADDRESS_fbt.h" #ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP #include "SET_LOCAL_ADS_ADDRESS_fbt_gen.cpp" #endif -#include - -#include +#include "iec61131_functions.h" +#include "forte_array_common.h" +#include "forte_array.h" +#include "forte_array_fixed.h" +#include "forte_array_variable.h" +#include "sstream" +#include "AdsLib.h" DEFINE_FIRMWARE_FB(FORTE_SET_LOCAL_ADS_ADDRESS, g_nStringIdSET_LOCAL_ADS_ADDRESS) -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataInputNames[] ={g_nStringIdQI, g_nStringIdPARAMS}; - -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataInputTypeIds[] = { g_nStringIdBOOL, g_nStringIdSTRING }; - -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataOutputNames[] = { g_nStringIdQO, g_nStringIdSTATUS, g_nStringIdLOCAL_ADS_ADDRESS }; - -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataOutputTypeIds[] = { g_nStringIdBOOL, g_nStringIdWSTRING, g_nStringIdSTRING }; - -const TForteInt16 FORTE_SET_LOCAL_ADS_ADDRESS::scmEIWithIndexes[] = { 0 }; -const TDataIOID FORTE_SET_LOCAL_ADS_ADDRESS::scmEIWith[] = { 0, scmWithListDelimiter }; -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventInputNames[] = { g_nStringIdINIT }; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdPARAMS}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdSTRING}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdSTATUS, g_nStringIdLOCAL_ADS_ADDRESS}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdWSTRING, g_nStringIdSTRING}; +const TDataIOID FORTE_SET_LOCAL_ADS_ADDRESS::scmEIWith[] = {0, scmWithListDelimiter}; +const TForteInt16 FORTE_SET_LOCAL_ADS_ADDRESS::scmEIWithIndexes[] = {0}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventInputNames[] = {g_nStringIdINIT}; const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventInputTypeIds[] = {g_nStringIdEInit}; - -const TDataIOID FORTE_SET_LOCAL_ADS_ADDRESS::scmEOWith[] = { 0, 1, 2, scmWithListDelimiter }; +const TDataIOID FORTE_SET_LOCAL_ADS_ADDRESS::scmEOWith[] = {0, 1, 2, scmWithListDelimiter}; const TForteInt16 FORTE_SET_LOCAL_ADS_ADDRESS::scmEOWithIndexes[] = { 0, -1 }; -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventOutputNames[] = { g_nStringIdINITO }; -const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventOutputTypeIds[] = {g_nStringIdEvent}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventOutputNames[] = {g_nStringIdINITO}; +const CStringDictionary::TStringId FORTE_SET_LOCAL_ADS_ADDRESS::scmEventOutputTypeIds[] = {g_nStringIdEInit}; +const SFBInterfaceSpec FORTE_SET_LOCAL_ADS_ADDRESS::scmFBInterfaceSpec = { + 1, scmEventInputNames, scmEventInputTypeIds, scmEIWith, scmEIWithIndexes, + 1, scmEventOutputNames, scmEventOutputTypeIds, scmEOWith, scmEOWithIndexes, + 2, scmDataInputNames, scmDataInputTypeIds, + 3, scmDataOutputNames, scmDataOutputTypeIds, + 0, nullptr, + 0, nullptr +}; -const SFBInterfaceSpec FORTE_SET_LOCAL_ADS_ADDRESS::scmFBInterfaceSpec = { 1, scmEventInputNames, scmEventInputTypeIds, scmEIWith, scmEIWithIndexes, 1, scmEventOutputNames, scmEventOutputTypeIds, scmEOWith, scmEOWithIndexes, 2, scmDataInputNames, scmDataInputTypeIds, 3, scmDataOutputNames, scmDataOutputTypeIds, 0, 0 }; +FORTE_SET_LOCAL_ADS_ADDRESS::FORTE_SET_LOCAL_ADS_ADDRESS(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : + CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId), + var_QI(0_BOOL), + var_PARAMS(""_STRING), + var_QO(0_BOOL), + var_STATUS(u""_WSTRING), + var_LOCAL_ADS_ADDRESS(""_STRING), + var_conn_QO(var_QO), + var_conn_STATUS(var_STATUS), + var_conn_LOCAL_ADS_ADDRESS(var_LOCAL_ADS_ADDRESS), + conn_INITO(this, 0), + conn_QI(nullptr), + conn_PARAMS(nullptr), + conn_QO(this, 0, &var_conn_QO), + conn_STATUS(this, 1, &var_conn_STATUS), + conn_LOCAL_ADS_ADDRESS(this, 2, &var_conn_LOCAL_ADS_ADDRESS) { +}; + +void FORTE_SET_LOCAL_ADS_ADDRESS::setInitialValues() { + var_QI = 0_BOOL; + var_PARAMS = ""_STRING; + var_QO = 0_BOOL; + var_STATUS = u""_WSTRING; + var_LOCAL_ADS_ADDRESS = ""_STRING; +} -void FORTE_SET_LOCAL_ADS_ADDRESS::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { - switch (paEIID){ +void FORTE_SET_LOCAL_ADS_ADDRESS::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { + switch(paEIID) { case scmEventINITID: AmsNetId desiredAddress(std::string(PARAMS().getStorage().c_str())); if(QI()){ @@ -71,3 +109,67 @@ void FORTE_SET_LOCAL_ADS_ADDRESS::executeEvent(TEventID paEIID, CEventChainExecu } } +void FORTE_SET_LOCAL_ADS_ADDRESS::readInputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITID: { + readData(0, var_QI, conn_QI); + break; + } + default: + break; + } +} + +void FORTE_SET_LOCAL_ADS_ADDRESS::writeOutputData(const TEventID paEIID) { + switch(paEIID) { + case scmEventINITOID: { + writeData(0, var_QO, conn_QO); + writeData(1, var_STATUS, conn_STATUS); + writeData(2, var_LOCAL_ADS_ADDRESS, conn_LOCAL_ADS_ADDRESS); + break; + } + default: + break; + } +} + +CIEC_ANY *FORTE_SET_LOCAL_ADS_ADDRESS::getDI(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QI; + case 1: return &var_PARAMS; + } + return nullptr; +} + +CIEC_ANY *FORTE_SET_LOCAL_ADS_ADDRESS::getDO(const size_t paIndex) { + switch(paIndex) { + case 0: return &var_QO; + case 1: return &var_STATUS; + case 2: return &var_LOCAL_ADS_ADDRESS; + } + return nullptr; +} + +CEventConnection *FORTE_SET_LOCAL_ADS_ADDRESS::getEOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_INITO; + } + return nullptr; +} + +CDataConnection **FORTE_SET_LOCAL_ADS_ADDRESS::getDIConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QI; + case 1: return &conn_PARAMS; + } + return nullptr; +} + +CDataConnection *FORTE_SET_LOCAL_ADS_ADDRESS::getDOConUnchecked(const TPortId paIndex) { + switch(paIndex) { + case 0: return &conn_QO; + case 1: return &conn_STATUS; + case 2: return &conn_LOCAL_ADS_ADDRESS; + } + return nullptr; +} diff --git a/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.h b/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.h index 5223cc2f8..dc1588a4f 100644 --- a/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.h +++ b/src/modules/ads/SET_LOCAL_ADS_ADDRESS_fbt.h @@ -1,25 +1,39 @@ -/******************************************************************************* - * Copyright (c) 2018 TU Wien/ACIN - * 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: - * Martin Melik-Merkumians - initial contribution - *******************************************************************************/ +/************************************************************************* + *** Copyright (c) 2018 TU Vienna/ACIN + *** + *** This program and the accompanying materials are made + *** available under the terms of the Eclipse Public License 2.0 + *** which is available at https://www.eclipse.org/legal/epl-2.0/ + *** + *** SPDX-License-Identifier: EPL-2.0 + *** + *** FORTE Library Element + *** + *** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! + *** + *** Name: SET_LOCAL_ADS_ADDRESS + *** Description: Service Interface Function Block Type + *** Version: + *** 1.0: 2018-08-31/Martin Melik Merkumians - TU Vienna/ACIN - initial contribution + *************************************************************************/ + +#pragma once #ifndef _SET_LOCAL_ADS_ADDRESS_H_ #define _SET_LOCAL_ADS_ADDRESS_H_ -#include -#include -#include -#include +#include "funcbloc.h" +#include "forte_bool.h" +#include "forte_string.h" +#include "forte_wstring.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_SET_LOCAL_ADS_ADDRESS : public CFunctionBlock{ - DECLARE_FIRMWARE_FB (FORTE_SET_LOCAL_ADS_ADDRESS) +class FORTE_SET_LOCAL_ADS_ADDRESS final : public CFunctionBlock { + DECLARE_FIRMWARE_FB(FORTE_SET_LOCAL_ADS_ADDRESS) private: static const CStringDictionary::TStringId scmDataInputNames[]; @@ -52,27 +66,68 @@ class FORTE_SET_LOCAL_ADS_ADDRESS : public CFunctionBlock{ ; static const TEventID scmEventINITID = 0; - static const TForteInt16 scmEIWithIndexes[]; static const TDataIOID scmEIWith[]; + static const TForteInt16 scmEIWithIndexes[]; static const CStringDictionary::TStringId scmEventInputNames[]; static const CStringDictionary::TStringId scmEventInputTypeIds[]; - static const TEventID scmEventINITOID = 0; - static const TForteInt16 scmEOWithIndexes[]; static const TDataIOID scmEOWith[]; + static const TForteInt16 scmEOWithIndexes[]; static const CStringDictionary::TStringId scmEventOutputNames[]; static const CStringDictionary::TStringId scmEventOutputTypeIds[]; 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: FUNCTION_BLOCK_CTOR (FORTE_SET_LOCAL_ADS_ADDRESS) { }; - ~FORTE_SET_LOCAL_ADS_ADDRESS() override = default; + + FORTE_SET_LOCAL_ADS_ADDRESS(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); + + CIEC_BOOL var_QI; + CIEC_STRING var_PARAMS; + + CIEC_BOOL var_QO; + CIEC_WSTRING var_STATUS; + CIEC_STRING var_LOCAL_ADS_ADDRESS; + + CIEC_BOOL var_conn_QO; + CIEC_WSTRING var_conn_STATUS; + CIEC_STRING var_conn_LOCAL_ADS_ADDRESS; + + CEventConnection conn_INITO; + + CDataConnection *conn_QI; + CDataConnection *conn_PARAMS; + + CDataConnection conn_QO; + CDataConnection conn_STATUS; + CDataConnection conn_LOCAL_ADS_ADDRESS; + + 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 &paPARAMS, CIEC_BOOL &paQO, CIEC_WSTRING &paSTATUS, CIEC_STRING &paLOCAL_ADS_ADDRESS) { + var_QI = paQI; + var_PARAMS = paPARAMS; + executeEvent(scmEventINITID, nullptr); + paQO = var_QO; + paSTATUS = var_STATUS; + paLOCAL_ADS_ADDRESS = var_LOCAL_ADS_ADDRESS; + } + void operator()(const CIEC_BOOL &paQI, const CIEC_STRING &paPARAMS, CIEC_BOOL &paQO, CIEC_WSTRING &paSTATUS, CIEC_STRING &paLOCAL_ADS_ADDRESS) { + evt_INIT(paQI, paPARAMS, paQO, paSTATUS, paLOCAL_ADS_ADDRESS); + } }; #endif //close the ifdef sequence from the beginning of the file