Closed jojoguy10 closed 6 months ago
Or maybe, and this could also be related to #24, can I instantiate a new Member
with a string as the LogixData
type? Granted, that would be require the program to make sure the other properties are configured properly, possibly (unless Logix will find defaults for them when uploaded).
public Member(string name, string dataType)
: base(CreateMember(name, data))
{ }
Seems like that kind of breaks a few things with how you're making the XElement
:/ .
I agree and I had been thinking about how to do this. I have added a new method in version 2.3.0 to create LogixData instance by just providing a name.
//Creates a concrete DINT instance.
var atomic = LogixData.Create("DINT");
//Creates a concrete TIMER instance.
var predefined = LogixData.Create("TIMER");
//Created a ComplexData instance with name "MyType"
var data = LogixData.Create("MyType");
If the data type name is not known then it resorts to the normal ComplexData instance.
I was going to add a new constructor to Member but it caused too many test errors, since StringData is implicitly convertible to a string type in .NET. But you can just call this method like so.
var member = new Member("MemberName", LogixData.Create("TIMER"));
This let me add new constructors in a few other places, like ArrrayData and Tag.
//Creates 100 DINT objects from the provided name.
var array = new ArrayData<LogixData>("DINT", new Dimensions(100));
//Creates the TIMER instance from the name.
var tag = new Tag("MyTag", "TIMER");
Related to my other feat7ure request, is there a function available to parse a string of a
DataType
to aDataType
instance?Something like this, but then output to the actual
DataType
( or rather,LogixType
) to use in makingTags
?