Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new s7 #607

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ dependencies {
edgeModule("com.hivemq:hivemq-edge-module-plc4x")
edgeModule("com.hivemq:hivemq-edge-module-opcua")
edgeModule("com.hivemq:hivemq-edge-module-modbus")
edgeModule("com.hivemq:hivemq-edge-module-s7")
}

val hivemqEdgeZip by tasks.registering(Zip::class) {
Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
apache-commonsIO = "2.17.0"
apache-commonsIO = "2.18.0"
apache-commonsCompress = "1.27.1"
apache-commonsLang = "3.17.0"
apache-plc4x = "0.11.0"
Expand All @@ -8,7 +8,7 @@ awaitility = "4.2.2"
bouncycastle = "1.70"
byteBuddy = "1.15.5"
concurrentUnit = "0.4.6"
dagger = "2.52"
dagger = "2.53.1"
dropwizard-metrics = "4.2.28"
equalsVerifier = "3.17.1"
future-converter = "1.2.0"
Expand All @@ -17,6 +17,7 @@ hivemq-edge-adapterSdk = "2024.5"
hivemq-edge-extensionSdk = "2024.5"
hivemq-extensionSdk = "4.30.0"
hivemq-mqttClient = "1.3.3"
iot-communication = "1.5.3"
kotlin = "1.9.25"
jackson = "2.18.0"
jacoco = "0.8.11"
Expand All @@ -43,7 +44,7 @@ slf4j = "2.0.16"
spotBugs = "4.8.5"
stefanBirkner-systemRules = "1.19.0"
swagger-annotations = "2.2.25"
victools-jsonschema = "4.36.0"
victools-jsonschema = "4.37.0"
wiremock = "3.0.1"
zeroAllocationHashing = "0.16"

Expand Down Expand Up @@ -75,6 +76,7 @@ hivemq-edge-adapterSdk = { module = "com.hivemq:hivemq-edge-adapter-sdk", versio
hivemq-edge-extensionSdk = { module = "com.hivemq:hivemq-edge-extension-sdk", version.ref = "hivemq-edge-extensionSdk" }
hivemq-extensionSdk = { module = "com.hivemq:hivemq-extension-sdk", version.ref = "hivemq-extensionSdk" }
hivemq-mqttClient = { module = "com.hivemq:hivemq-mqtt-client", version.ref = "hivemq-mqttClient" }
iot-communication = { module = "com.github.xingshuangs:iot-communication", version.ref = "iot-communication" }
kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
jackson-dataformat-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "jackson" }
Expand Down
1 change: 1 addition & 0 deletions hivemq-edge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ dependencies {
implementation(libs.victools.jsonschema.generator)
implementation(libs.victools.jsonschema.jackson)
implementation(libs.jsonSchemaInferrer)

}

/* ******************** test ******************** */
Expand Down
19 changes: 19 additions & 0 deletions hivemq-edge/src/main/resources/hivemq-edge-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@
"external" : true
}
},
{
"id" : "s7-new",
"version" : "2024.9",
"name" : "S7 to MQTT Protocol Adapter",
"description" : "Connects HiveMQ Edge to S7-300, S7-400, S7-1200 & S7-1500 devices, reading data from the PLC into MQTT.",
"author" : "HiveMQ",
"documentationLink" : {
"url" : "https://docs.hivemq.com/hivemq-edge/protocol-adapters.html#s7-adapter",
"external" : true
},
"provisioningLink" : {
"url" : "https://github.com/hivemq/hivemq-edge/releases",
"external" : true
},
"logoUrl" : {
"url" : "https://raw.githubusercontent.com/hivemq/hivemq-edge/master/modules/hivemq-edge-module-plc4x/src/main/resources/httpd/images/s7-icon.png",
"external" : true
}
},
{
"id" : "ads",
"version" : "2024.7",
Expand Down
13 changes: 13 additions & 0 deletions modules/hivemq-edge-module-s7/HEADER
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2023-present HiveMQ GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
67 changes: 67 additions & 0 deletions modules/hivemq-edge-module-s7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
New:

BOOL(Boolean.class),

BYTE(Byte.class),

INT16(Short.class),
UINT16(Short.class),

INT32(Integer.class),
UINT32(Integer.class),

INT64(Long.class),

REAL(Float.class),

LREAL(Double.class),

TIME(Long.class)

STRING(String.class),

DATE(LocalDate.class),
TIME_OF_DAY(LocalTime.class),
DATE_AND_TIME(LocalDateTime.class),


NULL((short) 0x00, null),

BOOL((short) 0x01, Boolean.class),

BYTE((short) 0x02, Byte.class),
SINT((short) 0x21, Byte.class),

WORD((short) 0x03, Short.class),
USINT((short) 0x11, Short.class),
INT((short) 0x22, Short.class),
WCHAR((short) 0x42, Short.class),

DWORD((short) 0x04, Integer.class),
UINT((short) 0x12, Integer.class),
DINT((short) 0x23, Integer.class),

LWORD((short) 0x05, Long.class),
UDINT((short) 0x13, Long.class),
LINT((short) 0x24, Long.class),

ULINT((short) 0x14, BigInteger.class),

STRING((short) 0x43, String.class),
WSTRING((short) 0x44, String.class),

REAL((short) 0x31, Float.class),
LREAL((short) 0x32, Double.class),

CHAR((short) 0x41, Character.class),


TIME((short) 0x51, Duration.class),
LTIME((short) 0x52, Duration.class),
DATE((short) 0x53, LocalDate.class),
LDATE((short) 0x54, LocalDate.class),
TIME_OF_DAY((short) 0x55, LocalTime.class),
LTIME_OF_DAY((short) 0x56, LocalTime.class),
DATE_AND_TIME((short) 0x57, LocalDateTime.class),
LDATE_AND_TIME((short) 0x58, LocalDateTime.class),
RAW_BYTE_ARRAY((short) 0x71, Byte.class);
213 changes: 213 additions & 0 deletions modules/hivemq-edge-module-s7/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
import nl.javadude.gradle.plugins.license.DownloadLicensesExtension.license
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent.*

plugins {
java
alias(libs.plugins.defaults)
alias(libs.plugins.shadow)
alias(libs.plugins.license)
id("com.hivemq.edge-version-updater")
id("com.hivemq.third-party-license-generator")
}

group = "com.hivemq"

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
exclusiveContent {
forRepository {
maven {
url = uri("https://jitpack.io")
}
}
filter {
includeGroup("com.github.simon622.mqtt-sn")
includeGroup("com.github.simon622")
}
}
}

dependencies {
compileOnly(libs.hivemq.edge.adapterSdk)
compileOnly(libs.apache.commonsIO)
compileOnly(libs.slf4j.api)
compileOnly(libs.jackson.databind)
implementation(libs.iot.communication)

}

dependencies {
testImplementation("com.hivemq:hivemq-edge")
testImplementation(libs.jackson.databind)
testImplementation(libs.hivemq.edge.adapterSdk)
testImplementation(libs.mockito.junitJupiter)
testImplementation(libs.junit.jupiter)

testImplementation(libs.assertj)
testImplementation(libs.awaitility)
}

tasks.test {
useJUnitPlatform()
testLogging {
events = setOf(STARTED, PASSED, FAILED, SKIPPED, STANDARD_ERROR)
exceptionFormat = TestExceptionFormat.FULL
}
}

tasks.register<Copy>("copyAllDependencies") {
shouldRunAfter("assemble")
from(configurations.runtimeClasspath)
into("${buildDir}/deps/libs")
}

tasks.named("assemble") { finalizedBy("copyAllDependencies") }

/* ******************** artifacts ******************** */

val releaseBinary: Configuration by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("binary"))
attribute(Usage.USAGE_ATTRIBUTE, objects.named("release"))
}
}

val thirdPartyLicenses: Configuration by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named("third-party-licenses"))
}
}

artifacts {
add(releaseBinary.name, tasks.shadowJar)
add(thirdPartyLicenses.name, tasks.updateThirdPartyLicenses.flatMap { it.outputDirectory })
}

/* ******************** compliance ******************** */

license {
header = file("HEADER")
mapping("java", "SLASHSTAR_STYLE")
}

downloadLicenses {
aliases = mapOf(
license("Apache License, Version 2.0", "https://opensource.org/licenses/Apache-2.0") to listOf(
"Apache 2",
"Apache 2.0",
"Apache-2.0",
"Apache License 2.0",
"Apache License, 2.0",
"Apache License v2.0",
"Apache License, Version 2",
"Apache License Version 2.0",
"Apache License, Version 2.0",
"Apache License, version 2.0",
"The Apache License, Version 2.0",
"Apache Software License - Version 2.0",
"Apache Software License, version 2.0",
"The Apache Software License, Version 2.0"
),
license("MIT License", "https://opensource.org/licenses/MIT") to listOf(
"MIT License",
"MIT license",
"The MIT License",
"The MIT License (MIT)"
),
license("CDDL, Version 1.0", "https://opensource.org/licenses/CDDL-1.0") to listOf(
"CDDL, Version 1.0",
"Common Development and Distribution License 1.0",
"COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0",
license("CDDL", "https://glassfish.dev.java.net/public/CDDLv1.0.html")
),
license("CDDL, Version 1.1", "https://oss.oracle.com/licenses/CDDL+GPL-1.1") to listOf(
"CDDL 1.1",
"CDDL, Version 1.1",
"Common Development And Distribution License 1.1",
"CDDL+GPL License",
"CDDL + GPLv2 with classpath exception",
"Dual license consisting of the CDDL v1.1 and GPL v2",
"CDDL or GPLv2 with exceptions",
"CDDL/GPLv2+CE"
),
license("LGPL, Version 2.0", "https://opensource.org/licenses/LGPL-2.0") to listOf(
"LGPL, Version 2.0",
"GNU General Public License, version 2"
),
license("LGPL, Version 2.1", "https://opensource.org/licenses/LGPL-2.1") to listOf(
"LGPL, Version 2.1",
"LGPL, version 2.1",
"GNU Lesser General Public License version 2.1 (LGPLv2.1)",
license("GNU Lesser General Public License", "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html")
),
license("LGPL, Version 3.0", "https://opensource.org/licenses/LGPL-3.0") to listOf(
"LGPL, Version 3.0",
"Lesser General Public License, version 3 or greater"
),
license("EPL, Version 1.0", "https://opensource.org/licenses/EPL-1.0") to listOf(
"EPL, Version 1.0",
"Eclipse Public License - v 1.0",
"Eclipse Public License - Version 1.0",
license("Eclipse Public License", "http://www.eclipse.org/legal/epl-v10.html")
),
license("EPL, Version 2.0", "https://opensource.org/licenses/EPL-2.0") to listOf(
"EPL 2.0",
"EPL, Version 2.0"
),
license("EDL, Version 1.0", "https://www.eclipse.org/org/documents/edl-v10.php") to listOf(
"EDL 1.0",
"EDL, Version 1.0",
"Eclipse Distribution License - v 1.0"
),
license("BSD 3-Clause License", "https://opensource.org/licenses/BSD-3-Clause") to listOf(
"BSD 3-clause",
"BSD-3-Clause",
"BSD 3-Clause License",
"3-Clause BSD License",
"New BSD License",
license("BSD", "http://asm.ow2.org/license.html"),
license("BSD", "http://asm.objectweb.org/license.html"),
license("BSD", "LICENSE.txt")
),
license("Bouncy Castle License", "https://www.bouncycastle.org/licence.html") to listOf(
"Bouncy Castle Licence"
),
license("W3C License", "https://opensource.org/licenses/W3C") to listOf(
"W3C License",
"W3C Software Copyright Notice and License",
"The W3C Software License"
),
license("CC0", "https://creativecommons.org/publicdomain/zero/1.0/") to listOf(
"CC0",
"Public Domain"
)
)

dependencyConfiguration = "runtimeClasspath"
}

tasks.updateThirdPartyLicenses {
dependsOn(tasks.downloadLicenses)
projectName.set(project.name)
group = "license"
dependencyLicense.set(tasks.downloadLicenses.get().xmlDestination.resolve("dependency-license.xml"))
outputDirectory.set(layout.buildDirectory.dir("distribution/third-party-licenses"))
}

val javaComponent = components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements.get()) {
skip()
}

5 changes: 5 additions & 0 deletions modules/hivemq-edge-module-s7/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version=2024.8-SNAPSHOT

# Enable build cache.
org.gradle.caching=true
org.gradle.jvmargs=-Xmx1024M
Loading
Loading