Tải bản đầy đủ - 0 (trang)
Phục lục 2: chương trình giám sát hệ thống

Phục lục 2: chương trình giám sát hệ thống

Tải bản đầy đủ - 0trang

}

else

{

sp->Write("s"+"k");

axTChart2->Series(0)->AddXY(0,Convert::ToDouble(tbps>Text),"",2000);// vi tri set

axTChart2->Series(1)->AddXY(0,0,"",2000);

axTChart2->Series(2)->AddXY(0,0,"",2000);

axTChart2->Series(0)>AddXY(time+2000,Convert::ToDouble(tbps->Text),"",2000);

run->Text="Pause";

s=1;

}

}

private: System::Void stop_Click(System::Object^ sender, System::EventArgs^ e) {

sp->Write("x");

tran1=" ";

tran2=" ";

tran3=" ";

tran4=" ";

tran5=" ";

tran6=" ";

}

private: System::Void quit_Click(System::Object^ sender, System::EventArgs^ e) {

this->Close();

}

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)

{

run->Enabled=false;

stop->Enabled=false;

lbcom->Enabled=true;

array ^ a1=

System::IO::Ports::SerialPort::GetPortNames();

for(int i =0;iLength;i++)

{

lbcom->Items->Add(a1[i]);

}

}

private: System::Void connect_Click(System::Object^ sender, System::EventArgs^ e)

{

sp->PortName=Convert::ToString(lbcom->SelectedItem);



if(kt)

{

kt=false;

connect->Text="Disconnect";

sp->Open();

run->Enabled=true;

stop->Enabled=true;

lbcom->Enabled=false;

}

else

{

kt=true;

connect->Text="Connect";

sp->Close();

}

}

private: System::Void left_Click(System::Object^ sender, System::EventArgs^ e) {

tran2="2"+"q"+"a";

sp->Write(tran2);

}

private: System::Void right_Click(System::Object^ sender, System::EventArgs^ e) {

tran2="2"+"w"+"b";

sp->Write(tran2);

}

private: System::Void down_Click(System::Object^ sender, System::EventArgs^ e) {

tran3="3"+"e";

sp->Write(tran3);

}

private: System::Void up_Click(System::Object^ sender, System::EventArgs^ e) {

tran3="3"+"y";

sp->Write(tran3);

}

private: System::Void near_Click(System::Object^ sender, System::EventArgs^ e) {

tran5="5"+"u";

sp->Write(tran5);

}

private: System::Void far_Click(System::Object^ sender, System::EventArgs^ e) {

tran5="5"+"i";

sp->Write(tran5);

}

private: System::Void big_Click(System::Object^ sender, System::EventArgs^ e) {

tran6= "6"+"o";

sp->Write(tran6);

}



private: System::Void small_Click(System::Object^ sender, System::EventArgs^ e) {

tran6= "6"+"p";

sp->Write(tran6);

}

private: System::Void sp_DataReceived_2(System::Object^ sender,

System::IO::Ports::SerialDataReceivedEventArgs^ e) {

Control::CheckForIllegalCrossThreadCalls=false;

pos=Convert::ToString(sp->ReadLine());

current_v = Convert::ToDouble(pos);//vi tri hien tai

tbpc->Text=Convert::ToString(current_v*0.9);

//tbpc->Text=pos;

pos_v =Convert::ToInt32(tbps->Text);//vi tri set

//current_v=current_v*0.9;

time+=1;

axTChart2->Series(1)->AddXY(time,current_v*0.9,"",200000);

angle = Convert::ToInt32(current_v - pre_angle);

axTChart2->Series(2)->AddXY(time,angle*1.5,"",200000);

pre_angle = current_v;

if(time>10)

{

axTChart2->Axis->Bottom->Maximum=time+5;

}

}

private: System::Void set_Click(System::Object^ sender, System::EventArgs^ e) {

sp->Write(tbkp->Text+"p");

for(int i =0;i<20;i++){};

sp->Write(tbki->Text+"i");

for(int i =0;i<20;i++){};

sp->Write(tbkd->Text+"d");

if(vitri->Checked)

sp->Write(((Convert::ToInt32(tbps>Text)*10)/9)+"o"+"n");

if(vantoc->Checked)

sp->Write(((Convert::ToInt32(tbps>Text)*10)/9)+"v"+"m");

}

private: System::Void reset_Click(System::Object^ sender, System::EventArgs^ e) {

time1=0;//bien van toc

time=0;// bien vi tri

pot=0;



ts=0;

current_v=0;

pre_angle=0;

kqmax2=0;

angle=0;

kqmax1=0;

dem=0;

pos="0";

pos_v=0;

axTChart2->Series(0)->Clear ();// char2:vi tri

axTChart2->Series(1)->Clear ();

axTChart2->Series(2)->Clear ();

}

private: System::Void len_Click(System::Object^ sender, System::EventArgs^ e) {

tran1="1"+"t"+"f";

sp->Write(tran1);

}

private: System::Void xuong_Click(System::Object^ sender, System::EventArgs^ e) {

tran1="1"+"n"+"r";

sp->Write(tran1);

}

private: System::Void trai_Click(System::Object^ sender, System::EventArgs^ e) {

tran1="1"+"n"+"f";

sp->Write(tran1);

}

private: System::Void phai_Click(System::Object^ sender, System::EventArgs^ e) {

tran1="1"+"t"+"r";

sp->Write(tran1);

}

private: System::Void vantoc_CheckedChanged(System::Object^ sender,

System::EventArgs^ e) {

lbps->Text="Vel Set";

lbpc->Text="Vel Cur";

}

private: System::Void vitri_CheckedChanged(System::Object^ sender,

System::EventArgs^ e) {

lbps->Text="Pos Set";

lbpc->Text="Pos Cur";

}

};



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Phục lục 2: chương trình giám sát hệ thống

Tải bản đầy đủ ngay(0 tr)

×