Разработка комплекса программ для автоматизации экспериментальных исследований тангенциального точения на станке с ЧПУ 6Р13Ф3, страница 13

          XStream^.Read(D,NumRead); secs:=D.STime;

         compress:=false; {растягивание-сжатие графика}

         km:=1; {коэфф. масштабирования по амплитуде}

         kmx:=1; {коэфф. масштабирования по времени}

         {kmx = 1/5 - пять секунд на экран, если данные сжимаются (время в файле > 1 сек)}

         {kmx = 5 - одна пятая секунды, если данные растягиваются ( файл < 1 сек)}

         Chn:=1;

         beg:

          XStream^.Seek(0);

          ft:=true; aft:=false; {для начала отсчета времени}

          isRedraw:=false;

          refresh:=true; {начало экрана}

          if (compress) and (((secs+50000)/1000000)>1) then

            begin ratex:=0.638*(maxx/640)/((secs)/1000000) end

          else ratex:=0.64*kmx*(maxx/640);

          repeat

            XStream^.Read(D, NumRead);

            if D.Detector then col:=MaxC-1 else col:=MaxC; SetColor(col);

            y:=GetRealY(D.D[Chn]);

            if refresh then

              begin

                ClearViewPort; x:=0; xx:=0; yy:=round(y);

                refresh:=false; St3:=St2;

              end;

            if not FT then

              begin

                St2:=D.STime; x:=x+(St2-St1)/1000*ratex; St1:=St2;

                if x<=maxx then

                  begin

                    Line(xx,yy,round(X),round(Y));

                    if aft=true then aft:=false;

                    xx:=round(x); yy:=round(y);

                  end

                else refresh:=true;

              end

            else

              begin

                FT:=false; yy:=trunc(y); xx:=trunc(x); aft:=true;

                St2:=D.Stime; St1:=St2; St3:=St2;

                ms101:=trunc((St2-trunc(st2/1000000)*1000000)/100000); ms102:=ms101;

              end;

              {получение десятой доли секунды:}

              ms102:=trunc((St2-trunc(st2/1000000)*1000000)/100000);

              if ms101<>ms102 then

              begin

                if (ratex>=0.21) and (ms102<>0) then

                  begin {1/10 секунды}

                    SetColor(MaxC-2); setlinestyle(1,0,NormWidth);

                    line(xx,0,xx,maxx); setlinestyle(SolidLn,0, NormWidth);

                  end;

                if ms102=0 then {каждую секунду}

                begin

                  SetColor(MaxC-2); setlinestyle(3,0,ThickWidth);

                  line(xx,0,xx,maxx); setlinestyle(SolidLn,0, NormWidth);

                end;

              end;

              ms101:=ms102;

              isend:=XStream^.Position>=XStream^.Size;

              if refresh or isend then

                 begin

                   SetColor(MaxC-2);

                   rr:=trunc(GetRealY(2048)); line(0,rr,maxx,rr);

                   SetLineStyle(1,0,NormWidth);

                   rr:=trunc(GetRealY(3596)); line(0,rr,maxx,rr);

                   rr:=trunc(GetRealY(3084)); line(0,rr,maxx,rr);

                   rr:=trunc(GetRealY(2572)); line(0,rr,maxx,rr);

                   rr:=trunc(GetRealY(1548)); line(0,rr,maxx,rr);

                   rr:=trunc(GetRealY(1024)); line(0,rr,maxx,rr);

                   rr:=trunc(GetRealY(512));  line(0,rr,maxx,rr);

                   SetLineStyle(0,0,NormWidth);

                   if isEnd then

                     begin

                       x:=x+ratex*500;

                       if x<=maxx then

                        begin SetColor(MaxC-2); line(xx,0,xx,maxx); end;

                     end;

                   OutInfo;

                   repg:

                     cmd:=GetCmd;

                   if isEnd and (cmd=_cmNext) then goto repg;

                   case cmd of

                     _cmSetChn1.._cmSetChn8 :

                          begin

                            if (cmd-_cmSetChn1+1)<=count then

                              begin

                                chn:=cmd-_cmSetChn1+1;

                                isRedraw:=true;

                              end

                            else goto repg;

                          end;

                     _cmIncChn : if (chn+1)<=count then

                                   begin chn:=chn+1; isRedraw:=true; end

                                 else goto repg;

                     _cmDecChn : if (chn-1)>=1 then

                                   begin chn:=chn-1; isRedraw:=true; end

                                 else goto repg;

                     _cmCompress : begin compress:=not compress; isRedraw:=true; end;

                     _cmRedraw : isRedraw:=true;

                     _cmNormalize : begin km:=1; kmx:=1; isRedraw:=true; end;

                     _cmIncY : begin

                                 if km<1 then begin km:=km*2; isRedraw:=true; end

                                  else

                                    if km<128 then begin km:=km*2; isRedraw:=true; end;

                               end;

                     _cmDecY : begin

                                if km>1 then begin km:=km/2; isRedraw:=true; end

                                  else

                                    if km<=1 then begin km:=km/2; isRedraw:=true; end;

                               end;

                     _cmIncX : begin

                                 if kmx<1 then begin kmx:=kmx*1.2; isRedraw:=true; end

                                  else

                                    if kmx<128 then begin kmx:=kmx*1.25; isRedraw:=true; end;

                               end;

                     _cmDecX : begin

                                if kmx>1 then begin kmx:=kmx/1.25; isRedraw:=true; end

                                  else

                                    if kmx<=1 then begin kmx:=kmx/1.2; isRedraw:=true; end;

                               end;

                   end;

                 if isRedraw then goto beg;

                 end;

          until cmd=_cmStop;

          CloseGraph;

      end;