-
Notifications
You must be signed in to change notification settings - Fork 0
Modified S7StringAttribute support for Class Type. #1
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
base: jjelks
Are you sure you want to change the base?
Conversation
Extended PLCAddress.Parse method
Tests/TypeTests: Add ClassTests from #178
PLCAddress: Add OB, OW, OD types from PR #277
PLC: Improve exceptions on Read
Add new class Types.Dtl by taking the DateTime type and adjusting things. Also add unit test with binary data calculated by hand. (Need to verify with actual S7 data)
Add DateTimeLong type
Convert UnitTest project to SDK project type.
- Change build image to VS 2019 - Update Microsoft.SourceLink.GitHub package - Update solution file - Build separate symbol package (.snupkg)
AppVeyor and infra updates
This requires reference types that can be null to be annotated by a ? operator, similar to value types. This gives the advantage that the compiler can warn against any null dereference exceptions, of which this commits elimits a few. To make the underlying protocol implementation not any more complicated and to eliminate existing problems, and not that precise error reporting, I replaced some return null statements with explicit Exceptions. This lead to the assumption that those core protocoll functions always return non-null objects if they do not throw, making the PLC code simpler. Adjust some NotConnected tests to look for explicit PlcException instead of NullReferenceException.
Add nullable support throughout the whole library.
Both Synchronous and Asynchronous need to build the same binary data package to write a bytes array. Move that package building out into a common function. Also use IEnumerable to pass in data instead of converting it to array and back multiple times. Not that happy with the whole ByteArray class, we could probably just use a MemoryStream instead.
Merges data creation between sync and async for writing bit values.
Use MemoryStream as well.
Instead of using a loop, use Array.Copy to
Default ReadTimeout and WriteTimeout to 10 seconds
Add unit test to ensure a connection has been properly closed
Use consistent DWord conversion for both Int32 and UInt32. Unfortunately there is no Span or even a FromByteArray function accepting a offset, so just use the same Array.Copy falls used for double.
|
I tried using the new string functionality for classes and it wouldn't work. It works perfectly for structs but I had to change from using the underlying type of the property to propertyinfo to be able to get the S7StringAttribute as well as increment numBytes with the ReservedLengthInBytes property. // getting attribute from instance not type and increment numBytes if (attribute == default(S7StringAttribute)) |
|
Thanks for the heads up, I will check it. |
|
@dhullett08 - It appears yesterday's commit had some merge issues, which I don't have time to look into at this moment. feel free to pull from my tree: jjelks for the latest update, which is working for me on the S7-1200 & S7-1500. |
|
@Jason-Jelks I am using S71500S software PLC on a Siemens Microbox PC and .NET 5.0. I tried full framework as well and I couldn't get classes to work? Thats when I went and started digging on MSDN and noticed that it states to GetCustomAttributes of a property it has to be a PropertyInfo object and the method needs called on the instance, not the underlying type (System.String). For the Struct using FieldInfo works because it is for that instance of a Field. I'm not sure what the disconnect is if it works for you. |
…alize S7String, instead of always using Encoding.ASCII
Allow changing the default Encoding used in S7String
Flowed cancellation token to TcpClient.ConnectAsync in .NET 5.0 target
Added support for string/wstring in a class
ci: Run test on ubuntu-20.04 due to lack of snap7 on newer ubuntu
# Conflicts: # S7.Net/Types/Class.cs
Fix ReadClass for UInt32
…> for .NET5 or greater
add Read/WriteBytes(Async) overloads accepting Span<byte>/Memory<byte> for .NET5 or greater
Use System.Memory for < .NET 5 and avoid (some) unnecessary allocations
Classes can now include String properties by adding the "S7StringAttribute" to the Properties to define maximum string size. The Attribute is required for Class type implementing a String.
Classes can now include DateTime Properties. The internal call structures now support passing the current CPU instantiated so that the proper DateTime structure is implemented based on the PLC.
S7-1200 & S71500 : use DateTimeLong (DTL - 12-bytes)
all others use: older DT 8-byte format as they don't support the DTL
The CPU parameter does not break existing implementations, but does default direct calls made by an external source to S7-300 if not defined.