FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
ExternalLinkStandard.h
1
47#ifndef EXTERNAL_LINK_STANDARD_H
48#define EXTERNAL_LINK_STANDARD_H
49
50
51#include <mutex>
52#include <string>
53
54
55#include <fhsim/simobject/ExternalLink.h>
56/*
57#include <vector>
58using std::vector;*/
59#include <map>
60using std::map;
61
62
63class ExternalLinkStandard : public ExternalLink
64{
65 public:
66 ExternalLinkStandard(std::string simObjectName, ISimObjectCreator* creator);
68 virtual bool SetMyOutputPort(const std::string& portName, const double* portValueArray);
69 virtual bool SetMyOutputPortWithCopy(const std::string& portName, const double* portValueArray);
70 virtual const double* GetMyInputPort(const std::string& portName);
71 virtual bool SetMyOutputPort(int portIndex, const double* portValueArray);
72 virtual bool SetMyOutputPortWithCopy(int portIndex, const double* portValueArray);
73 virtual const double* GetMyInputPort(int portIndex);
74 virtual std::vector<std::string> GetAllInputPorts();
75 virtual std::vector<std::string> GetAllOutputPorts();
76 virtual int GetInputPortSize(std::string portName);
77 virtual int GetOutputPortSize(std::string portName);
78 virtual int GetInputPortSize(int portIndex);
79 virtual int GetOutputPortSize(int portIndex);
80 //virtual void UpdateStatesAndTime(const double T, const double* const X); /// refresh state and time values. Must be called before GetMyInputPort
81
82
83 virtual int GetMyInputPortIndex(const std::string& portName);
84 virtual bool SetMyOutputPortWithIndex(const int portName, const double* portValueArray);
85 virtual bool SetMyOutputPortWithCopyWithIndex(const int portName, const double* portValueArray);
86
87
88 protected:
89 const double* externalPort(const double T, const double* const X, const int index);
90
91 const double** m_OutputArrays;
95 ISignalPort** m_InputPorts;
98 std::map<std::string, int> m_OutputPortIndex;
99 std::map<std::string, int> m_InputPortIndex;
100 //const double* m_X; /// holds the last updated simulation state array
101 //double m_T; /// holds the last updated simulation time
102
103 static std::recursive_mutex s_Mutex;
104};
105
106#endif
Definition ExternalLinkStandard.h:64
virtual bool SetMyOutputPort(int portIndex, const double *portValueArray)
Gets value of externalobject input port.
virtual const double * GetMyInputPort(const std::string &portName)
Sets value of externalobject output port. Copies values to internal buffer.
int m_numInputPorts
size of all input ports
Definition ExternalLinkStandard.h:97
double ** m_LocalBufferArrays
size of all output ports
Definition ExternalLinkStandard.h:93
int m_numOutputPorts
holds pointers to initialized values
Definition ExternalLinkStandard.h:94
const double ** m_OutputArrays
indexed output port. See PortDefs.h.
Definition ExternalLinkStandard.h:91
virtual int GetOutputPortSize(int portIndex)
Get size of input port, -1 if the name or index is unknown.
virtual bool SetMyOutputPortWithCopyWithIndex(const int portName, const double *portValueArray)
Sets value of externalobject output port. Only stores pointer, does NOT copy values.
virtual bool SetMyOutputPortWithCopy(int portIndex, const double *portValueArray)
Sets value of externalobject output port. Only stores pointer, does NOT copy values.
std::map< std::string, int > m_InputPortIndex
maps the names of output ports to index in m_OutputArrays
Definition ExternalLinkStandard.h:99
virtual bool SetMyOutputPortWithCopy(const std::string &portName, const double *portValueArray)
Sets value of externalobject output port. Only stores pointer, does NOT copy values.
int * m_inputPortSize
holds pointers to all input port ISignalPorts
Definition ExternalLinkStandard.h:96
virtual int GetInputPortSize(int portIndex)
Get size of output port, -1 if the name or index is unknown.
virtual bool SetMyOutputPortWithIndex(const int portName, const double *portValueArray)
Gets index of externalobject input port, -1 if the name is unknown.
virtual std::vector< std::string > GetAllOutputPorts()
Get names of all input ports.
ISignalPort ** m_InputPorts
number of outputPorts;
Definition ExternalLinkStandard.h:95
virtual int GetMyInputPortIndex(const std::string &portName)
Get size of output port, -1 if the name or index is unknown.
const double * externalPort(const double T, const double *const X, const int index)
Sets value of externalobject output port. Copies values to internal buffer.
static std::recursive_mutex s_Mutex
maps the names of input ports to index in m_InputPorts
Definition ExternalLinkStandard.h:103
virtual std::vector< std::string > GetAllInputPorts()
Gets value of externalobject input port.
std::map< std::string, int > m_OutputPortIndex
number of inputPorts;
Definition ExternalLinkStandard.h:98
int * m_outputPortSize
holds pointers to all output port arrays
Definition ExternalLinkStandard.h:92
virtual ~ExternalLinkStandard()
reads parameters, registers states, input/output ports and shared resources
virtual const double * GetMyInputPort(int portIndex)
Sets value of externalobject output port. Copies values to internal buffer.
virtual int GetOutputPortSize(std::string portName)
Get size of input port, -1 if the name or index is unknown.
virtual int GetInputPortSize(std::string portName)
Get names of all output ports.