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

📄 umain.pas

📁 机器人足球赛比赛平台源代码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit uMain;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, uClass, jpeg, ScktComp, ComCtrls, ToolWin, Menus,
  Buttons, Gauges;

//{$DEFINE ROBOTLOG}

const
   TEAMDLL1 = 'teamdlla.dll';
   TEAMDLL2 = 'teamdllb.dll';
   CFLDXOFFSET = 70;
   CFLDYOFFSET = 10;
   CACTFLDLEN = 600;
   CACTFLDWIDTH = 375;
   CBALLRADIUS = CACTFLDLEN div 400 * 8;

type
  TForm1 = class(TForm)
    Image1: TImage;
    Label4: TLabel;
    Label2: TLabel;
    Label1: TLabel;
    Label3: TLabel;
    ToolBar1: TToolBar;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    Gauge1: TGauge;
    procedure btnStartClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnCloseClick(Sender: TObject);
    procedure btnStopClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    amatchfield : TMatchField;
    bStop       : boolean;
    procedure drawmatch;
    procedure drawfield;
  end;

  TS_init = record
    iTeamNo : integer;
  end;

var
  Form1: TForm1;
  dllhandle1 : THandle;
  dllhandle2 : THandle;
  firstteamCMD : TCMDS;
  secondteamCMD: TCMDS;

  pMatchStat : PMS;
  pFirstTeamAState: PTS;
  pFirstTeamBState: PTS;
  pFirstBallState : PBS;

  pSecondTeamAState: PTS;
  pSecondTeamBState: PTS;
  pSecondBallState : PBS;
  timeStart:integer;
procedure initmydll_first(aS_init : TS_init);stdcall; external 'teamdlla.dll' name 'initdll';
procedure initmydll_second(aS_init : TS_init);stdcall; external 'teamdllb.dll' name 'initdll';
procedure tellmatch_first(ams : TMatchStat;atmAs: TRobotStats;atmBs: TRobotStats;abs : TBallState);stdcall; external 'teamdlla.dll' name 'tellmatchstate';
procedure tellmatch_second(ams : TMatchStat;atmAs: TRobotStats;atmBs: TRobotStats;abs : TBallState);stdcall; external 'teamdllb.dll' name 'tellmatchstate';
procedure setaction_first(pMyCMD : pCMD);stdcall; external 'teamdlla.dll' name 'setaction';
procedure setaction_second(pMyCMD : pCMD);stdcall; external 'teamdllb.dll' name 'setaction';
function getteamname_first:PChar;stdcall; external 'teamdlla.dll' name 'teamname';
function getteamname_second:PChar;stdcall; external 'teamdllb.dll' name 'teamname';
function getauthorname_first:PChar;stdcall; external 'teamdlla.dll' name 'teamauthor';
function getauthorname_second:PChar;stdcall; external 'teamdllb.dll' name 'teamauthor';
function getplayername_first(no :integer):PChar; stdcall; external 'teamdlla.dll' name 'getplayername';
function getplayername_second(no :integer):PChar; stdcall; external 'teamdllb.dll' name 'getplayername';

implementation

uses udllinterface, zlog;

{$R *.DFM}

procedure TForm1.btnStartClick(Sender: TObject);
var
  i:integer;
  s:string;
begin
  bStop := false;
  i:=timeStart;
  while  (i<=CTIMECNT) do
  begin
  try
    inc(i);
    timeStart:=i;
//    AddLog('-----------------------------------------------------');
    Gauge1.Progress := round(i * 100/ CTIMECNT);
    if bStop then
      break;
    amatchfield.TimeTip;
    amatchfield.iNow := i;
    amatchfield.iTFG := amatchfield.iTFG + 1;
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.getMatchState(pMatchStat);');
    {$ENDIF}
    amatchfield.getMatchState(pMatchStat);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.firstgetTeamAState(pFirstTeamAState);');
    {$ENDIF}
    amatchfield.firstgetTeamAState(pFirstTeamAState);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.firstgetTeamAState(pFirstTeamBState);');
    {$ENDIF}
    amatchfield.firstGetTeamBState(pFirstTeamBState);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.FirstgetBallState(pFirstBallState);');
    {$ENDIF}
    amatchfield.FirstgetBallState(pFirstBallState);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.SecondgetTeamAState(pSecondTeamAState);');
    {$ENDIF}
    amatchfield.SecondgetTeamAState(pSecondTeamAState);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.SecondGetTeamBState(pSecondTeamBState);');
    {$ENDIF}
    amatchfield.SecondGetTeamBState(pSecondTeamBState);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.SecondGetBallState(pSecondBallState);');
    {$ENDIF}
    amatchfield.SecondGetBallState(pSecondBallState);
    {$IFDEF ROBOTLOG}
        AddLog('Tellmatch_first');
    {$ENDIF}
    tellmatch_first(pMatchStat^, pFirstTeamAState^, pFirstTeamBState^, pFirstBallState^);
    {$IFDEF ROBOTLOG}
        AddLog('Tellmatch_second');
    {$ENDIF}
    tellmatch_second(pMatchStat^, pSecondTeamAState^, pSecondTeamBState^, pSecondBallState^);
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.setfirstteamaction;');
    {$ENDIF}
{  s := format('server == TeamA : (%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)'+
              'TeamB : (%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)(%d, %d, %0.1f, %0.1f)'+
              'Ball  : (%d, %d, %0.1f, %0.1f)',
              [pFirstTeamAState^[0].x, pFirstTeamAState^[0].y, pFirstTeamAState^[0].vx, pFirstTeamAState^[0].vy,
               pFirstTeamAState^[1].x, pFirstTeamAState^[1].y, pFirstTeamAState^[1].vx, pFirstTeamAState^[1].vy,
               pFirstTeamAState^[2].x, pFirstTeamAState^[2].y, pFirstTeamAState^[2].vx, pFirstTeamAState^[2].vy,
               pFirstTeamAState^[3].x, pFirstTeamAState^[3].y, pFirstTeamAState^[3].vx, pFirstTeamAState^[3].vy,
               pFirstTeamAState^[4].x, pFirstTeamAState^[4].y, pFirstTeamAState^[4].vx, pFirstTeamAState^[4].vy,
               pFirstTeamBState^[0].x, pFirstTeamBState^[0].y, pFirstTeamBState^[0].vx, pFirstTeamBState^[0].vy,
               pFirstTeamBState^[1].x, pFirstTeamBState^[1].y, pFirstTeamBState^[1].vx, pFirstTeamBState^[1].vy,
               pFirstTeamBState^[2].x, pFirstTeamBState^[2].y, pFirstTeamBState^[2].vx, pFirstTeamBState^[2].vy,
               pFirstTeamBState^[3].x, pFirstTeamBState^[3].y, pFirstTeamBState^[3].vx, pFirstTeamBState^[3].vy,
               pFirstTeamBState^[4].x, pFirstTeamBState^[4].y, pFirstTeamBState^[4].vx, pFirstTeamBState^[4].vy,
               pFirstBallState^.x, pFirstBallState^.y, pFirstBallState^.vx, pFirstBallState^.vy]);

  AddLog(s);}

    try
      amatchfield.setfirstteamaction;
    except
    end;
    {$IFDEF ROBOTLOG}
        AddLog('amatchfield.setsecondteamaction;');
    {$ENDIF}
    try
      amatchfield.setsecondteamaction;
    except
    end;
    {$IFDEF ROBOTLOG}
        AddLog('drawmatch');
    {$ENDIF}

    drawmatch;
    sleep(40);
    application.ProcessMessages;
    if amatchfield.iTFG = 1 then
      sleep(1000);
  except
  end;  
  end;
end;

procedure TForm1.drawfield;
var 
    a_init : TS_init;
begin
  a_init.iTeamNo := 1;
  initmydll_first(a_init);
  a_init.iTeamNo := 2;
  initmydll_second(a_init);
  label3.Caption := getteamname_first;
  label4.Caption := getteamname_second;
{  memo1.Lines.Add(format('TEAM:%s',[getteamname_first]));
  memo1.Lines.Add(format('Author:%s',[getauthorname_first]));
  memo2.lines.add(format('TEAM:%s',[getteamname_second]));

⌨️ 快捷键说明

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