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

#pragma resource "*.dfm"

TPropForm *PropForm;

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

__fastcall TPropForm::TPropForm(TComponent* Owner)

        : TForm(Owner)

{

}

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

void __fastcall TPropForm::OkBtnClick(TObject *Sender)

{

  StmForm->ChangeBusVal(ValEd->Text.c_str(),StrToInt(SwitchEd->Text));

  Close();       

}

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

newsig.h

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

#ifndef newsigH

#define newsigH

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

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <Buttons.hpp>

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

class TNewStimForm : public TForm

{

__published:  // IDE-managed Components

        TGroupBox *GroupBox1;

        TRadioButton *BasicRB;

        TRadioButton *ClockRB;

        TRadioButton *BusRB;

        TSpeedButton *OKBtn;

        TSpeedButton *CancelBtn;

        void __fastcall CancelBtnClick(TObject *Sender);

        void __fastcall OKBtnClick(TObject *Sender);

private:   // User declarations

public:           // User declarations

        __fastcall TNewStimForm(TComponent* Owner);

};

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

extern PACKAGE TNewStimForm *NewStimForm;

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

#endif

newsig.cpp

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

#include <vcl.h>

#pragma hdrstop

#include "newsig.h"

#include "newbasic.h"

#include "newbus.h"

#include "newclock.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TNewStimForm *NewStimForm;

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

__fastcall TNewStimForm::TNewStimForm(TComponent* Owner)

        : TForm(Owner)

{

}

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

void __fastcall TNewStimForm::CancelBtnClick(TObject *Sender)

{

  Close();       

}

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

void __fastcall TNewStimForm::OKBtnClick(TObject *Sender)

{

  if (BasicRB->Checked)

    NewBasicForm->ShowModal();

  if (ClockRB->Checked)

    NewClockForm->ShowModal();

  if (BusRB->Checked)

    NewBusform->ShowModal();

}

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

newbasic.h

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

#ifndef newbasicH

#define newbasicH

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

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <Buttons.hpp>

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

class TNewBasicForm : public TForm

{

__published:  // IDE-managed Components

        TEdit *NameEd;

        TEdit *StartTimeEd;

        TLabel *Label1;

        TComboBox *ValCB;

        TLabel *Label2;

        TLabel *Label3;

        TLabel *Label4;

        TSpeedButton *OKBtn;

        void __fastcall OKBtnClick(TObject *Sender);

        void __fastcall FormActivate(TObject *Sender);

private:   // User declarations

public:           // User declarations

        void __fastcall err(int error);

        __fastcall TNewBasicForm(TComponent* Owner);

};

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

extern PACKAGE TNewBasicForm *NewBasicForm;

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

#endif

newbasic.cpp

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

#include <vcl.h>

#pragma hdrstop

#include "newbasic.h"

#include "newsig.h"

#include "main.h"

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

#pragma package(smart_init)

#pragma resource "*.dfm"

TNewBasicForm *NewBasicForm;

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

__fastcall TNewBasicForm::TNewBasicForm(TComponent* Owner)

        : TForm(Owner)

{

}

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

void __fastcall TNewBasicForm::err(int error)

{

  switch (error)

  {

    case 1: MessageBox(NULL,"Signal name must contain dot,ex. SCHEMATIC1.INPUT","Error",MB_OK|MB_ICONWARNING);

           break;

    case 2: MessageBox(NULL,"Time must contain only digits, ex. 123","Error",MB_OK|MB_ICONWARNING);

           break;

    case 3: MessageBox(NULL,"Init value must contain only digits, ex. 123","Error",MB_OK|MB_ICONWARNING);

           break;

    default:MessageBox(NULL,"Unexpected error","Error",MB_OK|MB_ICONWARNING);

  };

}

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

void __fastcall TNewBasicForm::OKBtnClick(TObject *Sender)

{

  int error=0;

  if(NameEd->Text.AnsiPos(".")==0)

    error=1;

  try

  {

    StartTimeEd->Text.ToInt();

  }

  catch(const Exception &E)

  {

    error=2;

  }

  if (!error)

  {

    StmForm->AddSignal(1);

    Close();

  }

  else

    err(error);

}

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

void __fastcall TNewBasicForm::FormActivate(TObject *Sender)

{

  NewStimForm->Close();       

}

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

newbus.h

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

#ifndef newbusH

#define newbusH

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

#include <Classes.hpp>