Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add splitting directory and SPLIT_XYZ_INTO_BOOLS_fct functions #250

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 201 additions & 0 deletions src/modules/utils/splitting/SPLIT_BYTE_INTO_BOOLS_fct.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/*************************************************************************
*** 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
***
*** FORTE Library Element
***
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG!
***
*** Name: SPLIT_BYTE_INTO_BOOLS
*** Description: this Function extracts the 8 BOOLS from a byte
*** Version:
*** 1.0: 2024-02-22/Franz Höpfinger - HR Agrartechnik - initial Implementation
*** 1.1: 2024-07-28/Moritz Ortmeier - HR Agrartechnik - rename Function and change Output Variables
*************************************************************************/

#include "SPLIT_BYTE_INTO_BOOLS_fct.h"
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
#include "SPLIT_BYTE_INTO_BOOLS_fct_gen.cpp"
#endif

#include "criticalregion.h"
#include "resource.h"
#include "forte_byte.h"
#include "forte_bool.h"
#include "iec61131_functions.h"
#include "forte_array_common.h"
#include "forte_array.h"
#include "forte_array_fixed.h"
#include "forte_array_variable.h"

DEFINE_FIRMWARE_FB(FORTE_SPLIT_BYTE_INTO_BOOLS, g_nStringIdSPLIT_BYTE_INTO_BOOLS)

const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmDataInputNames[] = {g_nStringIdIN};
const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmDataInputTypeIds[] = {g_nStringIdBYTE};
const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmDataOutputNames[] = {g_nStringIdBIT_00, g_nStringIdBIT_01, g_nStringIdBIT_02, g_nStringIdBIT_03, g_nStringIdBIT_04, g_nStringIdBIT_05, g_nStringIdBIT_06, g_nStringIdBIT_07};
const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmDataOutputTypeIds[] = {g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL, g_nStringIdBOOL};
const TDataIOID FORTE_SPLIT_BYTE_INTO_BOOLS::scmEIWith[] = {0, scmWithListDelimiter};
const TForteInt16 FORTE_SPLIT_BYTE_INTO_BOOLS::scmEIWithIndexes[] = {0};
const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmEventInputNames[] = {g_nStringIdREQ};
const TDataIOID FORTE_SPLIT_BYTE_INTO_BOOLS::scmEOWith[] = {0, 1, 2, 3, 4, 5, 6, 7, scmWithListDelimiter};
const TForteInt16 FORTE_SPLIT_BYTE_INTO_BOOLS::scmEOWithIndexes[] = {0};
const CStringDictionary::TStringId FORTE_SPLIT_BYTE_INTO_BOOLS::scmEventOutputNames[] = {g_nStringIdCNF};
const SFBInterfaceSpec FORTE_SPLIT_BYTE_INTO_BOOLS::scmFBInterfaceSpec = {
1, scmEventInputNames, scmEIWith, scmEIWithIndexes,
1, scmEventOutputNames, scmEOWith, scmEOWithIndexes,
1, scmDataInputNames, scmDataInputTypeIds,
8, scmDataOutputNames, scmDataOutputTypeIds,
0, nullptr,
0, nullptr
};

FORTE_SPLIT_BYTE_INTO_BOOLS::FORTE_SPLIT_BYTE_INTO_BOOLS(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) :
CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId),
var_conn_BIT_00(var_BIT_00),
var_conn_BIT_01(var_BIT_01),
var_conn_BIT_02(var_BIT_02),
var_conn_BIT_03(var_BIT_03),
var_conn_BIT_04(var_BIT_04),
var_conn_BIT_05(var_BIT_05),
var_conn_BIT_06(var_BIT_06),
var_conn_BIT_07(var_BIT_07),
conn_CNF(this, 0),
conn_IN(nullptr),
conn_BIT_00(this, 0, &var_conn_BIT_00),
conn_BIT_01(this, 1, &var_conn_BIT_01),
conn_BIT_02(this, 2, &var_conn_BIT_02),
conn_BIT_03(this, 3, &var_conn_BIT_03),
conn_BIT_04(this, 4, &var_conn_BIT_04),
conn_BIT_05(this, 5, &var_conn_BIT_05),
conn_BIT_06(this, 6, &var_conn_BIT_06),
conn_BIT_07(this, 7, &var_conn_BIT_07) {
}

void FORTE_SPLIT_BYTE_INTO_BOOLS::setInitialValues() {
var_IN = 0_BYTE;
var_BIT_00 = 0_BOOL;
var_BIT_01 = 0_BOOL;
var_BIT_02 = 0_BOOL;
var_BIT_03 = 0_BOOL;
var_BIT_04 = 0_BOOL;
var_BIT_05 = 0_BOOL;
var_BIT_06 = 0_BOOL;
var_BIT_07 = 0_BOOL;
}

void FORTE_SPLIT_BYTE_INTO_BOOLS::readInputData(const TEventID paEIID) {
switch(paEIID) {
case scmEventREQID: {
readData(0, var_IN, conn_IN);
break;
}
default:
break;
}
}

void FORTE_SPLIT_BYTE_INTO_BOOLS::writeOutputData(const TEventID paEIID) {
switch(paEIID) {
case scmEventCNFID: {
writeData(0, var_BIT_00, conn_BIT_00);
writeData(1, var_BIT_01, conn_BIT_01);
writeData(2, var_BIT_02, conn_BIT_02);
writeData(3, var_BIT_03, conn_BIT_03);
writeData(4, var_BIT_04, conn_BIT_04);
writeData(5, var_BIT_05, conn_BIT_05);
writeData(6, var_BIT_06, conn_BIT_06);
writeData(7, var_BIT_07, conn_BIT_07);
break;
}
default:
break;
}
}

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

CIEC_ANY *FORTE_SPLIT_BYTE_INTO_BOOLS::getDO(const size_t paIndex) {
switch(paIndex) {
case 0: return &var_BIT_00;
case 1: return &var_BIT_01;
case 2: return &var_BIT_02;
case 3: return &var_BIT_03;
case 4: return &var_BIT_04;
case 5: return &var_BIT_05;
case 6: return &var_BIT_06;
case 7: return &var_BIT_07;
}
return nullptr;
}

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

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

CDataConnection *FORTE_SPLIT_BYTE_INTO_BOOLS::getDOConUnchecked(const TPortId paIndex) {
switch(paIndex) {
case 0: return &conn_BIT_00;
case 1: return &conn_BIT_01;
case 2: return &conn_BIT_02;
case 3: return &conn_BIT_03;
case 4: return &conn_BIT_04;
case 5: return &conn_BIT_05;
case 6: return &conn_BIT_06;
case 7: return &conn_BIT_07;
}
return nullptr;
}

void FORTE_SPLIT_BYTE_INTO_BOOLS::executeEvent(const TEventID, CEventChainExecutionThread *const paECET) {
func_SPLIT_BYTE_INTO_BOOLS(var_IN, var_BIT_00, var_BIT_01, var_BIT_02, var_BIT_03, var_BIT_04, var_BIT_05, var_BIT_06, var_BIT_07);
sendOutputEvent(scmEventCNFID, paECET);
}

void func_SPLIT_BYTE_INTO_BOOLS(CIEC_BYTE st_lv_IN, CIEC_BOOL &st_lv_BIT_00, CIEC_BOOL &st_lv_BIT_01, CIEC_BOOL &st_lv_BIT_02, CIEC_BOOL &st_lv_BIT_03, CIEC_BOOL &st_lv_BIT_04, CIEC_BOOL &st_lv_BIT_05, CIEC_BOOL &st_lv_BIT_06, CIEC_BOOL &st_lv_BIT_07) {
st_lv_BIT_00 = 0_BOOL;
st_lv_BIT_01 = 0_BOOL;
st_lv_BIT_02 = 0_BOOL;
st_lv_BIT_03 = 0_BOOL;
st_lv_BIT_04 = 0_BOOL;
st_lv_BIT_05 = 0_BOOL;
st_lv_BIT_06 = 0_BOOL;
st_lv_BIT_07 = 0_BOOL;

#line 19 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_00 = st_lv_IN.cpartial<CIEC_BOOL>(0);
#line 20 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_01 = st_lv_IN.cpartial<CIEC_BOOL>(1);
#line 21 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_02 = st_lv_IN.cpartial<CIEC_BOOL>(2);
#line 22 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_03 = st_lv_IN.cpartial<CIEC_BOOL>(3);
#line 23 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_04 = st_lv_IN.cpartial<CIEC_BOOL>(4);
#line 24 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_05 = st_lv_IN.cpartial<CIEC_BOOL>(5);
#line 25 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_06 = st_lv_IN.cpartial<CIEC_BOOL>(6);
#line 26 "SPLIT_BYTE_INTO_BOOLS.fct"
st_lv_BIT_07 = st_lv_IN.cpartial<CIEC_BOOL>(7);

}

118 changes: 118 additions & 0 deletions src/modules/utils/splitting/SPLIT_BYTE_INTO_BOOLS_fct.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*************************************************************************
*** 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
***
*** FORTE Library Element
***
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG!
***
*** Name: SPLIT_BYTE_INTO_BOOLS
*** Description: this Function extracts the 8 BOOLS from a byte
*** Version:
*** 1.0: 2024-02-22/Franz Höpfinger - HR Agrartechnik - initial Implementation
*** 1.1: 2024-07-28/Moritz Ortmeier - HR Agrartechnik - rename Function and change Output Variables
*************************************************************************/

#pragma once

#include "funcbloc.h"
#include "forte_byte.h"
#include "forte_bool.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_SPLIT_BYTE_INTO_BOOLS final : public CFunctionBlock {
DECLARE_FIRMWARE_FB(FORTE_SPLIT_BYTE_INTO_BOOLS)

private:
static const CStringDictionary::TStringId scmDataInputNames[];
static const CStringDictionary::TStringId scmDataInputTypeIds[];
static const CStringDictionary::TStringId scmDataOutputNames[];
static const CStringDictionary::TStringId scmDataOutputTypeIds[];
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[];

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_SPLIT_BYTE_INTO_BOOLS(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer);

CIEC_BYTE var_IN;

CIEC_BOOL var_BIT_00;
CIEC_BOOL var_BIT_01;
CIEC_BOOL var_BIT_02;
CIEC_BOOL var_BIT_03;
CIEC_BOOL var_BIT_04;
CIEC_BOOL var_BIT_05;
CIEC_BOOL var_BIT_06;
CIEC_BOOL var_BIT_07;

CIEC_BOOL var_conn_BIT_00;
CIEC_BOOL var_conn_BIT_01;
CIEC_BOOL var_conn_BIT_02;
CIEC_BOOL var_conn_BIT_03;
CIEC_BOOL var_conn_BIT_04;
CIEC_BOOL var_conn_BIT_05;
CIEC_BOOL var_conn_BIT_06;
CIEC_BOOL var_conn_BIT_07;

CEventConnection conn_CNF;

CDataConnection *conn_IN;

CDataConnection conn_BIT_00;
CDataConnection conn_BIT_01;
CDataConnection conn_BIT_02;
CDataConnection conn_BIT_03;
CDataConnection conn_BIT_04;
CDataConnection conn_BIT_05;
CDataConnection conn_BIT_06;
CDataConnection conn_BIT_07;

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_REQ(const CIEC_BYTE &paIN, CIEC_BOOL &paBIT_00, CIEC_BOOL &paBIT_01, CIEC_BOOL &paBIT_02, CIEC_BOOL &paBIT_03, CIEC_BOOL &paBIT_04, CIEC_BOOL &paBIT_05, CIEC_BOOL &paBIT_06, CIEC_BOOL &paBIT_07) {
var_IN = paIN;
executeEvent(scmEventREQID, nullptr);
paBIT_00 = var_BIT_00;
paBIT_01 = var_BIT_01;
paBIT_02 = var_BIT_02;
paBIT_03 = var_BIT_03;
paBIT_04 = var_BIT_04;
paBIT_05 = var_BIT_05;
paBIT_06 = var_BIT_06;
paBIT_07 = var_BIT_07;
}

void operator()(const CIEC_BYTE &paIN, CIEC_BOOL &paBIT_00, CIEC_BOOL &paBIT_01, CIEC_BOOL &paBIT_02, CIEC_BOOL &paBIT_03, CIEC_BOOL &paBIT_04, CIEC_BOOL &paBIT_05, CIEC_BOOL &paBIT_06, CIEC_BOOL &paBIT_07) {
evt_REQ(paIN, paBIT_00, paBIT_01, paBIT_02, paBIT_03, paBIT_04, paBIT_05, paBIT_06, paBIT_07);
}
};

void func_SPLIT_BYTE_INTO_BOOLS(CIEC_BYTE st_lv_IN, CIEC_BOOL &st_lv_BIT_00, CIEC_BOOL &st_lv_BIT_01, CIEC_BOOL &st_lv_BIT_02, CIEC_BOOL &st_lv_BIT_03, CIEC_BOOL &st_lv_BIT_04, CIEC_BOOL &st_lv_BIT_05, CIEC_BOOL &st_lv_BIT_06, CIEC_BOOL &st_lv_BIT_07);


Loading