SpeedScale:=GetMaxY/(3*W0);
for CurrentNumber:=0 to 640 do
begin
for CurrentRepeat:=1 to RepeatNumber do
begin
Runge;
I1a:=x[1]/L11-K2/L11*x[3];
I1b:=x[2]/L11-K2/L11*x[4];
I1:=sqrt(sqr(I1a)+sqr(I1b));
I21a:=x[3]/L21-K1/L21*x[1];
I21b:=x[4]/L21-K1/L21*x[2];
I21:=Sqrt(sqr(I21a)+sqr(I21b));
I0a:=I1a+I21a;I0b:=I1b+I21b;
I0:=sqrt(sqr(I0a)+sqr(I0b));
t:=t+dt;
PutPixel(CurrentNumber,round(GetMaxY/2-
SpeedScale*x[5]/p),color);
end;
PutPixel(CurrentNumber,round(GetMaxY/2-
SpeedScale*x[5]/p),color);
SetActivePage(0);
PsiAlpha:=AbsoluteAngle(I0a,I0b)-
AbsoluteAngle(x[3],x[4]);
IsPsirAlpha:=AbsoluteAngle(I1a,I1b)-
AbsoluteAngle(x[3],x[4]);
IsAlpha:=AbsoluteAngle(U1a,U1b)-
AbsoluteAngle(I1a,I1b);
CosF:=cos(IsAlpha*Pi/180);
if (Uss*I1)<>0 then
KPD:=abs(M*Fs*4*Pi/(3*p*Uss*I1));
Str(Uss:5,StringPsiAlpha);Str(IsAlpha,StringIsAlpha);
Str(KPD:5:3,StringKPD);Str(IsPsirAlpha,StringIsPsirAlpha);
Str(s:6:4,StringAlphaRasch);Str(x[5]/p:5:1,StringCurrW);
Str(I1:6:2,StringIs);Str(CosF:4:2,StringCosF);
SetViewPort(184,20,240,30,False);ClearViewPort;SetViewPort(304,20,368,30,Fal
se);ClearViewPort;
SetViewPort(400,20,472,30,False);ClearViewPort;SetViewPort(576,20,638,30,Fal
se);ClearViewPort;
SetViewPort(184,40,248,50,False);ClearViewPort;SetViewPort(296,40,368,50,Fal
se);ClearViewPort;
SetViewPort(400,40,472,50,False);ClearViewPort;SetViewPort(576,40,638,50,Fal
se);ClearViewPort;
SetViewPort(0,0,GetMaxX,GetMaxY,True);
OutTextXY(192,20,StringPsiAlpha);OutTextXY(312,20,StringIsAlpha);
OutTextXY(408,20,StringKPD);OutTextXY(584,20,StringIsPsirAlpha);
OutTextXY(192,40,StringAlphaRasch);OutTextXY(312,40,StringCurrW);
OutTextXY(408,40,StringIs);OutTextXY(584,40,StringCosF);
PressKeyAnalysis;
end;
end;
{ Процедура формирования заголовка файла }
procedure FileHead;
begin
Assign(Result,'lw.res');
Rewrite(Result);
Writeln(Result,GetVectorString(ST11));Writeln(Result,GetVectorString(ST12));
Write(Result,GetVectorString(ST13));Writeln(Result,GetVectorString(ST21));
Write(Result,GetVectorString(ST14));Writeln(Result,GetVectorString(ST22));
Write(Result,GetVectorString(ST15));Writeln(Result,GetVectorString(ST23));
Write(Result,GetVectorString(ST16));Writeln(Result,GetVectorString(ST24));
Write(Result,GetVectorString(ST17));Writeln(Result,GetVectorString(ST25));
end;
{ Основная программа }
begin
ReCalculation;
ClrScr;Writeln;
TextColor(10);WriteLn(' Программа расчета и вывода векторной
диаграммы А.Д.');
TextColor(12);Writeln(' Для IBM PC/XT/AT/PS-2 с ОЗУ экрана
256/512 Кб');
for i:=0 to 4 do Writeln;TextColor(15);
Write('Введите время окончания работы двигателя: ');Readln(EndT);
Write('Введите частоту питающей сети (Гц): ');Readln(Fs);
t:=0;dt:=1e-4;Ms:=0;Uss:=round(310*Fs/50);
FileHead;Prepeare;Init_Graph;TextMode(2);
SetActivePage(0);SetVisualPage(0);
Scale(1.5*W0,-1.5*W0,EndT,'t,c','W,рад/с');
SetColor(round(GetMaxColor*0.7));
OutTextXY(66,8,'Программа расчета векторной диаграммы и некоторых
параметров А.Д.');
SetColor(round(GetMaxColor*0.9));
OutTextXY(112,20,'PsiAlpha:');OutTextXY(240,20,'IsAlpha:');
OutTextXY(368,20,'KPD:');OutTextXY(496,20,'IsPrAlpha:');
OutTextXY(96,40,'RelSkRasch:');OutTextXY(256,40,'CurrW:');
OutTextXY(376,40,'Is:');OutTextXY(536,40,'CosF:');
SetViewPort(0,0,GetMaxX,GetMaxY,True);
color:=GetMaxColor;SetColor(color);
Model;
Quit;
end.
{ ИСХОДНЫЙ ТЕКСТ МОДУЛЯ СЕРВИСНЫХ ПРОЦЕДУР И ФУНКЦИЙ }
Unit Im_tpu;
Interface
uses graph,dos,crt,printer;
type string4=string[4];
procedure pausa;
procedure Scale(Ymax,Ymin,Tmax:real;XText,YText:string);
function AbsoluteAngle(AComponent,BComponent:real):integer;
procedure PutVector(Xb,Yb,MVector,AVector,Col:real;Name:string4);
function NumberInput(What:string):integer;
procedure TextOut(X,Y:integer;Col:real;TextString:string);
procedure CopyToPRN;
function Sgn(v:real):integer;
function DefTime:string;
procedure TimeOut;
procedure PrintPausa;
Implementation
{ Пауза до первой нажатой клавиши }
procedure pausa;
begin
Repeat Until ReadKey<>#0
end;
{ Вывод на экран системы координат }
procedure Scale(Ymax,Ymin,Tmax:real;XText,YText:string);
var Ybeg,Ystep,Tstep,t1:real;
ScaleGrad:string;
Col:word;
SDrawX,SDrawY,HelpVar,GDriver,GMode:integer;
begin
DetectGraph(GDriver,GMode);GMode:=1;
InitGraph(Gdriver,GMode,'');
SetBkColor(0);SetColor(GetMaxColor);
Col:=GetMaxColor;PutPixel(0,0,Col);
LineTo(GetMaxX,0);LineTo(GetMaxX,GetMaxY);
LineTo(0,GetMaxY);LineTo(0,0);
for SDrawX:=1 to 19 do
for SdrawY:=1 to 19 do
PutPixel(SdrawX*GetMaxX div
20,SdrawY*GetMaxY div 20,col);
SetTextStyle(0,0,1);
if Ymin<0 then Ystep:=(Ymax-Ymin)/10
else
Ystep:=Ymax/10;
for HelpVar:=0 to 10 do
begin
Str(Ymax:9,ScaleGrad);
OutTextXY(0,HelpVar*GetMaxY div
10,ScaleGrad);
Ymax:=Ymax-Ystep;
end;
Tstep:=Tmax/5;t1:=0;
for HelpVar:=0 to 4 do
begin
Str(t1:9,ScaleGrad);
OutTextXY(HelpVar*GetMaxX div 5,GetMaxY-
10,ScaleGrad);
t1:=t1+Tstep;
end;
SetColor(round(GetMaxColor/1.25));
OutTextXY(GetMaxX-48,GetMaxY-
11,XText);OutTextXY(8,20,YText);
SetColor(GetMaxColor);
end;
{ Функция геометрического анализа и расчета абсолютного угла вектора }
function AbsoluteAngle(AComponent,BComponent:real):integer;
var IntAngle:integer;
begin
if AComponent<>0 then
IntAngle:=round(180/Pi*ArcTan(BComponent/AComponent));
if AComponent=0 then
begin
if BComponent>0 then IntAngle:=90
else IntAngle:=-90;
end
else
if BComponent=0 then
begin
if AComponent>0 then
IntAngle:=0
else IntAngle:=180;
end
else
if ((AComponent>0) and (BComponent>0)) or
(AComponent>0) and (BComponent<0) then
{первый и второй квадранты}
IntAngle:=IntAngle
else
IntAngle:=180+IntAngle;{второй и третий квадранты};
if IntAngle<0 then IntAngle:=360+IntAngle;
AbsoluteAngle:=IntAngle;
end;
{ Процедура вывода вектора по заданным координатам }
procedure PutVector(Xb,Yb,MVector,AVector,Col:real;Name:string4);
const LengthPoint=8;
var Xbh,Ybh,Xeh,Yeh,Xp,Yp,AVAngle:integer;
Xk,Yk,Colh:word;
Kx:real;
begin
GetAspectRatio(Xk,Yk);Kx:=Yk/Xk;
Xbh:=round(Xb);Ybh:=Round(Yb);
Xeh:=Round(Xb+Kx*MVector*cos(Pi/180*AVector));
Yeh:=round(Yb-MVector*sin(Pi/180*AVector));
Colh:=round(Col);SetColor(Colh);
Line(Xbh,Ybh,Xeh,Yeh);
AVAngle:=AbsoluteAngle((Xeh-Xbh),(Ybh-Yeh));
Xp:=round(LengthPoint*Kx*Cos(Pi/180*(AVAngle+10)));
Yp:=round(LengthPoint*Sin(Pi/180*(AVAngle+10)));
Xp:=Xeh-Xp;Yp:=Yeh+Yp;
Line(Xeh,Yeh,Xp,Yp);
Xp:=round(LengthPoint*Kx*Cos(Pi/180*(AVAngle-10)));
Yp:=round(LengthPoint*Sin(Pi/180*(AVAngle-10)));
Xp:=Xeh-Xp;Yp:=Yeh+Yp;
Line(Xeh,Yeh,Xp,Yp);
OutTextXY(Xeh+4,Yeh,Name);
end;
{ Функция ввода числа с клавиатуры в графическом режиме }
function NumberInput(What:string):integer;
var InputChar:char;
number:integer;
begin
SetActivePage(1);SetVisualPage(1);
SetColor(round(GetMaxColor*0.8));What:=What+' :';
OutTextXY(0,GetMaxY-80,What);Number:=0;MoveTo(120,GetMaxY-80);
Repeat
InputChar:=ReadKey;
if (InputChar>'/') and (InputChar<':') then
begin
Number:=Number*10-48+ord(InputChar);
OutText(InputChar);
end;
Until ord(InputChar)=13;
SetColor(GetMaxColor);SetBkColor(0);
SetViewPort(0,GetMaxY-80,300,GetMaxY-72,True);
ClearViewPort;NumberInput:=Number;
SetViewPort(0,0,GetMaxX,GetMaxY,True);
SetActivePage(0);
end;
{ Процедура вывода на экран в заданную позицию (X,Y)
заданного текста (TextString) заданным цветом (Col) }
procedure TextOut(X,Y:integer;Col:real;TextString:string);
begin
SetColor(round(Col*GetMaxColor));
OutTextXY(X,Y,TextString);
end;
{ Процедура графической копии экрана }
procedure CopyToPRN;
var x1,x2,y1,y2:integer;
Bk1,Bk2,Mode:Byte;
Inverse:Boolean;
procedure SetPoints;
begin
x1:=0;x2:=GetMaxX;
y1:=0;y2:=GetMaxY;
Bk1:=0;Bk2:=0;
Inverse:=False;
Mode:=1;
end;
{ X1,Y1,X2,Y2 - the size of output screen }
{ Bk1,Bk2 - the colours of the both backgrounds }
{ Inverse - normal (false) or invert (true) colour of the printing copy }
{ Mode: 1 - double density 120 points/inch }
{ 2 - high speed 120 points/inch }
{ 3 - high density 240 points/inch }
{ 0, 4, 5 - 80 points/inch }
{ 6 - 90 points/inch }
{ For nonFX EPSON - printers Mode = 1 }
var ScanLine:integer;{ current printing string }
n1,n2 :Byte; { special data for printer }
{ The construction of the byte for the printing graphics }
function ConstructByte(x,y:integer):byte;
const bits:array[0..7] of byte=(128,64,32,16,8,4,2,1);
var p :word; { the colour of the pixel }
CByte,Bit:byte; { byte and the bites number }
YY :integer; { the state of the current pixel }
begin
CByte:=0;
for Bit:=0 to 7 do
begin
Страницы: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|