📄 unit1.~pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ZLib;
const
KKIL_STPOS = 10; //船位数据个数
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
imhead_t = record // 消息头数据 16 B
mtype: Integer; // 消息类型
priority: char; // 消息优先级KKCON_PRIORITY_LOW
// KKCON_PRIORITY_NORMAL
// KKCON_PRIORITY_HIGH
// KKCON_PRIORITY_EMERGENCY
majorversion: char; // 接口主版本号
minorversion: char; // 接口副版本号
reply: char; // 要求回复(1=回复,0=不需回复)
sequid: Integer; // 回复时对应的消息流水号
fz: char; // 仿真数据标识KKCON_FZDATA,KKCON_NOTFZDATA
systemID: char; // 使用了一个备用字节用作系统标志,1:NSHM南沙船位监测;2:XZMZ西藏明珠;3:中海油;
rsv: Array[0..2-1] of char; // 备用,在本系统中一个字节用作系统标志,现在的备用只剩下两个字节
end;
// 物理地址数据子结构
immdcitocp_addr_t = record //union
case Integer of
//int Type; //
0: ( iaddr: Integer); // 整数形式 =KKCON_SRCTYPE_INT
1: ( caddr: Array[0..16-1] of char); // 字符串形式 =KKCON_SRCTYPE_STR
end;
Pimmdcitocp_addr_t = ^ immdcitocp_addr_t;
SingleAddr = record
mType: Integer; //地址类型:1:北斗;2:海事;3:手机:4:CDMA //add by fqy 20061001为解决一条船上同时安装北斗、海事的问题
LogicID: Integer; // 信源逻辑编号,=逻辑号;=0无逻辑号值,由编码地址表示;=-1广播地址)
TermSeqID: Integer; // 终端序号
TermProtocal: Integer; // 终端协议版本:10表示老版本终端1.0版,20表示新海洋渔业终端2.0版
AddrType: Integer; // 信源编码类型(KKCON_SRCTYPE_INT/KKCON_SRCTYPE_STR)
Addr: immdcitocp_addr_t; // 信源编码,即终端原是的卡号码
end;
PSingleAddr = ^ SingleAddr;
////////////////////////////////////////////////////////////////
// 一体机业务状态
YTJWorkStatus = record
PosStatus: Integer; // 定位状态P: 表示对应采样点的定位状态,0-定位成功,1-定位不成功;
PowerType: Integer; // 供电类别T: 0表示外接电源供电,1表示内置电池供电;
PowerLeft: Integer; // 电池剩余电量L: 0:≤25%; 1:25-50%;2:50-75%;3:≥75%
end;
PYTJWorkStatus = ^ YTJWorkStatus;
////////////////////////////////////////////////////////////////
// s_imposdata,定位数据包
imposdata_t = record
t: Integer; // 定位数据时间(秒)----秒以上的部分
msec: Smallint; // 定位数据时间(毫秒)--当秒的毫秒部分
coor: Smallint; // 坐标系标识 KKCON_COOR_BJ54, KKCON_COOR_WGS84
l: double; // 定位经度
b: double; // 定位纬度
h: double; // 定位高程
v: double; // 定位速度
a: double; // 定位方位角
sig: double; // 定位精度
devh: double; // 定位高程异常
end;
Pimposdata_t = ^ imposdata_t;
imstpos_t = record
head: imhead_t; // 消息头,消息类型 KKIMSTPOS
Src: SingleAddr; // 定位数据产生者标识,载体的LogicID
Dst: SingleAddr; // 信息接收方
status: YTJWorkStatus;
posmode: Integer; // 定位数据方式(KKCON_BDPOS,KKCON_GPSPOS,KKCON_BDEMGPOS)
sec: Integer; //add by fqy 20061107加上时间作为台站和通信控制中心数据库存储时间统一用,该时间从解码来
haspos: Integer; // 定位数据个数 0<=haspos<=KKIL_STPOS
pos: Array[0..KKIL_STPOS-1] of imposdata_t; // 定位数据
end;
Pimstpos_t = ^ imstpos_t;
function CompressBuffer(InS: PChar; IL: Integer;
OutS: PChar; out OL: Integer): Integer; stdcall; external '..\Compress.dll';
function DecompressBuffer(InS: PChar; IL: Integer;
OutS: PChar; out OL: Integer): Integer; stdcall; external '..\Compress.dll';
var
Form1: TForm1;
implementation
var
Buf: Array [0..10000] of Char;
OBuf: Array [0..10000] of Char;
IBuf: Array [0..10000] of Char;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
L, H: Integer;
begin
StrCopy(Buf, '2222888888885555555555555555555555558888888888888233333');
H := StrLen(Buf);
CompressBuffer(Buf, H, OBuf, L);
DecompressBuffer(OBuf, L, IBuf, H);
ShowMessage(IBuf);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Pos: imstpos_t;
Buf: Array [0..10000] of char;
S, L, LO: Integer;
Pos1: imstpos_t;
begin
Zeromemory(@Pos, SizeOf(Pos));
Pos.head.mtype := 100;
Pos.head.priority := Chr(1);
Pos.head.majorversion := Chr(1);
Pos.head.minorversion := #3;
Pos.head.reply := '1';
Pos.head.sequid := 9998;
Pos.head.fz := #1;
Pos.head.systemID := #1;
Pos.Src.mType := 1;
Pos.Src.LogicID := 23456;
Pos.Src.TermSeqID := 43566;
Pos.Src.TermProtocal := 1;
Pos.Src.AddrType := 0;
Pos.Src.Addr.iaddr := 87675;
Pos.Dst.mType := 1;
Pos.Dst.LogicID := 23456;
Pos.Dst.TermSeqID := 4435566;
Pos.Dst.TermProtocal := 1;
Pos.Dst.AddrType := 0;
Pos.Dst.Addr.iaddr := 866765;
Pos.status.PosStatus := 55566;
Pos.status.PowerType := 4;
Pos.status.PowerLeft := 3;
Pos.posmode := 3;
Pos.sec := 234343445;
Pos.haspos := 2;
for L:=0 to Pos.haspos-1 do
begin
Pos.pos[0].t := 23232323 ;
Pos.pos[0].msec := 222 + L;
Pos.pos[0].coor := 22 + L;
Pos.pos[0].l := 110.66677 + L;
Pos.pos[0].b := 45.776545 + L;
Pos.pos[0].h := 23.45 + L;
Pos.pos[0].v := 44.555 + L;
Pos.pos[0].a := 323.33 + L;
Pos.pos[0].sig := 11.22 + L;
Pos.pos[0].devh := 3.45676 + L;
end;
S := SizeOf(Pos);
CompressBuffer(@Pos, S, Buf, L);
DecompressBuffer(Buf, L, @Pos1, LO);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -