Global Namespace¶
Overview¶
// namespaces namespace BulletLib; namespace ConvertLib; namespace FunctionalNodePolicies; namespace InputNodePolicies; namespace MujocoLib; namespace NGraph; namespace NRPThreads; namespace NrpCoresProcess; namespace OpenAIGymLib; namespace OpensimLib; namespace OutputNodePolicies; namespace SimManager; namespace Trainer; namespace async_pysim_engine; namespace async_python_grpc_engine; namespace async_python_json_engine; namespace boost; namespace brain_devices; namespace engine_script; namespace gazebo; namespace grpc_engine_script; namespace grpc_server_callbacks; namespace json_converter; namespace json_event_loop_engine; namespace json_utils; namespace nlohmann; namespace numpy_json_serializer; namespace proto_field_ops; namespace protobuf_event_loop_engine; namespace protobuf_ops; namespace python; namespace python_grpc_engine; namespace python_json_engine; namespace server_callbacks; namespace std; // typedefs typedef DataPackController<google::protobuf::Message> ProtoDataPackController; typedef DataPack<nlohmann::json> JsonDataPack; typedef RawData<nlohmann::json> JsonRawData; typedef nlohmann::json json; typedef void() load_factory_fcn_t; typedef FunctionalNodeBase*(const std::string&, const std::string&, FunctionalNodePolicies::ExecutionPolicy) create_fn_fcn_t; typedef InputEdge<T_IN, T_IN, INPUT_CLASS> SimpleInputEdge; typedef OutputEdge<T_OUT, T_OUT, OUTPUT_CLASS> SimpleOutputEdge; typedef GazeboEngineGrpcNRPClient::EngineLauncher<GazeboGrpcConfigConst::EngineType> GazeboEngineGrpcLauncher; typedef GazeboEngineJSONNRPClient::EngineLauncher<GazeboJSONConfigConst::EngineType> GazeboEngineJSONLauncher; typedef DataPackInterface::shared_ptr DataPackInterfaceSharedPtr; typedef DataPackInterface::const_shared_ptr DataPackInterfaceConstSharedPtr; typedef std::set<std::shared_ptr<const DataPackInterface>, DataPackPointerComparator> datapacks_set_t; typedef std::vector<std::shared_ptr<const DataPackInterface>> datapacks_vector_t; typedef std::set<DataPackIdentifier> datapack_identifiers_set_t; typedef EngineClientInterface::shared_ptr EngineClientInterfaceSharedPtr; typedef EngineClientInterface::const_shared_ptr EngineClientInterfaceConstSharedPtr; typedef EngineLauncherInterface::shared_ptr EngineLauncherInterfaceSharedPtr; typedef EngineLauncherInterface::const_shared_ptr EngineLauncherInterfaceConstSharedPtr; typedef EngineLauncherManager::shared_ptr EngineLauncherManagerSharedPtr; typedef EngineLauncherManager::const_shared_ptr EngineLauncherManagerConstSharedPtr; typedef NRP_ENGINE_LAUNCH_FCN_T engine_launch_fcn_t; typedef ProcessLauncherManager<ProcessLauncherBasic> MainProcessLauncherManager; typedef MainProcessLauncherManager::shared_ptr MainProcessLauncherManagerSharedPtr; typedef MainProcessLauncherManager::const_shared_ptr MainProcessLauncherManagerConstSharedPtr; typedef std::shared_ptr<FunctionManager> FunctionManagerSharedPtr; typedef std::shared_ptr<const FunctionManager> FunctionManagerConstSharedPtr; typedef std::shared_ptr<FunctionManager> TransceiverFunctionInterpreterSharedPtr; typedef std::shared_ptr<const FunctionManager> TransceiverFunctionInterpreterConstSharedPtr; typedef TransceiverDataPackInterface::shared_ptr TransceiverDataPackInterfaceSharedPtr; typedef TransceiverDataPackInterface::const_shared_ptr TransceiverDataPackInterfaceConstSharedPtr; typedef std::shared_ptr<nlohmann::json> jsonSharedPtr; typedef std::shared_ptr<const nlohmann::json> jsonConstSharedPtr; typedef std::chrono::nanoseconds SimulationTime; typedef NestEngineJSONNRPClient::EngineLauncher<NestConfigConst::EngineType> NestEngineJSONLauncher; typedef NestEngineServerNRPClient::EngineLauncher<NestServerConfigConst::EngineType> NestEngineServerNRPClientLauncher; typedef protobuf_ops::NRPProtobufOpsIface*() protobuf_ops_fcn_t; typedef PySimNRPClient::EngineLauncher<PySimConfigConst::EngineType> PySimJSONLauncher; typedef PythonEngineGRPCNRPClient::EngineLauncher<PythonGrpcConfigConst::EngineType> PythonEngineGRPCLauncher; typedef PythonEngineJSONNRPClient::EngineLauncher<PythonConfigConst::EngineType> PythonEngineJSONLauncher; typedef FTILoop::shared_ptr FTILoopSharedPtr; typedef FTILoop::const_shared_ptr FTILoopConstSharedPtr; typedef std::shared_ptr<nlohmann::json> jsonSharedPtr; // enums enum DataPackPassingPolicy; // structs struct ComputationalGraphHandle; struct DataPackIdentifier; struct DataPackPointerComparator; template <class DATA> struct DataPortHandle; struct EngineGRPCConfigConst; struct EngineJSONConfigConst; template <std::size_t N> struct FixedString; struct FunctionData; struct GazeboGrpcConfigConst; struct GazeboJSONConfigConst; struct NestConfigConst; struct NestServerConfigConst; struct PySimConfigConst; struct PythonConfigConst; struct PythonGrpcConfigConst; struct SimulationParams; struct ZipSourceWrapper; struct ZipWrapper; template <class T_IN> struct dataConverter<T_IN, bpy::object>; template <class T_IN, class T_OUT> struct dataConverter; template <class T_OUT> struct dataConverter<bpy::object, T_OUT>; template <typename T> struct function_traits; template <typename R, typename ... Args> struct function_traits<std::function<R(Args...)>>; template <size_t, typename, typename, size_t> struct sub_tuple; template <std::size_t IDX, typename... Tpack, typename Tuple> struct sub_tuple<IDX, std::tuple<Tpack...>, Tuple, IDX>; template <size_t IDX1, typename... Tpack, typename Tuple, size_t IDX2> struct sub_tuple<IDX1, std::tuple<Tpack...>, Tuple, IDX2>; template <typename T> struct tuple_array<T, 0>; template <typename T, size_t N> struct tuple_array; // classes class BasicFork; class CommControllerSingleton; class ComputationalGraph; class ComputationalGraphManager; class ComputationalNode; class CreateDataPackClass; template <class MSG_TYPE> class DPInputMQTTEdge; template <class MSG_TYPE> class DPInputMQTTNode; template <class MSG_TYPE> class DPOutputMQTTEdge; template <class MSG_TYPE> class DPOutputMQTTNode; template <class DATA_TYPE> class DataPack; template <class DATA_TYPE> class DataPackController; class DataPackInterface; class DataPackProcessor; class DockerLauncher; class ELEOptsParser; class EmptyLaunchCommand; template <class ENGINE, const char* SCHEMA> class EngineClient; class EngineClientInterface; class EngineDataPack; class EngineDataPacks; class EngineGRPCOptsParser; template <class ENGINE, const char* SCHEMA> class EngineGrpcClient; class EngineGrpcServer; template <class ENGINE, const char* SCHEMA> class EngineJSONNRPClient; class EngineJSONOptsParser; class EngineJSONRegistrationServer; class EngineJSONServer; class EngineLauncherInterface; class EngineLauncherManager; class EnginePluginManager; class EngineProtoWrapper; class EventLoop; class EventLoopEngine; class EventLoopInterface; class EventLoopSimManager; class F2FEdge; class FTILoop; class FTILoopSimManager; class FileFinder; class FunctionManager; template <typename... INPUT_TYPES, typename... OUTPUT_TYPES> class FunctionalNode<std::tuple<INPUT_TYPES...>, std::tuple<OUTPUT_TYPES...>>; template <typename, typename> class FunctionalNode; class FunctionalNodeBase; class FunctionalNodeFactory; class FunctionalNodeFactoryManager; class GazeboEngineGrpcNRPClient; class GazeboEngineJSONNRPClient; class GazeboStepController; class InputClockEdge; class InputClockNode; class InputDummy; class InputDummyEdge; template <class T_IN, class T_OUT, INPUT_C<T_IN> INPUT_CLASS> class InputEdge; class InputEngineEdge; class InputEngineNode; class InputIterationEdge; class InputIterationNode; template <class MSG_TYPE> class InputMQTTEdge; template <class MSG_TYPE> class InputMQTTNode; template <class DATA> class InputNode; template <class T_IN, class T_OUT> class InputPort; template <class MSG_TYPE> class InputROSEdge; template <class MSG_TYPE> class InputROSNode; class InputSpinnakerEdge; class InputSpinnakerNode; class InputTimeBaseNode; class JsonDataPackController; template <const char* LAUNCH_COMMAND> class LaunchCommand; class LaunchCommandInterface; class MQTTCallback; class NRPException; class NRPExceptionNonRecoverable; class NRPExceptionRecoverable; class NRPGazeboCommunicationController; class NRPJSONCommunicationController; class NRPLogger; class NRPMQTTClient; class NRPMQTTProxy; class NRPROSProxy; class NRPSpinnakerProxy; class NestEngineJSONDataPackController; class NestEngineJSONNRPClient; class NestEngineServerNRPClient; class NestJSONServer; class NestKernelDataPackController; class NrpCoreServer; class OutputDummy; class OutputDummyEdge; template <class T_IN, class T_OUT, OUTPUT_C<T_OUT> OUTPUT_CLASS> class OutputEdge; class OutputEngineEdge; class OutputEngineNode; template <class MSG_TYPE> class OutputMQTTEdge; template <class MSG_TYPE> class OutputMQTTNode; template <class DATA> class OutputNode; template <class T> class OutputPort; template <class MSG_TYPE> class OutputROSEdge; template <class MSG_TYPE> class OutputROSNode; class OutputSpinnakerEdge; class OutputSpinnakerNode; class PipeCommunication; class PluginManager; class Port; class PreprocessedDataPack; class PreprocessingFunction; template < class PROCESS_LAUNCHER, const char* LAUNCHER_TYPE, class ... LAUNCHER_COMMANDS > class ProcessLauncher; class ProcessLauncherBasic; class ProcessLauncherInterface; template <class ... PROCESS_LAUNCHERS> class ProcessLauncherManager; class ProtoOpsManager; template <class T> class PtrTemplates; class PySimNRPClient; class PythonEngineGRPCNRPClient; class PythonEngineJSONNRPClient; template <class ENGINE, const char* SCHEMA> class PythonEngineJSONNRPClientBase; class PythonFunctionalNode; class PythonGILLock; class PythonInterpreterState; template <class DATA_TYPE> class RawData; class RepeatedScalarFieldIterProxy; class RepeatedScalarFieldProxy; class RestClientSetup; class SimulationDataManager; class SimulationIterationDecorator; class SimulationManager; class SimulationTimeDecorator; class SpiNNakerJsonReceiveCallbackInterface; class StatusFunction; class TFManagerHandle; class TransceiverDataPackInterface; class TransceiverFunction; class WCharTConverter; class ZipContainer; class node_policies_ns; template <class MSG_TYPE, class ... FIELD_MSG_TYPES> class proto_python_bindings; // global variables const int QOS = 1; const auto TIMEOUT = std::chrono::seconds(10); concept INPUT_C = std::is_base_of_v<InputNode<T_IN>, T>; concept OUTPUT_C = std::is_base_of_v<OutputNode<T_OUT>, T>; const char LAUNCH_COMMAND[] = "BasicFork"; const char LAUNCH_DOCKER_COMMAND[] = "DockerLauncher"; const char EmptyLaunchC[] = "EmptyLaunchCommand"; const char Basic[] = "Basic"; static CreateDataPackClass* pCreateDataPack = nullptr; static CreateDataPackClass* pCreateDataPack = nullptr; // global functions template <class T> bool operator == ( const std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T> operator * ( const std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T>& operator += ( std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T>& operator -= ( std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T> operator + ( const std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T> operator - ( const std::set<T>& A, const std::set<T>& B ); template <class T> std::set<T> symm_diff( const std::set<T>& A, const std::set<T>& B ); template <class T, class constT> bool includes_elm( const std::set<T>& A, constT& a ); template <class T> int intersection_size( const std::set<T>& A, const std::set<T>& B ); template <class T> int big_small_intersection_size( const std::set<T>& A, const std::set<T>& B ); template <class T> int union_size(const std::set<T>& A, const std::set<T>& B); template <class T> int set_difference_size( const std::set<T>& A, const std::set<T>& B ); void createPythonGraphFromConfig( const nlohmann::json& config, const ComputationalGraph::ExecMode& execMode, const boost::python::dict& globalDict ); std::pair<InputClockNode*, InputIterationNode*> findTimeNodes(); CREATE_NRP_ENGINE_LAUNCHER(GazeboEngineGrpcLauncher); CREATE_NRP_ENGINE_LAUNCHER(GazeboEngineJSONLauncher); std::shared_ptr<DataPackIdentifier> genDevID( const std::string& name, const std::string& engineName ); std::shared_ptr<DataPackInterface> genDevInterface( const std::string& name, const std::string& engineName ); BOOST_PYTHON_MODULE(PYTHON_MODULE_NAME); boost::python::object createFNFromFactoryModule( const std::string& fnModuleName, const std::string& functionName, const std::string& nodeName, FunctionalNodePolicies::ExecutionPolicy policy ); BOOST_PYTHON_MODULE(EVENT_LOOP_PYTHON_MODULE_NAME); static PyObject* setPythonError(PyObject* type, const std::string& message); static PyObject* getItemFromJsonArray( const nlohmann::json& jsonParent, PyObject* index ); static PyObject* getItemFromJsonObject( const nlohmann::json& jsonParent, PyObject* index ); static PyObject* nlohmannJsonGetItem( const nlohmann::json& jsonParent, PyObject* index ); static void nlohmannJsonSetItem( nlohmann::json* jsonParent, PyObject* index, PyObject* value ); static PyObject* nlohmannJsonDump(const nlohmann::json& json); static PyObject* nlohmannJsonSize(const nlohmann::json& json); static PyObject* nlohmannJsonType(const nlohmann::json& json); static PyObject* nlohmannJsonKeys(const nlohmann::json& json); static void nlohmannJsonAppend(nlohmann::json* jsonParent, PyObject* value); BOOST_PYTHON_MODULE(JSON_PYTHON_MODULE_NAME); std::string parseAndValidateEngineConfig(const std::string& configFile); BOOST_PYTHON_MODULE(NRP_PYTHON_ENGINE_MODULE); std::string parseAndValidateEngineConfig(const std::string& configFile); BOOST_PYTHON_MODULE(NRP_PYTHON_GRPC_ENGINE_MODULE); template <std::size_t N> FixedString(const char(&) str[N]); template <std::size_t N> FixedString(const FixedString<N>& str); FixedString(); template <class T> FixedString(T str); std::string handle_pyerror(); std::string handle_pyerror(); void setup_venv(); SimulationTime toSimulationTimeFromSeconds(double time); double getRoundedRunTimeMs( const SimulationTime runTime, const float simulationResolutionMs ); std::string getTimestamp(); template <class vartype, class ratio> static SimulationTime toSimulationTime(vartype time); SimulationTime toSimulationTimeFromSeconds(double time); template <class vartype, class ratio> static vartype fromSimulationTime(SimulationTime time); double getRoundedRunTimeMs( const SimulationTime runTime, const float simulationResolutionMs ); std::string getTimestamp(); int bindOrFindFreePort(std::string hostIpv4, int port = 0); void bindToAddress(std::string hostIpv4, int port); int getFreePort(std::string hostIpv4); void appendPythonPath(const std::string& path); int main(int argc, char* argv[]); static void loadPlugins( const char* libName, EnginePluginManager& pluginManager, const EngineLauncherManagerSharedPtr& engines, const std::set<std::string>& engineTypes ); static void loadEngines( EnginePluginManager& pluginManager, EngineLauncherManagerSharedPtr& engines, std::vector<std::string> pluginsList, const std::set<std::string>& engineTypes ); static int processLogOutputOption( const std::string& logOutput, std::string logFilename, std::string logDir ); int main(int argc, char* argv[]); CREATE_NRP_ENGINE_LAUNCHER(NestEngineJSONLauncher); python::object CreateDataPack(python::tuple args, python::dict kwargs); void RegisterDataPack(python::str devName, python::object nodeCollection); python::dict GetDevMap(); BOOST_PYTHON_MODULE(NRP_NEST_PYTHON_MODULE); python::object CreateDataPack(python::tuple args, python::dict kwargs); void RegisterDataPack(python::str devName, python::object nodeCollection); python::dict GetDevMap(); BOOST_PYTHON_MODULE(NRP_NEST_PYTHON_MODULE); CREATE_NRP_ENGINE_LAUNCHER(NestEngineServerNRPClientLauncher); Py_ssize_t ExtractIndices( PyObject* indices, Py_ssize_t& from, Py_ssize_t& to, Py_ssize_t& step, Py_ssize_t length ); Py_ssize_t ExtractIndices( PyObject* indices, Py_ssize_t& from, Py_ssize_t& to, Py_ssize_t& step, Py_ssize_t length ); CREATE_NRP_ENGINE_LAUNCHER(PySimJSONLauncher); CREATE_NRP_ENGINE_LAUNCHER(PythonEngineGRPCLauncher); CREATE_NRP_ENGINE_LAUNCHER(PythonEngineJSONLauncher); static void resetIsUpdateFlags(datapacks_set_t& dataPacks); static void updateDataPackPool( datapacks_vector_t dataPacks, datapacks_set_t& pool ); static DataPackProcessor* makeHandleFromConfig( jsonSharedPtr config, SimulationDataManager* simulationDataManager ); static void runLoopStepAsyncGet(EngineClientInterfaceSharedPtr engine); // macros #define CREATE_NRP_ENGINE_LAUNCHER(engine_launcher_name) #define CREATE_NRP_ENGINE_LAUNCHER_FCN #define CREATE_NRP_ENGINE_LAUNCHER_FCN_STR #define CREATE_PROTOBUF_OPS(proto_ops_class) #define CREATE_PROTOBUF_OPS_FCN_STR #define MQTT_BASE #define NPY_NO_DEPRECATED_API #define NRP_ENGINE_LAUNCH_FCN_T #define NRP_LOGGER_TRACE(...) #define SPDLOG_ACTIVE_LEVEL #define VOLTAGE_INT_TO_S1615 #define use(x)
Detailed Documentation¶
Typedefs¶
typedef ProcessLauncherManager<ProcessLauncherBasic> MainProcessLauncherManager
Type to manage all available process launchers.
Global Variables¶
const char EmptyLaunchC[] = "EmptyLaunchCommand"
Empty Launch Command. A “dummy” launcher that doesn’t launch a process. Useful in the cases when the EngineServer is not intended to be launched by the corresponding EngineClient.
const char Basic[] = "Basic"
Basic Process Launcher, for simple process management.
Global Functions¶
template <class T> std::set<T> operator + ( const std::set<T>& A, const std::set<T>& B )
Returns:
a new set, the union of A and B.
template <class T> std::set<T> operator - ( const std::set<T>& A, const std::set<T>& B )
Returns:
the A - B: elements in A but not in B.
template <class T> std::set<T> symm_diff( const std::set<T>& A, const std::set<T>& B )
Returns:
a new (possibly empty) set, the symmetric difference of A and B. That is, elements in only one set, but not the other. Mathematically, this is A+B - (A*B)
template <class T, class constT> bool includes_elm( const std::set<T>& A, constT& a )
Returns:
true, if element a is in set A
boost::python::object createFNFromFactoryModule( const std::string& fnModuleName, const std::string& functionName, const std::string& nodeName, FunctionalNodePolicies::ExecutionPolicy policy )
Helper function for instantiating a C++ Functional Node from Python.
Parameters:
fnModuleName |
name of the module library which will be used to instantiate the node |
functionName |
name of the C++ function which the node will run |
nodeName |
name of the FN |
policy |
exec policy of the FN |
Returns:
instantiated FN wrapped in a Python object
static PyObject* setPythonError(PyObject* type, const std::string& message)
Generates python error with given type and message.
Parameters:
type |
Type of exception |
message |
Message of the exception |
Returns:
Py_None object
static PyObject* getItemFromJsonArray( const nlohmann::json& jsonParent, PyObject* index )
Returns element stored in json array under given index.
Parameters:
json |
The object of which the method was invoked |
index |
Index to be accessed |
Returns:
Object stored under given index
static PyObject* getItemFromJsonObject( const nlohmann::json& jsonParent, PyObject* index )
Returns element stored in json object under given key.
Parameters:
json |
The object of which the method was invoked |
index |
Key to be accessed |
Returns:
Object stored under given key
static PyObject* nlohmannJsonGetItem( const nlohmann::json& jsonParent, PyObject* index )
Implements python getitem method of nlohmann::json.
The function is part of the python interface for nlohmann::json. It allows to access nlohmann::json objects using ‘object[index]’ notation. Both json arrays and objects cannot be accessed this way.
Parameters:
json |
The object of which the method was invoked |
index |
Index (in case of arrays) or key (in case of objects) to be accessed |
Returns:
Object stored under given key or index
static void nlohmannJsonSetItem( nlohmann::json* jsonParent, PyObject* index, PyObject* value )
Implements python setitem method of nlohmann::json.
The function is part of the python interface for nlohmann::json. It allows to modify nlohmann::json objects using ‘object[key] = value’ notation. Json arrays cannot be modified this way.
Parameters:
json |
The object of which the method was invoked |
index |
Key to be modified or created |
value |
Value to be inserted under the key |
static PyObject* nlohmannJsonDump(const nlohmann::json& json)
Implements python str method of nlohmann::json.
The function is part of the python interface for nlohmann::json.
Parameters:
json |
The object of which the method was invoked |
Returns:
String representation of the object
static PyObject* nlohmannJsonSize(const nlohmann::json& json)
Implements python len method of nlohmann::json.
The function is part of the python interface for nlohmann::json.
Parameters:
json |
The object of which the method was invoked |
Returns:
Length of the object as long int
static PyObject* nlohmannJsonType(const nlohmann::json& json)
Returns the type of a json object as a string.
Parameters:
json |
The object of which the method was invoked |
Returns:
json type of the object
static PyObject* nlohmannJsonKeys(const nlohmann::json& json)
Implements python keys method of nlohmann::json.
The function is part of the python interface for nlohmann::json.
Parameters:
json |
The object of which the method was invoked |
Returns:
List of keys in case of json object, list of indices as strings in case of json array
std::string parseAndValidateEngineConfig(const std::string& configFile)
Helper function for instantiating a PythonEngineJSONNRPClient to validate a PythonEngine Engine configuration.
Parameters:
config |
engine configuration to be processed |
Returns:
validated config
std::string parseAndValidateEngineConfig(const std::string& configFile)
Helper function for instantiating a PythonEngineGRPCNRPClient to validate a PythonEngineGRPC Engine configuration.
Parameters:
config |
engine configuration to be processed |
Returns:
validated config
std::string handle_pyerror()
Read out a properly formatted Python exception string. Only call if a Python exception was thrown.
Returns:
Returns human-readable error string
std::string handle_pyerror()
Read out a properly formatted Python exception string. Only call if a Python exception was thrown.
Returns:
Returns human-readable error string
SimulationTime toSimulationTimeFromSeconds(double time)
Converts floating-point seconds into SimulationTime.
Parameters:
time |
The value to be converted |
Returns:
SimulationTime object that corresponds to the argument
double getRoundedRunTimeMs( const SimulationTime runTime, const float simulationResolutionMs )
Calculates simulation run time rounded to milliseconds, accounting for given resolution.
Parameters:
runTime |
Simulation run time that will be rounded |
simulationResolutionMs |
Simulation resolution in milliseconds |
When simulation run time is smaller than simulation resolution |
Returns:
Rounded simulation run time
std::string getTimestamp()
returns the current local time as a string in the format: YYMMDD-hhmmss-pid, being pid the pid of the calling process
template <class vartype, class ratio> static SimulationTime toSimulationTime(vartype time)
Converts given value to SimulationTime object.
The function is parametrized with two parameters: vartype and ratio. Vartype is the type of variable that is supposed to be converted to SimulationTime. Usually this will be int or float. Ratio is std::ratio class.
SimulationTime toSimulationTimeFromSeconds(double time)
Converts floating-point seconds into SimulationTime.
Parameters:
time |
The value to be converted |
Returns:
SimulationTime object that corresponds to the argument
template <class vartype, class ratio> static vartype fromSimulationTime(SimulationTime time)
Converts SimulationTime object to specified type and with given ratio.
double getRoundedRunTimeMs( const SimulationTime runTime, const float simulationResolutionMs )
Calculates simulation run time rounded to milliseconds, accounting for given resolution.
Parameters:
runTime |
Simulation run time that will be rounded |
simulationResolutionMs |
Simulation resolution in milliseconds |
When simulation run time is smaller than simulation resolution |
Returns:
Rounded simulation run time
std::string getTimestamp()
returns the current local time as a string in the format: YYMMDD-hhmmss-pid, being pid the pid of the calling process
int bindOrFindFreePort(std::string hostIpv4, int port = 0)
Attempts to bind to a given address.
When “port” is 0, the function asks the OS to look for a free port number. Throws an exception if the connection is not successful
Parameters:
hostIpv4 |
IP4 address of the host |
port |
Port to connect to, if 0 a free port is searched and used |
Returns:
Port used in the connection, same as “port” argument or found free port
void bindToAddress(std::string hostIpv4, int port)
Attempts to bind to a given address.
Throws an exception if the connection is not successful
Parameters:
hostIpv4 |
IP4 address of the host |
port |
Port to connect to |
int getFreePort(std::string hostIpv4)
Returns a free port number.
Asks the OS to look for a free port number
Parameters:
hostIpv4 |
IP4 address of the host |
Returns:
Free port number
void appendPythonPath(const std::string& path)
Appends ‘path’ to PYTHON_PATH env variable.
Py_ssize_t ExtractIndices( PyObject* indices, Py_ssize_t& from, Py_ssize_t& to, Py_ssize_t& step, Py_ssize_t length )
Function which processes an index or slice object and sets from, to and step appropriately.
Returns the size of the described range, -1 if ‘indices’ is not a valid slice
Py_ssize_t ExtractIndices( PyObject* indices, Py_ssize_t& from, Py_ssize_t& to, Py_ssize_t& step, Py_ssize_t length )
Function which processes an index or slice object and sets from, to and step appropriately.
Returns the size of the described range, -1 if ‘indices’ is not a valid slice
Macros¶
#define CREATE_NRP_ENGINE_LAUNCHER(engine_launcher_name)
Create a new engine launcher. Will be used to load a launcher out of a dynamically loaded library.
#define CREATE_PROTOBUF_OPS(proto_ops_class)
Create a Protobuf operations object.
#define NPY_NO_DEPRECATED_API
Suppresses numpy warnings about deprecated API.
#define NRP_LOGGER_TRACE(...)
trace log macro. It is voided by defining PRODUCTION_RELEASE