1. This Software is no longer supported by us. Please download the new motion control software SimTools.
    Dismiss Notice
  2. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  3. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  4. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  5. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

small code in C++ and motion of shifter

Discussion in 'Yoda - ForceFeedback Scanner' started by akina, Aug 17, 2009.

  1. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Hello, sirnoname and other :hi:

    Thank you for yours softwares. :thbup:


    I want make a source code small in C++ for be to utilised in matlab. Because there is much of possibilitie for motion control on matlab, and especially mathematically.

    I have begin this with help of site, I succeed to read the effet send by Yoda in export liste, but I not come read :



    current gear
    current speed
    gear shakee effect
    accelaration speed
    lateral force
    vertical force
    longitudinal force
    pitch
    yaw
    roll
    ...

    which should this found in position 20,21,22,23,24,25,...
    I think this a problem of initialisation, because I have on Yoda write free buffer 35. Ever, 19 but i don't recall how I do, and if this is good?

    And I want know how recovers gauge data

    Thank you for yours softwares again and your help.


    Ragard, akina


    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <cstdlib>
    #include <iostream>


    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    #pragma once

    // TODO: reference additional headers your program requires here

    struct Export
    {
    bool active[40];
    bool play [40];
    int data [40];
    int type [40];
    };

    void LoadFcn(void);
    void GetData(void);
    void EndConnection(void);
    #include windows.h

    Export myYoda;

    // Set dll handle
    HINSTANCE hDLL;

    // Define the dll function GetExport
    typedef Export (*myFunc1) (void);
    myFunc1 GetExport;

    // Define the dll function EndYoda
    typedef bool (*myFunc2) (int info);
    myFunc2 EndYoda;

    void LoadFcn(void)
    {

    // Load the buffer DLL in same Directory or insert here other location.
    hDLL = LoadLibrary (buffer.dll);

    if (hDLL!=NULL) {
    // printf(hDLL diff de null);
    // Define the dll function GetExport and get its address
    GetExport = (myFunc1) GetProcAddress (hDLL, GetExport);
    EndYoda = (myFunc2) GetProcAddress (hDLL, EndYoda);
    }
    }

    void GetData(void)
    {
    if (hDLL!=NULL) {

    myYoda = GetExport();}
    else printf(hDLL=null);
    }

    void EndConnection(void)
    {
    if (hDLL!=NULL) {
    EndYoda(1);
    FreeLibrary(hDLL);
    hDLL=NULL;
    }
    }




    using namespace std;

    int main(void)
    {
    LoadFcn();
    GetData();
    printf(\ndata1 %s \n,hDLL);
    //int donnee= GetExport;
    int donnee=myYoda.data[23];
    do{

    int donnee0=myYoda.data[20];//current gear
    int donnee1=myYoda.data[21];//current speed
    int donnee2=myYoda.data[22];//gear shakee effect
    int donnee3=myYoda.data[23];//accelaration speed
    int donnee4=myYoda.data[24];//lateral force
    int donnee5=myYoda.data[25];//vertical force
    int donnee6=myYoda.data[26];//longitudinal force
    int donnee7=myYoda.data[27];//pitch
    int donnee8=myYoda.data[28];//yaw
    int donnee9=myYoda.data[29];//roll
    int donnee10=myYoda.data[30];//carCGLoc1
    LoadFcn();
    GetData();
    printf(\n %i - %i - %i - %i - %i - %i - %i - %i - %i - %i - %i \n,donnee0,donnee1,donnee2,donnee3,donnee4,donnee5,donnee6,donnee7,donnee8,donnee9,donnee10);}
    while(1);
    system(PAUSE);
    EndConnection;
    return 0;

    }

  2. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Thank you.
    I will serve MMF and GetPluginDataEx for GTR2 , it will better match for me, I think.
    I will keep you up-to-date of my advanced.

    Ragard, akina
  3. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Thank you,
    It's OK, I succeed to read the effet send by GTREvo directly, with your plugin

    Thank you again sirnoname ,
    I will keep you up-to-date of my advanced with matlab.

    Ragard, akina
  4. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Hello

    Pour les nombreux français qui vienne sur ce site et qui on seulement des notions de c++ comme moi, si vous voulez faire un petit programme en C++, il faut d'abord comprendre a quoi sert un DLL, (je ne le savait pas :blush: ) Apres une fois que vous savez que en gros, c'est des bibliothèques de fonction qu'on peu appeler par plusieurs programme, d'où l'intérêt quelles ne soit pas en plusieurs exemplaire sur le même PC et sa évite de faire plusieur fois le boulot :thbup: .

    Apres sa parerait plus évident quand on voit des plugins Race07Plugin.dll qui se promène :yippiee:

    Il suffit alors de modifier un petit prog qui appel le DLL et la fonction voulu
    je me suis servie du programme de Martin Wiedenbauer (thank you ;D ) qui appelai le buffer.dll

    exemple a améliorer :? ( il y des truc qui doivent pas servir)


    Code:
    // MSFlightSimDll.cpp : Definiert die Initialisierungsroutinen für die DLL.
    //
    //
    //		
    //		Spiel: Race07
    //		www.x-sim.de
    //		From Author: Martin Wiedenbauer   :hi: 
    //
    //
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <cstdlib>
    #include <iostream>
    #include <time.h>
    
    
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    #pragma once
    
    // TODO: reference additional headers your program requires here
    
    
    struct GetPluginDataEx
    {
    	int			data[22];				//Simulator plugin values
    	int			speed;					//current speed in kmh
    	int			rpm;					//rpm
    	int			fuel;					//fuel of tank
    	int			tempfuel;				//tank temperature
    	int			currentgear;			//number of gear
    	int			currentlap;				//number of current lab
    	int			bestlaptime;			//best lap time
    	int			lastlaptime;			//last lap time
    	int			position;				//current possition
    	int			tempwater;				//water temperature
    	int			flags;					//flags
    	int			tiretemps[4][3];		//temp of each tire (inner middle outer)
    	int			altimeter;				//Flight gauge altimeter
    	int			airspeed;				//Flight gauge airspeed over ground
    	int			verticalvelocity;		//Flight Vertical speed meter
    	int			attidude;				//Flight attitude Indicator
    	int			heading;				//Flight heading Indikator
    	int			fuelflow;				//Flight fuelflow
    	int			fuelleft;				//Flight fuelleft
    	int			fuelright;				//Flight fuelright
    	int			tempexhaustgas;			//Flight temperature of exhaust gas
    	int			oiltemperature;			//Flight temperature of oil
    	int			oilpressure;			//Flight pressure of oil
    	int			turncoordinator;		//Flight turncoordinator
    	int			outsidetemperture;		//Flight outside air temperature
    	int			ampmeter;				//Flight ampmeter
    	int			buffer[6];				//not defined values left
    };
    
    
    
    int LoadFcn(void);
    void GetData(void);
    void EndConnection(void);
    #include windows.h
    
    GetPluginDataEx myYoda;
    
    // Set dll handle
    HINSTANCE hDLL;
    
    // Define the dll function GetExport
    typedef GetPluginDataEx (*myFunc1) (void);
    myFunc1 GetExport;
    
    // Define the dll function EndYoda
    typedef bool (*myFunc2) (int info);
    myFunc2 EndYoda;
    
    int LoadFcn(void)
    {
     
    	// Load the buffer DLL in same Directory or insert here other location.
    	hDLL = LoadLibrary (Race07Plugin.dll); 
    
    	if (hDLL!=NULL) {
                      //printf(hDLL diff de null);
    	// Define the dll function GetExport and get its address
    	GetExport = (myFunc1) GetProcAddress (hDLL, GetDataArrayEx);
    	EndYoda = (myFunc2) GetProcAddress (hDLL, EndYoda);
    	return 10;
    	}
    	else return -1;
    }
    
    void GetData(void)
    {
    	if (hDLL!=NULL) {
                      
        myYoda = GetExport();}
        else printf(hDLL=null);
    }
    
    void EndConnection(void)
    {
    	if (hDLL!=NULL) {
    		EndYoda(1);
    		FreeLibrary(hDLL);
    		hDLL=NULL;
    	}
    }
    
    
    
    
    int main(void)
    {
         
          do{
                        LoadFcn();
                        GetData(); 
                        printf(\nrpm %04i ,myYoda.rpm);
                        printf(gear %02i ,myYoda.data[1]);
                        printf(speed %03i ,myYoda.data[2]);
                        printf(geareffekt %05i ,myYoda.data[3]);
                        printf(acceleration %05i ,myYoda.data[4]);
                        printf(lateral %05i ,myYoda.data[5]);
                        printf(longitudinal %05i ,myYoda.data[6]);
                        printf(pitch %05i ,myYoda.data[7]);
                        printf(yaw %05i ,myYoda.data[8]);
                        Sleep(100);
                       
    
    
          }while(1);
          printf( jeu arreter.(hDLL=NULL)\n);
                  
    
        system(PAUSE);
        EndConnection;
        return 0;
        
    }
    
    
    n'hésiter pas a critiquer :thbd: et proposer des améliorations svp

    Thank you again for sirnoname :clap: :clap: :clap:

    Bye
  5. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
  6. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Hi I want make this http://www.youtube.com/watch?v=bnc4IDwojPY but with the vibration and movement in function of car acceleration.

    The Joystick is not good for this, not so fast for the good vibration. I want make the gear with the metal (normal) and add two motor or small acuetor for the immersive motion. Or it is possible of add a bass bump for the vibration?

    The S-function has in input the game name and in output (speed,rpm,acceleration,fuel,lap...)
  7. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Thank you,
    For the vibration i have try with simulink and basic function include by default, thus i can juste change the mean force, for example
    (FFB= constant+sin(x*t) ).

    You think, I can use a specifique function for vibrations (by a DLL may be) ??? It is better if the vibration signal don't cross the USB each time, just the frequency and the amplitude. :thbup:

    I try of make the vibration because I had a old car and the gearbox had lot of vibration, and it moved when I accelerated , break, turn...
    I like this, it is more imersive i think.

    Now the Shifter is very stable,(especially for the German car ;D ), but there is a litle vibration, especially in a sport car i think.

    Else for FFShifter, I think it is free ware but no open source, you can download here http://rs34.rapidshare.com/files/942782 ... ta_0_3.zip

    Bye , good christmas day :cheers:
  8. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Re: I want make a source code small in C++

    Ok thank you I will see this. I'm not sure of use a joystick because the appearance is not nice for a shifter. I prefer a robuste shifter in metal for the H and add a effect with small actuator(or electromagnet of big electrical relay). But I will use probably the electronic circuit of joystick.
  9. akina

    akina New Member

    Joined:
    Jun 7, 2009
    Messages:
    25
    Balance:
    1Coins
    Ratings:
    +0 / 0 / -0
    Hello , I give the code of S-function for NSR1 by exemple
    Code:
    /*
     
      *
      *   --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
      *
      *   This file is an S-function produced by the S-Function
      *   Builder which only recognizes certain fields.  Changes made
      *   outside these fields will be lost the next time the block is
      *   used to load, edit, and resave this file. This file will be overwritten
      *   by the S-function Builder block. If you want to edit this file by hand, 
      *   you must change it only in the area defined as:  
      *
      *        %%%-SFUNWIZ_defines_Changes_BEGIN
      *        #define NAME 'replacement text' 
      *        %%% SFUNWIZ_defines_Changes_END
      *
      *   DO NOT change NAME--Change the 'replacement text' only.
      *
      *   For better compatibility with the Real-Time Workshop, the
      *   wrapper S-function technique is used.  This is discussed
      *   in the Real-Time Workshop User's Manual in the Chapter titled,
      *   Wrapper S-functions.
      *
      *  -------------------------------------------------------------------------
      * | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
      *  ------------------------------------------------------------------------- 
     * Created: Wed Sep 30 21:41:30 2009
     * 
     *
     */
    
    
    #define S_FUNCTION_NAME NSR1
    #define S_FUNCTION_LEVEL 2
    /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
    /* %%%-SFUNWIZ_defines_Changes_BEGIN --- EDIT HERE TO _END */
    #define NUM_INPUTS           0
    
    #define NUM_OUTPUTS          3
    /* Output Port  0 */
    #define OUT_PORT_0_NAME      x
    #define OUTPUT_0_WIDTH       1
    #define OUTPUT_DIMS_0_COL    1
    #define OUTPUT_0_DTYPE       real_T
    #define OUTPUT_0_COMPLEX     COMPLEX_NO
    #define OUT_0_FRAME_BASED    FRAME_NO
    #define OUT_0_DIMS           1-D
    #define OUT_0_ISSIGNED        1
    #define OUT_0_WORDLENGTH      8
    #define OUT_0_FIXPOINTSCALING 1
    #define OUT_0_FRACTIONLENGTH  3
    #define OUT_0_BIAS            0
    #define OUT_0_SLOPE           0.125
    /* Output Port  1 */
    #define OUT_PORT_1_NAME      y
    #define OUTPUT_1_WIDTH       1
    #define OUTPUT_DIMS_1_COL    1
    #define OUTPUT_1_DTYPE       real_T
    #define OUTPUT_1_COMPLEX     COMPLEX_NO
    #define OUT_1_FRAME_BASED    FRAME_NO
    #define OUT_1_DIMS           1-D
    #define OUT_1_ISSIGNED        1
    #define OUT_1_WORDLENGTH      8
    #define OUT_1_FIXPOINTSCALING 1
    #define OUT_1_FRACTIONLENGTH  3
    #define OUT_1_BIAS            0
    #define OUT_1_SLOPE           0.125
    /* Output Port  2 */
    #define OUT_PORT_2_NAME      z
    #define OUTPUT_2_WIDTH       1
    #define OUTPUT_DIMS_2_COL    1
    #define OUTPUT_2_DTYPE       real_T
    #define OUTPUT_2_COMPLEX     COMPLEX_NO
    #define OUT_2_FRAME_BASED    FRAME_NO
    #define OUT_2_DIMS           1-D
    #define OUT_2_ISSIGNED        1
    #define OUT_2_WORDLENGTH      8
    #define OUT_2_FIXPOINTSCALING 1
    #define OUT_2_FRACTIONLENGTH  3
    #define OUT_2_BIAS            0
    #define OUT_2_SLOPE           0.125
    
    #define NPARAMS              0
    
    #define SAMPLE_TIME_0        INHERITED_SAMPLE_TIME
    #define NUM_DISC_STATES      0
    #define DISC_STATES_IC       [0]
    #define NUM_CONT_STATES      0
    #define CONT_STATES_IC       [0]
    
    #define SFUNWIZ_GENERATE_TLC 1
    #define SOURCEFILES __SFB__
    #define PANELINDEX           6
    #define USE_SIMSTRUCT        0
    #define SHOW_COMPILE_STEPS   0                   
    #define CREATE_DEBUG_MEXFILE 0
    #define SAVE_CODE_ONLY       0
    #define SFUNWIZ_REVISION     3.0
    /* %%%-SFUNWIZ_defines_Changes_END --- EDIT HERE TO _BEGIN */
    /*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
    #include simstruc.h
    
    extern void GTR_Evo_Outputs_wrapper(real_T *x,
                              real_T *y,
                              real_T *z);
    
    /*====================*
     * S-function methods *
     *====================*/
    /* Function: mdlInitializeSizes ===============================================
     * Abstract:
     *   Setup sizes of the various vectors.
     */
    static void mdlInitializeSizes(SimStruct *S)
    {
    
        DECL_AND_INIT_DIMSINFO(outputDimsInfo);
        ssSetNumSFcnParams(S, NPARAMS);
         if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
    	 return; /* Parameter mismatch will be reported by Simulink */
         }
    
        ssSetNumContStates(S, NUM_CONT_STATES);
        ssSetNumDiscStates(S, NUM_DISC_STATES);
    
        if (!ssSetNumInputPorts(S, NUM_INPUTS)) return;
    
        if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return;
        /* Output Port 0 */
        ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH);
        ssSetOutputPortDataType(S, 0, SS_DOUBLE);
        ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX);
        /* Output Port 1 */
        ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH);
        ssSetOutputPortDataType(S, 1, SS_DOUBLE);
        ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX);
        /* Output Port 2 */
        ssSetOutputPortWidth(S, 2, OUTPUT_2_WIDTH);
        ssSetOutputPortDataType(S, 2, SS_DOUBLE);
        ssSetOutputPortComplexSignal(S, 2, OUTPUT_2_COMPLEX);
    
        ssSetNumSampleTimes(S, 1);
        ssSetNumRWork(S, 0);
        ssSetNumIWork(S, 0);
        ssSetNumPWork(S, 0);
        ssSetNumModes(S, 0);
        ssSetNumNonsampledZCs(S, 0);
    
        /* Take care when specifying exception free code - see sfuntmpl_doc.c */
        ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE |
                         SS_OPTION_USE_TLC_WITH_ACCELERATOR | 
    		     SS_OPTION_WORKS_WITH_CODE_REUSE));
    }
    
    /* Function: mdlInitializeSampleTimes =========================================
     * Abstract:
     *    Specifiy  the sample time.
     */
    static void mdlInitializeSampleTimes(SimStruct *S)
    {
        ssSetSampleTime(S, 0, SAMPLE_TIME_0);
        ssSetOffsetTime(S, 0, 0.0);
    }
    
    #define MDL_SET_OUTPUT_PORT_DATA_TYPE
    static void mdlSetOutputPortDataType(SimStruct *S, int port, DTypeId dType)
    {
        ssSetOutputPortDataType(S, 0, dType);
    }
    
    #define MDL_SET_DEFAULT_PORT_DATA_TYPES
    static void mdlSetDefaultPortDataTypes(SimStruct *S)
    {
       ssSetOutputPortDataType(S, 0, SS_DOUBLE);
    }
    /* Function: mdlOutputs =======================================================
     *
    */
    
    
    
    
    
    
    
    
    
    
    
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <cstdlib>
    #include <iostream>
    #include <time.h>
    //#include <SDL.h>
    
    void sleep( clock_t milliSeconde)
    {
    clock_t stop;
    
    stop = milliSeconde + clock();
    while( stop > clock() );
    }
    
    
    
    
    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently, but
    // are changed infrequently
    #pragma once
    
    // TODO: reference additional headers your program requires here
    
    /*
    struct Export
    {
    	bool	active[40];
    	bool	play  [40];
    	int		data  [40];
    	int		type  [40];
    };*/
    struct GetPluginDataEx
    {
    	int			data[22];				//Simulator plugin values
    	int			speed;					//current speed in kmh
    	int			rpm;					//rpm
    	int			fuel;					//fuel of tank
    	int			tempfuel;				//tank temperature
    	int			currentgear;			//number of gear
    	int			currentlap;				//number of current lab
    	int			bestlaptime;			//best lap time
    	int			lastlaptime;			//last lap time
    	int			position;				//current possition
    	int			tempwater;				//water temperature
    	int			flags;					//flags
    	int			tiretemps[4][3];		//temp of each tire (inner middle outer)
    	int			altimeter;				//Flight gauge altimeter
    	int			airspeed;				//Flight gauge airspeed over ground
    	int			verticalvelocity;		//Flight Vertical speed meter
    	int			attidude;				//Flight attitude Indicator
    	int			heading;				//Flight heading Indikator
    	int			fuelflow;				//Flight fuelflow
    	int			fuelleft;				//Flight fuelleft
    	int			fuelright;				//Flight fuelright
    	int			tempexhaustgas;			//Flight temperature of exhaust gas
    	int			oiltemperature;			//Flight temperature of oil
    	int			oilpressure;			//Flight pressure of oil
    	int			turncoordinator;		//Flight turncoordinator
    	int			outsidetemperture;		//Flight outside air temperature
    	int			ampmeter;				//Flight ampmeter
    	int			buffer[6];				//not defined values left
    };
    
    
    struct GetInfo
    {
    	char		pluginname[51];
    	char		plugininfo[20][31];
    };
    
    
    int LoadFcn(void);
    void GetData(void);
    void EndConnection(void);
    #include windows.h
    
    GetPluginDataEx myYoda;
    GetInfo Info;
    // Set dll handle
    HINSTANCE hDLL;
    
    // Define the dll function GetExport
    typedef GetPluginDataEx (*myFunc1) (void);
    myFunc1 GetExport;
    
    typedef GetInfo (*myFunc3) (void);
    myFunc3 GetInfoExport;
    
    
    // Define the dll function EndYoda
    typedef bool (*myFunc2) (int info);
    myFunc2 EndYoda;
    
    int LoadFcn(void)
    {
     
    	// Load the buffer DLL in same Directory or insert here other location.
    	hDLL = LoadLibrary (NSR1Plugin.dll); 
    
    	if (hDLL!=NULL) {
                      //printf(hDLL diff de null);
    	// Define the dll function GetExport and get its address
    	GetExport = (myFunc1) GetProcAddress (hDLL, GetDataArrayEx);
    	GetInfoExport = (myFunc3) GetProcAddress (hDLL, GetPluginName);
    	EndYoda = (myFunc2) GetProcAddress (hDLL, EndYoda);
    	return 10;
    	}
    	else return -1;
    }
    
    void GetData(void)
    {
    	if (hDLL!=NULL) {
                      
                        myYoda = GetExport();
                        Info = GetInfoExport(); }
        else printf(hDLL=null);
    }
    
    void EndConnection(void)
    {
    	if (hDLL!=NULL) {
    		EndYoda(1);
    		FreeLibrary(hDLL);
    		hDLL=NULL;
    	}
    }
    
    
    
    
    using namespace std;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    static void mdlOutputs(SimStruct *S, int_T tid)
    {
        real_T        *x  = (real_T *)ssGetOutputPortRealSignal(S,0);
        real_T        *y  = (real_T *)ssGetOutputPortRealSignal(S,1);
        real_T        *z  = (real_T *)ssGetOutputPortRealSignal(S,2);
        
        
        
        
        
          do{
                        LoadFcn();
                        GetData(); 
                        printf(\nrpm %04i ,myYoda.rpm);
                        printf(gear %02i ,myYoda.data[1]);
                        *x++ = myYoda.data[2];
                        *y++ = myYoda.data[3];
                        *z++ = myYoda.data[4];
                        Sleep(1000);
    
    
          }while(LoadFcn() ==10);
          printf( jeu arreter.(hDLL=NULL)\n);
                  
    
        system(PAUSE);
        EndConnection;
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    
        GTR_Evo_Outputs_wrapper(x, y, z);
    }
    
    
    
    /* Function: mdlTerminate =====================================================
     * Abstract:
     *    In this function, you should perform any actions that are necessary
     *    at the termination of a simulation.  For example, if memory was
     *    allocated in mdlStart, this is the place to free it.
     */
    static void mdlTerminate(SimStruct *S)
    {
    }
    
    #ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */
    #include simulink.c      /* MEX-file interface mechanism */
    #else
    #include cg_sfun.h       /* Code generation registration function */
    #endif