-
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.
- Loading branch information
Showing
4 changed files
with
273 additions
and
3 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
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,160 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014, 2024 fortiss GmbH, HR Agrartechnik 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 | ||
* | ||
*** Name: QE | ||
*** Description: Output service interface function block for event output data | ||
*** Version: | ||
*** 1.0: 2014-08-26/Waldemar Eisenmenger - fortiss GmbH - | ||
*** 1.1: 2014-08-30/Alois Zoitl - fortiss GmbH - | ||
*** 1.2: 2015-06-10/Monika Wenger - fortiss GmbH - | ||
*** 1.3: 2024-05-16/Franz Höpfinger - HR Agrartechnik GmbH - copied over QX to QE, and removed the OUT | ||
*************************************************************************/ | ||
|
||
#include "QE_fbt.h" | ||
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP | ||
#include "QE_fbt_gen.cpp" | ||
#endif | ||
|
||
#include "criticalregion.h" | ||
#include "resource.h" | ||
|
||
DEFINE_FIRMWARE_FB(FORTE_QE, g_nStringIdQE) | ||
|
||
const CStringDictionary::TStringId FORTE_QE::scmDataInputNames[] = {g_nStringIdQI, g_nStringIdPARAMS}; | ||
const CStringDictionary::TStringId FORTE_QE::scmDataInputTypeIds[] = {g_nStringIdBOOL, g_nStringIdSTRING}; | ||
const CStringDictionary::TStringId FORTE_QE::scmDataOutputNames[] = {g_nStringIdQO, g_nStringIdSTATUS}; | ||
const CStringDictionary::TStringId FORTE_QE::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdSTRING}; | ||
const TDataIOID FORTE_QE::scmEIWith[] = {0, 1, scmWithListDelimiter, 0, scmWithListDelimiter}; | ||
const TForteInt16 FORTE_QE::scmEIWithIndexes[] = {0, 3}; | ||
const CStringDictionary::TStringId FORTE_QE::scmEventInputNames[] = {g_nStringIdINIT, g_nStringIdREQ}; | ||
const TDataIOID FORTE_QE::scmEOWith[] = {0, 1, scmWithListDelimiter, 0, 1, scmWithListDelimiter}; | ||
const TForteInt16 FORTE_QE::scmEOWithIndexes[] = {0, 3}; | ||
const CStringDictionary::TStringId FORTE_QE::scmEventOutputNames[] = {g_nStringIdINITO, g_nStringIdCNF}; | ||
const SFBInterfaceSpec FORTE_QE::scmFBInterfaceSpec = { | ||
2, scmEventInputNames, scmEIWith, scmEIWithIndexes, | ||
2, scmEventOutputNames, scmEOWith, scmEOWithIndexes, | ||
2, scmDataInputNames, scmDataInputTypeIds, | ||
2, scmDataOutputNames, scmDataOutputTypeIds, | ||
0, nullptr, | ||
0, nullptr | ||
}; | ||
|
||
FORTE_QE::FORTE_QE(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : | ||
CProcessInterface(paContainer, &scmFBInterfaceSpec, paInstanceNameId), | ||
var_conn_QO(var_QO), | ||
var_conn_STATUS(var_STATUS), | ||
conn_INITO(this, 0), | ||
conn_CNF(this, 1), | ||
conn_QI(nullptr), | ||
conn_PARAMS(nullptr), | ||
conn_QO(this, 0, &var_conn_QO), | ||
conn_STATUS(this, 1, &var_conn_STATUS) { | ||
}; | ||
|
||
void FORTE_QE::setInitialValues() { | ||
var_QI = 0_BOOL; | ||
var_PARAMS = ""_STRING; | ||
var_QO = 0_BOOL; | ||
var_STATUS = ""_STRING; | ||
} | ||
|
||
void FORTE_QE::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { | ||
switch(paEIID) { | ||
case scmEventINITID: | ||
if (var_QI) { | ||
var_QO = CIEC_BOOL(CProcessInterface::initialise(false, paECET)); //initialise as output | ||
} else { | ||
var_QO = CIEC_BOOL(CProcessInterface::deinitialise()); | ||
} | ||
sendOutputEvent(scmEventINITOID, paECET); | ||
break; | ||
case scmEventREQID: | ||
if (var_QI) { | ||
var_QO = CIEC_BOOL(CProcessInterface::write(var_QO)); | ||
} else { | ||
var_QO = false_BOOL; | ||
} | ||
sendOutputEvent(scmEventCNFID, paECET); | ||
break; | ||
} | ||
} | ||
|
||
void FORTE_QE::readInputData(const TEventID paEIID) { | ||
switch(paEIID) { | ||
case scmEventINITID: { | ||
readData(0, var_QI, conn_QI); | ||
readData(1, var_PARAMS, conn_PARAMS); | ||
break; | ||
} | ||
case scmEventREQID: { | ||
readData(0, var_QI, conn_QI); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void FORTE_QE::writeOutputData(const TEventID paEIID) { | ||
switch(paEIID) { | ||
case scmEventINITOID: { | ||
writeData(0, var_QO, conn_QO); | ||
writeData(1, var_STATUS, conn_STATUS); | ||
break; | ||
} | ||
case scmEventCNFID: { | ||
writeData(0, var_QO, conn_QO); | ||
writeData(1, var_STATUS, conn_STATUS); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
CIEC_ANY *FORTE_QE::getDI(const size_t paIndex) { | ||
switch(paIndex) { | ||
case 0: return &var_QI; | ||
case 1: return &var_PARAMS; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CIEC_ANY *FORTE_QE::getDO(const size_t paIndex) { | ||
switch(paIndex) { | ||
case 0: return &var_QO; | ||
case 1: return &var_STATUS; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CEventConnection *FORTE_QE::getEOConUnchecked(const TPortId paIndex) { | ||
switch(paIndex) { | ||
case 0: return &conn_INITO; | ||
case 1: return &conn_CNF; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CDataConnection **FORTE_QE::getDIConUnchecked(const TPortId paIndex) { | ||
switch(paIndex) { | ||
case 0: return &conn_QI; | ||
case 1: return &conn_PARAMS; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CDataConnection *FORTE_QE::getDOConUnchecked(const TPortId paIndex) { | ||
switch(paIndex) { | ||
case 0: return &conn_QO; | ||
case 1: return &conn_STATUS; | ||
} | ||
return nullptr; | ||
} | ||
|
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,107 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2014, 2024 fortiss GmbH, HR Agrartechnik 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 | ||
* | ||
*** Name: QE | ||
*** Description: Output service interface function block for event output data | ||
*** Version: | ||
*** 1.0: 2014-08-26/Waldemar Eisenmenger - fortiss GmbH - | ||
*** 1.1: 2014-08-30/Alois Zoitl - fortiss GmbH - | ||
*** 1.2: 2015-06-10/Monika Wenger - fortiss GmbH - | ||
*** 1.3: 2024-05-16/Franz Höpfinger - HR Agrartechnik GmbH - copied over QX to QE, and removed the OUT | ||
*************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#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" | ||
|
||
#include "processinterface.h" | ||
|
||
class FORTE_QE final : public CProcessInterface { | ||
DECLARE_FIRMWARE_FB(FORTE_QE) | ||
|
||
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_QE(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); | ||
|
||
CIEC_BOOL var_QI; | ||
CIEC_STRING var_PARAMS; | ||
|
||
CIEC_BOOL var_QO; | ||
CIEC_STRING var_STATUS; | ||
|
||
CIEC_BOOL var_conn_QO; | ||
CIEC_STRING var_conn_STATUS; | ||
|
||
CEventConnection conn_INITO; | ||
CEventConnection conn_CNF; | ||
|
||
CDataConnection *conn_QI; | ||
CDataConnection *conn_PARAMS; | ||
|
||
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 &paPARAMS, CIEC_BOOL &paQO, CIEC_STRING &paSTATUS) { | ||
var_QI = paQI; | ||
var_PARAMS = paPARAMS; | ||
executeEvent(scmEventINITID, nullptr); | ||
paQO = var_QO; | ||
paSTATUS = var_STATUS; | ||
} | ||
|
||
void evt_REQ(const CIEC_BOOL &paQI, const CIEC_STRING &paPARAMS, CIEC_BOOL &paQO, CIEC_STRING &paSTATUS) { | ||
var_QI = paQI; | ||
var_PARAMS = paPARAMS; | ||
executeEvent(scmEventREQID, nullptr); | ||
paQO = var_QO; | ||
paSTATUS = var_STATUS; | ||
} | ||
|
||
void operator()(const CIEC_BOOL &paQI, const CIEC_STRING &paPARAMS, CIEC_BOOL &paQO, CIEC_STRING &paSTATUS) { | ||
evt_INIT(paQI, paPARAMS, paQO, paSTATUS); | ||
} | ||
}; | ||
|
||
|