[570829] Fix opc module compilation errors and deadlock bug

opc da module has some compilation errors and deadlock problems.
fix opc module compilation errors and deadlock bug

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570829
Change-Id: I7d4f791b0c0236d03f15049cc64697bdd724acb3
Signed-off-by: yguo1s3 <guoys@hitrobotgroup.com>
diff --git a/src/com/opc/opccomlayer.cpp b/src/com/opc/opccomlayer.cpp
index 4bf43d9..abd634d 100644
--- a/src/com/opc/opccomlayer.cpp
+++ b/src/com/opc/opccomlayer.cpp
@@ -1,13 +1,14 @@
 /*******************************************************************************

- * Copyright (c) 2012 -2014 AIT, ACIN, fortiss GmbH

- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
+ * Copyright (c) 2012 -2021 AIT, ACIN, fortiss GmbH, Hit robot group

+ * This program and the accompanying materials are made available under the

+ * terms of the Eclipse Public License 2.0 which is available at

+ * http://www.eclipse.org/legal/epl-2.0.

+ *

  * SPDX-License-Identifier: EPL-2.0

  *

  * Contributors:

  *   Filip Andren, Patrick Smejkal, Alois Zoitl, Martin Melik-Merkumians - initial API and implementation and/or initial documentation

+ *   ys guo - Fix opc module compilation errors and deadlock bug

  *******************************************************************************/

 #include "opccomlayer.h"

 #include "../../arch/devlog.h"

@@ -387,7 +388,7 @@
   }

 

   void COpcComLayer::convertInputData(void *pa_pData, unsigned int pa_nSize){

-    //CIEC_ANY *apoSDs =  static_cast<CIEC_ANY*>(pa_pData);

+    CIEC_ANY *apoSDs =  static_cast<CIEC_ANY*>(pa_pData);

     unsigned int nrSDs = pa_nSize;

     unsigned int sdIndex = 0;

 

@@ -395,11 +396,10 @@
     TOpcProcessVarList::Iterator itEnd = m_lFBInputVars.end();

 

     while(sdIndex < nrSDs && it_var != itEnd){

- //     CIEC_ANY *dataIn = &apoSDs[sdIndex];

+      CIEC_ANY *dataIn = &apoSDs[sdIndex];

       Variant newVariant;

-      //unsigned int valueSize = 0;

 

-    //valueSize = getInputValueSize(dataIn, &newVariant);;

+	  getInputValueSize(dataIn, &newVariant);;

 

       it_var->setNewValue(newVariant);

 

diff --git a/src/com/opc/opcconnection.cpp b/src/com/opc/opcconnection.cpp
index 32d636a..6aa4810 100644
--- a/src/com/opc/opcconnection.cpp
+++ b/src/com/opc/opcconnection.cpp
@@ -1,13 +1,14 @@
 /*******************************************************************************

- * Copyright (c) 2012 -2014 AIT, fortiss GmbH

- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
+ * Copyright (c) 2012 -2014 AIT, fortiss GmbH, Hit robot group

+ * This program and the accompanying materials are made available under the

+ * terms of the Eclipse Public License 2.0 which is available at

+ * http://www.eclipse.org/legal/epl-2.0.

+ *

  * SPDX-License-Identifier: EPL-2.0

  *

  * Contributors:

  *   Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation

+ *   ys guo - Fix opc module compilation errors and deadlock bug

  *******************************************************************************/

 #include "opcconnection.h"

 #include "opcconnectionimpl.h"

@@ -156,20 +157,17 @@
     //m_eConnectionEvent = e_Disconnected;

 

   if(!m_bBlockingConnect){

-    m_oSync.lock();

 

     TOpcGroupMapList::Iterator itEnd = m_lOpcGroupMapList.end();

     for(TOpcGroupMapList::Iterator it = m_lOpcGroupMapList.begin(); it != itEnd; ++it){

       m_eventHandler->executeComCallback((*it)->m_nCallbackDesc);

     }

 

-    m_oSync.unlock();

   }

 }

 

 void COpcConnection::response_dataReceived(const char *pa_acGroupName, TItemDataList & pa_lItemDataList){

   // Loop through OpcGroups

-  m_oSync.lock();

   TOpcGroupMapList::Iterator itEnd_group = m_lOpcGroupMapList.end();

   for(TOpcGroupMapList::Iterator it_group = m_lOpcGroupMapList.begin(); it_group != itEnd_group; ++it_group){

 

@@ -213,7 +211,6 @@
       break;

     }

   }

-  m_oSync.unlock();

 }

 

 void COpcConnection::response_itemAdded(COpcProcessVar* pa_pOpcItem){

diff --git a/src/com/opc/opcconnectionhandler.cpp b/src/com/opc/opcconnectionhandler.cpp
index 910b930..8ddddca 100644
--- a/src/com/opc/opcconnectionhandler.cpp
+++ b/src/com/opc/opcconnectionhandler.cpp
@@ -1,18 +1,21 @@
 /*******************************************************************************

- * Copyright (c) 2012 -2014 AIT, fortiss GmbH

- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
+ * Copyright (c) 2012 -2014 AIT, fortiss GmbH, Hit robot group

+ * This program and the accompanying materials are made available under the

+ * terms of the Eclipse Public License 2.0 which is available at

+ * http://www.eclipse.org/legal/epl-2.0.

+ *

  * SPDX-License-Identifier: EPL-2.0

  *

  * Contributors:

  *   Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation

+ *   ys guo - Fix opc module compilation errors and deadlock bug

  *******************************************************************************/

 #include "opcconnectionhandler.h"

 #include "opcconnection.h"

 #include <extevhandlerhelper.h>

 

+#include "opceventhandler.h"

+#include "commfb.h"

 using namespace forte::com_infra;

 

 DEFINE_SINGLETON(COpcConnectionHandler);

@@ -32,7 +35,7 @@
 

   COpcConnection *newConnection = findOpcConnection(pa_acHost, pa_acServerName);

   if(newConnection == NULL){

-    newConnection = new COpcConnection(pa_acHost, pa_acServerName, getExtEvHandler<COpcEventHandler>(*pa_pComCallback->getCommFB()));

+    newConnection = new COpcConnection(pa_acHost, pa_acServerName, &(getExtEvHandler<COpcEventHandler>(*pa_pComCallback->getCommFB())));

 

     m_lOpcConnectionList.pushBack(newConnection);

   }

diff --git a/src/com/opc/opceventhandler.cpp b/src/com/opc/opceventhandler.cpp
index f2ec4fc..cc40f78 100644
--- a/src/com/opc/opceventhandler.cpp
+++ b/src/com/opc/opceventhandler.cpp
@@ -1,13 +1,14 @@
 /*******************************************************************************

- * Copyright (c) 2012 - 2014 AIT, fortiss GmbH

- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License 2.0 which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
+ * Copyright (c) 2012 - 2014 AIT, fortiss GmbH, Hit robot group

+ * This program and the accompanying materials are made available under the

+ * terms of the Eclipse Public License 2.0 which is available at

+ * http://www.eclipse.org/legal/epl-2.0.

+ *

  * SPDX-License-Identifier: EPL-2.0

  *

  * Contributors:

  *   Filip Andren, Alois Zoitl - initial API and implementation and/or initial documentation

+ *   ys guo - Fix opc module compilation errors and deadlock bug

  *******************************************************************************/

 #include "opceventhandler.h"

 #include "../core/devexec.h"

@@ -22,7 +23,7 @@
 COpcEventHandler::COpcEventHandler(CDeviceExecution& pa_poDeviceExecution) : CExternalEventHandler(pa_poDeviceExecution)  {

   this->start();

   // Sleep to allow new thread to start

-  CThread::sleep(100);

+  CThread::sleepThread(100);

 }

 

 COpcEventHandler::~COpcEventHandler(){