{
for (i=0;i<this->num_ff;i++)
{
fwrite(&type,sizeof(char),1,f);
fwrite(&czero,sizeof(char),1,f);
if (v[i][0]=='0') type_basic=0x2;
if (v[i][0]=='1') type_basic=0x3;
if (v[i][0]=='Z') type_basic=0x4;
if (v[i][0]=='L') type_basic=0x6;
fwrite(&type_basic,sizeof(char),1,f);
fwrite(&czero,sizeof(char),1,f);
fwrite(&czero,sizeof(char),1,f);
fwrite(&czero,sizeof(char),1,f);
time_ff=times[i];
fwrite(&time_ff,sizeof(long),1,f);
fwrite(&zero,sizeof(long),1,f);
var=0x1;
fwrite(&var,sizeof(char),1,f);
fwrite(&v[i][0],sizeof(char),1,f);
}
}
if (this->dim==2)
{
for (i=0;i<this->num_ff;i++)
{
fwrite(&type,sizeof(char),1,f);
fwrite(&czero,sizeof(char),1,f);
fwrite(&maxlong,sizeof(long),1,f);
time_ff=times[i];
fwrite(&time_ff,sizeof(long),1,f);
fwrite(&zero,sizeof(long),1,f);
var=strlen(v[i]);
fwrite(&var,sizeof(char),1,f);
fwrite(v[i],sizeof(char),var,f);
}
}
}
}
//------------------------------------------------
int signal::GetDimension() //Считать разрядность сигнала
{
return this->dim;
}
//------------------------------------------------------
int signal::GetNumFF() //Считать кол-во переключений сигнала
{
return this->num_ff;
}
//-------------------------------------------------
void signal::GetOneFF(int index, int *_time, char *val) //Считать информацию о переключении
{
if (index<N)
{
*_time=this->times[index];
int i;
strcpy(val,v[index]);
}
}
//-------------------------------------------------
signal::signal() //конструктор
{
SetSignalInfo(0,0,"");
}
//----------------------------------------------
void __fastcall TStmForm::LoadFromFile(char *fname)
{
FILE *f=fopen(fname,"rb+");
fseek(f,8l,SEEK_SET);
fread(&num_signals,sizeof(char),1,f);
read_signal_info(f);
fclose(f);
}
//---------------------------------------------------------------------------
__fastcall TStmForm::TStmForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::OpenFileMenuClick(TObject *Sender)
{
if (OpDlg->Execute())
{
LoadFromFile(OpDlg->FileName.c_str());
SBar->Panels->Items[1]->Text="Filename : "+OpDlg->FileName;
opened=1;
}
DrawMnuClick(NULL);
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::ExitMenuClick(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TStmForm::AddSignal(int type)
{
if (type==1)
{
strcpy(schname,NewBasicForm->NameEd->Text.c_str());
int time=StrToInt(NewBasicForm->StartTimeEd->Text);
char *val=new char[2];
char *name=new char[100];
strcpy(val,NewBasicForm->ValCB->Items->Strings[NewBasicForm->ValCB->ItemIndex].c_str());
strcpy(name,NewBasicForm->NameEd->Text.c_str());
signals[num_signals].SetSignalInfo(1,1,name);
signals[num_signals].SetOneFF(0,time,val);
num_signals+=1;
delete val;
delete name;
}
if (type==2)
{
strcpy(schname,NewBusform->NameEd->Text.c_str());
int time=StrToInt(NewBusform->StartTimeEd->Text);
char *val=new char[10];
char *name=new char[100];
strcpy(val,NewBusform->InitValEd->Text.c_str());
strcpy(name,NewBusform->NameEd->Text.c_str());
signals[num_signals].SetSignalInfo(1,2,name);
signals[num_signals].SetOneFF(0,time,val);
num_signals+=1;
delete val;
delete name;
}
if (type==3)
{
strcpy(schname,NewClockForm->NameEd->Text.c_str());
int time1=StrToInt(NewClockForm->T1Ed->Text);
int time2=StrToInt(NewClockForm->T2Ed->Text);
char *val1=new char[2];
char *val2=new char[2];
char *name=new char[100];
strcpy(val1,NewClockForm->ValCB1->Items->Strings[NewClockForm->ValCB1->ItemIndex].c_str());
strcpy(val2,NewClockForm->ValCB2->Items->Strings[NewClockForm->ValCB2->ItemIndex].c_str());
strcpy(name,NewClockForm->NameEd->Text.c_str());
signals[num_signals].SetSignalInfo(2,3,name);
signals[num_signals].SetOneFF(0,time1,val1);
signals[num_signals].SetOneFF(1,time2,val2);
num_signals+=1;
delete val1,val2;
delete name;
}
DrawMnuClick(NULL);
}
//------------------------------------------------------------
void __fastcall TStmForm::ChangeBusVal(char *val,int ff)
{
char tmp[10];
int time;
int Dim=signals[cur_sig].GetDimension();
if(Dim==2)
{
signals[cur_sig].GetOneFF(ff,&time,tmp);
signals[cur_sig].SetOneFF(ff,time,val);
}
}
//------------------------------------------------------------
void __fastcall TStmForm::DrawMnuClick(TObject *Sender)
{
int i,j,x,y1,y2;
int s_res_x=StmForm->Width,s_res_y=StmForm->Height;
int n_signals=10;
double koef_x=(double)s_res_x/(double)r_res_x;//koef_y=s_res_y/n_signals;
char val1[10],val2[10],*val = new char [100];
int time1,time2,global_y=-25,dimension,len;
int y_high=global_y,y_low=global_y+20,y=global_y;
StmForm->Canvas->Brush->Color=clBlack;
StmForm->Canvas->Pen->Color=clLime;
StmForm->Canvas->FillRect(Rect(0,0,StmForm->Width,StmForm->Height));
//Сетка
StmForm->Canvas->Pen->Width=1;
StmForm->Canvas->Pen->Color=clGray;
Canvas->Font->Color=clLtGray;
Canvas->Font->Size=10;
int step=r_res_x/NUM_LINES;
for (i=0,x=0;i<(offset+r_res_x)/NUM_LINES;i++)
{
StmForm->Canvas->MoveTo(OFFS_X+x*koef_x-offset*koef_x,StmForm->Height-100);
StmForm->Canvas->LineTo(OFFS_X+x*koef_x-offset*koef_x,0);
StmForm->Canvas->TextOut(OFFS_X+x*koef_x-offset*koef_x-10,StmForm->Height-90,IntToStr(x)+"ns");
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.