1 | #include "diabolo.h"
|
---|
2 | #include "bolo.h"
|
---|
3 | #include "auto.h"
|
---|
4 | #include "acqui.h"
|
---|
5 | #include "fichier.h"
|
---|
6 | #include "regul.h"
|
---|
7 | #include "tm.h"
|
---|
8 | #include "alarme.h"
|
---|
9 |
|
---|
10 |
|
---|
11 | //-----------------------------------------------------------------------------------------
|
---|
12 | //-------------------- fonction exec de la fenetre : regul --------------------------
|
---|
13 | //-----------------------------------------------------------------------------------------
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 | void exec_regul(int fen,int item,double valeur,...)
|
---|
18 | {
|
---|
19 | regul_p_i_d pid;
|
---|
20 | int bolo,g;
|
---|
21 |
|
---|
22 | switch(item)
|
---|
23 | {
|
---|
24 | case ouverture : tachedefond(fen,10*60);
|
---|
25 | case rg_num_bolo :
|
---|
26 | case rg_nb_mes :
|
---|
27 | case rg_chauf :
|
---|
28 | case rg_p : case rg_p+1000:
|
---|
29 | case rg_i : case rg_i+1000:
|
---|
30 | case rg_d : case rg_d+1000:
|
---|
31 | // case rg_periode_raz : case rg_periode_raz+1000 :
|
---|
32 |
|
---|
33 | pid.code=tc_regul;
|
---|
34 | pid.num_bolo=litD(fen,rg_num_bolo,0L);
|
---|
35 | pid.nb_mes=litD(fen,rg_nb_mes,0L);
|
---|
36 | pid.chauf=litD(fen,rg_chauf,0L);
|
---|
37 | pid.p=litD(fen,rg_p,0L);
|
---|
38 | pid.i=litD(fen,rg_i,0L);
|
---|
39 | pid.d=litD(fen,rg_d,0L);
|
---|
40 | // tt->reg.per_raz=litD(fen,rg_periode_raz,0L);
|
---|
41 | // printf(" nbmes=%d chauf=%d prop=%g compteur=%d \n",gg->reg.nb_mes,gg->reg.chauf,gg->reg.p,gg->reg.compteur);
|
---|
42 | // printf(" valeur=%ld commande=%d int=%g compteur=%d \n",tt->.valeur,tt->reg.cc,tt->reg.tint,tt->reg.compteur);
|
---|
43 |
|
---|
44 | // for(i=0;i<10;i++) btc.mot[i]=mot[i];
|
---|
45 |
|
---|
46 | emission_telecommande(tc_dir_transputer,&pid);
|
---|
47 |
|
---|
48 | break;
|
---|
49 |
|
---|
50 | case tache_de_fond : // toutes les 10 secondes, test la saturation de la regul
|
---|
51 | if( ! litD(fenetre_acquisition,e_tache_inter,0) ) break;
|
---|
52 | // break;
|
---|
53 | pid.code=tc_regul;
|
---|
54 | pid.num_bolo=bolo=litD(fen,rg_num_bolo,0L);
|
---|
55 | pid.nb_mes=litD(fen,rg_nb_mes,0L);
|
---|
56 | pid.p=litD(fen,rg_p,0L);
|
---|
57 | pid.i=litD(fen,rg_i,0L);
|
---|
58 | pid.d=litD(fen,rg_d,0L);
|
---|
59 | if(test_saturation(bolo))
|
---|
60 | {
|
---|
61 | pid.chauf=0;
|
---|
62 | g=gainbrut(gg->reglage.bolo[bolo-1]);
|
---|
63 | if(g>15) g=g&3;
|
---|
64 | g--;
|
---|
65 | if(g<0) g=0;
|
---|
66 | printf("ecritgain dans regul\n");
|
---|
67 | ecritD(bolo,b_gain,g); ecritgain(bolo);
|
---|
68 | if( litD(fenetre_alarme,a_sat_regul,0) >0) son(133);
|
---|
69 | }
|
---|
70 | else pid.chauf=litD(fen,rg_chauf,0L);
|
---|
71 |
|
---|
72 | emission_telecommande(tc_dir_transputer,&pid);
|
---|
73 |
|
---|
74 | break;
|
---|
75 |
|
---|
76 |
|
---|
77 | case caseferme : cache(fen);stop_exec(fen); break;
|
---|
78 | default: break;
|
---|
79 | }
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | //-----------------------------------------------------------------------------------------
|
---|
84 | //-----------------------------------------------------------------------------------------
|
---|
85 | //-------------------- fonction exec de la fenetre : regulation ---------------------
|
---|
86 | //-----------------------------------------------------------------------------------------
|
---|
87 | //-----------------------------------------------------------------------------------------
|
---|
88 |
|
---|
89 | void ecrit_regulation(void);
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | void exec_regulation(int fen,int item,double valeur,...)
|
---|
94 | {
|
---|
95 | if( (item>0) ou (item==ouverture) ) ecrit_regulation();
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | void ecrit_regulation(void)
|
---|
100 | {
|
---|
101 | int i,a;
|
---|
102 | long ll;
|
---|
103 | //printf("ecrit regulation nombre_de_regul=%d \n",nombre_de_regul);
|
---|
104 | for(i=0;i<nombre_de_regul;i++)
|
---|
105 | {
|
---|
106 | ll=(long)(&(gg->reglage.regul[i].mode))-(long)(&(gg->reglage.regul[0]));
|
---|
107 | a=litD(fenetre_regulation,regu_mode+i,0L)-1;
|
---|
108 | // printf(" a= %d reglage=%d ll=%d \n",a,gg->reglage.regul[i].mode,ll);
|
---|
109 | if(a!=gg->reglage.regul[i].mode)
|
---|
110 | {
|
---|
111 | // printf(" envoie %d en regul mode \n",a);
|
---|
112 | emission_tc_reduite(tc2_regul,ll,a);
|
---|
113 | }
|
---|
114 | ll=(long)(&(gg->reglage.regul[i].num_bolo))-(long)(&(gg->reglage.regul[0]));
|
---|
115 | a=litD(fenetre_regulation,regu_bolo+i,0L)-1;
|
---|
116 | if(a!=gg->reglage.regul[i].num_bolo) emission_tc_reduite(tc2_regul,ll,a);
|
---|
117 |
|
---|
118 | ll=(long)(&(gg->reglage.regul[i].voie_chauf))-(long)(&(gg->reglage.regul[0]));
|
---|
119 | a=litD(fenetre_regulation,regu_voie_chauf+i,0L)-1;
|
---|
120 | if(a!=gg->reglage.regul[i].voie_chauf) emission_tc_reduite(tc2_regul,ll,a);
|
---|
121 |
|
---|
122 | ll=(long)(&(gg->reglage.regul[i].prop))-(long)(&(gg->reglage.regul[0]));
|
---|
123 | a=litD(fenetre_regulation,regu_prop+i,0L);
|
---|
124 | if(a!=gg->reglage.regul[i].prop) emission_tc_reduite(tc2_regul,ll,a);
|
---|
125 |
|
---|
126 | ll=(long)(&(gg->reglage.regul[i].integ))-(long)(&(gg->reglage.regul[0]));
|
---|
127 | a=litD(fenetre_regulation,regu_int+i,0L)-1;
|
---|
128 | if(a!=gg->reglage.regul[i].integ) emission_tc_reduite(tc2_regul,ll,a);
|
---|
129 |
|
---|
130 | ll=(long)(&(gg->reglage.regul[i].deriv))-(long)(&(gg->reglage.regul[0]));
|
---|
131 | a=litD(fenetre_regulation,regu_deriv+i,0L)-1;
|
---|
132 | if(a!=gg->reglage.regul[i].deriv) emission_tc_reduite(tc2_regul,ll,a);
|
---|
133 | }
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 |
|
---|