Initial commit with my code directory
This commit is contained in:
		
							
								
								
									
										777
									
								
								code_JMW/Unit1.pas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										777
									
								
								code_JMW/Unit1.pas
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,777 @@ | ||||
| unit Unit1; | ||||
|  | ||||
| interface | ||||
|  | ||||
| uses | ||||
|   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | ||||
|   Dialogs, Menus, ExtCtrls, StdCtrls, Buttons, | ||||
|   UInit, UDessin, Uedit, UES, UDessinComposant, UPage, Spin, UExec, UTest, | ||||
|   ExtDlgs; | ||||
|  | ||||
| type | ||||
|   TForm1 = class(TForm) | ||||
|     Pnl_Haut: TPanel; | ||||
|     MainMenu: TMainMenu; | ||||
|     Fichier1: TMenuItem; | ||||
|     Memo1: TMemo; | ||||
|     Nouveau: TMenuItem; | ||||
|     M_Ouvrir: TMenuItem; | ||||
|     M_Enregistrer_sous: TMenuItem; | ||||
|     Pnl_Composants: TPanel; | ||||
|     Im_al1: TImage; | ||||
|     Im_al2: TImage; | ||||
|     Im_al3: TImage; | ||||
|     Im_cx: TImage; | ||||
|     Im_rl4: TImage; | ||||
|     Im_rl1: TImage; | ||||
|     Im_rl10: TImage; | ||||
|     Im_rl7: TImage; | ||||
|     Im_rl8: TImage; | ||||
|     Im_rl5: TImage; | ||||
|     Editer: TMenuItem; | ||||
|     M_Affichage: TMenuItem; | ||||
|     LoupeAg: TMenuItem; | ||||
|     LoupeRed: TMenuItem; | ||||
|     Grille: TMenuItem; | ||||
|     Taille_normale: TMenuItem; | ||||
|     Im_rl3: TImage; | ||||
|     Im_rl2: TImage; | ||||
|     Im_rl6: TImage; | ||||
|     Im_rl9: TImage; | ||||
|     Im_rl11: TImage; | ||||
|     Im_ct1: TImage; | ||||
|     Zoom_Max: TMenuItem; | ||||
|     Label1: TLabel; | ||||
|     Im_ct2: TImage; | ||||
|     Im_ct4: TImage; | ||||
|     Im_ct3: TImage; | ||||
|     Im_ct6: TImage; | ||||
|     Im_ct5: TImage; | ||||
|     OpenDialog1: TOpenDialog; | ||||
|     SaveDialog: TSaveDialog; | ||||
|     Im_ct7: TImage; | ||||
|     Im_ct8: TImage; | ||||
|     Im_ct9: TImage; | ||||
|     Zoom_min: TMenuItem; | ||||
|     M_Decalage: TMenuItem; | ||||
|     Vers_haut: TMenuItem; | ||||
|     Vers_bas: TMenuItem; | ||||
|     Vers_gauche: TMenuItem; | ||||
|     Vers_droite: TMenuItem; | ||||
|     Pnl_Image: TPanel; | ||||
|     Image: TImage; | ||||
|     SB_Hor: TScrollBar; | ||||
|     SB_Ver: TScrollBar; | ||||
|     Im_cp1: TImage; | ||||
|     Im_ct10: TImage; | ||||
|     Button1: TButton; | ||||
|     Executer: TMenuItem; | ||||
|     Pnl_Editer: TPanel; | ||||
|     BBtn_Supprime: TBitBtn; | ||||
|     SBtn_Selection: TSpeedButton; | ||||
|     SBtn_Deplace: TSpeedButton; | ||||
|     SBtn_Compo: TSpeedButton; | ||||
|     SBtn_Relier: TSpeedButton; | ||||
|     BBtn_Gauche: TBitBtn; | ||||
|     BBtn_Haut: TBitBtn; | ||||
|     BBtn_Bas: TBitBtn; | ||||
|     BBtn_Droite: TBitBtn; | ||||
|     SBtn_Label: TSpeedButton; | ||||
|     Pnl_Contact: TPanel; | ||||
|     CB_C_Manuel: TCheckBox; | ||||
|     CB_C_EtatI: TCheckBox; | ||||
|     Label2: TLabel; | ||||
|     Btn_C_ok: TButton; | ||||
|     Im_ct11: TImage; | ||||
|     Im_ct12: TImage; | ||||
|     Im_ct13: TImage; | ||||
|     Im_ct14: TImage; | ||||
|     Label7: TLabel; | ||||
|     CO_C_Nom: TComboBox; | ||||
|     CB_C_Visible: TCheckBox; | ||||
|     Label8: TLabel; | ||||
|     SP_C_dx: TSpinEdit; | ||||
|     Label9: TLabel; | ||||
|     SP_C_dy: TSpinEdit; | ||||
|     Timer1: TTimer; | ||||
|     Noir1: TMenuItem; | ||||
|     Potentiels1: TMenuItem; | ||||
|     Courants1: TMenuItem; | ||||
|     Im_ct15: TImage; | ||||
|     N2: TMenuItem; | ||||
|     VisuelRelais: TMenuItem; | ||||
|     Im_rl12: TImage; | ||||
|     Im_la1: TImage; | ||||
|     Im_la2: TImage; | ||||
|     Pnl_Lampe: TPanel; | ||||
|     Label11: TLabel; | ||||
|     Label12: TLabel; | ||||
|     Label13: TLabel; | ||||
|     Label14: TLabel; | ||||
|     ED_L_Nom: TEdit; | ||||
|     Btn_L_Ok: TButton; | ||||
|     SP_L_dx: TSpinEdit; | ||||
|     SP_L_dy: TSpinEdit; | ||||
|     CB_L_Visible: TCheckBox; | ||||
|     Pnl_Relais: TPanel; | ||||
|     Label3: TLabel; | ||||
|     Label4: TLabel; | ||||
|     Label5: TLabel; | ||||
|     Label6: TLabel; | ||||
|     Label10: TLabel; | ||||
|     ED_R_Nom: TEdit; | ||||
|     CB_R_EtatI: TCheckBox; | ||||
|     Btn_R_Ok: TButton; | ||||
|     SP_R_dx: TSpinEdit; | ||||
|     SP_R_dy: TSpinEdit; | ||||
|     CB_R_Visible: TCheckBox; | ||||
|     ED_R_Tempo: TEdit; | ||||
|     PNL_L0: TPanel; | ||||
|     PNL_L1: TPanel; | ||||
|     Label15: TLabel; | ||||
|     Label16: TLabel; | ||||
|     ColorDialog1: TColorDialog; | ||||
|     TmrPulse: TTimer; | ||||
|     SavePictureDialog1: TSavePictureDialog; | ||||
|     EnregistrerImage1: TMenuItem; | ||||
|     Visuelinteractif: TMenuItem; | ||||
|     Im_ct16: TImage; | ||||
|     Im_ct17: TImage; | ||||
|     Zoomajuster1: TMenuItem; | ||||
|     Memo2: TMemo; | ||||
|     Panel1: TPanel; | ||||
|     Button2: TButton; | ||||
|     Button4: TButton; | ||||
|     Button5: TButton; | ||||
|     Button3: TButton; | ||||
|     Button6: TButton; | ||||
|     Button7: TButton; | ||||
|     Button8: TButton; | ||||
|     Button9: TButton; | ||||
|     procedure FormActivate(Sender: TObject); | ||||
|     procedure EditerClick(Sender: TObject); | ||||
|     procedure ImageDragOver(Sender, Source: TObject; X, Y: Integer;  State: TDragState; var Accept: Boolean); | ||||
|     procedure ImageDragDrop(Sender, Source: TObject; X, Y: Integer); | ||||
|     procedure LoupeAgClick(Sender: TObject); | ||||
|     procedure LoupeRedClick(Sender: TObject); | ||||
|     procedure Taille_normaleClick(Sender: TObject); | ||||
|     procedure GrilleClick(Sender: TObject); | ||||
|     procedure Zoom_MaxClick(Sender: TObject); | ||||
|     procedure ImageMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer); | ||||
|     procedure M_Enregistrer_sousClick(Sender: TObject); | ||||
|     procedure M_OuvrirClick(Sender: TObject); | ||||
|     procedure ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); | ||||
|     procedure ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); | ||||
|     procedure NouveauClick(Sender: TObject); | ||||
|     procedure Zoom_minClick(Sender: TObject); | ||||
|     procedure Vers_hautClick(Sender: TObject); | ||||
|     procedure Vers_gaucheClick(Sender: TObject); | ||||
|     procedure Vers_basClick(Sender: TObject); | ||||
|     procedure Vers_droiteClick(Sender: TObject); | ||||
|     procedure SB_HorChange(Sender: TObject); | ||||
|     procedure SB_VerChange(Sender: TObject); | ||||
|     procedure BBtn_SupprimeClick(Sender: TObject); | ||||
|     procedure ImageContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); | ||||
|     procedure Button1Click(Sender: TObject); | ||||
|     procedure ExecuterClick(Sender: TObject); | ||||
|     procedure SBtn_CompoClick(Sender: TObject); | ||||
|     procedure SBtn_SelectionClick(Sender: TObject); | ||||
|     procedure SBtn_DeplaceClick(Sender: TObject); | ||||
|     procedure SBtn_RelierClick(Sender: TObject); | ||||
|     procedure SBtn_LabelClick(Sender: TObject); | ||||
|     procedure BBtn_BasClick(Sender: TObject); | ||||
|     procedure BBtn_HautClick(Sender: TObject); | ||||
|     procedure BBtn_GaucheClick(Sender: TObject); | ||||
|     procedure BBtn_DroiteClick(Sender: TObject); | ||||
|     procedure Btn_C_okClick(Sender: TObject); | ||||
|     procedure Btn_R_OkClick(Sender: TObject); | ||||
|     procedure Button2Click(Sender: TObject); | ||||
|     procedure Button3Click(Sender: TObject); | ||||
|     procedure Memo1DblClick(Sender: TObject); | ||||
|     procedure Fichier1Click(Sender: TObject); | ||||
|     procedure Noir1Click(Sender: TObject); | ||||
|     procedure Potentiels1Click(Sender: TObject); | ||||
|     procedure Courants1Click(Sender: TObject); | ||||
|     procedure VisuelRelaisClick(Sender: TObject); | ||||
|     procedure Button4Click(Sender: TObject); | ||||
|     procedure Timer1Timer(Sender: TObject); | ||||
|     procedure ED_R_TempoKeyPress(Sender: TObject; var Key: Char); | ||||
|     procedure Btn_L_OkClick(Sender: TObject); | ||||
|     procedure PNLCLRClick(Sender: TObject); | ||||
|     procedure TmrPulseTimer(Sender: TObject); | ||||
|     procedure EnregistrerImage1Click(Sender: TObject); | ||||
|     procedure FormCreate(Sender: TObject); | ||||
|     procedure Button5Click(Sender: TObject); | ||||
|     procedure VisuelinteractifClick(Sender: TObject); | ||||
|     procedure Zoomajuster1Click(Sender: TObject); | ||||
|     procedure Button6Click(Sender: TObject); | ||||
|     procedure Button7Click(Sender: TObject); | ||||
|     procedure Button8Click(Sender: TObject); | ||||
|     procedure Button9Click(Sender: TObject); | ||||
|   private | ||||
|     { D<>clarations priv<69>es } | ||||
|   public | ||||
|     { D<>clarations publiques } | ||||
|   end; | ||||
|            | ||||
| var | ||||
|   Form1: TForm1; | ||||
|  | ||||
| const rmax=999; | ||||
|  | ||||
| implementation | ||||
|  | ||||
|  | ||||
| {$R *.dfm} | ||||
|  | ||||
| // * Initialisation * | ||||
| procedure TForm1.FormActivate(Sender: TObject); | ||||
| begin | ||||
|   Initialisation; | ||||
| end; | ||||
|  | ||||
| // * Zoom * | ||||
| procedure TForm1.LoupeAgClick(Sender: TObject); | ||||
| begin | ||||
|   If Zoom>0.5 then Zoom:=Zoom/1.15; | ||||
|   Affichage; | ||||
| end; | ||||
| procedure TForm1.LoupeRedClick(Sender: TObject); | ||||
| begin | ||||
|   If Zoom<1.75 then Zoom:=Zoom*1.15; | ||||
|   Affichage; | ||||
| end; | ||||
| procedure TForm1.Taille_normaleClick(Sender: TObject); | ||||
| begin | ||||
|   Zoom:=1; | ||||
|   Affichage; | ||||
| end; | ||||
| procedure TForm1.Zoom_minClick(Sender: TObject); | ||||
| begin | ||||
|   Zoom:=2.1; | ||||
|   Affichage; | ||||
| end; | ||||
| procedure TForm1.Zoom_MaxClick(Sender: TObject); | ||||
| begin | ||||
|   Zoom:=0.43; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| // * Grille * | ||||
| procedure TForm1.GrilleClick(Sender: TObject); | ||||
| begin | ||||
|   Grille.Checked:=not(Grille.Checked); | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| // * D<>calage Image * | ||||
| procedure TForm1.Vers_hautClick(Sender: TObject); | ||||
| begin | ||||
|   Decalage(0,1); | ||||
| end; | ||||
| procedure TForm1.Vers_gaucheClick(Sender: TObject); | ||||
| begin | ||||
|   Decalage(1,0); | ||||
| end; | ||||
| procedure TForm1.Vers_basClick(Sender: TObject); | ||||
| begin | ||||
|   Decalage(0,-1); | ||||
| end; | ||||
| procedure TForm1.Vers_droiteClick(Sender: TObject); | ||||
| begin | ||||
|   Decalage(-1,0); | ||||
| end; | ||||
| procedure TForm1.SB_HorChange(Sender: TObject); | ||||
| begin | ||||
|   Affichage; | ||||
| end; | ||||
| procedure TForm1.SB_VerChange(Sender: TObject); | ||||
| begin | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| // * Menu Fichier * | ||||
| procedure TForm1.M_Enregistrer_sousClick(Sender: TObject); | ||||
| begin | ||||
|   Enregistrer; | ||||
| end; | ||||
| procedure TForm1.M_OuvrirClick(Sender: TObject); | ||||
| begin | ||||
|   Ouvrir; | ||||
|   Affichage; | ||||
|   ListeNom; | ||||
| end; | ||||
| procedure TForm1.NouveauClick(Sender: TObject); | ||||
| begin | ||||
|   Initialisation;    | ||||
| end; | ||||
|  | ||||
| // * Menu Editer * | ||||
| procedure TForm1.EditerClick(Sender: TObject); | ||||
| begin | ||||
|   bEdit:=true; | ||||
|   bExec:=false; | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| procedure TForm1.ImageDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); | ||||
| begin | ||||
|   Accept:=Sender is TImage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.ImageDragDrop(Sender, Source: TObject; X, Y: Integer); | ||||
| begin | ||||
| //  memo1.Lines.Add('ok '+(Source as TImage).Name); | ||||
|   AjouteComposant((Source as TImage).Name,X,Y); | ||||
| end; | ||||
|  | ||||
|  | ||||
|  | ||||
| procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); | ||||
| begin | ||||
|   bRelier:=SBtn_Relier.Down and bEdit; | ||||
|   bSelectionner:= SBtn_Selection.Down and bEdit; | ||||
|  | ||||
|   dx:=cordo(x)+Form1.SB_Hor.Position*sbx; | ||||
|   dy:=cordo(y)+Form1.SB_Ver.Position*sby; | ||||
|   fx:=cordo(x)+Form1.SB_Hor.Position*sbx; | ||||
|   fy:=cordo(y)+Form1.SB_Ver.Position*sby; | ||||
|  | ||||
|  | ||||
|   if bRelier then bLier:=true;  //   not (ssShift in Shift) and | ||||
|   if bSelectionner then bSelection:=true; | ||||
|  | ||||
|   if bExec then SourisBas; | ||||
|  | ||||
|  | ||||
| //  if (ssShift in Shift) then RechercheComposant; | ||||
| //  if (ssCtrl in Shift) and (CompoEnCours<>'') then Deplacer:=true; | ||||
|  | ||||
|  | ||||
| //  ssShift, ssAlt, ssCtrl, | ||||
| //    ssLeft, ssRight, ssMiddle, ssDouble | ||||
|  | ||||
| //   memo1.Lines.Add('MouseDown'); | ||||
| //  if (ssShift in Shift) then memo1.Lines.Add('ssShift'); | ||||
| //  if (ssAlt in Shift) then memo1.Lines.Add('ssAlt'); | ||||
| //  if (ssCtrl in Shift) then memo1.Lines.Add('ssCtrl'); | ||||
|  | ||||
| end; | ||||
|  | ||||
| procedure TForm1.ImageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); | ||||
| begin | ||||
|   if bLier or bSelection then begin | ||||
|     fx:=cordo(x)+Form1.SB_Hor.Position*sbx; | ||||
|     fy:=cordo(y)+Form1.SB_Ver.Position*sby; | ||||
|     Affichage; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
|  | ||||
| procedure TForm1.ImageMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); | ||||
| begin | ||||
|   fx:=cordo(x)+Form1.SB_Hor.Position*sbx; | ||||
|   fy:=cordo(y)+Form1.SB_Ver.Position*sby; | ||||
|  | ||||
|  | ||||
|  | ||||
|   if bLier and ((fx<>dx) or (fy<>dy)) then AjouteSegment; | ||||
|   if bSelection then SelectionComposants; | ||||
|   if bExec then SourisHaut; | ||||
|  | ||||
|   bLier:=false; | ||||
|   bSelection:=false; | ||||
|   if not bExec then Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.BBtn_SupprimeClick(Sender: TObject); | ||||
| begin | ||||
|   SupprimeComposant; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.ImageContextPopup(Sender: TObject; MousePos: TPoint;  var Handled: Boolean); | ||||
| begin | ||||
|   if bEdit then PanneauEdition(MousePos.X,MousePos.Y); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button1Click(Sender: TObject); | ||||
| begin | ||||
|   Resegmentation; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.ExecuterClick(Sender: TObject); | ||||
| begin | ||||
|   bEdit:=false; | ||||
|   bExec:=true; | ||||
|   Panneaux; | ||||
|   RAZSelection; | ||||
|   Resegmentation; | ||||
|   InitExec; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.SBtn_CompoClick(Sender: TObject); | ||||
| begin | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.SBtn_SelectionClick(Sender: TObject); | ||||
| begin | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.SBtn_DeplaceClick(Sender: TObject); | ||||
| begin | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.SBtn_RelierClick(Sender: TObject); | ||||
| begin | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.SBtn_LabelClick(Sender: TObject); | ||||
| begin | ||||
|   Panneaux; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.BBtn_BasClick(Sender: TObject); | ||||
| begin | ||||
|   DeplaceSelection(0,-1); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.BBtn_HautClick(Sender: TObject); | ||||
| begin | ||||
|   DeplaceSelection(0,1); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.BBtn_GaucheClick(Sender: TObject); | ||||
| begin | ||||
|   DeplaceSelection(1,0); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.BBtn_DroiteClick(Sender: TObject); | ||||
| begin | ||||
|   DeplaceSelection(-1,0); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Btn_C_okClick(Sender: TObject); | ||||
| var i:integer; | ||||
| begin | ||||
|   for i:=0 to Nb_Contact-1 do if L_Contact[i].Select then begin | ||||
|     L_Contact[i].EtatI:=CB_C_EtatI.Checked; | ||||
|     L_Contact[i].Manuel:=CB_C_Manuel.Checked; | ||||
|     L_Contact[i].nom:=CO_C_Nom.Text; | ||||
|     L_Contact[i].visible:=CB_C_visible.Checked; | ||||
|     L_Contact[i].Pd.X:=SP_C_dx.Value; | ||||
|     L_Contact[i].Pd.Y:=SP_C_dy.Value; | ||||
|    end; | ||||
|   RAZPanneauEdition; | ||||
|   ListeNom; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Btn_R_OkClick(Sender: TObject); | ||||
| var i:integer; | ||||
| begin | ||||
|   for i:=0 to Nb_Relais-1 do if L_Relais[i].Select then begin | ||||
| ///    L_Relais[i].EtatI:=CB_R_EtatI.Checked; | ||||
|     L_Relais[i].Visible:=CB_R_Visible.Checked; | ||||
|     L_Relais[i].nom:=Ed_R_Nom.Text; | ||||
|     L_Relais[i].Pd.X:=SP_R_dx.Value; | ||||
|     L_Relais[i].Pd.Y:=SP_R_dy.Value; | ||||
|     L_Relais[i].tpr:=StrToInt('0'+Ed_R_Tempo.Text); | ||||
|    end; | ||||
|   RAZPanneauEdition; | ||||
|   ListeNom; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button2Click(Sender: TObject); | ||||
| var F:TextFile; | ||||
|     S:string; | ||||
|     i,j:integer; | ||||
| begin | ||||
|   AssignFile(F,'List.csv'); | ||||
|   Rewrite(F); | ||||
|   Writeln(F,'Segments,'); | ||||
|   Writeln(F,'n<>,P1,P2,C<>t<EFBFBD>1,C<>t<EFBFBD>2,Branche'); | ||||
|   for i:=0 to Nb_Segment-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+'('+IntToStr(L_Segment[i].P1.X)+';'+IntToStr(L_Segment[i].P1.Y)+'),'; | ||||
|     s:=s+'('+IntToStr(L_Segment[i].P2.X)+';'+IntToStr(L_Segment[i].P2.Y)+'),'; | ||||
|     S:=s+L_Segment[i].Cote1+','+L_Segment[i].Cote2+','; | ||||
|     s:=s+IntToStr(L_Segment[i].AppaBranche)+','; | ||||
|     Writeln(F,s); | ||||
|   end; | ||||
|   Writeln(F,','); | ||||
|   Writeln(F,'Branches,'); | ||||
|   Writeln(F,'n<>,C<>t<EFBFBD>1,C<>t<EFBFBD>2,Pot,S1,S2,S3,S4,S5,S6,S7,S8'); | ||||
|   for i:=0 to length(L_Branche)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Branche[i].Cote1+','+L_Branche[i].Cote2+','; | ||||
|     s:=s+IntToStr(L_Branche[i].AppaPotentiel)+','; | ||||
|     for j:=0 to length(L_Branche[i].CompSegments)-1 do s:=s+IntToStr(L_Branche[i].CompSegments[j])+','; | ||||
|     Writeln(F,s); | ||||
|   end; | ||||
|  | ||||
|   Writeln(F,','); | ||||
|   Writeln(F,'Potentiels,'); | ||||
|   Writeln(F,'n<>,B1,B2,B3,B4,B5,B6,B7,B8'); | ||||
|   for i:=0 to length(L_Potentiel)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     for j:=0 to length(L_Potentiel[i].CompBranches)-1 do s:=s+IntToStr(L_Potentiel[i].CompBranches[j])+','; | ||||
|     Writeln(F,s); | ||||
|   end; | ||||
|   CloseFile(F); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button3Click(Sender: TObject); | ||||
| var i,j:integer; | ||||
|     s:string; | ||||
| begin | ||||
|   test('Segments'); | ||||
|   for i:=0 to Nb_Segment-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+'('+IntToStr(L_Segment[i].P1.X)+';'+IntToStr(L_Segment[i].P1.Y)+'),'; | ||||
|     s:=s+'('+IntToStr(L_Segment[i].P2.X)+';'+IntToStr(L_Segment[i].P2.Y)+'),'; | ||||
|     S:=s+L_Segment[i].Cote1+','+L_Segment[i].Cote2+','; | ||||
|     s:=s+IntToStr(L_Segment[i].AppaBranche)+','; | ||||
|     test(s); | ||||
|   end; | ||||
|   test2('Branches'); | ||||
|   for i:=0 to length(L_Branche)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Branche[i].Cote1+','+L_Branche[i].Cote2+','; | ||||
|     s:=s+IntToStr(L_Branche[i].AppaPotentiel)+','; | ||||
|     S:=S+'C'+IntToStr(L_Branche[i].Courant); | ||||
|     for j:=0 to length(L_Branche[i].CompSegments)-1 do s:=s+IntToStr(L_Branche[i].CompSegments[j])+','; | ||||
|     test2(s); | ||||
|   end; | ||||
|  | ||||
|   test(''); | ||||
|   test('Potentiels'); | ||||
|   for i:=0 to length(L_Potentiel)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     S:=S+IntToStr(L_Potentiel[i].Rp)+','+IntToStr(L_Potentiel[i].Rm)+','; | ||||
|     for j:=0 to length(L_Potentiel[i].CompBranches)-1 do s:=s+IntToStr(L_Potentiel[i].CompBranches[j])+','; | ||||
|     test(s); | ||||
|   end; | ||||
|  | ||||
|   test('Fonctions'); | ||||
|   for i:=0 to length(L_Fonction)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Fonction[i].comp+','; | ||||
|     s:=s+L_Fonction[i].nom+','; | ||||
|     s:=s+IntToStr(L_Fonction[i].x)+','; | ||||
|     test(s); | ||||
|   end; | ||||
|  | ||||
|   test('Relais'); | ||||
|   for i:=0 to length(L_Relais)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Relais[i].nom+','; | ||||
|   //  s:=s+IntToStr(L_Relais[i].Fonction)+','; | ||||
|     S:=S+' 0:'+IntToStr(L_Relais[i].AppPot[0])+' 1:'+IntToStr(L_Relais[i].AppPot[1])+','; | ||||
|     test(s); | ||||
|   end; | ||||
|  | ||||
|     test('Lampe'); | ||||
|   for i:=0 to length(L_Lampe)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Lampe[i].nom+','; | ||||
|   //  s:=s+IntToStr(L_Lampe[i].Fonction)+','; | ||||
|     //S:=S+' 0:'+IntToStr(L_Lampe[i].AppPot[0])+' 1:'+IntToStr(L_Lampe[i].AppPot[1])+','; | ||||
|     test(s); | ||||
|   end; | ||||
|  | ||||
|  | ||||
|   test('Contact'); | ||||
|   for i:=0 to length(L_Contact)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Contact[i].nom+','; | ||||
|     s:=s+IntToStr(L_Contact[i].Fonction)+','; | ||||
|     test(s); | ||||
|   end; | ||||
| end;   | ||||
|  | ||||
| procedure TForm1.Memo1DblClick(Sender: TObject); | ||||
| begin | ||||
|   memo1.Clear; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Fichier1Click(Sender: TObject); | ||||
| begin | ||||
|   bExec:=false; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Noir1Click(Sender: TObject); | ||||
| begin | ||||
|   ExecCouleur(1); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Potentiels1Click(Sender: TObject); | ||||
| begin | ||||
|   ExecCouleur(2); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Courants1Click(Sender: TObject); | ||||
| begin | ||||
|   ExecCouleur(3); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.VisuelRelaisClick(Sender: TObject); | ||||
| begin | ||||
|   ExecVisuel; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button4Click(Sender: TObject); | ||||
| var i:integer; | ||||
|     s:string; | ||||
| begin | ||||
|   test(''); | ||||
|   test('Potentiels'); | ||||
|   for i:=0 to length(L_Potentiel)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     S:=S+IntToStr(L_Potentiel[i].Rp)+','+IntToStr(L_Potentiel[i].Rm); | ||||
|  //   for j:=0 to length(L_Potentiel[i].CompBranches)-1 do s:=s+IntToStr(L_Potentiel[i].CompBranches[j])+','; | ||||
|     test(s); | ||||
|   end; | ||||
|  | ||||
|   test('Relais'); | ||||
|   for i:=0 to length(L_Relais)-1 do begin | ||||
|     s:=IntToStr(i)+','; | ||||
|     s:=s+L_Relais[i].nom+','; | ||||
|    // s:=s+IntToStr(L_Relais[i].Fonction)+','; | ||||
|    // S:=S+' 0:'+IntToStr(L_Relais[i].AppPot[0])+' 1:'+IntToStr(L_Relais[i].AppPot[1])+','; | ||||
|    // S:=S+'   '+IntToStr(L_Relais[i].AppPot[0])+' 1:'+IntToStr(L_Relais[i].AppPot[1])+','; | ||||
|     S:=S+'   '+ IntToStr(L_Potentiel[L_Relais[i].AppPot[0]].Rp)+','+IntToStr(L_Potentiel[L_Relais[i].AppPot[0]].Rm)+' ; '+IntToStr(L_Potentiel[L_Relais[i].AppPot[1]].Rp)+','+IntToStr(L_Potentiel[L_Relais[i].AppPot[1]].Rm); | ||||
|     test(s); | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Timer1Timer(Sender: TObject); | ||||
| begin | ||||
|   Temporisations; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.ED_R_TempoKeyPress(Sender: TObject; var Key: Char); | ||||
| begin | ||||
|   if not (Key in [#8, '0'..'9']) then Key := #0; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Btn_L_OkClick(Sender: TObject); | ||||
| var i:integer; | ||||
| begin | ||||
|   for i:=0 to Nb_Lampe-1 do if L_Lampe[i].Select then begin | ||||
|     L_lampe[i].Visible:=CB_L_Visible.Checked; | ||||
|     L_lampe[i].nom:=Ed_L_Nom.Text; | ||||
|     L_lampe[i].Pd.X:=SP_L_dx.Value; | ||||
|     L_lampe[i].Pd.Y:=SP_L_dy.Value; | ||||
|     L_Lampe[i].Clr0:=PNL_L0.Color; | ||||
|     L_Lampe[i].Clr1:=PNL_L1.Color; | ||||
|   end; | ||||
|   RAZPanneauEdition; | ||||
|   ListeNom; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.PNLCLRClick(Sender: TObject); | ||||
| begin | ||||
|   if ColorDialog1.Execute then begin | ||||
|     if (Sender is TPanel) then (Sender as TPanel).Color:=ColorDialog1.Color; | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.TmrPulseTimer(Sender: TObject); | ||||
| begin | ||||
|   pulse:=not pulse; | ||||
|   if bExec then CycleExec; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.EnregistrerImage1Click(Sender: TObject); | ||||
| begin | ||||
|   if SavePictureDialog1.Execute then Image.Picture.SaveToFile(SavePictureDialog1.FileName); | ||||
| end; | ||||
|  | ||||
| procedure TForm1.FormCreate(Sender: TObject); | ||||
| begin | ||||
| //  DoubleBuffered := true; | ||||
|  | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button5Click(Sender: TObject); | ||||
| var i:integer; | ||||
| begin | ||||
|   for i:=0 to Nb_Fonction-1 do begin | ||||
|     test2(L_Fonction[i].nom+' '+IntToStr(L_Fonction[i].x)); | ||||
|                           | ||||
|   end; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.VisuelinteractifClick(Sender: TObject); | ||||
| begin | ||||
|   ExecInteractif; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Zoomajuster1Click(Sender: TObject); | ||||
| begin | ||||
| //  Zoom:=0.43; | ||||
|   Affichage; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button6Click(Sender: TObject); | ||||
| begin | ||||
|   memo2.Visible:=false; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button7Click(Sender: TObject); | ||||
| begin | ||||
|   memo2.Visible:=true; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button8Click(Sender: TObject); | ||||
| begin | ||||
|   memo2.Clear; | ||||
| end; | ||||
|  | ||||
| procedure TForm1.Button9Click(Sender: TObject); | ||||
| var i:integer; | ||||
|     s:string; | ||||
| begin | ||||
|   memo2.Lines.Add('SEGMENTS'); | ||||
|   s:=' # | xa, ya| xb, yb|c<>t<EFBFBD>1 |c<>t<EFBFBD>2 |Bra|S1|S2'; | ||||
|   memo2.Lines.Add(s); | ||||
|   for i:=0 to Nb_Segment-1 do begin | ||||
|     s:=format('%3d|%3d,%3d|%3d,%3d|%-6s|%-6s|%3d|%-.2s|%-.2s', | ||||
|               [i,L_Segment[i].P1.X,L_Segment[i].P1.Y,L_Segment[i].P2.X,L_Segment[i].P2.Y,L_Segment[i].Cote1,L_Segment[i].Cote2,L_Segment[i].AppaBranche,VartoStr(L_Segment[i].Select1),VartoStr(L_Segment[i].Select1)]); | ||||
|     memo2.Lines.Add(s); | ||||
|   end; | ||||
|  | ||||
|   memo2.Lines.Add('BRANCHES'); | ||||
|   s:=' # |c<>t<EFBFBD>1 |c<>t<EFBFBD>2 |Cou|Par'; | ||||
|   memo2.Lines.Add(s); | ||||
|   for i:=0 to length(L_Branche)-1 do begin | ||||
|     s:=format('%3d|%-6s|%-6s|%3d|%3d', | ||||
|               [i,L_Branche[i].Cote1,L_Branche[i].Cote2,L_Branche[i].Courant,L_Branche[i].Parcouru]); | ||||
|     memo2.Lines.Add(s); | ||||
|   end; | ||||
|  | ||||
|  | ||||
|   { | ||||
|   T_Branche = record | ||||
|     AppaPotentiel : integer; | ||||
|     EtatP, EtatF : boolean; | ||||
|     CompSegments :array of integer; | ||||
|     Cote1,Cote2 : string; | ||||
|     Courant:integer; | ||||
|     Parcouru :integer; | ||||
|   end; | ||||
|   } | ||||
|  | ||||
| end; | ||||
|  | ||||
| end. | ||||
		Reference in New Issue
	
	Block a user