2014-05-28 11:20:38 +02:00
|
|
|
/*-------------------------------------------------------------------
|
2014-05-28 16:27:53 +02:00
|
|
|
VCSignalProtocolAddOn.h
|
|
|
|
-------------------------------------------------------------------
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
(c) Vector Informatik GmbH. All rights reserved.
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
------------------------------------------------------------------- */
|
2014-05-28 11:20:38 +02:00
|
|
|
|
|
|
|
#include "StdAfx.h"
|
2014-05-28 16:27:53 +02:00
|
|
|
#include "ModbusProtocolAddOn.h"
|
|
|
|
#include "ModbusProtocol.h"
|
2014-05-28 11:20:38 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2014-05-28 16:27:53 +02:00
|
|
|
// Implementation of ModbusProtocolAddOn
|
2014-05-28 11:20:38 +02:00
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
ModbusProtocolAddOn *ModbusProtocolAddOn::sInstance = NULL;
|
2014-05-28 11:20:38 +02:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//!
|
|
|
|
/**
|
|
|
|
*/
|
2014-05-28 16:27:53 +02:00
|
|
|
ModbusProtocolAddOn::ModbusProtocolAddOn()
|
2014-05-28 11:20:38 +02:00
|
|
|
{
|
2014-05-28 16:27:53 +02:00
|
|
|
sInstance = this;
|
2014-05-28 11:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//!
|
|
|
|
/**
|
|
|
|
*/
|
2014-05-28 16:27:53 +02:00
|
|
|
ModbusProtocolAddOn& ModbusProtocolAddOn::Instance()
|
2014-05-28 11:20:38 +02:00
|
|
|
{
|
2014-05-28 16:27:53 +02:00
|
|
|
if (sInstance == 0) throw;
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
return *sInstance;
|
2014-05-28 11:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// IProtocolAddOn
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//!
|
|
|
|
/**
|
|
|
|
*/
|
2014-05-28 16:27:53 +02:00
|
|
|
VDEF ModbusProtocolAddOn::CreateProtocol( const char /*in*/ *protocolSymbol, NIPB::IProtocol /*out*/ **protocol )
|
2014-05-28 11:20:38 +02:00
|
|
|
{
|
2014-05-28 16:27:53 +02:00
|
|
|
if (protocol == 0) return NIPB::kInvalidArg;
|
|
|
|
if (protocolSymbol == 0) return NIPB::kInvalidArg;
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
*protocol = new ModbusProtocol();
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
return NIPB::kOK;
|
2014-05-28 11:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//!
|
|
|
|
/**
|
|
|
|
*/
|
2014-05-28 16:27:53 +02:00
|
|
|
VDEF ModbusProtocolAddOn::ReleaseProtocol( NIPB::IProtocol /*in*/ *protocol)
|
2014-05-28 11:20:38 +02:00
|
|
|
{
|
2014-05-28 16:27:53 +02:00
|
|
|
ModbusProtocol *prot = dynamic_cast<ModbusProtocol*>( protocol );
|
|
|
|
delete prot;
|
2014-05-28 11:20:38 +02:00
|
|
|
|
2014-05-28 16:27:53 +02:00
|
|
|
return NIPB::kOK;
|
2014-05-28 11:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// Public Methods
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
//!
|
|
|
|
/**
|
|
|
|
*/
|
2014-05-28 16:27:53 +02:00
|
|
|
void ModbusProtocolAddOn::Release()
|
2014-05-28 11:20:38 +02:00
|
|
|
{
|
2014-05-28 16:27:53 +02:00
|
|
|
delete this;
|
2014-05-28 11:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|