Comments (4)
This is a good pickup, according to once of my go-to sources:
Once disposed, an object is beyond redemption. It cannot be reactivated, and calling its methods or properties (other than Dispose) throws an ObjectDisposedException.
Albahari, Joseph; Albahari, Ben. C# 7.0 in a Nutshell (p. 514). O'Reilly Media. Kindle Edition.
FYI Internally, IsInitialized is separate to IsDisposed - the tag handle creation does some communication with the PLC, and libplctag core library has the concept of an async constructor. Of course in C# there is no such thing as an async constructor, so we decided to separate the initialization, so it can be lazily initialized (or if you wanted to create several hundred tags at once, you could do them all at once, asynchronously, rather than one after the other).
from libplctag.net.
Btw @romanka5150 - what you've done is fine. You don't need to call Dispose()
yourself because the GarbageCollector will do this for you.
from libplctag.net.
@romanka5150 - it also looks like you're using the lower level (native) class for Tag. That's fine by all means, but there is also an implementation that handles types and offsets for you.
It looks like your setting up a length read in order to eventually retrieve a string.
Here's an example of the higher level syntax, in this case writing an array of strings:
var stringTag = new Tag<StringPlcMapper, string[]>()
{
Name = "MY_STRING_1D[0]",
Gateway = gateway,
Path = path,
Protocol = Protocol.ab_eip,
PlcType = PlcType.ControlLogix,
ArrayDimensions = new int[] { 100 },
};
var r = new Random((int)DateTime.Now.ToBinary());
for (int ii = 0; ii < stringTag.Value.Length; ii++)
stringTag.Value[ii] = r.Next().ToString();
stringTag.Write();
More examples here: https://github.com/libplctag/libplctag.NET/tree/master/src/Examples/CSharp%20DotNetCore
from libplctag.net.
This should be closed by #99.
It'll make it into the next build.
from libplctag.net.
Related Issues (20)
- PowerFlex 753 communication over Ethernet. Is it possible? HOT 4
- Booleans in UDTs HOT 3
- Deadlock if Async Read/Write called from UI Thread HOT 2
- How to write an UDT subset HOT 5
- UDT with mixed read/write access HOT 3
- Expose more TagOfT properties to ITag interface HOT 2
- String tag read but not write HOT 4
- Issue's when controller is located in last slot of rack HOT 7
- How to read/write strings HOT 43
- Reading PLC 5 Data File HOT 5
- CompactLogix reading UDT's issue HOT 1
- Doubt about getting values from a unknown tag HOT 3
- Is it possible to use libplctag.NET for reading and writing tags in Siemens S7-1200? HOT 2
- In the StringPlcMapper, Omron is not present HOT 17
- Array of UDT HOT 4
- Array tag notification on change HOT 1
- Array of BOOL ErrorBadParam HOT 2
- ASP.Net error HOT 6
- Unable to load DLL plctag or one of its dependencies HOT 4
- List all tags in Omron NJ: ErrorUnsupported HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libplctag.net.