Skip to content

Commit

Permalink
Merge pull request #193 from eclipse-4diac/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
azoitl authored Jul 22, 2024
2 parents 1f0dbcc + 3db3d21 commit 6bb5ff5
Show file tree
Hide file tree
Showing 24 changed files with 225 additions and 129 deletions.
7 changes: 6 additions & 1 deletion src/arch/threadbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ namespace forte {
*/
void start();


/*! \brief Stops the execution of the thread
*
* This function immediately stops the execution of the thread (setting alive to false).
*/
void stop();

/*! \brief Stops the execution of the thread and waits for its end
*
* This function immediately stops the execution of the thread (setting alive to false) and waits till
* this is finished.
Expand Down
14 changes: 11 additions & 3 deletions src/arch/threadbase.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::start(){
}
}

template <typename TThreadHandle, TThreadHandle nullHandle, typename ThreadDeletePolicy>
void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::stop() {
if(nullHandle != mThreadHandle){
setAlive(false);
mThreadHandle = nullHandle; //indicate that thread is in shutdownmode
}
}

template <typename TThreadHandle, TThreadHandle nullHandle, typename ThreadDeletePolicy>
void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::end() {
CCriticalRegion criticalRegion(mThreadMutex);
if(nullHandle != mThreadHandle){
setAlive(false);
stop();
join();
ThreadDeletePolicy::deleteThread(mThreadHandle);
mThreadHandle = nullHandle;
}
}

Expand All @@ -65,10 +71,12 @@ template <typename TThreadHandle, TThreadHandle nullHandle, typename ThreadDelet
void CThreadBase<TThreadHandle, nullHandle, ThreadDeletePolicy>::runThread(CThreadBase *paThread) {
// if pointer is ok
if (nullptr != paThread) {
TThreadHandle threadHandle = paThread->mThreadHandle;
paThread->setAlive(true);
paThread->run();
paThread->setAlive(false);
paThread->mJoinSem.inc();
ThreadDeletePolicy::deleteThread(threadHandle);
} else {
DEVLOG_ERROR("pThread pointer is 0!");
}
Expand Down
4 changes: 4 additions & 0 deletions src/arch/utils/mainparam_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <string.h>
#include <stdlib.h>

#ifdef FORTE_TRACE_CTF
#include <string>
#endif

/*!\brief Lists the help for FORTE
*
*/
Expand Down
4 changes: 2 additions & 2 deletions src/arch/zephyr/forte_Init.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ extern "C" {
* @param paSignal Signal value to terminate instance
* @param paInstance Instance to terminate
*/
FORTE_SHARED_PREFIX void FORTE_SHARED_CALL forteStopInstance(int paSignal, TForteInstance* paResultInstance);
FORTE_SHARED_PREFIX void FORTE_SHARED_CALL forteStopInstance(int paSignal, TForteInstance paInstance);

/**
* \brief Terminates a Forte instance
* @param paInstance Instance to terminate
*/
FORTE_SHARED_PREFIX void FORTE_SHARED_CALL forteJoinInstance(TForteInstance* paResultInstance);
FORTE_SHARED_PREFIX void FORTE_SHARED_CALL forteJoinInstance(TForteInstance paInstance);

/**
* \brief Initializes the architecture. Prepare all resources needed by the Forte's instances. Must be called once before the first Forte instance is started
Expand Down
2 changes: 1 addition & 1 deletion src/core/basicfb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void CBasicFB::traceInstanceData() {

barectf_default_trace_instanceData(getResource()->getTracePlatformContext().getContext(),
getFBTypeName() ?: "null",
getInstanceName() ?: "null",
getFullQualifiedApplicationInstanceName('.').c_str() ?: "null",
static_cast<uint32_t >(inputs.size()), inputs_c_str.data(),
static_cast<uint32_t >(outputs.size()), outputs_c_str.data(),
static_cast<uint32_t >(internals.size()), internals_c_str.data(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/datatypes/forte_any_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CIEC_ANY_STRING : public CIEC_ANY_CHARS {
*
* @return number of bytes that this string has allocated for use
*/
TForteUInt16 getCapacity() const {
virtual TForteUInt16 getCapacity() const {
return (nullptr != getGenData()) ? (*((TForteUInt16 *)(getGenData() + 2))) : static_cast<TForteUInt16>(0);
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/datatypes/forte_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class CIEC_STRING : public CIEC_ANY_STRING {
return scmMaxStringLen;
}

TForteUInt16 getCapacity() const override {
return static_cast<TForteUInt16>(mValue.capacity());
}

void reserve(const TForteUInt16 paRequestedSize) override;

void assign(const char *paData, const TForteUInt16 paLen) override;
Expand Down
2 changes: 1 addition & 1 deletion src/core/ecet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void CEventChainExecutionThread::changeExecutionState(EMGMCommandType paCommand)
clear();
[[fallthrough]];
case EMGMCommandType::Stop:
setAlive(false); //end thread in both cases
stop();
break;
default:
break;
Expand Down
1 change: 1 addition & 0 deletions src/core/fbcontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class CFunctionBlock;
class CDevice;
class CResource;

namespace forte {
namespace core {
Expand Down
8 changes: 4 additions & 4 deletions src/core/funcbloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void CFunctionBlock::readData(size_t paDINum, CIEC_ANY& paValue, const CDataConn
paValue.toString(valueString.data(), valueString.capacity());
barectf_default_trace_inputData(this->getResource()->getTracePlatformContext().getContext(),
getFBTypeName() ?: "null",
getInstanceName() ?: "null",
getFullQualifiedApplicationInstanceName('.').c_str() ?: "null",
static_cast<uint64_t>(paDINum), valueString.c_str());
}
}
Expand All @@ -393,7 +393,7 @@ void CFunctionBlock::writeData(size_t paDONum, CIEC_ANY& paValue, CDataConnectio
paValue.toString(valueString.data(), valueString.capacity());
barectf_default_trace_outputData(this->getResource()->getTracePlatformContext().getContext(),
getFBTypeName() ?: "null",
getInstanceName() ?: "null",
getFullQualifiedApplicationInstanceName('.').c_str() ?: "null",
static_cast<uint64_t>(paDONum), valueString.c_str());
}
}
Expand Down Expand Up @@ -696,7 +696,7 @@ void CFunctionBlock::traceInputEvent(TEventID paEIID){
if(barectf_is_tracing_enabled(getResource()->getTracePlatformContext().getContext())) {
barectf_default_trace_receiveInputEvent(this->getResource()->getTracePlatformContext().getContext(),
getFBTypeName() ?: "null",
getInstanceName() ?: "null",
getFullQualifiedApplicationInstanceName('.').c_str() ?: "null",
static_cast<uint64_t>(paEIID));
traceInstanceData();
}
Expand All @@ -706,7 +706,7 @@ void CFunctionBlock::traceOutputEvent(TEventID paEOID){
if(barectf_is_tracing_enabled(getResource()->getTracePlatformContext().getContext())) {
barectf_default_trace_sendOutputEvent(this->getResource()->getTracePlatformContext().getContext(),
getFBTypeName() ?: "null",
getInstanceName() ?: "null",
getFullQualifiedApplicationInstanceName('.').c_str() ?: "null",
static_cast<uint64_t>(paEOID));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/funcbloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class CFunctionBlock {

/*!\brief Returns the type name of this FB instance
*/
const char * getFBTypeName(){
const char * getFBTypeName() const {
return CStringDictionary::getInstance().get(getFBTypeId());
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/mgmcmdstruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
#define MGMCMDSTRUCT_H_

#include "mgmcmd.h"
#include "datatypes/forte_string.h"
#include "utils/fixedcapvector.h"
#include "stringdict.h"
#include <string>

namespace forte {
namespace core {
Expand Down Expand Up @@ -70,7 +71,7 @@ namespace forte {

/*!\brief Additional params needed by a MGM command (e.g., to return results of query commands)
*/
CIEC_STRING mAdditionalParams;
std::string mAdditionalParams;

/*\brief pointer to the ID to generate the correct response */
char *mID;
Expand Down
2 changes: 1 addition & 1 deletion src/core/monitoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void CMonitoringHandler::appendEventWatch(std::string &paResponse, SEventWatchEn
paResponse += "\"/>\n</Port>"s;
}

void CMonitoringHandler::createFullFBName(CIEC_STRING &paFullName, forte::core::TNameIdentifier &paNameList){
void CMonitoringHandler::createFullFBName(std::string &paFullName, forte::core::TNameIdentifier &paNameList){
for(forte::core::TNameIdentifier::CIterator runner(paNameList.begin()); runner != paNameList.end(); ++runner){
paFullName.append(CStringDictionary::getInstance().get(*runner));
if(!runner.isLastEntry()){
Expand Down
4 changes: 2 additions & 2 deletions src/core/monitoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace forte {
typedef CSinglyLinkedList<SEventWatchEntry> TEventWatchList;

struct SFBMonitoringEntry{
CIEC_STRING mFullFBName;
std::string mFullFBName;
CFunctionBlock *mFB;
TDataWatchList mWatchedDataPoints;
TEventWatchList mWatchedEventPoints;
Expand Down Expand Up @@ -106,7 +106,7 @@ namespace forte {
static void appendPortTag(std::string &paResponse, CStringDictionary::TStringId paPortId);
void appendEventWatch(std::string &paResponse, SEventWatchEntry &paEventWatchEntry);

static void createFullFBName(CIEC_STRING &paFullName, forte::core::TNameIdentifier &paNameList);
static void createFullFBName(std::string &paFullName, forte::core::TNameIdentifier &paNameList);

static size_t getExtraSizeForEscapedChars(const CIEC_ANY& paDataValue);

Expand Down
Loading

0 comments on commit 6bb5ff5

Please sign in to comment.