📄 prodave60.pas
字号:
unit Prodave60;
interface
uses Messages, SysUtils,Classes,Forms,Windows,Dialogs,StrUtils;
Const
Prodave6='Prodave6.dll';
Type
Ptm=^tm;
tm=Record
tm_hour :Integer; //'Hours since midnight (0 ?23)
tm_isdst:Integer; //'Positive if daylight saving time is in effect; 0 if daylight saving time is not in effect; negative if status of daylight saving time is unknown. The C run-time library assumes the United States抯 rules for implementing the calculation of Daylight Saving Time (DST).
tm_mday :Integer; //'Day of month (1 ?31)
tm_min :Integer; //'Minutes after hour (0 ?59)
tm_mon :Integer; //'Month (0 ?11; January = 0)
tm_sec :Integer; //'Seconds after minute (0 ?59)
tm_wday :Integer; //'Day of week (0 ?6; Sunday = 0)
tm_yday :Integer; //'Day of year (0 ?365; January 1 = 0)
tm_year :Integer; //'Year (current year minus 1900)
end;
Type
PTTIMESTAMP=^TTIMESTAMP;
TTIMESTAMP=Record
Timestamp:Array[1..8] of Byte ;
End;
Type
CON_ADR_TYPE=Record
Adresse:Array[1..6] of byte; //' MPI Stationsadresse (2 |0 |0 |0 |0 |0 )
End; //' IP Adresse (192|168|0 |1 |0 |0 )
//' MAC Adresse (08 |00 |06 |01 |AA |BB )
Type
PCON_TABLE_TYPE=^CON_TABLE_TYPE;
CON_TABLE_TYPE=Record
Adr : CON_ADR_TYPE ; //' Verbindungsadresse
AdrType : Byte ; //' Typ der Adresse MPI(1) IP(2) MAC(3)
SlotNr : Byte ; //' Slot-Nummer
RackNr : Byte ; //' Rack-Nummer
End;
Type
PAS_INFO_TYPE=^AS_INFO_TYPE;
AS_INFO_TYPE=Record
Plcas :Array[1..4] of Char; //' TypAusgabestand PLC
Pgas :Array[1..2] of Char; //' TypAusgabestand PGAS
mlfb :Array[1..20] of char; //' MLFB der angeschlossenen AS
END;
Type
PAS200_INFO_TYPE=^AS200_INFO_TYPE;
AS200_INFO_TYPE=Record
Firmware:integer;
ASIC :integer;
mlfb :array[1..16] of char; //' MLFB der angeschlossenen AS
end;
Type
PBST_DIAG_TYPE=^BST_DIAG_TYPE;
BST_DIAG_TYPE=Record
blknr:SmallInt; //' Bausteinnummer
Timestamp:tm; //' Zeitstempel zu der Bausteinnummer
End;
Type
PDIAG_BUFFER_TYPE=^DIAG_BUFFER_TYPE;
DIAG_BUFFER_TYPE=Record
EventID:SmallInt ; //' EreignisID
EventInfo:Array[1..10] of Byte ; //' Info zum Ereignis
Timestamp:TTIMESTAMP ; //' Zeitstempel des Ereignises
End ;
Type
PBST_STAT_TYPE=^BST_STAT_TYPE;
BST_STAT_TYPE=Record
blkType:SmallInt ; //' Bausteintyp
BlkNumber:SmallInt ; //' Bausteinnummer
BlkName :Array[1..8] of char; //' Bausteinname
BlkVersion :SmallInt ; //' Bausteinversion
BlkLength :Integer; //' Bausteinl鋘ge
BlkTimestamp1:tm; //' Zeitstempel zu der Bausteinnummer
BlkTimestamp2:tm; //' Zeitstempel zu der Bausteinnummer
blkSecurity:Array[1..3] of byte; //' Baustein Schutzstufe
End;
Type
PBST_HEADER_TYPE=^BST_HEADER_TYPE;
BST_HEADER_TYPE=Record
ProgLang :byte; //' Programiersprache
blkType :Byte; //' Bausteintyp
BlkNumber : SmallInt ; //' Bausteinnummer
Attribute : Byte ; //' Attribute
BlkVersion :SmallInt; //' Bausteinversion
BlkLength :Integer; //' Bausteinl鋘ge
Length :array[1..3] of integer; //' Datenl鋘ge
DynLen :SmallInt; //' L鋘ge der dyn. lokal Daten
BlkTimestamp1 : tm; //' Zeitstempel zu der Bausteinnummer
BlkTimestamp2 : tm; //' Zeitstempel zu der Bausteinnummer
blkSecurity:Array[1..3] of Byte; //' Baustein Schutzstufe
ProducerName :Array[1..8] of Char;//' Producer Name
BlkFamName :Array[1..8] of Char; //' Baustein Familien Name
BlkName :Array[1..8] of Char; //' Bausteinname
Version :SmallInt; //' Dies ist eine Anwenderversion und hat nicht mit der Bausteinversion zu tun
chckSum :SmallInt; //' Checksumme
CPUType :integer; //' CPU-Typ
signature :SmallInt; //'signature
End ;
type
Pbyte =^byte;
PInteger=^integer;
Pword=^Word;
//---------------------------------------------------------------------
Function GetErrorMessage_ex6(ErrNUM:integer):String;
//---------------------------------------------------------------------
Function LoadConnection_ex6(ConNr:Smallint;AccessPoint:Pchar;ConTableLen:Smallint;
pConTable:PCON_TABLE_TYPE):integer ;stdcall;
Function SetActiveConnection_ex6(ConNr:Smallint):integer;stdcall;
Function UnloadConnection_ex6(ConNr:Smallint):integer;stdcall;
Function as_info_ex6(BufLen:integer;pInfoBuffer:PAS_INFO_TYPE;pDatLen:Pinteger):integer; stdcall;
Function as_zustand_ex6(pState:Pbyte):integer;stdcall;
Function db_buch_ex6(BufLen:integer;pBuchBuffer: Pword;pDatLen:Pinteger):integer;stdcall;
Function db_read_ex6(blknr:Integer;DatType:byte;StartNr:integer;Amount:pinteger;
BufLen:Integer;pBuchBuffer:Pointer;pDatLen:PInteger):integer;stdcall;
Function db_write_ex6(blknr:Integer;DatType:byte;StartNr:integer;Amount:Pinteger;
BufLen:integer;pWriteBuffer:Pointer):integer;stdcall;
Function bst_read_diag_ex6(blkType:integer;StartNr:Smallint;Amount:integer;
BufLen:Integer;pDiagBuffer:Pointer{byte};pDatLen:Integer):integer; stdcall;
Function bst_read_stat_ex6(blkType:integer;BufLen:Integer;pStatBuffer:Pointer{byte};
PdadLen:Pinteger):integer;stdcall;
Function read_diag_buf_ex6(Buflen:Integer;pDiagBuffer:Pointer{byte};pDatLen:Pinteger):Integer;stdcall;
Function field_read_ex6(FieldType:Char;blknr:Smallint;StartNr:integer;Amount:integer;
BufLen:Integer;pBuffer:Pointer{Byte};pDatLen:pInteger):integer;stdcall;
Function field_write_ex6(FieldType:Char;blknr:Smallint;StartNr:Smallint;Amount:integer;
BufLen:Integer;pBuffer:Pointer{byte}):integer;stdcall;
Function mb_setbit_ex6(MbNr:Smallint;BitNr:Smallint;Value:byte):integer;stdcall;
Function mb_bittest_ex6(MbNr:Smallint;BitNr:Smallint;Value:PByte):integer;stdcall;
//-----------------------------------------------------------------------------------------------
//-------------------S7200 PLC
//-----------------------------------------------------------------------------------------------
implementation
//------------------------------------------------------------------------------
Function GetErrorMessage_ex6(ErrNUM:integer):String;
var
ErrList:Tstringlist;
CurErr :string[255];
ErrCount,i:integer;
ErrHead:string;
ErrNo:integer;
errName:String;
CurDir:String;
begin
CurDir := ExtractFilePath(ParamStr(0));
if RightStr(CurDir,1) <> '\' then
CurDir := CurDir + '\';
if not FileExists(CurDir + 'error.dat') then begin
Result:='故障列表文件不存在,请重新安装程序.或未知错误代码! ';
exit;
end;
errhead:=Concat('0x',IntToHex(ErrNUM,4));
try
ErrList:=Tstringlist.Create;
Errlist.LoadFromFile(CurDir + 'error.dat');
ErrCount:=ErrList.Count;
for i:=0 to (ErrCount-1) do
begin
CurErr:=trim(ErrList.Strings[i]);
if Pos(errhead,CurErr)>0 then begin
Result:=(Copy(CurErr,8,Length(CurErr)));
break;
end;
end;
if Trim(Result)='' then
Result:='未知错误!,请检查是否在线或请先激活连接.';
finally
ErrList.Free;
end;
end;
//-----------------------------------------------------------------------------
Function LoadConnection_ex6;external Prodave6 name 'LoadConnection_ex6';
Function SetActiveConnection_ex6;external Prodave6 name 'SetActiveConnection_ex6';
Function UnloadConnection_ex6;external Prodave6 Name 'UnloadConnection_ex6';
Function as_info_ex6;external Prodave6 Name 'as_info_ex6';
Function as_zustand_ex6;external Prodave6 Name 'as_zustand_ex6';
Function db_buch_ex6;external Prodave6 Name 'db_buch_ex6';
Function db_read_ex6;external Prodave6 Name 'db_read_ex6';
Function db_write_ex6;external Prodave6 Name 'db_write_ex6';
Function bst_read_diag_ex6;external Prodave6 Name 'bst_read_diag_ex6';
Function bst_read_stat_ex6;external Prodave6 Name 'bst_read_stat_ex6';
Function read_diag_buf_ex6;external Prodave6 Name 'read_diag_buf_ex6';
Function field_read_ex6;external Prodave6 Name 'field_read_ex6';
Function field_write_ex6;external Prodave6 Name 'field_write_ex6';
Function mb_setbit_ex6;external Prodave6 Name 'mb_setbit_ex6';
Function mb_bittest_ex6;external Prodave6 Name 'mb_bittest_ex6';
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -