Skip to content

Commit

Permalink
add startDate input
Browse files Browse the repository at this point in the history
  • Loading branch information
moniwe authored and azoitl committed Oct 15, 2024
1 parent ea5c30f commit f16ac09
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 29 deletions.
55 changes: 37 additions & 18 deletions src/modules/utils/timing/TIMESTAMP_NS_fct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* 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: TIMESTAMP_NS
*** Description: creates a Unix-Epoch-Timestamp in nanoseconds that is accepted by InfluxDB 2.0
*** Version:
*** 1.0: 2024-10-14/Monika Wenger - -
*
* This file was generated using the 4DIAC FORTE Export Filter
*
* Name: TIMESTAMP_NS
* Description: creates default a Unix-Epoch-Timestamp in nanoseconds use other start dates for other timestamp types
* Version:
* 1.0: 2024-10-14/Monika Wenger - initial commit -
*************************************************************************/

#include "TIMESTAMP_NS_fct.h"
Expand All @@ -31,35 +31,48 @@

DEFINE_FIRMWARE_FB(FORTE_TIMESTAMP_NS, g_nStringIdTIMESTAMP_NS)

const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmDataInputNames[] = {g_nStringIdstartDate};
const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmDataInputTypeIds[] = {g_nStringIdDATE_AND_TIME};
const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmDataOutputNames[] = {g_nStringId};
const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmDataOutputTypeIds[] = {g_nStringIdULINT};
const TForteInt16 FORTE_TIMESTAMP_NS::scmEIWithIndexes[] = {-1};
const TDataIOID FORTE_TIMESTAMP_NS::scmEIWith[] = {0, scmWithListDelimiter};
const TForteInt16 FORTE_TIMESTAMP_NS::scmEIWithIndexes[] = {0};
const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmEventInputNames[] = {g_nStringIdREQ};
const TDataIOID FORTE_TIMESTAMP_NS::scmEOWith[] = {0, scmWithListDelimiter};
const TForteInt16 FORTE_TIMESTAMP_NS::scmEOWithIndexes[] = {0};
const CStringDictionary::TStringId FORTE_TIMESTAMP_NS::scmEventOutputNames[] = {g_nStringIdCNF};
const SFBInterfaceSpec FORTE_TIMESTAMP_NS::scmFBInterfaceSpec = {
1, scmEventInputNames, nullptr, scmEIWithIndexes,
1, scmEventInputNames, scmEIWith, scmEIWithIndexes,
1, scmEventOutputNames, scmEOWith, scmEOWithIndexes,
0, nullptr, nullptr,
1, scmDataInputNames, scmDataInputTypeIds,
1, scmDataOutputNames, scmDataOutputTypeIds,
0, nullptr,
0, nullptr
};

FORTE_TIMESTAMP_NS::FORTE_TIMESTAMP_NS(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) :
CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId),
var_startDate(0_DATE_AND_TIME),
var_conn_(var_),
conn_CNF(this, 0),
conn_startDate(nullptr),
conn_(this, 0, &var_conn_) {
}

void FORTE_TIMESTAMP_NS::setInitialValues() {
var_startDate = 0_DATE_AND_TIME;
var_ = 0_ULINT;
}

void FORTE_TIMESTAMP_NS::readInputData(TEventID) {
// nothing to do
void FORTE_TIMESTAMP_NS::readInputData(const TEventID paEIID) {
switch(paEIID) {
case scmEventREQID: {
readData(0, var_startDate, conn_startDate);
break;
}
default:
break;
}
}

void FORTE_TIMESTAMP_NS::writeOutputData(const TEventID paEIID) {
Expand All @@ -73,7 +86,10 @@ void FORTE_TIMESTAMP_NS::writeOutputData(const TEventID paEIID) {
}
}

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

Expand All @@ -91,7 +107,10 @@ CEventConnection *FORTE_TIMESTAMP_NS::getEOConUnchecked(const TPortId paIndex) {
return nullptr;
}

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

Expand All @@ -103,15 +122,15 @@ CDataConnection *FORTE_TIMESTAMP_NS::getDOConUnchecked(const TPortId paIndex) {
}

void FORTE_TIMESTAMP_NS::executeEvent(const TEventID, CEventChainExecutionThread *const paECET) {
var_ = func_TIMESTAMP_NS();
var_ = func_TIMESTAMP_NS(var_startDate);
sendOutputEvent(scmEventCNFID, paECET);
}

CIEC_ULINT func_TIMESTAMP_NS() {
CIEC_ULINT func_TIMESTAMP_NS(CIEC_DATE_AND_TIME st_lv_startDate) {
CIEC_ULINT st_ret_val = 0_ULINT;

#line 2 "TIMESTAMP_NS.fct"
st_ret_val = func_TIME_IN_NS_TO_ULINT(func_SUB<CIEC_TIME>(func_NOW(), 0_DATE_AND_TIME));
#line 5 "TIMESTAMP_NS.fct"
st_ret_val = func_TIME_IN_NS_TO_ULINT(func_SUB<CIEC_TIME>(func_NOW(), st_lv_startDate));

return st_ret_val;
}
31 changes: 20 additions & 11 deletions src/modules/utils/timing/TIMESTAMP_NS_fct.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
* 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: TIMESTAMP_NS
*** Description: creates a Unix-Epoch-Timestamp in nanoseconds that is accepted by InfluxDB 2.0
*** Version:
*** 1.0: 2024-10-14/Monika Wenger - -
*
* This file was generated using the 4DIAC FORTE Export Filter
*
* Name: TIMESTAMP_NS
* Description: creates default a Unix-Epoch-Timestamp in nanoseconds use other start dates for other timestamp types
* Version:
* 1.0: 2024-10-14/Monika Wenger - initial commit -
*************************************************************************/

#pragma once

#include "funcbloc.h"
#include "forte_date_and_time.h"
#include "forte_ulint.h"
#include "iec61131_functions.h"
#include "forte_array_common.h"
Expand All @@ -28,9 +29,12 @@ class FORTE_TIMESTAMP_NS final : public CFunctionBlock {
DECLARE_FIRMWARE_FB(FORTE_TIMESTAMP_NS)

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;
Expand All @@ -49,12 +53,16 @@ class FORTE_TIMESTAMP_NS final : public CFunctionBlock {
public:
FORTE_TIMESTAMP_NS(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer);

CIEC_DATE_AND_TIME var_startDate;

CIEC_ULINT var_;

CIEC_ULINT var_conn_;

CEventConnection conn_CNF;

CDataConnection *conn_startDate;

CDataConnection conn_;

CIEC_ANY *getDI(size_t) override;
Expand All @@ -63,14 +71,15 @@ class FORTE_TIMESTAMP_NS final : public CFunctionBlock {
CDataConnection **getDIConUnchecked(TPortId) override;
CDataConnection *getDOConUnchecked(TPortId) override;

void evt_REQ() {
void evt_REQ(const CIEC_DATE_AND_TIME &pastartDate) {
var_startDate = pastartDate;
executeEvent(scmEventREQID, nullptr);
}

void operator()() {
evt_REQ();
void operator()(const CIEC_DATE_AND_TIME &pastartDate) {
evt_REQ(pastartDate);
}
};

CIEC_ULINT func_TIMESTAMP_NS();
CIEC_ULINT func_TIMESTAMP_NS(CIEC_DATE_AND_TIME st_lv_startDate);

0 comments on commit f16ac09

Please sign in to comment.