0001
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
0042 "No choc ? "
0043 "%d"
0044
0045
0046
0047
0048 "Il a %ld diag \n"
0049
0050 "%d %s \n"
0051
0052 "TSLDIAG cr = %d\n"
0053
0054 " Test listsig new "
0055 "No choc ? "
0056 "%d"
0057 "Nom diag ? "
0058 "%s"
0059
0060
0061
0062
0063 "Il a %ld signaux \n"
0064
0065 "%d %s \n"
0066
0067 "TSLSIG cr = %d\n"
0068
0069
0070 " Test listeobjet"
0071 "No choc ? "
0072 "%d"
0073
0074 "Nom prod ? "
0075 "%s"
0076
0077 "Nom type objet ? "
0078 "%s"
0079
0080
0081
0082
0083 "On a %d objets\n"
0084
0085
0086
0087
0088 "%d %s : %s \n"
0089
0090
0091
0092
0093
0094
0095
0096
0097 "bob : Erreur tslisterObjet %d\n"
0098
0099
0100
0101 "\n Test Writeparm"
0102 "Nom prod ? "
0103 "%s"
0104 "Nom objet ? "
0105 "%s"
0106 "Nom param ? "
0107 "%s"
0108
0109
0110
0111 "sizeof data %d\n"
0112
0113
0114
0115
0116
0117 "bob tswriteparam OK"
0118
0119
0120 "bob : Erreur tswriteparam %d \n"
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 "DYB"
0137 "OBJYB"
0138 "PARAMYB"
0139 "CYB"
0140
0141
0142
0143 "DESCOM"
0144
0145
0146 "bob tswriteparam common OK"
0147
0148
0149 "bob : Erreur tswriteparam %d \n"
0150
0151
0152
0153
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:
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 " Test TSdescObjet"
0297
0298 "No Choc ? "
0299 "%d"
0300 "Nom prod ? "
0301 "%s"
0302 "Nom objet ? "
0303 "%s"
0304 "Nom type objet ? "
0305 "%s"
0306
0307
0308
0309
0310
0311
0312 "bob tsdescobj OK"
0313 "comment %s \n"
0314
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382 "bob tsdescobj Pb %d\n"
0383
0384
0385
0386 "TSDescDon_choc \nNo Choc ? "
0387 "%d"
0388 "Nom donnee ? "
0389 "%s"
0390
0391
0392
0393
0394 "bob tsdescdon_choc OK"
0395 " id_objet :\t%d \n"
0396 " numero :\t%d \n"
0397 " id_donnee :\t%d \n"
0398 " condif :\t%d \n"
0399 " type_don :\t%d \n"
0400 " nb_compo :\t%d \n"
0401 " nb_coord :\t%d \n"
0402 " formatX :\t%s \n"
0403 " formatY :\t%s \n"
0404 " formatI :\t%s \n"
0405 " formatJ :\t%s \n"
0406 " uniteX :\t%s \n"
0407 " uniteY :\t%s \n"
0408 " uniteI :\t%s \n"
0409 " uniteJ :\t%s \n"
0410 " structX :\t%d \n"
0411 " structY :\t%d \n"
0412 " strucI :\t%d \n"
0413 " strucJ :\t%d \n"
0414 " longi :\t%d \n"
0415 " longj :\t%d \n"
0416 " maxtrame :\t%d \n"
0417 " remdif :\t%d \n"
0418
0419
0420
0421 "bob tsdesdon_choc Pb %d\n"
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 }
0455
0456
0457 return(0);
0458
0459
0460 }
0461