Commit 88b8e423 authored by Patrick Bellot's avatar Patrick Bellot
Browse files

EDP

parent d449a6c1
......@@ -46,119 +46,74 @@ protected:
AddNodesResponse ** pRResponse
)
{
return STATUS_OK ;
// uint32_t loopCpt = 0 ;
//
// CallbackData_Invoke callbackData_Invoke ;
// callbackData_Invoke.baseClient = (void *)this ;
// callbackData_Invoke.pData = (void *)pRResponse ;
// callbackData_Invoke.event = 0 ;
//
// debug(MAIN_LIFE_DBG,"BaseNodeManagement","Invoke_AddNodes begin") ;
//
// StubClient_CallbackData callbackData ;
// callbackData.stub = &callbackData_Invoke ;
//
// SOPC_StatusCode status = STATUS_OK ;
//
// OpcUa_AddNodesRequest request ;
// OpcUa_AddNodesRequest_Initialize(&request);
// rrequest->fromCpptoC(&status,request) ;
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddNodes failed (case 1): status=0x%08x",status) ;
// goto out ;
// }
//
// status = OpcUa_ClientApi_BeginAddNodes(
// hChannel,
// &(request.RequestHeader),
// request.NoOfNodesToAdd,
// request.NodesToAdd,
// (SOPC_Channel_PfnRequestComplete*) &BaseNodeManagement::_Invoke_AddNodes_Callback,
// &callbackData);
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddNodes failed (case 2): status=0x%08x",status) ;
// goto out ;
// }
//
// while (status == STATUS_OK && callbackData_Invoke.event == 0 && loopCpt*sleepTimeout <= loopTimeout) {
// debug(COM_ERR,"BaseNodeManagement","Invoke_AddNodes loop") ;
// status = SOPC_TreatReceivedMessages(sleepTimeout) ;
// loopCpt++ ;
// }
//
// if (*pRResponse == NULL) {
// debug(COM_ERR,"BaseNodeManagement","Invoke_AddNodes failed (case 3)") ;
// status = _Bad_InternalError ;
// goto out ;
// }
//
// if (status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddNodes failed (case 4): status=0x%08x",status) ;
// if (*pRResponse != NULL) {
// (*pRResponse)->checkRefCount() ;
// *pRResponse = NULL ;
// }
// }
//
// out:
// OpcUa_AddNodesRequest_Clear(&request) ;
// return status ;
}
debug(MAIN_LIFE_DBG,"BaseNodeManagement","Connexion_AddNodes begin") ;
SOPC_StatusCode status = STATUS_OK ;
OpcUa_RequestHeader requestHeader ;
OpcUa_RequestHeader_Initialize(&requestHeader);
OpcUa_AddNodesRequest request ;
OpcUa_AddNodesRequest_Initialize(&request);
rrequest->fromCpptoC(&status,requestHeader,request) ;
int loopCpt = 0;
BaseDataType * obj = NULL ;
if(status != STATUS_OK) {
debug_i(COM_ERR,"BaseNodeManagement","Connexion_AddNodes failed (case 1): status=0x%08x",status) ;
goto out ;
}
debug_ii(IPCS_DBG,"BaseNodeManagement","Connexion_AddNodes: sending request with scId=%d ad requestId=%d...",channel_config_idx,num) ;
Service_SendRequest(
channel_config_idx,
num,
&OpcUa_AddNodesRequest_EncodeableType,
&requestHeader,
&request) ;
//protected:
//
// static SOPC_StatusCode _Invoke_AddNodes_Callback(
// SOPC_Channel channel,
// void * response,
// SOPC_EncodeableType * responseType,
// void * callbackData,
// SOPC_StatusCode status)
// {
// return STATUS_OK ;
//
// NOT_USED(channel) ;
// NOT_USED(status) ;
//
// StubClient_CallbackData * ptrToStub = (StubClient_CallbackData *)callbackData ;
// CallbackData_Invoke * pCallbackData = (CallbackData_Invoke *)(ptrToStub->stub) ;
// BaseNodeManagement * baseClient = (BaseNodeManagement *)(pCallbackData->baseClient) ;
// AddNodesResponse ** pResponse = (AddNodesResponse **)(pCallbackData->pData) ;
//
// pCallbackData->event = 1 ;
//
// return baseClient->Invoke_AddNodes_Callback(response,responseType,pResponse) ;
// }
//
//private:
//
// SOPC_StatusCode Invoke_AddNodes_Callback(void * response, SOPC_EncodeableType * responseType, AddNodesResponse ** pResponse)
// {
// SOPC_StatusCode status = STATUS_OK ;
//
// if (OpcUa_AddNodesResponse_EncodeableType.TypeId == responseType->TypeId) { /* check response type */
//
// *pResponse = AddNodesResponse::fromCtoCpp(&status, *((const OpcUa_AddNodesResponse *)response)) ;
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseQuery","Invoke_AddNodes_Callback failed in from CtoCpp: status=0x%08x",status) ;
// if (*pResponse != NULL) {
// (*pResponse)->checkRefCount() ;
// *pResponse = NULL ;
// }
// }
//
// OpcUa_AddNodesResponse_Clear(response);
// } else {
// status = Invoke_Error("Invoke_AddNodes_Callback",response,responseType) ;
// }
//
// free(response) ;
// return status ;
// }
debug(IPCS_DBG,"BaseNodeManagement","Connexion_AddNodes: waiting for answer...") ;
while ((obj = responsesQueue->tryPop()) == NULL && loopCpt * sleepTimeout <= loopTimeout) {
loopCpt++;
SOPC_Sleep(sleepTimeout);
}
debug(IPCS_DBG,"BaseNodeManagement","After waiting for answer...") ;
if (obj==NULL || loopCpt * sleepTimeout > loopTimeout) {
debug_i(COM_ERR,"BaseNodeManagement","Connexion_AddNodes: service failed with timeout, client=%d",num) ;
status = SOPC_STATUS_TIMEOUT;
goto out ;
}
if (obj->getTypeId() == OpcUaId_ServiceFault) {
ServiceFault * serviceFault = (ServiceFault *)obj ;
status = serviceFault->getResponseHeader()->getServiceResult()->get() ;
delete obj ;
debug_ii(COM_ERR,"BaseNodeManagement","Connexion_AddNodes: service failed with rc=0x%08x for client=%d",status,num) ;
goto out ;
}
if (obj->getTypeId() != OpcUaId_AddNodesResponse) {
debug_iii(COM_ERR,"BaseQuery","Connexion_AddNodes: bad Response answer with typeId=%d, rc=0x%08x for client=%d",obj->getTypeId(),status,num) ;
ServiceFault * serviceFault = (ServiceFault *)obj ;
status = serviceFault->getResponseHeader()->getServiceResult()->get() ;
delete obj ;
goto out ;
}
debug(IPCS_DBG,"BaseNodeManagement","Connexion_AddNodes: answer is AddNodes") ;
*pRResponse = (AddNodesResponse *)obj ;
out:
OpcUa_RequestHeader_Clear(&requestHeader) ;
OpcUa_AddNodesRequest_Clear(&request) ;
return status ;
}
protected:
......@@ -167,119 +122,74 @@ protected:
AddReferencesResponse ** pRResponse
)
{
return STATUS_OK ;
// uint32_t loopCpt = 0 ;
//
// CallbackData_Invoke callbackData_Invoke ;
// callbackData_Invoke.baseClient = (void *)this ;
// callbackData_Invoke.pData = (void *)pRResponse ;
// callbackData_Invoke.event = 0 ;
//
// debug(MAIN_LIFE_DBG,"BaseNodeManagement","Invoke_AddReferences begin") ;
//
// StubClient_CallbackData callbackData ;
// callbackData.stub = &callbackData_Invoke ;
//
// SOPC_StatusCode status = STATUS_OK ;
//
// OpcUa_AddReferencesRequest request ;
// OpcUa_AddReferencesRequest_Initialize(&request);
// rrequest->fromCpptoC(&status,request) ;
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddReferences failed (case 1): status=0x%08x",status) ;
// goto out ;
// }
//
// status = OpcUa_ClientApi_BeginAddReferences(
// hChannel,
// &(request.RequestHeader),
// request.NoOfReferencesToAdd,
// request.ReferencesToAdd,
// (SOPC_Channel_PfnRequestComplete*) &BaseNodeManagement::_Invoke_AddReferences_Callback,
// &callbackData);
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddReferences failed (case 2): status=0x%08x",status) ;
// goto out ;
// }
//
// while (status == STATUS_OK && callbackData_Invoke.event == 0 && loopCpt*sleepTimeout <= loopTimeout) {
// debug(COM_ERR,"BaseNodeManagement","Invoke_AddReferences loop") ;
// status = SOPC_TreatReceivedMessages(sleepTimeout) ;
// loopCpt++ ;
// }
//
// if (status != STATUS_OK) {
// debug_i(COM_ERR,"BaseNodeManagement","Invoke_AddReferences failed (case 3): status=0x%08x",status) ;
// if (*pRResponse != NULL) {
// (*pRResponse)->checkRefCount() ;
// *pRResponse = NULL ;
// }
// goto out ;
// }
//
// if (*pRResponse == NULL) {
// debug(COM_ERR,"BaseNodeManagement","Invoke_AddReferences failed (case 4)") ;
// status = _Bad_InternalError ;
// }
//
// out:
// OpcUa_AddReferencesRequest_Clear(&request) ;
// return status ;
}
debug(MAIN_LIFE_DBG,"BaseNodeManagement","Connexion_AddReferences begin") ;
SOPC_StatusCode status = STATUS_OK ;
OpcUa_RequestHeader requestHeader ;
OpcUa_RequestHeader_Initialize(&requestHeader);
OpcUa_AddReferencesRequest request ;
OpcUa_AddReferencesRequest_Initialize(&request);
rrequest->fromCpptoC(&status,requestHeader,request) ;
int loopCpt = 0;
BaseDataType * obj = NULL ;
if(status != STATUS_OK) {
debug_i(COM_ERR,"BaseNodeManagement","Connexion_AddReferences failed (case 1): status=0x%08x",status) ;
goto out ;
}
debug_ii(IPCS_DBG,"BaseNodeManagement","Connexion_AddReferences: sending request with scId=%d ad requestId=%d...",channel_config_idx,num) ;
Service_SendRequest(
channel_config_idx,
num,
&OpcUa_AddReferencesRequest_EncodeableType,
&requestHeader,
&request) ;
//protected:
//
// static SOPC_StatusCode _Invoke_AddReferences_Callback(
// SOPC_Channel channel,
// void * response,
// SOPC_EncodeableType * responseType,
// void * callbackData,
// SOPC_StatusCode status)
// {
// return STATUS_OK ;
//
// NOT_USED(channel) ;
// NOT_USED(status) ;
//
// StubClient_CallbackData * ptrToStub = (StubClient_CallbackData *)callbackData ;
// CallbackData_Invoke * pCallbackData = (CallbackData_Invoke *)(ptrToStub->stub) ;
// BaseNodeManagement * baseClient = (BaseNodeManagement *)(pCallbackData->baseClient) ;
// AddReferencesResponse ** pResponse = (AddReferencesResponse **)(pCallbackData->pData) ;
//
// pCallbackData->event = 1 ;
//
// return baseClient->Invoke_AddReferences_Callback(response,responseType,pResponse) ;
// }
//
//private:
//
// SOPC_StatusCode Invoke_AddReferences_Callback(void * response, SOPC_EncodeableType * responseType, AddReferencesResponse ** pResponse)
// {
// SOPC_StatusCode status = STATUS_OK ;
//
// if (OpcUa_AddReferencesResponse_EncodeableType.TypeId == responseType->TypeId) { /* check response type */
//
// *pResponse = AddReferencesResponse::fromCtoCpp(&status, *((const OpcUa_AddReferencesResponse *)response)) ;
//
// if(status != STATUS_OK) {
// debug_i(COM_ERR,"BaseQuery","Invoke_AddReferences_Callback failed in from CtoCpp: status=0x%08x",status) ;
// if (*pResponse != NULL) {
// (*pResponse)->checkRefCount() ;
// *pResponse = NULL ;
// }
// }
//
// OpcUa_AddReferencesResponse_Clear(response);
// } else {
// status = Invoke_Error("Invoke_AddReferences_Callback",response,responseType) ;
// }
//
// free(response) ;
// return status ;
// }
debug(IPCS_DBG,"BaseNodeManagement","Connexion_AddReferences: waiting for answer...") ;
while ((obj = responsesQueue->tryPop()) == NULL && loopCpt * sleepTimeout <= loopTimeout) {
loopCpt++;
SOPC_Sleep(sleepTimeout);
}
debug(IPCS_DBG,"BaseNodeManagement","After waiting for answer...") ;
if (obj==NULL || loopCpt * sleepTimeout > loopTimeout) {
debug_i(COM_ERR,"BaseNodeManagement","Connexion_AddReferences: service failed with timeout, client=%d",num) ;
status = SOPC_STATUS_TIMEOUT;
goto out ;
}
if (obj->getTypeId() == OpcUaId_ServiceFault) {
ServiceFault * serviceFault = (ServiceFault *)obj ;
status = serviceFault->getResponseHeader()->getServiceResult()->get() ;
delete obj ;
debug_ii(COM_ERR,"BaseNodeManagement","Connexion_AddReferences: service failed with rc=0x%08x for client=%d",status,num) ;
goto out ;
}
if (obj->getTypeId() != OpcUaId_AddReferencesResponse) {
debug_iii(COM_ERR,"BaseQuery","Connexion_AddReferences: bad Response answer with typeId=%d, rc=0x%08x for client=%d",obj->getTypeId(),status,num) ;
ServiceFault * serviceFault = (ServiceFault *)obj ;
status = serviceFault->getResponseHeader()->getServiceResult()->get() ;
delete obj ;
goto out ;
}
debug(IPCS_DBG,"BaseNodeManagement","Connexion_AddReferences: answer is AddReferences") ;
*pRResponse = (AddReferencesResponse *)obj ;
out:
OpcUa_RequestHeader_Clear(&requestHeader) ;
OpcUa_AddReferencesRequest_Clear(&request) ;
return status ;
}
#endif // WITH_NODEMNGT == 1
......
......@@ -279,6 +279,7 @@ MYDLL void Service_CloseSession(
#if (WITH_READ == 1)
#include "lib/Services/Query/OpcUa_IPCS_ReadResponse.h"
MYDLL void Service_Read(
......@@ -316,9 +317,11 @@ MYDLL void Service_Read(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_WRITE == 1)
#include "lib/Services/Query/OpcUa_IPCS_WriteResponse.h"
MYDLL void Service_Write(
......@@ -356,9 +359,11 @@ MYDLL void Service_Write(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_CALL == 1)
#include "lib/Services/Method/OpcUa_IPCS_CallResponse.h"
MYDLL void Service_Call(
......@@ -396,9 +401,11 @@ MYDLL void Service_Call(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_BROWSE == 1)
#include "lib/Services/View/OpcUa_IPCS_BrowseResponse.h"
MYDLL void Service_Browse(
......@@ -436,9 +443,11 @@ MYDLL void Service_Browse(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_REGISTER_UNREGISTER_NODES == 1)
#include "lib/Services/View/OpcUa_IPCS_RegisterNodesResponse.h"
MYDLL void Service_RegisterNodes(
......@@ -476,9 +485,11 @@ MYDLL void Service_RegisterNodes(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_REGISTER_UNREGISTER_NODES == 1)
#include "lib/Services/View/OpcUa_IPCS_UnregisterNodesResponse.h"
MYDLL void Service_UnregisterNodes(
......@@ -516,9 +527,11 @@ MYDLL void Service_UnregisterNodes(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_TRANSLATE_BROWSEPATHS_TO_NODEIDS == 1)
#include "lib/Services/View/OpcUa_IPCS_TranslateBrowsePathsToNodeIdsResponse.h"
MYDLL void Service_TranslateBrowsePathsToNodeIds(
......@@ -556,10 +569,11 @@ MYDLL void Service_TranslateBrowsePathsToNodeIds(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/MonitoredItem/OpcUa_IPCS_CreateMonitoredItemsResponse.h"
MYDLL void Service_CreateMonitoredItems(
......@@ -597,10 +611,11 @@ MYDLL void Service_CreateMonitoredItems(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/MonitoredItem/OpcUa_IPCS_ModifyMonitoredItemsResponse.h"
MYDLL void Service_ModifyMonitoredItems(
......@@ -638,10 +653,12 @@ MYDLL void Service_ModifyMonitoredItems(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/MonitoredItem/OpcUa_IPCS_SetMonitoringModeResponse.h"
MYDLL void Service_SetMonitoringMode(
......@@ -679,10 +696,12 @@ MYDLL void Service_SetMonitoringMode(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/MonitoredItem/OpcUa_IPCS_DeleteMonitoredItemsResponse.h"
MYDLL void Service_DeleteMonitoredItems(
......@@ -720,10 +739,12 @@ MYDLL void Service_DeleteMonitoredItems(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_CreateSubscriptionResponse.h"
MYDLL void Service_CreateSubscription(
......@@ -761,10 +782,11 @@ MYDLL void Service_CreateSubscription(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_ModifySubscriptionResponse.h"
MYDLL void Service_ModifySubscription(
......@@ -802,10 +824,12 @@ MYDLL void Service_ModifySubscription(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_SetPublishingModeResponse.h"
MYDLL void Service_SetPublishingMode(
......@@ -843,10 +867,12 @@ MYDLL void Service_SetPublishingMode(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_PublishResponse.h"
MYDLL void Service_Publish(
......@@ -884,10 +910,12 @@ MYDLL void Service_Publish(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_RepublishResponse.h"
MYDLL void Service_Republish(
......@@ -925,10 +953,12 @@ MYDLL void Service_Republish(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_TransferSubscriptionsResponse.h"
MYDLL void Service_TransferSubscriptions(
......@@ -966,10 +996,12 @@ MYDLL void Service_TransferSubscriptions(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_SUBSCRIPTION == 1)
#include "lib/Services/Subscription/OpcUa_IPCS_DeleteSubscriptionsResponse.h"
MYDLL void Service_DeleteSubscriptions(
......@@ -1007,7 +1039,92 @@ MYDLL void Service_DeleteSubscriptions(
free(responseHeader) ;
free(response) ;
}
#endif
#if (WITH_NODEMNGT == 1)
#include "lib/Services/NodeManagement/OpcUa_IPCS_AddNodesResponse.h"
MYDLL void Service_AddNodes(
uint32_t scConnectionId,
uint32_t requestId,
OpcUa_ResponseHeader * responseHeader,
OpcUa_AddNodesResponse * response)
{
SOPC_StatusCode status = STATUS_OK ;
AddNodesResponse * r = NULL ;
r = AddNodesResponse::fromCtoCpp(&status, *responseHeader, *response) ;
if (status != STATUS_OK) {
debug_i(IPCS_ERR,"Service_AddNodes","Cannot convert from C to Cpp with client=%d",requestId) ;
if (r != NULL)
delete r ;
return ;
}
uint32_t client = r->getResponseHeader()->getRequestHandle()->get() & 0x000000FF ;
if (client > (uint32_t)the_nbClient) {
debug_ii(IPCS_ERR,"Service_AddNodes","Not a client number (<%d): client=%d",the_nbClient,client) ;
delete r ;
return ;
}