找传奇、传世资源到传世资源站!

各类磅秤通讯测试

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】

【相关图片】

from clipboard

【源码结构】

unit constdef;
//系统用到的一些常量、变量,函数、过程的定义pas
interface
uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, DB, DBTables, StdCtrls, DBGrids, Grids, Buttons;

type
//实际上,crn的数组中,一部分发给吊车的指令,不一定在执行;
//另一部分是吊车当前的状态,有可能是上一次作业的状态,是根据返回值展开的。因此,必须从概念上区分开!!!!
  Trec_CraneData=record
      i_crn_sts  : integer;    //status

      s_commandstr : String;   //command
      i_kind   : integer;     //command
      i_Wrk_no : integer;     //command

      i_ctn_type: integer;
      i_fstn:Integer;          //吊车的出入库站编号
      i_tstn:Integer;          //吊车的出入库站编号
      s_Flocno:String;          //command
      s_Tlocno:String;          //command

      s_F_stano:String;          //工作档的起始站点编号
      s_T_stano:String;          //工作档的起始站点编号

      r_x0:real;
      r_y0:real;

      r_x1:real;
      r_y1:real;

      r_x2:real;
      r_y2:real;

      r_x:real;
      r_y:real;

      i_s_time:integer     ;

      i_s_time1:integer     ;
      i_s_time2:integer     ;

      i_r_time:integer     ;


      i_Errcod:Integer;      //status
      i_onHP:Integer;        //status
  end;

  Trec_plc_stn_Data=record
      s_dev_no   : String;
      s_type_mk  : String;
      s_term_mk  : String;
      i_status : integer;

      i_plc_no : integer;
      i_Wrk_no : integer;
      i_Wrk_no1 : integer;
      i_ctn_type: integer;
      i_pak_mk : integer;
      i_buff_count : integer;

      s_from_stn    : String;
      s_next_stn    : String;
      s_t_station  : String;

      i_s_time:Integer;
      i_t_time:Integer;
      i_tr_position:Integer;
      s_tr_stn  : String;

      s_autoing    : String;
      s_loading    : String;
      s_canining  : String;
      s_canouting  : String;
      s_fronting    : String;
      s_hight     : String;
      s_middle        : String;
      s_low     : String;
      s_inreq1       : String;
      s_inreq2      : String;
      s_error      : String;
      s_rev_dev_no   : String;

      i_past_time:Integer;
      s_begin_mk : String;
      i_req_mk      :integer;

  end;


  const
   ci_moxport_count=14      ;
   ci_crn_count=10      ;
   //ci_crn_count=9      ;
   ci_scale_count=1      ;
   ci_bcscale_count=2 ;
   ci_crn_title_count=10 ;
   cs_ar_crntitle : Array[0..ci_crn_title_count-1] of String
      =('吊车号','吊车状态','ID号','源站','目标站','源库位','目标库位','原点否','异常代号','吊车命令');
   ci_trolly_count=1;
   ci_out_io_pri=10;
   ci_sta_count=371 ;
   ci_plc_error_count=720 ;
   ci_plc_error_count1=519;
   ci_plc_error_count2=96;

  ci_sta_title_count=8 ;

  cs_ar_statitle : Array[0..ci_sta_title_count-1] of String
      =('序号','站点','ID号','自动','有物',
      '可入','可出','目标');

  {CRN STATUS}
   ch_crn1_online         = $0001;
   ch_crn1_idle           = $0002;
   ch_crn1_error          = $0004;
   ch_crn1_error_tohp     = $0008;

   ch_crn1_hp             = $0010;

   {CRN1 STATUS1}
    ch_crn2_manual    =$0001;         //手动模式
    ch_crn2_auto      =$0002;         //自动模式
    ch_crn2_online    =$0004;         //电脑模式
    ch_crn2_manual1   =$0008;         //手动中
    ch_crn2_auto1     =$0010;         //自动中
    ch_crn2_online1   =$0020;         //电脑模式中
    ch_crn2_stop      =$0040;         //急停
    ch_crn2_err       =$0080;         //异常
    ch_crn2_can       =$0100;         //下命令可
    ch_crn2_receive   =$0200;         //电脑命令正确接收
    ch_crn2_storing   =$0400;         //入库中
    ch_crn2_retriving =$0800;         //出库中
    ch_crn2_loctoloc  =$1000;         //库对库中
    ch_crn2_stntostn  =$2000;         //站对站中
    ch_crn2_moving    =$4000;         //移行中
    ch_crn2_picking   =$8000;         //吊车取货阶段

    {CRN1 STATUS2}
    ch_crn2_put         =$0001;       //吊车放货阶段
    ch_crn2_idle        =$0002;       //吊车空闲
    ch_crn2_movhp       =$0004;       //走行原点定位
    ch_crn2_lifthp      =$0008;       //升降原点定位
    ch_crn2_movpos      =$0010;       //走行在定位
    ch_crn2_mid         =$0020;       //叉牙在中间
    ch_crn2_left        =$0040;       //叉牙在左边
    ch_crn2_right       =$0080;       //叉牙在右边
    ch_crn2_liftupppos  =$0100;       //升降上定位
    ch_crn2_liftdownppos=$0200;       //升降下定位
    ch_crn2_bettrery    =$0400;       //PLC电力不足
    ch_crn2_load        =$0800;       //车上有物
    ch_crn2_proper      =$1000;       //电脑待命状态


   {PLC DEVICE/STATION STATUS CODE}

   ch_AUTO         = $0001;  { AUTO STATUS       }
   ch_LOAD         = $0002;  { load IN STATUS }
   ch_canIN           = $0004;  { can in  STATUS    }
   ch_canOUT          = $0008;  { can out  STATUS    }

   ch_requ1        = $0010;  { front }
   ch_requ2        = $0020;  { rear}
  // ch_excep        = $0040;  { excep}
  //以下定义的是检测成品(晋亿成品)的尺寸(高,中,低)
   ch_hinch       = $0100;
   ch_minch       =$0080;
   ch_linch       =$0040;


   ///PLC ERROR CODE///2005/11/18
   ch_d1         = $0001;  { }
   ch_d2         = $0002;  { }
   ch_d3         = $0004;  {}
   ch_d4         = $0008;  {}
   ch_d5         = $0010;  {}
   ch_d6         = $0020;  {}
   ch_d7         = $0040;  {}
   ch_d8         = $0080;  {}
   ch_d9         = $0100;  {}
   ch_d10        = $0200;  {}
   ch_d11        = $0400;  {}
   ch_d12        = $0800;  {}
   ch_d13        = $1000;  {}
   ch_d14        = $2000;  {}
   ch_d15        = $4000;  {}
   ch_d16        = $8000;  {}


  {CRANE I/O TYPE}
  ci_CRN_LINK         = 1;
  ci_CRN_RESET        = 2;
  ci_CRN_CLEAR        = 3;
  ci_CRN_HOME         = 4;
  ci_CRN_START        = 5;
//ci_CRN_SHELF        = 6;
  ci_CRN_INQUIRY      = 6;
  ci_CRN_STORE        = 7;
  ci_CRN_RETRIEVE     = 8;
  ci_CRN_MOVE         = 9;
  ci_CRN_ErrorInquire = 10;
  ci_CRN_STNTOSTN     = 11;
  ci_CRN_LOCTOLOC     = 12;

  {Crane Status}
  ci_CRN_STS_INIT          =-1;
  ci_CRN_SETTING           = 0;
  ci_CRN_STS_IDLE          = 1;
  ci_CRN_STS_STORE_MOVE    = 2; { STORE COMMAND }
  ci_CRN_STS_RETRIEVE_MOVE = 3; { RETRIEVE COMMAND }
  ci_CRN_STS_MOVING        = 4; { MOVE COMMAND }
  ci_CRN_STS_STORE_OK      = 5;
  ci_CRN_STS_RETRIEVE_OK   = 6;
  ci_CRN_STS_MOVING_OK     = 7;
  ci_CRN_STS_ERROR         = 8;
  ci_CRN_STS_ERROR_IDLE    = 9;
  ci_CRN_STS_STOP          = 11;
  ci_CRN_STS_STNCHG_MOVE   = 12;
  ci_CRN_STS_STNCHG_OK     = 13;
  ci_CRN_STS_LOCATION_MOVE = 14;

  //ci_plc_MAX = 1;
  ci_plc_Max=5;
  ci_plc_MAX_QUEUE = 6;


{WORK STATUS}
  ci_WRK_STORE_SETDATA     = 1;
  ci_WRK_STORE_SETPLC      = 2;
  ci_WRK_STORE_SETCRN      = 3;
  ci_WRK_STORE_OK          = 4;
  ci_WRK_STORE_UPDDB       = 5;
  ci_WRK_STORE_exit        = 6;

  ci_WRK_RETRIEVE_SETDATA  = 11;
  ci_WRK_RETRIEVE_SETCRN   = 12;
  ci_WRK_RETRIEVE_OK       = 14;
  ci_WRK_RETRIEVE_UPDDB    = 15;


  {PLC WRITE  TYPE}
  ci_PLC_SETID      =1;
  ci_PLC_SETDEST    =2;
  ci_PLC_SETIDDEST  =3;
  ci_PLC_SETerr   =4;
  ci_PLC_SETFORWARD =5;
  ci_PLC_SETTANK    =6;
  ci_PLC_SETPACK    =7;
  ci_PLC_SETCRNERR  =8;
  ci_PLC_clerrequ  =9;

  ci_PLC_SETg_ars_sta_bid_Addr  =9;
  ci_PLC_SETg_ars_sta_bctn_Addr  =10;
  ci_PLC_SET_exit_lamp  =11;
  ci_dest_stano=11;

 //********************************
 {ASCII Code}
  ci_STX=2;
  ci_ETX=3;
  ci_EOT=4;
  ci_ENQ=5;
  ci_ACK=6;
  ci_LF=10;
  ci_CR=13;
  ci_NAK=15;

  {Scale Command Type}
  ci_SCALE_IDLE         = 0;
  ci_SCALE_READ_COMMAND = 1;
  ci_SCALE_ZERO_COMMAND = 2;
  ci_SCALE_TARE_COMMAND = 3;
  ci_SCALE_NTGS_COMMAND = 4;

 {crane Store In Buffer qty}
  ci_Max_HP_In = 2;
  ci_Max_TP_In = 2;
 // ID_INTER   = 2;

  {COMUCATION I/O BUFFER SIZE}
  ci_crn_MAXBUFSIZE  = 4096;
  ci_scale_MAXBUFSIZE=4096;
  ci_MAXINCOUNT  = 35;
  ci_MAXOUTCOUNT = 50;

  {CRANE SLEEP TIME}
  ci_CRNtimeInterval=1500;
  ci_CRNtimeInterval1=300;
  {PLC SLEEP TIME}
  ci_PLCtimeInterval=400;

  ci_scaletimeInterval=500;
  {DATABASE ALIAS NAME}
  cs_DBName = 'ASRSDB';

  { Commucation Initial Port }
  ci_PLC_Port = 5;
  ci_CRN_Port = 8;

  {Database Update flag}
  ch_UPD_INS   = $10;
  ch_UPD_DEL   = $20;
  ch_UPD_PICK  = $30;
  ch_UPD_MERGE = $40;

    {     }
  ch_CMD_START = $100;
  ch_CMD_PAUSE = $200;
  ch_CMD_CLOSE = $300;


var

  scalewt :real;
  gi_sto_seq:integer;
  gi_pick826_count,gi_pick832_count:integer;
  g_ars_weight : Array[1..6] of real;
  gi_asr_work:  Array[1..6] of integer;
  gs_stn_err_status:string;      //20070414 add
  gi_wrk_no:Array[1..2] of integer;
  gb_crn_status:array[1..10] of boolean;
   gs_111:string;
  gs_dev_error_code: Array[1..ci_plc_error_count] of string;
  gs_dev_error_code1: Array[1..ci_plc_error_count1] of string;
  gs_dev_error_code2: Array[1..ci_plc_error_count2] of string;
  gi_dev_error_code: Array[1..6] of integer;
  gs_pre_str,gs_now_str :string;
  gi_wrk_tag:integer;
  gi_wrk_num:array[1..1] of integer;
  gi_inch_tag:array[1..4] of integer; //尺寸标志 站点从小到大依次排列
  gi_zhanban_tag:array[1..6] of integer;
  gi_req_tag:array[1..3] of integer;
  gi_status_tag:array[1..2] of string;
  gs_crn_err_Addr : Array[1..1] of String[5];
  gs_crn_err,gs_crn_err_pre,gs_crn_err1,gs_crn_err_pre1:string;
  f_ctn_wt:real;
  gi_wrk_nu:array[1..2] of integer;
  gs_dev_sts:array[1..17] of string;
  gi_dev_sts:array[1..20] of integer;
  gs_dev_sts1:array[1..19] of string;
  gi_crn_wrkno:array[1..21] of integer;
  gi_dev_err :array[1..20] of integer;
  gs_dev_err_last: array[1..20] of string;
  gi_plc_err,gi_plc_err_back:array[1..10] of integer;
     // ,gs_dev_sts1
  gi_plc_stn_buff1,gi_plc_stn_buff2,gi_plca_end,g_rec_plc_stn_data_his_count:integer;
  g_arr_swt: Array[1..1] of real;
  gs_plc_sta_scale:array[1..2] of string;
  gr_arr_swt :array[1..1] of real;
  g_ari_plc_buff1,g_ari_plc_buff2,g_ari_plc_buff_count1,g_ari_plc_buff_count2 :array[1..11] of integer;
  gr_swt_limit,gr_swt_limit_min:real;     //磅秤的重量限制
  W_sta_mach,W_stamk:array[1..500] of integer ;
  gi_crn_err1,gi_crn_err2,gi_crn_err4:integer;
  gi_cart650_pos,gi_cart643_pos,gi_cart752_pos,gi_cart774_pos,gi_cart908_pos,gi_cart917_pos:integer;
  gi_exit_type,gi_crn8_port,gi_crn9_port,gi_crn10_port,gi_crn11_port,gi_crn12_port,gi_crn13_port,gi_crn14_port,gi_crn15_port,gi_crn16_port,gi_plce_port,gi_plcf_port,gi_plcg_port,gi_bar_port1:Integer;
  g_ari_staion_plc_no,g_ari_staion_Component_seq: Array[1..600] of integer;
  g_ari_staion: Array[1..ci_sta_count] of integer;
  g_ari_sta_status  :array[1..600] of integer;
  gs_crn17_port,gs_crn_ip_now,gs_crn_ip_pre :string;
  g_ari_sta_status1:Array[1..17] of integer;
  gi_crn_comm_time,gi_Online_flag,gi,gi_port_crn1,gi_port_crn2,gi_port_plc1,gi_port_plc2:integer;
  gs_plcthr_mess_send,gs_last_dest_stano:string;
  gs_crn_manu,gs_crn_auto,gs_crn_online,gs_crn_status,gs_crn_status1,gs_crn_rows,gs_crn_lev: String;
  gs_crn_manuing,gs_crn_onlining,gs_crn_autuing,gs_crn_stop,gs_crn_error,gs_crn_can  :String;
  gs_crn_receive,gs_crn_storing,gs_crn_retriving,gs_crn_loctoloc,gs_crn_stntostn :string;
  gs_crn_moving,gs_crn_pick,gs_crn_put,gs_crn_idle,gs_crn_movhp,gs_crn_lifthp,gs_crn_movpos,gs_crn_mid,gs_crn_left,gs_crn_right,gs_crn_liftup,gs_crn_liftdown,gs_crn_bettery,gs_crn_load,gs_crn_proper:string;
  gs_loc_type:array[1..371] of string;
  gs_empty_mk:array[1..371] of string;
  g_rec_CRNData : Array[1..ci_crn_count] of trec_CraneData;
//  g_rec_CRNData : Array[1..9] of trec_CraneData;
  g_rec_plc_stn_data : Array[1..600] of Trec_plc_stn_Data; //20080221
  g_barcode:array[1..2] of string;

  g_crn_move,g_colo_noauto,g_colo_auto,g_colo_autoload,g_colo_autoloadid,g_colo_autoid,g_colo_id,g_colo_no_id : TColor;
  g_ars_PLCA_QUEUE : Array[1..ci_plc_MAX,1..ci_plc_MAX_QUEUE] of String[14];

   g_ars_sta_ID_Addr,g_ars_staion_name     : Array[1..ci_sta_count] of String[5];
   g_ars_dev_err_Addr  : Array[1..20] of String[5];
   g_ars_sta_detsta_Addr : Array[1..ci_sta_count] of String[5];
   g_ars_sta_status_Addr : Array[1..ci_sta_count] of String[5];
   g_ars_clr_id_Addr:array[1..300] of String[5];

   g_ars_sta_pre_data : Array[1..ci_sta_count] of String[50];
   g_ars_sta_bid_Addr    : Array[1..ci_sta_count] of String[5];
   g_ars_sta_bctn_Addr    : Array[1..ci_sta_count] of String[5];


   g_ari_crn_pre_error,g_ari_crn_pre_error1 : Array[1..ci_crn_count] of integer;
   g_ari_crn_pre_wrk_no : Array[1..ci_sta_count] of integer;

   var_ars_CrnerrAddr : Array[1..5] of String[1];  //吊车的错误编码,写入到plc中

   ar_Colo_back1,ar_Colo_font1: Array[1..ci_crn_count] of TColor;
   g_ars_crn_lastio: Array[1..ci_crn_count] of String[1];
   // g_ars_crn_lastio: Array[1..10] of String[1];  //20080802新增

   gs_plc_stn_buff_addr1,gs_plc_stn_buff_addr2:  Array[1..10] of String[5];
   gi_last_dest_stano : integer;
   g_ars_dest_stano : Array[1..ci_dest_stano] of String[5];
   gs_plc_error_desc: Array[1..ci_plc_error_count] of String;
   gd_start_time:Tdatetime;


function  g_funi_get_station_seq(station : integer) : integer;
function  g_funs_Crnsts_name(i_sts : integer) : string;

//----- PLC I/O Buffer Queue  -------------------
procedure g_proc_Init_PLC_Queue;
function  g_funi_PLCA_Queue_Count(k:integer) : integer;
function  g_funs_Get_PLCA_Queue(k:integer) : String;
procedure g_proc_PLCA_Queue_Adjust(k:integer);
procedure g_proc_Add_PLCA_Queue(k:integer;s_Data: String);

//procedure g_proc_SetPLCA(k,i_nKind,i_nID,i_SrcStn,i_DestStn: integer);
function g_funi_htoi(s_data:string;i_len:integer):integer;
procedure g_proc_init_g_ari_staion;
function  g_funs_get_last_dest_stano(station:string):integer;
function  g_funi_io_buffer_Count(s_stn_no:string) : integer;
//procedure g_proc_staion_disable_plca;

function funb_strtoint_ok(s_tempStr:string) : Boolean;
function funb_strtofloat_ok(s_tempStr:string) : Boolean;
function funb_hextodec(data:string):integer;

implementation

function  g_funs_Crnsts_name(i_sts : integer) : string;
   //该过程里面还包含一个函数Crnsts
   begin
      case i_sts of
         ci_CRN_STS_INIT          : Result := '初始化';
         ci_CRN_SETTING           : Result := '设定中';
         ci_CRN_STS_IDLE          : Result := '空闲';
         ci_CRN_STS_STORE_MOVE    : Result := '入库移动';
         ci_CRN_STS_RETRIEVE_MOVE : Result := '出库移动';
         ci_CRN_STS_MOVING        : Result := '移动';
         ci_CRN_STS_STORE_OK      : Result := '入库完成';
         ci_CRN_STS_RETRIEVE_OK   : Result := '出库完成';
         ci_CRN_STS_MOVING_OK     : Result := '移动完成';
         ci_CRN_STS_ERROR         : Result := '错误';
         ci_CRN_STS_STOP          : Result := '停止';
         ci_CRN_STS_STNCHG_MOVE   : Result := '站到站移动';
         ci_CRN_STS_STNCHG_OK     : Result := '站到站完成';
         ci_CRN_STS_LOCATION_MOVE : Result := '库位移栽';
     end;
end;

function  g_funi_get_station_seq(station : integer) : integer;
var i : integer;
begin
    Result := -1;
   for i := 1 to ci_sta_count do
   begin
      if g_ari_staion[i]=station then
        begin
          Result := i;
         break
        end
   end;
end;

function funb_strtoint_ok(s_tempStr:string) : Boolean;
var
    i,i_len : integer;
begin
   result:=false;
   i_len := Length(s_tempStr);
   for i := 1 to i_len do
   begin
      if (s_tempStr[i] >='0') and (s_tempStr[i] <='9')   then   result:=true

        else
         begin
          result:=false;
          exit;
         end;

   end;
end;

function funb_hextodec(data:string):integer;
var ls_str,cptr,hexstr:string;
    nctr,rptr,nsum,li_len :integer;
    k:integer;
begin
    hexstr:=data;
    ls_str:=trim(hexstr);
    li_len:=Length(ls_str) ;
    nsum:=0;
    for nctr := 1 to li_len do
    begin
       cptr:=copy(ls_str,li_len - nctr   1 ,1);
       if cptr='A'  then cptr:='10'
       else if cptr='B' then cptr:='11'
       else if cptr='C' then cptr:='12'
       else if cptr='D' then cptr:='13'
       else if cptr='E' then cptr:='14'
       else if cptr='F' then cptr:='15' ;
       if nctr=1 then  k:=1
        else  if nctr=2 then  k:=16
        else  if nctr=3 then  k:=256
        else  if nctr=4 then  k:=16 * 256;
        nsum:=nsum  strtoint(cptr) * k;
    end;
    result := nsum;
end;


function funb_strtofloat_ok(s_tempStr:string) : Boolean;
var
    i,i_len : integer;
begin
   result:=false;
   i_len := Length(s_tempStr);
   for i := 1 to i_len do
   begin
      if ((s_tempStr[i] >='0') and (s_tempStr[i] <='9')) or (s_tempStr[i]='.')  then   result:=true

        else
         begin
          result:=false;
          exit;
         end;

   end;
end;

function  g_funs_get_last_dest_stano(station : string) : integer;
var i : integer;
begin
    Result := -1;
   for i := 1 to ci_dest_stano do
   begin
      if g_ars_dest_stano[i]=station then
        begin
          Result := i;
         break
        end
   end;
end;


procedure g_proc_Init_PLC_Queue;
var i ,k: integer;
begin
   for k := 1 to ci_plc_MAX do
   for i := 1 to ci_plc_MAX_QUEUE do g_ars_PLCA_QUEUE[k,i] := '';
end;

procedure g_proc_Add_PLCA_Queue(k:integer;s_Data: String);
var i : integer;
begin
   if s_Data='' then Exit;
   for i := ci_plc_MAX_QUEUE downto 1 do
   begin
      if g_ars_PLCA_QUEUE[k,i]='' then
      begin
         g_ars_PLCA_QUEUE[k,i] := s_Data;
         Break;
      end;
   end;
   g_proc_PLCA_Queue_Adjust(k);
end;


function  g_funs_Get_PLCA_Queue(k:integer) : String;
var i : integer;
    s_temp : String;
begin
   s_temp := '';
   for i := 1 to ci_plc_MAX_QUEUE do
   begin
      if g_ars_PLCA_QUEUE[k,i]<>'' then
      begin
         s_temp := g_ars_PLCA_QUEUE[k,i];
         g_ars_PLCA_QUEUE[k,i] := '';
         Break;
      end;
   end;
   g_proc_PLCA_Queue_Adjust(k);
   Result := s_temp;
end;


function  g_funi_PLCA_Queue_Count(k:integer) : integer;
var i,Count : integer;
begin

   Count := 0;
   for i := 1 to ci_plc_MAX_QUEUE do
   begin
      if g_ars_PLCA_QUEUE[k,i]<>'' then Inc(Count);
   end;
   Result := Count;
end;

procedure g_proc_PLCA_Queue_Adjust(k:integer);
var i,j : integer;
    s_temp1,s_temp2 : string;
begin
  for j:=1 to  ci_plc_MAX_QUEUE do
  begin
     s_temp1 := ''; s_temp2 := '';
     for i := ci_plc_MAX_QUEUE downto 1 do
     begin
        s_temp1 := g_ars_PLCA_QUEUE[k,i];
        if i > 1 then
        begin
           s_temp2 := g_ars_PLCA_QUEUE[k,i-1];
           if (s_temp1<>'') and (s_temp2='') then
           begin
              g_ars_PLCA_QUEUE[k,i-1] := s_temp1;
              g_ars_PLCA_QUEUE[k,i]   := '';
           end;
        end;
     end;
  end;
end;



function g_funi_htoi(s_data:string;i_len:integer):integer;
var i_sum,i_tmp,x:integer;
begin
     result:=0;
     if s_data='' then
     begin
      exit;
     end;
     i_sum   :=0;
     for x := 1 to i_len do
     begin
      i_tmp  := ord(Upcase(s_data[x]));
      if i_tmp >58 then i_tmp := i_tmp-7;

      i_sum := i_sum*16 i_tmp-48;
     end;
     result := i_sum;
end;


procedure g_proc_init_g_ari_staion;
var i,j:integer;
begin
  for i := 1 to ci_sta_count do
     begin
         if i in [1..54] then
         begin
             { g_ari_staion[i]  := i 500;
              g_ars_staion_name[i]:=inttostr(i 500);
              if i in[1..9] then g_ars_sta_id_Addr[i] :='D000' inttostr(i);
              if i in[10..54] then g_ars_sta_id_Addr[i] :='D00' inttostr(i);
              g_ars_sta_status_Addr[i] :='D0' inttostr(600 i);
              g_ars_sta_detsta_Addr[i] :='D0' inttostr(300 i);
              g_ari_crn_pre_wrk_no[i]:=0;
              g_rec_plc_stn_data[i].s_dev_no:=inttostr(g_ari_staion[i]);
              g_rec_plc_stn_data[i].s_autoing  :='N';
              g_rec_plc_stn_data[i].s_loading  :='N';
              g_rec_plc_stn_data[i].s_canining  :='N';
              g_rec_plc_stn_data[i].s_canouting  :='N';
              g_rec_plc_stn_data[i].s_inreq1   :='N';
              g_rec_plc_stn_data[i].s_inreq2   :='N';
              g_rec_plc_stn_data[i].s_error:='N';
              g_rec_plc_stn_data[i].i_buff_count:=0;
              g_ari_staion_plc_no[i]:=1;
              g_rec_plc_stn_data[i].i_pak_mk:=0;
              if (i=345) then  //尺寸
              begin
                  g_rec_plc_stn_data[i].s_hight:='N';
                  g_rec_plc_stn_data[i].s_middle:='N';
                  g_rec_plc_stn_data[i].s_low:='N';
              end;  }
         end;


         if i in [55..229] then
         begin
                g_ari_staion[i]  := i 545;
                g_ars_staion_name[i]:=inttostr(i 545);
                if i in [55..64] then
                  begin
                   g_ars_sta_id_Addr[i] :='D000' inttostr(i-55);
                   g_ars_sta_status_Addr[i] :='D0' inttostr(545 i);
                   g_ars_sta_detsta_Addr[i] :='D0' inttostr(245 i);
                  end;
                if i in [65..154] then
                  begin
                   g_ars_sta_id_Addr[i] :='D00' inttostr(i-55);
                   g_ars_sta_status_Addr[i] :='D0' inttostr(545 i);
                   g_ars_sta_detsta_Addr[i] :='D0' inttostr(245 i);
                    end;
                if i in [155..229] then
                  begin
                   g_ars_sta_id_Addr[i] :='D0' inttostr(i-55);
                   g_ars_sta_status_Addr[i] :='D0' inttostr(545 i);
                   g_ars_sta_detsta_Addr[i] :='D0' inttostr(245 i);
                   end;
                g_ari_crn_pre_wrk_no[i]:=0;
                g_rec_plc_stn_data[i].s_dev_no:=inttostr(g_ari_staion[i]);
                g_rec_plc_stn_data[i].s_autoing  :='N';
                g_rec_plc_stn_data[i].s_loading  :='N';
                g_rec_plc_stn_data[i].s_canining  :='N';
                g_rec_plc_stn_data[i].s_canouting  :='N';
                g_rec_plc_stn_data[i].s_inreq1   :='N';
                g_rec_plc_stn_data[i].s_inreq2   :='N';
                g_rec_plc_stn_data[i].s_error:='N';
                g_rec_plc_stn_data[i].i_buff_count:=0;
                g_ari_staion_plc_no[i]:=2;
                g_rec_plc_stn_data[i].i_pak_mk:=0;
                g_rec_plc_stn_data[i].s_hight:='N';
                g_rec_plc_stn_data[i].s_middle:='N';
                g_rec_plc_stn_data[i].s_low:='N';
          end;

         if ((i>=230)and(i<=342)) then
         begin
                g_ari_staion[i]  := i 545;
                g_ars_staion_name[i]:=inttostr(i 545);
                g_ars_sta_id_Addr[i] :='D0' inttostr(i-55);
                g_ars_sta_status_Addr[i] :='D0' inttostr(545 i);
                g_ars_sta_detsta_Addr[i] :='D0' inttostr(245 i);
                g_ari_crn_pre_wrk_no[i]:=0;
                g_rec_plc_stn_data[i].s_dev_no:=inttostr(g_ari_staion[i]);
                g_rec_plc_stn_data[i].s_autoing  :='N';
                g_rec_plc_stn_data[i].s_loading  :='N';
                g_rec_plc_stn_data[i].s_canining  :='N';
                g_rec_plc_stn_data[i].s_canouting  :='N';
                g_rec_plc_stn_data[i].s_inreq1   :='N';
                g_rec_plc_stn_data[i].s_inreq2   :='N';
                g_rec_plc_stn_data[i].s_error:='N';
                g_rec_plc_stn_data[i].i_buff_count:=0;
                g_ari_staion_plc_no[i]:=3;
                g_rec_plc_stn_data[i].i_pak_mk:=0;
                g_rec_plc_stn_data[i].s_hight:='N';
                g_rec_plc_stn_data[i].s_middle:='N';
                g_rec_plc_stn_data[i].s_low:='N';
                {if (i=274)or(i=282) or(i=287) or(i=310) then  //得到902站点的尺寸
                begin
                    g_rec_plc_stn_data[i].s_hight:='N';
                    g_rec_plc_stn_data[i].s_middle:='N';
                    g_rec_plc_stn_data[i].s_low:='N';
                 end; }

          end;

         if ((i>=343)and(i<=363)) then
         begin
                g_ari_staion[i]  := i 557;
                g_ars_staion_name[i]:=inttostr(i 557);
                if ((i>=343)and(i<=352)) then g_ars_sta_id_Addr[i] :='D000' inttostr(i-343);
                if ((i>=353)and(i<=363)) then g_ars_sta_id_Addr[i] :='D00' inttostr(i-343);
                g_ars_sta_status_Addr[i] :='D0' inttostr(i 257);
                g_ars_sta_detsta_Addr[i] :='D0' inttostr(i-43);
                g_ari_crn_pre_wrk_no[i]:=0;
                g_rec_plc_stn_data[i].s_dev_no:=inttostr(g_ari_staion[i]);
                g_rec_plc_stn_data[i].s_autoing  :='N';
                g_rec_plc_stn_data[i].s_loading  :='N';
                g_rec_plc_stn_data[i].s_canining  :='N';
                g_rec_plc_stn_data[i].s_canouting  :='N';
                g_rec_plc_stn_data[i].s_inreq1   :='N';
                g_rec_plc_stn_data[i].s_inreq2   :='N';
                g_rec_plc_stn_data[i].s_error:='N';
                g_rec_plc_stn_data[i].i_buff_count:=0;
                g_ari_staion_plc_no[i]:=4;
                g_rec_plc_stn_data[i].i_pak_mk:=0;
                g_rec_plc_stn_data[i].s_hight:='N';
                g_rec_plc_stn_data[i].s_middle:='N';
                g_rec_plc_stn_data[i].s_low:='N';

               {if (i=345) then  //得到902站点的尺寸
                begin
                    g_rec_plc_stn_data[i].s_hight:='N';
                    g_rec_plc_stn_data[i].s_middle:='N';
                    g_rec_plc_stn_data[i].s_low:='N';
                 end;   }
         end;

         if ((i>=364)and(i<=371)) then
         begin
              g_ari_staion[i]  := i 524;
              g_ars_staion_name[i]:=inttostr(i 524);
              g_ars_sta_id_Addr[i] :='D0' inttostr(i-176);
              g_ars_sta_status_Addr[i] :='D0' inttostr(i 424);
              g_ars_sta_detsta_Addr[i] :='D0' inttostr(i 124);
              g_ari_crn_pre_wrk_no[i]:=0;
              g_rec_plc_stn_data[i].s_dev_no:=inttostr(g_ari_staion[i]);
              g_rec_plc_stn_data[i].s_autoing  :='N';
              g_rec_plc_stn_data[i].s_loading  :='N';
              g_rec_plc_stn_data[i].s_canining  :='N';
              g_rec_plc_stn_data[i].s_canouting  :='N';
              g_rec_plc_stn_data[i].s_inreq1   :='N';
              g_rec_plc_stn_data[i].s_inreq2   :='N';
              g_rec_plc_stn_data[i].s_error:='N';
              g_rec_plc_stn_data[i].i_buff_count:=0;
              g_ari_staion_plc_no[i]:=2;
              g_rec_plc_stn_data[i].i_pak_mk:=0;
         end;

     end;
     for i:=1 to 20 do
       g_ars_dev_err_Addr[i] :='D00' inttostr(i 50);


    //gi_plca_end:=22;

     //根据测试的a系列的plc,好像48个应该没有问题,50不知是否可以,如果可以就要分成两段来写了
     //plca出库缓存,plca,480-483
     {gi_plc_stn_buff1:=11;
     g_ari_plc_buff_count1[1]:=2;
     g_ari_plc_buff_count1[2]:=2;
     g_ari_plc_buff_count1[3]:=2;
     g_ari_plc_buff_count1[4]:=3;
     g_ari_plc_buff_count1[5]:=3;
     g_ari_plc_buff_count1[6]:=3;
     g_ari_plc_buff_count1[7]:=3;
     g_ari_plc_buff_count1[8]:=3;
     g_ari_plc_buff_count1[9]:=3;
     g_ari_plc_buff_count1[10]:=3;
     g_ari_plc_buff_count1[11]:=3;

     for i := 1 to gi_plc_stn_buff1 do
     begin
      gs_plc_stn_buff_addr1[i] :='D0' inttostr(554 i);
      g_ari_plc_buff1[i]:=0;
     end;

    gs_last_dest_stano:='142';
    g_ars_dest_stano[1]:='132';
    g_ars_dest_stano[2]:='122';
    g_ars_dest_stano[3]:='411';
    g_ars_dest_stano[4]:='418';
    g_ars_dest_stano[5]:='415';
    g_ars_dest_stano[6]:='412';
    g_ars_dest_stano[7]:='409';
    g_ars_dest_stano[8]:='406';
    g_ars_dest_stano[9]:='403';
    g_ars_dest_stano[10]:='400';
    g_ars_dest_stano[11]:='142';}
  //入库重量的范围
    for i:=1 to ci_crn_count do
    begin
    g_ars_crn_lastio[i]:='Y';
    end;
     {gr_swt_limit:=1200;
     gr_swt_limit_min:=1;

     //g_arr_swt[1]:=500;

     for i:= 1 to ci_plc_error_count do
     begin
       gs_plc_error_desc[i]:=inttostr(i);
     end;  }
end;

{procedure g_proc_staion_disable_plca;
var i,j:integer;
begin
     for i := 1 to 80 do
     begin
            //i:=j 400;
            g_ari_staion[i]  := i;
            g_rec_plc_stn_data[i 199].s_dev_no:=inttostr(g_ari_staion[i]);
            g_rec_plc_stn_data[i 199].s_autoing  :='N';
            g_rec_plc_stn_data[i 199].s_loading  :='N';
            g_rec_plc_stn_data[i 199].s_canining  :='N';
            g_rec_plc_stn_data[i 199].s_canouting  :='N';
            g_rec_plc_stn_data[i 199].s_inreq1   :='N';
            g_rec_plc_stn_data[i 199].s_inreq2   :='N';
            g_rec_plc_stn_data[i 199].s_error:='N';
            g_rec_plc_stn_data[i 199].i_pak_mk:=0;
            g_rec_plc_stn_data[i 199].i_Wrk_no:=0;
            g_rec_plc_stn_data[i 199].i_Wrk_no1:=0;
     end;
end; }


function  g_funi_io_buffer_Count(s_stn_no:string) : integer;
var Count : integer;
begin
       Count := 10;
        case strtoint(s_stn_no) of
           //hp in
            533: begin   Count := g_ari_plc_buff_count1[1]-g_rec_plc_stn_data[g_funi_get_station_seq(12)].i_buff_count; end;
            //16: begin   Count := g_ari_plc_buff_count1[2]-g_rec_plc_stn_data[g_funi_get_station_seq(16)].i_buff_count;end;
           //hp out
            //6:  begin   Count := g_ari_plc_buff_count1[3]-g_rec_plc_stn_data[g_funi_get_station_seq(6)].i_buff_count;end;
         end;
   Result := Count;
end;

initialization

 g_colo_autoloadid:=clred        ;
 g_colo_autoload  :=clFuchsia       ;
 g_colo_autoid    :=clYellow     ;
 g_colo_auto      :=clLime     ;
 g_colo_noauto    :=clBtnFace     ;
 g_crn_move       :=clred        ;

 g_colo_id         :=clBlack	    ;
 g_colo_no_id      :=clred		    ;


 g_proc_init_g_ari_staion;




end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复