<applications> <application name="publishAppli"> <modules> <customModule name="PublishModule" type="simulink"> <implementation path="myAppli"> <parameter key="simulinkRuntime" value="C/Programs/Mathlab" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </customModule> </modules> </application> </applications>
customFactories
key is found in the configuration. Then depending on the content of each module configuration, the factory is called to create the Module definition and the associated Module.moduleFactory
: the path of the FactorymoduleType
: the type of the module which will be created by the factorymoduleFactory: org.da.test.PythonModuleFactory moduleType: python
/** * Return the framework properties supported by the factory and their associated property types. * * @return the framework properties supported by the factory and their associated property types */ public default Map<String, Class<?>> getFrameworkPropertiesTypes() { return new HashMap<>(); } /** * Return the keys for the mandatory module implementation parameters * * @return the keys for the mandatory module implementation parameters */ public default Set<String> getMandatoryModuleParameters() { return new HashSet<>(); } /** * Set a framework property value. The value is guaranteed to be consistent with the type defined in {@link #getFrameworkPropertiesTypes()}. * * @param key the framework property key * @param value the framework property value */ public default void setFrameworkProperty(String key, Object value) { } /** * Return a framework property value. The value is guaranteed to be consistent with the type defined in {@link #getFrameworkPropertiesTypes()}. * * @param key the framework property key * @return the framework property value */ public default Object getFrameworkProperty(String key) { return null; } /** * Return the module implementation parameters supported by the custom module and their associated parameter types. * * @return the module implementation parameters supported by the custom module and their associated parameter types */ public default Map<String, Class<?>> getModuleParameterTypes() { return new HashMap<>(); } /** * Creates a custom module definition. * * @param appli the application definition * @param name the module name * @param id the module ID * @return the custom module definition */ public CustomModuleDefinition createModuleDefinition(ApplicationDefinition appli, String name, long id); /** * Creates a custom module. * * @param appli the application * @param name the module name * @return the custom module */ public Module createModule(Application appli, String name); /** * Return the class used to define custom modules for this factory. * * @return the class */ public Class<?> getModuleDefinitionClass();
/** * Return the framework properties supported by the factory and their associated property types. * * @return the framework properties supported by the factory and their associated property types */ public default Map<String, Class<?>> getFrameworkPropertiesTypes() { return new HashMap<>(); } /** * Set a framework property value. The value is guaranteed to be consistent with the type defined in {@link #getFrameworkPropertiesTypes()}. * * @param key the framework property key * @param value the framework property value */ public default void setFrameworkProperty(String key, Object value) { } /** * Return a framework property value. The value is guaranteed to be consistent with the type defined in {@link #getFrameworkPropertiesTypes()}. * * @param key the framework property key * @return the framework property value */ public default Object getFrameworkProperty(String key) { return null; }
<files> <file url="applications.xml" /> <file url="services.xml" /> <file url="types.xml" /> <file url="properties.xml" /> <property key="customFactories" value="mySimulinkFactory.jar" /> <property key="mathlabPath" value="C:/program/Mathlab" /> </files>
/** * Return the keys for the mandatory module implementation parameters * * @return the keys for the mandatory module implementation parameters */ public default Set<String> getMandatoryModuleParameters() { return new HashSet<>(); } /** * Return the module implementation parameters supported by the custom module and their associated parameter types. * * @return the module implementation parameters supported by the custom module and their associated parameter types */ public default Map<String, Class<?>> getModuleParameterTypes() { return new HashMap<>(); }
<applications> <application name="publishAppli"> <modules> <customModule name="PublishModule" type="python"> <implementation path="myAppli"> <parameter key="inputPort" value="6000" /> <parameter key="outputPort" value="6001" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </customModule> </modules> </application> </applications>
/** * Creates a custom module definition. * * @param appli the application definition * @param name the module name * @param id the module ID * @return the custom module definition */ public CustomModuleDefinition createModuleDefinition(ApplicationDefinition appli, String name, long id); /** * Creates a custom module. * * @param appli the application * @param name the module name * @return the custom module */ public Module createModule(Application appli, String name); /** * Return the class used to define custom modules for this factory. * * @return the class */ public Class<?> getModuleDefinitionClass();
<applications> <application name="publishAppli"> <modules> <customModule name="PublishModule" type="python"> <implementation path="myAppli"> <parameter key="inputPort" value="6000" /> <parameter key="outputPort" value="6001" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </customModule> </modules> </application> </applications>
<applications> <application name="publishAppli"> <modules> <customModule name="PublishModule" type="python"> <implementation path="myAppli"> <parameter key="inputPort" value="6000" /> <parameter key="outputPort" value="6001" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </customModule> </modules> </application> </applications>Suppose the Manifest of the
myPythonFactory.jar
jar file is:moduleFactory: org.da.test.PythonModuleFactory moduleType: pythonThe factory class will have the following code:
public class CustomPythonModuleFactory implements CustomModuleFactory { private static final Map<String, Class<?>> MODULE_PARAMS_TYPES = new HashMap<>(); static { MODULE_PARAMS_TYPES.put("inputPort", Integer.class); MODULE_PARAMS_TYPES.put("outputPort", Integer.class); MODULE_PARAMS_TYPES.put("inputSize", Integer.class); MODULE_PARAMS_TYPES.put("outputSize", Integer.class); } @Override public CustomModuleDefinition createModuleDefinition(ApplicationDefinition appli, String name, long id) { CustomPythonModuleDefinition moduleDef = new CustomPythonModuleDefinition(this, appli, name, id); return moduleDef; } /** * Creates a custom module. * * @param appli the application definition * @param name the module name * @return the custom module */ @Override public Module createModule(Application appli, String name) { CustomPythonModule module = new CustomPythonModule(appli, name); return module; } /** * Return the module implementation properties supported by the custom module and their associated property types. * * @return the module implementation properties supported by the custom module and their associated property types */ @Override public Map<String, Class<?>> getModulePropertiesTypes() { return MODULE_PROPERTIES_TYPES; } @Override public Class<?>> getModuleDefinitionClass() { return CustomPythonModuleDefinition.class; } }Then the current applications configuration will use this factory:
<applications> <application name="publishAppli"> <modules> <customModule name="PublishModule" type="python"> <implementation path="myAppli"> <parameter key="inputPort" value="6000" /> <parameter key="outputPort" value="6001" /> <defaultSendEntryPoint method="publish" /> </implementation> <interfaces> <eventReceived service="event"/> <cyclic service="published" frequency="200ms" attach="attach"/> </interfaces> </customModule> </modules> </application> </applications>
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence