From 022bde85a4553c1fcfac9222bb50aed58573b42e Mon Sep 17 00:00:00 2001 From: gmist Date: Sat, 14 Feb 2009 19:30:33 +0000 Subject: [PATCH] Fix broken merge; git-svn-id: http://frl.googlecode.com/svn/trunk@220 daf5c975-553e-0410-8cda-3135a9dfd8f3 --- include/opc/impl/frl_opc_impl_browse.h | 4 - ...l_opc_impl_browse_server_address_space.cpp | 4 +- src/opc/impl/frl_opc_impl_common.cpp | 97 +------ src/opc/impl/frl_opc_impl_group_state_mgt.cpp | 252 ++---------------- src/opc/impl/frl_opc_impl_item_io.cpp | 197 +------------- src/opc/impl/frl_opc_impl_item_properties.cpp | 252 ++---------------- src/opc/impl/frl_opc_impl_server.cpp | 6 +- 7 files changed, 62 insertions(+), 750 deletions(-) diff --git a/include/opc/impl/frl_opc_impl_browse.h b/include/opc/impl/frl_opc_impl_browse.h index 6e92da2..01b1b41 100644 --- a/include/opc/impl/frl_opc_impl_browse.h +++ b/include/opc/impl/frl_opc_impl_browse.h @@ -7,14 +7,11 @@ namespace frl { namespace opc { namespace impl { -<<<<<<< .working -======= /*! \class BrowseImpl \brief IOPCBrowse implementation. \details IOPCBrowse interface provides improved methods for browsing the server address space and for obtaining the item properties. */ ->>>>>>> .merge-right.r218 class BrowseImpl : public IOPCBrowse, virtual public opc::OPCServerBase @@ -22,7 +19,6 @@ class BrowseImpl public: virtual ~BrowseImpl(); - // IOPCBrowse implementation STDMETHODIMP GetProperties( /* [in] */ DWORD dwItemCount, /* [size_is][string][in] */ LPWSTR *pszItemIDs, diff --git a/src/opc/impl/frl_opc_impl_browse_server_address_space.cpp b/src/opc/impl/frl_opc_impl_browse_server_address_space.cpp index 58649be..041f264 100644 --- a/src/opc/impl/frl_opc_impl_browse_server_address_space.cpp +++ b/src/opc/impl/frl_opc_impl_browse_server_address_space.cpp @@ -264,7 +264,7 @@ STDMETHODIMP BrowseServerAddressSpace::BrowseOPCItemIDs( // filtration by name if( szFilterCriteria != NULL && wcslen( szFilterCriteria ) != 0 ) - { + { #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) String filter = szFilterCriteria; #else @@ -394,7 +394,7 @@ STDMETHODIMP BrowseServerAddressSpace::GetItemID( return E_INVALIDARG; tag = opcAddressSpace::getInstance().getTag( itemDataID ); } - + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) *szItemID = util::duplicateString( tag->getID() ); #else diff --git a/src/opc/impl/frl_opc_impl_common.cpp b/src/opc/impl/frl_opc_impl_common.cpp index 6239898..3cf1429 100644 --- a/src/opc/impl/frl_opc_impl_common.cpp +++ b/src/opc/impl/frl_opc_impl_common.cpp @@ -1,92 +1,3 @@ -<<<<<<< .working -#include "opc/impl/frl_opc_impl_common.h" -#if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) -#include -#include "../dependency/vendors/opc_foundation/opcerror.h" -#include "os/win32/com/frl_os_win32_com_allocator.h" -#include "opc/frl_opc_util.h" -#include "sys/frl_sys_util.h" - -namespace frl { namespace opc { namespace impl { - -OPCCommon::OPCCommon() : lcid( 0 ) -{ -} - -OPCCommon::~OPCCommon() -{ -} - -STDMETHODIMP OPCCommon::SetLocaleID( /* [in] */ LCID dwLcid ) -{ - switch( dwLcid ) - { - case MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT): - case MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT): - case LOCALE_NEUTRAL: - case LOCALE_INVARIANT: - case LOCALE_SYSTEM_DEFAULT: - case LOCALE_USER_DEFAULT: - { - lcid = dwLcid; - return S_OK; - } - } - return E_INVALIDARG; -} - -STDMETHODIMP OPCCommon::GetLocaleID( /* [out] */ LCID *pdwLcid ) -{ - if( pdwLcid == NULL ) - return E_INVALIDARG; - *pdwLcid = lcid; - return S_OK; -} - -STDMETHODIMP OPCCommon::QueryAvailableLocaleIDs( /* [out] */ DWORD *pdwCount, /* [size_is][size_is][out] */ LCID **pdwLcid ) -{ - if( pdwCount == NULL || pdwLcid == NULL ) - return E_INVALIDARG; - - *pdwCount = 6; - *pdwLcid = os::win32::com::allocMemory< LCID >( *pdwCount ); - - (*pdwLcid)[0] = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); - (*pdwLcid)[1] = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_NEUTRAL), SORT_DEFAULT); - (*pdwLcid)[2] = LOCALE_SYSTEM_DEFAULT; - (*pdwLcid)[3] = LOCALE_USER_DEFAULT; - (*pdwLcid)[4] = LOCALE_NEUTRAL; - (*pdwLcid)[5] = LOCALE_INVARIANT; - - return S_OK; -} - -STDMETHODIMP OPCCommon::GetErrorString( /* [in] */ HRESULT dwError, /* [string][out] */ LPWSTR *ppString ) -{ - if( ppString == NULL ) - return E_INVALIDARG; - - *ppString = NULL; - return util::getErrorString( dwError, lcid, &ppString ); -} - -STDMETHODIMP OPCCommon::SetClientName( /* [string][in] */ LPCWSTR szName ) -{ - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - clientName = szName; - #else - clientName = wstring2string( szName ); - #endif - - return S_OK; -} - -} // namespace impl -} // namespace opc -} // FatRat Library - -#endif // FRL_PLATFORM_WIN32 -======= #include "opc/impl/frl_opc_impl_common.h" #if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) #include @@ -256,7 +167,12 @@ STDMETHODIMP OPCCommon::GetErrorString( /* [in] */ HRESULT dwError, /* [string][ */ STDMETHODIMP OPCCommon::SetClientName( /* [string][in] */ LPCWSTR szName ) { - clientName = similarCompatibility( szName ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + clientName = szName; + #else + clientName = wstring2string( szName ); + #endif + return S_OK; } @@ -265,4 +181,3 @@ STDMETHODIMP OPCCommon::SetClientName( /* [string][in] */ LPCWSTR szName ) } // FatRat Library #endif // FRL_PLATFORM_WIN32 ->>>>>>> .merge-right.r218 diff --git a/src/opc/impl/frl_opc_impl_group_state_mgt.cpp b/src/opc/impl/frl_opc_impl_group_state_mgt.cpp index 94780fc..d487ad9 100644 --- a/src/opc/impl/frl_opc_impl_group_state_mgt.cpp +++ b/src/opc/impl/frl_opc_impl_group_state_mgt.cpp @@ -1,234 +1,3 @@ -<<<<<<< .working -#include "opc/impl/frl_opc_impl_group_state_mgt.h" -#if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) -#include -#include "../dependency/vendors/opc_foundation/opcerror.h" -#include "opc/frl_opc_server.h" -#include "opc/frl_opc_group.h" - -namespace frl { namespace opc { namespace impl { - -GroupStateMgt::~GroupStateMgt() -{ -} - -STDMETHODIMP GroupStateMgt::GetState( /* [out] */ DWORD *pUpdateRate, /* [out] */ BOOL *pActive, /* [string][out] */ LPWSTR *ppName, /* [out] */ LONG *pTimeBias, /* [out] */ FLOAT *pPercentDeadband, /* [out] */ DWORD *pLCID, /* [out] */ OPCHANDLE *phClientGroup, /* [out] */ OPCHANDLE *phServerGroup ) -{ - if( deleted ) - return E_FAIL; - - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - *ppName = util::duplicateString( name ); - #else - *ppName = util::duplicateString( string2wstring( name ) ); - #endif - - *pActive = actived; - *pUpdateRate = updateRate; - *phServerGroup = getServerHandle(); - *phClientGroup = clientHandle; - *pTimeBias = timeBias; - *pPercentDeadband = deadband; - *pLCID = localeID; - return S_OK; -} - -STDMETHODIMP GroupStateMgt::SetState( /* [in][unique] */ DWORD *pRequestedUpdateRate, /* [out] */ DWORD *pRevisedUpdateRate, /* [in][unique] */ BOOL *pActive, /* [in][unique] */ LONG *pTimeBias, /* [in][unique] */ FLOAT *pPercentDeadband, /* [in][unique] */ DWORD *pLCID, /* [in][unique] */ OPCHANDLE *phClientGroup ) -{ - if( deleted ) - return E_FAIL; - - HRESULT hResult = S_OK; - if( pRevisedUpdateRate != NULL ) - *pRevisedUpdateRate = 0; - - // validate deadband - if( pPercentDeadband != NULL ) - { - if( *pPercentDeadband < 0 || *pPercentDeadband > 100 ) - return E_INVALIDARG; - deadband = *pPercentDeadband; - } - - boost::mutex::scoped_lock guard( groupGuard ); - - if( pRequestedUpdateRate != NULL ) - { - static const int maxUpdateRate = 100; - DWORD dwUpdateRate = *pRequestedUpdateRate; - if( dwUpdateRate == 0 || dwUpdateRate%maxUpdateRate != 0 ) - { - dwUpdateRate = maxUpdateRate*( dwUpdateRate/maxUpdateRate + 1 ); - hResult = OPC_S_UNSUPPORTEDRATE; - } - - *pRevisedUpdateRate = updateRate = dwUpdateRate; - } - - if( pTimeBias != NULL ) - timeBias = *pTimeBias; - - if( pLCID != NULL ) - localeID = *pLCID; - - if( phClientGroup != NULL ) - clientHandle = *phClientGroup; - - if( pActive != NULL ) - { - Bool oldState = actived; - if( (*pActive == TRUE ) || (*pActive == VARIANT_TRUE ) ) - actived = True; - else - actived = False; - - if( actived ) - { - if( ! oldState ) - { - if( itemList.size() ) - { - if( isConnected( IID_IOPCDataCallback ) ) - { - std::list< OPCHANDLE > handles; - GroupItemElemList::iterator end = itemList.end(); - for( GroupItemElemList::iterator it = itemList.begin(); it != end; ++it ) - { - if( (*it).second->isActived() ) - handles.push_back( (*it).first ); - } - if( handles.size() ) - { - GroupElem tmp = GroupElem( dynamic_cast< Group* >( this ) ); - //AsyncRequestListElem request( new AsyncRequest( tmp, async_request::UPDATE, handles) ); - doAsyncRefresh( boost::make_shared< AsyncRequest >( tmp, async_request::UPDATE, handles ) ); - } - } - } - renewUpdateRate(); - } - } - else - { - server->removeGroupFromRequestList( getServerHandle() ); - } - } - return hResult; -} - -STDMETHODIMP GroupStateMgt::SetName( /* [string][in] */ LPCWSTR szName ) -{ - if( deleted ) - return E_FAIL; - - if( szName == NULL || wcslen( szName ) == 0 ) - return E_INVALIDARG; - - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - String new_name = szName; - #else - String new_name = wstring2string( szName ); - #endif - - HRESULT res = server->setGroupName( name, new_name ); - if( FAILED( res ) ) - return res; - name = name; - return S_OK; -} - -STDMETHODIMP GroupStateMgt::CloneGroup( /* [string][in] */ LPCWSTR szName, /* [in] */ REFIID riid, /* [iid_is][out] */ LPUNKNOWN *ppUnk ) -{ - if( deleted ) - return E_FAIL; - - if( ppUnk == NULL ) - return E_INVALIDARG; - - String new_name; - if( szName == NULL || wcslen( szName ) == 0 ) - { - new_name = util::getUniqueName(); - } - else - { - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - new_name = szName; - #else - new_name = wstring2string( szName ); - #endif - } - - GroupElem group; - try - { - group = server->cloneGroup( name, new_name ); - } - catch( GroupManager::IsExistGroup& ) - { - return OPC_E_DUPLICATENAME; - } - catch( GroupManager::NotExistGroup& ) - { - return E_INVALIDARG; - } - - HRESULT result = group->QueryInterface( riid, (void**)ppUnk ); - - if( FAILED( result ) ) - { - server->RemoveGroup( group->getServerHandle(), FALSE ); - } - - return result; -} - -STDMETHODIMP GroupStateMgt::SetKeepAlive( /* [in] */ DWORD dwKeepAliveTime, /* [out] */ DWORD *pdwRevisedKeepAliveTime ) -{ - if( pdwRevisedKeepAliveTime == NULL ) - return E_INVALIDARG; - - if( deleted ) - return E_FAIL; - - if( dwKeepAliveTime == 0 ) - { - keepAlive = *pdwRevisedKeepAliveTime = 0; - return S_OK; - } - - static const DWORD maxKeepAliveTime = 100000; // 100 sec - - DWORD tmp = dwKeepAliveTime; // for non blocked change Group::keepAlive - if( tmp%maxKeepAliveTime != 0 ) - { - tmp = maxKeepAliveTime * ( tmp / maxKeepAliveTime + 1 ); - } - keepAlive = *pdwRevisedKeepAliveTime = tmp; - - if( tmp != dwKeepAliveTime ) - return OPC_S_UNSUPPORTEDRATE; - return S_OK; -} - -STDMETHODIMP GroupStateMgt::GetKeepAlive( /* [out] */ DWORD *pdwKeepAliveTime ) -{ - if( pdwKeepAliveTime == NULL ) - return E_INVALIDARG; - - if( deleted ) - return E_FAIL; - - *pdwKeepAliveTime = keepAlive; - return S_OK; -} - -} // namespace impl -} // namespace opc -} // FatRat Library - -#endif // FRL_PLATFORM_WIN32 -======= #include "opc/impl/frl_opc_impl_group_state_mgt.h" #if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) #include @@ -305,7 +74,12 @@ STDMETHODIMP GroupStateMgt::GetState( /* [out] */ DWORD *pUpdateRate, /* [out] * if( deleted ) return E_FAIL; - *ppName = util::duplicateString( unicodeCompatibility( name ) ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + *ppName = util::duplicateString( name ); + #else + *ppName = util::duplicateString( string2wstring( name ) ); + #endif + *pActive = actived; *pUpdateRate = updateRate; *phServerGroup = getServerHandle(); @@ -484,7 +258,12 @@ STDMETHODIMP GroupStateMgt::SetName( /* [string][in] */ LPCWSTR szName ) if( szName == NULL || wcslen( szName ) == 0 ) return E_INVALIDARG; - String new_name = similarCompatibility( szName ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + String new_name = szName; + #else + String new_name = wstring2string( szName ); + #endif + HRESULT res = server->setGroupName( name, new_name ); if( FAILED( res ) ) return res; @@ -574,7 +353,11 @@ STDMETHODIMP GroupStateMgt::CloneGroup( /* [string][in] */ LPCWSTR szName, /* [i } else { - new_name = similarCompatibility( szName ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + new_name = szName; + #else + new_name = wstring2string( szName ); + #endif } GroupElem group; @@ -703,4 +486,3 @@ STDMETHODIMP GroupStateMgt::GetKeepAlive( /* [out] */ DWORD *pdwKeepAliveTime ) } // FatRat Library #endif // FRL_PLATFORM_WIN32 ->>>>>>> .merge-right.r218 diff --git a/src/opc/impl/frl_opc_impl_item_io.cpp b/src/opc/impl/frl_opc_impl_item_io.cpp index b556467..16c93fa 100644 --- a/src/opc/impl/frl_opc_impl_item_io.cpp +++ b/src/opc/impl/frl_opc_impl_item_io.cpp @@ -1,181 +1,3 @@ -<<<<<<< .working -#include "opc/impl/frl_opc_impl_item_io.h" -#if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) -#include -#include "../dependency/vendors/opc_foundation/opcerror.h" -#include "os/win32/com/frl_os_win32_com_allocator.h" -#include "opc/address_space/frl_opc_address_space.h" - -namespace frl { namespace opc { namespace impl { - -OPCItemIO::~OPCItemIO() -{ -} - -STDMETHODIMP OPCItemIO::Read( - /* [in] */ DWORD dwCount, - /* [size_is][in] */ LPCWSTR *pszItemIDs, - /* [size_is][in] */ DWORD *pdwMaxAge, - /* [size_is][size_is][out] */ VARIANT **ppvValues, - /* [size_is][size_is][out] */ WORD **ppwQualities, - /* [size_is][size_is][out] */ FILETIME **ppftTimeStamps, - /* [size_is][size_is][out] */ HRESULT **ppErrors ) -{ - boost::mutex::scoped_lock guard( scopeGuard ); - - if( pszItemIDs == NULL || pdwMaxAge == NULL || - ppvValues == NULL || ppwQualities == NULL || - ppftTimeStamps == NULL || ppErrors == NULL ) - { - return E_INVALIDARG; - } - - *ppvValues = NULL; - *ppwQualities = NULL; - *ppftTimeStamps = NULL; - *ppErrors = NULL; - - if( dwCount == 0 ) - return E_INVALIDARG; - - *ppvValues = os::win32::com::allocMemory< VARIANT >( dwCount ); - *ppwQualities = os::win32::com::allocMemory< WORD >( dwCount ); - *ppftTimeStamps = os::win32::com::allocMemory< FILETIME >( dwCount ); - *ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount ); - - os::win32::com::zeroMemory< VARIANT >( *ppvValues, dwCount ); - os::win32::com::zeroMemory< WORD >( *ppwQualities, dwCount ); - os::win32::com::zeroMemory< FILETIME >( *ppftTimeStamps, dwCount ); - os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount ); - - HRESULT res = S_OK; - address_space::Tag *item = NULL; - String itemID; - for( DWORD i = 0; i < dwCount; ++i ) - { - try - { - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - if( pszItemIDs[i] ) - itemID = pszItemIDs[i]; - #else - if( pszItemIDs[i] ) - itemID = wstring2string( pszItemIDs[i] ); - #endif - item = opcAddressSpace::getInstance().getLeaf( itemID ); - } - catch( frl::Exception& ) - { - (*ppErrors)[i] = OPC_E_INVALIDITEMID; - res = S_FALSE; - continue; - } - - if( ! ( item->isReadable() ) ) - { - res = S_FALSE; - (*ppErrors)[i] = OPC_E_BADRIGHTS; - continue; - } - - (*ppErrors)[i] = os::win32::com::Variant::variantCopy( (*ppvValues)[i], item->read() ); - if( FAILED( (*ppErrors)[i] ) ) - { - res = S_FALSE; - continue; - } - (*ppwQualities)[i] = item->getQuality(); - (*ppftTimeStamps)[i] = item->getTimeStamp(); - } - return res; -} - -STDMETHODIMP OPCItemIO::WriteVQT( - /* [in] */ DWORD dwCount, - /* [size_is][in] */ LPCWSTR *pszItemIDs, - /* [size_is][in] */ OPCITEMVQT *pItemVQT, - /* [size_is][size_is][out] */ HRESULT **ppErrors ) -{ - boost::mutex::scoped_lock guard( scopeGuard ); - - if( pszItemIDs == NULL || pItemVQT == NULL || ppErrors == NULL ) - return E_INVALIDARG; - - *ppErrors = NULL; - - if( dwCount == 0 ) - return E_INVALIDARG; - - *ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount ); - os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount ); - - HRESULT res = S_OK; - address_space::Tag *item = NULL; - String itemID; - for( DWORD i = 0; i < dwCount; ++i ) - { - try - { - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - if( pszItemIDs[i] ) - itemID = pszItemIDs[i]; - #else - if( pszItemIDs[i] ) - itemID = wstring2string( pszItemIDs[i] ); - #endif - item = opcAddressSpace::getInstance().getLeaf( itemID ); - } - catch( frl::Exception& ) - { - (*ppErrors)[i] = OPC_E_INVALIDITEMID; - res = S_FALSE; - continue; - } - - if( ! item->isWritable() ) - { - res = S_FALSE; - (*ppErrors)[i] = OPC_E_BADRIGHTS; - continue; - } - - if( pItemVQT[i].vDataValue.vt == VT_EMPTY ) - { - res = S_FALSE; - (*ppErrors)[i] = OPC_E_BADTYPE; - continue; - } - - VARIANT tmp; - ::VariantInit( &tmp ); - os::win32::com::Variant::variantCopy( &tmp, &pItemVQT[i].vDataValue ); - (*ppErrors)[i] = ::VariantChangeType( &tmp, &tmp, 0, item->getCanonicalDataType() ); - if( FAILED( (*ppErrors)[i] ) ) - { - res = S_FALSE; - continue; - } - item->writeFromOPC( tmp ); - - if( pItemVQT[i].bQualitySpecified ) - { - item->setQuality( pItemVQT[i].wQuality ); - } - - if( pItemVQT[i].bTimeStampSpecified ) - { - item->setTimeStamp( pItemVQT[i].ftTimeStamp ); - } - } - return res; -} - -} // namespace impl -} // namespace opc -} // FatRat Library - -#endif // FRL_PLATFORM_WIN32 -======= #include "opc/impl/frl_opc_impl_item_io.h" #if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) #include @@ -346,10 +168,15 @@ STDMETHODIMP OPCItemIO::Read( String itemID; for( DWORD i = 0; i < dwCount; ++i ) { - if( pszItemIDs[i] ) - itemID = similarCompatibility( pszItemIDs[i] ); try { + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + if( pszItemIDs[i] ) + itemID = pszItemIDs[i]; + #else + if( pszItemIDs[i] ) + itemID = wstring2string( pszItemIDs[i] ); + #endif item = opcAddressSpace::getInstance().getLeaf( itemID ); } catch( frl::Exception& ) @@ -481,10 +308,15 @@ STDMETHODIMP OPCItemIO::WriteVQT( String itemID; for( DWORD i = 0; i < dwCount; ++i ) { - if( pszItemIDs[i] ) - itemID = similarCompatibility( pszItemIDs[i] ); try { + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + if( pszItemIDs[i] ) + itemID = pszItemIDs[i]; + #else + if( pszItemIDs[i] ) + itemID = wstring2string( pszItemIDs[i] ); + #endif item = opcAddressSpace::getInstance().getLeaf( itemID ); } catch( frl::Exception& ) @@ -537,4 +369,3 @@ STDMETHODIMP OPCItemIO::WriteVQT( } // FatRat Library #endif // FRL_PLATFORM_WIN32 ->>>>>>> .merge-right.r218 diff --git a/src/opc/impl/frl_opc_impl_item_properties.cpp b/src/opc/impl/frl_opc_impl_item_properties.cpp index 9113e04..814272e 100644 --- a/src/opc/impl/frl_opc_impl_item_properties.cpp +++ b/src/opc/impl/frl_opc_impl_item_properties.cpp @@ -1,233 +1,3 @@ -<<<<<<< .working -#include "opc/impl/frl_opc_impl_item_properties.h" -#if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) -#include "../dependency/vendors/opc_foundation/opcerror.h" -#include "opc/address_space/frl_opc_address_space.h" -#include "opc/frl_opc_util.h" -#include "os/win32/com/frl_os_win32_com_variant.h" - -namespace frl { namespace opc { namespace impl { - -OPCItemProperties::~OPCItemProperties() -{ -} - -STDMETHODIMP OPCItemProperties::QueryAvailableProperties( - /* [in] */ LPWSTR szItemID, - /* [out] */ DWORD *pdwCount, - /* [size_is][size_is][out] */ DWORD **ppPropertyIDs, - /* [size_is][size_is][out] */ LPWSTR **ppDescriptions, - /* [size_is][size_is][out] */ VARTYPE **ppvtDataTypes ) -{ - if ( - szItemID == NULL || - pdwCount == NULL || - ppPropertyIDs == NULL || - ppDescriptions == NULL || - ppvtDataTypes == NULL - ) - { - return E_INVALIDARG; - } - - *pdwCount = 0; - *ppPropertyIDs = NULL; - *ppDescriptions = NULL; - *ppvtDataTypes = NULL; - - if( wcslen( szItemID ) == 0 ) - return OPC_E_INVALIDITEMID; - - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - String itemID = szItemID; - #else - String itemID = wstring2string( szItemID ); - #endif - - if( opcAddressSpace::getInstance().isExistBranch( itemID ) ) - return S_OK; - - address_space::Tag *item = NULL; - try - { - item = opcAddressSpace::getInstance().getTag( itemID ); - } - catch( address_space::Tag::NotExistTag& ) - { - return OPC_E_UNKNOWNITEMID; - } - - std::vector< DWORD > propArray = item->getAvailableProperties(); - *pdwCount = (DWORD) propArray.size(); - - *ppPropertyIDs = os::win32::com::allocMemory( *pdwCount ); - if( *ppPropertyIDs == NULL ) - return E_OUTOFMEMORY; - os::win32::com::zeroMemory( *ppPropertyIDs, *pdwCount ); - - *ppDescriptions = os::win32::com::allocMemory< LPWSTR >( *pdwCount ); - if( *ppDescriptions == NULL ) - { - os::win32::com::freeMemory( *ppPropertyIDs ); - return E_OUTOFMEMORY; - } - os::win32::com::zeroMemory< LPWSTR >( *ppDescriptions, *pdwCount ); - - *ppvtDataTypes = os::win32::com::allocMemory< VARTYPE >( *pdwCount ); - if( *ppvtDataTypes == NULL ) - { - os::win32::com::freeMemory( *ppPropertyIDs ); - os::win32::com::freeMemory( *ppDescriptions ); - return E_OUTOFMEMORY; - } - os::win32::com::zeroMemory< VARTYPE >( *ppvtDataTypes, *pdwCount ); - - for( DWORD i = 0; i < *pdwCount; ++i ) - { - (*ppPropertyIDs)[i] = propArray[i]; - (*ppDescriptions)[i] = util::duplicateString( util::getPropertyDesc( propArray[i] ) ); - (*ppvtDataTypes)[i] = util::getPropertyType( propArray[i] ); - } - - return S_OK; -} - -STDMETHODIMP OPCItemProperties::GetItemProperties( - /* [in] */ LPWSTR szItemID, - /* [in] */ DWORD dwCount, - /* [size_is][in] */ DWORD *pdwPropertyIDs, - /* [size_is][size_is][out] */ VARIANT **ppvData, - /* [size_is][size_is][out] */ HRESULT **ppErrors ) -{ - if ( szItemID == NULL || ppvData == NULL || ppErrors == NULL ) - return E_INVALIDARG; - - *ppvData = NULL; - *ppErrors = NULL; - - if( dwCount == 0 ) - return E_INVALIDARG; - - if( wcslen( szItemID ) == 0 ) - return OPC_E_INVALIDITEMID; - - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - String itemID = szItemID; - #else - String itemID = wstring2string( szItemID ); - #endif - - address_space::Tag *item = NULL; - try - { - item = opcAddressSpace::getInstance().getLeaf( itemID ); - } - catch( frl::opc::address_space::Tag::NotExistTag& ) - { - return OPC_E_UNKNOWNITEMID; - } - - *ppvData = os::win32::com::allocMemory< VARIANT >( dwCount ); - if( *ppvData == NULL ) - return E_OUTOFMEMORY; - - os::win32::com::zeroMemory< VARIANT >( *ppvData, dwCount ); - - *ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount ); - if( *ppErrors == NULL ) - return E_OUTOFMEMORY; - - os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount ); - - HRESULT res = S_OK; - for( DWORD i = 0; i < dwCount; ++i ) - { - (*ppErrors)[i] = item->getPropertyValue( pdwPropertyIDs[i], (*ppvData)[i] ); - if( FAILED( (*ppErrors)[i] ) ) - res = S_FALSE; - } - return res; -} - -STDMETHODIMP OPCItemProperties::LookupItemIDs( - /* [in] */ LPWSTR szItemID, - /* [in] */ DWORD dwCount, - /* [size_is][in] */ DWORD *pdwPropertyIDs, - /* [size_is][size_is][string][out] */ LPWSTR **ppszNewItemIDs, - /* [size_is][size_is][out] */ HRESULT **ppErrors ) -{ - if ( szItemID == NULL || ppszNewItemIDs == NULL || ppErrors == NULL ) - return E_INVALIDARG; - - *ppszNewItemIDs = NULL; - *ppErrors = NULL; - - if (dwCount == 0) - return E_INVALIDARG; - - if( wcslen( szItemID ) == 0 ) - return OPC_E_INVALIDITEMID; - - #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) - String itemID = szItemID; - #else - String itemID = wstring2string( szItemID ); - #endif - - address_space::Tag *item = NULL; - try - { - item = opcAddressSpace::getInstance().getLeaf( itemID ); - } - catch( address_space::Tag::NotExistTag& ) - { - return OPC_E_UNKNOWNITEMID; - } - - *ppszNewItemIDs = os::win32::com::allocMemory< LPWSTR >( dwCount ); - if( ppszNewItemIDs == NULL ) - return E_OUTOFMEMORY; - - os::win32::com::zeroMemory< LPWSTR>( *ppszNewItemIDs, dwCount ); - - *ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount ); - if( ppErrors == NULL ) - return E_OUTOFMEMORY; - - os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount ); - - HRESULT ret = S_OK; - for( DWORD i = 0; i < dwCount; ++i ) - { - if( item->isValidProperties( pdwPropertyIDs[i] ) ) - { - (*ppszNewItemIDs)[i] = util::duplicateString( util::getPropertyDesc( pdwPropertyIDs[i] ) ); - } - else - { - (*ppErrors)[i] = OPC_E_INVALID_PID; - ret = S_FALSE; - } - - if( pdwPropertyIDs[i] <= OPC_PROPERTY_EU_INFO) - { - (*ppErrors)[i] = OPC_E_INVALID_PID; - ret = S_FALSE; - } - else - { - (*ppErrors)[i] = S_OK; - } - } - return ret; -} - -} // namespace impl -} // namespace opc -} // FatRat Library - -#endif // FRL_PLATFORM_WIN32 -======= #include "opc/impl/frl_opc_impl_item_properties.h" #if( FRL_PLATFORM == FRL_PLATFORM_WIN32 ) #include "../dependency/vendors/opc_foundation/opcerror.h" @@ -312,7 +82,12 @@ STDMETHODIMP OPCItemProperties::QueryAvailableProperties( if( wcslen( szItemID ) == 0 ) return OPC_E_INVALIDITEMID; - String itemID = similarCompatibility( szItemID ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + String itemID = szItemID; + #else + String itemID = wstring2string( szItemID ); + #endif + if( opcAddressSpace::getInstance().isExistBranch( itemID ) ) return S_OK; @@ -446,7 +221,12 @@ STDMETHODIMP OPCItemProperties::GetItemProperties( if( wcslen( szItemID ) == 0 ) return OPC_E_INVALIDITEMID; - String itemID = similarCompatibility( szItemID ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + String itemID = szItemID; + #else + String itemID = wstring2string( szItemID ); + #endif + address_space::Tag *item = NULL; try { @@ -558,7 +338,12 @@ STDMETHODIMP OPCItemProperties::LookupItemIDs( if( wcslen( szItemID ) == 0 ) return OPC_E_INVALIDITEMID; - String itemID = similarCompatibility( szItemID ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + String itemID = szItemID; + #else + String itemID = wstring2string( szItemID ); + #endif + address_space::Tag *item = NULL; try { @@ -612,4 +397,3 @@ STDMETHODIMP OPCItemProperties::LookupItemIDs( } // FatRat Library #endif // FRL_PLATFORM_WIN32 ->>>>>>> .merge-right.r218 diff --git a/src/opc/impl/frl_opc_impl_server.cpp b/src/opc/impl/frl_opc_impl_server.cpp index 2495dce..0226dc3 100644 --- a/src/opc/impl/frl_opc_impl_server.cpp +++ b/src/opc/impl/frl_opc_impl_server.cpp @@ -184,7 +184,11 @@ STDMETHODIMP OPCServer::AddGroup( } else { - name = similarCompatibility( szName ); + #if( FRL_CHARACTER == FRL_CHARACTER_UNICODE ) + name = szName; + #else + name = wstring2string( szName ); + #endif } try