bob

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 typedef struct v_t_decode_ {
0021         char    type[2];
0022         short   numero;
0023         short   polar;
0024         char    declench1[L_NOM_DECLENCHE];
0025         char    declench2[L_NOM_DECLENCHE];
0026         Longint duree;
0027         char    comment[L_COMMENTAIRE];
0028   } v_t_decode;
0029 
0030 
0031 char gros_buffer[12345]={"AZE"};
0032 
0033 int
0034 main ()
0035 {
0036   char t_objet[16], n_prod[13], n_objet[13], n_param[13];
0037   register int i;
0038   int the_size, n_choc, nb_obj,n_val = 0;
0039   ts_objet *p_ts_obj, *p_tmp;
0040   int cr;
0041   int format, nb_val, data_int[32];
0042   float *pt_flt, data_float[4];
0043   char *pt_char, *pt_comment;
0044   char **pt_cmt;
0045   void *pt_void;
0046   char *pt__;
0047   ts_diagnostic *pt_diagnostic;
0048   ts_donnee     *pt_donnee;
0049   char        *ldiag[100], *lsig[200];
0050   tdecl *ptdecl;
0051   v_t_decode *pp;
0052   char VAL[123456];
0053   int L;
0054 
0055   /*  puts (" Test Tstele");
0056 
0057   cr = TStele ("APOLO",1,1,&VAL,&L);
0058   if (cr == 0)
0059       printf ("bob tstele OK on a %d long \n",L);
0060       
0061     else
0062       printf ("bob tstele PAS OK %d \n",cr);
0063      exit(0);
0064 */
0065 
0066   puts (" Test RqParm");
0067 
0068   printf ("No Choc ? ");
0069   scanf ("%d", &n_choc);
0070   printf ("Nom prod ? ");
0071   scanf ("%s", n_prod);
0072   printf ("Nom objet ? ");
0073   scanf ("%s", n_objet);
0074   printf ("Nom param ? ");
0075   scanf ("%s", n_param);
0076 
0077   pt_char = NULL;
0078 
0079   n_val = 256;
0080   cr = TSRqParm (n_choc, n_prod, n_objet, n_param, n_val, &pt_char, &nb_val, &format);
0081   if (cr == 0)
0082     {
0083       printf ("bob tsrqparm OK on a %d valeurs \n",nb_val);
0084       switch(format){
0085     case OCTET:
0086     {
0087           ts_v_int1 * pt_void;
0088           pt_void = (ts_v_int1 *) pt_char;
0089       for (i = 0; i < nb_val; i++)
0090         {
0091           printf ("valeur %i : %d\n", i, pt_void->integer1);
0092           pt_void += 1;
0093         }
0094          free(pt_char);
0095          break;
0096     }
0097     case INT16:
0098     {
0099           short * pt_void;
0100           pt_void = (short *) gros_buffer;
0101           pt_void = (short *) pt_char;
0102       for (i = 0; i < nb_val; i++)
0103         {
0104           printf ("valeur %i : %d\n", i, *(pt_void));
0105           pt_void += 1;
0106         }
0107          free(pt_char);
0108          break;
0109     }
0110     case INT32:
0111     {
0112           int * pt_void;
0113           pt_void = (int *) pt_char;
0114       for (i = 0; i < nb_val; i++)
0115         {
0116           printf ("valeur %i : %d\n", i, *(pt_void));
0117           pt_void += 1;
0118         }
0119          free(pt_char);
0120          break;
0121     }
0122     case REEL16:
0123     {
0124           ts_v_float4 * pt_void;
0125           pt_void = (ts_v_float4 *) pt_char;
0126       for (i = 0; i < nb_val; i++)
0127         {
0128           printf ("valeur %i : %6.3f\n", i, pt_void->float4);
0129           pt_void += 1;
0130         }
0131          free(pt_char);
0132          break;
0133     }
0134     case STRING12:
0135     {
0136           char * pt_void;
0137           pt_void = (char *) pt_char;
0138       for (i = 0; i < nb_val; i++)
0139         {
0140           printf ("valeur %d : %s\n", i, pt_void);
0141           pt_void += 1;
0142         }
0143          free(pt_char);
0144          break;
0145     }
0146     case T_DECLENC:
0147     {
0148           ts_v_declenc * pt_void;
0149           pt_void = (ts_v_declenc *) pt_char;
0150       for (i = 0; i < nb_val; i++)
0151         {
0152           printf ("nom %s valeur : %f  \n", pt_void->nom,pt_void->temps);
0153           pt_void += 1;
0154         }
0155          free(pt_char);
0156          break;
0157     }
0158     case 16:
0159     {
0160           tdecl * ptdecl;
0161           ptdecl = (tdecl *) pt_char;
0162       for (i = 0; i < nb_val; i++)
0163         {
0164               int j;
0165           printf ("nom[%3d] : ",i);
0166                    for(j=0;j<8;j++)
0167                 printf("%c",ptdecl->nom[j]);
0168           printf ("  valeur : %d  \n",ptdecl->temps);
0169           ptdecl += 1;
0170         }
0171          free(pt_char);
0172          break;
0173     }
0174     case TWIN_REEL32:
0175     {
0176           ts_v_float4_float4 * pt_void;
0177           pt_void = (ts_v_float4_float4 *) pt_char;
0178       for (i = 0; i < nb_val; i++)
0179         {
0180           printf ("valeur %i : %6.3f %6.3f \n", i,
0181                pt_void->float4_1,pt_void->float4_2);
0182           pt_void += 1;
0183         }
0184          free(pt_char);
0185          break;
0186     }
0187 
0188     case F_ACHRONO:
0189     {
0190           ts_v_achrono * pt_void;
0191           pt_void = (ts_v_achrono *) pt_char;
0192       for (i = 0; i < nb_val; i++)
0193         {
0194           printf ("valeur %i : %s %s %6.3f %6.3f %s\n", i,
0195                pt_void->code,pt_void->declenche,
0196                pt_void->decalage,pt_void->duree,pt_void->comment);
0197           pt_void += 1;
0198         }
0199          free(pt_char);
0200          break;
0201     }
0202     
0203     case F_DESCRIPTEUR:
0204     {
0205           ts_v_descripteur * pt_void;
0206           pt_void = (ts_v_descripteur *) pt_char;
0207       for (i = 0; i < nb_val; i++)
0208         {
0209           printf ("valeur %i : %d  %s  %s  %d  %s  %s  %d\n", i,
0210                pt_void->num_choc, pt_void->nom_diag, pt_void->donnee_brute,
0211            pt_void->indiceb, pt_void->nom_trait, pt_void->donnee_traitee,
0212            pt_void->indicet);
0213           pt_void += 1;
0214         }
0215          free(pt_char);
0216          break;
0217 
0218     case 24:
0219     {
0220           v_t_decode * pt_void;
0221       for (i = 0; i < nb_val; i++)
0222         {
0223           pt_void = (v_t_decode *) pt_char;
0224           printf ("valeur %i : %2c  %d  %d  %s  %s  %d  %s\n", i,
0225                pt_void->type, pt_void->numero, pt_void->polar,
0226            pt_void->declench1, pt_void->declench2, pt_void->duree,
0227            pt_void->comment);
0228 
0229         pt_char  = pt_char + 2+sizeof(short) *2+ 2*L_NOM_DECLENCHE+
0230                    sizeof(Longint)+L_COMMENTAIRE;
0231 
0232         }
0233          free(pt_char);
0234          break;
0235     }
0236     }
0237       default:  puts(" Not yet implemented ");
0238     }
0239    } 
0240   else
0241     {
0242       printf ("bob : Erreur tsrqparam %d\n",cr);
0243     }
0244 
0245 /*
0246   puts (" Test TSdescObjet");
0247 
0248   printf ("No Choc ? ");
0249   scanf ("%d", &n_choc);
0250   printf ("Nom prod ? ");
0251   scanf ("%s", n_prod);
0252   printf ("Nom objet ? ");
0253   scanf ("%s", n_objet);
0254   printf ("Nom type objet ? ");
0255   scanf ("%s", t_objet);
0256  
0257 
0258   cr = TSdescObjet (n_choc, n_prod, n_objet,
0259                                          &pt_char, &pt_comment);
0260   if (cr == 0)
0261     {
0262       puts ("bob tsdescobj OK");
0263       printf("comment %s \n",pt_comment);
0264 
0265       cr = decObjet(t_objet, pt_char);
0266       switch (fi(t_objet))
0267     {
0268     case DIAGNOSTIC:
0269           pt_diagnostic =  (ts_diagnostic *)pt_char;
0270       break;
0271 
0272     case DONNEE:
0273           pt_donnee =  (ts_donnee *)pt_char;
0274       break;
0275     case ICM100:
0276       break; 
0277     case ICM101:
0278       break;
0279     case CAMAC2162:
0280       break;
0281     case CAMAC6103:
0282       break;
0283     case CAMAC6810:
0284       break;
0285     case CAMAC8818:
0286       break;
0287     case CHRONO:
0288       break;
0289     case DATE1:
0290       break;
0291     case DATE2:
0292       break;
0293     case SEQ_NUM:
0294       break;
0295     case GENE_FONCTION:
0296       break;
0297     case DECOD_CHRONO:
0298       break;
0299     case ENCOD_CHRONO:
0300       break;
0301     case STRAT_DIAG:
0302       break;
0303     case PILOTAGE:
0304       break;
0305     case CHRONOVME:
0306 
0307       break;
0308     case TRAITEMENT:
0309       break;
0310     case ASSERVISSEMENT:
0311       break;
0312     case CONSIGNE:
0313       break;
0314     case DONGEN:
0315       break;
0316     case STRAT_PIL:
0317       break;
0318     case OBJET_CHRONO:
0319       break;
0320     case TORE_SUPRA:
0321       break;
0322     case COMMON:
0323       break;
0324 
0325     }
0326 
0327      free(pt_comment);
0328      free(pt_char);
0329      }
0330      else
0331      {
0332       printf ("bob tsdescobj Pb %d\n",cr);
0333 
0334       }
0335 
0336   printf ("TSDescDon_choc \nNo Choc ? ");
0337   scanf ("%d", &n_choc);
0338   printf ("Nom donnee ? ");
0339   scanf ("%s", n_objet);
0340 
0341   cr = TSDescDon_choc (n_objet, n_choc, &pt_donnee);
0342   if (cr == 0)
0343     {
0344       puts ("bob tsdescdon_choc OK");
0345            printf(" id_objet :\t%d \n",        pt_donnee->id_objet);
0346            printf(" numero :\t%d \n",            pt_donnee->numero);
0347            printf(" id_donnee :\t%d \n",    pt_donnee->id_donnee);
0348            printf(" condif :\t%d \n",        pt_donnee->confidentialite);
0349            printf(" type_don :\t%d \n",        pt_donnee->type_donnee);
0350            printf(" nb_compo :\t%d \n",        pt_donnee->nb_composantes);
0351            printf(" nb_coord :\t%d \n",        pt_donnee->nb_coordonnees);
0352            printf(" formatX :\t%s \n",        pt_donnee->formatx);
0353            printf(" formatY :\t%s \n",        pt_donnee->formaty);
0354            printf(" formatI :\t%s \n",        pt_donnee->formati);
0355            printf(" formatJ :\t%s \n",        pt_donnee->formatj);
0356            printf(" uniteX :\t%s \n",        pt_donnee->unitex);
0357            printf(" uniteY :\t%s \n",        pt_donnee->unitey);
0358            printf(" uniteI :\t%s \n",        pt_donnee->unitei);
0359            printf(" uniteJ :\t%s \n",        pt_donnee->unitej);
0360            printf(" structX :\t%d \n",        pt_donnee->structx);
0361            printf(" structY :\t%d \n",        pt_donnee->structy);
0362            printf(" strucI :\t%d \n",        pt_donnee->structi);
0363            printf(" strucJ :\t%d \n",        pt_donnee->structj);
0364            printf(" longi :\t%d \n",        pt_donnee->longueuri);
0365            printf(" longj :\t%d \n",        pt_donnee->longueurj);
0366            printf(" maxtrame :\t%d \n",        pt_donnee->maxtrame);
0367            printf(" remdif :\t%d \n",        pt_donnee->remdif);
0368 
0369    }
0370      else
0371       printf ("bob tsdesdon_choc Pb %d\n",cr);
0372 
0373 */
0374   return (0);
0375 }
0376 
0377 decObjet(char *type_objet, char *pt_val )
0378 {
0379 
0380 void * result;
0381 switch (  fi(type_objet)) {
0382 
0383    case DONNEE: {
0384            ts_donnee *pt = (ts_donnee *) pt_val;
0385 
0386            printf(" id_objet :\t%d \n",        pt->id_objet);
0387            printf(" id_donnee :\t%d \n",    pt->id_donnee);
0388            printf(" condif :\t%d \n",        pt->confidentialite);
0389            printf(" type_don :\t%d \n",        pt->type_donnee);
0390            printf(" nb_compo :\t%d \n",        pt->nb_composantes);
0391            printf(" nb_coord :\t%d \n",        pt->nb_coordonnees);
0392            printf(" structX :\t%d \n",        pt->structx);
0393            printf(" structY :\t%d \n",        pt->structy);
0394            printf(" strucI :\t%d \n",        pt->structi);
0395            printf(" strucJ :\t%d \n",        pt->structj);
0396            printf(" lgi :\t%d \n",        pt->longueuri);
0397            printf(" lgj :\t%d \n",        pt->longueurj);
0398            printf(" maxtrame :\t%d \n",        pt->maxtrame);
0399            printf(" remdif :\t%d \n",        pt->remdif);
0400          }
0401           break;
0402                       
0403 
0404  } /* end switch */
0405 
0406 
0407 return(0);
0408 
0409 
0410 }
0411

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