📄 cmsitemdefine.pas
字号:
unit CMSITEMDefine;
interface
uses windows, Graphics ,math,sysutils,Classes,StrUtils;
////////////////////////////////////////////////////////////////////////////////////
////////////////////// //////////////////////////////////
///////////////////// 情报版数据格式(发送格式) ///////////////////////////////////
///////////////////// ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
const
cms_strlen = 56; //28个字
cms_txtlen = 4; //每页显示4行字
cms_bmplen = 4; //每页显示的图片最大4个
cms_leaflen = 7; //最大显示5屏
{情报板发送数据格式,接收客户端发送来的数据结构,根据数据来构造各个设备需要的情报板字符串。然后发送到
设备上,设备读取返回的数据也构造成此数据格式,发送给请求的客户端}
type
TDVCID = array[1..10] of char; //设备编号
TCMSBMP =record {情报板图片格式定义}
X :smallint;
Y :smallint;
Width:smallint;
Height:smallint;
BmpName :array[1..3] of char; //图片名称
end;
TCMSTXT=record {情报板字符格式定义}
XPos:smallint;
YPos:smallint;
FColor:TColor; //Font color;
FSize :byte;
FStype:byte; //字体类型 黑体1,宋体2,楷体3
bColor:TColor; //backgroud color;
sColor:Tcolor; //shadow color;
Fdistance:byte; // 间隔点阵数
Txtcount:byte;
Txtstring: array [1..cms_strlen] of char;
end;
PCMSDisplayLeaf = ^TCMSDisplayLeaf;
TCMSDisplayLeaf =record {情报板一页的数据格式}
LeafID : Byte;
PlayInMode : byte;
PlayOutMode : byte;
PlaySpeed : byte; //0-49;
DelayTime : smallint;
BmpCount : Byte;
TxtCount : Byte;
cmsbmpItem : array [1..cms_bmplen] of TCMSBMP;
cmsTxtItem : array [1..cms_txtlen] of TCMSTXT;
end;
TCMSPublishInfo =record {情报板发送数据格式}
CMSPort :byte; //情报板端口
CMSID :array[1..10]of char; //情报板地址
CMSWidth :smallint; //情报板宽度
CMSHeight :Smallint; //情报板高度
LeafCount :byte; //总页屏数
CMSPlayItems :array [1..cms_leaflen] of TCMSDisplayLeaf; //具体每个屏的数据格式
end;
////////////////////////////////////////////////////////////////////////////////////
////////////////////// //////////////////////////////////
///////////////////// 情报版数据格式 ///////////////////////////////////
///////////////////// ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
{情报版数据格式}
type
TCMSDSDATA = record
DVSTAT : integer; //设备故障信息
TTIME : TDateTime;
Ds : byte; //情报版数据状态
ERRERID : INTEGER; //设备故障状态代码 20071105
end;
TCMSTXTDATA = record //专门为发送情报版显示内容制定的数据格式,显示内容为文本格式
DISSTR : array [1..1000] of char; //显示内容
end;
TCMSWRITEDATA = record
Data : TCMSPublishInfo;
end;
{情报板状态数据包}
UDPCMSDSPK = record
PKHEAD : array[1..7] of char; //数据包包头 'xgssoft'
DATATYPE: BYTE; //设备类型,30
DVCID : TDVCID; //设备ID
DVCPORT : BYTE; //设备端口号
TTIME : TDATETIME; //数据采集时间
CMSDATA : TCMSDSDATA ; //情报版状态数据
end;
{情报版数据包 TXT} //DRVTYPE 31
UDPCMSTXTPK = record
PKHEAD : array[1..7] of char; //数据包包头 'xgssoft'
DATATYPE: BYTE; //设备类型,31
DVCID : TDVCID; //设备ID
DVCPORT : BYTE; //设备端口号
TTIME : TDATETIME; //数据采集时间
CMSDATA : TCMSTXTDATA ; //情报版数据
end;
{情报板播放play} //DRVTYPE 32
UDPCMSPLAYPK = record
PKHEAD : array[1..7] of char; //数据包包头 'xgssoft'
DATATYPE: Byte; //设备类型 32
DVCID : TDVCID; //设备编号
DVCPORT : BYTE; //设备端口号
//程序以段口号来区分各个设备,因为假设各
//个设备连接在不同的端口上。
TTIME : TDATETIME; //数据发布时间
USERID : array[1..10] of char; //上传者的ID
CMSPlayDATA : TCMSPublishInfo; //情报板播放数据包
end;
{情报板请求文字格式}
UDPCMSREQDATAPK = record // 请求情报板 文字格式的数据
PKHEAD : array[1..7] of char; // 数据包包头 'xgssoft'
DATATYPE: Byte; // 设备类型 33
DVCPORT : BYTE; // 设备端口
TTIME : TDATETIME; // 时间
end;
{情报板请求数据格式}
UDPCMSREQPLAYPK = record // 请求情报板 PLAY 的数据
PKHEAD : array[1..7] of char; // 数据包包头 'xgssoft'
DATATYPE: Byte; // 设备类型 34
DVCPORT : BYTE; // 设备端口
TTIME : TDATETIME; // 时间
end;
//35 表示客户请求情报板状态数据
{情报版返回数据格式}
PCmsDataRec = ^TCmsDataRec; // 串口传来的数据类型
TCmsDataRec = record //
TTime : TDateTime; // 数据时间
FuncID : Longint; // 0为不可用
Value : TCMSDSDATA; // 数据内容 情报板数据
Value2 : TCMSWRITEDATA; // 数据2 写入或者读取其他的数据
Port : Word; // 端口
Address: Byte; //设备地址
Ds : Byte; // 数据返回状态 2005.08.01 增加DS 表明数据取回状态
end;
////////////////////////////////////////////////////////////////////////////////
function transferTColorToCCCStr(s:TColor):string;
function TurnStructToPlayList( fCmsPlayLeaf :TCMSDisplayLeaf) :string;
procedure splitToList(sourceStr,splitStr:String; s:TStrings);
function TurnStrToCmsPublishFormat(s:string) :TCMSPublishInfo;
function ReadFromTxtFile(fileName:string) :string;
implementation
function transferTColorToCCCStr(s:TColor):string;
var r,g,b:integer;
ss:string;
begin
ss:= IntToHex(s,6) ;
r := StrToInt('$'+copy(ss,5,2));
g := StrToInt('$'+copy(ss,3,2));
b := StrToInt('$'+copy(ss,1,2));
result:= copy(inttostr(r+1000),2,3) + copy(inttostr(g+1000),2,3) +copy(inttostr(b+1000),2,3)+'000';
end;
function TurnStructToPlayList( fCmsPlayLeaf :TCMSDisplayLeaf) :string;
var
CmsBmp : TCMSBMP; //情报板图片内容
CmsTxt : TCMSTXT; //情报板文字内容
CmsLeafCount, CmsBmpCount, CmsTxtCount, TxtCount : Byte; //每一屏的 情报板总的屏数, 情报板的图片数, 情报板的文字数
i,j,k,m :Integer;
tmpstr,content,tmptxt :String; //临时字符串,总的构造字符,临时文字
FontType,bgcolor,shcolor,fdistance :string; //字体,背景颜色,阴影颜色,字符间距
xpos,ypos :integer;
xposstr,yposstr :string;
RDSValue:integer;
begin
CmsBmpCount := fCmsPlayLeaf.BmpCount; //当前屏的总图片数量
CmsTxtCount := fCmsPlayLeaf.TxtCount; //当前屏的总文字行数
tmpstr := inttostr(fCmsPlayLeaf.DelayTime)+','+inttostr(fCmsPlayLeaf.PlayInMode)+','+
inttostr(fCmsPlayLeaf.PlaySpeed)+',';
//停留时间,出字方式,播放速度
content := Content +tmpstr;
tmpstr := '';
//图片处理
//1 图片位置, 处理关于
xpos := CmsBmp.X;
ypos := CmsBmp.Y;
if xpos<0 then xposstr :='0'+ copy(inttostr(1000+xpos),2,3) else xposstr := copy(inttostr(1000+XPos),2,3);
if ypos<0 then yposstr :='0'+ copy(inttostr(1000+YPos),2,3) else yposstr := copy(inttostr(1000+YPos),2,3);
for j:=1 to CmsBmpCount do
begin
CmsBmp := fCmsPlayLeaf.CmsBmpItem[j];
tmpstr := tmpstr+'\C'
+ xposstr
+ yposstr
+ '\B'+CmsBmp.BmpName; //增加图片的显示功能
end;
content := Content +tmpstr;
tmpstr :='';
//文字信息
for k := 1 to CmsTxtCount do
begin
CmsTxt := fCmsPlayLeaf.CmsTxtItem[k];
case CmsTxt.FStype of
1: FontType :='h';
2: FontType :='k';
3: FontType :='s';
end;
TxtCount := CmsTxt.Txtcount;// High(CmsTxt.TxtString)+1;
tmptxt :='';
tmpstr :='';
for m:=1 to TxtCount do tmptxt := tmptxt + CmsTxt.TxtString[m]; //文字部分
if CmsTxt.bColor= rgb(0,0,0) then bgcolor:='' else bgcolor :=transferTColorToCCCStr(CmsTxt.bColor); //背景颜色
if CmsTxt.sColor= rgb(0,0,0) then shcolor:='' else shcolor :=transferTColorToCCCStr(CmsTxt.sColor); //前景颜色
if CmsTxt.Fdistance= 0 then fdistance :='\S00' else fdistance := '\S'+copy(inttostr(100+CmsTxt.Fdistance),2,2) ;//字符间距
xpos := CmsTxt.XPos;
ypos := CmsTxt.YPos;
if xpos<0 then xposstr :='0'+ copy(inttostr(1000+XPos),2,3) else xposstr := copy(inttostr(1000+XPos),2,3);
if ypos<0 then yposstr :='0'+ copy(inttostr(1000+YPos),2,3) else yposstr := copy(inttostr(1000+YPos),2,3);
tmpstr := tmpstr
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -