⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 串口发送水文数据
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, SPComm, StdCtrls;

type
  TForm1 = class(TForm)
    Comm1: TComm;
    Timer1: TTimer;
    Button1: TButton;
    ComboBox1: TComboBox;
    Label1: TLabel;
    ComboBox2: TComboBox;
    Label2: TLabel;
    Label4: TLabel;
    ComboBox3: TComboBox;
    Label5: TLabel;
    ComboBox4: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
  zz:boolean;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
comm1.StartComm ;
zz:=true;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
comm1.StopComm ;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
stx:array[0..1] of char;
num1:integer;
num2:integer;
num3:integer;
num4:integer;
num5:integer;
num6:integer;
num7:integer;
s:string;
fa:string;
str:array[0..7] of char;
begin
  num1:=88;
  num2:=strtoint(combobox1.Text );
  num3:=strtoint(combobox2.Text );
  s:=combobox3.Text;
  if  s='好' then
  num4:=1
  else if  s='中' then
  num4:=2
  else if  s='差' then
  num4:=3
  else if  s='很差' then
  num4:=4;
  num5:=strtoint(combobox4.Text );
  num6:=(num1 xor num2 xor num3 xor num4 xor num5) and 127;
  num7:=0;
  fa:=inttostr(num1)+inttostr(num2)+inttostr(num3)+inttostr(num4)+inttostr(num5)+inttostr(num6)+inttostr(num7);
for i:=0 to 7 do
  str[i]:=char(fa[i]);
  comm1.WriteCommData(str,8);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -