-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a generic F_MOVE where the type can be configured during deploy
- Loading branch information
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013, 2024 ACIN, Martin Erich Jobst, | ||
* Primetals Technologies Austria 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: | ||
* Alois Zoitl - refactored from F_MOVE | ||
*******************************************************************************/ | ||
|
||
#include "GEN_F_MOVE_fct.h" | ||
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP | ||
#include "GEN_F_MOVE_fct_gen.cpp" | ||
#endif | ||
|
||
#include "criticalregion.h" | ||
#include "resource.h" | ||
|
||
DEFINE_GENERIC_FIRMWARE_FB(GEN_FORTE_F_MOVE, g_nStringIdGEN_F_MOVE) | ||
|
||
const CStringDictionary::TStringId GEN_FORTE_F_MOVE::scmDataInputNames[] = {g_nStringIdIN}; | ||
|
||
const CStringDictionary::TStringId GEN_FORTE_F_MOVE::scmDataOutputNames[] = {g_nStringIdOUT}; | ||
|
||
const TDataIOID GEN_FORTE_F_MOVE::scmEIWith[] = {0, scmWithListDelimiter}; | ||
const TForteInt16 GEN_FORTE_F_MOVE::scmEIWithIndexes[] = {0}; | ||
const CStringDictionary::TStringId GEN_FORTE_F_MOVE::scmEventInputNames[] = {g_nStringIdREQ}; | ||
|
||
const TDataIOID GEN_FORTE_F_MOVE::scmEOWith[] = {0, scmWithListDelimiter}; | ||
const TForteInt16 GEN_FORTE_F_MOVE::scmEOWithIndexes[] = {0}; | ||
const CStringDictionary::TStringId GEN_FORTE_F_MOVE::scmEventOutputNames[] = {g_nStringIdCNF}; | ||
|
||
|
||
GEN_FORTE_F_MOVE::GEN_FORTE_F_MOVE(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : | ||
CGenFunctionBlock<CFunctionBlock>(paContainer, paInstanceNameId) { | ||
} | ||
|
||
GEN_FORTE_F_MOVE::~GEN_FORTE_F_MOVE(){ | ||
if(nullptr!= mInterfaceSpec){ | ||
delete[](mInterfaceSpec->mDIDataTypeNames); | ||
delete[](mInterfaceSpec->mDODataTypeNames); | ||
} | ||
} | ||
|
||
void GEN_FORTE_F_MOVE::executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) { | ||
switch(paEIID) { | ||
case scmEventREQID: | ||
var_OUT() = var_IN(); | ||
sendOutputEvent(scmEventCNFID, paECET); | ||
break; | ||
} | ||
} | ||
|
||
void GEN_FORTE_F_MOVE::readInputData(TEventID paEIID) { | ||
if(paEIID == scmEventREQID) { | ||
readData(0, *mDIs[0], mDIConns[0]); | ||
} | ||
} | ||
|
||
void GEN_FORTE_F_MOVE::writeOutputData(TEventID paEOID) { | ||
if(paEOID == scmEventCNFID){ | ||
writeData(0, *mDOs[0], mDOConns[0]); | ||
} | ||
} | ||
|
||
bool GEN_FORTE_F_MOVE::createInterfaceSpec(const char *paConfigString, SFBInterfaceSpec &paInterfaceSpec) { | ||
CTypeLib::CTypeEntry *poToCreate = CTypeLib::findType(getDataTypeNameId(paConfigString), CTypeLib::getDTLibStart()); | ||
if (nullptr == poToCreate) { | ||
return false; | ||
} | ||
|
||
CStringDictionary::TStringId *diDataTypeNames = new CStringDictionary::TStringId[1]; | ||
diDataTypeNames[0] = poToCreate->getTypeNameId(); | ||
CStringDictionary::TStringId *doDataTypeNames = new CStringDictionary::TStringId[1]; | ||
doDataTypeNames[0] = poToCreate->getTypeNameId(); | ||
|
||
paInterfaceSpec.mNumEIs = 1; | ||
paInterfaceSpec.mEINames = scmEventInputNames; | ||
paInterfaceSpec.mEIWith = scmEIWith; | ||
paInterfaceSpec.mEIWithIndexes = scmEIWithIndexes; | ||
paInterfaceSpec.mNumEOs = 1; | ||
paInterfaceSpec.mEONames = scmEventOutputNames; | ||
paInterfaceSpec.mEOWith = scmEOWith; | ||
paInterfaceSpec.mEOWithIndexes = scmEOWithIndexes; | ||
paInterfaceSpec.mNumDIs = 1; | ||
paInterfaceSpec.mDINames = scmDataInputNames; | ||
paInterfaceSpec.mDIDataTypeNames = diDataTypeNames; | ||
paInterfaceSpec.mNumDOs = 1; | ||
paInterfaceSpec.mDONames = scmDataOutputNames; | ||
paInterfaceSpec.mDODataTypeNames = doDataTypeNames; | ||
|
||
return true; | ||
} | ||
|
||
CStringDictionary::TStringId GEN_FORTE_F_MOVE::getDataTypeNameId(const char *paConfigString) { | ||
const char *acPos = strchr(paConfigString, '_'); | ||
if(nullptr != acPos){ | ||
acPos++; | ||
acPos = strchr(acPos, '_'); | ||
if(nullptr != acPos){ | ||
acPos += 2; //put the position one after the separating number | ||
return CStringDictionary::getInstance().getId(acPos); | ||
} | ||
} | ||
return CStringDictionary::scmInvalidStringId; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013, 2024 ACIN, Martin Erich Jobst, | ||
* Primetals Technologies Austria 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: | ||
* Alois Zoitl - refactored from F_MOVE | ||
*******************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <genfb.h> | ||
#include "forte_any_variant.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 GEN_FORTE_F_MOVE : public CGenFunctionBlock<CFunctionBlock> { | ||
DECLARE_GENERIC_FIRMWARE_FB(GEN_FORTE_F_MOVE) | ||
|
||
private: | ||
static const CStringDictionary::TStringId scmDataInputNames[]; | ||
|
||
static const CStringDictionary::TStringId scmDataOutputNames[]; | ||
|
||
static const TEventID scmEventREQID = 0; | ||
|
||
static const TDataIOID scmEIWith[]; | ||
static const TForteInt16 scmEIWithIndexes[]; | ||
static const CStringDictionary::TStringId scmEventInputNames[]; | ||
|
||
static const TEventID scmEventCNFID = 0; | ||
|
||
static const TDataIOID scmEOWith[]; | ||
static const TForteInt16 scmEOWithIndexes[]; | ||
static const CStringDictionary::TStringId scmEventOutputNames[]; | ||
|
||
|
||
bool createInterfaceSpec(const char *paConfigString, SFBInterfaceSpec &paInterfaceSpec) override; | ||
|
||
void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; | ||
|
||
void readInputData(TEventID paEIID) override; | ||
void writeOutputData(TEventID paEIID) override; | ||
|
||
static CStringDictionary::TStringId getDataTypeNameId(const char *paConfigString); | ||
|
||
public: | ||
GEN_FORTE_F_MOVE(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); | ||
~GEN_FORTE_F_MOVE() override; | ||
|
||
CIEC_ANY_VARIANT& var_IN() { | ||
return *static_cast<CIEC_ANY_VARIANT*>(getDI(0)); | ||
} | ||
|
||
CIEC_ANY_VARIANT& var_OUT() { | ||
return *static_cast<CIEC_ANY_VARIANT*>(getDO(0)); | ||
} | ||
|
||
}; | ||
|
||
|
||
|