cancel
Showing results for 
Search instead for 
Did you mean: 

structure problem

samiassaad
Associate II
Posted on March 21, 2011 at 09:29

structure problem

10 REPLIES 10
trevor23
Associate III
Posted on May 17, 2011 at 14:28

 > aParameter Parameters[]={{1,2,3,4},{1,2,3,4},.......etc ..}  

  Please include the code exactly (don't just put etc.) as this may be important to solving your problem.

samiassaad
Associate II
Posted on May 17, 2011 at 14:28

Thank you Trevor

here is the code 

/*----parameters ----------------------------*/

 aParameter Parameters[] = {

 /* type,  value, min, max ,def */

 {Liste, Asagi, Basit, Cift_buton,Asagi},           //Kumanda_turu

 {Tamsayi,2, 2, 32,8},                //Durak_sayisi

 {Liste, VVVF, Tek_hiz, Hidrolik,VVVF},            //Tahrik_tipi

 {Liste, _10ms, _10ms, _20ms,_10ms},             //Hiz

 {Tamsayi, 1, 1, 32,1},                //Ana_durak

 {Tamsayi, 10, 1, 120,10},               //Seyir_suresi

 {Tamsayi, 10, 1, 120,10},               //Kabin_lamba_suresi

 {Tamsayi, 5, 1, 120,5},                //Katta_kapi_acma_suresi

/*---------sami ekledi -----------*/

 

 {Liste, sayma_tek_tube, sayma_tek_tube,sayma_grey_kod,sayma_tek_tube},     //sayma_tipi

 {Liste, oto_door,no_door,yes_kapin_door,oto_door},      //kapi tipi

 {Liste, door_limitsiz,door_limitsiz,door_limitli,door_limitsiz},       //limitli _limitsiz kapi  

    {Liste, ksr_active,ksr_inactive,ksr_active,ksr_active},         //limitli _limitsiz kapi 

 {Tamsayi,2,1,20,2},                  //kapi asma suresi

 {Tamsayi,2,1,20,2},                  //fotosel suresi

 {Liste, p_kart, p_kart,seri_kart,p_kart},            //p_kart mı _ seri_kart 

 {Tamsayi,2,1,20,2},                  //kilit_bekleme_suresi

 {Tamsayi,2,1,20,2},                  //lirpomp deneme

                       

}; // here is teh defenions 

#define Tamsayi    0

#define Ondalik    1

#define yuzdelik   2

#define Liste    3

#define password   4

/*--------------------parameters --------------------------------------*/

#define Kumanda_turu     0

  #define Basit   0

  #define Karisik   1

  #define Asagi   2

  #define Yukari   3

  #define Cift_buton  4

#define Durak_sayisi     1

#define Tahrik_tipi      2

  #define Tek_hiz   0

  #define Cift_hiz  1

  #define VVVF   2

  #define Hidrolik  3

#define Hiz        3

  #define  _10ms  0

  #define  _16ms  1

  #define  _20ms  2

#define Ana_durak      4

#define Seyir_suresi     5

#define Kabin_lamba_suresi    6

#define Katta_kapi_acma_suresi   7

/*------- sami ekledi ---------------*/

#define sayma_tipi      8

  #define sayma_tek_tube   0

  #define sayma_grey_kod    1

/*----- kapi parameters --------------*/

#define kapi_tipi      9 

 #define no_door     0

 #define oto_door    1  // otomatik

 #define no_kapin_door   2  // y otomatik _  kapin kapi yok

 #define yes_kapin_door   3  // y otomatik _  kapin kapi var

/*----------------------------------------------------*/

#define kapi_limit_tipi      10

  #define door_limitsiz   0

  #define door_limitli   1

/*--------------ksr--------------------------------------*/

#define ksr_tipi      11

  #define ksr_inactive   0

  #define ksr_active     1

/*-------- kapi asma suresi ----------------------*/

#define kapi_asma_suresi     12

/*------------forosel suresi ------------------------------------*/

#define fotosel_suresi      13 

/*----------------parallel kart   seri kart     ----------------*/

#define  p_s_kart      14 

   #define  p_kart   0

  #define  seri_kart  1

  #define  s_kart   1  // ayni seri kart

/*----------------kilit bekleme  suresi --------------------*/

 #define  kilit_bekleme_suresi   15 

 /*-----lirpomo deneme unti fail ---------------*/

 #define  lirpomp_deneme     16

samiassaad
Associate II
Posted on May 17, 2011 at 14:29

Yes I am sure

the example :

Parameters[14].value =0; not passed

Parameters[14].value=1 ; it is ok

only with zero !

thank you again

trevor23
Associate III
Posted on May 17, 2011 at 14:29

The ASCII code for '0' is 48 decimal. Are you sure you are not using '0' instead of 0?

John F.
Senior
Posted on May 17, 2011 at 14:29

Although your code is not pretty, the following does work in an alternative C compiler.

I completed the struct with parts missing in your post..

struct sParameter {

    unsigned int type;

    unsigned int value ;

    unsigned int min;

    unsigned int max;

    unsigned int def;

}; <- *** HERE ***

// here are the definitions

#define Tamsayi 0

#define Ondalik 1

#define yuzdelik 2

#define Liste 3

#define password 4

/*-parameters -*/

#define Kumanda_turu 0

#define Basit 0

#define Karisik 1

#define Asagi 2

#define Yukari 3

#define Cift_buton 4

#define Durak_sayisi 1

#define Tahrik_tipi 2

#define Tek_hiz 0

#define Cift_hiz 1

#define VVVF 2

#define Hidrolik 3

#define Hiz 3

#define _10ms 0

#define _16ms 1

#define _20ms 2

#define Ana_durak 4

#define Seyir_suresi 5

#define Kabin_lamba_suresi 6

#define Katta_kapi_acma_suresi 7

/*- sami ekledi -*/

#define sayma_tipi 8

#define sayma_tek_tube 0

#define sayma_grey_kod 1

/*- kapi parameters -*/

#define kapi_tipi 9

#define no_door 0

#define oto_door 1 // otomatik

#define no_kapin_door 2 // y otomatik _ kapin kapi yok

#define yes_kapin_door 3 // y otomatik _ kapin kapi var

/*-*/

#define kapi_limit_tipi 10

#define door_limitsiz 0

#define door_limitli 1

/*-ksr-*/

#define ksr_tipi 11

#define ksr_inactive 0

#define ksr_active 1

/*- kapi asma suresi -*/

#define kapi_asma_suresi 12

/*-forosel suresi -*/

#define fotosel_suresi 13

/*-parallel kart seri kart -*/

#define p_s_kart 14

#define p_kart 0

#define seri_kart 1

#define s_kart 1 // ayni seri kart

/*-kilit bekleme suresi -*/

#define kilit_bekleme_suresi 15

/*-lirpomo deneme unti fail -*/

#define lirpomp_deneme 16

typedef struct sParameter aParameter;

struct sParameter {

    unsigned int type;

    unsigned int value ;

    unsigned int min;

    unsigned int max;

    unsigned int def;

};

/*-parameters -*/

aParameter Parameters[] =

{

    /* type, value, min, max ,def */

    {Liste, Asagi, Basit, Cift_buton,Asagi}, //Kumanda_turu

    {Tamsayi,2, 2, 32,8}, //Durak_sayisi

    {Liste, VVVF, Tek_hiz, Hidrolik,VVVF}, //Tahrik_tipi

    {Liste, _10ms, _10ms, _20ms,_10ms}, //Hiz

    {Tamsayi, 1, 1, 32,1}, //Ana_durak

    {Tamsayi, 10, 1, 120,10}, //Seyir_suresi

    {Tamsayi, 10, 1, 120,10}, //Kabin_lamba_suresi

    {Tamsayi, 5, 1, 120,5}, //Katta_kapi_acma_suresi

    /*-sami ekledi -*/

    {Liste, sayma_tek_tube, sayma_tek_tube,sayma_grey_kod,sayma_tek_tube}, //sayma_tipi

    {Liste, oto_door,no_door,yes_kapin_door,oto_door}, //kapi tipi

    {Liste, door_limitsiz,door_limitsiz,door_limitli,door_limitsiz}, //limitli _limitsiz kapi

    {Liste, ksr_active,ksr_inactive,ksr_active,ksr_active}, //limitli _limitsiz kapi

    {Tamsayi,2,1,20,2}, //kapi asma suresi

    {Tamsayi,2,1,20,2}, //fotosel suresi

    {Liste, p_kart, p_kart,seri_kart,p_kart}, //p_kart m? _ seri_kart

    {Tamsayi,2,1,20,2}, //kilit_bekleme_suresi

    {Tamsayi,2,1,20,2}, //lirpomp deneme

};

int main(int argc, char* argv[])

{

    Parameters[14].value = 0;

    Parameters[14].value = 1;

    Parameters[14].value = 2;

}

samiassaad
Associate II
Posted on May 17, 2011 at 14:29

John in the real code I have }; <- *** HERE ***

when I posted it I forget to copy it ;

the problem still found :) any other suggestions ?

John F.
Senior
Posted on May 17, 2011 at 14:29

Simplify your code. Test your understanding of the debugger with simple variables then try using a structure. If assigning zero shows 48, what does assigning 1 show etc.

Good luck.

trevor23
Associate III
Posted on May 17, 2011 at 14:29

I suggest you use variables that have bits set in every nibble e.g. 0x11111111, 0x22222222, ....etc. so you can tell if a variable is ''overflowing'' into another variable in your struct.

Then use the memory watch window set to the address of your structure. This will allow you to see what is happening at the lowest level.

Posted on May 17, 2011 at 14:29

What you want is :

typedef struct sParameter aParameter;

typedef struct sParameter {

    unsigned int type;

    unsigned int value ;

    unsigned int min;

    unsigned int max;

    unsigned int def;

} aParameter;

/*-parameters -*/

aParameter Parameters[] =

{

    /* type, value, min, max ,def */

    {Liste, Asagi, Basit, Cift_buton,Asagi}, //Kumanda_turu

    {Tamsayi,2, 2, 32,8}, //Durak_sayisi

..
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..