User-defined blocks in Xcos June 29th 2011 Clément DAVID & Bruno JOFRET Scilab Consortium Scilab/Xcos: Modeling dynamical systems ● Configurable subsystems use ● Conditionally executed subsystems creation ● Signals and blocks parameters adaptation ● Scilab algorithms and handwritten code integration The free and open source software for numerical computation Outline ● Model Building and Edition: – User-defined palettes, – Configurable subsystems use. ● Xcos toolbox skeleton ● Future external modules: – User defined blocks enabling Scilab and Modelica algorithms calls. The free and open source software for numerical computation Model Building and Edition The free and open source software for numerical computation Example to mimic a Simulink® block ● Emulate an integrator which triggers a state reset on an input signal 1 s xo In te g ra to r Scilab / Xcos Matlab / Simulink Simulink is a registered trademark of The Mathworks, Inc. The free and open source software for numerical computation The Simulink® diagram 1 C o n sta n t 1 s P u lse G e n e ra to r xo In te g ra to r 0 C o n sta n t1 The free and open source software for numerical computation S cope The Simulink® diagram results The free and open source software for numerical computation The Xcos diagram The free and open source software for numerical computation The Xcos diagram results The free and open source software for numerical computation With a SuperBlock The free and open source software for numerical computation Customize it The free and open source software for numerical computation With exact input mapping The free and open source software for numerical computation With exact input mapping (2) The free and open source software for numerical computation Adding to the palettes The free and open source software for numerical computation Using masked SuperBlocks ● Define variables in the parent context ● Use context on the blocks ● Create and customize the mask ● Remove variable in the parent context The free and open source software for numerical computation The masked SuperBlock The free and open source software for numerical computation Xcos toolbox skeleton The free and open source software for numerical computation Xcos toolbox skeleton ● Included into the Scilab distribution (Development tools) with: – Documentation (how to write your own help pages), – Examples, – Demos. ● Quick start to deploy an Xcos module through ATOMS. ● Interface your own libraries: – Native ones (C, C++, Fortran, …), – Interpreted (Scilab, Modelica). The free and open source software for numerical computation External modules distribution ● ATOMS – http://atoms.scilab.org – ● Scilab File Exchange – http://fileexchange.scilab.org – ● Package your business logic Upload sample files Forge – http://forge.scilab.org – Public or private collaboration platform The free and open source software for numerical computation Future External Modules The free and open source software for numerical computation UDP Blocks ● Implement blocks to handle remote data access using the UDP protocol: – http://forge.scilab.org/index.php/p/udp-blocks/ – not yet packaged in ATOMS. The free and open source software for numerical computation UDP Blocks ● UDP Send: – ● C function to send UDP packet UDP Receive: – C function to receive UDP packet The free and open source software for numerical computation UDP Blocks ● Example: Scilab ↔ Scilab Network The free and open source software for numerical computation UDP Blocks ● Example: Scilab ↔ ??? Network The free and open source software for numerical computation UDP Blocks ● Example: ??? ↔ Scilab Network The free and open source software for numerical computation UDP Blocks ● UDP Blocks: – Based on ToolBox Skeleton, – C Simulations function, – Available through ATOMS (coming soon), – Encode/Decode your own UDP packet, – Easy communication with hardware devices. The free and open source software for numerical computation COSELICA ● COSELICA (Modelica) Standard Modelica Library in Xcos – Use more Modelica features: ● ● ● – Electrical, Thermal, Mechanics. Advanced Xcos UI features (port colors, SVG blocks, etc... ) The free and open source software for numerical computation COSELICA The free and open source software for numerical computation COSELICA The free and open source software for numerical computation COSELICA The free and open source software for numerical computation COSELICA The free and open source software for numerical computation COSELICA ● COSELICA (Modelica): – Based on ToolBox Skeleton, – Modelica Equations, – Generated C Simulation functions, – Available through ATOMS (coming soon), – Extends Xcos on other scientific domains. The free and open source software for numerical computation Future Functionality Available with Scilab 5.4.0 The free and open source software for numerical computation Block wizard ● Common UI for user blocks generation ● Ease new blocks integration The free and open source software for numerical computation Thanks for your attention www.scilab.org