Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341845
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:03:55

环境BCB6,程序编译通过,但OnCommNotify事件却不执行,老大帮忙看看吧!!先谢过了!!
#include
#pragma hdrstop

#include "Main.h"
#include "Unit2.h"
#include "SetData.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "YBComm32"
#pragma link "YbCommDevice"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N10Click(TObject *Sender)
{
    Application->Terminate();       // 程序运行结束
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    Form1->Memo1->Lines->Clear();   // 清除输出框
    ComboBox1->Clear();
    ComboBox2->Clear();

    Baudrate    =   2400;
    NewBaud = TYbCommDevice::br2400;
    Com_port    =   1;
    D_time      =   1;          // 1 秒
    U_meter     =   1;
    U_comm      =   1;          // 初始化
    Rxd_cnt =   0;
    Txd_cnt =   0;          //  计数器清零
    AppCfg.Load(YbCommDevice1); //如果配置文件存在,从配置文件载入信息
    Form1->StatusBar1->Panels->Items[0]->Text=IntToStr(Baudrate)+"bps ";
    Form1->StatusBar2->Panels->Items[0]->Text="Com: "+IntToStr(Com_port);
    Form1->StatusBar3->Panels->Items[0]->Text="Tx: "+IntToStr(Txd_cnt);
    Form1->StatusBar4->Panels->Items[0]->Text="Rx: "+IntToStr(Rxd_cnt);
    Form1->Edit1->Text = D_time;

    ComboBox1->ItemIndex = U_meter;
    ComboBox2->ItemIndex = U_comm;

    switch(Baudrate)
    {
        case 1200:NewBaud = TYbCommDevice::br1200;break;
        case 2400:NewBaud = TYbCommDevice::br2400;break;
        case 4800:NewBaud = TYbCommDevice::br4800;break;
        case 9600:NewBaud = TYbCommDevice::br9600;break;
        case 19200:NewBaud = TYbCommDevice::br19200;break;
        case 38400:NewBaud = TYbCommDevice::br38400;break;
        case 57600:NewBaud = TYbCommDevice::br57600;break;
        case 115200:NewBaud = TYbCommDevice::br115200;break;
        default:NewBaud = TYbCommDevice::br2400;break;
    }
    Comm_active();      // 端口操作
}
//---------------------------------------------------------------------------


void __fastcall TForm1::YbCommDevice1CommNotify(TObject *Sender,int NotifyType)
{
 if(NotifyType==EV_RXCHAR)
   {
    Rxd_cnt++;
    }
}


--------------------next---------------------
#ifndef MainH
#define MainH
//---------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include "YBComm32.h"
#include "YbCommDevice.h"
#include
#include
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
        TComboBox *ComboBox1;
        TGroupBox *GroupBox1;
        TButton *Button1;
        TButton *Button2;
        TGroupBox *GroupBox2;
        TGroupBox *GroupBox3;
        TGroupBox *GroupBox4;
        TComboBox *ComboBox2;
        TEdit *Edit1;
        TLabel *Label1;
        TButton *Button3;
        TLabel *Label2;
        TMainMenu *MainMenu1;
        TMenuItem *N5;
        TMenuItem *N6;
        TMenuItem *N7;
        TMenuItem *Com11;
        TMenuItem *Com12;
        TMenuItem *Com13;
        TMenuItem *Com14;
        TMenuItem *N12001;
        TMenuItem *N24001;
        TMenuItem *N48001;
        TMenuItem *N96001;
        TMenuItem *N192001;
        TMenuItem *N384001;
        TMenuItem *N576001;
        TMenuItem *N1152001;
        TMenuItem *N8;
        TMenuItem *N9;
        TMenuItem *N10;
        TStatusBar *StatusBar2;
        TStatusBar *StatusBar1;
        TStatusBar *StatusBar3;
        TButton *Button4;
    TStatusBar *StatusBar4;
    TMemo *Memo1;
    TTimer *Timer1;
    TYbCommDevice *YbCommDevice1;
    TTimer *R_timer;
    void __fastcall N10Click(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall Button2Click(TObject *Sender);
    void __fastcall N12001Click(TObject *Sender);
    void __fastcall N24001Click(TObject *Sender);
    void __fastcall N48001Click(TObject *Sender);
    void __fastcall N96001Click(TObject *Sender);
    void __fastcall N192001Click(TObject *Sender);
    void __fastcall N384001Click(TObject *Sender);
    void __fastcall N576001Click(TObject *Sender);
    void __fastcall N1152001Click(TObject *Sender);
    void __fastcall Com11Click(TObject *Sender);
    void __fastcall Com12Click(TObject *Sender);
    void __fastcall Com13Click(TObject *Sender);
    void __fastcall Com14Click(TObject *Sender);
    void __fastcall Button4Click(TObject *Sender);
    void __fastcall N8Click(TObject *Sender);
    void __fastcall ComboBox1Change(TObject *Sender);
    void __fastcall ComboBox2Change(TObject *Sender);
    void __fastcall Button1Click(TObject *Sender);
    void __fastcall YbCommDevice1CommNotify(TObject *Sender, int NotifyType);
    void __fastcall R_timerTimer(TObject *Sender);
private: // User declarations
    long    Rxd_cnt;        // 接收计数器
    long    Txd_cnt;        // 发送计数器
    TYbCommDevice::TBaudRate NewBaud;
    void __fastcall Sent_sv(void);  // 发送命令服务
    void __fastcall Comm_active(void);  // 端口操作

public: // User declarations
        __fastcall TForm1(TComponent* Owner);
        int     Baudrate;       // 波特率
        int     Com_port;       // 端口
        int     U_meter;    // 用户设备
        int     U_comm;     // 用户命令
        int     D_time;     // 延时时间
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;

--------------------next---------------------

阅读(1360) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~