?? 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 + -