<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Monospaced;
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"Préformaté HTML Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
{mso-style-priority:99;
mso-style-link:"Texte de bulles Car";
margin:0cm;
margin-bottom:.0001pt;
font-size:8.0pt;
font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.TextedebullesCar
{mso-style-name:"Texte de bulles Car";
mso-style-priority:99;
mso-style-link:"Texte de bulles";
font-family:"Tahoma","sans-serif";}
span.PrformatHTMLCar
{mso-style-name:"Préformaté HTML Car";
mso-style-priority:99;
mso-style-link:"Préformaté HTML";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:929236625;
mso-list-type:hybrid;
mso-list-template-ids:1716170938 -506821126 67895299 67895301 67895297 67895299 67895301 67895297 67895299 67895301;}
@list l0:level1
{mso-level-start-at:0;
mso-level-number-format:bullet;
mso-level-text:-;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-font-family:Calibri;
mso-bidi-font-family:"Times New Roman";}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=FR link=blue vlink=purple>
<div class=WordSection1>
<p class=MsoNormal>Bonjour à tous,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Je cherche actuellement à utiliser une dll dans Scilab
5.4.0.<o:p></o:p></p>
<p class=MsoNormal>J’explique ici mon problème.<o:p></o:p></p>
<p class=MsoNormal>J’ai créé une dll grâce à l’outil RTW (Real-Time
Workshop) sur Matlab à partir d’un modèle Simulink qui est le suivant :<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><img width=685 height=412 id="Image_x0020_1"
src="cid:image001.png@01CE57AC.01A0A620"><o:p></o:p></p>
<p class=MsoNormal>Ce modèle se nomme « model_test » et l’entrée
et la sortie sont toutes les deux de dimensions 2.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>L’outil RTW me permet de créer un code C recréant ce
schéma, dont je me suis ensuite servi pour créer la dll.<o:p></o:p></p>
<p class=MsoNormal>J’ai créé celle-ci grâce à un wrapper dans le quel se
trouve 5 fonctions :<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Initiate : qui initialise le modèle<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>SetInput_CDV : qui permet de définir les entrées
du modèle<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>OneStep_CDV : qui réalise un pas de calcul<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>getOuput_CDV : qui permet d’obtenir la
sortie<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Pour info, voilà comment sont définis les fonctions SetInput_CDV
et getOutput_CDV.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US>char* SetInput_CDV(double* inputArgs)<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>{<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> *(model_test_U.In1) =
*inputArgs; /*Change Model name
and name of Input here*/<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> </span>return
"t";<o:p></o:p></p>
<p class=MsoNormal>}<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US>char* getOutput_CDV(double* outputArgs)<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>{ <o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> *outputArgs =
*(model_test_Y.Out1); /*Change Model
name and name of Output here*/<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> </span>return "t";<o:p></o:p></p>
<p class=MsoNormal>}<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>U représente la structure des entrées et Y la structure des
sorties.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Voilà ensuite comment je veux utiliser ma dll dans Scilab.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Monospaced","serif";
color:black'>func_names</span><span lang=EN-US style='font-size:10.0pt;
font-family:"Monospaced","serif"'> <span style='color:#5C5C5C'>=</span> <span
style='color:#4A55DB'>[</span> <span style='color:rosybrown'>'_SetInput_CDV'</span><span
style='color:black'>,</span> <span style='color:rosybrown'>'_Initiate_CDV'</span><span
style='color:black'>,</span> <span style='color:rosybrown'>'_OneStep_CDV'</span><span
style='color:black'>,</span> <span style='color:rosybrown'>'_getOutput_CDV'</span><span
style='color:black'>,</span> <span style='color:rosybrown'>'_Cleanup_CDV'</span>
<span style='color:#4A55DB'>]</span><span style='color:black'>;</span><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Monospaced","serif";
color:black'>flag</span><span lang=EN-US style='font-size:10.0pt;font-family:
"Monospaced","serif";color:#5C5C5C'>=</span><span lang=EN-US style='font-size:
10.0pt;font-family:"Monospaced","serif";color:rosybrown'>"c"</span><span
lang=EN-US style='font-size:10.0pt;font-family:"Monospaced","serif";color:black'>;</span><span
lang=EN-US style='font-size:10.0pt;font-family:"Monospaced","serif"'><o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Monospaced","serif";
color:black'>dll</span><span lang=EN-US style='font-size:10.0pt;font-family:
"Monospaced","serif"'> <span style='color:#5C5C5C'>=</span> <span
style='color:black'>link</span><span style='color:#4A55DB'>(</span><span
style='color:rosybrown'>"model_test.dll"</span><span
style='color:black'>,</span> <span style='color:black'>func_names,</span> <span
style='color:black'>flag</span><span style='color:#4A55DB'>)<o:p></o:p></span></span></p>
<pre><span style='font-family:"Monospaced","serif";color:black'>Ini</span><span
style='font-family:"Monospaced","serif";color:#5C5C5C'>=</span><span
style='font-family:"Monospaced","serif";color:black'>call</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>(</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"_Initiate_CDV"</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>)</span><span
style='font-family:"Monospaced","serif"'><o:p></o:p></span></pre><pre><span
style='font-family:"Monospaced","serif";color:black'>In</span><span
style='font-family:"Monospaced","serif";color:#5C5C5C'>=</span><span
style='font-family:"Monospaced","serif";color:black'>call</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>(</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"_SetInput_CDV"</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>2</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>1</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"d"</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>)</span><span
style='font-family:"Monospaced","serif"'> <i><span style='color:#64AE64'>//la valeur d'entrée de In1 est donc 2</span></i><o:p></o:p></span></pre><pre><span
lang=EN-US style='font-family:"Monospaced","serif";color:black'>OS</span><span
lang=EN-US style='font-family:"Monospaced","serif";color:#5C5C5C'>=</span><span
lang=EN-US style='font-family:"Monospaced","serif";color:black'>call</span><span
lang=EN-US style='font-family:"Monospaced","serif";color:#4A55DB'>(</span><span
lang=EN-US style='font-family:"Monospaced","serif";color:rosybrown'>"_OneStep_CDV"</span><span
lang=EN-US style='font-family:"Monospaced","serif";color:#4A55DB'>)</span><span
lang=EN-US style='font-family:"Monospaced","serif"'><o:p></o:p></span></pre><pre><span
style='font-family:"Monospaced","serif";color:black'>Out</span><span
style='font-family:"Monospaced","serif";color:#5C5C5C'>=</span><span
style='font-family:"Monospaced","serif";color:black'>call</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>(</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"_getOuput_CDV"</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"out"</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>[</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>2</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>1</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>]</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>1</span><span
style='font-family:"Monospaced","serif";color:black'>,</span><span
style='font-family:"Monospaced","serif";color:rosybrown'>"d"</span><span
style='font-family:"Monospaced","serif";color:#4A55DB'>)</span><i><span
style='font-family:"Monospaced","serif";color:#64AE64'>//la sortie est bien de dimension 2 et de type double</span></i><span
style='font-family:"Monospaced","serif"'><o:p></o:p></span></pre><pre><span
style='font-family:"Monospaced","serif"'><o:p> </o:p></span></pre>
<p class=MsoNormal>J’obtiens en résultat : <o:p></o:p></p>
<p class=MsoNormal>Out =<o:p></o:p></p>
<p class=MsoNormal> <o:p></o:p></p>
<p class=MsoNormal> 4. <o:p></o:p></p>
<p class=MsoNormal> 2.97D-313 <o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>On a bien la dimension 1 qui est égale à 4 (gain1=2, In1=2)<o:p></o:p></p>
<p class=MsoNormal>En revanche on devrait avoir 10 pour la dimension 2 (5*2)
mais cette valeur n’est pas reconnue et j’obtiens un nombre
aléatoire en sortie.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Savez-vous comment faire pour bien obtenir en sortie un
vecteur de dimension 2 avec les bons résultats soit Out=[4,10] ?<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Je vous remercie pour votre aide.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Cordialement,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Cédric<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Ps : je met en pièce jointe mon modèle Simulink<o:p></o:p></p>
</div>
<DIV><P><HR>
Le contenu de ce message est prévu uniquement pour le destinataire nommé. Il contient des informations qui peuvent être confidentielles. A moins d'être le destinataire nommé ou autorisé par le destinataire, vous ne pouvez pas copier, employer ou révéler à une autre personne le contenu de ce message. Si vous le recevez par erreur, s'il vous plait, informez nous immédiatement et détruisez le.<BR>
<BR>
The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.
</P></DIV>
</body>
</html>