88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
/*-------------------------------------------------------------------
|
|
VCSignalProtocolAddOn.h
|
|
-------------------------------------------------------------------
|
|
|
|
(c) Vector Informatik GmbH. All rights reserved.
|
|
|
|
------------------------------------------------------------------- */
|
|
|
|
#include "StdAfx.h"
|
|
#include "ModbusProtocolAddOn.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Implementation of ModbusProtocolAddOn
|
|
//
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
ModbusProtocolAddOn *ModbusProtocolAddOn::sInstance = NULL;
|
|
|
|
//----------------------------------------------------------------------
|
|
//!
|
|
/**
|
|
*/
|
|
ModbusProtocolAddOn::ModbusProtocolAddOn()
|
|
{
|
|
sInstance = this;
|
|
this->sProtocol = NULL;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
//!
|
|
/**
|
|
*/
|
|
ModbusProtocolAddOn& ModbusProtocolAddOn::Instance()
|
|
{
|
|
if (sInstance == 0) throw;
|
|
|
|
return *sInstance;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
// IProtocolAddOn
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//----------------------------------------------------------------------
|
|
//!
|
|
/**
|
|
*/
|
|
VDEF ModbusProtocolAddOn::CreateProtocol( const char /*in*/ *protocolSymbol, NIPB::IProtocol /*out*/ **protocol )
|
|
{
|
|
if (protocol == 0) return NIPB::kInvalidArg;
|
|
if (protocolSymbol == 0) return NIPB::kInvalidArg;
|
|
|
|
if (this->sProtocol == 0)
|
|
this->sProtocol = new ModbusProtocol();
|
|
*protocol = this->sProtocol;
|
|
|
|
return NIPB::kOK;
|
|
}
|
|
|
|
//----------------------------------------------------------------------
|
|
//!
|
|
/**
|
|
*/
|
|
VDEF ModbusProtocolAddOn::ReleaseProtocol( NIPB::IProtocol /*in*/ *protocol)
|
|
{
|
|
ModbusProtocol *prot = dynamic_cast<ModbusProtocol*>( protocol );
|
|
delete prot;
|
|
|
|
return NIPB::kOK;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
// Public Methods
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//----------------------------------------------------------------------
|
|
//!
|
|
/**
|
|
*/
|
|
void ModbusProtocolAddOn::Release()
|
|
{
|
|
delete this;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////
|
|
|