⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsitemdefine.pas

📁 程序主要是在监控系统中的车辆检测与其他设备协议的测试程序
💻 PAS
📖 第 1 页 / 共 2 页
字号:
               +'\C'+xposstr +yposstr       //X坐标  y坐标
               +'\f'+ FontType             //字体大小   1616,2424,3232
               +inttostr(CmsTxt.FSize)+inttostr(CmsTxt.FSize)                         //字体
               +'\b'+bgcolor          //背景颜色
               +'\s'+shcolor          //前景颜色                            
               +'\c'+transferTColorToCCCStr(CmsTxt.FColor)    //字符颜色
               //+fdistance //字符间距   //去掉字间距
               +tmptxt;
       content := Content +tmpstr;
     end;
   Result := content ;

end;
/////////////////////////////////////////////////////////////////////////////////
// 功能 :将字符串根据分隔符转换到字符串数组中 
/////////////////////////////////////////////////////////////////////////////////
procedure  splitToList(sourceStr,splitStr:String; s:TStrings);
var
  p,slen:integer;
  ss,items:string;
begin
  s.Clear;
  ss:= sourceStr;
  slen :=length(splitStr);  //分解字符长度
  p :=   pos(splitStr,ss);
  while p>0 do
  begin
    items  := copy(ss,1,p-1) ;
    if  trim(items)<>'' then  s.Add(items);
    delete(ss,1,p+slen-1);
    p :=  pos(splitStr,ss);
  end;
  if trim(ss)<>'' then s.Add(ss);
end;
/////////////////////////////////////////////////////////////////////////////////
{
    [list]
    item_no=2
    item0=200,1,2,\fk3232\C000000\c255255000000sadasdasdas
    item1=200,1,2,\fk3232\C000000\c255255000000assssssssssssss
    }
//将字符串类型转换为情报板发送格式
/////////////////////////////////////////////////////////////////////////////////
function TurnStrToCmsPublishFormat(s:string) :TCMSPublishInfo;
var tmpstr,s1,str :string;
    s_lists,s_listsc,s_listsx : TStringList;
    leafcount,lastleafcount,bmpcount,txtcount :integer;
    i,j,k,mpos,npos:integer;
    CmsTxt :TCMSTXT;
    CmsBmp :TCMSBMP;
    Cmsleaf:TCMSDisplayLeaf;
    CmsDisInfo :TCMSPublishInfo;
    fonttype :string;
    leafindex:integer;
begin
  s_lists := TStringList.Create;   //播放列表分组
  s_listsc:= TStringList.Create;   //处理换行文字部分
  splitToList(s,#13#10,s_lists);  //划分为数组
  leafcount := s_lists.count-2;   //总的屏数
  lastleafcount := leafcount;
  leafindex := 1;
  for i := 1 to leafcount do
  begin
    if i>cms_leaflen then  Break; //大于最大值,跳出
    tmpstr := s_lists.Strings[i+1];  //当前行的文字信息
    bmpcount :=0;
    txtcount :=0;

    mpos := pos('\',tmpstr);
    //首先计算前面一段 itemx=100,0,100,
    //item0=aaaaaa,bb,cc,str  延迟时间,入屏方式,播放速度
    s1   := copy(tmpstr,1,mpos-1);
    //处理s1
    mpos := pos('=',s1);
    if mpos=0 then
    begin
      lastleafcount := lastleafcount-1;
      Continue;
    end;
    s1   := copy(s1,mpos+1,length(s1));

    mpos := pos(',',s1);
    Cmsleaf.DelayTime   := strtoint(copy(s1,1,mpos-1));        //延迟时间
    delete(s1,1,mpos);

    Cmsleaf.LeafID      := i;         //当前屏的序号

    mpos := pos(',',s1);
    Cmsleaf.PlayInMode  := strtoint(copy(s1,1,mpos-1));        //入屏方式
    delete(s1,1,mpos);

    mpos := pos(',',s1);
    Cmsleaf.PlaySpeed   := strtoint(copy(s1,1,mpos-1));        //播放速度

    //处理剩下的部分
    s1   := copy(tmpstr,mpos,length(tmpstr));
    splitToList(s1,'\C',s_listsc);
    for j :=0  to s_listsc.Count-1 do
    begin
      s1 := s_listsc.Strings[j];  //000000\Bbbb ; 000000\fh1616\文字;
      mpos := pos('\B',s1);       //判断是否图片
      if mpos>0 then
      begin
        bmpcount := bmpcount+1;
        CmsBmp.X := strtoint(copy(s1,1,3));  //000
        CmsBmp.Y := strtoint(copy(s1,4,3));  //000
        npos := pos('\B',s1);
        if npos>0 then begin
          for k := 1  to 3 do  CmsBmp.BmpName[k] := copy(s1,npos+2,3)[k];  //图片名称
        end;
        CmsBmp.Height :=0;
        CmsBmp.Width  :=0;
        if bmpcount<=cms_bmplen then  Cmsleaf.cmsbmpItem[bmpcount] := CmsBmp
        else bmpcount := cms_bmplen;
      end;

      mpos := pos('\c',s1); //判断文字  C021021\fh1616\c255000000000\W我爱你,我的老婆
      if mpos>0 then
      begin
        txtcount := txtcount+1;

        //背景颜色
        npos := pos('\b',s1);
        if npos>0 then CmsTxt.bColor := rgb(strtoint(copy(s1,npos+2,3)),
                                            strtoint(copy(s1,npos+5,3)),
                                            strtoint(copy(s1,npos+8,3)))
        else   CmsTxt.bColor    := 0;

        //阴影色
        npos := pos('\s',s1);
        if npos>0 then CmsTxt.sColor := rgb(strtoint(copy(s1,npos+2,3)),
                                            strtoint(copy(s1,npos+5,3)),
                                            strtoint(copy(s1,npos+8,3)))
        else  CmsTxt.sColor    := 0;

        //字符间距
        npos := pos('\S',s1);
        if npos>0 then CmsTxt.Fdistance := strtoint(copy(s1,npos+2,2))
        else  CmsTxt.Fdistance := 0;

        //字体
        npos := pos('\f',s1);
        if npos>0 then
        begin
          fonttype := copy(s1,npos+2,1);  //h,
          CmsTxt.FSize := strtoint(Copy(s1,npos+3,2));
        end
        else
        begin
          fonttype :='h';
          CmsTxt.FSize := 32; //默认值为32*32
        end;
        CmsTxt.FStype := 1;
        if fonttype='h' then CmsTxt.FStype := 1;
        if fonttype='k' then CmsTxt.FStype := 2;
        if fonttype='s' then CmsTxt.FStype := 3;

        //字符颜色
        npos := pos('\c',s1);
        if npos>0 then
        begin
           CmsTxt.FColor := rgb(strtoint(copy(s1,npos+2,3)),
                                        strtoint(copy(s1,npos+5,3)),
                                        strtoint(copy(s1,npos+8,3))) ;
                       str := trim(copy(s1,npos+14,length(s1)-npos-14+1));

        end else  begin
          CmsTxt.FColor := 0;
          str:='';
        end;

        {//文字部分
        npos := pos('\S',s1);
        if npos>0 then
        begin
          str := copy(s1,npos+4,length(s1));
          str := AnsiReplaceStr(str,'\A',#13#10);
        end else str :='';
        }

        CmsTxt.Txtcount  := length(str);

        CmsTxt.XPos := strtoint(copy(s1,1,3));
        CmsTxt.YPos := strtoint(copy(s1,4,3));
        for k := 1 to length(str) do CmsTxt.Txtstring[k] := str[k];

        //CmsTxt.Txtstring :='';
        if txtcount<=cms_txtlen then  Cmsleaf.cmsTxtItem[txtcount] := CmsTxt
        else txtcount := cms_txtlen;
      end;

    end;
    Cmsleaf.BmpCount := bmpcount;  //当前屏的图片数量
    Cmsleaf.TxtCount := txtcount;  //当前屏的文字数量


    CmsDisInfo.CMSPlayItems[leafindex] := Cmsleaf;
    inc(leafindex);
  end;

  CmsDisInfo.CMSHeight := 0;
  CmsDisInfo.CMSWidth  := 0;
  CmsDisInfo.LeafCount := lastleafcount;
  CmsDisInfo.CMSPort   := 0;
  CmsDisInfo.CMSID     := '0000000000';

  result := CmsDisInfo;
  s_lists.Free;
  s_listsc.Free;

end;
////////////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////////////
function ReadFromTxtFile(fileName:string) :string;
var
  f:textfile;
  filestr:string;
  tempch:char;
begin
   AssignFile(f,fileName);
   reset(f);
   while not eof(f) do
   begin
     read(f,tempch);
     filestr:=filestr+tempch;
   end;
   CloseFile(F);
   result := filestr;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -