boby

PURPOSE ^

C/C++ source

SYNOPSIS ^

C/C++ source

DESCRIPTION ^

C/C++ source

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 /* bob is a dirty test program */
0002 
0003 #include <stdio.h>
0004 #include <stdlib.h>
0005 #include<string.h>
0006 #include<ctype.h>
0007 #include<malloc.h>
0008 
0009 #include "tsarcad.h"
0010 #include "def.h"
0011 #include "tdef.h"
0012 #include "erreur.h"
0013 char tslib_reel='f';
0014 
0015 typedef struct t_ {
0016     char nom[8];
0017     int temps;
0018 }tdecl;
0019 
0020 char gros_buffer[12345]={"AZE"};
0021 
0022 int
0023 main ()
0024 {
0025   char t_objet[16], n_prod[13], n_objet[13], n_param[13];
0026   register int i;
0027   int the_size, n_choc, nb_obj,n_val = 0;
0028   ts_objet *p_ts_obj, *p_tmp;
0029   int cr;
0030   int format, nb_val, data_int[32];
0031   float *pt_flt, data_float[4];
0032   char *pt_char, *pt_comment;
0033   char **pt_cmt;
0034   void *pt_void;
0035   char *pt__;
0036   ts_diagnostic *pt_diagnostic;
0037   ts_donnee     *pt_donnee;
0038   char        *ldiag[100], *lsig[200];
0039   tdecl *ptdecl;
0040 
0041 /*  puts (" Test listdiag new ");
0042   printf ("No choc ? ");
0043   scanf ("%d", &n_choc);
0044 
0045   cr = TSLDiag(n_choc, &nb_obj, ldiag); 
0046   if (cr == 0)
0047     {
0048      printf("Il a %ld diag \n", nb_obj);
0049       for (i = 0; i < nb_obj; i++)
0050       printf ("%d  %s  \n",i, ldiag[i]);
0051     } else
0052        printf("TSLDIAG cr = %d\n",cr);
0053 
0054   puts (" Test listsig new ");
0055   printf ("No choc ? ");
0056   scanf ("%d", &n_choc);
0057   printf ("Nom diag ? ");
0058   scanf ("%s", n_prod);
0059 
0060   cr = TSLSig(n_choc, n_prod, &nb_obj, lsig); 
0061   if (cr == 0)
0062     {
0063      printf("Il a %ld signaux \n", nb_obj);
0064       for (i = 0; i < nb_obj; i++)
0065       printf ("%d  %s  \n",i, lsig[i]);
0066     } else
0067        printf("TSLSIG cr = %d\n",cr);
0068 
0069 
0070   puts (" Test listeobjet");
0071   printf ("No choc ? ");
0072   scanf ("%d", &n_choc);
0073 
0074   printf ("Nom prod ? ");
0075   scanf ("%s", n_prod);
0076 
0077   printf ("Nom type objet ? ");
0078   scanf ("%s", t_objet);
0079 
0080   cr = TSlistObjet (n_choc, n_prod, t_objet, &p_ts_obj, &pt_cmt, &nb_obj);
0081   if (cr == 0)
0082     {
0083       printf ("On a %d objets\n", nb_obj);
0084       sleep (2);
0085       p_tmp = p_ts_obj;
0086       for (i = 0; i < nb_obj; i++)
0087     {
0088       printf ("%d  %s :  %s \n",i, p_tmp->nom_objet, pt_cmt[i]);
0089           free (pt_cmt[i]);
0090       p_tmp++;
0091     }
0092       free (p_ts_obj);
0093       free(pt_cmt);
0094     }
0095   else
0096     {
0097       printf ("bob : Erreur tslisterObjet %d\n",cr);
0098     }
0099 
0100 
0101   puts ("\n Test Writeparm");
0102   printf ("Nom prod ? ");
0103   scanf ("%s", n_prod);
0104   printf ("Nom objet ? ");
0105   scanf ("%s", n_objet);
0106   printf ("Nom param ? ");
0107   scanf ("%s", n_param);
0108 
0109   data_float[0] = 99.1;
0110   data_float[1] = 999.2;
0111   printf ("sizeof data %d\n", sizeof (data_float));
0112   the_size = sizeof (float) * 2;
0113 
0114   cr = TSwriteParam (n_prod, n_objet , n_param,
0115                  2, the_size, (char *) data_float);
0116   if (cr == 0)
0117     puts ("bob tswriteparam OK");
0118   else
0119     {
0120       printf ("bob : Erreur tswriteparam %d \n",cr);
0121     }
0122 
0123   {
0124    typedef struct le_common {
0125         char    nom_diag[L_NOM_PRODUCTEUR];
0126         char    nom_objet[L_NOM_OBJET];
0127         char    nom_param[L_NOM_PARAM];
0128         char    colonne[L_NOM_COLONNE];
0129         short   indice1;
0130         short   indice2;
0131         short   format;
0132   } v_c;
0133   v_c *pp;
0134 
0135   pp = (v_c *)malloc(sizeof(v_c));
0136   strcpy(pp->nom_diag,"DYB"); 
0137   strcpy(pp->nom_objet,"OBJYB"); 
0138   strcpy(pp->nom_param,"PARAMYB"); 
0139   strcpy(pp->colonne,"CYB"); 
0140   pp->indice1 = 1001;
0141   pp->indice2 = 2002;
0142 
0143   cr = TSwriteParam ("DMAG", "COMMON", "COMMON", "DESCOM",
0144                  1, sizeof(v_c), (char *) pp);
0145   if (cr == 0)
0146     puts ("bob tswriteparam common OK");
0147   else
0148     {
0149       printf ("bob : Erreur tswriteparam %d \n",cr);
0150     }
0151   }
0152   
0153  */ puts (" Test RqParm");
0154 
0155   printf ("No Choc ? ");
0156   scanf ("%d", &n_choc);
0157   printf ("Nom prod ? ");
0158   scanf ("%s", n_prod);
0159   printf ("Nom objet ? ");
0160   scanf ("%s", n_objet);
0161   printf ("Nom param ? ");
0162   scanf ("%s", n_param);
0163 
0164   pt_char = NULL;
0165 
0166   n_val = 256;
0167   cr = TSRqParm (n_choc, n_prod, n_objet, n_param, n_val, &pt_char, &nb_val, &format);
0168   if (cr == 0)
0169     {
0170       printf ("bob tsrqparm OK on a %d valeurs \n",nb_val);
0171       switch(format){
0172     case OCTET:
0173     {
0174           char * pt_void;
0175           pt_void = (char *) pt_char;
0176       for (i = 0; i < nb_val; i++)
0177         {
0178           printf ("valeur %i : %d\n", i, *pt_void);
0179           pt_void += 1;
0180         }
0181          free(pt_char);
0182          break;
0183     }
0184     case INT16:
0185     {
0186           short * pt_void;
0187           pt_void = (short *) pt_char;
0188       for (i = 0; i < nb_val; i++)
0189         {
0190           printf ("valeur %i : %d\n", i, *(pt_void));
0191           pt_void += 1;
0192         }
0193          free(pt_char);
0194          break;
0195     }
0196     case INT32:
0197     {
0198           int * pt_void;
0199           pt_void = (int *) pt_char;
0200       for (i = 0; i < nb_val; i++)
0201         {
0202           printf ("valeur %i : %d\n", i, *(pt_void));
0203           pt_void += 1;
0204         }
0205          free(pt_char);
0206          break;
0207     }
0208     case REEL16:
0209     {
0210           float * pt_void;
0211           pt_void = (float *) pt_char;
0212       for (i = 0; i < nb_val; i++)
0213         {
0214           printf ("valeur %i : %6.3f\n", i, *pt_void);
0215           pt_void += 1;
0216         }
0217          free(pt_char);
0218          break;
0219     }
0220     case STRING12:
0221     {
0222           char * pt_void;
0223           pt_void = (char *) pt_char;
0224       for (i = 0; i < nb_val; i++)
0225         {
0226           printf ("valeur %d : %s\n", i, pt_void);
0227           pt_void += 1;
0228         }
0229          free(pt_char);
0230          break;
0231     }
0232     case T_DECLENC:
0233     {
0234           ts_v_declenc * pt_void;
0235           pt_void = (ts_v_declenc *) pt_char;
0236       for (i = 0; i < nb_val; i++)
0237         {
0238           printf ("nom %s valeur : %f  \n", pt_void->nom,pt_void->temps);
0239           pt_void += 1;
0240         }
0241          free(pt_char);
0242          break;
0243     }
0244     case 16: /*    Aie aie */
0245     {
0246           tdecl * ptdecl;
0247           ptdecl = (tdecl *) pt_char;
0248       for (i = 0; i < nb_val; i++)
0249         {
0250               int j;
0251           printf ("nom[%3d] : ",i);
0252                    for(j=0;j<8;j++)
0253                 printf("%c",ptdecl->nom[j]);
0254           printf ("  valeur : %d  \n",ptdecl->temps);
0255           ptdecl += 1;
0256         }
0257          free(pt_char);
0258          break;
0259     }
0260     case TWIN_REEL32:
0261     {
0262           
0263           float *pt_void  = (float *) malloc(nb_val *2*sizeof(float));
0264           memcpy(pt_void, pt_char,nb_val *2*sizeof(float));
0265       for (i = 0; i <  nb_val; i++)
0266         {
0267           printf ("valeur %i : %6.3f %6.3f \n", i,
0268                          pt_void[i*2],pt_void[i*2+1]);
0269         }
0270          free(pt_char);
0271          break;
0272     }
0273         case 30 :
0274 
0275           {
0276           char * pt_void;
0277           pt_void = (char *) pt_char;
0278       for (i = 0; i < nb_val; i++)
0279         {
0280           printf ("valeur %d : %s\n", i, pt_void);
0281           pt_void += 13;
0282         }
0283          free(pt_char);
0284           }
0285                 break;
0286       default:  puts(" Not yet implemented ");
0287     }
0288    } 
0289   else
0290     {
0291       printf ("bob : Erreur tsrqparam %d\n",cr);
0292     }
0293 
0294 
0295 /*
0296   puts (" Test TSdescObjet");
0297 
0298   printf ("No Choc ? ");
0299   scanf ("%d", &n_choc);
0300   printf ("Nom prod ? ");
0301   scanf ("%s", n_prod);
0302   printf ("Nom objet ? ");
0303   scanf ("%s", n_objet);
0304   printf ("Nom type objet ? ");
0305   scanf ("%s", t_objet);
0306  
0307 
0308   cr = TSdescObjet (n_choc, n_prod, n_objet,
0309                                          &pt_char, &pt_comment);
0310   if (cr == 0)
0311     {
0312       puts ("bob tsdescobj OK");
0313       printf("comment %s \n",pt_comment);
0314 
0315       cr = decObjet(t_objet, pt_char);
0316       switch (fi(t_objet))
0317     {
0318     case DIAGNOSTIC:
0319           pt_diagnostic =  (ts_diagnostic *)pt_char;
0320       break;
0321 
0322     case DONNEE:
0323           pt_donnee =  (ts_donnee *)pt_char;
0324       break;
0325     case ICM100:
0326       break; 
0327     case ICM101:
0328       break;
0329     case CAMAC2162:
0330       break;
0331     case CAMAC6103:
0332       break;
0333     case CAMAC6810:
0334       break;
0335     case CAMAC8818:
0336       break;
0337     case CHRONO:
0338       break;
0339     case DATE1:
0340       break;
0341     case DATE2:
0342       break;
0343     case SEQ_NUM:
0344       break;
0345     case GENE_FONCTION:
0346       break;
0347     case DECOD_CHRONO:
0348       break;
0349     case ENCOD_CHRONO:
0350       break;
0351     case STRAT_DIAG:
0352       break;
0353     case PILOTAGE:
0354       break;
0355     case CHRONOVME:
0356 
0357       break;
0358     case TRAITEMENT:
0359       break;
0360     case ASSERVISSEMENT:
0361       break;
0362     case CONSIGNE:
0363       break;
0364     case DONGEN:
0365       break;
0366     case STRAT_PIL:
0367       break;
0368     case OBJET_CHRONO:
0369       break;
0370     case TORE_SUPRA:
0371       break;
0372     case COMMON:
0373       break;
0374 
0375     }
0376 
0377      free(pt_comment);
0378      free(pt_char);
0379      }
0380      else
0381      {
0382       printf ("bob tsdescobj Pb %d\n",cr);
0383 
0384       }
0385 
0386   printf ("TSDescDon_choc \nNo Choc ? ");
0387   scanf ("%d", &n_choc);
0388   printf ("Nom donnee ? ");
0389   scanf ("%s", n_objet);
0390 
0391   cr = TSDescDon_choc (n_objet, n_choc, &pt_donnee);
0392   if (cr == 0)
0393     {
0394       puts ("bob tsdescdon_choc OK");
0395            printf(" id_objet :\t%d \n",        pt_donnee->id_objet);
0396            printf(" numero :\t%d \n",            pt_donnee->numero);
0397            printf(" id_donnee :\t%d \n",    pt_donnee->id_donnee);
0398            printf(" condif :\t%d \n",        pt_donnee->confidentialite);
0399            printf(" type_don :\t%d \n",        pt_donnee->type_donnee);
0400            printf(" nb_compo :\t%d \n",        pt_donnee->nb_composantes);
0401            printf(" nb_coord :\t%d \n",        pt_donnee->nb_coordonnees);
0402            printf(" formatX :\t%s \n",        pt_donnee->formatx);
0403            printf(" formatY :\t%s \n",        pt_donnee->formaty);
0404            printf(" formatI :\t%s \n",        pt_donnee->formati);
0405            printf(" formatJ :\t%s \n",        pt_donnee->formatj);
0406            printf(" uniteX :\t%s \n",        pt_donnee->unitex);
0407            printf(" uniteY :\t%s \n",        pt_donnee->unitey);
0408            printf(" uniteI :\t%s \n",        pt_donnee->unitei);
0409            printf(" uniteJ :\t%s \n",        pt_donnee->unitej);
0410            printf(" structX :\t%d \n",        pt_donnee->structx);
0411            printf(" structY :\t%d \n",        pt_donnee->structy);
0412            printf(" strucI :\t%d \n",        pt_donnee->structi);
0413            printf(" strucJ :\t%d \n",        pt_donnee->structj);
0414            printf(" longi :\t%d \n",        pt_donnee->longueuri);
0415            printf(" longj :\t%d \n",        pt_donnee->longueurj);
0416            printf(" maxtrame :\t%d \n",        pt_donnee->maxtrame);
0417            printf(" remdif :\t%d \n",        pt_donnee->remdif);
0418 
0419    }
0420      else
0421       printf ("bob tsdesdon_choc Pb %d\n",cr);
0422 
0423 */
0424   return (0);
0425 }
0426 
0427 decObjet(char *type_objet, char *pt_val )
0428 {
0429 
0430 void * result;
0431 switch (  fi(type_objet)) {
0432 
0433    case DONNEE: {
0434            ts_donnee *pt = (ts_donnee *) pt_val;
0435 
0436            printf(" id_objet :\t%d \n",        pt->id_objet);
0437            printf(" id_donnee :\t%d \n",    pt->id_donnee);
0438            printf(" condif :\t%d \n",        pt->confidentialite);
0439            printf(" type_don :\t%d \n",        pt->type_donnee);
0440            printf(" nb_compo :\t%d \n",        pt->nb_composantes);
0441            printf(" nb_coord :\t%d \n",        pt->nb_coordonnees);
0442            printf(" structX :\t%d \n",        pt->structx);
0443            printf(" structY :\t%d \n",        pt->structy);
0444            printf(" strucI :\t%d \n",        pt->structi);
0445            printf(" strucJ :\t%d \n",        pt->structj);
0446            printf(" lgi :\t%d \n",        pt->longueuri);
0447            printf(" lgj :\t%d \n",        pt->longueurj);
0448            printf(" maxtrame :\t%d \n",        pt->maxtrame);
0449            printf(" remdif :\t%d \n",        pt->remdif);
0450          }
0451           break;
0452                       
0453 
0454  } /* end switch */
0455 
0456 
0457 return(0);
0458 
0459 
0460 }
0461

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.