Создание редактора входных воздействий цифровых сигналов для САПР OrCad 9.1, страница 9

//---------------------------------------------------------------------------

void __fastcall TStmForm::SigPropClick(TObject *Sender)

{

  int s_res_x=StmForm->Width;

  double koef_x=(double)s_res_x/(double)r_res_x;

  double _x=offset+CUR_X/koef_x;

  int __x=_x;

  char *name=new char[100],*c;

  char *name2=new char[100];

  char *val=new char[3];

  int dim,ff,start_time;

  name=signals[cur_sig].GetName();

  strcpy(name2,name);

  strcat(name2,".");

  c=name;

  c+=strlen(name)+1;

  strcat(name2,c);

  dim=signals[cur_sig].GetDimension();

  ff=signals[cur_sig].GetFFAtTime(__x);

  signals[cur_sig].GetOneFF(ff,&start_time,val);

  val=signals[cur_sig].GetValAtTime(__x);

  PropForm->ValEd->Text=val;

  PropForm->SwitchEd->Text=IntToStr(ff);

  PropForm->DurationEd->Text=IntToStr(start_time)+" ns"; 

  PropForm->SigNameEd->Text=name2;

  if (dim==1)

    PropForm->SigTypeEd->Text="Basic signal";

  if (dim==2)

    PropForm->SigTypeEd->Text="Bus signal";

  if (dim==3)

    PropForm->SigTypeEd->Text="Clock signal";

  PropForm->ShowModal();

  delete name,name2,val;

  DrawMnuClick(NULL);

}

//---------------------------------------------------------------------------

void __fastcall TStmForm::SaveBtnClick(TObject *Sender)

{

  FILE *f;

  if (opened)

  {

    f=fopen(SaveDlg->FileName.c_str(),"wb+");

    SaveAll(f);

    fclose(f);

  }

}

//---------------------------------------------------------------------------

start.h

//---------------------------------------------------------------------------

#ifndef startH

#define startH

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

//---------------------------------------------------------------------------

class TStartForm : public TForm

{

__published:  // IDE-managed Components

        TButton *NewStimBtn;

        TButton *EditStimBtn;

        TButton *ModelBtn;

        void __fastcall NewStimBtnClick(TObject *Sender);

        void __fastcall EditStimBtnClick(TObject *Sender);

        void __fastcall ModelBtnClick(TObject *Sender);

private:   // User declarations

public:           // User declarations

        char * __fastcall TStartForm::NewCmdLine(char *pname);

        __fastcall TStartForm(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TStartForm *StartForm;

//---------------------------------------------------------------------------

#endif

start.cpp

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "start.h"

#include "main.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TStartForm *StartForm;

char project[100];

char exename[255];

char *bf=new char[300];

//---------------------------------------------------------------------------

__fastcall TStartForm::TStartForm(TComponent* Owner)

        : TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TStartForm::NewStimBtnClick(TObject *Sender)

{

  StmForm->Show();

}

//---------------------------------------------------------------------------

void __fastcall TStartForm::EditStimBtnClick(TObject *Sender)

{

  StmForm->Show();

  StmForm->OpenFileMenuClick(NULL);

}

//---------------------------------------------------------------------------

char * __fastcall TStartForm::NewCmdLine(char *pname)

{

  int i,k;

  char buf2[300]={0,0,0,0,0,0,0,0,0,0},*p;

  for(i=0;i<strlen(bf);i++)

    if(bf[i]=='e'&&bf[i+1]=='x'&&bf[i+2]=='e') break;

  p=&bf[i+5];

  return p;

}

//-----------------------------------------------

void __fastcall TStartForm::ModelBtnClick(TObject *Sender)

{

  FILE *fin=fopen("c:\\stimed.dat","rt+");

  fgets(exename,255,fin);

  exename[strlen(exename)-1]=0;

  fclose(fin);

  char *p=new char[250],*proj,*cmdl;

  p=GetCommandLine();

  if (strlen(p)<60)

  {

    ShellExecute(Application->Handle,"open",exename,"","",SW_MAXIMIZE);

  }else{

  strcpy(bf,p);

  cmdl=NewCmdLine(bf);

  ShellExecute(Application->Handle,"open",exename,cmdl,"",SW_MAXIMIZE);

//  ShellExecute(Application->Handle,"open","simulate.exe",cmdl,"",SW_MAXIMIZE);

  delete p;}

  Application->Terminate();

}

//---------------------------------------------------------------------------

prop.h

//---------------------------------------------------------------------------

#ifndef propH

#define propH

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

//---------------------------------------------------------------------------

class TPropForm : public TForm

{

__published:  // IDE-managed Components

        TLabel *Label1;

        TLabel *Label2;

        TLabel *Label3;

        TLabel *Label4;

        TEdit *SigNameEd;

        TEdit *SigTypeEd;

        TEdit *DurationEd;

        TEdit *ValEd;

        TButton *OkBtn;

        TLabel *Label5;

        TEdit *SwitchEd;

        void __fastcall OkBtnClick(TObject *Sender);

private:   // User declarations

public:           // User declarations

        __fastcall TPropForm(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TPropForm *PropForm;

//---------------------------------------------------------------------------

#endif

prop.cpp

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "prop.h"

#include "main.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)