Autor Beitrag
thorstenf01
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 60

Win XP
D5 enterprise
BeitragVerfasst: Di 23.09.03 18:56 
Hy,
ich habe folgendes Problem:
Der Programmauszug zeigt drei Timer wovon Timer1 und Timer3
jeweils einen Start und Stop der Schnittstellenabfrage festlegen
Timer2 vergleicht die Uhrzeit mit den festgelegten Start- und Stopzeiten.
Wenn ein "1" signal über Port DSR oder CTS oder DCD oder RI an Delphi gesendet wird,
erscheint es in der Listbox2.Soweit funktioniert auch alles, nur das das TShape
einen falschen Status anzeigt! Das TShape soll, wie unten gezeigt, bei Timer1 und
Timer2 enabled=true grün aufleuchten und wenn dies nicht der Fall ist,rot.
Es wird aber angezeigt:

timer1.Enabled = true =rot
timer1.Enabled = false =rot
timer3.Enabled = true =grün
timer3.Enabled = false =rot

Danke im voraus...

ausblenden volle Höhe Quelltext
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:
...
procedure TForm3.FormCreate(Sender: TObject);
begin
 Opencom(Pchar('COM1:9600,N,8,1'));
 Edit4.text := FormatDateTime('tt',Time);
 Edit5.text := FormatDateTime('ddddd',Date);
 DTR (1);
 CTSalt:= -1;
 DSRalt:= -1;
 DCDalt:= -1;
 RIalt:= -1;

end;

procedure TForm3.Timer2Timer(Sender: TObject);
var  Hour, Min, Sec, mSec: Word;
begin
 if (timer1.Enabled = true) and (Opencom(Pchar('COM1:9600,N,8,1')) = 0) then
 ShowMessage ('COM1 belegt'); 
 DecodeTime(time, Hour, Min, Sec, mSec);
 Edit4.text := FormatDateTime('tt',Time);
 Edit5.text := FormatDateTime('ddddd',Date);

 if (Time > StrToTime (Edit2.Text)) and (Time < StrToTime (Edit3.Text)) and (Date >= StrToDate (Edit6.Text)) and (Date <= StrToDate (Edit7.Text)) then timer1.Enabled := true;
 if (Time > StrToTime (Edit3.Text)) and (Date >= StrToDate (Edit7.Text)) then timer1.Enabled := false ;

 if (Time > StrToTime (Edit9.Text)) and (Time < StrToTime (Edit11.Text)) and (Date >= StrToDate (Edit8.Text)) and (Date <= StrToDate (Edit10.Text)) then timer3.Enabled := true;
 if (Time > StrToTime (Edit11.Text)) and (Date >= StrToDate (Edit10.Text)) then timer3.Enabled := false ;

 with shape1 do begin
    if timer1.Enabled = true then Brush.Color:=clLime else Brush.Color:=clRed;
    if timer3.Enabled = true then Brush.Color:=clLime else Brush.Color:=clRed;
    end;
end;

procedure TForm3.Timer1Timer(Sender: TObject);
begin
  try
    CTSneu:=CTS;
    DSRneu:=DSR;
    DCDneu:=DCD;
    RIneu:=RI;

    if  CTSneu = 1 then 
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' CTS = 1' )

    else if  DSRneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+'  ' + ' DSR = 1' )

    else if  DCDneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + '  DCD = 1' )

    else if  RIneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' RI = 1' );
    except
  end;
end;

procedure TForm3.Timer3Timer(Sender: TObject);
begin
  try
    CTSneu:=CTS;
    DSRneu:=DSR;
    DCDneu:=DCD;
    RIneu:=RI;

    if  CTSneu = 1 then 
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' CTS = 1' )

    else if  DSRneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' DSR = 1' )

    else if  DCDneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' DCD = 1' )

    else if  RIneu = 1 then
    ListBox2.Items.Add(' '+DateToStr(Date)+' '+TimeToStr(Time)+' ' + ' RI = 1' ); 
   except
  end;
end;
...


Gruß
Thorsten