1 | unit UISPProgrammer;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, Registry, UIntelHexFile,
|
---|
9 | UCPUType, UJobProgressView;
|
---|
10 |
|
---|
11 | type
|
---|
12 | TLogEvent = procedure (Text: string) of object;
|
---|
13 |
|
---|
14 | TISPProgCapability = (ipcRead, ipcWrite, ipcReset, ipcErase);
|
---|
15 | TISPProgCapabilities = set of TISPProgCapability;
|
---|
16 |
|
---|
17 | { TISPProgrammer }
|
---|
18 |
|
---|
19 | TISPProgrammer = class
|
---|
20 | private
|
---|
21 | FActive: Boolean;
|
---|
22 | FOnActivate: TNotifyEvent;
|
---|
23 | FOnDeactivate: TNotifyEvent;
|
---|
24 | FOnLog: TLogEvent;
|
---|
25 | FCPUType: TCPUType;
|
---|
26 | protected
|
---|
27 | function GetCPUType: TCPUType; virtual;
|
---|
28 | procedure SetCPUType(AValue: TCPUType); virtual;
|
---|
29 | procedure SetActive(AValue: Boolean); virtual; // private
|
---|
30 | public
|
---|
31 | HexFile: TIntelHexFile;
|
---|
32 | FileName: string;
|
---|
33 | Capabilities: TISPProgCapabilities;
|
---|
34 | procedure Log(Text: string);
|
---|
35 | procedure LoadFromRegistry(Root: HKEY; Key: string); virtual;
|
---|
36 | procedure SaveToRegistry(Root: HKEY; Key: string); virtual;
|
---|
37 | procedure Write(Job: TJob); virtual;
|
---|
38 | procedure Read(Job: TJob); virtual;
|
---|
39 | procedure Verify(Job: TJob); virtual;
|
---|
40 | procedure Erase; virtual;
|
---|
41 | procedure Reset; virtual;
|
---|
42 | function ReadIdentification: string; virtual;
|
---|
43 | constructor Create; virtual;
|
---|
44 | destructor Destroy; override;
|
---|
45 | property OnLog: TLogEvent read FOnLog write FOnLog;
|
---|
46 | property Active: Boolean read FActive write SetActive;
|
---|
47 | property CPUType: TCPUType read GetCPUType write SetCPUType;
|
---|
48 | property OnActivate: TNotifyEvent read FOnActivate write FOnActivate;
|
---|
49 | property OnDeactivate: TNotifyEvent read FOnDeactivate write FOnDeactivate;
|
---|
50 | end;
|
---|
51 |
|
---|
52 | implementation
|
---|
53 |
|
---|
54 | resourcestring
|
---|
55 | SNotImplemented = 'Not implemented';
|
---|
56 |
|
---|
57 | { TISPProgrammer }
|
---|
58 |
|
---|
59 | function TISPProgrammer.GetCPUType: TCPUType;
|
---|
60 | begin
|
---|
61 | Result := FCPUType;
|
---|
62 | end;
|
---|
63 |
|
---|
64 | procedure TISPProgrammer.SetCPUType(AValue: TCPUType);
|
---|
65 | begin
|
---|
66 | FCPUType := AValue;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | procedure TISPProgrammer.SetActive(AValue: Boolean);
|
---|
70 | begin
|
---|
71 | if FActive = AValue then Exit;
|
---|
72 | FActive := AValue;
|
---|
73 | if AValue then begin
|
---|
74 | if Assigned(FOnActivate) then
|
---|
75 | FOnActivate(Self);
|
---|
76 | end else begin
|
---|
77 | if Assigned(FOnDeactivate) then
|
---|
78 | FOnDeactivate(Self);
|
---|
79 | end;
|
---|
80 | end;
|
---|
81 |
|
---|
82 | procedure TISPProgrammer.Log(Text: string);
|
---|
83 | begin
|
---|
84 | if Assigned(FOnLog) then
|
---|
85 | FOnLog(Text);
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TISPProgrammer.LoadFromRegistry(Root: HKEY; Key: string);
|
---|
89 | begin
|
---|
90 |
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TISPProgrammer.SaveToRegistry(Root: HKEY; Key: string);
|
---|
94 | begin
|
---|
95 |
|
---|
96 | end;
|
---|
97 |
|
---|
98 | procedure TISPProgrammer.Write(Job: TJob);
|
---|
99 | begin
|
---|
100 | raise Exception.Create(SNotImplemented);
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TISPProgrammer.Read(Job: TJob);
|
---|
104 | begin
|
---|
105 | raise Exception.Create(SNotImplemented);
|
---|
106 | end;
|
---|
107 |
|
---|
108 | procedure TISPProgrammer.Verify(Job: TJob);
|
---|
109 | begin
|
---|
110 | raise Exception.Create(SNotImplemented);
|
---|
111 | end;
|
---|
112 |
|
---|
113 | procedure TISPProgrammer.Erase;
|
---|
114 | begin
|
---|
115 | raise Exception.Create(SNotImplemented);
|
---|
116 | end;
|
---|
117 |
|
---|
118 | procedure TISPProgrammer.Reset;
|
---|
119 | begin
|
---|
120 | raise Exception.Create(SNotImplemented);
|
---|
121 | end;
|
---|
122 |
|
---|
123 | function TISPProgrammer.ReadIdentification: string;
|
---|
124 | begin
|
---|
125 | Result := '';
|
---|
126 | raise Exception.Create(SNotImplemented);
|
---|
127 | end;
|
---|
128 |
|
---|
129 | constructor TISPProgrammer.Create;
|
---|
130 | begin
|
---|
131 | //ExtPin := TCommPin.Create;
|
---|
132 | HexFile := TIntelHexFile.Create;
|
---|
133 | HexFile.BytePerLine := 20;
|
---|
134 | end;
|
---|
135 |
|
---|
136 | destructor TISPProgrammer.Destroy;
|
---|
137 | begin
|
---|
138 | Active := False;
|
---|
139 | //FreeAndNil(ExtPin);
|
---|
140 | FreeAndNil(HexFile);
|
---|
141 | inherited Destroy;
|
---|
142 | end;
|
---|
143 |
|
---|
144 | end.
|
---|
145 |
|
---|