Einbinden von TcEventViewer-ActiveX-Control
System requirements:
- CodeGear C++Builder 2009;
- TwinCAT v2.11 B2228 or higher;
- Import the type library of the TcEventViewer.dll (TCEVENTVIEWERLib_OCX);
The sample below uses the TcEventViewer-activeX control to display active alarms on a TwinCAT System.
The following steps are necessary to create the sample:
- Create a new VCL formula application;
- Move TTcEventView from the component palette to the form;
- Implement the methods: FormCreate(), FormClose();
With FormCreate() the connection to EventLogger is configurated/created. With FormClose() the connection is separated. If you want to access to a remote PC you have to configure the network address of the TwinCAT System (AmsNetID).
#include <vcl.h>
#pragma hdrstop
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "TCEVENTVIEWERLib_OCX"
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
address = 0;
bRemote = false;
}
//---------------------------------------------------------------------------
// This method is called when the form is loaded
void __fastcall TForm2::FormCreate(TObject *Sender)
{
if (bRemote) {
address = ::SysAllocString(L"ADS://10.1.128.220.1.1");
TcEventView1->AddConnection(address);
}
TcEventView1->ShowActiveEvents();
}
//---------------------------------------------------------------------------
void __fastcall TForm2::FormClose(TObject *Sender, TCloseAction &Action)
{
if (bRemote) {
TcEventView1->DeleteConnection(address);
if (address) {
::SysFreeString(address);
address = 0;
}
}
}
Language / IDE |
Source code |
---|---|
CodeGear C++Builder 2009 |