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

Read LINT as BOOL array #427

Closed
alessandrossi97 opened this issue Jan 8, 2025 · 2 comments
Closed

Read LINT as BOOL array #427

alessandrossi97 opened this issue Jan 8, 2025 · 2 comments

Comments

@alessandrossi97
Copy link

Hi everyone,

Is there a way to read integer types (INT, DINT, LINT) as boolean arrays?
I am using the following code:

var bit = new Tag<BoolPlcMapper, bool>()
{
    Name = "ALARMS_GENERAL.SeriuosAlarms.0",
    Gateway = "172.27.7.205",
    Path = "1,0",
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip,
    Timeout = TimeSpan.FromSeconds(5)
};
Console.WriteLine($"{bit.Name} value: {bit.Read()}.");

var array = new Tag<BoolPlcMapper, bool[]>()
{
    Name = $"ALARMS_GENERAL.SeriuosAlarms",
    Gateway = "172.27.7.205",
    Path = "1,0",
    ArrayDimensions = new int[] { 64 },
    PlcType = PlcType.ControlLogix,
    Protocol = Protocol.ab_eip,
    Timeout = TimeSpan.FromSeconds(5)
};
Console.WriteLine($"{array.Name} value: {array.Read()}.");

ALARMS_GENERAL.SeriuosAlarms is a LINT variable, I can correctly read single bits, but i cannot read the LINT as bool array. The array initializer method raises an exception and returns ErrorOutOfBounds.

Any help would be greatly appreciated,
Thanks in advance

@kyle-github
Copy link
Member

Within the PLC and within the CIP protocol, data access to tags is typed and the type of the access must match the type of the tag. That said, you can use the bit accessor functions (change to camel-case for C#/.NET I think) to get individual bits. You could write your own mapper with that.

@timyhac
Copy link
Collaborator

timyhac commented Jan 25, 2025

I trust this was the information you needed.

If you need some inspiration on Mappers, there are some examples to study here.

@timyhac timyhac closed this as completed Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants