Giter VIP home page Giter VIP logo

Comments (7)

timyhac avatar timyhac commented on September 26, 2024

Alrighty in that case we'll close the other issue.

from libplctag.net.

timyhac avatar timyhac commented on September 26, 2024

Adding constructors to the TagGroup isn't required at all - in fact its probably even more verbose than something like tagGroup.Add(new Tag()). Hmmmm yes it was just because it was more terse having a TagCreate function where you can provide a few details about the tag - but we could just have them as optional parameters in the constructor instead - which would override any of the same details found in the attribute group.

With the additional async method (with the timeout), we thought that it would still be useful to add a timeout to the non-blocking method. This would be useful as you'd often want it to be non-blocking (so UIs can remain responsive) but still timeout on network connection issues.

The API for HttpClient instead has an optional Timeout property that applies to all calls for a given HttpClient , as opposed to applying it per call. Could make sense? @jkoplo
One benefit of that is that it could be provided in the constructor, and the default behaviour for the constructor could be a blocking call with the provided timeout - but if they chose to delay it they could ask for that too.

var myDint = new Tag<PLC,CLR>(attributeGroup, "MY_DINT", 5000, initNow: false);
await myDint.InitializeAsync(); // non-blocking, and times out after 5000ms

versus

var myDint = new Tag<PLC,CLR>(attributeGroup, "MY_DINT", 5000);   // blocks and times out after 5000ms

from libplctag.net.

timyhac avatar timyhac commented on September 26, 2024

Following on from the comment about Tag creation from above, I've updated the group branch, the new API is consumed as follows:

var myPlcA = new AttributeGroup()
{
    Gateway = "192.168.0.10",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip
};

var myPlcB = new AttributeGroup()
{
    Gateway = "192.168.0.11",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip
};

var dint1a = new Tag<DintMarshaller, int>(myPlcA, "MY_DINT_1D[0]");
var dint2a = new Tag<DintMarshaller, int>(myPlcA, "MY_DINT_1D[1]");
var dint1b = new Tag<DintMarshaller, int>(myPlcB, "MY_DINT_1D[2]");
var dint2b = new Tag<DintMarshaller, int>(myPlcB, "MY_DINT_1D[3]");

var tagGroup = new TagGroup()
{
    dint1a, dint2a, dint1b, dint2b
};

var timeout = 1000;
tagGroup.InitializeAll(timeout);
tagGroup.ReadAll(timeout);

var value = dint2b.Value[0];

Console.WriteLine(value);

from libplctag.net.

AndreasMartinGB avatar AndreasMartinGB commented on September 26, 2024

Do you already know when you plan to merge the Group branch into the master (and maybe also the other branches)? For my project it would be very helpful.

Thx in advance

from libplctag.net.

timyhac avatar timyhac commented on September 26, 2024

@AndreasMartinGB - no plans at the moment. It is a reasonably big change from an API perspective, and motivation to integrate it working has dropped somewhat (from me).

Just out of interest - what is your use case here, what interests you about the group branch?

from libplctag.net.

AndreasMartinGB avatar AndreasMartinGB commented on September 26, 2024

I want to be able to configure the tags to read and write. My idea here was to add the specific base type mapper to the tag group item based on the configuration. From code perspective it would feel cleaner if this would be supported directly but as there is no plan for merging this is also no big deal to do it by my own.
Thx for your answer.

from libplctag.net.

timyhac avatar timyhac commented on September 26, 2024

This has not had any serious exploration for some years.
The libplctag.NET project won't add any feature like this unless it were supported in the core library.

from libplctag.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.