Skip to content

Commit

Permalink
Add Timer FBs (eclipse-4diac#36)
Browse files Browse the repository at this point in the history
* Update E_IMPULSE function block to handle standard timer functions:
- Change data input and output names from TM to PT and QO to Q respectively
- Update internal variables and connections accordingly

* Copy over E_CTUD to E_CTUD_UDINT with corrected name spelling.

* Add standard timer function block (pulse) implementation. Define input and output data, event connections, internal FBs, and set initial values.

* Add standard timer function block for on/off-delay timing

This commit adds a new file implementing the E_TONOF function block, including data input/output definitions and event connections. Initial values are set, and read/write methods are implemented for handling input/output data.

* Add E_TON function block for standard timer (on-delay timing).

This commit introduces the E_TON function block for on-delay timing, including initialization, data connections, event handling, and interface definitions.

* Add standard timer function block for off-delay timing. Define inputs, outputs, event connections, and internal FBs.

* Update event source files list

Added multiple event source files to the list in CMakeLists.txt.

* Update event function block names and file references.

- Rename E_IMPULSE to E_PULSE in source files
- Update class names, header files, and function definitions accordingly.

* Update internal and event connections, add new FB instances.

- Added a new FB instance E_PERMIT.
- Updated event connections for E_RS, E_DELAY, and E_PERMIT.
- Adjusted data connections for PT, Q, IN ports.

* Update copyright year and rename function block types.

Details:
- Updated copyright year to 2024 for HR Agrartechnik GmbH.
- Renamed function block type E_IMPULSE to E_PULSE on 2024-05-03 by Franz Hoepfinger.
  • Loading branch information
franz-hoepfinger-4diac authored Apr 5, 2024
1 parent dd310ed commit a5c5826
Show file tree
Hide file tree
Showing 14 changed files with 1,257 additions and 182 deletions.
2 changes: 1 addition & 1 deletion src/stdfblib/events/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ forte_add_sourcefile_hcpp(E_RDELAY E_RESTART E_R_TRIG E_SPLIT E_SWITCH)
forte_add_sourcefile_hcpp(GEN_E_DEMUX GEN_E_MUX)
forte_add_sourcefile_hcpp(ATimeOut E_TimeOut ARTimeOut E_RTimeOut E_T_FF)
forte_add_sourcefile_hcpp(E_TRAIN)
forte_add_sourcefile_hcpp(E_IMPULSE_fbt)
forte_add_sourcefile_hcpp(E_PULSE_fbt E_TP_fbt E_TON_fbt E_TOF_fbt E_TONOF_fbt)
2 changes: 1 addition & 1 deletion src/stdfblib/events/E_CTUD_UDINT_fbt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*** Version:
*** 1.0: 2017-09-22/Alois Zoitl - fortiss GmbH - initial API and implementation and/or initial documentation (E_CTUD)
*** 1.1: 2019-07-09/Alois Zoitl - JKU - fixed bug in down counting (E_CTUD)
*** 1.2: 2024-02-10/Franz Höpfinger - HR Agrartechnik GmbH - Copy over E_CTUD to E_CTUD_UDINT
*** 1.2: 2024-02-10/Franz Hoepfinger - HR Agrartechnik GmbH - Copy over E_CTUD to E_CTUD_UDINT
*************************************************************************/

#include "E_CTUD_UDINT_fbt.h"
Expand Down
2 changes: 1 addition & 1 deletion src/stdfblib/events/E_CTUD_UDINT_fbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*** Version:
*** 1.0: 2017-09-22/Alois Zoitl - fortiss GmbH - initial API and implementation and/or initial documentation (E_CTUD)
*** 1.1: 2019-07-09/Alois Zoitl - JKU - fixed bug in down counting (E_CTUD)
*** 1.2: 2024-02-10/Franz Höpfinger - HR Agrartechnik GmbH - Copy over E_CTUD to E_CTUD_UDINT
*** 1.2: 2024-02-10/Franz Hoepfinger - HR Agrartechnik GmbH - Copy over E_CTUD to E_CTUD_UDINT
*************************************************************************/

#pragma once
Expand Down
158 changes: 0 additions & 158 deletions src/stdfblib/events/E_IMPULSE_fbt.cpp

This file was deleted.

159 changes: 159 additions & 0 deletions src/stdfblib/events/E_PULSE_fbt.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
/*************************************************************************
*** Copyright (c) 2024 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
***
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG!
***
*** Name: E_PULSE
*** Description: standard timer function block (pulse)
*** Version:
*** 1.0: 2023-08-21/Franz Hoepfinger - HR Agrartechnik GmbH - initial implementation as E_IMPULSE
*** 2024-05-03/Franz Hoepfinger - HR Agrartechnik GmbH - renamed to E_PULSE
*************************************************************************/

#include "E_PULSE_fbt.h"
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
#include "E_PULSE_fbt_gen.cpp"
#endif

#include "criticalregion.h"
#include "resource.h"

DEFINE_FIRMWARE_FB(FORTE_E_PULSE, g_nStringIdE_PULSE)

const CStringDictionary::TStringId FORTE_E_PULSE::scmDataInputNames[] = {g_nStringIdPT};
const CStringDictionary::TStringId FORTE_E_PULSE::scmDataInputTypeIds[] = {g_nStringIdTIME};
const CStringDictionary::TStringId FORTE_E_PULSE::scmDataOutputNames[] = {g_nStringIdQ};
const CStringDictionary::TStringId FORTE_E_PULSE::scmDataOutputTypeIds[] = {g_nStringIdBOOL};
const TDataIOID FORTE_E_PULSE::scmEIWith[] = {0, scmWithListDelimiter};
const TForteInt16 FORTE_E_PULSE::scmEIWithIndexes[] = {0, -1};
const CStringDictionary::TStringId FORTE_E_PULSE::scmEventInputNames[] = {g_nStringIdREQ, g_nStringIdR};
const TDataIOID FORTE_E_PULSE::scmEOWith[] = {0, scmWithListDelimiter};
const TForteInt16 FORTE_E_PULSE::scmEOWithIndexes[] = {0};
const CStringDictionary::TStringId FORTE_E_PULSE::scmEventOutputNames[] = {g_nStringIdCNF};
const SFBInterfaceSpec FORTE_E_PULSE::scmFBInterfaceSpec = {
2, scmEventInputNames, scmEIWith, scmEIWithIndexes,
1, scmEventOutputNames, scmEOWith, scmEOWithIndexes,
1, scmDataInputNames, scmDataInputTypeIds,
1, scmDataOutputNames, scmDataOutputTypeIds,
0, nullptr,
0, nullptr
};

FORTE_E_PULSE::FORTE_E_PULSE(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) :
CCompositeFB(paContainer, &scmFBInterfaceSpec, paInstanceNameId, scmFBNData),
var_conn_Q(var_Q),
conn_CNF(this, 0),
conn_PT(nullptr),
conn_Q(this, 0, &var_conn_Q) {
};

void FORTE_E_PULSE::setInitialValues() {
var_PT = 0_TIME;
var_Q = 0_BOOL;
}

const SCFB_FBInstanceData FORTE_E_PULSE::scmInternalFBs[] = {
{g_nStringIdE_DELAY, g_nStringIdE_DELAY},
{g_nStringIdE_SR, g_nStringIdE_SR}
};


const SCFB_FBConnectionData FORTE_E_PULSE::scmEventConnections[] = {
{GENERATE_CONNECTION_PORT_ID_1_ARG(g_nStringIdREQ), -1, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_DELAY, g_nStringIdSTART), 0},
{GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_DELAY, g_nStringIdEO), 0, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_SR, g_nStringIdR), 1},
{GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_SR, g_nStringIdEO), 1, GENERATE_CONNECTION_PORT_ID_1_ARG(g_nStringIdCNF), -1},
{GENERATE_CONNECTION_PORT_ID_1_ARG(g_nStringIdR), -1, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_DELAY, g_nStringIdSTOP), 0},
};

const SCFB_FBFannedOutConnectionData FORTE_E_PULSE::scmFannedOutEventConnections[] = {
{0, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_SR, g_nStringIdS), 1},
{3, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_SR, g_nStringIdR), 1},
};

const SCFB_FBConnectionData FORTE_E_PULSE::scmDataConnections[] = {
{GENERATE_CONNECTION_PORT_ID_1_ARG(g_nStringIdPT), -1, GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_DELAY, g_nStringIdDT), 0},
{GENERATE_CONNECTION_PORT_ID_2_ARG(g_nStringIdE_SR, g_nStringIdQ), 1, GENERATE_CONNECTION_PORT_ID_1_ARG(g_nStringIdQ), -1},
};

const SCFB_FBNData FORTE_E_PULSE::scmFBNData = {
2, scmInternalFBs,
4, scmEventConnections,
2, scmFannedOutEventConnections,
2, scmDataConnections,
0, nullptr,
0, nullptr,
0, nullptr
};

void FORTE_E_PULSE::readInternal2InterfaceOutputData(const TEventID paEOID) {
switch(paEOID) {
case scmEventCNFID: {
if(CDataConnection *conn = getIn2IfConUnchecked(0); conn) { conn->readData(var_Q); }
break;
}
default:
break;
}
}
void FORTE_E_PULSE::readInputData(const TEventID paEIID) {
switch(paEIID) {
case scmEventREQID: {
readData(0, var_PT, conn_PT);
break;
}
default:
break;
}
}

void FORTE_E_PULSE::writeOutputData(const TEventID paEIID) {
switch(paEIID) {
case scmEventCNFID: {
writeData(0, var_Q, conn_Q);
break;
}
default:
break;
}
}

CIEC_ANY *FORTE_E_PULSE::getDI(const size_t paIndex) {
switch(paIndex) {
case 0: return &var_PT;
}
return nullptr;
}

CIEC_ANY *FORTE_E_PULSE::getDO(const size_t paIndex) {
switch(paIndex) {
case 0: return &var_Q;
}
return nullptr;
}

CEventConnection *FORTE_E_PULSE::getEOConUnchecked(const TPortId paIndex) {
switch(paIndex) {
case 0: return &conn_CNF;
}
return nullptr;
}

CDataConnection **FORTE_E_PULSE::getDIConUnchecked(const TPortId paIndex) {
switch(paIndex) {
case 0: return &conn_PT;
}
return nullptr;
}

CDataConnection *FORTE_E_PULSE::getDOConUnchecked(const TPortId paIndex) {
switch(paIndex) {
case 0: return &conn_Q;
}
return nullptr;
}

Loading

0 comments on commit a5c5826

Please sign in to comment.