-
Notifications
You must be signed in to change notification settings - Fork 3
/
PicProgN.pas
193 lines (148 loc) · 3.91 KB
/
PicProgN.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{+--------------------------------------------------------------------------+
| Created: 2001-06-24 15:45:41
| Author:
| Company:
| Copyright
| Description:
| Version: $Revisions$ $Date: 2002-12-30 17:22:53+13 $
| Open Issues:
+--------------------------------------------------------------------------+}
unit PicProgN;
interface
uses Windows,Messages,SysUtils,Classes,PortIO;
type
TPicPN = class(TDLPrinterPortIO)
private
FPower: Boolean;
FAutoOpen:boolean;
fIsOpen : boolean;
fRB7 : boolean;
function GetPower: Boolean;
procedure SetPower(AValue: Boolean);
function GetOpen: Boolean;
procedure SetOpen(AValue: Boolean);
function getRB7: boolean;
procedure setRB7(AValue: boolean);
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy;override;
procedure Reset(Channel:integer);
procedure Idle;
procedure MakeOpen;
published
property AutoOpen : boolean read FAutoOpen write FAutoOpen;
property Power: Boolean read GetPower write SetPower;
property Open : boolean read getOpen write setOpen;
property RB7 : boolean read getRB7 write setRB7;
end; {TPicPN}
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('DiskDude', [TPicPN]);
end;
//////////////////////// TPicPN ///////////////////////
{Private methods for TPicPN}
procedure TPicPN.MakeOpen; {opens the driver if it is closed}
begin
if (not fIsOpen) and fAutoOpen
then SetOpen(true);
end; //MakeOpen
function TPicPN.GetPower: Boolean;
begin
result:=FPower;
end; {GetPower}
procedure TPicPN.SetPower(AValue: Boolean);
begin
// this is called during init when the Power property is loaded.
FPower:= AValue;
if not (csLoading in ComponentState) and not (csDesigning in ComponentState)
then begin
MakeOpen;
//LPTAutofd(FPower);
if AValue
then Port[LPTBasePort+2]:=2 //Power ON
else Port[LPTBasePort+2]:=0; //Power Off
end; //if
end; {SetPower}
function TPicPN.GetOpen: Boolean;
begin
if not(csDesigning in ComponentState) and not (csLoading in ComponentState)
then begin
fIsOpen:=ActiveHW;
end;
result:=fIsOpen;
end; {GetOpen}
procedure TPicPN.SetOpen(AValue: Boolean);
begin
if not(csDesigning in ComponentState) and not (csLoading in ComponentState)
then begin
if AValue
then OpenDriver
else CloseDriver;
fIsOpen:=ActiveHW;
//fIsOpen:=true;
end else begin //designing or loading
fIsOpen:=AValue;
end
// if fIsOpen then Idle;
end; {SetOpen}
function TPicPN.getRB7 : boolean;
begin
result:=fRB7; //default...
if not (csDesigning in ComponentState) and not (csLoading in ComponentState)
then begin
MakeOpen;
fRB7:= not LPTAckwl;
result:=fRB7;
end; //if
end; //getRB7
procedure TPicPN.setRB7(AValue: boolean);
begin
fRB7:=AValue;
{ if not(csDesigning in ComponentState) and not (csLoading in ComponentState)
then begin
MakeOpen;
if AValue
Port[LPTBasePort]:=
else
Port[LPTBasePort]:=
result:=fRB7;
end; //if
}
end; //setRB7
{Public methods for TPicPN}
constructor TPicPN.Create(AOwner: TComponent);
begin
inherited Create(Aowner);
fAutoOpen:=true;
fIsOpen:=false;
fPower:=false;
end; {Create}
destructor TPicPN.Destroy;
begin
// if fIsOpen then Idle; //this seems to crash it on w2k
//sleep(1000);
//CloseDriver;
inherited Destroy; //also closes driver
end; {Destroy}
procedure TPicPN.Reset(Channel:integer);
begin
//MakeOpen;
case ( Channel ) of
0: Port[LPTBasePort]:=4+16+64;//Pin[8]:=false;
1: Port[LPTBasePort]:=4+16;
2: Port[LPTBasePort]:=4+64;
end;
sleep(500);
Idle;
end; {Reset}
procedure TPicPN.Idle; //power on, vmid,
begin
MakeOpen;
Port[LPTBasePort]:=4; // Vmid
Port[LPTBasePort+2]:=2; //Power ON
end; {Idle}
{Published methods for TPicPN}
end.