| 1 | #ifndef _CXFEL_H
 | 
|---|
| 2 | #define _CXFEL_H
 | 
|---|
| 3 | 
 | 
|---|
| 4 | #include "stdafx.h"
 | 
|---|
| 5 | 
 | 
|---|
| 6 | 
 | 
|---|
| 7 | #include <modbus.h>
 | 
|---|
| 8 | #include "modbus-private.h"
 | 
|---|
| 9 | #include "stdint.h"
 | 
|---|
| 10 | #include "unit-test.h"
 | 
|---|
| 11 | 
 | 
|---|
| 12 | #include "alloulibere.h"
 | 
|---|
| 13 | 
 | 
|---|
| 14 | //#define _INC_WINDOWS
 | 
|---|
| 15 | //#include <winsock2.h>
 | 
|---|
| 16 | //#include <windows.h>
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #using <mscorlib.dll>
 | 
|---|
| 19 | #using <System.dll>
 | 
|---|
| 20 | #using <System.Windows.Forms.dll>
 | 
|---|
| 21 | #using <System.Drawing.dll>//pour les controles bouton
 | 
|---|
| 22 | 
 | 
|---|
| 23 | using namespace System;
 | 
|---|
| 24 | using namespace System::ComponentModel;//contient des classes pour les composants et les contrôles
 | 
|---|
| 25 | using namespace System::Windows::Forms;//contient des classes dédiées à la génération des formulaires
 | 
|---|
| 26 | using namespace System::Drawing;//contient les classes Point et Size du bouton
 | 
|---|
| 27 | 
 | 
|---|
| 28 | using namespace System::Threading;
 | 
|---|
| 29 | using namespace System::Collections;
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #define NB_BANCS                                4
 | 
|---|
| 32 | #define NB_COUPLEURS                    8
 | 
|---|
| 33 | #define NB_ETAPES                               12
 | 
|---|
| 34 | #define MAX_NB_LABEL_TEXTBOX    500
 | 
|---|
| 35 | 
 | 
|---|
| 36 | #define MODBUS_SIZE_READ_COILS                  13
 | 
|---|
| 37 | #define MODBUS_SIZE_READ_HOLDINGS_LOW   82
 | 
|---|
| 38 | #define MODBUS_SIZE_READ_HOLDINGS_HIGH  125
 | 
|---|
| 39 | 
 | 
|---|
| 40 | #define MODBUS_BASEADR_COILS                    3000
 | 
|---|
| 41 | #define MODBUS_BASEADR_LOW_HOLDINGS             2000
 | 
|---|
| 42 | #define MODBUS_BASEADR_HIGH_HOLDINGS    2082
 | 
|---|
| 43 | 
 | 
|---|
| 44 | __gc public class CGroupBox : public Form {
 | 
|---|
| 45 | private:
 | 
|---|
| 46 |         String* name;
 | 
|---|
| 47 | //      int labPosX, labPosY;
 | 
|---|
| 48 |         Label* labNumP;
 | 
|---|
| 49 |         Label* labNumC1;
 | 
|---|
| 50 |         Label* labNumC2;
 | 
|---|
| 51 |         TextBox* valNumP;
 | 
|---|
| 52 |         TextBox* valNumC1;
 | 
|---|
| 53 |         TextBox* valNumC2;
 | 
|---|
| 54 |         GroupBox* gbox;
 | 
|---|
| 55 | 
 | 
|---|
| 56 |         Button* appliquerBtn;
 | 
|---|
| 57 | 
 | 
|---|
| 58 |         void AppliquerBtn_Clicked(Object* pSender,EventArgs* pArgs);
 | 
|---|
| 59 | public:
 | 
|---|
| 60 |         CGroupBox(String* gname, int posX, int posY);
 | 
|---|
| 61 |         //CGROUPBox(uint16_t *tab_rp_registers_low,uint16_t *tab_rp_registers_high);
 | 
|---|
| 62 | 
 | 
|---|
| 63 |         GroupBox* GetGroupBox();
 | 
|---|
| 64 |         Label* GetLabelNumP();
 | 
|---|
| 65 |         Label* GetLabelNumC1();
 | 
|---|
| 66 |         Label* GetLabelNumC2();
 | 
|---|
| 67 | //      TextBox* GetTextBox();
 | 
|---|
| 68 | //      void SetVal(String*);
 | 
|---|
| 69 | protected:
 | 
|---|
| 70 |         static int nbInstance=0;//variable de classe
 | 
|---|
| 71 | };
 | 
|---|
| 72 | 
 | 
|---|
| 73 | //classe boite de dialogue avec utilisation de données
 | 
|---|
| 74 | __gc public class CDialogConfig : public Form {
 | 
|---|
| 75 | public:
 | 
|---|
| 76 |         CDialogConfig();
 | 
|---|
| 77 |         CDialogConfig(uint16_t *tab_rp_registers_low,uint16_t *tab_rp_registers_high);
 | 
|---|
| 78 |         String* getTp_max();
 | 
|---|
| 79 | 
 | 
|---|
| 80 | protected ://privé sauf au niveau des classes dérivées
 | 
|---|
| 81 |         String* name;
 | 
|---|
| 82 |         static String* gname[] = {"a","b","c","d" };
 | 
|---|
| 83 |         int indexGroupBox;//nb de GroupBox
 | 
|---|
| 84 | 
 | 
|---|
| 85 | private://données avec controle, label, bouton OK, textBox... 
 | 
|---|
| 86 |     Button* sortirBtn;
 | 
|---|
| 87 | 
 | 
|---|
| 88 |         GroupBox* gboxPtr;
 | 
|---|
| 89 |         static ArrayList* pal; 
 | 
|---|
| 90 | 
 | 
|---|
| 91 |         Label* labTp_max;
 | 
|---|
| 92 |         TextBox* valTp_max;
 | 
|---|
| 93 |         Label* labN_cur;
 | 
|---|
| 94 |         ComboBox* valN_cur;
 | 
|---|
| 95 |         Button* btnAppliquer;
 | 
|---|
| 96 | 
 | 
|---|
| 97 | private: 
 | 
|---|
| 98 |         void SortirBtn_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 99 |         void BtnAppliquer_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 100 | };
 | 
|---|
| 101 | 
 | 
|---|
| 102 | 
 | 
|---|
| 103 | __gc public class CLabelTextBox : public Form {
 | 
|---|
| 104 | private:
 | 
|---|
| 105 |         String* name;
 | 
|---|
| 106 |         int labPosX, labPosY;
 | 
|---|
| 107 |         int labSizeX, labSizeY;
 | 
|---|
| 108 |         Label* lab;
 | 
|---|
| 109 |         TextBox* val;
 | 
|---|
| 110 | public:
 | 
|---|
| 111 |         CLabelTextBox(String* lab, int posX, int posY, int sizeX, int sizeY, int sizeText);
 | 
|---|
| 112 |         Label* GetLabel();
 | 
|---|
| 113 |         TextBox* GetTextBox();
 | 
|---|
| 114 |         void SetVal(String*);
 | 
|---|
| 115 |         String* GetVal();
 | 
|---|
| 116 |         String* GetName();
 | 
|---|
| 117 |         void SetColor(int);
 | 
|---|
| 118 | protected:
 | 
|---|
| 119 |         static int nbInstance=0;//variable de classe
 | 
|---|
| 120 | };
 | 
|---|
| 121 | 
 | 
|---|
| 122 | //classe boite de dialogue avec utilisation de données
 | 
|---|
| 123 | __gc public class MaDialogUser : public Form {
 | 
|---|
| 124 | public:
 | 
|---|
| 125 |     MaDialogUser();
 | 
|---|
| 126 | 
 | 
|---|
| 127 | protected ://privé sauf au niveau des classes dérivées
 | 
|---|
| 128 |         String* name;
 | 
|---|
| 129 |         static String* nameLab_1[] = { "dtp(sec)","dt(sec)","dP(dB)","dPSecu(dB)","Nbal",
 | 
|---|
| 130 |                 "P_cde(dBm)","Pp(kW)","Nbal_max","Fr(Hz)","N_cur",
 | 
|---|
| 131 |                 "SVd(10-9mbar)","SVfin(10-9mbar)","SV1(10-9mbar)","SV2(10-9mbar)","V_cur(10-9mbar)",
 | 
|---|
| 132 |                 "Pi_min(kW)","Timer(min)","SVil(10-9mbar)","Sleil(mA)","STc(°C)",
 | 
|---|
| 133 |                 "Eil","Nil","Nil_stat","P_last(dBm)","N_last","dPil(dB)"};
 | 
|---|
| 134 | 
 | 
|---|
| 135 |         static String* nameLab_2[] = {"1a","2a","1b","2b","1c","2c","1d","2d" };
 | 
|---|
| 136 | 
 | 
|---|
| 137 |         static String* nameLab_3[] = {"a","b","c","d" };
 | 
|---|
| 138 | 
 | 
|---|
| 139 |         static String* nameLab_4[] = {"a","a","a","b","b","b","c","c","c","d","d","d" };
 | 
|---|
| 140 | 
 | 
|---|
| 141 |         static String* nameLab_5[] = {"N_cur","Ln(us)","Tp_max(h)","Pi_max(kW)"};
 | 
|---|
| 142 | 
 | 
|---|
| 143 |         static String* nameLab_6[] = {"1","2","3","4","5","6","7","8"};
 | 
|---|
| 144 | 
 | 
|---|
| 145 |         int indexTextBox;//nb de TextBox
 | 
|---|
| 146 |         int indexTextBoxSave;//nb de TextBox après conditionning
 | 
|---|
| 147 | 
 | 
|---|
| 148 | private://données avec controle, label, bouton OK, textBox... 
 | 
|---|
| 149 |     Button* OKBtn;
 | 
|---|
| 150 |     Button* CancelBtn;
 | 
|---|
| 151 |         Button* EcritureBtn;
 | 
|---|
| 152 | 
 | 
|---|
| 153 |         GroupBox* gbox;
 | 
|---|
| 154 |         RadioButton* rb1;//oui
 | 
|---|
| 155 |     RadioButton* rb2;//non
 | 
|---|
| 156 | 
 | 
|---|
| 157 |         Thread* uThread;
 | 
|---|
| 158 | 
 | 
|---|
| 159 |         static ArrayList* pal; 
 | 
|---|
| 160 |         Label* lblPtr;
 | 
|---|
| 161 |         TextBox* tbxPtr;
 | 
|---|
| 162 | 
 | 
|---|
| 163 |         static Button* btnStart;
 | 
|---|
| 164 |         static Button* btnStop;
 | 
|---|
| 165 |         static Button* btnPause;
 | 
|---|
| 166 |         static Button* btnReprise;//ces 4 controles bouton sont membres de System::Windows::Forms
 | 
|---|
| 167 | 
 | 
|---|
| 168 | private: 
 | 
|---|
| 169 |         void OKMaDBtn_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 170 |         void Radio_Clicked(Object* pSender, EventArgs* pArgs);//remplit automatiquement la zone de texte
 | 
|---|
| 171 |         void Setup_Group ();//creation et configuration d'un groupe d'options
 | 
|---|
| 172 |         void Setup_Group_Conditionning ();//creation et configuration d'un groupe d'options
 | 
|---|
| 173 |     void Setup_Buttons_Conditionning();//creation et definition des boutons
 | 
|---|
| 174 |     void BtnStart_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 1
 | 
|---|
| 175 |     void BtnStop_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 2
 | 
|---|
| 176 |         void BtnPause_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 3
 | 
|---|
| 177 |         void BtnReprise_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 4
 | 
|---|
| 178 | 
 | 
|---|
| 179 |         void EcritureBtn_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 180 | 
 | 
|---|
| 181 |         static void ThreadProc();
 | 
|---|
| 182 |         static float PermutToReversed(uint16_t* tab_rp_registers,int index);//permut le float32 en float32 Reverse
 | 
|---|
| 183 | };
 | 
|---|
| 184 | 
 | 
|---|
| 185 | 
 | 
|---|
| 186 | //classe boite de dialogue : c'est un formulaire comme un autre.. à l'affichage près
 | 
|---|
| 187 | __gc public class AboutBox : public Form {
 | 
|---|
| 188 | 
 | 
|---|
| 189 | private: 
 | 
|---|
| 190 |         void OKButton_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 191 |  
 | 
|---|
| 192 | private:
 | 
|---|
| 193 |     Button* OKButton;
 | 
|---|
| 194 | 
 | 
|---|
| 195 | public:
 | 
|---|
| 196 |     AboutBox();//constructeur
 | 
|---|
| 197 | 
 | 
|---|
| 198 | };
 | 
|---|
| 199 | 
 | 
|---|
| 200 | //classe boite de dialogue avec utilisation de données
 | 
|---|
| 201 | __gc public class MaDialog : public Form {
 | 
|---|
| 202 | public:
 | 
|---|
| 203 |     MaDialog();
 | 
|---|
| 204 | 
 | 
|---|
| 205 | public://permet au code appelant de recuperer et modifier les données
 | 
|---|
| 206 |     void setIp(String* theIp);
 | 
|---|
| 207 |     String* getIp();
 | 
|---|
| 208 |     void setPort(String* thePort);
 | 
|---|
| 209 |     String* getPort();
 | 
|---|
| 210 |     void setTimeout(int theTimeout);
 | 
|---|
| 211 |     int getTimeout();
 | 
|---|
| 212 | 
 | 
|---|
| 213 | private://données (ip/port/tiemout) avec controle, label, bouton OK et Cancel
 | 
|---|
| 214 |     Label* ipLabel;
 | 
|---|
| 215 |     TextBox* ipBox;
 | 
|---|
| 216 |     Label* portLabel;
 | 
|---|
| 217 |     TextBox* portBox;
 | 
|---|
| 218 |     Label* timeoutLabel;
 | 
|---|
| 219 |     ComboBox* timeoutCombo;
 | 
|---|
| 220 | 
 | 
|---|
| 221 |     Button* OKBtn;
 | 
|---|
| 222 |     Button* CancelBtn;
 | 
|---|
| 223 | 
 | 
|---|
| 224 | private: 
 | 
|---|
| 225 |         void OKMaDBtn_Clicked(Object* pSender,EventArgs* pArgs);//gestionnaire d'evenement de la boite dialogue
 | 
|---|
| 226 | 
 | 
|---|
| 227 |     };
 | 
|---|
| 228 | 
 | 
|---|
| 229 | //classe managée du formulaire : __gc hérite de la classe System::Windows::Forms::Form
 | 
|---|
| 230 | __gc public class CppForm : public Form {
 | 
|---|
| 231 | private:
 | 
|---|
| 232 |     Button* btn1;//ces controles bouton sont membres de System::Windows::Forms
 | 
|---|
| 233 |     Button* btn2;
 | 
|---|
| 234 |     Button* btn3;
 | 
|---|
| 235 |         Button* btn4;
 | 
|---|
| 236 | 
 | 
|---|
| 237 |         Label* theLabel;
 | 
|---|
| 238 | 
 | 
|---|
| 239 |         //groupe d'options avec 3 cases
 | 
|---|
| 240 |         GroupBox* gbox;
 | 
|---|
| 241 |     RadioButton* rb1;
 | 
|---|
| 242 |     RadioButton* rb2;
 | 
|---|
| 243 |     RadioButton* rb3;
 | 
|---|
| 244 |         RadioButton* rb4;
 | 
|---|
| 245 | 
 | 
|---|
| 246 |     ComboBox* combo1;
 | 
|---|
| 247 | 
 | 
|---|
| 248 |     TextBox* text1;
 | 
|---|
| 249 |     
 | 
|---|
| 250 |         MainMenu* menuBar;//barre de menu
 | 
|---|
| 251 |     MenuItem* fileMenu;//menu deroulant
 | 
|---|
| 252 |     MenuItem* item1;//element du menu
 | 
|---|
| 253 |     MenuItem* item2;//element du menu
 | 
|---|
| 254 |     System::Windows::Forms::ContextMenu* popupMenu;
 | 
|---|
| 255 |     MenuItem* item_p1;
 | 
|---|
| 256 |     MenuItem* item_p2;
 | 
|---|
| 257 |     MenuItem* item_p3;
 | 
|---|
| 258 | 
 | 
|---|
| 259 |         MenuItem* item11;//pour afficher la boite de dialogue
 | 
|---|
| 260 | 
 | 
|---|
| 261 |         MenuItem* fontDlgItem;//élément du menu Fichier
 | 
|---|
| 262 | 
 | 
|---|
| 263 |         //ss menus
 | 
|---|
| 264 |         MenuItem* actionMenu;
 | 
|---|
| 265 |         MenuItem* subMenu1;
 | 
|---|
| 266 |         MenuItem* anotherItem;
 | 
|---|
| 267 |         MenuItem* item1_1;
 | 
|---|
| 268 |         MenuItem* item1_2;
 | 
|---|
| 269 | 
 | 
|---|
| 270 |         System::Drawing::Font* labelFont;//pour afficher unr boite de dialogue Font pour choisir une police
 | 
|---|
| 271 | 
 | 
|---|
| 272 | public:
 | 
|---|
| 273 |     CppForm();//constructeur
 | 
|---|
| 274 | 
 | 
|---|
| 275 | private:
 | 
|---|
| 276 |     void Btn1_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 1
 | 
|---|
| 277 |         void Btn2_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 2
 | 
|---|
| 278 |         void Btn3_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 3
 | 
|---|
| 279 |         void Btn4_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenements associés au bouton 4
 | 
|---|
| 280 |     void Combo1_SelChanged(Object* pSender, EventArgs* pArgs);//gestionnaire d'evenement associé à la liste deroulante
 | 
|---|
| 281 |     void MenuItem_Clicked(Object* pSender, EventArgs* pArgs);//gestionnaire des elements de menu
 | 
|---|
| 282 |     void Radio_Clicked(Object* pSender, EventArgs* pArgs);//remplit automatiquement la zone de texte
 | 
|---|
| 283 |     void Setup_Buttons();//creation et definition du bouton
 | 
|---|
| 284 |     void Setup_Combo ();//configuration de la liste deroulmnte
 | 
|---|
| 285 |     void Setup_Context_Menu ();//menu contextuel
 | 
|---|
| 286 |     void Setup_Group ();//creation et configuration d'un groupe d'options
 | 
|---|
| 287 |     void Setup_Label();//description textuelle dans le formulaire
 | 
|---|
| 288 |     void Setup_Menu();//barre de menu
 | 
|---|
| 289 |     void Setup_Text();//controle d'edition
 | 
|---|
| 290 | };
 | 
|---|
| 291 | 
 | 
|---|
| 292 | 
 | 
|---|
| 293 | #endif
 | 
|---|
| 294 | 
 | 
|---|
| 295 | 
 | 
|---|
| 296 | 
 | 
|---|