Skip to content
Snippets Groups Projects
Select Git revision
  • 61c3d48bca06e840026aac8c45248b7f29bcebc1
  • master default protected
  • Rpc
3 results

IRpcFrontend.h

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    IRpcFrontend.h 1.94 KiB
    #pragma once
    #include <string>
    #include <vector>
    
    // Struct that will be used for the NewValues callback
    struct ValuesStruct
    {
        std::string instanceName;
        std::vector<uint32_t> integerValueRefs;
        std::vector<int32_t> integerValues;
        std::vector<uint32_t> realValueRefs;
        std::vector<double> realValues;
        std::vector<uint32_t> boolValueRefs;
        std::vector<int32_t> boolValues;
        std::vector<uint32_t> stringValueRefs;
        std::vector<std::string> stringValues;
    };
    
    // Definition of a channel link
    struct ChannelLink
    {
        std::string masterInstanceName;
        std::string slaveInstanceName;
        uint32_t masterValueRef;
        uint32_t slaveValueRef;
        double factor;
        double offset;
    };
    
    // Callback definitions shall be easy to marshall
    typedef void(__stdcall *NewValuesCallback)(double timestamp, ValuesStruct values);
    typedef void(__stdcall *LogCallback)(std::string instanceName, int status, std::string message);
    
    
    /// This interface hides the rpc (framework) implementation.
    /// We can compile a pure native library and do not have to worry about CLI compiler errors.
    class IRpcFrontend
    {
    public:
        virtual void destroy() = 0;
        virtual void connect(std::string address, unsigned int port) = 0;
        virtual void registerCallbacks(NewValuesCallback newValuesCallback, LogCallback logCallback) = 0;
        /// Returns fmi2Status
        virtual int play() = 0;
        /// Returns fmi2Status
        virtual int playFast(double timeToPlay) = 0;
        virtual void pause() = 0;
        /// Returns fmi2Status
        virtual int stop() = 0;
        virtual bool addFmu(std::string instanceName, std::vector<unsigned char> fmuFile) = 0;
        virtual bool removeFmu(std::string instanceName) = 0;
        virtual bool addChannelLink(ChannelLink channelLink) = 0;
        virtual bool removeChannelink(ChannelLink channelLink) = 0;
        /// Returns fmi2Status
        virtual int setValues(ValuesStruct values) = 0;
    };
    
    // Export a function of this type
    typedef IRpcFrontend* (*createRpcFrontendType)();