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

📄 u_main.pas

📁 钢筋拉伸系统,是一个图形和数据库结合在一起的技术体现
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TFrm_Main.button1Click(Sender: TObject);
begin
   frm_sys_ini:=Tfrm_sys_ini.Create(self);
   frm_sys_ini.ShowModal;
end;

procedure TFrm_Main.Button2Click(Sender: TObject);
begin
  frm_help:=Tfrm_help.Create(self);
  frm_help.ShowModal;
end;

procedure TFrm_Main.Button3Click(Sender: TObject);
begin
   frm_set_system:=Tfrm_set_system.Create(self);
   frm_set_system.ShowModal;
end;

procedure TFrm_Main.Button4Click(Sender: TObject);
begin
  frm_Syset:=Tfrm_syset.Create(self);
  frm_syset.ShowModal;
end;

procedure Tfrm_Main.Com_data();
    var P_Fh,P_Wy:Real;
        P_FhH,P_WyH:string;
        PP_fh,PP_Wy:string;
         j,n:integer;
         Ik:integer;
   begin
   //
   inc(com_count);
   if com_count>250 then
      begin
        p_fh:= 0.8*com_count*random(2) ;
        p_wy := com_count*0.2 ;
      end
    else
        begin
        p_fh:= 1.3*Com_count ;
        p_wy:= com_count*0.2 ;
        end;

      edit6.Text:='A'+floattostr(p_fh)+'B'+floattostr(p_wy);
      comm.OutputString(edit6.Text);
       p_fhh:=comm.Input;

      if trim(p_fhh)='' then
        exit;
          j:=Length(p_fhh);
          for ik:=1 to j do
            begin
             if Midstr(p_fhh,ik,1)='B' then
                begin
                 //  pp_fh:= midstr(p_fhh,2,ik-2);
                 //  pp_wy:=midstr(p_fhh,ik+1,j);
                 p_fh:=strtofloat(midstr(p_fhh,2,ik-2));
                 p_Wy:=strtofloat(midstr(p_fhh,ik+1,j));
                  break;
                end;
            end;

    m_fh:=p_fh;
    m_wy:=p_wy;
   end;

procedure TFrm_Main.Timer1Timer(Sender: TObject);
begin
  com_data;
  inc(data_count);
  now_data_count:=data_count;
  line_draw;
   // tim_i:=(lbl_sj.Caption);

  inc(tim_count);
  if tim_count>4 then
   begin
     inc(tim_sj);
    lbl_sj.Caption:= inttostr(tim_sj);
    tim_count:=0;
   end;
    lbl_fh.Caption:=floattostr(m_fh);
    lbl_wy.Caption:=floattostr(m_wy);
     data_x[data_count]:=m_wy;
     data_y[data_count]:=m_fh;
     g_data[data_count].FH:=m_fh;
     g_data[data_count].Wy:=m_wy;
     g_data[data_count].Sj:=tim_sj;
     g_yl_data.FH:=m_fh;
     g_yl_data.Wy:=m_wy;


end;
procedure Tfrm_main.Line_Draw();
  var i:integer;
  begin
  //

    line(self.UpDown1.Position,self.UpDown2.Position);
    pic.Canvas.Pen.Color:=edit5.Color;
    pic.Canvas.Pen.Style:=pssolid;
    pic.Canvas.MoveTo(0,pic.Height);
     for i:=1 to data_count do
       begin
        pic.Canvas.LineTo(round(pic.width/x_axis_bl *data_x[i]),round(pic.Height-pic.Height/y_axis_bl*data_y[i]));
        pic.Canvas.MoveTo(round(pic.width/X_axis_bl*data_x[i]),round(pic.Height-pic.Height/Y_Axis_bl*data_y[i]));
        edit7.Text:=floattostr(m_wy);
        edit6.Text:=floattostr(pic.Height-m_fh/pic.Height);
         if ini_data.WyMax <=data_x[i]  then
           begin
               x_axis_bl:=x_axis_bl*1.2;
               ini_data.wyMax:=trunc(ini_data.wyMax*1.2);
           end;
         if ini_data.fhMax <=data_y[i] then
            begin
              y_axis_bl:=y_axis_bl*1.2;
              ini_data.FhMax:=trunc(ini_data.FhMax*1.2);
            end;
       end;
  end;
procedure TFrm_Main.Button6Click(Sender: TObject);
var aa:string;
begin
  if button6.Caption='启动试验'then
     begin
       if g_sy_content.Symj<=0 then
          begin
            application.MessageBox('请对试验试样进行设定','明日科技');
           frm_Syset:=Tfrm_syset.Create(self);
           frm_syset.ShowModal;
             exit;
          end;
       com_count:=0;
       comm.CommPort:=pncom1;
       comm.PortOpen:=true;
       data_count:=0;
       tim_sj:=0;
       tim_count:=0;
       ini_data.WyMax:=60;
       ini_data.FhMax:=60;
       x_axis_bl:=ini_data.WyMax;
       Y_axis_bl:=ini_data.FhMax;
        line(self.UpDown1.Position,self.UpDown2.Position);
        Line_Draw;
       timer1.Interval:=200;
       button6.Caption:='停止试验';
     end
  else
     begin
     aa:=formatdatetime('yyyymmddhhmmss',now);
       comm.PortOpen:=false;
       timer1.Interval:=0;
        g_data[data_count].FH:=g_sy_content.Symj;
        inc(now_data_count);
        line_save(aa,Extractfilepath(application.ExeName));
       button6.Caption:='启动试验';
       Last_Fm;
     end;
end;
procedure  Tfrm_main.Last_Fm();//最后屈服换算
  var i:integer;
      P_Font_data,P_back_data:real;
      Fm,Fsu,Fsl:real;
      FmId,FsuId,FslId:int64;
  begin
      P_Font_Data := G_Data[1].FH;
    for i:=1 To Data_Count  do
      begin
       P_Back_Data := G_Data[i + 1].FH;
       If P_Font_Data < P_Back_Data Then
          begin
          P_Font_Data := P_Back_Data;
          Fm := P_Font_Data;
          FmId := i;
         end;
       end;
    Fsu := G_Data[FmId].FH;
    Fsl := G_Data[FmId].FH;
   For i := 1 To FmId do//上屈服
      begin
       P_Font_Data := G_Data[i].FH;
       P_Back_Data := G_Data[i + 1].FH;
       If P_Font_Data > P_Back_Data Then
         begin
          Fsu := P_Font_Data;
          FsuId := i;
          break;
         end;

      end;
   For i := FsuId To FmId do //'下屈服
      begin
       P_Font_Data := G_Data[i].FH;
       P_Back_Data := G_Data[i + 1].FH;
       If P_Font_Data < P_Back_Data Then
         begin
         Fsl := P_Font_Data;
         break;
         end;
      end;
           self.Lvw_Lb.Items.Clear;

  with lvw_lb.Items.Add  do
  begin
      caption:='Fm';
       subitems.Add(floattostr(fm));
  end;
 with lvw_lb.Items.Add  do
  begin
    caption:='Rm';
    subitems.Add(floattostr(round(fm*1000/g_sy_content.symj)));
  end;
  with lvw_lb.Items.Add   do
  begin
      caption:='Fsu';
      subitems.Add(floattostr(fsu));
  end;
 with lvw_lb.Items.Add   do
  begin
       caption:='Rsh';
       subitems.Add(floattostr(round(fsu*1000/g_sy_content.symj)));
  end;
  with lvw_lb.Items.Add  do
  begin
      caption:='Fsl';
      subitems.Add(floattostr(fsl));
  end;
  with lvw_lb.Items.Add do
  begin
      caption:='Rsl';
      subitems.Add(floattostr(round(fsl*1000/g_sy_content.symj)));
  end;
  end;
procedure TFrm_Main.Button5Click(Sender: TObject);
  var
  i:integer;
begin
   fileopen.Filter:='*.asp|*.asp';
   fileopen.FilterIndex:=1;
   fileopen.InitialDir:=application.GetNamePath+ 'data\';
   fileopen.Execute;
   if fileopen.FileName<>'' then
      begin

        Line_read(fileopen.FileName);
          data_count:=now_data_count-2;
        for i:=1 to now_data_count-1 do
          begin
               data_x[i]:=g_data[i].wy;
               data_y[i]:=g_data[i].FH;
               lbl_sj.Caption:=floattostr(g_data[i].sj);
          end;
        lbl_fh.Caption:=floattostr(data_y[data_count-1]);
        lbl_wy.Caption:=floattostr(data_x[data_count-1]);
        g_sy_content.symj:=data_y[data_count-1];
          ini_data.WyMax:=60;
          ini_data.FhMax:=60;
        x_axis_bl:=ini_data.WyMax;
       Y_axis_bl:=ini_data.FhMax;
       line(self.UpDown1.Position,self.UpDown2.Position);
        line_draw;
        line(self.UpDown1.Position,self.UpDown2.Position);
        Line_Draw;
        Last_Fm;
      end;
end;

procedure TFrm_Main.Edit5Click(Sender: TObject);
begin
    self.ColorDialog.Execute;
    edit5.Color:=colordialog.Color;
   line(self.UpDown1.Position,self.UpDown2.Position);
   Line_Draw;
end;

procedure TFrm_Main.PicMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
   var TY,TX:string;
begin
//data_y[i]=pic.Height/pic.Height -y /y_axis_bl
//
  {  ty:='负荷='+floattostr(round((pic.Height/(pic.Height-y))*y_axis_bl));
    tx:='  位移='+inttostr(x);
    pic.Hint:=ty+tx;
    pic.ShowHint:=true;
    //*data_y[i]=(pic.Height/(pic.Height-y))y_axis_bl
        }
end;

end.

⌨️ 快捷键说明

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