Skip to content

Commit

Permalink
Generated ADS fbt files from IDE to also use EInit
Browse files Browse the repository at this point in the history
Generated ADS_SERVER_CONFIG from IDE to also use EInit

Generated SET_LOCAL_ADS_ADDRESS from IDE to also use EInit

remove Tab
  • Loading branch information
MoritzO02 committed Feb 23, 2025
1 parent e8b3291 commit eed1c21
Show file tree
Hide file tree
Showing 4 changed files with 423 additions and 108 deletions.
159 changes: 129 additions & 30 deletions src/modules/ads/ADS_SERVER_CONFIG_fbt.cpp
Original file line number Diff line number Diff line change
@@ -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<CIEC_UDINT::TValueType>(ADS_PORT()), SERVER_IPV4_OR_HOSTNAME().getStorage().c_str()));
Expand All @@ -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;
}
107 changes: 83 additions & 24 deletions src/modules/ads/ADS_SERVER_CONFIG_fbt.h
Original file line number Diff line number Diff line change
@@ -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 <funcbloc.h>
#include <forte_bool.h>
#include <forte_string.h>
#include <forte_uint.h>
#include <forte_wstring.h>
#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[];
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit eed1c21

Please sign in to comment.