// Scicos // // Copyright (C) INRIA - METALAU Project // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // See the file ../license.txt // function [x,y,typ]=AUTOMAT(job,arg1,arg2) x=[]; y=[]; typ=[]; select job case "set" then x=arg1; graphics=arg1.graphics; exprs=graphics.exprs model=arg1.model; ipar=model.ipar; NMode=ipar(1) NX=ipar(3) while %t do CX="C1"; MSG0="''Jump from Mode "; MSG2=":[..;M_final(Guard=In("; MSG3=").i);..]''" MSG=MSG0+"1"+MSG2+"1"+MSG3; VEC="''mat'',[-1,1]"; for i=2:NMode CX=CX+","+"C"+string(i); MSG=MSG+";"+MSG0+string(i)+MSG2+string(i)+MSG3; VEC=VEC+","+"''mat'',[-1,1]"; end //=========================================== GTV="[ok,NMode,Minitial,NX,X0,XP,"+CX+",exprs]=scicos_getvalue(''Set Finite state machine model'',.. [''Number (finite-state) Modes'';''Initial Mode'';''Number of continuous-time states'';''Continuous-time states intial values'';''Xproperties of continuous-time states in each Mode'';"+MSG+"],.. list(''vec'',1,''vec'',1,''vec'',1,''mat'',[-1,-1],''mat'',[-1,-1],"+VEC+"),exprs)" execstr(GTV); if ~ok then break, end NMode_old=size(exprs,"*")-5;//-number of fileds before CX ModifEncore=%f; if (NMode_old>NMode) then exprs(NMode+6:NMode_old+5)=[];// number of fileds ModifEncore=%t; end if (NMode_oldsize(X0,"*")) then messagebox("the size of intial continuous-time states should be NX="+string(NX),"modal","error"); ModifEncore=%t; end [rXP,cXP]=size(XP) if cXP<>NX then messagebox("Xproperty matrix is not valid: it should have NX="+string(NX)+" columns","modal","error"); ModifEncore=%t; elseif ((rXP<>NMode) & (rXP>1)) messagebox("Xproperty matrix is not valid: it should have NMode="+string(NMode)+" or 1 row(s)","modal","error"); ModifEncore=%t; elseif (rXP==1) for i=1:NMode-1 XP=[XP;XP(1,:)];// xproprties are identical in modes. end end if (NMode_old==NMode)&(~ModifEncore) then XP=matrix(XP',NMode*NX,1);// put XP in column vector to be stocked in ipar ipar=[NMode;Minitial;NX;XP]; rpar=matrix(X0,NX,1);// put X0 in a column vector; INP=ones(NMode,1); if NX>0 then OUT=[2;2*NX]; else OUT=[2]; end MaxModes=1; nzcross=0; for i=1:NMode Ci=evstr(exprs(5+i));// number of fileds ipar=[ipar;Ci]; INP(i,1)=2*NX+length(Ci); if (nzcrossNMode then messagebox(["Number of Modes should be "+string(MaxModes);.. "A destination Mode in Mode#"+string(imax)+"''s targets is invalid!"],"modal","error"); ModifEncore=%t; end if MaxModes