You are on page 1of 4

1 SCRIPTS DE FORMULARIOS 01

2 Program Prog1;
3 uses xhexedit, uuprog, windows,
4 forms, Unit2, Unit3, Unit4, controls, unit5;
5
6 var code: string;
7 EnterCodeForm: TEnterCodeForm;
8 f1,f2: TForm4;
9 dt: string;
10 ScriptPath: string;
11
12 procedure ReadCode;
13
14 const Adr = $31;
15
16 begin
17 if not ReadDevice then begin
18 MsgBox( 'Read Error', 'Error', MB_OK or MB_ICONERROR );
19 end
20 else begin
21 Code := chr(GetByteHexEdit( Adr ))+
22 chr(GetByteHexEdit( Adr+1 ))+
23 chr(GetByteHexEdit( Adr+2 ))+
24 chr(GetByteHexEdit( Adr+3 ));
25
26 MsgBox( '[$'+IntToHex( Adr, 4 )+']='+ Code, 'Code', MB_OK or MB_ICONINFORMATION );
27 end;
28 end;
29
30 procedure WriteCode;
31 var n: integer;
32 begin
33 SetProgramModifiedOnly( false );
34 code := '';
35 if InBox( 'Enter', 'Code', code ) then begin
36 if length( code ) < 4 then begin
37 MsgBox( 'Enter 4 numbers', 'Error', 0 );
38 exit;
39 end;
40
41 n := StrToInt( code );
42
43 SetByteHexEdit( $31, ord(code[1]) );
44 SetByteHexEdit( $32, ord(code[2]) );
45 SetByteHexEdit( $33, ord(code[3]) );
46 SetByteHexEdit( $34, ord(code[4]) );
47
48 RefreshHexEdit;
49
50 if ProgramDevice then
51 VerifyDevice
52 else
53 MsgBox( 'Program Error', 'Error', 0 );
54 end;
55 end;
56
57 procedure OnSelectDevice( Device: TDevice; ProgrammerTab, ConnectionsTab: TWinControl );
58
59 begin
60 ShowMessage( 'Selected has selected' );
61 end;
62
63 procedure CreateCustomPage( AParent );
64
65 var i: integer;
66 ccount: integer;
67
68 begin
69 f1 := TForm4.Create( AParent );
70 f1.Parent := AParent;
71 f1.Visible := True;
72 f1.BringToFront;
73 end;
74
75 procedure DestroyCustomPage( PParent );
76 var i: integer;
77 ccount: integer;
78
79 begin
80 // ccount := PParent as TForm.ControlCount-1;
81 // AddMsg( 'Custom page will be destroyed - ' + inttostr( f )
82 // + ' controls:' + inttostr( ccount ));
83 if f1 <> null then begin
84 f1.OnFormClose;
85 PParent as TForm.RemoveControl( f1 );
86 end;
87 // f.free;
88 // ccount := PParent as TForm.ControlCount-1;
89 // for i:= 0 to ccount do begin
90 // PParent as TForm.Controls[i].Visible := True;
91 // end;
92 AddMsg( 'Custom page destroyed - ' + inttostr( f1 )
93 + ' controls:' + inttostr( ccount ));
94 end;
95
96 procedure CreateCustomPage2( PParent );
97
98 begin
99 PParent.Caption := 'oooiio'
100 f2 := TForm5.Create( PParent );
101 // f2.Show;
102 // SetOscillator( '4200' );
103 end;
104
105 procedure DestroyCustomPage2( PParent );
106
107 begin
108 // f2.Free;
109 code := code;
110 end;
111
112 procedure ShowForm5;
113 begin
114 F2.ShowModal;
115 end;
116
117 procedure SetHC908Params
118 var form: TTestHC908Form;
119 begin
120 form := TTestHC908Form.Create( Application );
121 form.ShowModal;
122 form.Free
123 end;
124
125
126
127 begin
128 code := 'xxx';
129 code := code + '3';
130 dt := datetimetostr(Now);
131
132 ScriptPath := GetScriptPath;
133 //Create Custom Device (Sub) Groups
134 AddDeviceGroup( 'Samples', 'Select a Device' ); //create a root group
135 AddDeviceGroupEx( 'Subgroup1', 'Select a Device', 'Samples' );
136 AddDeviceGroupEx( 'Subgroup2', 'Select a Device', 'Samples' );
137 AddDeviceGroupEx( 'Subgroup3', 'Select a Device', 'Samples' );
138 AddDeviceGroupEx( 'Subgroup31', 'Select a Device', 'Subgroup3' );
139
140 //Create Custom Devices
141 AddDevice( 'Device0', '25C080 Test device', 'Samples', '25C080');
142 AddDevice( 'Device1', '68HC05B8 - 0F10V', 'Subgroup1', 'MC68HC05B8');
143 AddDeviceEx( 'Device2', '24c04 Test device', 'Subgroup2', '24C04', 'CreateCustomPage',
144 'DestroyCustomPage');
145 AddDeviceEx( 'Device3', '68HC05B8 - 0F10V - 2', 'Subgroup3', 'MC68HC05B8',
146 'CreateCustomPage2', 'DestroyCustomPage2');
147 AddAction( 'Show Form5', 'ShowForm5', 'Device3' );
148
149 AddDevice( 'Device31', '68HC908az60A Test Device', 'Subgroup31', 'MC68HC908AZ60A/8MHz');
150 AddAction( 'Set HC908 Params', 'SetHC908Params', 'Device31' );
151
152
153
154 //Add Actions to created device
155 AddAction( 'Read Code', 'ReadCode', 'Device0' );
156 AddAction( 'Read Code', 'ReadCode', 'Device1' );
157
158 AddAction( 'Write Code', 'WriteCode', 'Device0' );
159 AddAction( 'Unit3Action', 'Unit3Action', 'Device0' );
160 AddOpenFileAction( 'Board Top Side', 'Device0', ScriptPath+'opel_imo2.jpg' );
161 AddOpenFileAction( 'Board Bottom Side', 'Device0', ScriptPath+'opel_imo3.jpg' );
162 AddOpenFileAction( 'Connections', 'Device0', ScriptPath+'mc68hc05b8_uusp.png' );
163 AddOpenFileAction( 'Connections Specifics', 'Device0', ScriptPath+'mc68hc05b8_uusp.txt' );
164 AddOpenFileAction( 'Edit project1.ssproj', 'Device0', ScriptPath+'project1.ssproj' );
165
166 AddMsg('Sample Device Script (Project1.xscr) Installed '#169' 2005 ELRASOFT');
167 SetProductInfo( 'Sample1', 'Device Script Example'#10'Copyright'#169' 2006 ELRASOFT Ltd.' );
168 end.

You might also like