13#include <dpsim/Config.h>
18#include <readerwriterqueue.h>
28 typedef std::shared_ptr<InterfaceQueued>
Ptr;
45 const String &name =
"",
UInt downsampling = 1)
48 moodycamel::BlockingReaderWriterQueue<AttributePacket>>();
50 moodycamel::BlockingReaderWriterQueue<AttributePacket>>();
53 virtual void open()
override;
54 virtual void close()
override;
83 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
85 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
91 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
92 mQueueDpsimToInterface;
93 std::shared_ptr<InterfaceWorker> mInterfaceWorker;
97 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
98 queueDpsimToInterface,
99 std::shared_ptr<InterfaceWorker> intf)
100 : mQueueDpsimToInterface(queueDpsimToInterface),
101 mInterfaceWorker(intf){};
107 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
108 mQueueInterfaceToDpsim;
109 std::shared_ptr<InterfaceWorker> mInterfaceWorker;
110 std::atomic<bool> &mOpened;
114 std::shared_ptr<moodycamel::BlockingReaderWriterQueue<AttributePacket>>
115 queueInterfaceToDpsim,
116 std::shared_ptr<InterfaceWorker> intf, std::atomic<bool> &opened)
117 : mQueueInterfaceToDpsim(queueInterfaceToDpsim), mInterfaceWorker(intf),
126 for (
const auto &[attr, _seqId, _blockOnRead, _syncOnStart] :
128 mModifiedAttributes.push_back(attr);
143 mAttributeDependencies.push_back(attr);
AttributePointer< AttributeBase > Ptr
std::shared_ptr< spdlog::logger > Log
Tasks to be defined by every component.
std::vector< AttributeBase::Ptr > mModifiedAttributes
std::vector< std::tuple< CPS::AttributeBase::Ptr, UInt, bool, bool > > mImportAttrsDpsim
std::atomic< bool > mOpened
virtual String & getName()
std::vector< std::tuple< CPS::AttributeBase::Ptr, UInt > > mExportAttrsDpsim
Interface(const String &name="", spdlog::level::level_enum logLevel=spdlog::level::level_enum::info)
PostStep(InterfaceQueued &intf)
void execute(Real time, Int timeStepCount) override
void execute(Real time, Int timeStepCount) override
PreStep(InterfaceQueued &intf)
ReaderThread(std::shared_ptr< moodycamel::BlockingReaderWriterQueue< AttributePacket > > queueInterfaceToDpsim, std::shared_ptr< InterfaceWorker > intf, std::atomic< bool > &opened)
WriterThread(std::shared_ptr< moodycamel::BlockingReaderWriterQueue< AttributePacket > > queueDpsimToInterface, std::shared_ptr< InterfaceWorker > intf)
std::shared_ptr< InterfaceQueued > Ptr
virtual void syncExports() override
std::shared_ptr< moodycamel::BlockingReaderWriterQueue< AttributePacket > > mQueueInterfaceToDpsim
std::shared_ptr< moodycamel::BlockingReaderWriterQueue< AttributePacket > > mQueueDpsimToInterface
virtual void open() override
virtual void setLogger(CPS::Logger::Log log) override
std::thread mInterfaceWriterThread
std::thread mInterfaceReaderThread
InterfaceQueued(std::shared_ptr< InterfaceWorker > intf, const String &name="", UInt downsampling=1)
virtual ~InterfaceQueued()
virtual void popDpsimAttrsFromQueue(bool isSync=false)
struct AttributePacket { CPS::AttributeBase::Ptr value; UInt attributeId; UInt sequenceId; unsigned char flags; } AttributePacket
virtual void close() override
virtual void syncImports() override
Function called by the Simulation to perform interface synchronization.
virtual CPS::Task::List getTasks() override
virtual void pushDpsimAttrsToQueue()
std::shared_ptr< InterfaceWorker > mInterfaceWorker
static CPS::AttributeBase::Ptr external