blob: 529ef8167bcab8461f8023363ad21050e7dac829 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2014, 2021 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, Monika Wenger, Jose Cabral
- initial API and implementation and/or initial documentation
Tibalt Zhao
- Update with visual studio code and msbuildtools.
-->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>OPC DA</title>
<link rel="stylesheet" type="text/css" href="../help.css">
</head>
<body>
<h1 id="topOfPage">OPC DA</h1>
<p>This section will show you how to create an OPC DA Client with 4DIAC and how to use it with FORTE. Download the following packages:</p>
<ul>
<li><a href="https://github.com/Tibalt/OPC_DA.git" target="_blank">OPC Client library</a> release 0.4</li>
<li><a href="http://www.boost.org" target="_blank">Boost Lexical Cast</a></li>
<li><a href="https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16" target="_blank">Visual studio buildtools 2019</a></li>
</ul>
<h2>Prepare and compile OPC Client Toolkit</h2>
<ol>
<li>Unzip Boost C++ Libraries</li>
<li id=msbuildtools>Install visual studio build tools with the components shown in the below. Since <a href="https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015?redirectedfrom=MSDN&view=msvc-160#mfc-and-atl" target="_blank"> Visual studio 2013</a>, atls.lib and atlsd.lib are unified as atls.lib which together with headers could be detected by the msvc, so that no need to specify in CMakeLists.txt for OPC module.
<div><img src="../../html/communication/img/opc_VSBuildtoolsInstallation.png" alt="VS Properties"/></div>
</li>
<li>Clone OPC Client, check out to master branch and open the OPCClientToolKit project in Visual Studio Code, be noticed that Visual Studio Code should be started with visual studio tool chains awared, one way is that start Visual Studio Code in "Developer Command Prompt for VS 2019" shown as below</li>
<div><img src="../../html/communication/img/opc_startVSCode.png" alt="VS Properties"/></div>
<li>Build project with ctrl+shift+B and choose debug or release which is same with forte.</li>
<li>Create the following folder structure:
<ul>
<li>[opcclientroot]/include - put header files from OPCClientToolKit project here </li>
<li>[opcclientroot]/lib - OPCClientToolkit.lib </li>
</ul>
</li>
</ol>
<h2>Compile FORTE with OPC DA Client Support</h2>
<ol>
<li>Create a MS Visual Studio Code Project of FORTE with CMake as described in <a href="../../html/installation/visualStudioCode.html" target="_blank">Compiling and Debugging FORTE with MS Visual Studio Code</a> and add the following variables in settings.json which are required for OPC Client support:
<ul>
<li> "FORTE_COM_OPC":"ON",</li>
<li>"FORTE_COM_OPC_LIB_ROOT": "Your path to opc lib root",</li>
<li>"FORTE_COM_OPC_BOOST_ROOT": "Your path to boost root",</li>
</ul>
</li>
<li>Open FORTE Project with MS Visual Studio Code. </li>
<li><a href="../../html/installation/visualStudioCode.html">compile or debug</a> FORTE</li>
</ol>
<h2>Create OPC Client</h2>
<p>Start the 4DIAC-IDE and create a new <span class="element61499">System</span> with a new <span class="element61499">Application</span> for one <span class="element61499">Device</span>. Add a <span class="specificText">CLIENT_1</span> Function Block to the <span class="element61499">Application</span>, set the following input values, and map it to the hardware.</p>
<ul>
<li>QI = 1</li>
<li>ID = opc[localhost:FestoDidactic.EzOPC.2:2000:0.01:VirtualPLC.EB0:VirtualPLC.AB0]</li>
<li>SD_1 = BYTE#210</li>
</ul>
<p>whereas the ID input has the following format:</p>
<div class="code">opc[host:serverName:updateRate:deadBand:fbInputItems:fbOutputItems]</div>
<ul>
<li><span class="inlineTitle">host</span>: address to computer with OPC server </li>
<li><span class="inlineTitle">serverName</span>: OPC server name, e.g. Matrikon.OPC.Simulation </li>
<li><span class="inlineTitle">updateRate</span>: update frequency in milliseconds </li>
<li><span class="inlineTitle">deadBand</span>: dead band used for update of value (same unit as value) </li>
<li><span class="inlineTitle">fbInputItems/fbOutputItems</span>: items to be added, items should be separated with a comma e.g. </li>
</ul>
<p>Change to the <span class="view4diac">Deployment perspective</span>, start Forte and download the Application. Switch the System into online mode and start watching the in- and outputs. For further information about <a href="../../html/4diacIDE/use4diacLocally.html#monitoringApplication">Monitoring functionalities</a> follow the link.</p>
<p>After triggering the INIT event, the OPC-client tries to connect with the OPC-server. In this example the OPC-server is "FestoDidactic.EzOPC.2". It is a tool from Festo and can be downloaded <a href="http://www.festo-didactic.com/de-de/service/software/vollversion-demos/ezopc.htm" target="_blank">here</a>.</p>
<img src="../../html/communication/img/opc_fordiacTrigger.png" alt="4DIAC Trigger"/>
<p>When the connection is established, a window of the server pops up.</p>
<img src="../../html/communication/img/opc_festoOPCserver.png" alt="Festo OPC Server"/>
<p>Now trigger the REQ event to send the data from client to server. "BYTE#210" should be send to the server's port "VirtualPLC.EB0". Click to "Virtual Controller" tab to check if the OPC server has received the information.</p>
<img src="../../html/communication/img/opc_festoOPCserverIO.png" alt="Festo OPC Server IO"/>
<h1>Where to go from here?</h1>
<p>Go back to Protocols index:</p>
<p><a href="../../html/communication/communicationIndex.html">Communication Index</a></p>
<p>If you want to go back to the Start Here page, we leave you here a fast access</p>
<p><a href="../../html/startHere/startHere.html">Start Here page</a></p>
<p class="goToTop">Or <a href="#topOfPage">Go to top</a></p>
</body>
</html>