📄 verifyammterview.cpp
字号:
}
key_voltage[0]<<=4;
SendBuffer2_man[14]=key_voltage[0]|key_voltage[1];
key_voltage[2]<<=4;
SendBuffer2_man[15]=key_voltage[2]|key_voltage[3];
key_voltage[4]<<=4;
SendBuffer2_man[16]=key_voltage[4]|key_voltage[5];
SendBuffer2_man[0]=0xfe;
SendBuffer2_man[1]=0xfe;
SendBuffer2_man[2]=0x68;
SendBuffer2_man[3]=01;
SendBuffer2_man[4]='C';
SendBuffer2_man[5]='h';
SendBuffer2_man[6]='e';
SendBuffer2_man[7]='c';
SendBuffer2_man[8]='k';
SendBuffer2_man[9]='o';
SendBuffer2_man[10]='u';
SendBuffer2_man[11]='t';
SendBuffer2_man[12]='V';
SendBuffer2_man[13]=sel4+1;
// SendBuffer1_man[12]='G';
for(int k=2;k<17;k++){
cs_man+=SendBuffer2_man[k];
}
SendBuffer2_man[17]=cs_man;
SendBuffer2_man[18]=0x16;
// m_power.Format("%.6x",(DWORD)power[sel1]);
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer2_man[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
}
void CVerifyAmmterView::OnCurrent1ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_current[10];
BYTE SendBuffer3_man[50];
BYTE cs_man=0;
if(m_transfer2.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_transfer2.GetAt(i)<='9')&&(m_transfer2.GetAt(i)>='0'))
key_current[i]=m_transfer2.GetAt(i)-'0';
else if(m_transfer2.GetAt(i)<='f'&&m_transfer2.GetAt(i)>='a')
key_current[i]=m_transfer2.GetAt(i)-'a'+10;
else if(m_transfer2.GetAt(i)<='F'&&m_transfer2.GetAt(i)>='A')
key_current[i]=m_transfer2.GetAt(i)-'A'+10;
else
{ AfxMessageBox("系统无效");
return;
}
}
key_current[0]<<=4;
SendBuffer3_man[14]=key_current[0]|key_current[1];
key_current[2]<<=4;
SendBuffer3_man[15]=key_current[2]|key_current[3];
key_current[4]<<=4;
SendBuffer3_man[16]=key_current[4]|key_current[5];
SendBuffer3_man[0]=0xfe;
SendBuffer3_man[1]=0xfe;
SendBuffer3_man[2]=0x68;
SendBuffer3_man[3]=01;
SendBuffer3_man[4]='C';
SendBuffer3_man[5]='h';
SendBuffer3_man[6]='e';
SendBuffer3_man[7]='c';
SendBuffer3_man[8]='k';
SendBuffer3_man[9]='o';
SendBuffer3_man[10]='u';
SendBuffer3_man[11]='t';
SendBuffer3_man[12]='C';
// SendBuffer1[12]='G';
SendBuffer3_man[13]=sel3+1;
// SendBuffer3_man[13]=(BYTE)(((DWORD)current[sel3])>>16);
// SendBuffer3_man[14]=(BYTE)(((DWORD)current[sel3])>>8);
// SendBuffer3_man[15]=(BYTE)((DWORD)current[sel3]);
for(int k=2;k<17;k++){
cs_man+=SendBuffer3_man[k];
}
SendBuffer3_man[17]=cs_man;
SendBuffer3_man[18]=0x16;
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer3_man[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
}
void CVerifyAmmterView::OnVoltage1TranButton()
{
// TODO: Add your control notification handler code here
BYTE SendBuffer3[50];
BYTE cs=0;
SendBuffer3[0]=0xfe;
SendBuffer3[1]=0xfe;
SendBuffer3[2]=0x68;
SendBuffer3[3]=01;
SendBuffer3[4]='L';
SendBuffer3[5]='o';
SendBuffer3[6]='a';
SendBuffer3[7]='d';
SendBuffer3[8]='V';
SendBuffer3[9]=sel4+1;
SendBuffer3[11]=0x16;
for(int k=2;k<10;k++){
cs+=SendBuffer3[k];
}
SendBuffer3[10]=cs;
CByteArray array;
array.RemoveAll();
array.SetSize(12);
// BYTE rxdata[32];
for(int i=0;i<12;i++){
array.SetAt(i,SendBuffer3[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
m_ctrlcomm.SetRThreshold(10);
}
void CVerifyAmmterView::OnCurrent1TranButton()
{
// TODO: Add your control notification handler code here
BYTE SendBuffer3[50];
BYTE cs=0;
SendBuffer3[0]=0xfe;
SendBuffer3[1]=0xfe;
SendBuffer3[2]=0x68;
SendBuffer3[3]=01;
SendBuffer3[4]='L';
SendBuffer3[5]='o';
SendBuffer3[6]='a';
SendBuffer3[7]='d';
SendBuffer3[8]='C';
SendBuffer3[9]=sel3+1;
SendBuffer3[11]=0x16;
for(int k=2;k<10;k++){
cs+=SendBuffer3[k];
}
SendBuffer3[10]=cs;
CByteArray array;
array.RemoveAll();
array.SetSize(12);
// BYTE rxdata[32];
for(int i=0;i<12;i++){
array.SetAt(i,SendBuffer3[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
m_ctrlcomm.SetRThreshold(10);
}
void CVerifyAmmterView::OnVerifyButton1()
{
// TODO: Add your control notification handler code here
CDialog2 tr;
tr.DoModal();
if(tr.Getbok()==TRUE){
BYTE SendBuffer1[50];
BYTE cs=0;
SendBuffer1[0]=0xfe;
SendBuffer1[1]=0xfe;
SendBuffer1[2]=0x68;
SendBuffer1[3]='S';
SendBuffer1[4]='y';
SendBuffer1[5]='s';
SendBuffer1[6]='t';
SendBuffer1[7]='e';
SendBuffer1[8]='m';
SendBuffer1[9]='I';
SendBuffer1[10]='n';
SendBuffer1[11]='i';
SendBuffer1[12]='t';
SendBuffer1[13]='i';
SendBuffer1[14]='a';
SendBuffer1[15]='l';
SendBuffer1[16]='i';
SendBuffer1[17]='z';
SendBuffer1[18]='e';
SendBuffer1[19]=01;
for(int k=2;k<20;k++){
cs+=SendBuffer1[k];
}
SendBuffer1[20]=cs;
SendBuffer1[21]=0x16;
CByteArray array;
array.RemoveAll();
array.SetSize(22);
for(int i=0;i<22;i++){
array.SetAt(i,SendBuffer1[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
}
}
void CVerifyAmmterView::OnAddButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_pSet->AddNew();
m_pSet->m_form_number=m_number1;
m_pSet->m_power1_verify=power11;
m_pSet->m_power2_verify=power12;
m_pSet->m_power3_verify=power13;
m_pSet->m_power4_verify=power14;
m_pSet->m_power1_error=error_power[0];
m_pSet->m_power2_error=error_power[1];
m_pSet->m_power3_error=error_power[2];
m_pSet->m_power4_error=error_power[3];//功率
m_pSet->m_phase1_verify=phase11;
m_pSet->m_phase2_verify=phase12;
m_pSet->m_phase3_verify=phase13;
m_pSet->m_phase4_verify=phase14;
m_pSet->m_phase1_error=error_phase[0];
m_pSet->m_phase2_error=error_phase[1];
m_pSet->m_phase3_error=error_phase[2];
m_pSet->m_phase4_error=error_phase[3];//相位
m_pSet->m_voltage_verify=voltage11;
m_pSet->m_voltage_verify=voltage12;
m_pSet->m_voltage_verify=voltage13;
m_pSet->m_voltage_verify=voltage14;
m_pSet->m_voltage_trans=disp_voltage[0];
m_pSet->m_voltage_trans=disp_voltage[1];
m_pSet->m_voltage_trans=disp_voltage[2];
m_pSet->m_voltage_trans=disp_voltage[3];//电压
m_pSet->m_current1_verify=current11;
m_pSet->m_current2_verify=current12;
m_pSet->m_current3_verify=current13;
m_pSet->m_current4_verify=current14;
m_pSet->m_current1_trans=disp_current[0];
m_pSet->m_current2_trans=disp_current[1];
m_pSet->m_current3_trans=disp_current[2];
m_pSet->m_current4_trans=disp_current[3];//电流
m_pSet->Update();
m_pSet->Requery();
}
void CVerifyAmmterView::OnCloseupList2Power()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel21=m_list21.GetCurSel();
m_error21=error_power2[sel21];
m_power2.Format("%.6x",(DWORD)power2[sel21]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList2Phase()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel22=m_list22.GetCurSel();
m_phase2.Format("%.6x",(DWORD)phase2[sel22]);
m_error22=error_phase2[sel22];
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList2Voltage()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel24=m_list24.GetCurSel();
m_voltage2.Format("%.2f",disp_voltage2[sel24]);
m_transfer21.Format("%.6x",(DWORD)voltage2[sel24]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList2Current()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel23=m_list23.GetCurSel();
m_current2.Format("%.2f",disp_current2[sel23]);
m_transfer22.Format("%.6x",(DWORD)current2[sel23]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnPower2VerifyButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
error_power2[sel21]=m_error21;
double result=pow(2,23);
double error_power1=error_power2[sel21]/100;
double pgain=(0-error_power1)/(1+error_power1);
if(m_error21<0.00)
power2[sel21]=pgain*result;
else if(m_error21>0.00)
power2[sel21]=pow(2,24)+pgain*result;
// BYTE power[32];
// power[0]=0xfe;
// power[1]=0xfe;
// power[2]=0x68;
// DWORD dwPower = (DWORD)power[sel1];
// BYTE temp = dwPower >> 8;
// CString msg;
// msg.Format("%x",dwPower);
// AfxMessageBox(msg);
// power[sel1]=((DWORD)power[sel1])&((DWORD)0x0FF0000);
BYTE SendBuffer[50];
BYTE cs=0;
SendBuffer[0]=0xfe;
SendBuffer[1]=0xfe;
SendBuffer[2]=0x68;
SendBuffer[3]=02;
SendBuffer[4]='C';
SendBuffer[5]='h';
SendBuffer[6]='e';
SendBuffer[7]='c';
SendBuffer[8]='k';
SendBuffer[9]='o';
SendBuffer[10]='u';
SendBuffer[11]='t';
SendBuffer[12]='P';
SendBuffer[13]='G';
SendBuffer[14]=sel21+1;
SendBuffer[15]=(BYTE)(((DWORD)power2[sel21])>>16);
SendBuffer[16]=(BYTE)(((DWORD)power2[sel21])>>8);
SendBuffer[17]=(BYTE)((DWORD)power2[sel21]);
for(int i=2;i<18;i++){
cs+=SendBuffer[i];
}
SendBuffer[18]=cs;
SendBuffer[19]=0x16;
m_power2.Format("%.6x",(DWORD)power2[sel21]);
if(sel21==0)
power2_11=m_power2;
else if(sel21==1)
power2_12=m_power2;
else if(sel21==2)
power2_13=m_power2;
else if(sel21==3)
power2_14=m_power2;
CByteArray array;
array.RemoveAll();
array.SetSize(20);
for(i=0;i<20;i++){
array.SetAt(i,SendBuffer[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
UpdateData(FALSE);
}
void CVerifyAmmterView::OnPhase2VerifyButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
error_phase2[sel22]=m_error22;
double result=pow(2,23);
double error_phase1=error_phase2[sel22]/100;
double cita=acos((1+error_phase1)*0.5)-3.1415926/3;
// double pgain=(0-error_phase1)/(1+error_phase1);
if(m_error22<0.00)
phase2[sel22]=cita*result;
else if(m_error22>0.00)
phase2[sel22]=pow(2,24)+cita*result;
BYTE SendBuffer1[50];
BYTE cs=0;
SendBuffer1[0]=0xfe;
SendBuffer1[1]=0xfe;
SendBuffer1[2]=0x68;
SendBuffer1[3]=02;
SendBuffer1[4]='C';
SendBuffer1[5]='h';
SendBuffer1[6]='e';
SendBuffer1[7]='c';
SendBuffer1[8]='k';
SendBuffer1[9]='o';
SendBuffer1[10]='u';
SendBuffer1[11]='t';
SendBuffer1[12]='P';
// SendBuffer1[12]='G';
SendBuffer1[13]=sel22+1;
SendBuffer1[14]=(BYTE)(((DWORD)phase2[sel22])>>16);
SendBuffer1[15]=(BYTE)(((DWORD)phase2[sel22])>>8);
SendBuffer1[16]=(BYTE)((DWORD)phase2[sel22]);
for(int i=2;i<17;i++){
cs+=SendBuffer1[i];
}
SendBuffer1[17]=cs;
SendBuffer1[18]=0x16;
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer1[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
// CString msg;
// msg.Format("%f",sel);
// AfxMessageBox(msg);
m_phase2.Format("%.6x",(DWORD)phase2[sel22]);
if(sel22==0)
phase2_11=m_phase2;
else if(sel22==1)
phase2_12=m_phase2;
else if(sel22==2)
phase2_13=m_phase2;
else if(sel22==3)
phase2_14=m_phase2;
// power=((DWORD)power)&((DWORD)0x0FF);
// m_strPowerEdit.Format("%.6x",(DWORD)power);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnVoltage2VerifyButton()
{
// TODO: Add your control notification handler code here
double urms=transfer21/pow(2,13);
disp_voltage2[sel24]=urms;
double ugain1=(double)220/urms -1;
// CString msg;
// msg.Format("%f",ugain1);
// AfxMessageBox(msg);
if(ugain1<0)
voltage2[sel24]=pow(2,24)+ugain1*pow(2,23);
else if(ugain1>0)
voltage2[sel24]=ugain1*pow(2,23);
BYTE SendBuffer2[50];
BYTE cs=0;
SendBuffer2[0]=0xfe;
SendBuffer2[1]=0xfe;
SendBuffer2[2]=0x68;
SendBuffer2[3]=02;
SendBuffer2[4]='C';
SendBuffer2[5]='h';
SendBuffer2[6]='e';
SendBuffer2[7]='c';
SendBuffer2[8]='k';
SendBuffer2[9]='o';
SendBuffer2[10]='u';
SendBuffer2[11]='t';
SendBuffer2[12]='V';
SendBuffer2[13]=sel24+1;
// SendBuffer1[12]='G';
// SendBuffer2[12]=sel2;
SendBuffer2[14]=(BYTE)(((DWORD)voltage2[sel24])>>16);
SendBuffer2[15]=(BYTE)(((DWORD)voltage2[sel24])>>8);
SendBuffer2[16]=(BYTE)((DWORD)voltage2[sel24]);
for(int i=2;i<17;i++){
cs+=SendBuffer2[i];
}
SendBuffer2[17]=cs;
SendBuffer2[18]=0x16;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -