?? main.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "main.h"
#include <math.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
double dd = 0;
double vol[3][73];
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double kk, ll;
double vref[3];
double ph[3];
ph[0] = -(this->pha->Text.ToDouble());
ph[1] = -(this->phb->Text.ToDouble());
ph[2] = -(this->phc->Text.ToDouble());
vref[0] = this->voltagea->Text.ToDouble()*sqrt(2);
vref[1] = this->voltageb->Text.ToDouble()*sqrt(2);
vref[2] = this->voltagec->Text.ToDouble()*sqrt(2);
for(Byte count = 0; count < 3; count++)
{
this->Chart1->Series[count]->Clear();
kk = (ph[count]+(count * 120)) / 180 * 3.1415926;
for( Byte xx = 0; xx < 73; xx++ )
{
ll = sin( 314.15 * xx / 3600+kk);
ll = vref[count] * ll;
vol[count][xx] = ll;
}
for( Byte xx = 0; xx < 73; xx++ )
{
this->Chart1->Series[count]->Add( vol[count][xx] ,AnsiString(xx+1),this->Chart1->Series[count]->SeriesColor);
}
}
double sum = 0;
double tt;
this->Chart1->Series[3]->Clear();
for(Byte count = 0; count < 72; count++ )
{
tt = vol[0][count] + vol[1][count] + vol[2][count];
this->Chart1->Series[3]->Add(tt,"",this->Chart1->Series[3]->SeriesColor);
sum = sum +tt*tt;
}
sum = sqrt(sum/72);
this->voltage2->Text = Text.FormatFloat("0.00",sum);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
double sumv,suma, sump, sums, pq,sumav;
/* sumv = 0;
suma = 0;
sump = 0;
sumav = 0;
this->Series1->Title = "電壓";
this->Series2->Title = "電流";
for(Byte count = 0; count < 72; count++ )
{
sumv += vol[count] * vol[count];
suma += cur[count] * cur[count];
sump += vol[count] * cur[count];
sumav += vola[count] * vola[count];
}
sumv = sumv / 72;
sumv = sqrt(sumv);
sumav = sumav / 72;
sumav = sqrt(sumav);
suma = suma / 72;
suma = sqrt(suma);
sums = sumv * suma;
sump = sump / 72;
this->voltage2->Text = this->voltage2->Text.FormatFloat("0.00",sumv);
this->Edit2->Text = Text.FormatFloat("0.00",sumav);
this->current2->Text = this->current2->Text.FormatFloat("0.0000",suma);
this->power->Text = this->power->Text.FormatFloat("0.000",sump);
this->powers->Text = this->powers->Text.FormatFloat("0.000",sums);
pq = sump / sums;
this->powerdata->Text = AnsiString::FormatFloat("0.000",pq);
pq = acos(pq);
pq = pq * 180 / 3.1415;
this->dushu->Text = this->dushu->Text.FormatFloat("0.0",pq); */
}
//---------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -