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

Refactor / improve python modbus #1581

Merged
merged 173 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 165 commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
a5d746d
fix(plc4py/umas): Start to add write support
hutcheb Mar 7, 2024
ebfe381
build(deps): bump github.com/stretchr/testify in /plc4go (#1439)
dependabot[bot] Mar 11, 2024
02a6f24
build(deps): bump golang.org/x/tools from 0.18.0 to 0.19.0 in /plc4go…
dependabot[bot] Mar 11, 2024
4e1f5bc
build(deps): bump logback.version from 1.5.0 to 1.5.1 (#1435)
dependabot[bot] Mar 11, 2024
f65dbd7
build(deps): bump github.com/gdamore/tcell/v2 in /plc4go (#1438)
dependabot[bot] Mar 11, 2024
eb662d4
build(deps): bump golang.org/x/net from 0.21.0 to 0.22.0 in /plc4go (…
dependabot[bot] Mar 11, 2024
061ebfc
build(deps): bump jakarta.activation:jakarta.activation-api (#1436)
dependabot[bot] Mar 11, 2024
39538e0
fix(plc4j/genericcan) Fix of generic CAN driver and CAN transports af…
splatch Mar 11, 2024
9352b0a
chore: Disabled a flaky test in GO
chrisdutz Mar 13, 2024
539d252
docs: Updated the url for the opie tool
chrisdutz Mar 13, 2024
604ba8a
chore: Updated vendor ids
chrisdutz Mar 13, 2024
22b3099
docs: Added some information on the site plugin and the asciidoctor p…
chrisdutz Mar 13, 2024
0f5f2f4
chore: Updated vendor ids
chrisdutz Mar 13, 2024
5723fad
build: Continued fine-tuning the reproducible build release-scripts.
chrisdutz Mar 13, 2024
52009e3
chore: Updated vendor ids
chrisdutz Mar 13, 2024
8323caf
feat: The S7 driver now returns supporting S7, if the connected devic…
chrisdutz Mar 13, 2024
53adbaf
fix: Fixed logging in the example.
chrisdutz Mar 13, 2024
ba11ff1
refactor: Made the "protocol" accessible in the AbstractPlcConnection
chrisdutz Mar 13, 2024
215d1bf
refactor: Added S7-400 to the list of supported devices.
chrisdutz Mar 13, 2024
49b882d
fix: Fixed the dependency usage error.
chrisdutz Mar 13, 2024
bc874ea
Fix/s7async (#1451)
glcj Mar 15, 2024
575bf83
build(deps): bump com.google.googlejavaformat:google-java-format (#1449)
dependabot[bot] Mar 18, 2024
3a15b84
build(deps): bump logback.version from 1.5.1 to 1.5.3 (#1448)
dependabot[bot] Mar 18, 2024
e295259
build(deps): bump com.gradle:common-custom-user-data-maven-extension …
dependabot[bot] Mar 18, 2024
3b21a8c
Update PlcRawByteArray.java (#1453)
mrwhy-orig Mar 18, 2024
a90e492
chore: Disabled some OPC-UA tests, that were continuously failing the…
chrisdutz Mar 18, 2024
1f20465
chore: Disabled some OPC-UA tests, that were continuously failing the…
chrisdutz Mar 18, 2024
55efeec
feat: Added a new flag allowing to disable tests on Jenkins. Added th…
chrisdutz Mar 18, 2024
f596a26
build(deps-dev): bump org.apache.commons:commons-compress (#1456)
dependabot[bot] Mar 20, 2024
f694abf
build(deps): bump org.awaitility:awaitility from 4.2.0 to 4.2.1 (#1455)
dependabot[bot] Mar 20, 2024
8933491
docs: Added "slave-id" to the description of the unit-identifier.
chrisdutz Mar 21, 2024
195e4ad
chore: Disabled the OpcuaPlcDriverTest as it also seems to regularly …
chrisdutz Mar 21, 2024
0b68f16
build(deps): bump org.springframework.boot:spring-boot-maven-plugin (…
dependabot[bot] Mar 22, 2024
0511e3c
build(deps): bump com.google.errorprone:error_prone_annotations (#1461)
dependabot[bot] Mar 22, 2024
07350bd
build(deps): bump org.springframework.boot:spring-boot-dependencies (…
dependabot[bot] Mar 22, 2024
11920e1
docs: Updated some documentation on the code-generation.
chrisdutz Mar 22, 2024
e594988
refactor: Renamed the paddingField paddingCondition to timesPadding
chrisdutz Mar 22, 2024
ed8dae0
chore: Removed some unneeded code.
chrisdutz Mar 22, 2024
934aa11
chore: Updated vendor ids
chrisdutz Mar 22, 2024
ae38064
chore: Cleaned up in the sandbox
chrisdutz Mar 23, 2024
016ad77
fix(plc4py): type extensions module added to setup.py
hutcheb Mar 23, 2024
80b75aa
fix(plc4py): Move out of sandbox
hutcheb Mar 23, 2024
dab01f0
chore(sandbox): Remove the Sandbox Directory
hutcheb Mar 23, 2024
90d671b
chore(plc4px): Remove manual test
hutcheb Mar 23, 2024
cb5714b
feat(plc4x/modbus): Add support for unit-id option for modbus tags.
splatch Mar 27, 2024
2ea34de
build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1467)
dependabot[bot] Apr 2, 2024
71fb92f
build(deps): bump org.cyclonedx:cyclonedx-maven-plugin (#1466)
dependabot[bot] Apr 2, 2024
508a18c
build(deps): bump org.apache.maven.plugins:maven-remote-resources-plu…
dependabot[bot] Apr 2, 2024
3c03181
build(deps): bump org.aspectj:aspectjweaver from 1.9.21.1 to 1.9.22 (…
dependabot[bot] Apr 3, 2024
3652bb4
build(deps): bump jakarta.xml.bind:jakarta.xml.bind-api (#1474)
dependabot[bot] Apr 3, 2024
86060a1
build(deps): bump com.google.guava:guava from 33.0.0-jre to 33.1.0-jr…
dependabot[bot] Apr 3, 2024
efc10e9
build(deps): bump golang.org/x/net from 0.22.0 to 0.23.0 in /plc4go (…
dependabot[bot] Apr 4, 2024
3c2b30c
build(deps): bump mockito.version from 5.10.0 to 5.11.0 (#1478)
dependabot[bot] Apr 4, 2024
0157fe0
build(deps): bump io.swagger:swagger-annotations from 1.6.13 to 1.6.1…
dependabot[bot] Apr 4, 2024
a47ea37
build(deps): bump org.sonarsource.scanner.maven:sonar-maven-plugin (#…
dependabot[bot] Apr 4, 2024
2489556
Update PlcCHAR.java add Character type check to of method (#1489)
mrwhy-orig Apr 5, 2024
2e3d44b
build(deps): bump golang.org/x/net from 0.23.0 to 0.24.0 in /plc4go (…
dependabot[bot] Apr 5, 2024
da2aa30
build(deps): bump groovy.version from 4.0.18 to 4.0.20 (#1486)
dependabot[bot] Apr 5, 2024
2da79f2
build(deps): bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.1…
dependabot[bot] Apr 5, 2024
03a2588
build(deps): bump org.apache.maven.plugins:maven-source-plugin (#1484)
dependabot[bot] Apr 5, 2024
6f9bcce
build(deps): bump golang.org/x/tools from 0.19.0 to 0.20.0 in /plc4go…
dependabot[bot] Apr 5, 2024
fb0e145
fix: A compilation error.
chrisdutz Apr 5, 2024
cc17fe5
refactor: Moved the examples, integrations and other extra stuff into…
chrisdutz Apr 5, 2024
820d3aa
fix: Disabling "Trivy Scan" workflow as it's randomy failing and I ca…
chrisdutz Apr 5, 2024
b67f559
chore: Updated the issue-tracker settings to point to GitHub instead …
chrisdutz Apr 5, 2024
33030f9
build(deps): bump nl.jqno.equalsverifier:equalsverifier (#1490)
dependabot[bot] Apr 8, 2024
373fd86
build(deps): bump org.apache.maven.plugins:maven-assembly-plugin (#1491)
dependabot[bot] Apr 8, 2024
e818b67
fix(plc4py): Fix exception on closing the connection
hutcheb Apr 9, 2024
c41e3a3
fix(plc4py): Fix connection lost exception being raised
hutcheb Apr 9, 2024
57c52e6
fix(plc4py): set test to manual
hutcheb Apr 9, 2024
e229c54
fix(plc4py): Got rid of returning future, starting to understand it a…
hutcheb Apr 9, 2024
a238c00
build(deps): bump jakarta.annotation:jakarta.annotation-api (#1494)
dependabot[bot] Apr 9, 2024
a0d41fd
build(deps): bump io.netty:netty-bom from 4.1.107.Final to 4.1.108.Fi…
dependabot[bot] Apr 9, 2024
24e59ef
fix(plc4py): Add to dependabot
hutcheb Apr 9, 2024
bdaacf2
build(deps): bump pytest-mock from 3.12.0 to 3.14.0 in /plc4py (#1501)
dependabot[bot] Apr 9, 2024
65a2325
build(deps): bump identify from 2.5.33 to 2.5.35 in /plc4py (#1500)
dependabot[bot] Apr 9, 2024
9e2fd21
build(deps): bump packaging from 23.2 to 24.0 in /plc4py (#1499)
dependabot[bot] Apr 9, 2024
debb8a6
build(deps): bump pytest-asyncio from 0.23.5 to 0.23.6 in /plc4py (#1…
dependabot[bot] Apr 9, 2024
1c27f79
build(deps): bump build from 1.0.3 to 1.2.1 in /plc4py (#1496)
dependabot[bot] Apr 9, 2024
004c2f8
fix(plc4py): Use packet length estimator to be able to handle multipl…
hutcheb Apr 12, 2024
ecfadf9
Update apache-kafka links to plc4x extra
ottlukas Apr 10, 2024
adf1568
feat(plc4go): change to TestingLog interface for TestLogger
sruehl Apr 10, 2024
2599310
build(deps): bump com.fasterxml.jackson.datatype:jackson-datatype-jsr…
dependabot[bot] Apr 11, 2024
a095a17
build(deps): bump com.gradle:common-custom-user-data-maven-extension …
dependabot[bot] Apr 11, 2024
84d6802
build(deps): bump mypy from 1.8.0 to 1.9.0 in /plc4py (#1502)
dependabot[bot] Apr 11, 2024
b85c765
build(deps): bump black from 24.1.1 to 24.3.0 in /plc4py (#1503)
dependabot[bot] Apr 11, 2024
6a6bade
build(deps): bump filelock from 3.13.1 to 3.13.4 in /plc4py (#1504)
dependabot[bot] Apr 11, 2024
6911bc9
build(deps): bump virtualenv from 20.25.0 to 20.25.1 in /plc4py (#1506)
dependabot[bot] Apr 11, 2024
7fb8b42
build(deps): bump typing-extensions from 4.9.0 to 4.11.0 in /plc4py (…
dependabot[bot] Apr 11, 2024
6f4bed9
build(deps): bump org.apache.maven.plugins:maven-invoker-plugin (#1514)
dependabot[bot] Apr 12, 2024
e5b90c6
build(deps): bump org.asciidoctor:asciidoctorj from 2.5.11 to 2.5.12 …
dependabot[bot] Apr 12, 2024
0f9520a
build(deps): bump com.google.googlejavaformat:google-java-format (#1516)
dependabot[bot] Apr 12, 2024
5fa88da
build(deps): bump coverage from 7.4.1 to 7.4.4 in /plc4py (#1511)
dependabot[bot] Apr 12, 2024
cb15079
build(deps): bump pytest from 8.0.0 to 8.1.1 in /plc4py (#1510)
dependabot[bot] Apr 12, 2024
906fa87
build(deps): bump pre-commit from 3.6.0 to 3.7.0 in /plc4py (#1512)
dependabot[bot] Apr 12, 2024
e551fb7
build(deps): bump pip-tools from 7.3.0 to 7.4.1 in /plc4py (#1513)
dependabot[bot] Apr 12, 2024
4da7244
fix(plc4j/ads): Fixed List serialization passing invalid datatype for…
IsmoLeszczynski Apr 12, 2024
b7529aa
feat: Changed the ManualTest to allow enabling read and write request…
chrisdutz Apr 12, 2024
dd5aad4
fix(plc4j/opcua): Cleanup discovery connection resources.
splatch Apr 12, 2024
3589478
fix(plc4j/ads): Invalid size writing multiple tags (#1524)
IsmoLeszczynski Apr 13, 2024
d4c2066
fix: Added the struct back to the manual ads test.
chrisdutz Apr 13, 2024
8a2f138
fix(plc4j/opcua): Make sure UA subscription acknowledges are retained…
splatch Apr 14, 2024
c98e9fc
chore: Updated vendor ids
chrisdutz Apr 14, 2024
ea61a35
chore: Addressed most high severity sonarcloud issues
chrisdutz Apr 14, 2024
257aff4
build(deps): bump black from 24.3.0 to 24.4.0 in /plc4py (#1528)
dependabot[bot] Apr 15, 2024
beaf82b
build(deps): bump org.apache.maven.plugins:maven-compiler-plugin (#1525)
dependabot[bot] Apr 15, 2024
1faae83
build(deps): bump org.codehaus.plexus:plexus-compiler-api (#1526)
dependabot[bot] Apr 15, 2024
11267a2
build(deps): bump com.google.errorprone:error_prone_annotations (#1527)
dependabot[bot] Apr 15, 2024
73913e0
build(deps): bump logback.version from 1.5.3 to 1.5.5 (#1531)
dependabot[bot] Apr 16, 2024
0872d89
build(deps): bump io.netty:netty-bom from 4.1.108.Final to 4.1.109.Fi…
dependabot[bot] Apr 16, 2024
384471f
build(deps): bump groovy.version from 4.0.20 to 4.0.21 (#1533)
dependabot[bot] Apr 16, 2024
cd38cb0
fix(plc4j/ads): Fixed connection hang on exception (#1530)
IsmoLeszczynski Apr 16, 2024
08f9260
build(deps): bump virtualenv from 20.25.1 to 20.25.2 in /plc4py (#1537)
dependabot[bot] Apr 17, 2024
6d42733
Remove Protocols section in developers section (duplicate from
ottlukas Apr 17, 2024
af6a4b8
Delete src/site/asciidoc/developers/protocols directory
ottlukas Apr 17, 2024
0ab6465
chore: Updated vendor ids
chrisdutz Apr 17, 2024
1c320f5
feat: Added a default-payload-byte-order option to the modbus driver …
chrisdutz Apr 17, 2024
63094a3
chore: Addressed more of the high severity sonarcloud issues
chrisdutz Apr 17, 2024
d8720ad
build(deps): bump slf4j.version from 2.0.12 to 2.0.13 (#1536)
dependabot[bot] Apr 17, 2024
b9846ed
build(deps): bump org.jetbrains.kotlin:kotlin-stdlib-jdk8 (#1534)
dependabot[bot] Apr 17, 2024
60f079d
Revert "Remove Protocols section in developers section (duplicate from "
ottlukas Apr 17, 2024
ab46e7a
Revert "Delete src/site/asciidoc/developers/protocols directory"
ottlukas Apr 17, 2024
c8bb411
Modbus in progress
ottlukas Apr 18, 2024
8e59aec
add index for protocol usage page
ottlukas Apr 18, 2024
12e646f
Add eip
ottlukas Apr 18, 2024
0d3ee01
fixing URLs
ottlukas Apr 18, 2024
5256375
build(deps): bump org.apache.commons:commons-configuration2 (#1541)
dependabot[bot] Apr 18, 2024
663034d
build(deps): bump org.apache.karaf.tooling:karaf-maven-plugin (#1539)
dependabot[bot] Apr 18, 2024
06cda0f
build(deps): bump com.googlecode.maven-download-plugin:download-maven…
dependabot[bot] Apr 18, 2024
ea50932
build(deps): bump virtualenv from 20.25.2 to 20.25.3 in /plc4py (#1542)
dependabot[bot] Apr 18, 2024
4cdd64a
build(deps): bump net.bytebuddy:byte-buddy from 1.14.12 to 1.14.13 (#…
dependabot[bot] Apr 19, 2024
71121e3
build(deps-dev): bump commons-io:commons-io from 2.15.1 to 2.16.1 (#1…
dependabot[bot] Apr 19, 2024
6212b0a
build(deps): bump org.apache.commons:commons-text from 1.11.0 to 1.12…
dependabot[bot] Apr 19, 2024
a95115d
chore: Made line-breaks in the configuration option descriptions get …
chrisdutz Apr 19, 2024
4dd77dd
chore: Updated vendor ids
chrisdutz Apr 19, 2024
834ab08
feat: Added device-group options for local, remote and remote2 to the…
chrisdutz Apr 19, 2024
8efab49
chore: Disabled the OpcuaSubscriptionHandleTest all together as it al…
chrisdutz Apr 19, 2024
4fffc88
feat: Added a "Since" annotation that provides information on when a …
chrisdutz Apr 19, 2024
75342ba
feat: Create a source bundle for PLC4C
chrisdutz Apr 19, 2024
8c87b04
chore: Added newly generated files.
chrisdutz Apr 19, 2024
f346f9f
build(deps): bump org.codehaus.mojo:extra-enforcer-rules (#1548)
dependabot[bot] Apr 22, 2024
85ee0bc
build(deps): bump logback.version from 1.5.5 to 1.5.6 (#1549)
dependabot[bot] Apr 22, 2024
6981261
build(deps): bump bouncycastle.version from 1.77 to 1.78.1 (#1550)
dependabot[bot] Apr 22, 2024
b1fabc9
build(deps): bump identify from 2.5.35 to 2.5.36 in /plc4py (#1546)
dependabot[bot] Apr 22, 2024
6c514bf
build(deps): bump pluggy from 1.4.0 to 1.5.0 in /plc4py (#1547)
dependabot[bot] Apr 22, 2024
431b9e3
build(deps): bump com.fazecast:jSerialComm from 2.10.4 to 2.11.0 (#1554)
dependabot[bot] Apr 23, 2024
104313f
feat(plc4j/api): Convert the string address into a PlcTag (#1468)
qtvbwfn Apr 23, 2024
fcfa85e
build(deps): bump commons-logging:commons-logging from 1.3.0 to 1.3.1…
dependabot[bot] Apr 23, 2024
b0aa7aa
build(deps-dev): bump org.json:json from 20240205 to 20240303 (#1552)
dependabot[bot] Apr 23, 2024
0fcc8b2
build(deps): bump org.apache.maven.plugins:maven-jar-plugin (#1559)
dependabot[bot] Apr 24, 2024
5762d51
build(deps): bump virtualenv from 20.25.3 to 20.26.0 in /plc4py (#1555)
dependabot[bot] Apr 24, 2024
8abefe6
build(deps): bump platformdirs from 4.2.0 to 4.2.1 in /plc4py (#1556)
dependabot[bot] Apr 24, 2024
109efa1
build(deps): bump coverage from 7.4.4 to 7.5.0 in /plc4py (#1557)
dependabot[bot] Apr 24, 2024
435edd7
build(deps): bump net.bytebuddy:byte-buddy from 1.14.13 to 1.14.14 (#…
dependabot[bot] Apr 25, 2024
1c684a8
build(deps): bump commons-cli:commons-cli from 1.6.0 to 1.7.0 (#1563)
dependabot[bot] Apr 25, 2024
720cdc9
build(deps): bump org.apache:apache from 31 to 32 (#1558)
dependabot[bot] Apr 25, 2024
453eef4
Change Python version to 3.10+
ottlukas Apr 25, 2024
bb63281
fix(plc4py/umas): Start to add write support
hutcheb Mar 7, 2024
c0f0f67
rebase umas
ottlukas Apr 25, 2024
67274f5
Merge branch 'develop' into feat/plc4py/umas_write_support
ottlukas May 1, 2024
3876158
Some small changes to python code
ottlukas May 3, 2024
46c0f7a
add additional comments in python code
ottlukas May 3, 2024
3e9054a
Merge branch 'develop' into Refactor-/-Improve-Python-Modbus
ottlukas May 7, 2024
e7a0510
fix(plc4py): Fix optional fields and clean some template stuff up
hutcheb May 8, 2024
d870810
Reset to capture timeouts
ottlukas May 8, 2024
7fc2b1f
Revert "Reset to capture timeouts"
ottlukas May 8, 2024
bc9b82a
Adding commentary / explaination for PLC4Py
ottlukas May 10, 2024
5799461
Merge branch 'develop' into Refactor-/-Improve-Python-Modbus
ottlukas May 10, 2024
e0735e8
some smaller changes
ottlukas May 10, 2024
26b333a
fix(plc4py): start to make the umas and modbus drivers act similialy.
hutcheb May 10, 2024
d751833
fix(plc4py/umas): Start to add write support
ottlukas May 15, 2024
13e9f79
Merge branch 'develop' into Refactor-/-Improve-Python-Modbus
ottlukas May 15, 2024
74de652
add @pytest.mark.xfail so that PLC4Py build succeeds (to be changed o…
ottlukas May 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -803,8 +803,8 @@ private String toBinaryTermExpression(Field field, TypeReference fieldType, Bina
// Except for doing a nil or not-nil check :-(
// So in case of such a check, we need to suppress the pointer-access.
boolean suppressPointerAccessOverride = (operation.equals("==") || operation.equals("!=")) && ((a instanceof NullLiteral) || (b instanceof NullLiteral));
String aExpression = toExpression(field, null, a, parserArguments, serializerArguments, serialize, suppressPointerAccessOverride);
String bExpression = toExpression(field, null, b, parserArguments, serializerArguments, serialize, suppressPointerAccessOverride);
String aExpression = toExpression(field, null, a, parserArguments, serializerArguments, serialize, true);
String bExpression = toExpression(field, null, b, parserArguments, serializerArguments, serialize, true);
return tracer + "bool((" + aExpression + ") " + operation + " (" + bExpression + "))";
case ">>":
case "<<":
Expand All @@ -813,21 +813,21 @@ private String toBinaryTermExpression(Field field, TypeReference fieldType, Bina
tracer = tracer.dive("bitwise");
// We don't want casts here
return tracer +
toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, false) +
toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, true) +
operation + " " +
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false);
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, true);
default:
tracer = tracer.dive("default");
if (fieldType instanceof StringTypeReference) {
tracer = tracer.dive("string type reference");
return tracer + toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, false) +
return tracer + toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, true) +
operation + " " +
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false);
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, true);
}
return tracer +
toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, false) +
toExpression(field, fieldType, a, parserArguments, serializerArguments, serialize, true) +
operation + " " +
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, false);
toExpression(field, fieldType, b, parserArguments, serializerArguments, serialize, true);
}
}

Expand Down Expand Up @@ -1281,7 +1281,7 @@ private String toCastVariableExpression(Field field, TypeReference typeReference

private String toOptionalVariableExpression(Field field, TypeReference typeReference, VariableLiteral variableLiteral, List<Argument> parserArguments, List<Argument> serializerArguments, boolean suppressPointerAccess, Tracer tracer) {
tracer = tracer.dive("optional fields");
return tracer + "(" + (suppressPointerAccess || (typeReference != null && typeReference.isComplexTypeReference()) ? "" : "*") + variableLiteral.getName() + ")" +
return tracer + (suppressPointerAccess || (typeReference != null && typeReference.isComplexTypeReference()) ? "" : "*") + camelCaseToSnakeCase(variableLiteral.getName()) +
variableLiteral.getChild().map(child -> "." + camelCaseToSnakeCase(toVariableExpression(field, typeReference, child, parserArguments, serializerArguments, false, suppressPointerAccess, true))).orElse("");
}

Expand Down

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions plc4py/plc4py/PlcDriverManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,47 @@ class PlcDriverManager:
_driver_map: Dict[str, Type[PlcDriver]] = field(default_factory=lambda: {})

def __post_init__(self):
"""
Initialize the PLC Driver Manager.

This function is called automatically when a new instance of the
PlcDriverManager class is created.

It registers the available drivers, by loading the entry points
defined in the "plc4py.drivers" namespace.
"""
# Log the class loader used
logging.info(
f"Instantiating new PLC Driver Manager with class loader {self.class_loader}"
)

# Add the PlcDriverClassLoader hookspecs to the class loader
self.class_loader.add_hookspecs(PlcDriverClassLoader)

# Log the registration of drivers
logging.info("Registering available drivers...")

# Register the plc4py.drivers package
import plc4py.drivers

self.class_loader.register(plc4py.drivers)

# Load the setuptools entry points defined in the "plc4py.drivers" namespace
self.class_loader.load_setuptools_entrypoints("plc4py.drivers")

# Create a dictionary mapping the hook names to the PlcDriver instances
self._driver_map = {
key: loader
for key, loader in zip(
self.class_loader.hook.key(), self.class_loader.hook.get_driver()
)
}

# Log the successful registration of each driver
for driver in self._driver_map:
logging.info(f"... {driver} .. OK")

# Check for any pending plugins
self.class_loader.check_pending()

@asynccontextmanager
Expand Down Expand Up @@ -95,9 +118,13 @@ def get_driver(self, protocol_code: str) -> Type[PlcDriver]:

def get_driver_for_url(self, url: str) -> Type[PlcDriver]:
"""
Returns the driver class that matches that identified within the connection string
Returns the driver class that matches the one identified within the connection string.

:param url: The plc connection string
:return: the protocol code
:return: The driver class that matches the protocol code identified within the connection string
"""
# Extract the protocol code from the connection string
protocol_code = get_protocol_code(url)

# Retrieve the driver class using the protocol code
return self._driver_map[protocol_code]
20 changes: 12 additions & 8 deletions plc4py/plc4py/drivers/modbus/ModbusConfiguration.py
ottlukas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ class ModbusConfiguration(PlcConfiguration):
"""

def __init__(self, url):
super().__init__(url)

if self.transport is None:
self.transport = "tcp"
"""
Initializes the ModbusConfiguration with the given URL.

if self.port is None:
self.port = 502
Args:
url (str): The URL of the Modbus device.
"""
super().__init__(url)

if "unit_identifier" not in self.parameters:
self.unit_identifier = 1
# Set the transport to TCP if not specified
self.transport = self.transport or "tcp"
# Set the port to 502 if not specified
self.port = self.port or 502
# Get the unit identifier from the parameters, default to 1
self.unit_identifier = self.parameters.get("unit_identifier", 1)
208 changes: 11 additions & 197 deletions plc4py/plc4py/drivers/modbus/ModbusConnection.py
ottlukas marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -16,208 +16,22 @@
# specific language governing permissions and limitations
# under the License.
#
import asyncio
import logging
from typing import Type, Awaitable
from plc4py.spi.configuration.PlcConfiguration import PlcConfiguration

import plc4py
from plc4py.api.PlcConnection import PlcConnection, PlcConnectionMetaData
from plc4py.api.PlcDriver import PlcDriver
from plc4py.api.authentication.PlcAuthentication import PlcAuthentication
from plc4py.api.messages.PlcResponse import (
PlcResponse,
PlcReadResponse,
PlcWriteResponse,
PlcTagResponse,
)
from plc4py.api.messages.PlcRequest import (
ReadRequestBuilder,
PlcRequest,
PlcReadRequest,
PlcWriteRequest,
)
from plc4py.api.value.PlcValue import PlcResponseCode
from plc4py.drivers.PlcDriverLoader import PlcDriverLoader
from plc4py.drivers.modbus.ModbusConfiguration import ModbusConfiguration
from plc4py.drivers.modbus.ModbusDevice import ModbusDevice
from plc4py.drivers.modbus.ModbusProtocol import ModbusProtocol
from plc4py.drivers.modbus.ModbusTag import ModbusTagBuilder
from plc4py.spi.messages.PlcReader import PlcReader
from plc4py.spi.messages.PlcRequest import DefaultReadRequestBuilder
from plc4py.spi.messages.PlcWriter import PlcWriter
from plc4py.spi.transport.Plc4xBaseTransport import Plc4xBaseTransport
from plc4py.spi.transport.TCPTransport import TCPTransport


class ModbusConnection(PlcConnection, PlcReader, PlcWriter, PlcConnectionMetaData):
class ModbusConfiguration(PlcConfiguration):
"""
Modbus TCP PLC connection implementation
Specific Modbus Configuration
"""

def __init__(self, config: ModbusConfiguration, transport: Plc4xBaseTransport):
super().__init__(config)
self._configuration: ModbusConfiguration
self._device: ModbusDevice = ModbusDevice(self._configuration)
self._transport: Plc4xBaseTransport = transport

@staticmethod
async def create(url: str):
"""
Static Factory to return an instance of a ModbusConnection.
It creates the TCP connection to the Modbus device before returning.

:param url: PLC4X connection string of the Modbus TCP connection
:return ModbusConnection instance using the configuration from the url provided
"""
config = ModbusConfiguration(url)
loop = asyncio.get_running_loop()
connection_future = loop.create_future()
transport = await asyncio.wait_for(
TCPTransport.create(
protocol_factory=lambda: ModbusProtocol(connection_future),
host=config.host,
port=config.port,
),
10,
)
return ModbusConnection(config, transport)

def is_connected(self) -> bool:
"""
Indicates if the connection is established to a remote PLC.
:return: True if connection, False otherwise
"""
if self._transport is not None:
return not self._transport.is_closing()
else:
return False

def close(self) -> None:
"""
Closes the connection to the remote PLC.
:return:
"""
if self._transport is not None:
self._transport.close()

def read_request_builder(self) -> ReadRequestBuilder:
"""
:return: read request builder.
"""
return DefaultReadRequestBuilder(ModbusTagBuilder)

async def execute(self, request: PlcRequest) -> PlcResponse:
"""
Executes a PlcRequest as long as it's already connected
:param request: Plc Request to execute
:return: The response from the Plc/Device
"""
if not self.is_connected():
return self._default_failed_request(PlcResponseCode.NOT_CONNECTED)

if isinstance(request, PlcReadRequest):
return await self._read(request)
elif isinstance(request, PlcWriteRequest):
return await self._write(request)

return self._default_failed_request(PlcResponseCode.NOT_CONNECTED)

def _check_connection(self) -> bool:
return self._device is None

async def _read(self, request: PlcReadRequest) -> PlcReadResponse:
"""
Executes a PlcReadRequest
"""
if self._check_connection():
logging.error("No device is set in the modbus connection!")
return self._default_failed_request(PlcResponseCode.NOT_CONNECTED)
try:
logging.debug("Sending read request to Modbus Device")
response = await asyncio.wait_for(
self._device.read(request, self._transport), 5
)
return response
except Exception:
# TODO:- This exception is very general and probably should be replaced
return PlcReadResponse(PlcResponseCode.INTERNAL_ERROR, {})

async def _write(self, request: PlcWriteRequest) -> PlcTagResponse:
"""
Executes a PlcWriteRequest
"""
if self._check_connection():
logging.error("No device is set in the modbus connection!")
return self._default_failed_request(PlcResponseCode.NOT_CONNECTED)
def __init__(self, url):
super().__init__(url)

try:
logging.debug("Sending write request to Modbus Device")
response = await asyncio.wait_for(
self._device.write(request, self._transport), 5
)
return response
except Exception:
# TODO:- This exception is very general and probably should be replaced
return PlcWriteResponse(PlcResponseCode.INTERNAL_ERROR, {})

def is_read_supported(self) -> bool:
"""
Indicates if the connection supports read requests.
:return: True if connection supports reading, False otherwise
"""
return True

def is_write_supported(self) -> bool:
"""
Indicates if the connection supports write requests.
:return: True if connection supports writing, False otherwise
"""
return False

def is_subscribe_supported(self) -> bool:
"""
Indicates if the connection supports subscription requests.
:return: True if connection supports subscriptions, False otherwise
"""
return False

def is_browse_supported(self) -> bool:
"""
Indicates if the connection supports browsing requests.
:return: True if connection supports browsing, False otherwise
"""
return False


class ModbusDriver(PlcDriver):
def __init__(self):
super().__init__()
self.protocol_code = "modbus-tcp"
self.protocol_name = "Modbus TCP"

async def get_connection(
self, url: str, authentication: PlcAuthentication = PlcAuthentication()
) -> PlcConnection:
"""
Connects to a PLC using the given plc connection string.
:param url: plc connection string
:param authentication: authentication credentials.
:return PlcConnection: PLC Connection object
"""
return await ModbusConnection.create(url)


class ModbusDriverLoader(PlcDriverLoader):
"""
Modbus Driver Pluggy Hook Implmentation, lets pluggy find the driver by name
"""
if self.transport is None:
self.transport = "tcp"

@staticmethod
@plc4py.hookimpl
def get_driver() -> Type[ModbusDriver]:
return ModbusDriver
if self.port is None:
self.port = 502

@staticmethod
@plc4py.hookimpl
def key() -> str:
return "modbus"
if "unit_identifier" not in self.parameters:
self.unit_identifier = 1