線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1802
推到 Plurk!
推到 Facebook!

傳輸有問題

尚未結案
b09101015
一般會員


發表:4
回覆:11
積分:3
註冊:2011-01-21

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-01-26 10:36:52 IP:114.33.xxx.xxx 訂閱


[code cpp]
//Edit_ID->Text = 123;
unsigned char i,common[12];
double f=0.0,weight=0.0,Fat=0.0,Fatmass=0.0,FFM=0.0;
double TBW=0.0,BMI=0.0;
unsigned char body=0,sex=0,height=0,age=0;
unsigned char index=0,index1=0;
long int a=0,impedance=0,BMR=0;
char *buf=(char*)Buffer;
char filename[80];
sprintf(filename, "measure_data\\%s_measure.txt", Edit_ID->Text.c_str());
FILE *output=fopen(filename,"a "); // 第1個參數是檔名, 第2個參數是開啟檔案的模式, w代write, t代text
fprintf( output, "%s_%s\n",Label_date->Caption.c_str(),buf);
while(0 == fclose(output));
//String x;
a = 0;
for(i=0;i<255;i )
{
if(buf[i] == 0x0A)
{
buf[i] = 0x00;
}
if(buf[i] == 0x0D)
{
buf[i] = '/';
}
if(buf[i] == 0x2C || buf[i] == 0x5C || buf[i] == '/')
{
common[a] = i;
a ;
}
}

麻煩大家幫忙一下了
在執行多次RS232傳輸後就會出現如附件中的訊息
然後就停在

fprintf( output, "%s_%s\n",Label_date->Caption.c_str(),buf);

這一段

第12行那邊

可以麻煩大家幫我看看嗎 謝謝

/* 體型 */
body = StrToInt(buf[0]);
if(body) //Athletic
{
//BodyGroup->ItemIndex = 1;
Image_Body_normal->Visible = false;
Image_Body_Ath->Visible = true;
}
else //normal
{
//BodyGroup->ItemIndex = 0;
Image_Body_normal->Visible = true;
Image_Body_Ath->Visible = false;
}

/* 性別 */
sex = StrToInt(buf[2]);
if(sex) //man
{
Image_Sex_Woman->Visible = false;
Image_Sex_Man->Visible = true;
}
else //female
{
//SexGroup->ItemIndex = 1;
Image_Sex_Woman->Visible = true;
Image_Sex_Man->Visible = false;
}

/* 身高 */
index = common[1];
index1 = common[2];
a = 100;
height = 0;
for(i = index 1 ; i {
height = a*StrToInt(buf[i]);
a = a/10;
}
Edit_height->Text = height;

/* 體重 */
index = common[2];
index1 = common[3];
weight = 0.0;
if((index1-index) == 6)
f = 100.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
weight = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_weight->Text = FloatToStrF( weight , ffFixed , 7 , 1 );
Series1->AddY(weight);

/* 阻抗 */
index = common[3];
index1 = common[4];
impedance = 0.0;
if((index1-index) == 4)
a = 100;
else if((index1-index) == 5)
a = 1000;
else
a = 10;
for(i = index 1 ; i {
impedance = a*StrToInt(buf[i]);
a = a/10;
}
Edit_imp->Text = impedance;
Series2->AddY(impedance);

/* 體脂肪率 */
index = common[4];
index1 = common[5];
Fat = 0.0;
if((index1-index) == 4)
f = 1.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
Fat = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_Fat->Text = FloatToStrF( Fat , ffFixed , 7 , 1 );
Series10->AddY(Fat);

/* 體脂肪體積 */
index = common[5];
index1 = common[6];
Fatmass = 0.0;
if((index1-index) == 4)
f = 1.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
Fatmass = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_Fatmass->Text = FloatToStrF( Fatmass , ffFixed , 7 , 1 );
Series6->AddY(Fatmass);

/* FFM */
index = common[6];
index1 = common[7];
FFM = 0.0;
if((index1-index) == 4)
f = 1.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
FFM = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_FFM->Text = FloatToStrF( FFM , ffFixed , 7 , 1 );
Series7->AddY(FFM);

/* TBW */
index = common[7];
index1 = common[8];
TBW = 0.0;
if((index1-index) == 4)
f = 1.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
TBW = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_TBW->Text = FloatToStrF( TBW , ffFixed , 7 , 1 );
Series8->AddY(TBW);

/* 年齡 */
index = common[8];
index1 = common[9];
age = 0;
if((index1-index) == 3)
a = 10;
else
a = 1;
for(i = index 1 ; i {
age = a*StrToInt(buf[i]);
a = a/10;
}
Edit_age->Text = age;

/* BMI */
index = common[9];
index1 = common[10];
BMI = 0.0;
if((index1-index) == 4)
f = 1.0;
else
f = 10.0;
for(i = index 1 ; i {
if(i != (index1-2))
{
BMI = f*StrToInt(buf[i]);
f = f/10.0;
}
}
Edit_BMI->Text = FloatToStrF( BMI , ffFixed , 7 , 1 );
Series9->AddY(BMI);

/* BMR */
index = common[10];
index1 = common[11];
//Edit3->Text
BMR = 0;
if((index1-index) == 4)
a = 100;
else if((index1-index) == 5)
a = 1000;
else
a = 10;
for(i = index 1 ; i {
BMR = a*StrToInt(buf[i]);
a = a/10;
}

Edit_BMR->Text = BMR;
Series4->AddY(BMR);

AnsiString temp;
//sprintf(dd, "%s.txt", Edit_ID->Text.c_str());
temp = AnsiString(Label_date->Caption.c_str());
temp = "_";
temp = AnsiString(buf);
//Memo1->Lines->Add(Label_date->Caption);
//Memo1->Lines->Add(" ");
//Memo1->Lines->Text = buf;
Memo1->Lines->Add(temp);
while(Memo1->Lines->Count >= StrToInt(Edit4->Text) 1)
{
//Edit_age->Text = "123";
Memo1->Lines->Delete(0);
LineOver = 1;
//Memo1->Lines->LoadFromFile(filename);
}

//FILE *output; // 用來指向一個輸出的位置
if(ID_change || Start)
{
Start = 0;
ID_change = 0;
sprintf(filename, "patient_data\\%s_patient.txt", Edit_ID->Text.c_str());
output=fopen(filename,"wt"); // 第1個參數是檔名, 第2個參數是開啟檔案的模式, w代write, t代text
fprintf( output, "%s,%s\n",Edit_name->Text,Edit_patient->Text.c_str() );
while(0 == fclose(output));
}


if(LineOver)
{
sprintf(filename, "measure_data\\%s_measure.txt", Edit_ID->Text.c_str());
output=fopen(filename,"wt"); // 第1個參數是檔名, 第2個參數是開啟檔案的模式, w代write, t代text
for(i=0;iLines->Count;i )
{
fprintf( output, "",Memo1->Lines->Strings[i].c_str());
}
while(0 == fclose(output));
output=fopen(filename,"a "); // 第1個參數是檔名, 第2個參數是開啟檔案的模式, w代write, t代text
for(i=0;iLines->Count;i )
{
fprintf( output, "%s\n",Memo1->Lines->Strings[i].c_str() );
}
while(0 == fclose(output));
Memo1->Lines->LoadFromFile(filename);
LineOver = 0;
}


Timer2->Enabled = false;
Timer2->Enabled = true;

if(CheckBox1->Checked == false)
Series1->Clear();
else
{
CheckBox1->Checked = false;
CheckBox1->Checked = true;
}
if(CheckBox2->Checked == false)
Series2->Clear();
else
{
CheckBox2->Checked = false;
CheckBox2->Checked = true;
}
if(CheckBox3->Checked == false)
Series9->Clear();
else
{
CheckBox3->Checked = false;
CheckBox3->Checked = true;
}
if(CheckBox4->Checked == false)
Series4->Clear();
else
{
CheckBox4->Checked = false;
CheckBox4->Checked = true;
}
if(CheckBox5->Checked == false)
Series10->Clear();
else
{
CheckBox5->Checked = false;
CheckBox5->Checked = true;
}
if(CheckBox6->Checked == false)
Series6->Clear();
else
{
CheckBox6->Checked = false;
CheckBox6->Checked = true;
}
if(CheckBox7->Checked == false)
Series7->Clear();
else
{
CheckBox7->Checked = false;
CheckBox7->Checked = true;
}
if(CheckBox8->Checked == false)
Series8->Clear();

else
{
CheckBox8->Checked = false;
CheckBox8->Checked = true;
}
if(close)
{Close();}

}
[/code]


系統時間:2024-04-26 3:38:59
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!