unit clientU;
interface
uses
Windows,
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
OleCtnrs, StdCtrls,
Buttons, ExtCtrls, ScktComp, ComCtrls;
type
TForm1 =
class(TForm)
Label1:
TLabel;
baglanti:
TGroupBox;
Label2:
TLabel;
Label3:
TLabel;
Label4:
TLabel;
edthostadr: TEdit;
edthostadi: TEdit;
edtuzaktport: TEdit;
GroupBox1: TGroupBox;
Label7:
TLabel;
edtuveri:
TEdit;
Shape9:
TShape;
Shape10:
TShape;
Shape11:
TShape;
Shape12:
TShape;
ctext:
TClientSocket;
btnbaglan: TBitBtn;
ayninetwork: TCheckBox;
Memo:
TMemo;
btnmsjgonder:
TButton;
edtmsg:
TEdit;
vrgonder:
TGroupBox;
Label5:
TLabel;
Shape1:
TShape;
Shape2:
TShape;
Shape3:
TShape;
Shape4:
TShape;
edtudata:
TEdit;
cdata:
TClientSocket;
edtuzakdport: TEdit;
Label9:
TLabel;
btnkes:
TBitBtn;
btntemizle: TButton;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
btnoku:
TBitBtn;
edtyereldata: TEdit;
btnyereldata: TSpeedButton;
btnyerelstatus: TSpeedButton;
edtyerelstatus: TEdit;
btnbaglan2: TBitBtn;
btngonder: TBitBtn;
Panel1:
TPanel;
edtdrm:
TEdit;
Label6:
TLabel;
BitBtn1:
TBitBtn;
procedure
btnbaglanClick(Sender: TObject);
procedure
ayninetworkClick(Sender: TObject);
procedure
btnmsjgonderClick(Sender: TObject);
procedure
btngonderClick(Sender: TObject);
procedure
btnkesClick(Sender: TObject);
procedure
btntemizleClick(Sender: TObject);
procedure
btnokuClick(Sender: TObject);
procedure
cdataRead(Sender: TObject; Socket: TCustomWinSocket);
procedure
ctextRead(Sender: TObject; Socket: TCustomWinSocket);
procedure
btnyereldataClick(Sender: TObject);
procedure
btnyerelstatusClick(Sender: TObject);
procedure
btnbaglan2Click(Sender: TObject);
procedure
cdataConnect(Sender: TObject; Socket: TCustomWinSocket);
private
{ Private
declarations }
public
{ Public
declarations }
end;
var
Form1:
TForm1;
veri,sonuc:integer;
implementation
{$R *.DFM}
procedure led(var sha,shb,shc,shd:tshape;str:string);
begin
case strtoint(str) of
15:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clblue;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clblue;
end ;
14:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clblue;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clwhite;
end;
13:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clblue;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clblue;
end;
12:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clblue;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clwhite;
end;
11:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clblue;
end;
10:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clwhite;
end;
9:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clblue;
end;
8:
begin
sha.Brush.Color:=clblue;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clwhite;
end;
7:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clblue;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clblue;
end;
6:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clblue;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clwhite;
end;
5:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clblue;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clblue;
end;
4:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clblue;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clwhite;
end;
3:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clblue;
end;
2:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clblue;
shd.Brush.Color:=clwhite;
end;
1:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clblue;
end;
0:
begin
sha.Brush.Color:=clwhite;
shb.Brush.color:=clwhite;
shc.Brush.Color:=clwhite;
shd.Brush.Color:=clwhite;
end;
end;//case için
end;
procedure TForm1.btnbaglanClick(Sender: TObject);
begin
ctext.Address:=(edthostadr.text);
ctext.Host:=(edthostadi.text);
ctext.Port:=strtoint64(edtuzaktport.text); //mesaj için
ctext.Active:=true;
end;
procedure TForm1.ayninetworkClick(Sender: TObject);
begin
if (ayninetwork.Checked=true)then
begin
edthostadr.Enabled:=false;
edthostadr.Color:=clgray;
end else
begin
edthostadr.Enabled:=true;
edthostadr.Color:=clwhite;
end;
end;
procedure TForm1.btnmsjgonderClick(Sender: TObject);
begin
ctext.Socket.SendText(edtmsg.text);
end;
procedure TForm1.btnkesClick(Sender: TObject);
begin
ctext.Close;
cdata.Close;
edthostadr.clear;
edthostadr.Enabled;
edthostadr.color:=clwhite;
edthostadi.clear;
edtuzaktport.clear;
edtuzakdport.clear;
edtmsg.clear;
memo.clear;
edtyereldata.clear;
edtyerelstatus.clear;
edtuveri.clear;
edtudata.Clear;
edtdrm.text:='Bağlantı Kesildi';
end;
procedure TForm1.btntemizleClick(Sender: TObject);
begin
memo.clear;
end;
procedure TForm1.btngonderClick(Sender: TObject);
begin
if not ((edtudata.text='')
or (strtoint64(edtudata.text)>15)) then
begin
cdata.Socket.SendText(edtudata.text); //gönder
led(shape1,shape2,shape3,shape4,edtudata.text);
end // if için
else begin
showmessage('lütfen uygun değer griniz');
edtudata.clear;
end;// else
için
end;
procedure TForm1.btnokuClick(Sender: TObject);
begin
cdata.Socket.SendText('o');
end;
procedure TForm1.cdataRead(Sender: TObject; Socket:
TCustomWinSocket);
begin
edtuveri.text:=cdata.Socket.ReceiveText; //cdata ya
gelen tek bilgi bu
led(shape9,shape10,shape11,shape12,edtuveri.text);
end;
procedure TForm1.ctextRead(Sender: TObject; Socket:
TCustomWinSocket);
begin
memo.lines.Add(Socket.ReceiveText) ;
end;
procedure TForm1.btnyereldataClick(Sender: TObject);
begin
if (edtyereldata.text='') then showmessage('bir şey
gir')
else begin
veri:=strtoint64(edtyereldata.text);
asm
mov
al,veri
mov
dx,378h
out dx,al
end;
end;//else için
end;
procedure TForm1.btnyerelstatusClick(Sender:
TObject);
begin
asm
mov
dx,379h
in al,dx
xor
al,80h // s7 yi tersle
mov
cl,3 // cl yi 3 yap
shr
al,cl // al yi 3 bit kaydır
and
al,00001111b //s7 yi kırp,4 bit okuyoruz
mov
&sonuc,al
end ; //asm end
edtyerelstatus.text:=inttostr(sonuc);
end;
procedure TForm1.btnbaglan2Click(Sender: TObject);
begin
cdata.Address:=(edthostadr.text);
cdata.Host:=(edthostadi.text);
cdata.Port:=strtoint64(edtuzakdport.text); // port
data için
cdata.Active:=true;
end;
procedure TForm1.cdataConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
edtdrm.text:=''+cdata.Host+' adlı bilgisayara bağlıntı kuruldu.';
end;
end. //
son