unit US200;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TFS200 =
class(TForm)
TestGrid: TStringGrid;
procedure FormActivate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
FS200: TFS200;
plc_adr_table :
array[0..15]
of byte;
plc_name :
array[0..255]
of char;
null, max_maschinen, max_buffer, res1,res2,res3 : integer;
buffer :
array[0..50]
of byte;
mzaehler :
array[0..25]
of word;
const
max_buffer1 = 10;
implementation
{$R *.dfm}
function Load_tool ( no :Byte;
name:
{Pointer}PChar;
adr:
{pointer}PChar):integer;
stdcall;
external '
w95_s7m.dll'
name '
load_tool';
function as200_vs_field_read ( no :integer;
var anz:integer;
var buffer):integer;
stdcall;
external '
w95_s7m.dll'
name '
as200_vs_field_read';
//function as200_ag_zustand ( var buffer):integer;
//stdcall;
//external 'w95_s7m.dll' name 'as200_ag_zustand';
function Unload_tool:integer;
stdcall;
external '
w95_s7m.dll'
name '
unload_tool';
procedure TFS200.FormActivate(Sender: TObject);
var
i,j : integer;
state : char;
begin
max_maschinen := 10;
max_buffer := max_maschinen * 2;
null := 0;
plc_adr_table[0] := 2;
//adresse
plc_adr_table[1] := 0;
//segment id
plc_adr_table[2] := 2;
//rack nr
plc_adr_table[3] := 0;
//slot nr
plc_adr_table[4] := 0;
//adresse
plc_adr_table[5] := 0;
//segment id
plc_adr_table[6] := 2;
//rack nr
plc_adr_table[7] := 0;
//slot nr
strcopy(plc_name,'
S7ONLINE');
res1 := Load_Tool(1,addr(plc_name),addr(plc_adr_table[0]));
res2 := as200_vs_field_read(null, max_buffer, buffer );
res3 := unload_Tool;
j := 0;
// Die Bytes zu WORDS zusammensetzen
for i:=0
to max_maschinen
do
begin
mzaehler[i] := 0;
mzaehler[i] := buffer[j]
shl 8;
mzaehler[i] := mzaehler[i] + buffer[j+1];
inc(j);
inc(j);
end;
FS200.Close;
end;
end.