📄 verifyammterview.cpp
字号:
m_pSet->m_voltage_trans=disp_voltage2[2];
m_pSet->m_voltage_trans=disp_voltage2[3];//电压
m_pSet->m_current1_verify=current2_11;
m_pSet->m_current2_verify=current2_12;
m_pSet->m_current3_verify=current2_13;
m_pSet->m_current4_verify=current2_14;
m_pSet->m_current1_trans=disp_current2[0];
m_pSet->m_current2_trans=disp_current2[1];
m_pSet->m_current3_trans=disp_current2[2];
m_pSet->m_current4_trans=disp_current2[3];//电流
m_pSet->Update();
m_pSet->Requery();
}
void CVerifyAmmterView::OnCloseupList3Power()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel31=m_list31.GetCurSel();
m_error31=error_power3[sel31];
m_power3.Format("%.6x",(DWORD)power3[sel31]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList3Phase()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel32=m_list32.GetCurSel();
m_phase3.Format("%.6x",(DWORD)phase3[sel32]);
m_error32=error_phase3[sel32];
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList3Voltage()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel34=m_list34.GetCurSel();
m_voltage3.Format("%.2f",disp_voltage3[sel34]);
m_transfer31.Format("%.6x",(DWORD)voltage3[sel34]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCloseupList3Current()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
sel33=m_list33.GetCurSel();
m_current3.Format("%.2f",disp_current3[sel33]);
m_transfer32.Format("%.6x",(DWORD)current3[sel33]);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnPower3VerifyButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
error_power3[sel31]=m_error31;
double result=pow(2,23);
double error_power1=error_power3[sel31]/100;
double pgain=(0-error_power1)/(1+error_power1);
if(m_error31<0.00)
power3[sel31]=pgain*result;
else if(m_error31>0.00)
power3[sel31]=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]=03;
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]=sel31+1;
SendBuffer[15]=(BYTE)(((DWORD)power3[sel31])>>16);
SendBuffer[16]=(BYTE)(((DWORD)power3[sel31])>>8);
SendBuffer[17]=(BYTE)((DWORD)power3[sel31]);
for(int i=2;i<18;i++){
cs+=SendBuffer[i];
}
SendBuffer[18]=cs;
SendBuffer[19]=0x16;
m_power3.Format("%.6x",(DWORD)power3[sel31]);
if(sel31==0)
power3_11=m_power3;
else if(sel31==1)
power3_12=m_power3;
else if(sel31==2)
power3_13=m_power3;
else if(sel31==3)
power3_14=m_power3;
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::OnPhase3VerifyButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
error_phase3[sel32]=m_error32;
double result=pow(2,23);
double error_phase1=error_phase3[sel32]/100;
double cita=acos((1+error_phase1)*0.5)-3.1415926/3;
// double pgain=(0-error_phase1)/(1+error_phase1);
if(m_error32<0.00)
phase3[sel32]=cita*result;
else if(m_error32>0.00)
phase3[sel32]=pow(2,24)+cita*result;
BYTE SendBuffer1[50];
BYTE cs=0;
SendBuffer1[0]=0xfe;
SendBuffer1[1]=0xfe;
SendBuffer1[2]=0x68;
SendBuffer1[3]=03;
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]=sel32+1;
SendBuffer1[14]=(BYTE)(((DWORD)phase3[sel32])>>16);
SendBuffer1[15]=(BYTE)(((DWORD)phase3[sel32])>>8);
SendBuffer1[16]=(BYTE)((DWORD)phase3[sel32]);
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_phase3.Format("%.6x",(DWORD)phase3[sel32]);
if(sel32==0)
phase3_11=m_phase3;
else if(sel32==1)
phase3_12=m_phase3;
else if(sel32==2)
phase3_13=m_phase3;
else if(sel32==3)
phase3_14=m_phase3;
// power=((DWORD)power)&((DWORD)0x0FF);
// m_strPowerEdit.Format("%.6x",(DWORD)power);
UpdateData(FALSE);
}
void CVerifyAmmterView::OnVoltage3VerifyButton()
{
// TODO: Add your control notification handler code here
double urms=transfer31/pow(2,13);
disp_voltage3[sel34]=urms;
double ugain1=(double)220/urms -1;
// CString msg;
// msg.Format("%f",ugain1);
// AfxMessageBox(msg);
if(ugain1<0)
voltage3[sel34]=pow(2,24)+ugain1*pow(2,23);
else if(ugain1>0)
voltage3[sel34]=ugain1*pow(2,23);
BYTE SendBuffer2[50];
BYTE cs=0;
SendBuffer2[0]=0xfe;
SendBuffer2[1]=0xfe;
SendBuffer2[2]=0x68;
SendBuffer2[3]=03;
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]=sel34+1;
// SendBuffer1[12]='G';
// SendBuffer2[12]=sel2;
SendBuffer2[14]=(BYTE)(((DWORD)voltage3[sel34])>>16);
SendBuffer2[15]=(BYTE)(((DWORD)voltage3[sel34])>>8);
SendBuffer2[16]=(BYTE)((DWORD)voltage3[sel34]);
for(int i=2;i<17;i++){
cs+=SendBuffer2[i];
}
SendBuffer2[17]=cs;
SendBuffer2[18]=0x16;
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer2[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
m_voltage3.Format("%.2f",disp_voltage3[sel34]);
m_transfer31.Format("%.6x",(DWORD)voltage3[sel34]);
if(sel34==0)
voltage3_11=m_transfer31;
else if(sel34==1)
voltage3_12=m_transfer31;
else if(sel34==2)
voltage3_13=m_transfer31;
else if(sel34==3)
voltage3_14=m_transfer31;
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCurrent3VerifyButton()
{
// TODO: Add your control notification handler code here
// current[sel3]=transfer2;
// disp_current[sel3]=current[sel3]/pow(2,13);
// double igain1=(double)1.5/irms -1;
//disp_current[sel3]=0.04;
double igain1=(double)1.5/disp_current3[sel33] -1;
// CString msg;
// msg.Format("%f",ugain1);
// AfxMessageBox(msg);
// int igain;
if(igain1<0)
current3[sel33]=pow(2,24)+igain1*pow(2,23);
else if(igain1>0)
current3[sel33]=igain1*pow(2,23);
BYTE SendBuffer3[50];
BYTE cs=0;
SendBuffer3[0]=0xfe;
SendBuffer3[1]=0xfe;
SendBuffer3[2]=0x68;
SendBuffer3[3]=03;
SendBuffer3[4]='C';
SendBuffer3[5]='h';
SendBuffer3[6]='e';
SendBuffer3[7]='c';
SendBuffer3[8]='k';
SendBuffer3[9]='o';
SendBuffer3[10]='u';
SendBuffer3[11]='t';
SendBuffer3[12]='C';
// SendBuffer1[12]='G';
SendBuffer3[13]=sel33+1;
SendBuffer3[14]=(BYTE)(((DWORD)current3[sel33])>>16);
SendBuffer3[15]=(BYTE)(((DWORD)current3[sel33])>>8);
SendBuffer3[16]=(BYTE)((DWORD)current3[sel33]);
for(int i=2;i<17;i++){
cs+=SendBuffer3[i];
}
SendBuffer3[17]=cs;
SendBuffer3[18]=0x16;
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer3[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
m_current3.Format("%.2f",disp_current3[sel33]);
m_transfer32.Format("%.6x",(DWORD)current3[sel33]);
if(sel33==0)
current3_11=m_transfer32;
else if(sel33==1)
current3_12=m_transfer32;
else if(sel33==2)
current3_13=m_transfer32;
else if(sel33==3)
current3_14=m_transfer32;
UpdateData(FALSE);
}
void CVerifyAmmterView::OnPower3ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_power[10];
BYTE SendBuffer_man[50];
BYTE cs_man=0;
if(m_power3.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_power3.GetAt(i)<='9')&&(m_power3.GetAt(i)>='0'))
key_power[i]=m_power3.GetAt(i)-'0';
else if(m_power3.GetAt(i)<='f'&&m_power3.GetAt(i)>='a')
key_power[i]=m_power3.GetAt(i)-'a'+10;
else if(m_power3.GetAt(i)<='F'&&m_power3.GetAt(i)>='A')
key_power[i]=m_power3.GetAt(i)-'A'+10;
else
{ AfxMessageBox("系统无效");
return;
}
}
key_power[0]<<=4;
SendBuffer_man[15]=key_power[0]|key_power[1];
key_power[2]<<=4;
SendBuffer_man[16]=key_power[2]|key_power[3];
key_power[4]<<=4;
SendBuffer_man[17]=key_power[4]|key_power[5];
SendBuffer_man[0]=0xfe;
SendBuffer_man[1]=0xfe;
SendBuffer_man[2]=0x68;
SendBuffer_man[3]=03;
SendBuffer_man[4]='C';
SendBuffer_man[5]='h';
SendBuffer_man[6]='e';
SendBuffer_man[7]='c';
SendBuffer_man[8]='k';
SendBuffer_man[9]='o';
SendBuffer_man[10]='u';
SendBuffer_man[11]='t';
SendBuffer_man[12]='P';
SendBuffer_man[13]='G';
SendBuffer_man[14]=sel31+1;
for(int k=2;k<18;k++){
cs_man+=SendBuffer_man[k];
}
SendBuffer_man[18]=cs_man;
SendBuffer_man[19]=0x16;
// m_power.Format("%.6x",(DWORD)power[sel1]);
CByteArray array;
array.RemoveAll();
array.SetSize(20);
for(i=0;i<20;i++){
array.SetAt(i,SendBuffer_man[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
}
void CVerifyAmmterView::OnPhase3ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_phase[10];
BYTE SendBuffer1_man[50];
BYTE cs_man=0;
if(m_phase3.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_phase3.GetAt(i)<='9')&&(m_phase3.GetAt(i)>='0'))
key_phase[i]=m_phase3.GetAt(i)-'0';
else if(m_phase3.GetAt(i)<='f'&&m_phase3.GetAt(i)>='a')
key_phase[i]=m_phase3.GetAt(i)-'a'+10;
else if(m_phase3.GetAt(i)<='F'&&m_phase3.GetAt(i)>='A')
key_phase[i]=m_phase3.GetAt(i)-'A'+10;
else
{ AfxMessageBox("系统无效");
return;
}
}
key_phase[0]<<=4;
SendBuffer1_man[14]=key_phase[0]|key_phase[1];
key_phase[2]<<=4;
SendBuffer1_man[15]=key_phase[2]|key_phase[3];
key_phase[4]<<=4;
SendBuffer1_man[16]=key_phase[4]|key_phase[5];
SendBuffer1_man[0]=0xfe;
SendBuffer1_man[1]=0xfe;
SendBuffer1_man[2]=0x68;
SendBuffer1_man[3]=03;
SendBuffer1_man[4]='C';
SendBuffer1_man[5]='h';
SendBuffer1_man[6]='e';
SendBuffer1_man[7]='c';
SendBuffer1_man[8]='k';
SendBuffer1_man[9]='o';
SendBuffer1_man[10]='u';
SendBuffer1_man[11]='t';
SendBuffer1_man[12]='P';
// SendBuffer1_man[12]='G';
SendBuffer1_man[13]=sel32+1;
for(int k=2;k<17;k++){
cs_man+=SendBuffer1_man[k];
}
SendBuffer1_man[17]=cs_man;
SendBuffer1_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,SendBuffer1_man[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
}
void CVerifyAmmterView::OnVolatge3ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_voltage[10];
BYTE SendBuffer2_man[50];
BYTE cs_man=0;
if(m_transfer31.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_transfer31.GetAt(i)<='9')&&(m_transfer31.GetAt(i)>='0'))
key_voltage[i]=m_transfer31.GetAt(i)-'0';
else if(m_transfer31.GetAt(i)<='f'&&m_transfer31.GetAt(i)>='a')
key_voltage[i]=m_transfer31.GetAt(i)-'a'+10;
else if(m_transfer31.GetAt(i)<='F'&&m_transfer31.GetAt(i)>='A')
key_voltage[i]=m_transfer31.GetAt(i)-'A'+10;
else
{ AfxMessageBox("系统无效");
return;
}
}
key_voltage[0]<<=4;
SendBuffer2_man[14]=key_voltage[0]|key_voltage[1];
key_voltage[
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -