C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[42018] 볼랜드 c++ 프로젝트 -- > VC 로 변환...
볼랜드초보 [] 1132 읽음    2005-09-27 14:30
아직 프로그래밍 초보입니다..

볼랜드를 이번에 처음 접해보았습니다..

볼랜드 c++빌더 프로젝트를 Visual c++ 환경으로 변환을 해야 하는 상황인데요 ...


컴포넌트가 소스 전반에 걸쳐있고 상당히 코드가 컴포넌트 의존적이라는 생각이 들어서
쉽지가 않아 보이네요... vcl.h <-- 이 헤더파일 관련하는 부분을 어찌해야 할지...


경험있으신 분들의 조언 부탁드리겠습니다...

이 프로젝트는 pci카드를 제어하고 어플리케이션까지 구동시키는 프로젝트입니다...


참고로 main.cpp 파일이 다음과 같습니다...



//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <winioctl.h>
#include "Main.h"
#include "Interrupt.h"
#include "HardwareSetup.h"
#include "StatusThread.h"
#include "BufferThread.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TMainForm *MainForm;
TInterruptThread *pInterruptThread=NULL;
TBufferThread *pBufferThread=NULL;
TStatusDisplayThread *pStatusDisplayThread=NULL;
HANDLE hDMAWriteCompleteEvent;
HANDLE hDMAReadCompleteEvent;
HANDLE hHiThreshIntEvent;
HANDLE hStatus_Display_Event ;
HANDLE hBufferGoEvent;

extern HANDLE hWinRTInt;
extern HANDLE hWinRTStat;
extern HANDLE hWinRTBuff;
extern int buffsize;//dma buffer size from AMCC
extern WINRT_DMA_BUFFER_INFORMATION  DmaBufferInfo; //DMA buffer information
String RecordFileNameA="SampleA.r2d";
String RecordFileNameB="SampleB.r2d";
//---------------------------------------------------------------------------
__fastcall TMainForm::TMainForm(TComponent* Owner)
  : TForm(Owner)
{
}
//--------------------------------------------------------------------
void __fastcall TMainForm::OpenBtnClick(TObject *Sender)
{
DWORD status;
static bool OpenCard;
OpenCard=!OpenCard;
if(OpenCard)
  {
  OpenPciAmcc();
  ResetAmcc();
  InitialiseCard();
  OpenBtn->Caption="Close";
  DriverOpen=true;
  hDMAWriteCompleteEvent = CreateEvent(NULL, true, false, NULL);
  hDMAReadCompleteEvent = CreateEvent(NULL, true, false, NULL);
  hStatus_Display_Event = CreateEvent(NULL, true, false, NULL);
  hBufferGoEvent= CreateEvent(NULL, true, false, NULL);
  hHiThreshIntEvent= CreateEvent(NULL, true, false, NULL);
  if(pInterruptThread==NULL)
    {
    pInterruptThread=new TInterruptThread(true,hWinRTInt);
    pInterruptThread->Priority=tpTimeCritical;
    }
  pInterruptThread->Resume();
  if(pStatusDisplayThread==NULL)
    {
    pStatusDisplayThread=new TStatusDisplayThread();
    pStatusDisplayThread->Priority=tpLowest;
    }
  pStatusDisplayThread->Resume();

  Write1->Enabled=true;
  Status1->Enabled=true;
  Controls1->Enabled=true;
  }
  else
  {
  if(Write1->Checked)
    Write1Click(MainForm);
  OpenBtn->Caption="Open";
  LabelError->Caption="No error";
  LabelMessage->Caption="No message";
  pInterruptThread->Terminate();
  pInterruptThread=NULL;
  pStatusDisplayThread->Terminate();
  pStatusDisplayThread=NULL;

  CloseHandle(hDMAWriteCompleteEvent);
  CloseHandle(hDMAReadCompleteEvent);
  CloseHandle(hStatus_Display_Event);
  CloseHandle(hBufferGoEvent);
  CloseHandle(hHiThreshIntEvent);
  DriverOpen=false;
  Write1->Enabled=false;
  Controls1->Enabled=false;
  Status1->Enabled=false;

  ClosePciAmcc();
  ListBox1->Clear();
  ListBox2->Clear();
  }

}
//------------------------------------------------------------------------
void TMainForm::InitialiseCard(void)
{
gCommand2&=~STRA_START&~STRA_UNFRAMED&~STRA_INTCLK&~STRA_E2E;
gCommand2|=STRA_FIFO_RESET;
gCommand2&=~STRA_OP_INHIBIT&~STRA_LOZ;
gCommand2&=~STRB_START&~STRB_UNFRAMED&~STRB_INTCLK&~STRB_E2E;
gCommand2|=STRB_FIFO_RESET;
gCommand2&=~STRB_OP_INHIBIT&~STRB_LOZ;
WriteMailBox1(OMB2, gCommand2);
ControlsForm->TrackBar1A->Position=32;// initial positions for thresholds
ControlsForm->TrackBar2A->Position=32;
ControlsForm->TrackBar1AExit(MainForm);
ControlsForm->TrackBar1B->Position=32;// initial positions for thresholds
ControlsForm->TrackBar2B->Position=32;
ControlsForm->TrackBar1BExit(MainForm);
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::Status1Click(TObject *Sender)
{
Status1->Checked=!Status1->Checked;
if(Status1->Checked)
  StatusForm->Show();
else
  StatusForm->Close();

}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Controls1Click(TObject *Sender)
{
Controls1->Checked=!Controls1->Checked;
if(Controls1->Checked)
  ControlsForm->Show();
else
  ControlsForm->Close();

}
//---------------------------------------------------------------------------


void __fastcall TMainForm::Write1Click(TObject *Sender)
{
int PBufPage;
DWORD Wait;
Write1->Checked=!Write1->Checked;
if(Write1->Checked)
  {
  RecFileNameA=ExtractFilePath(Application->ExeName)+ RecordFileNameA;
  RecFileStreamA = new TFileStream(RecFileNameA, fmCreate);//always overwrite
  RecFileNameB=ExtractFilePath(Application->ExeName)+ RecordFileNameB;
  RecFileStreamB = new TFileStream(RecFileNameB, fmCreate);//always overwrite

  MainForm->LabelMessage->Caption="No Message";
  MainForm->LabelError->Caption="No Error";
  //  stopcard
  MainForm->gCommand2&=~STRA_START&~STRB_START;
  //reset main memory buffers
  MainForm->gCommand2|=STRA_FIFO_RESET|STRB_FIFO_RESET;
  //set card streams to record mode
  MainForm->gCommand2|=STRA_RECORD|STRB_RECORD;
  //send the command to Outgoing mailbox 2
  WriteMailBox1(OMB2, MainForm->gCommand2);
  //reset the cache fifo
  MainForm->gCommand1|=XFIFO_RESET;
  WriteMailBox1(OMB1, MainForm->gCommand1);
  //set up the card interrupts
  MainForm->gCommand1|=INT_EN_THRESH_STRA;
  MainForm->gCommand1|=INT_EN_THRESH_STRB;
  MainForm->gCommand1|=INT_EN_THRESH_HI|INT_EN_COMMAND;
  WriteMailBox1(OMB1, MainForm->gCommand1);
  //disable the card interrupt enable to confirm the interrupt selection
  MainForm->gCommand1&=~INT_EN_COMMAND;
  WriteMailBox1(OMB1, MainForm->gCommand1);
  //set up the AMCC interrupt control status register
  gInterruptCommand|= S5933_INTCSR_WRITE_INTERRUPT;//dma transfer
  gInterruptCommand|=S5933_INTCSR_IN_MAILBOX_4|S5933_INTCSR_IN_BYTE_4|S5933_INTCSR_INCOMING_INTERRUPT;
  EnableAmccInterrupts(gInterruptCommand);
   //lift the card buffer resets
  MainForm->gCommand2&=~STRA_FIFO_RESET;
  MainForm->gCommand2&=~STRB_FIFO_RESET;
  WriteMailBox1(OMB2, MainForm->gCommand2);
  MainForm->gCommand1&=~XFIFO_RESET;
  WriteMailBox1(OMB1, MainForm->gCommand1);
  ResetEvent(hHiThreshIntEvent);//initial condition

  header_write1(RecFileStreamA);
  header_write1(RecFileStreamB);
  //set card to active, allow replay to start
  MainForm->gCommand2|=STRA_START;
  MainForm->gCommand2|= STRB_START;
  WriteMailBox1(OMB2, MainForm->gCommand2);

  if(pBufferThread==NULL)
    pBufferThread=new TBufferThread(true,hWinRTBuff);
  pBufferThread->Resume();

  Write=true;
  SetEvent(hBufferGoEvent);
  Timer1->Interval=60000;
  Timer1->Enabled=true;
  }
else
  {
  //stop buffer thread
  pBufferThread->Terminate();
  pBufferThread->WaitFor();
  pBufferThread=NULL;
  Write=false;
  Timer1->Enabled=false;
  ResetEvent(hBufferGoEvent);

  //stop interrupts
  gInterruptCommand&=~ S5933_INTCSR_WRITE_INTERRUPT;
  gInterruptCommand&=~ S5933_INTCSR_INCOMING_INTERRUPT;
  EnableAmccInterrupts(gInterruptCommand);
  MainForm->gCommand1|=INT_EN_COMMAND;
  MainForm->gCommand1&=~INT_EN_THRESH_HI&~INT_EN_THRESH_STRA&~INT_EN_THRESH_STRB;//&~STRA_DATA_REQ ;
  WriteMailBox1(OMB1, MainForm->gCommand1);
  MainForm->gCommand1&=~INT_EN_COMMAND;
  WriteMailBox1(OMB1, MainForm->gCommand1);

  MainForm->gCommand2&=~STRA_START&~STRB_START;
  MainForm->gCommand2|=STRA_FIFO_RESET|STRB_FIFO_RESET;
  WriteMailBox1(OMB2, MainForm->gCommand2);
  SetEvent(hHiThreshIntEvent);//frees waiting thread
  if(RecFileStreamA)
    delete RecFileStreamA;
  if(RecFileStreamB)
  delete RecFileStreamB;
  }
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
{
//turn off write  if selected
if(Write1->Checked)
  Write1Click(MainForm);
}
//---------------------------------------------------------------------------

void __fastcall TMainForm::Timer1Timer(TObject *Sender)
{
Write1Click(Timer1);
}
//---------------------------------------------------------------------------
void TMainForm::header_write1(TFileStream *Stream)
{
//header consists of record status(32bytes),start time, & cursor position 4 bytes
//contains information to ensure compatibility with R2D files
int n;
SYSTEMTIME st;
FILETIME filtim1;
short RecordStatus=1;
unsigned char Space=0x20;
int HeaderPos=0;
Stream->Seek(HeaderPos,soFromBeginning);
for(n=0;n<32;n++)//force record status to be all ones
  Stream->Write(&RecordStatus,1);
for(n=0;n<32;n++)
Stream->Write(&Space,1);
GetLocalTime(&st);//write file start time at pos 64
SystemTimeToFileTime(&st,&filtim1);
Stream->Write((char*)&filtim1,sizeof(FILETIME));
HeaderPos=Stream->Seek(0,soFromCurrent);
for (n=HeaderPos;n<1024;n++)
  Stream->Write(&Space,1);
}
//--------------------------------------------------------------

+ -

관련 글 리스트
42018 볼랜드 c++ 프로젝트 -- > VC 로 변환... 볼랜드초보 1132 2005/09/27
42027     Re:볼랜드 c++ 프로젝트 -- > VC 로 변환... 아제나 1461 2005/09/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.