You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2021/08/01 19:18:13 UTC

[plc4x] 08/13: - Added a fix allowing the opc-ua driver to be compiled on windows systems

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/profinet-chris
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit ec66a0ffe274c857892ad757d2a925ab0cfc9a81
Author: cdutz <ch...@c-ware.de>
AuthorDate: Sun Aug 1 19:52:38 2021 +0200

    - Added a fix allowing the opc-ua driver to be compiled on windows systems
---
 protocols/opcua/pom.xml                        | 416 +++++++++++++------------
 protocols/opcua/src/main/xslt/opc-manual.xsl   |  13 +-
 protocols/opcua/src/main/xslt/opc-services.xsl |  12 +-
 protocols/opcua/src/main/xslt/opc-status.xsl   |  12 +-
 4 files changed, 248 insertions(+), 205 deletions(-)

diff --git a/protocols/opcua/pom.xml b/protocols/opcua/pom.xml
index 299f628..f6a10c9 100644
--- a/protocols/opcua/pom.xml
+++ b/protocols/opcua/pom.xml
@@ -17,7 +17,8 @@
   specific language governing permissions and limitations
   under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
   <modelVersion>4.0.0</modelVersion>
 
@@ -33,215 +34,226 @@
   <description>Base protocol specifications for the OPC UA protocol</description>
 
   <build>
-      <plugins>
-          <!-- Fetch the master-data which will be used to translate manufacturer ids to readable names -->
-          <plugin>
-            <groupId>com.googlecode.maven-download-plugin</groupId>
-            <artifactId>download-maven-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>fetch-opc-datatypes</id>
-                <phase>generate-resources</phase>
-                <goals>
-                  <goal>wget</goal>
-                </goals>
-                <configuration>
-                  <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.Types.bsd</url>
-                  <unpack>false</unpack>
-                  <outputDirectory>${project.build.directory}/downloads</outputDirectory>
-                  <outputFileName>Opc.Ua.Types.bsd</outputFileName>
-                  <skipCache>true</skipCache>
-                  <overwrite>true</overwrite>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        <!-- Fetch the master-data which will be used to translate manufacturer ids to readable names -->
-        <plugin>
-          <groupId>com.googlecode.maven-download-plugin</groupId>
-          <artifactId>download-maven-plugin</artifactId>
-          <executions>
-            <execution>
-              <id>fetch-opc-statuscodes</id>
-              <phase>generate-resources</phase>
-              <goals>
-                <goal>wget</goal>
-              </goals>
-              <configuration>
-                <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/StatusCode.csv</url>
-                <unpack>false</unpack>
-                <outputDirectory>${project.build.directory}/downloads</outputDirectory>
-                <outputFileName>StatusCode.csv</outputFileName>
-              </configuration>
-            </execution>
-          </executions>
-        </plugin>
-          <plugin>
-            <groupId>com.googlecode.maven-download-plugin</groupId>
-            <artifactId>download-maven-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>fetch-opc-discriminators</id>
-                <phase>generate-resources</phase>
-                <goals>
-                  <goal>wget</goal>
-                </goals>
-                <configuration>
-                  <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.NodeSet2.Services.xml</url>
-                  <unpack>false</unpack>
-                  <outputDirectory>${project.build.directory}/downloads</outputDirectory>
-                  <outputFileName>Opc.Ua.NodeSet2.Services.xml</outputFileName>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-          <plugin>
-            <groupId>com.googlecode.maven-download-plugin</groupId>
-            <artifactId>download-maven-plugin</artifactId>
-            <executions>
-              <execution>
-                <id>fetch-opc-services-enum</id>
-                <phase>generate-resources</phase>
-                <goals>
-                  <goal>wget</goal>
-                </goals>
-                <configuration>
-                  <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.NodeIds.Services.csv</url>
-                  <unpack>false</unpack>
-                  <outputDirectory>${project.build.directory}/downloads</outputDirectory>
-                  <outputFileName>Opc.Ua.NodeIds.Services.csv</outputFileName>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
+    <plugins>
+      <!-- Fetch the master-data which will be used to translate manufacturer ids to readable names -->
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>fetch-opc-datatypes</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.Types.bsd</url>
+              <unpack>false</unpack>
+              <outputDirectory>${project.build.directory}/downloads</outputDirectory>
+              <outputFileName>Opc.Ua.Types.bsd</outputFileName>
+              <skipCache>true</skipCache>
+              <overwrite>true</overwrite>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- Fetch the master-data which will be used to translate manufacturer ids to readable names -->
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>fetch-opc-statuscodes</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/StatusCode.csv</url>
+              <unpack>false</unpack>
+              <outputDirectory>${project.build.directory}/downloads</outputDirectory>
+              <outputFileName>StatusCode.csv</outputFileName>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>fetch-opc-discriminators</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.NodeSet2.Services.xml</url>
+              <unpack>false</unpack>
+              <outputDirectory>${project.build.directory}/downloads</outputDirectory>
+              <outputFileName>Opc.Ua.NodeSet2.Services.xml</outputFileName>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>fetch-opc-services-enum</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>https://raw.githubusercontent.com/OPCFoundation/UA-Nodeset/v1.04/Schema/Opc.Ua.NodeIds.Services.csv</url>
+              <unpack>false</unpack>
+              <outputDirectory>${project.build.directory}/downloads</outputDirectory>
+              <outputFileName>Opc.Ua.NodeIds.Services.csv</outputFileName>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
 
-        <plugin>
-          <groupId>org.codehaus.mojo</groupId>
-          <artifactId>xml-maven-plugin</artifactId>
-          <version>1.0.2</version>
-          <executions>
-            <execution>
-              <id>transform-services</id>
-              <phase>process-resources</phase>
-              <goals>
-                <goal>transform</goal>
-              </goals>
-            </execution>
-          </executions>
-          <configuration>
-            <transformationSets>
-              <transformationSet>
-                <dir>${project.build.directory}/downloads</dir>
-                <includes>Opc.Ua.Types.bsd</includes>
-                <stylesheet>src/main/xslt/opc-services.xsl</stylesheet>
-                <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
-                <fileMappers>
-                  <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
-                    <targetName>opc-services.mspec</targetName>
-                  </fileMapper>
-                </fileMappers>
-                <parameters>
-                  <parameter>
-                    <name>servicesEnum</name>
-                    <value>${project.build.directory}/downloads/Opc.Ua.NodeIds.Services.csv</value>
-                  </parameter>
-                </parameters>
-                <outputProperties>
-                  <outputProperty>
-                    <name>indent</name>
-                    <value>no</value>
-                  </outputProperty>
-                </outputProperties>
-              </transformationSet>
-              <transformationSet>
-                <dir>${project.build.directory}/downloads</dir>
-                <includes>Opc.Ua.Types.bsd</includes>
-                <stylesheet>src/main/xslt/opc-status.xsl</stylesheet>
-                <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
-                <fileMappers>
-                  <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
-                    <targetName>opc-status.mspec</targetName>
-                  </fileMapper>
-                </fileMappers>
-                <parameters>
-                  <parameter>
-                    <name>statusCodes</name>
-                    <value>${project.build.directory}/downloads/StatusCode.csv</value>
-                  </parameter>
-                </parameters>
-                <outputProperties>
-                  <outputProperty>
-                    <name>indent</name>
-                    <value>no</value>
-                  </outputProperty>
-                </outputProperties>
-              </transformationSet>
-              <transformationSet>
-                <dir>${project.build.directory}/downloads</dir>
-                <includes>Opc.Ua.Types.bsd</includes>
-                <stylesheet>src/main/xslt/opc-manual.xsl</stylesheet>
-                <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
-                <fileMappers>
-                  <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
-                    <targetName>opc-manual.mspec</targetName>
-                  </fileMapper>
-                </fileMappers>
-                <parameters>
-                  <parameter>
-                    <name>services</name>
-                    <value>${project.build.directory}/downloads/Opc.Ua.NodeSet2.Services.xml</value>
-                  </parameter>
-                </parameters>
-                <outputProperties>
-                  <outputProperty>
-                    <name>indent</name>
-                    <value>no</value>
-                  </outputProperty>
-                </outputProperties>
-              </transformationSet>
-              <transformationSet>
-                <dir>${project.build.directory}/downloads</dir>
-                <includes>Opc.Ua.Types.bsd</includes>
-                <stylesheet>src/main/xslt/opc-types.xsl</stylesheet>
-                <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
-                <fileMappers>
-                  <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
-                    <targetName>opc-types.mspec</targetName>
-                  </fileMapper>
-                </fileMappers>
-                <outputProperties>
-                  <outputProperty>
-                    <name>indent</name>
-                    <value>no</value>
-                  </outputProperty>
-                </outputProperties>
-              </transformationSet>
-            </transformationSets>
-          </configuration>
-          <dependencies>
-            <!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
-            <dependency>
-              <groupId>net.sf.saxon</groupId>
-              <artifactId>Saxon-HE</artifactId>
-              <version>10.5</version>
-            </dependency>
-            <dependency>
-              <groupId>org.apache.plc4x</groupId>
-              <artifactId>plc4x-build-utils-language-base-freemarker</artifactId>
-              <version>0.9.0-SNAPSHOT</version>
-            </dependency>
-          </dependencies>
-        </plugin>
-
-      </plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>xml-maven-plugin</artifactId>
+        <version>1.0.2</version>
+        <executions>
+          <execution>
+            <id>transform-services</id>
+            <phase>process-resources</phase>
+            <goals>
+              <goal>transform</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <transformationSets>
+            <transformationSet>
+              <dir>${project.build.directory}/downloads</dir>
+              <includes>Opc.Ua.Types.bsd</includes>
+              <stylesheet>src/main/xslt/opc-services.xsl</stylesheet>
+              <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
+              <fileMappers>
+                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
+                  <targetName>opc-services.mspec</targetName>
+                </fileMapper>
+              </fileMappers>
+              <parameters>
+                <parameter>
+                  <name>osType</name>
+                  <value>${os.suffix}</value>
+                </parameter>
+                <parameter>
+                  <name>servicesEnum</name>
+                  <value>${project.build.directory}/downloads/Opc.Ua.NodeIds.Services.csv</value>
+                </parameter>
+              </parameters>
+              <outputProperties>
+                <outputProperty>
+                  <name>indent</name>
+                  <value>no</value>
+                </outputProperty>
+              </outputProperties>
+            </transformationSet>
+            <transformationSet>
+              <dir>${project.build.directory}/downloads</dir>
+              <includes>Opc.Ua.Types.bsd</includes>
+              <stylesheet>src/main/xslt/opc-status.xsl</stylesheet>
+              <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
+              <fileMappers>
+                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
+                  <targetName>opc-status.mspec</targetName>
+                </fileMapper>
+              </fileMappers>
+              <parameters>
+                <parameter>
+                  <name>osType</name>
+                  <value>${os.suffix}</value>
+                </parameter>
+                <parameter>
+                  <name>statusCodes</name>
+                  <value>${project.build.directory}/downloads/StatusCode.csv</value>
+                </parameter>
+              </parameters>
+              <outputProperties>
+                <outputProperty>
+                  <name>indent</name>
+                  <value>no</value>
+                </outputProperty>
+              </outputProperties>
+            </transformationSet>
+            <transformationSet>
+              <dir>${project.build.directory}/downloads</dir>
+              <includes>Opc.Ua.Types.bsd</includes>
+              <stylesheet>src/main/xslt/opc-manual.xsl</stylesheet>
+              <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
+              <fileMappers>
+                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
+                  <targetName>opc-manual.mspec</targetName>
+                </fileMapper>
+              </fileMappers>
+              <parameters>
+                <parameter>
+                  <name>osType</name>
+                  <value>${os.suffix}</value>
+                </parameter>
+                <parameter>
+                  <name>services</name>
+                  <value>${project.build.directory}/downloads/Opc.Ua.NodeSet2.Services.xml</value>
+                </parameter>
+              </parameters>
+              <outputProperties>
+                <outputProperty>
+                  <name>indent</name>
+                  <value>no</value>
+                </outputProperty>
+              </outputProperties>
+            </transformationSet>
+            <transformationSet>
+              <dir>${project.build.directory}/downloads</dir>
+              <includes>Opc.Ua.Types.bsd</includes>
+              <stylesheet>src/main/xslt/opc-types.xsl</stylesheet>
+              <outputDir>${project.build.outputDirectory}/protocols/opcua</outputDir>
+              <fileMappers>
+                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.MergeFileMapper">
+                  <targetName>opc-types.mspec</targetName>
+                </fileMapper>
+              </fileMappers>
+              <outputProperties>
+                <outputProperty>
+                  <name>indent</name>
+                  <value>no</value>
+                </outputProperty>
+              </outputProperties>
+            </transformationSet>
+          </transformationSets>
+        </configuration>
+        <dependencies>
+          <!-- https://mvnrepository.com/artifact/net.sf.saxon/Saxon-HE -->
+          <dependency>
+            <groupId>net.sf.saxon</groupId>
+            <artifactId>Saxon-HE</artifactId>
+            <version>10.5</version>
+          </dependency>
+          <dependency>
+            <groupId>org.apache.plc4x</groupId>
+            <artifactId>plc4x-build-utils-language-base-freemarker</artifactId>
+            <version>0.9.0-SNAPSHOT</version>
+          </dependency>
+        </dependencies>
+      </plugin>
+    </plugins>
   </build>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.plc4x</groupId>
       <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
       <version>0.9.0-SNAPSHOT</version>
     </dependency>
-
   </dependencies>
 
 </project>
diff --git a/protocols/opcua/src/main/xslt/opc-manual.xsl b/protocols/opcua/src/main/xslt/opc-manual.xsl
index 59b49c9..937bc59 100644
--- a/protocols/opcua/src/main/xslt/opc-manual.xsl
+++ b/protocols/opcua/src/main/xslt/opc-manual.xsl
@@ -38,8 +38,19 @@
 
     <xsl:variable name="originaldoc" select="/"/>
 
+    <xsl:param name="osType"></xsl:param>
+
     <xsl:param name="services"></xsl:param>
-    <xsl:param name="file" select="document($services)"/>
+
+    <!-- Intermediate, to reformat the url on windows systems -->
+    <xsl:param name="servicesUrl">
+        <xsl:choose>
+            <xsl:when test="$osType = 'win'">file:///<xsl:value-of select="replace($services, '\\', '/')"/></xsl:when>
+            <xsl:otherwise><xsl:value-of select="$services"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>
+
+    <xsl:param name="file" select="document($servicesUrl)"/>
 
     <xsl:template match="/">
 // Remark: The different fields are encoded in Little-endian.
diff --git a/protocols/opcua/src/main/xslt/opc-services.xsl b/protocols/opcua/src/main/xslt/opc-services.xsl
index 04fe8b7..472941c 100644
--- a/protocols/opcua/src/main/xslt/opc-services.xsl
+++ b/protocols/opcua/src/main/xslt/opc-services.xsl
@@ -37,9 +37,19 @@
 
     <xsl:variable name="originaldoc" select="/"/>
 
+    <xsl:param name="osType"></xsl:param>
+
     <xsl:param name="servicesEnum"></xsl:param>
 
-    <xsl:param name="servicesEnumFile" select="unparsed-text($servicesEnum)"/>
+    <!-- Intermediate, to reformat the url on windows systems -->
+    <xsl:param name="servicesEnumUrl">
+        <xsl:choose>
+            <xsl:when test="$osType = 'win'">file:///<xsl:value-of select="replace($servicesEnum, '\\', '/')"/></xsl:when>
+            <xsl:otherwise><xsl:value-of select="$servicesEnum"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>
+
+    <xsl:param name="servicesEnumFile" select="unparsed-text($servicesEnumUrl)"/>
 
     <xsl:template match="/">
         <xsl:call-template name="servicesEnumParsing"/>
diff --git a/protocols/opcua/src/main/xslt/opc-status.xsl b/protocols/opcua/src/main/xslt/opc-status.xsl
index af9eac7..ffd2aec 100644
--- a/protocols/opcua/src/main/xslt/opc-status.xsl
+++ b/protocols/opcua/src/main/xslt/opc-status.xsl
@@ -37,9 +37,19 @@
 
     <xsl:variable name="originaldoc" select="/"/>
 
+    <xsl:param name="osType"></xsl:param>
+
     <xsl:param name="statusCodes"></xsl:param>
 
-    <xsl:param name="statusCodeFile" select="unparsed-text($statusCodes)"/>
+    <!-- Intermediate, to reformat the url on windows systems -->
+    <xsl:param name="statusCodesUrl">
+        <xsl:choose>
+            <xsl:when test="$osType = 'win'">file:///<xsl:value-of select="replace($statusCodes, '\\', '/')"/></xsl:when>
+            <xsl:otherwise><xsl:value-of select="$statusCodes"/></xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>
+
+    <xsl:param name="statusCodeFile" select="unparsed-text($statusCodesUrl)"/>
 
     <xsl:template match="/">
         <xsl:call-template name="statusCodeParsing"/>