Code covered by the BSD License  

Highlights from
Logiciels temps réel

Logiciels temps réel

by

 

Real-time software concerning the domains of the signal processing, feedback and regulation

ouvre_modele_simulink.m
function [MOG,DEF,G]=ouvre_modele_simulink(MOGi,DEFi,Gi)

MOG=MOGi;
DEF=DEFi;
G=Gi;
modele='modele_simulinkmdl';
open_system([modele,'.mdl'])
repertoire=pwd;
cd ..
A=load('parametres_carte.mat');
cd(repertoire)
carte_entree=A.S.entree.carte;
plage_entree=num2str(A.S.entree.pop);
set_param(gcs,'solver','FixedStepDiscrete')
set_param(gcs,'StartTime','0') 
set_param(gcs,'StopTime','Inf')
set_param(gcs,'SystemTargetFile','rtwin.tlc') 
s=modele;
sbai=[s,'/Analog Input'];
set_param(sbai,'drvname',carte_entree);
set_param(sbai,'voltrange',plage_entree);
sbai1=[s,'/Analog Input1'];
set_param(sbai1,'drvname',carte_entree);
set_param(sbai1,'voltrange',plage_entree);
set_param(gcs,'SimulationMode','external');
set_param(gcs,'ExtMode','on');
duration=100000;
set_param(gcs,'ExtModeTrigDuration',duration);
scopeBlk = [modele,'/Scope'];
set_param(scopeBlk,'LimitDataPoints','on');
set_param(scopeBlk,'MaxDataPoints','12501');
open_system(scopeBlk)
MOG(1,6)= get_param(scopeBlk, 'Figure');
set(MOG(1,6),'color','white');
e=ecran;
p_ecran=[e(1)+10,e(4)/2,e(3)/2,e(4)/2];
set(MOG(1,6),'position',e)
pause(0.1)
n_fig=get(MOG(1,6),'name');
for k=1:1:DEF(1)
    zs=get_param([get_param(gcs,'name'),'/Constant',num2str(k+1)],'value');
    n_fig=[n_fig,'   VOIE',num2str(k),' : zro = ',zs,' cm'];
end;
pause(0.1)
set(MOG(1,6),'name',n_fig);
MOG(6,1)=get(MOG(1,6),'currentaxes');
set(MOG(6,1),'xcolor',[0.5 0.5 0.5],'ycolor',[0.5 0.5 0.5],'color','black');
set(MOG(6,1),'Ylim',[-7.5,7.5])
set(MOG(6,1),'position',p_ecran);
pause(0.1)
choix_txt_bdt={'','20 ms/cm','50 ms/cm','0,1 s/cm','0,2 s/cm','0,5 s/cm','1 s/cm','2 s/cm','5 s/cm','10 s/cm','20 s/cm'};
bdt=[20e-3,50e-3,0.1,0.2,0.5,1,2,5,10,20];
p_bdt=[0.55,0.9,0.2,0.1];
txt_bdt_titre=uicontrol(MOG(1,6),'style','text',...
    'unit','normalized',...
    'position',p_bdt,'backgroundcolor','w',...
	'foregroundcolor','b','fontunits','normalized','fontsize',0.3,...
    'fontweight','bold','string','Base de Temps');
p_popup=[0.6,0.8,0.1,0.1];
MOG(1,2)=uicontrol(MOG(1,6),'style','popupmenu',...
    'unit','normalized','position',p_popup,...
    'string',choix_txt_bdt,'backgroundcolor','w',...
	'foregroundcolor','r','fontunits','normalized','fontsize',0.3,'fontweight','bold');
p_synchro=[0.55,0.7,0.2,0.1];             
 txt_synchro=uicontrol(MOG(1,6),'style','text',...
     'unit','normalized',...
     'position',p_synchro,'backgroundcolor','w',...
	 'foregroundcolor','b','fontunits','normalized','fontsize',0.3,...
     'fontweight','bold','string','Synchro (Y1)');   
s={'','NON','OUI'};
MOG(1,3)=uicontrol(MOG(1,6),'style','popupmenu',...
    'unit','normalized',...
    'position',[0.7,0.7,0.1,0.1],...
     'string',s,'backgroundcolor','w',...
	 'foregroundcolor','r','fontunits','normalized','fontsize',0.3,'fontweight','bold',...
     'callback','[MOG,DEF]=synchro(MOG,DEF);');
choix_calibre_y={'','2 V/cm','1 V/cm','0,5 V/cm','0,2 V/cm','0,1 V/cm','50 mV/cm','20 mV/cm','VAR'};
calibre_y=[2,1,0.5,0.2,0.1,0.05,0.02,1];
for k=1:1:min(DEF(1),4)
    p_y=[0.175*(k-1)+0.125,0.35,0.1,0.1];
    s=['VOIE Y',num2str(k)];
    txt_y_titre=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized',...
		'position',p_y,'backgroundcolor','w',...
	    'foregroundcolor','b','fontunits','normalized','fontsize',0.3,...
        'fontweight','bold','string',s);
    p_p=[0.175*(k-1)+0.125,0.30,0.1,0.1];   
    MOG(1+k,2)=uicontrol(MOG(1,6),'style','popupmenu',...
        'unit','normalized',...
        'position',p_p,...
        'string',choix_calibre_y,'backgroundcolor','w',...
	    'foregroundcolor','r','fontunits','normalized','fontsize',0.3,'fontweight','bold');
       
end
p_y=[0.75+0.125,0.4,0.1,0.1];
%************************************************************
%  Partie caractristique du logiciel MODELE
%***********************************************************
p_y=[0.75+0.125,0.49,0.1,0.1];
s='Modle';
txt_y_titre=uicontrol(MOG(1,6),'style','text',...
    'unit','normalized',...
	'position',p_y,'backgroundcolor','w',...
	'foregroundcolor','b','fontunits','normalized','fontsize',0.3,...
    'fontweight','bold','string',s);
 p_p=[0.25*3+0.075,0.485,0.15,0.05];   
 %
 % Retard
 %
    MOG(1,7)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
        'string','Retard (s)','backgroundcolor','w',...
        'horizontalalignment','center',...
	    'foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold');  
  p_p=[0.25*3+0.075,0.47,0.15,0.04];   
  if MOG(2,7)~=0
        s=get(MOG(2,7),'string');
    else
        s='1';
    end;
    MOG(2,7)=uicontrol(MOG(1,6),'style','edit',...
        'unit','normalized','position',p_p,...
        'backgroundcolor','y','string',s,...
        'horizontalalignment','center',...
	    'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold');   
 p_p=[0.25*3+0.075,0.185,0.15,0.05];   
 %
 % Valeur initiale entre
 %
    MOG(3,7)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
        'string','Valeur Initiale Entre (V)',...
        'backgroundcolor','w','horizontalalignment','center',...
	    'foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold');  
  pause(0.1)
  p_p=[0.25*3+0.075,0.17,0.15,0.04];   
  if MOG(4,7)~=0
        s=get(MOG(4,7),'string');
    else
        s='0';
    end;
    MOG(4,7)=uicontrol(MOG(1,6),'style','edit',...
        'unit','normalized','position',p_p,...
         'backgroundcolor','y','string',s,...
         'horizontalalignment','center',...
	     'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold');   
  pause(0.1)
   p_p=[0.25*3+0.075,0.385,0.15,0.05];  
   %
   % Numrateur de T(p)
   %
    MOG(5,7)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
        'string','Numrateur','backgroundcolor','w',...
        'horizontalalignment','center',...
	    'foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold');  
  pause(0.1)
  p_p=[0.25*3+0.075,0.37,0.15,0.04];   
  if MOG(6,7)~=0
        s=get(MOG(6,7),'string');
    else
        s='NUM=[1]';
    end;
    MOG(6,7)=uicontrol(MOG(1,6),'style','edit',...
        'unit','normalized','position',p_p,...
        'backgroundcolor','y','string',s,...
         'horizontalalignment','center',...
        'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold'); 
  pause(0.1)
   p_p=[0.25*3+0.075,0.285,0.15,0.05];   
   %
   % Dnominateur de T(p)
   %
    MOG(7,7)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
        'string','Dnominateur','backgroundcolor','w',...
        'horizontalalignment','center',...
	    'foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold');  
  pause(0.1)
  p_p=[0.25*3+0.075,0.27,0.15,0.04];   
  if MOG(8,7)~=0
        s=get(MOG(8,7),'string');
    else
        s='DEN=[1,1]';
    end;
    MOG(8,7)=uicontrol(MOG(1,6),'style','edit',...
        'unit','normalized','position',p_p,...
        'backgroundcolor','y','string',s,...
        'horizontalalignment','center',...
	    'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold'); 
  pause(0.1)
  p_p=[0.25*3+0.075,0.085,0.15,0.05]; 
  %
  % Valeur initiale sortie analogique
  %
    MOG(9,7)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
         'string','Valeur Initiale Sortie (V)',...
         'backgroundcolor','w','horizontalalignment','center',...
	     'foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold');  
  pause(0.1)
  p_p=[0.25*3+0.075,0.07,0.15,0.04];   
  if MOG(10,7)~=0
        s=get(MOG(10,7),'string');
    else
        s='0';
    end;
    MOG(10,7)=uicontrol(MOG(1,6),'style','edit',...
        'unit','normalized','position',p_p,...
        'backgroundcolor','y','string',s,...
        'horizontalalignment','center',...
	    'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold');   
  pause(0.1)
%************************************************************
%  FIN Partie caractristique du logiciel MODELE
%***********************************************************  
MOG(12,1)=uicontrol(MOG(1,6),'style','text',...
    'unit','normalized','position',[0.01,0.18,0.05,0.04],...
    'backgroundcolor','w','string','Filtrage ?',...
    'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold');

for k=1:1:min(DEF(1),4)
    p_p=[0.175*(k-1)+0.125,0.18,0.05,0.04]; 
    s={'','NON','OUI'};
    MOG(12,2+k)=uicontrol(MOG(1,6),'style','popupmenu',...
        'unit','normalized','position',p_p,'userdata',k,...
        'backgroundcolor','w','string',s,...
        'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
         'callback','K=get(gco,''userdata'');MOG=nombre_point(MOG,K);'); 
end;
for k=1:1:min(DEF(1),4)
   p_p=[0.175*(k-1)+0.125,0.33,0.05,0.03]; 
    MOG(3,2+k)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized','position',p_p,'userdata',k,...
         'backgroundcolor','w','string','+1cm',...
         'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
         'callback','K=get(gco,''userdata'');MOG=regle_zero2(3,K,G,MOG);'); 
   p_p=[0.175*(k-1)+0.125,0.30,0.05,0.03]; 
    MOG(4,2+k)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized','position',p_p,'userdata',k,...
        'backgroundcolor','w','string','-1cm',...
        'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','K=get(gco,''userdata'');MOG=regle_zero2(4,K,G,MOG);');   
     p_p=[0.175*(k-1)+0.175,0.33,0.05,0.03]; 
    MOG(5,2+k)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized','position',p_p,'userdata',k,...
        'backgroundcolor','w','string','+1/2mm',...
        'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
         'callback','K=get(gco,''userdata'');MOG=regle_zero2(5,K,G,MOG);'); 
   p_p=[0.175*(k-1)+0.175,0.30,0.05,0.03]; 
    MOG(6,2+k)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized','position',p_p,'userdata',k,...
       'backgroundcolor','w','string','-1/2mm',...
       'foregroundcolor','r','fontunits','normalized','fontsize',0.5,'fontweight','bold',...
        'callback','K=get(gco,''userdata'');MOG=regle_zero2(6,K,G,MOG);');  
    p_p=[0.175*(k-1)+0.08,0.32,0.04,0.03];
    MOG(2,2+k)=uicontrol(MOG(1,6),'style','text',...
        'unit','normalized','position',p_p,...
        'backgroundcolor','w','string','ZERO',...
        'foregroundcolor','b','fontunits','normalized','fontsize',0.5,'fontweight','bold');
end;

MOG(8,1)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized',...
		'position',[0.9 0.95 0.1 0.05],...
	    'string','OK','foregroundcolor','r',...
        'fontunits','normalized','fontsize',0.4,'fontweight','bold',...
        'KeyPressFcn',{@lance_enregistrement,MOG,DEF},...
        'callback','[MOG,DEF,G]=lance_modele_simulink(MOG,DEF,G);');
MOG(9,1)=uicontrol(MOG(1,6),'style','push',...
        'unit','normalized',...
		'position',[0.9 0.87 0.1 0.05],...
	    'string','STOP','foregroundcolor','r','fontunits','normalized','fontsize',0.4,'fontweight','bold',...
        'callback','[MOG,DEF,G]=stop_modele(MOG,DEF,G);');
MOG(10,1)=uicontrol(MOG(1,6),'style','push','unit','normalized',...
		'position',[0.9 0.71 0.1 0.05],...
	    'string','MENU','foregroundcolor','r',...
        'fontunits','normalized','fontsize',0.4,'fontweight','bold',...
        'callback','close_system(gcs,0);[MOG,DEF,G]=modele_menu(MOG,DEF,G);');

inst='[MOG,DEF,G]=stop_modele(MOG,DEF,G);close_system(gcs,0);delete(figure(1));MOG=zeros(12,7);DEF=zeros(1,8);cd ..;liste_logiciels';

MOG(11,1)=uicontrol(MOG(1,6),'style','push',...
    'unit','normalized',...
		'position',[0.9 0.64 0.1 0.05],...
	    'string','FIN','foregroundcolor','r',...
        'fontunits','normalized','fontsize',0.4,'fontweight','bold',...
        'callback',inst);


Contact us