📄 verifyammterview.cpp
字号:
CByteArray array;
array.RemoveAll();
array.SetSize(19);
for(i=0;i<19;i++){
array.SetAt(i,SendBuffer2[i]);
}
m_ctrlcomm.SetOutput(COleVariant(array));
m_voltage2.Format("%.2f",disp_voltage2[sel24]);
m_transfer21.Format("%.6x",(DWORD)voltage2[sel24]);
if(sel24==0)
voltage2_11=m_transfer21;
else if(sel24==1)
voltage2_12=m_transfer21;
else if(sel24==2)
voltage2_13=m_transfer21;
else if(sel24==3)
voltage2_14=m_transfer21;
UpdateData(FALSE);
}
void CVerifyAmmterView::OnCurrent2VerifyButton()
{
// 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_current2[sel23] -1;
// CString msg;
// msg.Format("%f",ugain1);
// AfxMessageBox(msg);
// int igain;
if(igain1<0)
current2[sel23]=pow(2,24)+igain1*pow(2,23);
else if(igain1>0)
current2[sel23]=igain1*pow(2,23);
BYTE SendBuffer3[50];
BYTE cs=0;
SendBuffer3[0]=0xfe;
SendBuffer3[1]=0xfe;
SendBuffer3[2]=0x68;
SendBuffer3[3]=02;
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]=sel23+1;
SendBuffer3[14]=(BYTE)(((DWORD)current2[sel23])>>16);
SendBuffer3[15]=(BYTE)(((DWORD)current2[sel23])>>8);
SendBuffer3[16]=(BYTE)((DWORD)current2[sel23]);
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_current2.Format("%.2f",disp_current2[sel23]);
m_transfer22.Format("%.6x",(DWORD)current2[sel23]);
if(sel23==0)
current2_11=m_transfer22;
else if(sel23==1)
current2_12=m_transfer22;
else if(sel23==2)
current2_13=m_transfer22;
else if(sel23==3)
current2_14=m_transfer22;
UpdateData(FALSE);
}
void CVerifyAmmterView::OnPower2ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_power[10];
BYTE SendBuffer_man[50];
BYTE cs_man=0;
if(m_power2.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_power2.GetAt(i)<='9')&&(m_power2.GetAt(i)>='0'))
key_power[i]=m_power2.GetAt(i)-'0';
else if(m_power2.GetAt(i)<='f'&&m_power2.GetAt(i)>='a')
key_power[i]=m_power2.GetAt(i)-'a'+10;
else if(m_power2.GetAt(i)<='F'&&m_power2.GetAt(i)>='A')
key_power[i]=m_power2.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]=02;
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]=sel21+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::OnPhase2ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_phase[10];
BYTE SendBuffer1_man[50];
BYTE cs_man=0;
if(m_phase2.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_phase2.GetAt(i)<='9')&&(m_phase2.GetAt(i)>='0'))
key_phase[i]=m_phase2.GetAt(i)-'0';
else if(m_phase2.GetAt(i)<='f'&&m_phase2.GetAt(i)>='a')
key_phase[i]=m_phase2.GetAt(i)-'a'+10;
else if(m_phase2.GetAt(i)<='F'&&m_phase2.GetAt(i)>='A')
key_phase[i]=m_phase2.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]=02;
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]=sel22+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::OnVolatge2ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_voltage[10];
BYTE SendBuffer2_man[50];
BYTE cs_man=0;
if(m_transfer21.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_transfer21.GetAt(i)<='9')&&(m_transfer21.GetAt(i)>='0'))
key_voltage[i]=m_transfer21.GetAt(i)-'0';
else if(m_transfer21.GetAt(i)<='f'&&m_transfer21.GetAt(i)>='a')
key_voltage[i]=m_transfer21.GetAt(i)-'a'+10;
else if(m_transfer21.GetAt(i)<='F'&&m_transfer21.GetAt(i)>='A')
key_voltage[i]=m_transfer21.GetAt(i)-'A'+10;
else
{ AfxMessageBox("系统无效");
return;
}
}
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]=02;
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]=sel24;
// 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::OnCurrent2ManButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
BYTE key_current[10];
BYTE SendBuffer3_man[50];
BYTE cs_man=0;
if(m_transfer22.GetLength()!=6){
AfxMessageBox("系统无效");
return;
}
for(int i=0;i<6;i++){
if((m_transfer22.GetAt(i)<='9')&&(m_transfer22.GetAt(i)>='0'))
key_current[i]=m_transfer22.GetAt(i)-'0';
else if(m_transfer22.GetAt(i)<='f'&&m_transfer22.GetAt(i)>='a')
key_current[i]=m_transfer22.GetAt(i)-'a'+10;
else if(m_transfer22.GetAt(i)<='F'&&m_transfer22.GetAt(i)>='A')
key_current[i]=m_transfer22.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]=02;
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]=sel23+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::OnVoltage2TranButton()
{
// 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]=02;
SendBuffer3[4]='L';
SendBuffer3[5]='o';
SendBuffer3[6]='a';
SendBuffer3[7]='d';
SendBuffer3[8]='V';
SendBuffer3[9]=sel24+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::OnCurrent2TranButton()
{
// 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]=02;
SendBuffer3[4]='L';
SendBuffer3[5]='o';
SendBuffer3[6]='a';
SendBuffer3[7]='d';
SendBuffer3[8]='C';
SendBuffer3[9]=sel23+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::OnVerifyButton2()
{
// 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]=02;
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::OnAddButton2()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_pSet->AddNew();
m_pSet->m_form_number=m_number2;
m_pSet->m_power1_verify=power2_11;
m_pSet->m_power2_verify=power2_12;
m_pSet->m_power3_verify=power2_13;
m_pSet->m_power4_verify=power2_14;
m_pSet->m_power1_error=error_power2[0];
m_pSet->m_power2_error=error_power2[1];
m_pSet->m_power3_error=error_power2[2];
m_pSet->m_power4_error=error_power2[3];//功率
m_pSet->m_phase1_verify=phase2_11;
m_pSet->m_phase2_verify=phase2_12;
m_pSet->m_phase3_verify=phase2_13;
m_pSet->m_phase4_verify=phase2_14;
m_pSet->m_phase1_error=error_phase2[0];
m_pSet->m_phase2_error=error_phase2[1];
m_pSet->m_phase3_error=error_phase2[2];
m_pSet->m_phase4_error=error_phase2[3];//相位
m_pSet->m_voltage_verify=voltage2_11;
m_pSet->m_voltage_verify=voltage2_12;
m_pSet->m_voltage_verify=voltage2_13;
m_pSet->m_voltage_verify=voltage2_14;
m_pSet->m_voltage_trans=disp_voltage2[0];
m_pSet->m_voltage_trans=disp_voltage2[1];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -