1 | #include "cxfel.h" |
---|
2 | |
---|
3 | |
---|
4 | #include "heure.h" |
---|
5 | |
---|
6 | #using <mscorlib.dll> |
---|
7 | #using <System.dll> |
---|
8 | #using <System.Windows.Forms.dll> |
---|
9 | #using <System.Drawing.dll>//pour les controles bouton |
---|
10 | |
---|
11 | using namespace System; |
---|
12 | using namespace System::ComponentModel;//contient des classes pour les composants et les contrôles |
---|
13 | using namespace System::Windows::Forms;//contient des classes dédiées à la génération des formulaires |
---|
14 | using namespace System::Drawing;//contient les classes Point et Size du bouton |
---|
15 | |
---|
16 | using namespace System::IO;//contient les classes pour les I/O |
---|
17 | |
---|
18 | using namespace System::Threading; |
---|
19 | |
---|
20 | #undef MessageBox |
---|
21 | |
---|
22 | modbus_t *ctx;//modbus |
---|
23 | |
---|
24 | |
---|
25 | public __gc class ThreadReadModbus |
---|
26 | { |
---|
27 | public: |
---|
28 | // The ThreadProc method is called when the thread starts. |
---|
29 | static void ThreadProc() |
---|
30 | { |
---|
31 | uint8_t tab_rp_bits[MODBUS_SIZE_READ_COILS]; |
---|
32 | Console::WriteLine(S"ThreadProc: read coils..."); |
---|
33 | int rc = modbus_read_bits(ctx, 3000, 13, tab_rp_bits);////JCM : adresse coils=3000 |
---|
34 | if (rc != 13) |
---|
35 | Console::WriteLine(S"ThreadProc: read coils failed..."); |
---|
36 | Thread::Sleep(500); |
---|
37 | |
---|
38 | uint16_t tab_rp_registers_low[MODBUS_SIZE_READ_HOLDINGS_LOW]; |
---|
39 | Console::WriteLine(S"ThreadProc: read holdings..."); |
---|
40 | rc = modbus_read_registers(ctx, 2000,//JCM : adresse holding=2000 |
---|
41 | 82, tab_rp_registers_low); |
---|
42 | if (rc != 82) |
---|
43 | Console::WriteLine(S"ThreadProc: read holdings failed..."); |
---|
44 | Thread::Sleep(500); |
---|
45 | |
---|
46 | uint16_t wordPermuted[2]; |
---|
47 | float real = modbus_get_float(tab_rp_registers_low+6);//dP : float32 Normal |
---|
48 | *(wordPermuted+0)= tab_rp_registers_low[6+1];//dP : float32 Reverse |
---|
49 | *(wordPermuted+1)= tab_rp_registers_low[6+0];//dP : float32 Reverse |
---|
50 | float realReversed = modbus_get_float(wordPermuted+0);//dP : float32 Reverse |
---|
51 | |
---|
52 | Console::WriteLine(S"ThreadProc: read float..."); |
---|
53 | // if (real != UT_REAL) |
---|
54 | // Console::WriteLine(S"ThreadProc: read float failed..."); |
---|
55 | printf("real(2006d) = normal=%f reverse=%f\n", |
---|
56 | real, |
---|
57 | //word2float[0]+(word2float[1]<<16) |
---|
58 | //tab_rp_registers_low[6]+(tab_rp_registers_low[7]<<16)); |
---|
59 | realReversed); |
---|
60 | Thread::Sleep(500); |
---|
61 | |
---|
62 | uint16_t tab_rp_registers_high[MODBUS_SIZE_READ_HOLDINGS_HIGH]; |
---|
63 | Console::WriteLine(S"ThreadProc: read holdings..."); |
---|
64 | rc = modbus_read_registers(ctx, 2082, |
---|
65 | 125, tab_rp_registers_high); |
---|
66 | if (rc != 125) |
---|
67 | Console::WriteLine(S"ThreadProc: read holdings failed..."); |
---|
68 | Thread::Sleep(500); |
---|
69 | |
---|
70 | real = modbus_get_float(tab_rp_registers_high+36);//Pi_max |
---|
71 | Console::WriteLine(S"ThreadProc: read float..."); |
---|
72 | // if (real != UT_REAL) |
---|
73 | // Console::WriteLine(S"ThreadProc: read float failed..."); |
---|
74 | printf("real(2118d) = %f\n", real); |
---|
75 | Thread::Sleep(500); |
---|
76 | } |
---|
77 | }; |
---|
78 | |
---|
79 | |
---|
80 | CGroupBox::CGroupBox(String* gname, int posX, int posY) |
---|
81 | { |
---|
82 | name=gname; |
---|
83 | nbInstance++; |
---|
84 | |
---|
85 | // Creation |
---|
86 | gbox = new GroupBox(); |
---|
87 | gbox->Text = name; |
---|
88 | gbox->Size = System::Drawing::Size(200, 200);//taille du groupbox en pixels |
---|
89 | gbox->Location = Point(posX,posY); |
---|
90 | |
---|
91 | // Num_P label tt seul |
---|
92 | Label* labNumP= new Label(); |
---|
93 | // labNumP->Location = Point(posX+10,posY+5); |
---|
94 | labNumP->Location = Point(70,35); |
---|
95 | labNumP->Size = System::Drawing::Size(50,16); |
---|
96 | labNumP->Text = "Num_P";//zone de texte initialisée |
---|
97 | labNumP->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold);; |
---|
98 | labNumP->TextAlign = ContentAlignment::MiddleRight; |
---|
99 | valNumP= new TextBox(); |
---|
100 | valNumP->Location = Point(70,55); |
---|
101 | valNumP->Size = System::Drawing::Size(60, 40); |
---|
102 | valNumP->Text = "";//zone de texte initialisée vide |
---|
103 | valNumP->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold); |
---|
104 | valNumP->ForeColor = Color::Brown; |
---|
105 | gbox->Controls->Add(labNumP); |
---|
106 | gbox->Controls->Add(valNumP); |
---|
107 | // Num_C1 label tt seul |
---|
108 | Label* labNumC1= new Label(); |
---|
109 | // labNumC1->Location = Point(posX+5, posY+20); |
---|
110 | labNumC1->Location = Point(20, 90); |
---|
111 | labNumC1->Size = System::Drawing::Size(50,16); |
---|
112 | labNumC1->Text = "1";//zone de texte initialisée |
---|
113 | labNumC1->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold);; |
---|
114 | labNumC1->TextAlign = ContentAlignment::MiddleRight; |
---|
115 | valNumC1= new TextBox(); |
---|
116 | valNumC1->Location = Point(30,110); |
---|
117 | valNumC1->Size = System::Drawing::Size(60, 40); |
---|
118 | valNumC1->Text = "";//zone de texte initialisée vide |
---|
119 | valNumC1->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold);; |
---|
120 | valNumC1->ForeColor = Color::Brown; |
---|
121 | gbox->Controls->Add(labNumC1); |
---|
122 | gbox->Controls->Add(valNumC1); |
---|
123 | // Num_C2 label tt seul |
---|
124 | Label* labNumC2= new Label(); |
---|
125 | // labNumC2->Location = Point(posX+60, posY+20); |
---|
126 | labNumC2->Location = Point(85, 90); |
---|
127 | labNumC2->Size = System::Drawing::Size(50,16); |
---|
128 | labNumC2->Text = "2";//zone de texte initialisée |
---|
129 | labNumC2->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold);; |
---|
130 | labNumC2->TextAlign = ContentAlignment::MiddleRight; |
---|
131 | valNumC2= new TextBox(); |
---|
132 | valNumC2->Location = Point(105,110); |
---|
133 | valNumC2->Size = System::Drawing::Size(60, 40); |
---|
134 | valNumC2->Text = "";//zone de texte initialisée vide |
---|
135 | valNumC2->Font = new System::Drawing::Font(S"Arial", 9, FontStyle::Bold);; |
---|
136 | valNumC2->ForeColor = Color::Brown; |
---|
137 | gbox->Controls->Add(labNumC2); |
---|
138 | gbox->Controls->Add(valNumC2); |
---|
139 | //bouton Appliquer |
---|
140 | appliquerBtn = new Button(); |
---|
141 | appliquerBtn->Location = Point(65, 170); |
---|
142 | appliquerBtn->Name = "Bouton Appliquer"; |
---|
143 | appliquerBtn->Text = "Appliquer"; |
---|
144 | appliquerBtn->Click += new EventHandler(this, &CGroupBox::AppliquerBtn_Clicked); |
---|
145 | gbox->Controls->Add(appliquerBtn); |
---|
146 | |
---|
147 | /* |
---|
148 | String* str; |
---|
149 | str=String::Concat(labNumC1->Text); |
---|
150 | Console::WriteLine(str); |
---|
151 | str=String::Concat(labNumC2->Text); |
---|
152 | Console::WriteLine(str); |
---|
153 | */ |
---|
154 | //.............. |
---|
155 | //.............. |
---|
156 | |
---|
157 | } |
---|
158 | |
---|
159 | Label* CGroupBox::GetLabelNumP() |
---|
160 | { |
---|
161 | return labNumP; |
---|
162 | } |
---|
163 | |
---|
164 | Label* CGroupBox::GetLabelNumC1() |
---|
165 | { |
---|
166 | return labNumC1; |
---|
167 | } |
---|
168 | |
---|
169 | Label* CGroupBox::GetLabelNumC2() |
---|
170 | { |
---|
171 | return labNumC2; |
---|
172 | } |
---|
173 | |
---|
174 | GroupBox* CGroupBox::GetGroupBox() |
---|
175 | { |
---|
176 | return gbox; |
---|
177 | } |
---|
178 | |
---|
179 | void CGroupBox::AppliquerBtn_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton Appliquer |
---|
180 | { |
---|
181 | if(!String::Compare(name,"a")) |
---|
182 | { |
---|
183 | Console::WriteLine(S"appliquer a"); |
---|
184 | } |
---|
185 | if(!String::Compare(name,"b")) |
---|
186 | { |
---|
187 | Console::WriteLine(S"appliquer b"); |
---|
188 | } |
---|
189 | if(!String::Compare(name,"c")) |
---|
190 | { |
---|
191 | Console::WriteLine(S"appliquer c"); |
---|
192 | } |
---|
193 | if(!String::Compare(name,"d")) |
---|
194 | { |
---|
195 | Console::WriteLine(S"appliquer d"); |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | CDialogConfig::CDialogConfig() |
---|
200 | { |
---|
201 | // définit les paramètres du formulaire |
---|
202 | Text = S"XSUC - ecriture serveur"; |
---|
203 | FormBorderStyle = FormBorderStyle::Fixed3D;//impossible de modifier la taille |
---|
204 | Size = System::Drawing::Size(1000,800); |
---|
205 | |
---|
206 | // Creation de controle |
---|
207 | sortirBtn = new Button(); |
---|
208 | |
---|
209 | // bouton OK |
---|
210 | sortirBtn->Location = Point(900, 700); |
---|
211 | sortirBtn->Name = "Bouton Sortir"; |
---|
212 | sortirBtn->Text = "sortir"; |
---|
213 | sortirBtn->DialogResult = DialogResult::OK; |
---|
214 | |
---|
215 | // Ajoute les controles dans le formaulaire |
---|
216 | Controls->Add(sortirBtn); |
---|
217 | |
---|
218 | /* GroupBox* gbox = new GroupBox(); |
---|
219 | gbox->Text = S"name"; |
---|
220 | gbox->Size = System::Drawing::Size(200, 150);//taille du groupbox en pixels |
---|
221 | gbox->Location = Point(200,90); |
---|
222 | Label* labNumP= new Label(); |
---|
223 | labNumP->Location = Point(10, 20); |
---|
224 | labNumP->Size = System::Drawing::Size(50,16); |
---|
225 | labNumP->Text = "Num_P";//zone de texte initialisée |
---|
226 | labNumP->TextAlign = ContentAlignment::MiddleRight; |
---|
227 | gbox->Controls->Add(labNumP); |
---|
228 | Controls->Add(gbox); |
---|
229 | */ |
---|
230 | pal = new ArrayList(); |
---|
231 | int j=20;//depart affichage |
---|
232 | for (indexGroupBox=0;indexGroupBox<NB_BANCS;indexGroupBox++)//creation des controles dans le formulaire |
---|
233 | { |
---|
234 | pal->Add(new CGroupBox(gname[indexGroupBox],j,90)); |
---|
235 | j+=250; |
---|
236 | CGroupBox* gboxPtr = (CGroupBox *) pal->get_Item(indexGroupBox); |
---|
237 | // gboxPtr->Controls->Add(gboxPtr->GetLabelNumP()); |
---|
238 | // gboxPtr->GetGroupBox()->Controls->Add(gboxPtr->GetLabelNumC1()); |
---|
239 | // gboxPtr->Controls->Add(gboxPtr->GetLabelNumC2()); |
---|
240 | Controls->Add(gboxPtr->GetGroupBox()); |
---|
241 | String* str; |
---|
242 | str=String::Concat(gboxPtr->GetGroupBox()->Text); |
---|
243 | Console::WriteLine(str); |
---|
244 | /* str=String::Concat(gboxPtr->GetLabelNumP()->Text); |
---|
245 | Console::WriteLine(str); |
---|
246 | str=String::Concat(gboxPtr->GetLabelNumC1()->Text); |
---|
247 | Console::WriteLine(str); |
---|
248 | */ } |
---|
249 | |
---|
250 | //configure les 2 propriétés : AcceptButton contient la réf du bouton par défaut du formulaire.. |
---|
251 | //..on peut cliquer sur le bouton OK ou bien sur la touche Entrée du clavier.. |
---|
252 | //..referme aussi la boite car DialogResult renvoie OK |
---|
253 | AcceptButton = sortirBtn; |
---|
254 | |
---|
255 | //gestionnnaire associé au bouton OK |
---|
256 | sortirBtn->Click += new EventHandler(this, &CDialogConfig::SortirBtn_Clicked); |
---|
257 | } |
---|
258 | |
---|
259 | void CDialogConfig::SortirBtn_Clicked(Object* pSender,EventArgs* pArgs)//gestionnaire d'evenement de la boite dialogue |
---|
260 | { |
---|
261 | //fermer le formulaire lorsqu'on clique sur le bouton |
---|
262 | Close(); |
---|
263 | } |
---|
264 | |
---|
265 | |
---|
266 | CLabelTextBox::CLabelTextBox(String* labString, int posX, int posY, int sizeX, int sizeY, int sizeText) |
---|
267 | { |
---|
268 | name=labString; |
---|
269 | labPosX=posX; |
---|
270 | labPosY=posY; |
---|
271 | labSizeX=sizeX; |
---|
272 | labSizeY=sizeY; |
---|
273 | nbInstance++; |
---|
274 | |
---|
275 | lab= new Label(); |
---|
276 | val= new TextBox(); |
---|
277 | |
---|
278 | // dPLabel et dPBox : label et zone de saisie sont placés l'un à côté de l'autre |
---|
279 | lab->Location = Point(labPosX, labPosY); |
---|
280 | lab->Size = System::Drawing::Size(labSizeX,labSizeY); |
---|
281 | lab->Text = name;//zone de texte initialisée |
---|
282 | lab->TextAlign = ContentAlignment::MiddleRight; |
---|
283 | val->Location = Point(labPosX+labSizeX, labPosY); |
---|
284 | val->Size = System::Drawing::Size(sizeText, 20); |
---|
285 | val->Text = "";//zone de texte initialisée vide |
---|
286 | } |
---|
287 | |
---|
288 | Label* CLabelTextBox::GetLabel() |
---|
289 | { |
---|
290 | return lab; |
---|
291 | } |
---|
292 | |
---|
293 | TextBox* CLabelTextBox::GetTextBox() |
---|
294 | { |
---|
295 | return val; |
---|
296 | } |
---|
297 | |
---|
298 | String* CLabelTextBox::GetName() |
---|
299 | { |
---|
300 | return name; |
---|
301 | } |
---|
302 | |
---|
303 | void CLabelTextBox::SetVal(String* value) |
---|
304 | { |
---|
305 | val->Text=value; |
---|
306 | } |
---|
307 | |
---|
308 | String* CLabelTextBox::GetVal() |
---|
309 | { |
---|
310 | return val->Text; |
---|
311 | } |
---|
312 | |
---|
313 | void CLabelTextBox::SetColor(int value) |
---|
314 | { |
---|
315 | if(value) |
---|
316 | val->BackColor=Color::Red; |
---|
317 | else |
---|
318 | val->BackColor=Color::White; |
---|
319 | } |
---|
320 | |
---|
321 | |
---|
322 | MaDialogUser::MaDialogUser() |
---|
323 | { |
---|
324 | // définit les paramètres du formulaire |
---|
325 | Text = S"XSUC - lecture serveur"; |
---|
326 | FormBorderStyle = FormBorderStyle::Fixed3D;//impossible de modifier la taille |
---|
327 | Size = System::Drawing::Size(1000,800); |
---|
328 | |
---|
329 | // Creation de controle |
---|
330 | OKBtn = new Button(); |
---|
331 | EcritureBtn = new Button(); |
---|
332 | // CancelBtn = new Button(); |
---|
333 | |
---|
334 | // bouton OK |
---|
335 | OKBtn->Location = Point(900, 700); |
---|
336 | OKBtn->Name = "Bouton OK"; |
---|
337 | OKBtn->Text = "OK"; |
---|
338 | OKBtn->DialogResult = DialogResult::OK; |
---|
339 | /* |
---|
340 | // bouton Cancel |
---|
341 | CancelBtn->Location = Point(192, 136); |
---|
342 | CancelBtn->Name = "Bouton Cancel"; |
---|
343 | CancelBtn->Text = "Annuler"; |
---|
344 | CancelBtn->DialogResult = DialogResult::Cancel; |
---|
345 | */ |
---|
346 | // bouton Ecriture |
---|
347 | EcritureBtn->Location = Point(900, 600); |
---|
348 | EcritureBtn->Name = "Bouton Ecriture"; |
---|
349 | EcritureBtn->Text = "Ecriture"; |
---|
350 | EcritureBtn->DialogResult = DialogResult::OK; |
---|
351 | |
---|
352 | // Ajoute les controles dans le formaulaire |
---|
353 | Controls->Add(OKBtn); |
---|
354 | Controls->Add(EcritureBtn); |
---|
355 | |
---|
356 | pal = new ArrayList(); |
---|
357 | for (indexTextBox=0;indexTextBox<20;indexTextBox++)//creation des controles dans le formulaire |
---|
358 | { |
---|
359 | int posX=650, j=indexTextBox; |
---|
360 | if (indexTextBox>=10) |
---|
361 | { |
---|
362 | posX=800; |
---|
363 | j=indexTextBox-10; |
---|
364 | } |
---|
365 | pal->Add(new CLabelTextBox(nameLab_1[indexTextBox],posX,(25*j)+10,100,16,70)); |
---|
366 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
367 | Controls->Add(cltbPtr->GetLabel()); |
---|
368 | Controls->Add(cltbPtr->GetTextBox()); |
---|
369 | } |
---|
370 | for (;indexTextBox<26;indexTextBox++)//creation des controles dans le formulaire |
---|
371 | { |
---|
372 | int posX=400, j=indexTextBox-20; |
---|
373 | int sizeText=70; |
---|
374 | if (indexTextBox==20)sizeText=20; |
---|
375 | pal->Add(new CLabelTextBox(nameLab_1[indexTextBox],posX,(25*j)+10,100,16,sizeText)); |
---|
376 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
377 | Controls->Add(cltbPtr->GetLabel()); |
---|
378 | Controls->Add(cltbPtr->GetTextBox()); |
---|
379 | } |
---|
380 | Setup_Group_Conditionning(); |
---|
381 | // Mode tt seul |
---|
382 | pal->Add(new CLabelTextBox("MODE",20,100,50,16,75)); |
---|
383 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox++); |
---|
384 | Controls->Add(cltbPtr->GetLabel()); |
---|
385 | Controls->Add(cltbPtr->GetTextBox()); |
---|
386 | |
---|
387 | //configure les 2 propriétés : AcceptButton contient la réf du bouton par défaut du formulaire.. |
---|
388 | //..on peut cliquer sur le bouton OK ou bien sur la touche Entrée du clavier.. |
---|
389 | //..referme aussi la boite car DialogResult renvoie OK |
---|
390 | AcceptButton = OKBtn; |
---|
391 | //CancelButton contient la réf du bouton associée à la touche Echap du clavier |
---|
392 | // CancelButton = CancelBtn; |
---|
393 | |
---|
394 | //gestionnnaire associé aux boutons |
---|
395 | OKBtn->Click += new EventHandler(this, &MaDialogUser::OKMaDBtn_Clicked); |
---|
396 | EcritureBtn->Click += new EventHandler(this, &MaDialogUser::EcritureBtn_Clicked); |
---|
397 | |
---|
398 | Setup_Group(); |
---|
399 | } |
---|
400 | |
---|
401 | void MaDialogUser::EcritureBtn_Clicked(Object* pSender,EventArgs* pArgs)//gestionnaire d'evenement de la boite dialogue |
---|
402 | { |
---|
403 | //crée la boite de dialogue utilisateur |
---|
404 | CDialogConfig* box = new CDialogConfig(); |
---|
405 | //affiche la boite de dialogue |
---|
406 | if (box->ShowDialog() == DialogResult::OK) |
---|
407 | { |
---|
408 | //si la valeur OK est renvoyée, on affiche le nom |
---|
409 | //MessageBox::Show(S"Ecriture"); |
---|
410 | } |
---|
411 | } |
---|
412 | |
---|
413 | void MaDialogUser::OKMaDBtn_Clicked(Object* pSender,EventArgs* pArgs)//gestionnaire d'evenement de la boite dialogue |
---|
414 | { |
---|
415 | //fermer le formulaire lorsqu'on clique sur le bouton |
---|
416 | Close(); |
---|
417 | } |
---|
418 | |
---|
419 | float MaDialogUser::PermutToReversed(uint16_t* tab_rp_registers,int index)//permute float32 en float32 Reverse |
---|
420 | { |
---|
421 | uint16_t wordPermuted[2]; |
---|
422 | |
---|
423 | *(wordPermuted+0)= tab_rp_registers[index+1]; |
---|
424 | *(wordPermuted+1)= tab_rp_registers[index+0]; |
---|
425 | return (modbus_get_float(wordPermuted+0));//float32 Reverse |
---|
426 | } |
---|
427 | |
---|
428 | void MaDialogUser::ThreadProc()//gestionnaire d'evenement du thread de la boite dialogue |
---|
429 | { |
---|
430 | uint8_t tab_rp_bits[MODBUS_SIZE_READ_COILS]; |
---|
431 | uint16_t tab_rp_registers_low[MODBUS_SIZE_READ_HOLDINGS_LOW]; |
---|
432 | uint16_t tab_rp_registers_high[MODBUS_SIZE_READ_HOLDINGS_HIGH]; |
---|
433 | int rc, adress, size; |
---|
434 | CLabelTextBox* cltbPtr; |
---|
435 | |
---|
436 | for (;;) |
---|
437 | { |
---|
438 | Thread::Sleep(500); |
---|
439 | Console::WriteLine(S"ThreadProc: read coils..."); |
---|
440 | adress=3000;//adresse coils=3000 |
---|
441 | size=13; |
---|
442 | rc = modbus_read_bits(ctx, adress, size, tab_rp_bits);////JCM : adresse coils=3000 |
---|
443 | if (rc != size) |
---|
444 | Console::WriteLine(S"ThreadProc: read coils failed..."); |
---|
445 | |
---|
446 | Thread::Sleep(500); |
---|
447 | Console::WriteLine(S"ThreadProc: read holdings..."); |
---|
448 | adress=2000;//adresse holding=2000 |
---|
449 | size=82; |
---|
450 | rc = modbus_read_registers(ctx, adress, size, tab_rp_registers_low); |
---|
451 | if (rc != size) |
---|
452 | Console::WriteLine(S"ThreadProc: read holdings failed..."); |
---|
453 | |
---|
454 | int indexArrayList=0; |
---|
455 | //dtp : ui16 |
---|
456 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
457 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[4])); |
---|
458 | //dt : ui16 |
---|
459 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
460 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[5])); |
---|
461 | //dP : float32 |
---|
462 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
463 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,6))); |
---|
464 | //dPsecu : float32 |
---|
465 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
466 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,8))); |
---|
467 | |
---|
468 | //NBal : ui16 |
---|
469 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
470 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[42])); |
---|
471 | //P_cde : float32 |
---|
472 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
473 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,43))); |
---|
474 | //Pp : float32 |
---|
475 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
476 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,45))); |
---|
477 | |
---|
478 | //Nbal_max : ui16 |
---|
479 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
480 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[25])); |
---|
481 | //Fr : ui16 |
---|
482 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
483 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[26])); |
---|
484 | //N_cur : ui16 |
---|
485 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
486 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[27])); |
---|
487 | |
---|
488 | //SVd : ui16 |
---|
489 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
490 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[0])); |
---|
491 | //SVfin : ui16 |
---|
492 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
493 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[1])); |
---|
494 | //SV1 : ui16 |
---|
495 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
496 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[2])); |
---|
497 | //SV2 : ui16 |
---|
498 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
499 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[3])); |
---|
500 | |
---|
501 | //V_cur : ui16 |
---|
502 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
503 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[37])); |
---|
504 | //Pic : float32 |
---|
505 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
506 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,38))); |
---|
507 | //Timer : uint32 |
---|
508 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
509 | cltbPtr->SetVal(Convert::ToString((tab_rp_registers_low[40]<<16)+(tab_rp_registers_low[41]))); |
---|
510 | |
---|
511 | //SVil : ui16 |
---|
512 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
513 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[20])); |
---|
514 | //Sleil : float32 |
---|
515 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
516 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,21))); |
---|
517 | //STc : float32 |
---|
518 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
519 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,23))); |
---|
520 | |
---|
521 | //Eil : bool |
---|
522 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
523 | cltbPtr->SetVal(Convert::ToString(tab_rp_bits[0])); |
---|
524 | if(tab_rp_bits[0])//echec changer couleur |
---|
525 | cltbPtr->SetColor(1); |
---|
526 | else |
---|
527 | cltbPtr->SetColor(0); |
---|
528 | //Nil : ui16 |
---|
529 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
530 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[30])); |
---|
531 | //Nil_stat : ui16 |
---|
532 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
533 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[31])); |
---|
534 | //P_last : float32 |
---|
535 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
536 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,32))); |
---|
537 | //N_last : ui16 |
---|
538 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
539 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[34])); |
---|
540 | //DPil : float32 |
---|
541 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
542 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,35))); |
---|
543 | |
---|
544 | //Num_C : tab ui16 |
---|
545 | for (int indexMbArray=50;(indexArrayList<34 && indexMbArray<58);indexMbArray++) |
---|
546 | { |
---|
547 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
548 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[indexMbArray])); |
---|
549 | } |
---|
550 | |
---|
551 | //Stat_C : tab bool |
---|
552 | for (int indexMbArray=1;(indexArrayList<46 && indexMbArray<13);indexMbArray++) |
---|
553 | { |
---|
554 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
555 | cltbPtr->SetVal(Convert::ToString(tab_rp_bits[indexMbArray])); |
---|
556 | if(!tab_rp_bits[indexMbArray])//echec changer couleur |
---|
557 | cltbPtr->SetColor(1); |
---|
558 | else |
---|
559 | cltbPtr->SetColor(0); |
---|
560 | } |
---|
561 | |
---|
562 | //Temp_cond : tab ui16 |
---|
563 | for (int indexMbArray=58;(indexArrayList<58 && indexMbArray<71);indexMbArray++) |
---|
564 | { |
---|
565 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
566 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[indexMbArray])); |
---|
567 | } |
---|
568 | |
---|
569 | //status : ui16 |
---|
570 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
571 | if (tab_rp_registers_low[49] != 4)//on n'est pas ds le mode pulsing |
---|
572 | { |
---|
573 | cltbPtr->SetVal("ARRET"); |
---|
574 | btnStart->Enabled=false;//bouton start |
---|
575 | btnStop->Enabled=false;//bouton stop |
---|
576 | btnPause->Enabled=false;//bouton pause |
---|
577 | btnReprise->Enabled=false;//bouton reprise |
---|
578 | } |
---|
579 | else |
---|
580 | {//mode pulsing |
---|
581 | switch (tab_rp_registers_low[28]){//RetMAPR |
---|
582 | case 0://conditionnement arreté |
---|
583 | cltbPtr->SetVal("ARRET"); |
---|
584 | btnStart->Enabled=true;//bouton start |
---|
585 | btnStop->Enabled=false;//bouton stop |
---|
586 | btnPause->Enabled=false;//bouton pause |
---|
587 | btnReprise->Enabled=false;//bouton reprise |
---|
588 | break; |
---|
589 | case 2: case 3://conditionnement démarré ou repris |
---|
590 | cltbPtr->SetVal("MARCHE"); |
---|
591 | btnStart->Enabled=false;//bouton start |
---|
592 | btnStop->Enabled=true;//bouton stop |
---|
593 | btnPause->Enabled=true;//bouton pause |
---|
594 | btnReprise->Enabled=false;//bouton reprise |
---|
595 | break; |
---|
596 | case 1://conditionnement en pause |
---|
597 | cltbPtr->SetVal("PAUSE"); |
---|
598 | btnStart->Enabled=false;//bouton start |
---|
599 | btnStop->Enabled=true;//bouton stop |
---|
600 | btnPause->Enabled=false;//bouton pause |
---|
601 | btnReprise->Enabled=true;//bouton reprise |
---|
602 | break; |
---|
603 | } |
---|
604 | if (tab_rp_registers_low[28] != tab_rp_registers_low[48])//message affiché |
---|
605 | { |
---|
606 | String* stra[] = {S"RetMAPR=",Convert::ToString(tab_rp_registers_low[28]), |
---|
607 | S" not equal to MAPR=",Convert::ToString(tab_rp_registers_low[48])}; |
---|
608 | String* str=String::Concat(stra); |
---|
609 | Console::WriteLine(str); |
---|
610 | } |
---|
611 | }//fin mode pulsing |
---|
612 | |
---|
613 | //N_Seqcond : ui16 |
---|
614 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
615 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[47])); |
---|
616 | |
---|
617 | Thread::Sleep(500); |
---|
618 | Console::WriteLine(S"ThreadProc: read holdings..."); |
---|
619 | adress=2082;//adresse holding=2082 |
---|
620 | size=125; |
---|
621 | rc = modbus_read_registers(ctx, adress, size, tab_rp_registers_high); |
---|
622 | if (rc != size) |
---|
623 | Console::WriteLine(S"ThreadProc: read holdings failed..."); |
---|
624 | |
---|
625 | //DateD HeureD : tab ui16 |
---|
626 | String* str; |
---|
627 | String* strDD[] = { |
---|
628 | Convert::ToString(tab_rp_registers_high[84]), |
---|
629 | "-", |
---|
630 | Convert::ToString(tab_rp_registers_high[85]), |
---|
631 | "-", |
---|
632 | Convert::ToString(tab_rp_registers_high[86])}; |
---|
633 | str=String::Concat(strDD); |
---|
634 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
635 | cltbPtr->SetVal(str); |
---|
636 | String* strHD[] = { |
---|
637 | Convert::ToString(tab_rp_registers_high[87]), |
---|
638 | ":", |
---|
639 | Convert::ToString(tab_rp_registers_high[88]), |
---|
640 | ":", |
---|
641 | Convert::ToString(tab_rp_registers_high[89])}; |
---|
642 | str=String::Concat(strHD); |
---|
643 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
644 | cltbPtr->SetVal(str); |
---|
645 | |
---|
646 | //DateF HeureF : tab ui16 |
---|
647 | String* strDF[] = { |
---|
648 | Convert::ToString(tab_rp_registers_high[90]), |
---|
649 | "-", |
---|
650 | Convert::ToString(tab_rp_registers_high[91]), |
---|
651 | "-", |
---|
652 | Convert::ToString(tab_rp_registers_high[92])}; |
---|
653 | str=String::Concat(strDF); |
---|
654 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
655 | cltbPtr->SetVal(str); |
---|
656 | String* strHF[] = { |
---|
657 | Convert::ToString(tab_rp_registers_high[93]), |
---|
658 | ":", |
---|
659 | Convert::ToString(tab_rp_registers_high[94]), |
---|
660 | ":", |
---|
661 | Convert::ToString(tab_rp_registers_high[95])}; |
---|
662 | str=String::Concat(strHF); |
---|
663 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
664 | cltbPtr->SetVal(str); |
---|
665 | |
---|
666 | //Vides : tab ui16 |
---|
667 | for (int indexMbArray=98;indexMbArray<110;indexMbArray++) |
---|
668 | { |
---|
669 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
670 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_high[indexMbArray])); |
---|
671 | } |
---|
672 | |
---|
673 | //Prc : tab float32 |
---|
674 | for (int indexMbArray=68;indexMbArray<76;indexMbArray+=2) |
---|
675 | { |
---|
676 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
677 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_high,indexMbArray))); |
---|
678 | } |
---|
679 | |
---|
680 | //Pic : tab float32 |
---|
681 | for (int indexMbArray=60;indexMbArray<68;indexMbArray+=2) |
---|
682 | { |
---|
683 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
684 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_high,indexMbArray))); |
---|
685 | } |
---|
686 | |
---|
687 | //Pch : tab float32 |
---|
688 | for (int indexMbArray=76;indexMbArray<84;indexMbArray+=2) |
---|
689 | { |
---|
690 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
691 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_high,indexMbArray))); |
---|
692 | } |
---|
693 | |
---|
694 | //Ie_cur : tab float32 |
---|
695 | for (int indexMbArray=10;indexMbArray<18;indexMbArray+=2) |
---|
696 | { |
---|
697 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
698 | cltbPtr->SetVal(Convert::ToString(PermutToReversed(tab_rp_registers_low,indexMbArray))); |
---|
699 | } |
---|
700 | |
---|
701 | //Num_P : tab ui16 |
---|
702 | for (int indexMbArray=70;indexMbArray<74;indexMbArray++) |
---|
703 | { |
---|
704 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
705 | cltbPtr->SetVal(Convert::ToString(tab_rp_registers_low[indexMbArray])); |
---|
706 | } |
---|
707 | |
---|
708 | //Mode : ui16 |
---|
709 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList++); |
---|
710 | switch (tab_rp_registers_low[49]){ |
---|
711 | case 0://station en mode init |
---|
712 | cltbPtr->SetVal("INIT"); |
---|
713 | break; |
---|
714 | case 1://station en mode off |
---|
715 | cltbPtr->SetVal("OFF"); |
---|
716 | break; |
---|
717 | case 2://station en mode heater |
---|
718 | cltbPtr->SetVal("HEATER"); |
---|
719 | break; |
---|
720 | case 3://station en mode standby |
---|
721 | cltbPtr->SetVal("STANDBY"); |
---|
722 | break; |
---|
723 | case 4://station en mode pulsing=conditionnement |
---|
724 | cltbPtr->SetVal("PULSING"); |
---|
725 | break; |
---|
726 | case 5://station en mode off |
---|
727 | cltbPtr->SetVal("STOP"); |
---|
728 | break; |
---|
729 | } |
---|
730 | // |
---|
731 | // |
---|
732 | } |
---|
733 | } |
---|
734 | |
---|
735 | void MaDialogUser::Setup_Group ()//creation et configuration d'un groupe d'options |
---|
736 | { |
---|
737 | // Creation |
---|
738 | gbox = new GroupBox(); |
---|
739 | gbox->Text = S"enable lecture"; |
---|
740 | gbox->Size = System::Drawing::Size(200, 150);//taille du groupbox en pixels |
---|
741 | gbox->Location = Point(200, 90); |
---|
742 | |
---|
743 | // Creation des boutons radio. |
---|
744 | rb1 = new RadioButton(); |
---|
745 | rb1->Text = S"oui"; |
---|
746 | rb1->Location = Point(10,25); |
---|
747 | |
---|
748 | rb2 = new RadioButton(); |
---|
749 | rb2->Text = S"non"; |
---|
750 | rb2->Location = Point(10,55); |
---|
751 | |
---|
752 | // ajout des controles dans le groupe |
---|
753 | gbox->Controls->Add(rb1); |
---|
754 | gbox->Controls->Add(rb2); |
---|
755 | |
---|
756 | // ajout du groupe dans le formulaire. |
---|
757 | Controls->Add(gbox); |
---|
758 | |
---|
759 | // associe le gestionnaire au groupe d'options |
---|
760 | rb1->Click += new EventHandler(this, &MaDialogUser::Radio_Clicked); |
---|
761 | rb2->Click += new EventHandler(this, &MaDialogUser::Radio_Clicked); |
---|
762 | } |
---|
763 | |
---|
764 | void MaDialogUser::Setup_Group_Conditionning()//creation et configuration d'un groupe d'options |
---|
765 | { |
---|
766 | // Creation |
---|
767 | GroupBox* gboxC = new GroupBox(); |
---|
768 | gboxC->Text = S"CONDITIONNEMENT"; |
---|
769 | gboxC->Size = System::Drawing::Size(800, 450);//taille du groupbox en pixels |
---|
770 | gboxC->Location = Point(40,300); |
---|
771 | |
---|
772 | Setup_Buttons_Conditionning();//configure les boutons du formulaire |
---|
773 | |
---|
774 | // Num_C label tt seul |
---|
775 | Label* num_C= new Label(); |
---|
776 | num_C->Location = Point(50, 390); |
---|
777 | num_C->Size = System::Drawing::Size(50,16); |
---|
778 | num_C->Text = "Num_C";//zone de texte initialisée |
---|
779 | num_C->TextAlign = ContentAlignment::MiddleRight; |
---|
780 | Controls->Add(num_C); |
---|
781 | int j=60;//depart affichage |
---|
782 | // for (int i=0;indexTextBox<34;indexTextBox++,i++,j+=80)//creation des controles dans le formulaire |
---|
783 | for (int i=0;i<NB_COUPLEURS;indexTextBox++,i++,j+=80)//creation des controles dans le formulaire |
---|
784 | { |
---|
785 | int posX=70; |
---|
786 | pal->Add(new CLabelTextBox(nameLab_2[i],posX+j,390,25,16,50)); |
---|
787 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
788 | Controls->Add(cltbPtr->GetLabel()); |
---|
789 | Controls->Add(cltbPtr->GetTextBox()); |
---|
790 | } |
---|
791 | |
---|
792 | // Stat_C label tt seul |
---|
793 | Label* stat_C= new Label(); |
---|
794 | stat_C->Location = Point(50, 630); |
---|
795 | stat_C->Size = System::Drawing::Size(50,16); |
---|
796 | stat_C->Text = "Stat_C";//zone de texte initialisée |
---|
797 | stat_C->TextAlign = ContentAlignment::MiddleRight; |
---|
798 | Controls->Add(stat_C); |
---|
799 | j=20;//depart affichage |
---|
800 | // for (int i=0;indexTextBox<46;indexTextBox++,i++,j+=60)//creation des controles dans le formulaire |
---|
801 | for (int i=0;i<NB_ETAPES;indexTextBox++,i++,j+=60)//creation des controles dans le formulaire |
---|
802 | { |
---|
803 | int posX=100; |
---|
804 | pal->Add(new CLabelTextBox(Convert::ToString(i+1),posX+j,630,25,16,20)); |
---|
805 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
806 | Controls->Add(cltbPtr->GetLabel()); |
---|
807 | Controls->Add(cltbPtr->GetTextBox()); |
---|
808 | } |
---|
809 | |
---|
810 | // Temp_cond label tt seul |
---|
811 | Label* temp_cond= new Label(); |
---|
812 | temp_cond->Location = Point(50, 670); |
---|
813 | temp_cond->Size = System::Drawing::Size(70,16); |
---|
814 | temp_cond->Text = "Temp_cond";//zone de texte initialisée |
---|
815 | temp_cond->TextAlign = ContentAlignment::MiddleRight; |
---|
816 | Controls->Add(temp_cond); |
---|
817 | j=20;//depart affichage |
---|
818 | // for (int i=0;indexTextBox<58;indexTextBox++,i++,j+=60)//creation des controles dans le formulaire |
---|
819 | for (int i=0;i<NB_ETAPES;indexTextBox++,i++,j+=60)//creation des controles dans le formulaire |
---|
820 | { |
---|
821 | int posX=90; |
---|
822 | pal->Add(new CLabelTextBox(Convert::ToString(i+1),posX+j,670,25,16,40)); |
---|
823 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
824 | Controls->Add(cltbPtr->GetLabel()); |
---|
825 | Controls->Add(cltbPtr->GetTextBox()); |
---|
826 | } |
---|
827 | |
---|
828 | // status, N_Seqcond, DateD et heureD , DateF et HeureF labels tt seul |
---|
829 | Label* status= new Label(); |
---|
830 | status->Location = Point(370, 700); |
---|
831 | status->Size = System::Drawing::Size(65,16); |
---|
832 | status->Text = "status";//zone de texte initialisée |
---|
833 | status->TextAlign = ContentAlignment::MiddleRight; |
---|
834 | Controls->Add(status); |
---|
835 | Label* n_seqcond= new Label(); |
---|
836 | n_seqcond->Location = Point(450, 700); |
---|
837 | n_seqcond->Size = System::Drawing::Size(65,16); |
---|
838 | n_seqcond->Text = "N_Seqcond";//zone de texte initialisée |
---|
839 | n_seqcond->TextAlign = ContentAlignment::MiddleRight; |
---|
840 | Controls->Add(n_seqcond); |
---|
841 | Label* dateD= new Label(); |
---|
842 | dateD->Location = Point(510, 700); |
---|
843 | dateD->Size = System::Drawing::Size(65,16); |
---|
844 | dateD->Text = "DateD";//zone de texte initialisée |
---|
845 | dateD->TextAlign = ContentAlignment::MiddleRight; |
---|
846 | Controls->Add(dateD); |
---|
847 | Label* heureD= new Label(); |
---|
848 | heureD->Location = Point(580, 700); |
---|
849 | heureD->Size = System::Drawing::Size(65,16); |
---|
850 | heureD->Text = "HeureD";//zone de texte initialisée |
---|
851 | heureD->TextAlign = ContentAlignment::MiddleRight; |
---|
852 | Controls->Add(heureD); |
---|
853 | Label* dateF= new Label(); |
---|
854 | dateF->Location = Point(650, 700); |
---|
855 | dateF->Size = System::Drawing::Size(65,16); |
---|
856 | dateF->Text = "DateF";//zone de texte initialisée |
---|
857 | dateF->TextAlign = ContentAlignment::MiddleRight; |
---|
858 | Controls->Add(dateF); |
---|
859 | Label* heureF= new Label(); |
---|
860 | heureF->Location = Point(720, 700); |
---|
861 | heureF->Size = System::Drawing::Size(65,16); |
---|
862 | heureF->Text = "HeureF";//zone de texte initialisée |
---|
863 | heureF->TextAlign = ContentAlignment::MiddleRight; |
---|
864 | Controls->Add(heureF); |
---|
865 | j=330;//depart affichage |
---|
866 | // for (int i=0;indexTextBox<62;indexTextBox++,i++,j+=100)//creation des controles dans le formulaire |
---|
867 | for (int i=0;i<6;indexTextBox++,i++,j+=70)//creation des controles dans le formulaire |
---|
868 | { |
---|
869 | int posX=0; |
---|
870 | pal->Add(new CLabelTextBox("",posX+j,720,55,16,70)); |
---|
871 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
872 | Controls->Add(cltbPtr->GetTextBox()); |
---|
873 | } |
---|
874 | |
---|
875 | // Vides label tt seul |
---|
876 | Label* vides = new Label(); |
---|
877 | vides->Location = Point(50, 590); |
---|
878 | vides->Size = System::Drawing::Size(60,32); |
---|
879 | vides->Text = "Vides (10-9mbar)";//zone de texte initialisée |
---|
880 | vides->TextAlign = ContentAlignment::MiddleRight; |
---|
881 | Controls->Add(vides); |
---|
882 | j=40;//depart affichage |
---|
883 | for (int i=0;i<(NB_BANCS*3);indexTextBox++,i++,j+=60)//creation des controles dans le formulaire |
---|
884 | { |
---|
885 | int posX=70; |
---|
886 | pal->Add(new CLabelTextBox(nameLab_4[i],posX+j,590,10,16,50)); |
---|
887 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
888 | Controls->Add(cltbPtr->GetLabel()); |
---|
889 | Controls->Add(cltbPtr->GetTextBox()); |
---|
890 | } |
---|
891 | |
---|
892 | // Prc label tt seul |
---|
893 | Label* prc = new Label(); |
---|
894 | prc->Location = Point(50, 430); |
---|
895 | prc->Size = System::Drawing::Size(50,32); |
---|
896 | prc->Text = "Prc (kW)";//zone de texte initialisée |
---|
897 | prc->TextAlign = ContentAlignment::MiddleRight; |
---|
898 | Controls->Add(prc); |
---|
899 | j=100;//depart affichage |
---|
900 | for (int i=0;i<NB_BANCS;indexTextBox++,i++,j+=180)//creation des controles dans le formulaire |
---|
901 | { |
---|
902 | int posX=70; |
---|
903 | pal->Add(new CLabelTextBox(nameLab_3[i],posX+j,430,10,16,50)); |
---|
904 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
905 | Controls->Add(cltbPtr->GetLabel()); |
---|
906 | Controls->Add(cltbPtr->GetTextBox()); |
---|
907 | } |
---|
908 | |
---|
909 | // Pic label tt seul |
---|
910 | Label* pic = new Label(); |
---|
911 | pic->Location = Point(50, 470); |
---|
912 | pic->Size = System::Drawing::Size(50,32); |
---|
913 | pic->Text = "Pic (kW)";//zone de texte initialisée |
---|
914 | pic->TextAlign = ContentAlignment::MiddleRight; |
---|
915 | Controls->Add(pic); |
---|
916 | j=100;//depart affichage |
---|
917 | for (int i=0;i<NB_BANCS;indexTextBox++,i++,j+=180)//creation des controles dans le formulaire |
---|
918 | { |
---|
919 | int posX=70; |
---|
920 | pal->Add(new CLabelTextBox(nameLab_3[i],posX+j,470,10,16,50)); |
---|
921 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
922 | Controls->Add(cltbPtr->GetLabel()); |
---|
923 | Controls->Add(cltbPtr->GetTextBox()); |
---|
924 | } |
---|
925 | |
---|
926 | // Pch label tt seul |
---|
927 | Label* pch = new Label(); |
---|
928 | pch->Location = Point(50, 510); |
---|
929 | pch->Size = System::Drawing::Size(50,32); |
---|
930 | pch->Text = "Pch (kW)";//zone de texte initialisée |
---|
931 | pch->TextAlign = ContentAlignment::MiddleRight; |
---|
932 | Controls->Add(pch); |
---|
933 | j=100;//depart affichage |
---|
934 | for (int i=0;i<NB_BANCS;indexTextBox++,i++,j+=180)//creation des controles dans le formulaire |
---|
935 | { |
---|
936 | int posX=70; |
---|
937 | pal->Add(new CLabelTextBox(nameLab_3[i],posX+j,510,10,16,50)); |
---|
938 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
939 | Controls->Add(cltbPtr->GetLabel()); |
---|
940 | Controls->Add(cltbPtr->GetTextBox()); |
---|
941 | } |
---|
942 | |
---|
943 | // Ie_cur label tt seul |
---|
944 | Label* ie_cur = new Label(); |
---|
945 | ie_cur->Location = Point(50, 550); |
---|
946 | ie_cur->Size = System::Drawing::Size(50,32); |
---|
947 | ie_cur->Text = "Ie_cur (V)";//zone de texte initialisée |
---|
948 | ie_cur->TextAlign = ContentAlignment::MiddleRight; |
---|
949 | Controls->Add(ie_cur); |
---|
950 | j=100;//depart affichage |
---|
951 | for (int i=0;i<NB_BANCS;indexTextBox++,i++,j+=180)//creation des controles dans le formulaire |
---|
952 | { |
---|
953 | int posX=70; |
---|
954 | pal->Add(new CLabelTextBox(nameLab_3[i],posX+j,550,10,16,50)); |
---|
955 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
956 | Controls->Add(cltbPtr->GetLabel()); |
---|
957 | Controls->Add(cltbPtr->GetTextBox()); |
---|
958 | } |
---|
959 | |
---|
960 | // Num_P label tt seul |
---|
961 | Label* num_P = new Label(); |
---|
962 | num_P->Location = Point(50, 350); |
---|
963 | num_P->Size = System::Drawing::Size(50,32); |
---|
964 | num_P->Text = "Num_P";//zone de texte initialisée |
---|
965 | num_P->TextAlign = ContentAlignment::MiddleRight; |
---|
966 | Controls->Add(num_P); |
---|
967 | j=100;//depart affichage |
---|
968 | for (int i=0;i<NB_BANCS;indexTextBox++,i++,j+=180)//creation des controles dans le formulaire |
---|
969 | { |
---|
970 | int posX=70; |
---|
971 | pal->Add(new CLabelTextBox(nameLab_3[i],posX+j,350,10,16,50)); |
---|
972 | CLabelTextBox* cltbPtr = (CLabelTextBox *) pal->get_Item(indexTextBox); |
---|
973 | Controls->Add(cltbPtr->GetLabel()); |
---|
974 | Controls->Add(cltbPtr->GetTextBox()); |
---|
975 | } |
---|
976 | |
---|
977 | // crée un objet graphique |
---|
978 | Graphics* pg = this->CreateGraphics(); |
---|
979 | //crée un objet pen |
---|
980 | Pen* pen1 = new Pen(Color::Red); |
---|
981 | //trace une ligne |
---|
982 | pg->DrawLine(pen1,20,20,100,100); |
---|
983 | //dispose l'objet Graphics |
---|
984 | pg->Dispose(); |
---|
985 | |
---|
986 | // ajout du groupe dans le formulaire. |
---|
987 | Controls->Add(gboxC); |
---|
988 | |
---|
989 | /* |
---|
990 | // associe le gestionnaire au groupe d'options |
---|
991 | rb1->Click += new EventHandler(this, &MaDialogUser::Radio_Clicked); |
---|
992 | rb2->Click += new EventHandler(this, &MaDialogUser::Radio_Clicked); |
---|
993 | */ } |
---|
994 | |
---|
995 | void MaDialogUser::Setup_Buttons_Conditionning()//creation et definition des boutons |
---|
996 | { |
---|
997 | // ajoute bouton START |
---|
998 | btnStart = new Button(); |
---|
999 | btnStart->Text = S"MARCHE";//se sert de sa propriété Text pour definir son titre |
---|
1000 | btnStart->Size = System::Drawing::Size(70, 20);//taille du bouton en pixels |
---|
1001 | btnStart->Location = Point(70, 720);//emplacement |
---|
1002 | btnStart->Click += new EventHandler(this, &MaDialogUser::BtnStart_Clicked);//creation d'un objet EventHandler en.. |
---|
1003 | //..lui transmettant un ptr sur le bouotn et l'adresse de la fonction en charge de.. |
---|
1004 | //..l'evenement |
---|
1005 | Controls->Add(btnStart);//pour avertir le formulaire de la présence du bouton, on ajoute le bouton.. |
---|
1006 | //.. dans la collection des controles du formulaire |
---|
1007 | |
---|
1008 | // idem bouton STOP |
---|
1009 | btnStop = new Button(); |
---|
1010 | btnStop->Text = S"ARRET"; |
---|
1011 | btnStop->Size = System::Drawing::Size(70, 20); |
---|
1012 | btnStop->Location = Point(150, 720); |
---|
1013 | btnStop->Click += new EventHandler(this, &MaDialogUser::BtnStop_Clicked); |
---|
1014 | Controls->Add(btnStop); |
---|
1015 | |
---|
1016 | // idem bouton PAUSE |
---|
1017 | btnPause = new Button(); |
---|
1018 | btnPause->Text = S"PAUSE"; |
---|
1019 | btnPause->Size = System::Drawing::Size(70, 20); |
---|
1020 | btnPause->Location = Point(230, 720); |
---|
1021 | btnPause->Click += new EventHandler(this, &MaDialogUser::BtnPause_Clicked); |
---|
1022 | Controls->Add(btnPause); |
---|
1023 | |
---|
1024 | // idem bouton REPRISE |
---|
1025 | btnReprise = new Button(); |
---|
1026 | btnReprise->Text = S"REPRISE"; |
---|
1027 | btnReprise->Size = System::Drawing::Size(70, 20); |
---|
1028 | btnReprise->Location = Point(310, 720); |
---|
1029 | btnReprise->Click += new EventHandler(this, &MaDialogUser::BtnReprise_Clicked); |
---|
1030 | Controls->Add(btnReprise); |
---|
1031 | } |
---|
1032 | |
---|
1033 | void MaDialogUser::Radio_Clicked(Object* pSender, EventArgs* pArgs)//remplit automatiquement la zone de texte |
---|
1034 | { |
---|
1035 | if (pSender == rb1) |
---|
1036 | { |
---|
1037 | Console::WriteLine(S"MaDialogUser::Radio_Clicked : lecture activée..."); |
---|
1038 | Console::WriteLine(S"Main thread: Start a second thread."); |
---|
1039 | // Create the thread, passing a ThreadStart delegate that |
---|
1040 | // represents the ThreadReadModbus::ThreadProc method. |
---|
1041 | uThread = new Thread(new ThreadStart(0, &MaDialogUser::ThreadProc)); |
---|
1042 | // Start the thread. |
---|
1043 | uThread->Start(); |
---|
1044 | } |
---|
1045 | else if (pSender == rb2) |
---|
1046 | { |
---|
1047 | Console::WriteLine(S"MaDialogUser::Radio_Clicked : lecture désactivée..."); |
---|
1048 | if (uThread->IsAlive) |
---|
1049 | { |
---|
1050 | // Stop the thread. |
---|
1051 | uThread->Suspend(); |
---|
1052 | } |
---|
1053 | } |
---|
1054 | } |
---|
1055 | |
---|
1056 | void MaDialogUser::BtnStart_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 1 |
---|
1057 | { |
---|
1058 | // MessageBox::Show(S"ça marche!", S"bouton START...");//MessageBox fait partie de l'espace de noms Forms |
---|
1059 | //unique methode Show surchargée acceptant differents parametres |
---|
1060 | CLabelTextBox* cltbPtr; |
---|
1061 | for (int indexArrayList=0;(indexArrayList<MAX_NB_LABEL_TEXTBOX);indexArrayList++)//on cherche le LabelBox "MODE" |
---|
1062 | { |
---|
1063 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList); |
---|
1064 | if(String::Compare(cltbPtr->GetName(),"MODE")) |
---|
1065 | break;//on y est |
---|
1066 | if(indexArrayList==(MAX_NB_LABEL_TEXTBOX-1))return;//il faut sortir si non trouvé |
---|
1067 | } |
---|
1068 | if(String::Compare(cltbPtr->GetVal(),"PULSING")) |
---|
1069 | { |
---|
1070 | uint16_t tab_rp_registers[1] = { 0x2 }; |
---|
1071 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding..."); |
---|
1072 | int rc = modbus_write_registers(ctx, 2048,1 , tab_rp_registers); |
---|
1073 | if (rc != 48) |
---|
1074 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding failed..."); |
---|
1075 | } |
---|
1076 | } |
---|
1077 | |
---|
1078 | void MaDialogUser::BtnStop_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 1 |
---|
1079 | { |
---|
1080 | // MessageBox::Show(S"ça marche!", S"bouton STOP...");//MessageBox fait partie de l'espace de noms Forms |
---|
1081 | //unique methode Show surchargée acceptant differents parametres |
---|
1082 | CLabelTextBox* cltbPtr; |
---|
1083 | for (int indexArrayList=0;(indexArrayList<MAX_NB_LABEL_TEXTBOX);indexArrayList++)//on cherche le LabelBox "MODE" |
---|
1084 | { |
---|
1085 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList); |
---|
1086 | if(String::Compare(cltbPtr->GetName(),"MODE")) |
---|
1087 | break;//on y est |
---|
1088 | if(indexArrayList==(MAX_NB_LABEL_TEXTBOX-1))return;//il faut sortir si non trouvé |
---|
1089 | } |
---|
1090 | if(String::Compare(cltbPtr->GetVal(),"PULSING")) |
---|
1091 | { |
---|
1092 | uint16_t tab_rp_registers[1] = { 0x0 }; |
---|
1093 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding..."); |
---|
1094 | int rc = modbus_write_registers(ctx, 2048,1 , tab_rp_registers); |
---|
1095 | if (rc != 48) |
---|
1096 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding failed..."); |
---|
1097 | } |
---|
1098 | } |
---|
1099 | |
---|
1100 | void MaDialogUser::BtnPause_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 1 |
---|
1101 | { |
---|
1102 | // MessageBox::Show(S"ça marche!", S"bouton PAUSE...");//MessageBox fait partie de l'espace de noms Forms |
---|
1103 | //unique methode Show surchargée acceptant differents parametres |
---|
1104 | CLabelTextBox* cltbPtr; |
---|
1105 | for (int indexArrayList=0;(indexArrayList<MAX_NB_LABEL_TEXTBOX);indexArrayList++)//on cherche le LabelBox "MODE" |
---|
1106 | { |
---|
1107 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList); |
---|
1108 | if(String::Compare(cltbPtr->GetName(),"MODE")) |
---|
1109 | break;//on y est |
---|
1110 | if(indexArrayList==(MAX_NB_LABEL_TEXTBOX-1))return;//il faut sortir si non trouvé |
---|
1111 | } |
---|
1112 | if(String::Compare(cltbPtr->GetVal(),"PULSING")) |
---|
1113 | { |
---|
1114 | uint16_t tab_rp_registers[1] = { 0x1 }; |
---|
1115 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding..."); |
---|
1116 | int rc = modbus_write_registers(ctx, 2048,1 , tab_rp_registers); |
---|
1117 | if (rc != 48) |
---|
1118 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding failed..."); |
---|
1119 | } |
---|
1120 | } |
---|
1121 | |
---|
1122 | void MaDialogUser::BtnReprise_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 1 |
---|
1123 | { |
---|
1124 | // MessageBox::Show(S"ça marche!", S"bouton REPRISE...");//MessageBox fait partie de l'espace de noms Forms |
---|
1125 | //unique methode Show surchargée acceptant differents parametres |
---|
1126 | CLabelTextBox* cltbPtr; |
---|
1127 | for (int indexArrayList=0;(indexArrayList<MAX_NB_LABEL_TEXTBOX);indexArrayList++)//on cherche le LabelBox "MODE" |
---|
1128 | { |
---|
1129 | cltbPtr = (CLabelTextBox *) pal->get_Item(indexArrayList); |
---|
1130 | if(String::Compare(cltbPtr->GetName(),"MODE")) |
---|
1131 | break;//on y est |
---|
1132 | if(indexArrayList==(MAX_NB_LABEL_TEXTBOX-1))return;//il faut sortir si non trouvé |
---|
1133 | } |
---|
1134 | if(String::Compare(cltbPtr->GetVal(),"PULSING")) |
---|
1135 | { |
---|
1136 | uint16_t tab_rp_registers[1] = { 0x3 }; |
---|
1137 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding..."); |
---|
1138 | int rc = modbus_write_registers(ctx, 2048,1 , tab_rp_registers); |
---|
1139 | if (rc != 48) |
---|
1140 | Console::WriteLine(S"MaDialogUser::BtnStart_Clicked : write holding failed..."); |
---|
1141 | } |
---|
1142 | } |
---|
1143 | |
---|
1144 | |
---|
1145 | void AboutBox::OKButton_Clicked(Object* pSender,EventArgs* pArgs)//gestionnaire d'evenement de la boite dialogue |
---|
1146 | { |
---|
1147 | |
---|
1148 | //se contente de fermer le formulaire lorsqu'on clique sur le bouton |
---|
1149 | Close(); |
---|
1150 | } |
---|
1151 | |
---|
1152 | void MaDialog::OKMaDBtn_Clicked(Object* pSender,EventArgs* pArgs)//gestionnaire d'evenement de la boite dialogue |
---|
1153 | { |
---|
1154 | //fermer le formulaire lorsqu'on clique sur le bouton |
---|
1155 | Close(); |
---|
1156 | } |
---|
1157 | |
---|
1158 | AboutBox::AboutBox()//constructeur |
---|
1159 | { |
---|
1160 | // qqs propriétés |
---|
1161 | Text = S"A propos cxfel"; |
---|
1162 | FormBorderStyle = FormBorderStyle::Fixed3D;//impossible de modifier la taille |
---|
1163 | Size = System::Drawing::Size(300,150); |
---|
1164 | |
---|
1165 | // ajout de 2 labels au formulaire. |
---|
1166 | Label* label1 = new Label(); |
---|
1167 | label1->Text = "Application client XFEL"; |
---|
1168 | label1->Size = System::Drawing::Size(label1->PreferredWidth, |
---|
1169 | label1->PreferredHeight); |
---|
1170 | label1->Location = Point(20, 30); |
---|
1171 | |
---|
1172 | Label* label2 = new Label(); |
---|
1173 | label2->Text = "JC Marrucho, 2013"; |
---|
1174 | label2->Size = System::Drawing::Size(label1->PreferredWidth, |
---|
1175 | label1->PreferredHeight);//sert à modifier auto la taille des labels.. |
---|
1176 | //..selon le texte |
---|
1177 | label2->Location = Point(20, 30+label1->PreferredHeight+10);//sert à calculer la position du 2ème label |
---|
1178 | |
---|
1179 | // Ajoute les controles dans le formulaire |
---|
1180 | Controls->Add(label1); |
---|
1181 | Controls->Add(label2); |
---|
1182 | |
---|
1183 | // Ajout d'un bouton OK. |
---|
1184 | OKButton = new Button(); |
---|
1185 | OKButton->Text = S"OK"; |
---|
1186 | OKButton->DialogResult = System::Windows::Forms::DialogResult::OK;//renvoi de la valeur OK.. |
---|
1187 | //.. plus besoin d'associer le gestionnaire à sa fonction.. voir plus bas |
---|
1188 | OKButton->Size = System::Drawing::Size(40,25); |
---|
1189 | OKButton->Location = Point(240,85); |
---|
1190 | |
---|
1191 | //configure un gestionnaire : pas nécessaire si le formulaire renvoie une valeur.. voir + haut |
---|
1192 | //OKButton->Click += new EventHandler(this,&AboutBox::OKButton_Clicked); |
---|
1193 | |
---|
1194 | // Ajoute le bouton au formulaire. |
---|
1195 | Controls->Add(OKButton); |
---|
1196 | } |
---|
1197 | |
---|
1198 | |
---|
1199 | MaDialog::MaDialog() |
---|
1200 | { |
---|
1201 | // définit les paramètres du formulaire |
---|
1202 | Text = S"détails serveur"; |
---|
1203 | FormBorderStyle = FormBorderStyle::Fixed3D;//impossible de modifier la taille |
---|
1204 | Size = System::Drawing::Size(280,200); |
---|
1205 | |
---|
1206 | // Creation de tous les controles : TextBox pour io/port et ComboBox pour timeout |
---|
1207 | ipLabel = new Label(); |
---|
1208 | ipBox = new TextBox(); |
---|
1209 | portLabel = new Label(); |
---|
1210 | portBox = new TextBox(); |
---|
1211 | timeoutLabel = new Label(); |
---|
1212 | timeoutCombo = new ComboBox(); |
---|
1213 | OKBtn = new Button(); |
---|
1214 | CancelBtn = new Button(); |
---|
1215 | |
---|
1216 | // ipLabel et ipBox : label et zone de saisie sont placés l'un à côté de l'autre |
---|
1217 | ipLabel->Location = Point(16, 24); |
---|
1218 | ipLabel->Size = System::Drawing::Size(48, 16); |
---|
1219 | ipLabel->Text = "n°IP:";//zone de texte initialisée vide |
---|
1220 | ipLabel->TextAlign = ContentAlignment::MiddleRight; |
---|
1221 | ipBox->Location = Point(72, 24); |
---|
1222 | ipBox->Size = System::Drawing::Size(152, 20); |
---|
1223 | ipBox->Text = "";//zone de texte initialisée vide |
---|
1224 | |
---|
1225 | // portLabel et portBox |
---|
1226 | portLabel->Location = Point(16, 56); |
---|
1227 | portLabel->Size = System::Drawing::Size(48, 16); |
---|
1228 | portLabel->Text = "n°port:";//zone de texte initialisée vide |
---|
1229 | portLabel->TextAlign = ContentAlignment::MiddleRight; |
---|
1230 | portBox->Location = Point(72, 56); |
---|
1231 | portBox->Size = System::Drawing::Size(152, 20); |
---|
1232 | portBox->Text = "";//zone de texte initialisée |
---|
1233 | |
---|
1234 | // timeoutLabel et timeoutCombo : : liste déroulante spécifiant le tiemout et son label |
---|
1235 | timeoutLabel->Location = Point(16, 88); |
---|
1236 | timeoutLabel->Size = System::Drawing::Size(48, 16); |
---|
1237 | timeoutLabel->Text = "Timeout(ms):"; |
---|
1238 | timeoutLabel->TextAlign = ContentAlignment::MiddleRight; |
---|
1239 | timeoutCombo->DropDownWidth = 121; |
---|
1240 | timeoutCombo->Location = Point(72, 88); |
---|
1241 | timeoutCombo->Size = System::Drawing::Size(121, 21); |
---|
1242 | //5 items, pas de valeur par défaut |
---|
1243 | timeoutCombo->Items->Add(S"500"); |
---|
1244 | timeoutCombo->Items->Add(S"1000"); |
---|
1245 | timeoutCombo->Items->Add(S"1500"); |
---|
1246 | timeoutCombo->Items->Add(S"2000"); |
---|
1247 | timeoutCombo->Items->Add(S"3000"); |
---|
1248 | |
---|
1249 | // bouton OK |
---|
1250 | OKBtn->Location = Point(104, 136); |
---|
1251 | OKBtn->Name = "Bouton OK"; |
---|
1252 | OKBtn->Text = "OK"; |
---|
1253 | OKBtn->DialogResult = DialogResult::OK; |
---|
1254 | |
---|
1255 | // bouton Cancel |
---|
1256 | CancelBtn->Location = Point(192, 136); |
---|
1257 | CancelBtn->Name = "Bouton Cancel"; |
---|
1258 | CancelBtn->Text = "Annuler"; |
---|
1259 | CancelBtn->DialogResult = DialogResult::Cancel; |
---|
1260 | |
---|
1261 | // Ajoute les controles dans le formaulaire |
---|
1262 | Controls->Add(ipBox); |
---|
1263 | Controls->Add(portBox); |
---|
1264 | Controls->Add(ipLabel); |
---|
1265 | Controls->Add(portLabel); |
---|
1266 | Controls->Add(timeoutLabel); |
---|
1267 | Controls->Add(timeoutCombo); |
---|
1268 | Controls->Add(OKBtn); |
---|
1269 | Controls->Add(CancelBtn); |
---|
1270 | |
---|
1271 | //configure les 2 propriétés : AcceptButton contient la réf du bouton par défaut du formulaire.. |
---|
1272 | //..on peut cliquer sur le bouton OK ou bien sur la touche Entrée du clavier.. |
---|
1273 | //..referme aussi la boite car DialogResult renvoie OK |
---|
1274 | AcceptButton = OKBtn; |
---|
1275 | //CancelButton contient la réf du bouton associée à la touche Echap du clavier |
---|
1276 | CancelButton = CancelBtn; |
---|
1277 | |
---|
1278 | //gestionnnaire associé au bouton OK |
---|
1279 | OKBtn->Click += new EventHandler(this, &MaDialog::OKMaDBtn_Clicked); |
---|
1280 | } |
---|
1281 | |
---|
1282 | void MaDialog::setIp(String* theIp) |
---|
1283 | { |
---|
1284 | ipBox->Text = theIp; |
---|
1285 | } |
---|
1286 | |
---|
1287 | String* MaDialog::getIp() |
---|
1288 | { |
---|
1289 | return ipBox->Text; |
---|
1290 | } |
---|
1291 | |
---|
1292 | void MaDialog::setPort(String* thePort) |
---|
1293 | { |
---|
1294 | portBox->Text = thePort; |
---|
1295 | } |
---|
1296 | |
---|
1297 | String* MaDialog::getPort() |
---|
1298 | { |
---|
1299 | return portBox->Text; |
---|
1300 | } |
---|
1301 | |
---|
1302 | void MaDialog::setTimeout(int theTimeout) |
---|
1303 | { |
---|
1304 | timeoutCombo->SelectedIndex = theTimeout; |
---|
1305 | } |
---|
1306 | |
---|
1307 | int MaDialog::getTimeout() |
---|
1308 | { |
---|
1309 | return timeoutCombo->SelectedIndex; |
---|
1310 | } |
---|
1311 | |
---|
1312 | |
---|
1313 | CppForm::CppForm()//constructeur |
---|
1314 | { |
---|
1315 | // définit la légende du formulaire |
---|
1316 | //la propriété Text est héritée de Control |
---|
1317 | Text = S"XSUC"; |
---|
1318 | |
---|
1319 | // définit le style des bords |
---|
1320 | //la propriété FormBorder est membre de Form |
---|
1321 | FormBorderStyle = FormBorderStyle::Fixed3D; |
---|
1322 | |
---|
1323 | // Set up controls on the form. |
---|
1324 | Setup_Menu(); |
---|
1325 | Setup_Context_Menu(); |
---|
1326 | Setup_Buttons();//configure les boutons du formulaire |
---|
1327 | Setup_Label(); |
---|
1328 | // Setup_Group(); |
---|
1329 | // Setup_Combo(); |
---|
1330 | Setup_Text(); |
---|
1331 | |
---|
1332 | // pour agrandir la zone de saisie, on rajoute des pixels, par defaut 300x300 |
---|
1333 | // Size = System::Drawing::Size(450, 300); |
---|
1334 | Size = System::Drawing::Size(650, 500); |
---|
1335 | |
---|
1336 | } |
---|
1337 | |
---|
1338 | void CppForm::Btn1_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 1 |
---|
1339 | { |
---|
1340 | MessageBox::Show(S"ça marche!", S"Message...");//MessageBox fait partie de l'espace de noms Forms |
---|
1341 | //unique methode Show surchargée acceptant differents parametres |
---|
1342 | } |
---|
1343 | |
---|
1344 | |
---|
1345 | void CppForm::Btn2_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 2 |
---|
1346 | { |
---|
1347 | MessageBox::Show(S"ça marche aussi!", S"Message...");//MessageBox fait partie de l'espace de noms Forms |
---|
1348 | //unique methode Show surchargée acceptant differents parametres |
---|
1349 | } |
---|
1350 | |
---|
1351 | void CppForm::Btn3_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 3 |
---|
1352 | { |
---|
1353 | MessageBox::Show(S"connexion et lecture serveur", S"Message...");//MessageBox fait partie de l'espace de noms Forms |
---|
1354 | //unique methode Show surchargée acceptant differents parametres |
---|
1355 | } |
---|
1356 | |
---|
1357 | void CppForm::Btn4_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenements associés au bouton 4 |
---|
1358 | { |
---|
1359 | //crée la boite de dialogue utilisateur |
---|
1360 | CDialogConfig* box = new CDialogConfig(); |
---|
1361 | //affiche la boite de dialogue |
---|
1362 | if (box->ShowDialog() == DialogResult::OK) |
---|
1363 | { |
---|
1364 | //si la valeur OK est renvoyée, on affiche le nom |
---|
1365 | //MessageBox::Show(S"Ecriture"); |
---|
1366 | } |
---|
1367 | //unique methode Show surchargée acceptant differents parametres |
---|
1368 | } |
---|
1369 | |
---|
1370 | void CppForm::Combo1_SelChanged(Object* pSender, EventArgs* pArgs)//gestionnaire d'evenement associé à la liste deroulante |
---|
1371 | { |
---|
1372 | if (pSender == combo1) |
---|
1373 | { |
---|
1374 | // String* ps = String::Concat(S"New index is ", |
---|
1375 | // __box(combo1->SelectedIndex)->ToString()); |
---|
1376 | // MessageBox::Show(ps, S"Index Change"); |
---|
1377 | String* ps = __box(combo1->SelectedIndex)->ToString(); |
---|
1378 | if(String::Compare(ps,"1")==0) |
---|
1379 | { |
---|
1380 | Console::WriteLine(S"Main thread: Start a second thread."); |
---|
1381 | // Create the thread, passing a ThreadStart delegate that |
---|
1382 | // represents the ThreadReadModbus::ThreadProc method. |
---|
1383 | Thread *oThread = new Thread(new ThreadStart(0, &ThreadReadModbus::ThreadProc)); |
---|
1384 | // Start the thread. |
---|
1385 | oThread->Start(); |
---|
1386 | } |
---|
1387 | } |
---|
1388 | } |
---|
1389 | |
---|
1390 | void CppForm::MenuItem_Clicked(Object* pSender, EventArgs* pArgs)//gestionnaire des elements de menu |
---|
1391 | { |
---|
1392 | if (pSender == item1) |
---|
1393 | { |
---|
1394 | //affiche la boite de dialogue modale qui doit etre fermée avant de pouvoir revenir à l'application |
---|
1395 | MessageBox::Show(S"ITEM à propos", S"Menu"); |
---|
1396 | AboutBox* box = new AboutBox(); |
---|
1397 | box->ShowDialog(); |
---|
1398 | } |
---|
1399 | else if (pSender == item2) |
---|
1400 | { |
---|
1401 | // Exit application. |
---|
1402 | Application::Exit(); |
---|
1403 | } |
---|
1404 | else if (pSender == item11) |
---|
1405 | { |
---|
1406 | //crée la boite de dialogue |
---|
1407 | MaDialog* box = new MaDialog(); |
---|
1408 | //données initiales |
---|
1409 | /* String* path = new String("c:\\temp\\condip.txt.txt"); |
---|
1410 | if (!File::Exists(path)) |
---|
1411 | { |
---|
1412 | Console::WriteLine("le fichier n'existe pas!"); |
---|
1413 | } |
---|
1414 | */ |
---|
1415 | //lecture du n°IP dans le fichier condip |
---|
1416 | try |
---|
1417 | { |
---|
1418 | FileStream* fs = new FileStream("..\\condip.txt",FileMode::Open); |
---|
1419 | StreamReader* sr = new StreamReader(fs); |
---|
1420 | String* line = sr->ReadLine(); |
---|
1421 | box->setIp(line); |
---|
1422 | } |
---|
1423 | catch (System::Exception* pe) |
---|
1424 | { |
---|
1425 | Console::WriteLine(pe->ToString()); |
---|
1426 | } |
---|
1427 | // box->setIp(S"134.158.91.254"); |
---|
1428 | box->setPort(S"502"); |
---|
1429 | box->setTimeout(1); |
---|
1430 | //affiche la boite de dialogue |
---|
1431 | if (box->ShowDialog() == DialogResult::OK) |
---|
1432 | { |
---|
1433 | //si la valeur OK est renvoyée, on affiche le nom |
---|
1434 | MessageBox::Show(box->getIp(), S"le n° IP était..."); |
---|
1435 | } |
---|
1436 | |
---|
1437 | } |
---|
1438 | else if (pSender == anotherItem) |
---|
1439 | { |
---|
1440 | //crée la boite de dialogue utilisateur |
---|
1441 | MaDialogUser* box = new MaDialogUser(); |
---|
1442 | //données initiales |
---|
1443 | /* box->setIp(S"134.158.91.254"); |
---|
1444 | box->setPort(S"502"); |
---|
1445 | box->setTimeout(1); |
---|
1446 | */ //affiche la boite de dialogue |
---|
1447 | if (box->ShowDialog() == DialogResult::OK) |
---|
1448 | { |
---|
1449 | //si la valeur OK est renvoyée, on affiche le nom |
---|
1450 | MessageBox::Show(S"Lecture"); |
---|
1451 | } |
---|
1452 | } |
---|
1453 | else if (pSender == item1_1 || pSender == item1_2) |
---|
1454 | { |
---|
1455 | // modbus_t *ctx; |
---|
1456 | if(pSender == item1_1) |
---|
1457 | { |
---|
1458 | // ctx = (modbus_t *) malloc(sizeof(modbus_t)); |
---|
1459 | // Ex20cSquareRoot(4); |
---|
1460 | // char* ptr = GetHeure(1); |
---|
1461 | /* String* psone = String::Concat(S"il est ", GetHeure(1)); |
---|
1462 | MessageBox::Show(psone, S"heure"); |
---|
1463 | int* monInt = allou(); |
---|
1464 | int taille=sizeof(monInt); |
---|
1465 | Console::WriteLine(taille); |
---|
1466 | libere(monInt); |
---|
1467 | */ |
---|
1468 | //lecture du n°IP dans le fichier condip |
---|
1469 | String* lineIp; |
---|
1470 | try |
---|
1471 | { |
---|
1472 | FileStream* fs = new FileStream("..\\condip.txt",FileMode::Open); |
---|
1473 | StreamReader* sr = new StreamReader(fs); |
---|
1474 | lineIp = sr->ReadLine(); |
---|
1475 | } |
---|
1476 | catch (System::Exception* pe) |
---|
1477 | { |
---|
1478 | Console::WriteLine(pe->ToString()); |
---|
1479 | } |
---|
1480 | |
---|
1481 | Console::WriteLine(S"CppForm::MenuItem_Clicked : modbus_new_tcp..."); |
---|
1482 | // ctx = modbus_new_tcp("134.158.91.254", 502);//JCM |
---|
1483 | char* chaineChar = static_cast<char *>(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(lineIp).ToPointer()); |
---|
1484 | ctx = modbus_new_tcp(chaineChar,502);//JCM |
---|
1485 | modbus_set_debug(ctx, 1); |
---|
1486 | // modbus_set_error_recovery(ctx, |
---|
1487 | // MODBUS_ERROR_RECOVERY_LINK | |
---|
1488 | // MODBUS_ERROR_RECOVERY_PROTOCOL); |
---|
1489 | modbus_set_slave(ctx,1);//JCM: avec le serveur python slave=1 |
---|
1490 | if (modbus_connect(ctx) == -1) { |
---|
1491 | Console::WriteLine(modbus_strerror(errno)); |
---|
1492 | modbus_free(ctx); |
---|
1493 | } |
---|
1494 | } |
---|
1495 | else |
---|
1496 | { |
---|
1497 | modbus_free(ctx); |
---|
1498 | } |
---|
1499 | } |
---|
1500 | else if (pSender == fontDlgItem) |
---|
1501 | { |
---|
1502 | FontDialog* fd = new FontDialog(); |
---|
1503 | fd->Font = labelFont; |
---|
1504 | |
---|
1505 | if (fd->ShowDialog() == DialogResult::OK)//la police du label est modifiée selon le choix d el'uitlisateur |
---|
1506 | { |
---|
1507 | MessageBox::Show(fd->Font->Name, S"la police était..."); |
---|
1508 | labelFont = fd->Font; |
---|
1509 | theLabel->Font = labelFont; |
---|
1510 | } |
---|
1511 | } |
---|
1512 | else |
---|
1513 | MessageBox::Show(S"AUTRE ITEM", S"Menu"); |
---|
1514 | } |
---|
1515 | |
---|
1516 | void CppForm::Radio_Clicked(Object* pSender, EventArgs* pArgs)//remplit automatiquement la zone de texte |
---|
1517 | { |
---|
1518 | if (pSender == rb1) |
---|
1519 | { |
---|
1520 | text1->Text = "Read Coils choisi : \r\n\r\n" |
---|
1521 | "FC01"; |
---|
1522 | uint8_t tab_rp_bits[1]; |
---|
1523 | int rc = modbus_read_bits(ctx, 3000, 1, tab_rp_bits);////JCM : adresse coils=3000 |
---|
1524 | Console::WriteLine(S"CppForm::Radio_Clicked : read one coil..."); |
---|
1525 | if (rc != 1) |
---|
1526 | Console::WriteLine(S"CppForm::Radio_Clicked : read one coil failed..."); |
---|
1527 | } |
---|
1528 | else if (pSender == rb2) |
---|
1529 | { |
---|
1530 | text1->Text = "Write Coils choisi : \r\n\r\n" |
---|
1531 | "FC15"; |
---|
1532 | uint8_t tab_value[77];//JCM |
---|
1533 | modbus_set_bits_from_bytes(tab_value, 0, 77, UT_BITS_TAB); |
---|
1534 | printf("tab[0]=%d,tab[1]=%d,tab[2]=%d\n", tab_value[0], tab_value[1], tab_value[2]); |
---|
1535 | int rc = modbus_write_bits(ctx, 3000,//JCM : adresse coils=3000 |
---|
1536 | 77, tab_value); |
---|
1537 | if (rc != 77) |
---|
1538 | Console::WriteLine(S"CppForm::Radio_Clicked : write coil failed..."); |
---|
1539 | } |
---|
1540 | else if (pSender == rb3) |
---|
1541 | { |
---|
1542 | text1->Text = "Read Holdings choisi : \r\n\r\n" |
---|
1543 | "FC03"; |
---|
1544 | uint16_t tab_rp_registers[UT_REGISTERS_NB]; |
---|
1545 | int rc = modbus_read_registers(ctx, 2000,//JCM : adresse holding=2000 |
---|
1546 | UT_REGISTERS_NB, tab_rp_registers); |
---|
1547 | Console::WriteLine(S"CppForm::Radio_Clicked : read holding..."); |
---|
1548 | if (rc != UT_REGISTERS_NB) |
---|
1549 | Console::WriteLine(S"CppForm::Radio_Clicked : read holding failed..."); |
---|
1550 | } |
---|
1551 | else if (pSender == rb4) |
---|
1552 | { |
---|
1553 | text1->Text = "Write Holdings choisi :\r\n\r\n" |
---|
1554 | "FC16"; |
---|
1555 | Random* myRnd = new Random(); |
---|
1556 | float realToWrite, real = myRnd->NextDouble(); |
---|
1557 | printf("random = %f\n", real<0.5 ? realToWrite=-1000*real:realToWrite=1000*real); |
---|
1558 | |
---|
1559 | uint16_t tab_rp_registers[48]; |
---|
1560 | Console::WriteLine(S"CppForm::Radio_Clicked : write holding..."); |
---|
1561 | modbus_set_float(realToWrite, tab_rp_registers);//Pi_min |
---|
1562 | int rc = modbus_write_registers(ctx, 2118,48 , tab_rp_registers); |
---|
1563 | if (rc != 48) |
---|
1564 | Console::WriteLine(S"CppForm::Radio_Clicked : write holding failed..."); |
---|
1565 | } |
---|
1566 | } |
---|
1567 | |
---|
1568 | void CppForm::Setup_Buttons()//creation et definition du bouton |
---|
1569 | { |
---|
1570 | // ajoute un bouton |
---|
1571 | btn1 = new Button(); |
---|
1572 | btn1->Text = S"OK";//se sert de sa propriété Text pour definir son titre |
---|
1573 | |
---|
1574 | btn1->Size = System::Drawing::Size(70, 25);//taille du bouton en pixels |
---|
1575 | btn1->Location = Point(230, 400);//emplacement |
---|
1576 | // btn1->Font = new System::Drawing::Font(S"Verdana", 16, FontStyle::Bold);;//l'objet Font est sauvegardé dans l'objet LabelFont grâce au pointeur |
---|
1577 | // btn1->ForeColor = Color::Brown; |
---|
1578 | |
---|
1579 | btn1->Click += new EventHandler(this, &CppForm::Btn1_Clicked);//creation d'un objet EventHandler en.. |
---|
1580 | //..lui transmettant un ptr sur le bouotn et l'adresse de la fonction en charge de.. |
---|
1581 | //..l'evenement |
---|
1582 | |
---|
1583 | Controls->Add(btn1);//pour avertir le formulaire de la présence du bouton, on ajoute le bouton.. |
---|
1584 | //.. dans la collection des controles du formulaire |
---|
1585 | |
---|
1586 | // idem pour 2eme bouton |
---|
1587 | btn2 = new Button(); |
---|
1588 | btn2->Text = S"Annuler";//.. |
---|
1589 | |
---|
1590 | btn2->Size = System::Drawing::Size(70, 25);//.. |
---|
1591 | btn2->Location = Point(310, 400);//.. |
---|
1592 | btn2->Click += new EventHandler(this, &CppForm::Btn2_Clicked); |
---|
1593 | Controls->Add(btn2);//.. |
---|
1594 | //.. |
---|
1595 | |
---|
1596 | // idem pour 3eme bouton |
---|
1597 | btn3 = new Button(); |
---|
1598 | btn3->Text = S"Connexion";//.. |
---|
1599 | |
---|
1600 | btn3->Size = System::Drawing::Size(120, 25);//.. |
---|
1601 | btn3->Location = Point(50, 220);//.. |
---|
1602 | btn3->Font = new System::Drawing::Font(S"Verdana", 12, FontStyle::Bold);;//l'objet Font est sauvegardé dans l'objet LabelFont grâce au pointeur |
---|
1603 | btn3->ForeColor = Color::Brown; |
---|
1604 | |
---|
1605 | btn3->Click += new EventHandler(this, &CppForm::Btn3_Clicked); |
---|
1606 | Controls->Add(btn3);//.. |
---|
1607 | //.. |
---|
1608 | // idem pour 4eme bouton |
---|
1609 | btn4 = new Button(); |
---|
1610 | btn4->Text = S"Ecriture";//.. |
---|
1611 | |
---|
1612 | btn4->Size = System::Drawing::Size(120, 25);//.. |
---|
1613 | btn4->Location = Point(475, 220);//.. |
---|
1614 | btn4->Font = new System::Drawing::Font(S"Verdana", 12, FontStyle::Bold);;//l'objet Font est sauvegardé dans l'objet LabelFont grâce au pointeur |
---|
1615 | btn4->ForeColor = Color::Brown; |
---|
1616 | |
---|
1617 | btn4->Click += new EventHandler(this, &CppForm::Btn4_Clicked); |
---|
1618 | Controls->Add(btn4);//.. |
---|
1619 | //.. |
---|
1620 | |
---|
1621 | } |
---|
1622 | |
---|
1623 | void CppForm::Setup_Combo ()//configuration de la liste deroulmnte |
---|
1624 | { |
---|
1625 | // creation |
---|
1626 | combo1 = new ComboBox(); |
---|
1627 | combo1->DropDownStyle = ComboBoxStyle::DropDownList; |
---|
1628 | // combo1->Location = Point(20,180); |
---|
1629 | combo1->Location = Point(20,280); |
---|
1630 | |
---|
1631 | // pour ajuster la taille en fonction de la plus longue chaine |
---|
1632 | // la valeur 20 correspond à la taille du bouton situé à droite du bouton d'édition |
---|
1633 | Label* l1 = new Label(); |
---|
1634 | l1->Text = S"Automatique"; |
---|
1635 | combo1->Width = l1->PreferredWidth + 20; |
---|
1636 | |
---|
1637 | // ajout de qqs chaines et association avec tous les controles du formulaire |
---|
1638 | combo1->Items->Add(S"Manuel"); |
---|
1639 | combo1->Items->Add(S"Automatique"); |
---|
1640 | combo1->Items->Add(S"..."); |
---|
1641 | combo1->SelectedIndex = 0;//affiche la 1ere chaine par defaut |
---|
1642 | |
---|
1643 | // ajout du groupe dans le formulaire |
---|
1644 | Controls->Add(combo1); |
---|
1645 | |
---|
1646 | // associe le gestionnaire à liste deroulante. |
---|
1647 | combo1->SelectedIndexChanged += new EventHandler(this, &CppForm::Combo1_SelChanged); |
---|
1648 | } |
---|
1649 | |
---|
1650 | void CppForm::Setup_Context_Menu ()//menu contextuel |
---|
1651 | { |
---|
1652 | // Creation |
---|
1653 | popupMenu = new System::Windows::Forms::ContextMenu(); |
---|
1654 | |
---|
1655 | // Creation des items. |
---|
1656 | item_p1 = new MenuItem("UN"); |
---|
1657 | popupMenu->MenuItems->Add(item_p1); |
---|
1658 | item_p2 = new MenuItem("DEUX"); |
---|
1659 | popupMenu->MenuItems->Add(item_p2); |
---|
1660 | item_p3 = new MenuItem("TROIS"); |
---|
1661 | popupMenu->MenuItems->Add(item_p3); |
---|
1662 | |
---|
1663 | //associe le menu contextuel au formulaire |
---|
1664 | ContextMenu = popupMenu; |
---|
1665 | } |
---|
1666 | |
---|
1667 | void CppForm::Setup_Group ()//creation et configuration d'un groupe d'options |
---|
1668 | { |
---|
1669 | // Creation |
---|
1670 | gbox = new GroupBox(); |
---|
1671 | gbox->Text = S"Fonction Code"; |
---|
1672 | gbox->Size = System::Drawing::Size(200, 150);//taille du groupbox en pixels |
---|
1673 | gbox->Location = Point(20, 90); |
---|
1674 | |
---|
1675 | // Creation des boutons radio. |
---|
1676 | rb1 = new RadioButton(); |
---|
1677 | rb1->Text = S"Read Coils"; |
---|
1678 | rb1->Location = Point(10,25); |
---|
1679 | |
---|
1680 | rb2 = new RadioButton(); |
---|
1681 | rb2->Text = S"Write Coils"; |
---|
1682 | rb2->Location = Point(10,55); |
---|
1683 | |
---|
1684 | rb3 = new RadioButton(); |
---|
1685 | rb3->Text = S"Read Holdings"; |
---|
1686 | rb3->Location = Point(10,85); |
---|
1687 | // rb3->Checked = true;//c'est la valeur par defaut |
---|
1688 | |
---|
1689 | rb4 = new RadioButton(); |
---|
1690 | rb4->Text = S"Write Holdings"; |
---|
1691 | rb4->Location = Point(10,115); |
---|
1692 | rb4->Checked = true;//c'est la valeur par defaut |
---|
1693 | |
---|
1694 | // ajout des controles dans le groupe |
---|
1695 | gbox->Controls->Add(rb1); |
---|
1696 | gbox->Controls->Add(rb2); |
---|
1697 | gbox->Controls->Add(rb3); |
---|
1698 | gbox->Controls->Add(rb4); |
---|
1699 | |
---|
1700 | // ajout du groupe dans le formulaire. |
---|
1701 | Controls->Add(gbox); |
---|
1702 | |
---|
1703 | // associe le gestionnaire au groupe d'options |
---|
1704 | rb1->Click += new EventHandler(this, &CppForm::Radio_Clicked); |
---|
1705 | rb2->Click += new EventHandler(this, &CppForm::Radio_Clicked); |
---|
1706 | rb3->Click += new EventHandler(this, &CppForm::Radio_Clicked); |
---|
1707 | rb4->Click += new EventHandler(this, &CppForm::Radio_Clicked); |
---|
1708 | } |
---|
1709 | |
---|
1710 | void CppForm::Setup_Label()//description textuelle dans le formulaire |
---|
1711 | { |
---|
1712 | theLabel = new Label(); |
---|
1713 | theLabel->AutoSize = true; |
---|
1714 | |
---|
1715 | theLabel->Text = S" XFEL Supervision Client";//les espaces sont prévus pour inserer uen image |
---|
1716 | |
---|
1717 | // definition de la police |
---|
1718 | // labelFont = new System::Drawing::Font(S"Verdana", 20, FontStyle::Italic); |
---|
1719 | labelFont = new System::Drawing::Font(S"Arial", 20, FontStyle::Italic); |
---|
1720 | theLabel->Font = labelFont;//l'objet Font est sauvegardé dans l'objet LabelFont grâce au pointeur |
---|
1721 | theLabel->ForeColor = Color::Black; |
---|
1722 | |
---|
1723 | // taille et emplacement |
---|
1724 | // theLabel->Location = Point(300,20); |
---|
1725 | theLabel->Location = Point(125,40); |
---|
1726 | theLabel->Size = System::Drawing::Size(theLabel->PreferredWidth, |
---|
1727 | theLabel->PreferredHeight); |
---|
1728 | |
---|
1729 | // ajout de l'image |
---|
1730 | // Bitmap* theImage = new Bitmap("SAVE.BMP"); |
---|
1731 | Bitmap* theImage = new Bitmap("..//image1.BMP"); |
---|
1732 | theLabel->Image = theImage; |
---|
1733 | theLabel->ImageAlign = ContentAlignment::MiddleLeft; |
---|
1734 | |
---|
1735 | // ajout du label dans la collection des controles du formulaire |
---|
1736 | Controls->Add(theLabel); |
---|
1737 | } |
---|
1738 | |
---|
1739 | void CppForm::Setup_Menu()//barre de menu |
---|
1740 | { |
---|
1741 | // Creation de la barre de menu principal |
---|
1742 | menuBar = new MainMenu(); |
---|
1743 | |
---|
1744 | // Cree le menu fichier. |
---|
1745 | fileMenu = new MenuItem("&Fichier"); |
---|
1746 | menuBar->MenuItems->Add(fileMenu); |
---|
1747 | |
---|
1748 | // Cree les elements du menu et les affiche. |
---|
1749 | item1 = new MenuItem("&A propos..."); |
---|
1750 | item11 = new MenuItem("&MaDialogBox..."); |
---|
1751 | fontDlgItem = new MenuItem("&Choisir la police..."); |
---|
1752 | item2 = new MenuItem("S&ortie"); |
---|
1753 | fileMenu->MenuItems->Add(item1); |
---|
1754 | fileMenu->MenuItems->Add(item11); |
---|
1755 | fileMenu->MenuItems->Add(fontDlgItem); |
---|
1756 | fileMenu->MenuItems->Add(item2); |
---|
1757 | |
---|
1758 | // associe le gestionnaire ayx elements du menu. |
---|
1759 | item1->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1760 | item11->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1761 | fontDlgItem->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1762 | item2->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1763 | |
---|
1764 | // ajoute le menu principal dans le formulaire |
---|
1765 | Menu = menuBar; |
---|
1766 | |
---|
1767 | //,menu déroulant ajouté à la barre de menu, puis 2 éléments |
---|
1768 | actionMenu =new MenuItem("Action"); |
---|
1769 | menuBar->MenuItems->Add(actionMenu); |
---|
1770 | subMenu1=new MenuItem("Faire"); |
---|
1771 | actionMenu->MenuItems->Add(subMenu1); |
---|
1772 | //barre de séparation, le ptr n'est pas sauvegardé car le sépérateur ne peut être sélectionné |
---|
1773 | actionMenu->MenuItems->Add(new MenuItem("-")); |
---|
1774 | anotherItem=new MenuItem("lecture serveur"); |
---|
1775 | actionMenu->MenuItems->Add(anotherItem); |
---|
1776 | //crée les 2 élements du menu et les ajoute |
---|
1777 | item1_1 =new MenuItem("connexion serveur..."); |
---|
1778 | item1_2 = new MenuItem("deconnexion serveur..."); |
---|
1779 | subMenu1->MenuItems->Add(item1_1); |
---|
1780 | subMenu1->MenuItems->Add(item1_2); |
---|
1781 | //on pourrait aussi utiliser des propriétés pour afficher un syumbole.. |
---|
1782 | //..disant élémen tselectionné (Checked) et griser des éléments du menu (Enabled) |
---|
1783 | |
---|
1784 | // associe le gestionnaire aux elements du menu. |
---|
1785 | anotherItem->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1786 | item1_1->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1787 | item1_2->Click += new EventHandler(this, &CppForm::MenuItem_Clicked); |
---|
1788 | } |
---|
1789 | |
---|
1790 | void CppForm::Setup_Text()//controle d'edition |
---|
1791 | { |
---|
1792 | text1 = new TextBox(); |
---|
1793 | text1->Location = Point(200,110); |
---|
1794 | text1->Size = System::Drawing::Size(250,250); |
---|
1795 | text1->Multiline = true; |
---|
1796 | |
---|
1797 | text1->ReadOnly = true; |
---|
1798 | text1->Text = "Pour se connecter au Serveur : cliquer sur le bouton Connexion \r\n\r\n" |
---|
1799 | "Pour configurer des paramètres : cliquer sur le bouton Ecriture \r\n\r\n"; |
---|
1800 | |
---|
1801 | |
---|
1802 | Controls->Add(text1); |
---|
1803 | } |
---|