Comments (10)
Comparison of S-Functions and FMUs:
- https://en.wikipedia.org/wiki/Functional_Mock-up_Interface#Comparison_to_Simulink_S-Functions
- Chapter 4 (in particular section 4.3) of http://lup.lub.lu.se/student-papers/record/8847501/file/8859310.pdf
- Section 2.3.2 of https://www.computoolable.nl/P7a.pdf
- Section 3.4 of http://www.ep.liu.se/ecp/132/057/ecp17132507.pdf (limited to Clock/discrete time systems, a new feature that will be part of FMI 3)
from blockfactory.
- Code-based configuration vs file based configuration
-
In Simulink S-Functions and consequently in blockfactory, several configuration info such as the number of the ports, etc etc are specified by calling specific methods (in particular
setIOPortsData
in theconfigureSizeAndPorts
method). In FMI, this information are specified in the XML file. To handle this, possible solutions are (the last one is my favorite):- Duplicate this info in handwritten XML files for FMUs (yuk)
- Change how this info is specified (invasive)
- Generate the XML files after the build by running a program that invokes the
configureSizeAndPorts
method of the block to wrap as FMU (this will be problematic when cross-compiling, but it seems that easy solution for now)
-
TL;DR: Handle how to generate XML files for FMU block
-
from blockfactory.
PR adding some part of the array support to the FMI standard: modelica/fmi-standard#543 .
from blockfactory.
Generate the XML files after the build by running a program that invokes the
configureSizeAndPorts
method of the block to wrap as FMU
Interestingly, part of this solution could be eventually re-used to automatize the existing manual process of writing the .slx
file of the block library (i.e. the one described in https://robotology.github.io/blockfactory/mkdocs/create_new_library/#create-an-new-simulink-library).
As you can check by manually inspecting an .slx
file, and by reading in https://stackoverflow.com/questions/23408186/information-about-simulink-mdl-and-slx-formats, the .slx
is just a .zip
file that contains a bunch of .xml
(and some other format) files. A complete parser for reading/writing .slx
does not seem to be available or feasible, but perhaps it could make sense to have a "template" .slx
that can be be configured based on the library blocks' and ports.
from blockfactory.
Having a templated slx imho does not simplify that much the creation / maintenance of a Simulink Library, it is usually a trivial step from the GUI. I am pretty sure that Matlab (even the cli version) has some functions to automatize it without dealing with the file formats.
The main problem are the masks, the have to be developed from the GUI. I'm afraid that operating only on the slx
or mdl
would never be enough :/
from blockfactory.
OT reply moved to #10 (comment)
Having a templated slx imho does not simplify that much the creation / maintenance of a Simulink Library, it is usually a trivial step from the GUI.
It is trivial, if you have MATLAB/Simulink. It would be nice to be able to setup a blockfactory library without having MATLAB/Simulink on your PC (my current situation, for example : ) ).
The main problem are the masks, the have to be developed from the GUI. I'm afraid that operating only on the
slx
ormdl
would never be enough :/
Why this should be the case? Everything that you input through the GUI should be contained in the .slx
, right? As far as I can see, in particular the Mask information is contained in the <Mask>
tag of simulink/blockdiagram.xml
, for example for the SignalMath
block in the ExampleToolbox
:
<Block BlockType="S-Function" Name="Signal Math" SID="1">
<P Name="Ports">[2, 1]</P>
<P Name="Position">[335, 69, 470, 116]</P>
<P Name="ZOrder">1</P>
<P Name="FunctionName">BlockFactory</P>
<P Name="Parameters">'SignalMath','ExampleToolbox',operation</P>
<P Name="SFunctionDeploymentMode">off</P>
<P Name="EnableBusSupport">off</P>
<P Name="SFcnIsStateOwnerBlock">off</P>
<Mask>
<Display RunInitForIconRedraw="off">disp('Signal Math')
port_label('input',1,'Input 1')
port_label('input',2,'Input 2')
port_label('output',1,'Output')</Display>
<MaskParameter Name="operation" Type="popup" Evaluate="off">
<Prompt>Operation</Prompt>
<Value>Addition</Value>
<TypeOptions>
<Option>Addition</Option>
<Option>Subtraction</Option>
<Option>Multiplication</Option>
</TypeOptions>
</MaskParameter>
</Mask>
</Block>
Indeed automatically generating this may not be trivial, but I do not think it is impossible.
from blockfactory.
We can probably move this discussion in a separate issue, btw.
from blockfactory.
We can probably move this discussion in a separate issue, btw.
👍
OT reply
Indeed automatically generating this may not be trivial, but I do not think it is impossible.
Just to be clear, I never intended that this is impossible ^^ It is just complicating your own life. And, btw, if you don't plan to use Simulink (since you don't have it), why do you want to create a Simulink Library? If the aim is using / testing blockfactory, for simple models you could:
- Create a plugin library containing classes that inherit from
blockfactory::core::Block
- Implement a simple
blockfactory::core::BlockInformation
for your use case - Develop a system that connects the blocks by assigning a simulation order and sharing data between their input / outputs with buffers
Without having Simulink I don't see any benefit of passing through the slx
, but probably I didn't get entirely what you're trying to do.
from blockfactory.
Simulink related discussion moved to #10 .
from blockfactory.
Interesting paper on FMI interface with a real time communication protocol (in this case RabbitMQ): https://github.com/INTO-CPS-Association/rabbitmq-fmu-documentation/blob/e6e57da07394858bc1519ef7b746df8459123ed6/rabbitmq-fmu.pdf , similar to how BlockFactory is used with YARP.
from blockfactory.
Related Issues (20)
- Notes about Modelica support
- Compilation failed with MATLAB 2018a on Windows 10 Version 1803 with CMake 3.12.0 HOT 13
- Compilations fail with Matlab2019b on Macos HOT 3
- Compilation failure on Windows without Matlab installed HOT 4
- Blockfactory does not re-load config file HOT 1
- Specifying sample times HOT 6
- Suggestion for configuring Size And Ports into Initialize phase HOT 9
- In Simulink allow to export S-Function Blocks that support to run as Co-Simulation on Multiple Cores HOT 1
- Permit to run Simulink mode that use BlockFactory blocks in accelerator or rapid accelerotor mode
- Release v0.8.1 with Matlab Windows fixes for robotology-superbuild release 2020.02 HOT 1
- Update CI to Github Actions HOT 4
- Improve Blockfactory interface with wrapped C++ code making it more generic HOT 5
- Add blockfactory-smoke-test-run command line tool
- CMake Error related to MatLab Libraries with MATLAB 2021a/2022a on Windows 10 Version 21H2 with CMake 3.22.3 HOT 9
- Extension to newer versions of Matlab - 2020b: HOT 2
- Errors running the Model.mdl of the example folder HOT 11
- Compilation Failed in Ubuntu with MATLAB2023b HOT 7
- s-function HOT 26
- I encountered the same problem as #70 HOT 1
- Errors running the Model.mdl of the example folder HOT 25
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blockfactory.