📄 pcom.cpp
字号:
do
{
ret=sio_putch (com1,0x04);
}
while(ret!=1);
do
{
ret=sio_putch (com1,0xAA);
}
while(ret!=1);
do
{
ret=sio_putch (com1,Chk);
}
while(ret!=1);
break;
case MyFigure_T:
do
{
ret=sio_putch(com1,Kenn2);
}while(ret!=1);
break;
} //for switch
Send1Tel_OK = true;
ReleaseMutex(hMutex);
/*
if ( Send1Tel_OK ==false )
do
{
RTKernel.Delay ( 1 );
J++;
}
while(Send1Tel_OK||J>10);
while( Send1Tel_OK||I > 5 );
*/
}
//------------------------------------------------------------------------------------------
//for every the jobs
int display() //实时数据传送
{
if(NeuesGewicht!=true)
{
Send1Telegramm(Displ_T,0x02);
}
else
{
NeuesGewicht=false ;
return DAW50Gewicht;
}
}
//----------------------------------------------------------------
void cldisplay() //关闭实时显示
{
Send1Telegramm(Displ_T,0x04);
Sleep(10);
}
//---------------------------------------------------------------------------------------
String Memo(int pos) //参数校准
{
String s;
if(pos!=KalDat_T)
{
Send1Telegramm(KalPkt_T,pos); //送位置
Sleep(60);
}
Send1Telegramm(KalDat_T,0x01); //显示校准值和校准点,传回其数据
Sleep(100);
if (KalDat_OK)
{
s="";
for(int i=0;i<10;i++)
{
s+="a";
s+=IntToStr(KalAnalog[i]);
s+="a";
s+=IntToStr(KalPunkte[i]) ;
}
s+="a";
}
return s;
}
//--------------------------------------------------------------------------------------
void StaMode()
{
Send1Telegramm(StaMode_T,0x01);
Sleep(100);//a
}
//-------------------------------------------------------------------------------------
void ZeroSet() //零点设置
{
// do
// {
Send1Telegramm(ZeroSet_T,0x01);
// }
// while(ZeroSet_OK!=true);
}
//返回数组-------------------------------------------------------------------
HANDLE DisParam() //系统参数显示
{
// Send1Telegramm(Param_T,0x01);
Send1Telegramm(Param_T,0x01);
Sleep(100);
return SysParameter;
}
////////------------------------------------------------------------------------
HANDLE DisCLWParam() //CLW参数显示
{
//Send1Telegramm(CLW_P_T,0x01);
Send1Telegramm(CLW_P_T,0x01);
Sleep(100);
return SysFactor;
}
//-------------------------------------------------------------------------------
void DynMode() //动态模式设置
{
Send1Telegramm(DynMode_T,0x01);
Sleep(100);
}
//-------------------------------------------------------------------------
void StartoV() //开始信号
{
Send1Telegramm(StartoV_T,0x01);
Sleep(100);
}
//---------------------------------------------------------------------------
void EndoV() //结束信号
{
Send1Telegramm(EndoV_T,0x01);
// Sleep(100);
Sleep(300);
}
//--------------------------------------------------------------------------------
void ChgParam() //改变系统参数
{
Send1Telegramm(Param_T,0x11);
Sleep(100);
}
//-----------------------------------------------------------------------------------
void ChgCLWparam() //改变CLW参数
{
Send1Telegramm(CLW_P_T,0x11);
Sleep(100);
}
//------------------------------------------------------------------------------------
void DisToSeries() //显示到图表
{
if(DAW50Gewicht!=1)
{
for(int i=99;i>1;i--)
{
Form6->data[i]=Form6->data[i-1];
}
Form6->data[0]=DAW50Gewicht;
Form6->data[1]=Form6->data[0];
Form6->Series1->Clear();
Form6->Series1->AddArray(Form6->data,99);
}
}
///--------------------------------------------------------------------------------------
void KalPunkt() //修改校准点
{
String s,num,ss;
if (ParForm->ListBox2->ItemIndex!=-1)
{
KalPunkte[ParForm->ListBox2->ItemIndex]=StrToInt(ParForm->Edit4->Text);
Send1Telegramm(KalDat_T,0x11); //更改校准点
Sleep(100);
// Send1Telegramm(KalPkt_T,0x01); //显示新的校准点
// Sleep(100);
// if (KalDat_OK)
// {
s="";
for(int i=0;i<10;i++)
{
s+="a";
s+=IntToStr(KalAnalog[i]); //连接模拟值,以'a'作分隔符
s+="a";
s+=IntToStr(KalPunkte[i]) ; //连接校准点,以'a'作分隔符
}
s+="a";
// KalDat_OK=false ;
// }
char *ch;
ch=s.c_str();
int i=0,j=0,k=0;
ParForm->ListBox2->Clear();
while(ch[i]!=0)
{
if(ch[i]=='a')
{
if(j>0)
{
if((j%2)==1)
KalAnalogStr[k]=num; //分离数据
else
{
KalPunkteStr[k]=num;
ss=KalPunkteStr[k]; //校准点字符串
ParForm->ListBox2->Items->Add(ss);
ParForm->PunkList->Items->Delete(0);
ParForm->PunkList->Items->Add(ss);
k++;
}
}
j++;
num="";
}
else
num+=ch[i];
i++;
}
}
else
{
ShowMessage("请选择要更改的校准点");
}
}
//-----------------------------------------------------------------------------
void KalDat()
{
Send1Telegramm(KalDat_T,0x11);
Sleep(100);
}
//-------------------------------------------------------------------------------------------
void disweighdata()
{
int f, fl;
int totalwei;
EndoV();
Sleep(100);
Form3->sysInfoLbl->Caption="称重正常结束";
Form3->EditAG1->Text=FzgDaten.AchsGewichte[1];
Form3->EditAG2->Text=FzgDaten.AchsGewichte[2];
Form3->EditAG3->Text=FzgDaten.AchsGewichte[3];
Form3->EditAG4->Text=FzgDaten.AchsGewichte[4];
Form3->EditAG5->Text=FzgDaten.AchsGewichte[5];
Form3->EditAG6->Text=FzgDaten.AchsGewichte[6];
Form3->speed_edit->Text=FzgDaten.Geschwindigkeit;
fl=FzgDaten.GesamtGewicht/1000;
f=(FzgDaten.GesamtGewicht%1000)/10; //保留到小数点后2位,至少一吨
if(FzgDaten.GesamtGewicht%10>=5)
f++;
if(f==10)
{
fl++;
f=0;
}
if(f==0)
Form3->Edit_total->Text=IntToStr(fl);
else
Form3->Edit_total->Text=IntToStr(fl)+"."+IntToStr(f);
Form3->EditVT->Text=FzgDaten.GesamtGewicht;
Form3->EditVO->Text=FzgDaten.GesamtGewicht-40000;
if (FzgDaten.AchsGewichte[1]==0)
Form3->EditAG1->Text="";
if (FzgDaten.AchsGewichte[2]==0)
Form3->EditAG2->Text="";
if (FzgDaten.AchsGewichte[3]==0)
Form3->EditAG3->Text="";
if (FzgDaten.AchsGewichte[4]==0)
Form3->EditAG4->Text="";
if (FzgDaten.AchsGewichte[5]==0)
Form3->EditAG5->Text="";
if (FzgDaten.AchsGewichte[6]==0)
Form3->EditAG6->Text="";
}
//--------------------------------------------------------------
void AutoLoop()
{
Send1Telegramm(Loop_T,0x02);
Sleep(100);
}
//--------------------------------------------------------------
void AutoIO()
{
Send1Telegramm(Digin_T,0x02);
Sleep(100);
}
//--------------------------------------------------------------
void Convstr(unsigned char keyVal)
{
int temp;
temp=(0xff&keyVal)/16;
switch( temp )
{
case 10:
disStr+="A";
break;
case 11:
disStr+="B";
break;
case 12:
disStr+="C";
break;
case 13:
disStr+="D";
break;
case 14:
disStr+="E";
break;
case 15:
disStr+="F";
break;
default:
disStr+=IntToStr(temp);
break;
}
temp=(0xff&keyVal)%16;
switch( temp )
{
case 10:
disStr+="A";
break;
case 11:
disStr+="B";
break;
case 12:
disStr+="C";
break;
case 13:
disStr+="D";
break;
case 14:
disStr+="E";
break;
case 15:
disStr+="F";
break;
default:
disStr+=IntToStr(temp);
break;
}
disStr+=" ";
}
//------------------------------------------------------------------------------
void ConvRecStr(unsigned char keyVal)
{
int temp;
temp=(0xff&keyVal)/16;
switch( temp )
{
case 10:
recDisStr+="A";
break;
case 11:
recDisStr+="B";
break;
case 12:
recDisStr+="C";
break;
case 13:
recDisStr+="D";
break;
case 14:
recDisStr+="E";
break;
case 15:
recDisStr+="F";
break;
default:
recDisStr+=IntToStr(temp);
break;
}
temp=(0xff&keyVal)%16;
switch( temp )
{
case 10:
recDisStr+="A";
break;
case 11:
recDisStr+="B";
break;
case 12:
recDisStr+="C";
break;
case 13:
recDisStr+="D";
break;
case 14:
recDisStr+="E";
break;
case 15:
recDisStr+="F";
break;
default:
recDisStr+=IntToStr(temp);
break;
}
recDisStr+=" ";
}
//------------------------------------------------------------------------------
void SendBuf(AnsiString buf,int lg)
{
int len,temp,temp1;
String s;
if (buf.Length()%2!=0)
MessageDlg("数据填写错误",mtError,TMsgDlgButtons() << mbOK, 0);
else
for(int i=0;i<buf.Length()/2;i++)
{
s=buf.SubString(2*i+1,2);
char *buf1=s.c_str();
temp=(buf1[0]&0xff);
if (temp==0x30)
temp1=0;
else if (temp==0x31)
temp1=1*16;
else if (temp==0x32)
temp1=2*16;
else if (temp==0x33)
temp1=3*16;
else if (temp==0x34)
temp1=4*16;
else if (temp==0x35)
temp1=5*16;
else if (temp==0x36)
temp1=6*16;
else if (temp==0x37)
temp1=7*16;
else if (temp==0x38)
temp1=8*16;
else if (temp==0x39)
temp1=9*16;
else if (temp==0x61||temp==0x41)
temp1=10*16;
else if (temp==0x62||temp==0x42)
temp1=11*16;
else if (temp==0x63||temp==0x43)
temp1=12*16;
else if (temp==0x64||temp==0x44)
temp1=13*16;
else if (temp==0x65||temp==0x45)
temp1=14*16;
else if (temp==0x66||temp==0x46)
temp1=15*16;
temp=(buf1[1]&0xff);
if (temp==0x30)
temp1+=0;
else if (temp==0x31)
temp1+=1;
else if (temp==0x32)
temp1+=2;
else if (temp==0x33)
temp1+=3;
else if (temp==0x34)
temp1+=4;
else if (temp==0x35)
temp1+=5;
else if (temp==0x36)
temp1+=6;
else if (temp==0x37)
temp1+=7;
else if (temp==0x38)
temp1+=8;
else if (temp==0x39)
temp1+=9;
else if (temp==0x61||temp==0x41)
temp1+=10;
else if (temp==0x62||temp==0x42)
temp1+=11;
else if (temp==0x63||temp==0x43)
temp1+=12;
else if (temp==0x64||temp==0x44)
temp1+=13;
else if (temp==0x65||temp==0x45)
temp1+=14;
else if (temp==0x66||temp==0x46)
temp1+=15;
Send1Telegramm(MyFigure_T,temp1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -