AdvancedHMI Software

General Category => Support Questions => Topic started by: dhananjay.j@outlook.com on May 04, 2018, 06:58:28 AM

Title: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 04, 2018, 06:58:28 AM
I am using AdvancedHMIv399x. I am not using any UI Controls, I am just using EthernetIPforSLCMicroCom.Read and Write.
Recently I came across the Subscribe Event where PLC Polls Data after a Declare Time Interval. This will save me a Lot of Time for updating Values from PLC as 1by1 fetching Tags takes 10 ms (Specified on some other discussion). I can Fetch all Real bits normally with subscription but unable to work with Boolean Tags like B3:10/0-1-2-3 etc. and Timer valueslike T4:9.PRE, ACC, EN,DN values of all T4 tags list. Either this gives me error saying too small or too large value. or Event is not called entirely. Can you provide me a solution to subscribe ti Polling of Counters, timers and boolean values? I am using C# for programming.

I just need 2 Lines of code for reference to correct my logic.
I need correct
var Timers = Connection.Subscribe("Timertag", 50,100ms, Subscribedevent);
var Counters= Connection.Subscribe("CounterTag", 50,100ms, Subscribedevent);
var BooleanBits = Connection.Subscribe("BooleanBitTag(eg. B3:0/1)", 50,100ms, Subscribedevent);

I also use this

EthernetIPforSLCMicroCom  Connection = new EthernetIPforSLCMicroCom  ();
Connection.IP = "MyIP";
Connection.SubscriptionDataReceived += Connection_SubscriptionDataReceived;

To read values

If you can give me that My problems will be fixed. Nothing more to discuss. I am on a clock.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 04, 2018, 07:31:34 AM
Hi, I am on a clock here so any help is good. The connection either causes an error(in case of timers,) or dont call event handler at all.(in case of Counter Tags). in case of booleans it returns next tag values instead of bit values true false.

Update
 Counters and Timers go to oveflow Exception after subscription. while Booleans go to next Tag instead of Bit (B3:1, B3:2 instead of B3:1/0, B3:1/1).
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 09, 2018, 04:50:23 PM
I just tested this out and it works as expected for me:
Code: [Select]
    Private SubID As Integer
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SubID = EthernetIPforSLCMicroCom1.Subscribe("T4:0.PRE", 1, 0, AddressOf DataReturned)
    End Sub

    Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        If e.PlcAddress = "T4:0.PRE" Then
            Me.Text = e.Values(0)
        End If
    End Sub
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 09, 2018, 04:52:43 PM
I see the difference now. You are using SubscriptionDataReturned which doesn't seem to work. Use the DataReturned event.

This can be fixed by modifying EthernetIPforSLCMicroCom at line 304:
Code: [Select]
    Private Sub DataRecSync(ByVal e As Object)
        Dim e1 As MfgControl.AdvancedHMI.Drivers.Common.SubscriptionEventArgs = DirectCast(e, MfgControl.AdvancedHMI.Drivers.Common.SubscriptionEventArgs)
        e1.dlgCallBack(Me, e1)
        MyBase.OnSubscriptionDataReceived(e1)
    End Sub
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 12, 2018, 01:02:48 AM
Hi Archie,
I am fetching singular values directly by Read method. My requirement here is I want to fetch Timers, Counters & "B" tag values in bulk. I am doing this using subscription for "F" type floating values. eg. I am fetching F20:0 to F20:89 values in a single subscription. Like this If I want to fetch Timer values (like T4:0.ACC to T4:89.ACC, From  T4:0.PRE to T4:89.PRE etc)
Counter values (like C5:0 to C5:89) and boolean bits(B3:0/0 to B3:0/15 etc).
out of these Boolean seems to be giving me error. and returning Numbers like 2,16189 etc if I suscribe to (B3:0,100,100,eventHandler). Do I need to Convert These Values to Binary and then use Bits as true false?.

We work mostly on very complex logical HMI softwares where automation is required and Human interactions are very less. So we don't directly use advanceHMIcontrols but this driver is doing the Magic! Currently my application is working but its very slow due to use of Read and writes which take approx 10ms each (as suggested by you in some other post I read), Following will solve all my issues for all my clients.

Is there a way I can subscribe to PLC Polling to receive all Configured Tags like Rockwell RSLinx Does? If yes, is it a Array of Strings like in case of Subscribe()? If yes, How can I subscribe so that I can separate each tag values (like Convert.ToDouble(e.Values["F20:0"]) C#).

If this is available, then forget my original Question.
If not available, do you suggest /is it Fast enough to subscribe to all Tags individually like ("T4:0.PRE",1,0,eventHandler)?
I can not Thank you enough for doing what you do!

(I am from india, and this is like 10:30 AM here... Hence the Post Timing. I hope you understand)
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 12, 2018, 02:35:54 AM
First off... there is a confirmed issue when subscribing to more than 1 consecutive bit. For instance, if you subscribe to 10 bits starting at B3/0 it will only return the first bit. This issue is being addressed and an updated beta version should be available in a few days with the fix.


Before jumping into using all subscriptions, it's important to understand the 3 techniques of reading data with the driver.


Read (Synchronous reading)
Pro - Minimal code required making it very easy to implement.
Con - It is a blocking operation. If called from the UI thread, the UI will be unresponsive until data is returned from the PLC


BeginRead (Asynchronous reading)
Pro - Non-blocking operation that returns immediately after queueing the request, therefore will not freeze the UI thread
Con - Requires more code to implement. Since requests are queued, it is the developer's responsibility to throttle the rate of calling, otherwise a "send que full" exception can occur if requests are sent too fast

Subscription (Continuous refresh at a rate set by PollRateOverride)
Pro - Simplifies the code needed to receive values at a regular interval. The driver will optimize communications by grouping multiple subscriptions into a single packet when possible.
Con - Code can be complex to implement. A large number of subscriptions can put excessive load on the communication link. It is the developers responsibilty to maintain subscription IDs in order to unsubscribe when finished.


It sounds like you want to subscribe to a fairly large amount of data which is not a problem, but can potentially bottleneck your bandwidth and slow all communications.

You can subscribe to as many items as you wish. The callback specified by your subscribe will return an array of values matching the number of elements the subscription specified. For instance, if you peform:

SubID = EthernetIPforSLCMicroCom1.Subscribe("N7:0", 10, 0, AddressOf DataReturned)

then DataReturned subroutine will be called at an interval set by PollRateOverride driver property and e.Values will be an array of 10 values.

Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 14, 2018, 05:25:45 AM
I have used subscriptions so many major processes in my application are boosted in speed. But there is still a bug(May be) in subscribing to multiple Tags using same instance of EthernetIPforSLCMicroCom. I am working on creating a solid code example so that it can be reproduced for you to test. The primary observation is
1.
EthernetIPforSLCMicroCom  PLCconnection;
PLCconnection.SubscribeToPlcValues("F20:0", 90, 100, CallBackHandler); (C#)
with or without
PLCconnection.SubscriptionDataReceived += DataReceivedHandler (C#)
In some cases "DataReceivedHandler" is called while in others "CallBackHandler" is called. Again I'll put up a code that can reproduce this.
2. Once a "Read failed:No Response" exception occures (With my current PLC this is more frequent) The Polling is stopped and need to re-initiated. (If we can predict if PLC connection is lost or is too busy to respond we can wait and avoid this. But Currently there seems to be no way of doing this. )
3. If more than 1 subscription with single instance of EthernetIPforSLCMicroCom. Only 1 is called(preferably 1st one). Others are ignored. Again Not Confirmed when, will put up code.

 Now the Question remains,
1. Can we do somthing like check if EthernetIPforSLCMicroCom.IsConnected (available to Read and write)? if there is other way to this, its Most welcome...
2. Can we replicate polling like RSLinks receive from PLC. (All Setup tag(F's N's I's, O's, C's etc) values are polled every 100ms)? Cause we definitly need a lot of tags as we have like 10 different cycles running at a time in single PLC consuming Multiple Timers, Counters, PID's and all sort of hardwares values each.

If these 2 things Happen I think you'll have answered Half the PLC world issues :)

Thanks,
Dhananjay
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 15, 2018, 02:44:09 AM
Also, I usually get "MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException: Read Failed - 240. Error code in EXT STS Byte" and I have implemented a Retry policy for that. I googled alot even got the PLC Exception booklet but there is no specific explaination for this. Can you help me with this as to how to avoid this?
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 15, 2018, 03:21:44 AM
Also, I usually get "MfgControl.AdvancedHMI.Drivers.Common.PLCDriverException: Read Failed - 240. Error code in EXT STS Byte" and I have implemented a Retry policy for that. I googled alot even got the PLC Exception booklet but there is no specific explaination for this. Can you help me with this as to how to avoid this?
It means there is an extended status code. The driver is supposed to return the extended code. Since it doesn't the only way to see it is to do a Wireshark capture.

Page 130 of this manual explains the codes:

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1770-rm516_-en-p.pdf
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 15, 2018, 11:58:11 AM
I have used subscriptions so many major processes in my application are boosted in speed. But there is still a bug(May be) in subscribing to multiple Tags using same instance of EthernetIPforSLCMicroCom. I am working on creating a solid code example so that it can be reproduced for you to test. The primary observation is
1.
EthernetIPforSLCMicroCom  PLCconnection;
PLCconnection.SubscribeToPlcValues("F20:0", 90, 100, CallBackHandler); (C#)
with or without
PLCconnection.SubscriptionDataReceived += DataReceivedHandler (C#)
In some cases "DataReceivedHandler" is called while in others "CallBackHandler" is called. Again I'll put up a code that can reproduce this.
2. Once a "Read failed:No Response" exception occures (With my current PLC this is more frequent) The Polling is stopped and need to re-initiated. (If we can predict if PLC connection is lost or is too busy to respond we can wait and avoid this. But Currently there seems to be no way of doing this. )
3. If more than 1 subscription with single instance of EthernetIPforSLCMicroCom. Only 1 is called(preferably 1st one). Others are ignored. Again Not Confirmed when, will put up code.

 Now the Question remains,
1. Can we do somthing like check if EthernetIPforSLCMicroCom.IsConnected (available to Read and write)? if there is other way to this, its Most welcome...
2. Can we replicate polling like RSLinks receive from PLC. (All Setup tag(F's N's I's, O's, C's etc) values are polled every 100ms)? Cause we definitly need a lot of tags as we have like 10 different cycles running at a time in single PLC consuming Multiple Timers, Counters, PID's and all sort of hardwares values each.

If these 2 things Happen I think you'll have answered Half the PLC world issues :)

Thanks,
Dhananjay

Also anything on this? I thought this is a community forum but all I receive is responses from Archie...
Actually as a user we must have developed many strategies to solve these issues but no one is looking intereseted in sharing one. Thanks Archie.
Title: Re: EthernetIPforSLCMicroCom
Post by: Godra on May 15, 2018, 01:00:54 PM
Archie is the mastermind behind this project, so if anybody can help you then he can.

You should focus on providing the "solid code example so that it can be reproduced for you to test", as you suggested.
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 15, 2018, 01:30:14 PM
Also anything on this? I thought this is a community forum but all I receive is responses from Archie...
Actually as a user we must have developed many strategies to solve these issues but no one is looking intereseted in sharing one. Thanks Archie.
I have been waiting on your example code to demonstrate any bugs you found.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 15, 2018, 03:57:12 PM
Currently we are focusing on completing the project with what works "The Fastest" and fits the BW limitations of PLC. So having a little time to do some Testing, but will definitely post it once I am done here. But those are my observations may be I am right/Wrong.

For the sake of Professionalism, If you (Archie, Team and the viewers) have not found any way to "full scale PLC Tag poll" or "PLC Connection Flags(like Online, Offline, Busy, Available) etc. Please let me know so that I'll stop looking for now...
All our current Indicators are "Read Failed: No Response from PLC" Exceptions (try catch is slowing code like hell), worst case scenario is we do 10 Retries before we give up on a Read Write Operations. That number might have to be increased as complexity increases... And because our client can't afford additional PLCs (We use Micrologix 1400 A...)  right now as we are on tight budget... we have to make due on 1.

Thats the story of a developer... agreed? :D
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 15, 2018, 04:04:25 PM
Archie is the mastermind behind this project, so if anybody can help you then he can.

You should focus on providing the "solid code example so that it can be reproduced for you to test", as you suggested.

All I am currently intersted in 2 things

1.
EthernetIPforSLCMicroCom .SubscribeToAllPLCTags(100sPollrate, CallbackHandler);

void CallbackHandler(obj sender, args e)
{
foreach(var value in e.values)
{
var TagName = value.Address;
var TagValueString = value.Value;
}
}

2. var con = EthernetIPforSLCMicroCom.GetConnection(IPAddress);
if(con.IsConnected)
{}

switch(con.status)
{
case PLCStatus.Offline: con.Connect(); break;
case PLCStatus.Online: return "OK";
case PLCStatus.AvailableToReadWrite: return "Thank God";
.........
}

Is it good enough pseudo code?
Title: Re: EthernetIPforSLCMicroCom
Post by: Godra on May 15, 2018, 04:27:32 PM
I would say that what you posted looks more like a wishful thinking.

A "solid code example" to me would be an example that I could copy and paste into a project, run it and see what responses come from a PLC.
Minor modifications to that example could be done if necessary.
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 15, 2018, 04:59:27 PM
1. EthernetIPforSLCMicroCom .SubscribeToAllPLCTags(100sPollrate, CallbackHandler);
100ms for a large number of value is probably beyond the limits of the hardware. SLCs and Micros typically respond in 10-15ms in an ideal situation of only the PC and PLC connected directly together. Then you have a 236 byte packet limit on the newer models, less on the older.


Each table read requires it's own packet and anything beyond about 220 elements is broken into multiple packets. So let's say you want 100 floating point values, that is 2 packets therefore 20-30ms for that alone. Add 100 integers to that and you are now up to 40-60ms.


Comparing AdvancedHMI to an OPC server such as RSLinx is not an apples to apples comparison. Many OPC servers cache data and will send you stale values which leads you to think you are getting data faster than physically possible.

AdvancedHMI returns true data even if it has to delay beyond your requested rate. For instance, you can set a PollRateOverride of 1ms, but the PLC cannot respond at that rate, so you will get callbacks in about 10-15ms.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 16, 2018, 12:55:50 AM
I would say that what you posted looks more like a wishful thinking.

A "solid code example" to me would be an example that I could copy and paste into a project, run it and see what responses come from a PLC.
Minor modifications to that example could be done if necessary.


Yes It's a Wishful Thinking, I called it pseudo code for a reason. Sorry about that.

I guess our main issue is have to be limited to only 1 PLC primarily... I am currently using dictionaries in .net to sync Tags using subscriptions and considering 1s delay for around 230 values subscribed, plus some 40ish individual read writes, which should be enough time to do that. The issue as stated earlier is we have to rely on read failed exceptions to know PLC is busy. We tried put a bottleneck by using C# lock(ThreadLock){ } but still it takes atleast 6 tries some time to read or write a value which is considerable after the number of subscriptions that I have and the explanation that you gave.

Is it allowed to rewrite "EthernetIPforSLCMicroCom" driver code to test some changes? I am thinking of trying to force a thread safety and PLC availability check before push, pull request. If yes, Can we submit it to you so that we may get a feedback from you if it'll work considering PLC limitations/dependencies? will that be Considered as a Chargeable service request?
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 16, 2018, 07:59:26 AM
Quote
1. Can we do somthing like check if EthernetIPforSLCMicroCom.IsConnected (available to Read and write)? if there is other way to this, its Most welcome...
Amen, bro or should I say Thathaastu  or Amitabha Buddha.
Title: Re: EthernetIPforSLCMicroCom
Post by: Godra on May 16, 2018, 09:37:10 AM
An implementation of IsConected in the driver might not reflect timely responses.

This since the detection of a lost connection relies on a timeout occurring from no response from the PLC, so it could be delayed by several seconds.

Here is a simple example of implementation which does respond to the network cable being connected/disconnected:

Code: [Select]
    Private IsConnected As Boolean
    Private Sub drv_ConnectionEstablished(sender As Object, e As EventArgs) Handles drv.ConnectionEstablished
        IsConnected = True
    End Sub

    Private Sub drv_ComError(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles drv.ComError
        IsConnected = False
    End Sub
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 16, 2018, 12:26:17 PM
it's still nicer to have it right out the gate. Other drivers have it.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 17, 2018, 02:55:29 AM
Is there a free OPC server that we can use to subscribe to all Tags at once? I see OPC dlls with AdvancedHMI Drivers in my project can we use that without any "Other" Application. so that we need to only write tags using AdvanceHMI?
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 17, 2018, 03:28:47 AM
Is there a free OPC server that we can use to subscribe to all Tags at once?
I doubt it because that would flood the network on a PLC program with any reasonable amount of data tables.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 17, 2018, 06:31:30 AM
What is the TNS value (int type) that we need with Some of the Methods for this Driver(like ClearFault, ChangeMode etc.)?
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 17, 2018, 08:33:07 AM
What is the TNS value (int type) that we need with Some of the Methods for this Driver(like ClearFault, ChangeMode etc.)?
It is a transaction number that comes from the generator:

        Dim TNS As Integer = MfgControl.AdvancedHMI.Drivers.Common.TransactionNumberGenerator.GetNextTNSNumber(32767)

The normally used commands encapsulate the generation of a TNS and return it to the user for asynchronous methods. The methods that are rarely used have not been abstracted to the higher level.
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 17, 2018, 08:58:10 AM
I know i may be too much annoying but hopefully this may be the last one


How do I subscribe to B Tag Values like I need Some Boolean Values inside  from B3:0 to B3:10(B3:0/0 ,1, 2 to B3:10,0,1,2 etc...)? I get Numeric values in Return in EventErgs. Do I need to Convert them to binary and use as true false?


Also, Is there a priority to Subscriptions? like if I do
Connection.SubscriptionDataReceived += SubscriptionDataReceivedHandler;
            Connection.DataReceived += DataReceivedHandler;
            Connection.PCCCDataReceived += PCCCDataReceivedHandler;
            var BTagsSubscriptionId = Connection.Subscribe(Tag, 16, 100, CallBackHandlerForB3);

i get value only in PCCCDataReceivedHandler and not even in CallBackHandlerForB3. What will happen in case of multiple subscriptions?

Thanks & Regards,
Dhananjay
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 17, 2018, 09:03:26 AM
How do I subscribe to B Tag Values like I need Some Boolean Values inside  from B3:0 to B3:10(B3:0/0 ,1, 2 to B3:10,0,1,2 etc...)? I get Numeric values in Return in EventErgs. Do I need to Convert them to binary and use as true false?
There is a bug in the current version with subscribing to multiple bits. To workaround it, you need to subscribe to the words (B3:0), then parse out the bits. Within a weeks will be a new beta version that fixes this problem.
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 17, 2018, 09:39:36 AM
If you want to try OPC Ignition from Inductive Automation, it's very easy to use, drag & drop and you can you see all your tags in no time.
And it's free, you only need to hit reset every two hours.
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 17, 2018, 02:06:35 PM
If you want to try OPC Ignition from Inductive Automation, it's very easy to use, drag & drop and you can you see all your tags in no time.
And it's free, you only need to hit reset every two hours.
Do they have a stand-alone OPC server or is it just integrated into the Ignition software? If it works stand-alone, I'm interested in running some bench mark tests on their driver
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 17, 2018, 02:43:04 PM
it stated : "Ignition OPC-UA is offered free as a stand-alone server," but I dont recall in the installation package

https://inductiveautomation.com/news/free-modbus-driver-added-ignition-opc-ua
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 18, 2018, 02:29:09 AM
How do I subscribe to B Tag Values like I need Some Boolean Values inside  from B3:0 to B3:10(B3:0/0 ,1, 2 to B3:10,0,1,2 etc...)? I get Numeric values in Return in EventErgs. Do I need to Convert them to binary and use as true false?
There is a bug in the current version with subscribing to multiple bits. To workaround it, you need to subscribe to the words (B3:0), then parse out the bits. Within a weeks will be a new beta version that fixes this problem.

Can you give me a example of how to achieve this? When I subscribe to B3:0 and put numberOfElements to some value I get numbers that dont exceed 255(8bit) but  A B3:0 should have 0 to 15(16 bits) so I should only get 1 output till 32766 (signed).  How does this work?

Also, If I am already subscribed to a F tag using Driver Instance do I need to create another instance or subscribing with the same instance should work perfetctly?
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 18, 2018, 05:39:57 AM
Code: [Select]
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       SubID = EthernetIPforSLCMicroCom1.Subscribe("B3:0", 2, 0, AddressOf DataReturned)
       subID2 = EthernetIPforSLCMicroCom1.Subscribe("F8:0", 2, 0, AddressOf DataReturned)
     End Sub

    Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        If e.PlcAddress = "B3:0" Then
            Label1.Text = e.Values(0)
            Label2.Text = e.Values(1)
        ElseIf e.PlcAddress = "F8:0" Then
            Label3.Text = e.Values(0)
            Label4.Text = e.Values(1)
        End If
    End Sub
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 18, 2018, 06:05:46 AM
Quote
EthernetIPforSLCMicroCom1.Subscribe("B3:0", 2, 0, AddressOf DataReturned)

Just Checking...
So you say I should use numberOfElements = 2 to get a Word and then Convert the received 2 values to binary 16 bits and get individual flag?(B3:0/1,2,3...15) cause my e.Values(0) =79 while e.Values(1) = 0, so,
79(2) = 01001111 and 0(2)=00000000. Is that right?
Title: Re: EthernetIPforSLCMicroCom
Post by: Archie on May 18, 2018, 07:15:41 AM
Quote
EthernetIPforSLCMicroCom1.Subscribe("B3:0", 2, 0, AddressOf DataReturned)

Just Checking...
So you say I should use numberOfElements = 2 to get a Word and then Convert the received 2 values to binary 16 bits and get individual flag?(B3:0/1,2,3...15) cause my e.Values(0) =79 while e.Values(1) = 0, so,
79(2) = 01001111 and 0(2)=00000000. Is that right?
No, I just picked an arbitrary number of 2. It will return 2 words. Are you using the subscription callback and e.Vaues?
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 18, 2018, 10:04:46 AM
Now I am Testing with following
            Connection.Subscribe("B3:18", 2, 100, CallBackHandlerB18);
Do I hope that I will get B3:18 (0 to 15) and B3:19 (0 to 15) in CallBackHandlerB18 e.values?

update

I am not getting any data in CallBackHandlerB18 ...

When I do this
            Connection.SubscriptionDataReceived += CallBackHandlerB18Global;
I get call to CallBackHandlerB18Global.

Do I use values in e.Values like this?
int valueint1 = Convert.ToUInt16(e.Values[0]);
var value1 = Convert.ToString(valueint1, 2);
int valueint2 = Convert.ToUInt16(e.Values[1]);
var value2 = Convert.ToString(valueint2, 2);
           
then each char is a Tag value?

UPDATE:

Works like Charm....

For Anyone who wants to this sollution then here it is,

do
EthernetIPforSLCMicroCom  Connection = new EthernetIPforSLCMicroCom ();
//Setup Ip
Connection.Subscribe("B3:18", 2, 100, CallBackHandlerB18);
Connection.SubscriptionDataReceived += CallBackHandlerB18Global;

CallBackHandlerB18- Dont bother to implement- never called

public void CallBackHandlerB18Global(object sender, SubscriptionEventArgs e)
        {
            var value1 = Convert.ToString(Convert.ToUInt16(e.Values[0]), 2);//B3:18
            var value2 = Convert.ToString(Convert.ToUInt16(e.Values[1]), 2);// B3:19
            }
        }

Now if you have configured B3:18 0 to 11, like in my case,

Reverse string

public string Reverse( string s )
{
    char[] charArray = s.ToCharArray();
    Array.Reverse( charArray );
    return new string( charArray );
}

then
var newvalue = Reverse(value1);
if(value1.Length!= 11)
{
for(int i = 0;i<11-value1.Length;i++)
{
//Append enough Zeros to make it 11 char in length
newvalue1 += "0";
}
}

do same for B3:19 based on configured Bits (B3:19 0 to 6 7 flags)


 for (int i = 0; i < newvalue1.Length; i++)
            {
                File.AppendAllText("E:/value.txt", $"value of B3:18/{i} is {(newvalue1 == '1').ToString()}" + Environment.NewLine);
            }


 for (int i = 0; i < newvalue2.Length; i++)
            {
                File.AppendAllText("E:/value.txt", $"value of B3:19/{i} is {(newvalue2 == '1').ToString()}" + Environment.NewLine);
            }

If you subscribe to multiple Tags on a Same Connection like
Connection.Subscribe("B3:18", 2, 100, CallBackHandlerB18);
Connection.Subscribe("F20:0", 90, 100, CallBackHandlerF20);
Connection.SubscriptionDataReceived += CallBackHandlerGlobal;

Then Both callbacks will call CallBackHandlerGlobal with e.PLCAddress = "B3:18"/"F20:0". so you can Fetch values accordingly. CallBackHandlerB18 & CallBackHandlerF20 are never called.

And thats all!!!!!!! 8)

Thanks Archie and bachphi for support.
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 18, 2018, 06:20:52 PM
I am glad it's working for you using SubscriptionDataReceived event, but your case could be similar to this:
https://www.advancedhmi.com/forum/index.php?topic=1823.msg10155#msg10155

I did a test using Archie example and it's work fine for me , including bit. I am using 399y beta10, btw.

Code: [Select]
Imports AdvancedHMIDrivers

Public Class Form1

    Public PLC As EthernetIPforSLCMicroCom = New EthernetIPforSLCMicroCom()

    Private SubID, SubID2, SubID3 As Integer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        PLC.IPAddress = "192.168.1.10"
        PLC.PollRateOverride = "0"
        '
        SubID = PLC.Subscribe("T4:0.ACC", 1, 0, AddressOf DataReturned) '
        SubID2 = PLC.Subscribe("B3:1/0", 1, 0, AddressOf DataReturned)
        SubID3 = PLC.Subscribe("B3:1", 2, 0, AddressOf DataReturned)
    End Sub

    Private Sub DataReturned(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        If e.PlcAddress = "T4:0.ACC" Then
            Label1.Text = e.Values(0)
        End If
        If e.PlcAddress = "B3:1/0" Then
            Label2.Text = e.Values(0)
        End If
        If e.PlcAddress = "B3:1" Then
            Label3.Text = e.Values(0)
            Label4.Text = e.Values(1)
        End If

    End Sub

End Class
Title: Re: EthernetIPforSLCMicroCom
Post by: dhananjay.j@outlook.com on May 19, 2018, 02:05:53 AM
I am glad it's working for you using SubscriptionDataReceived event, but your case could be similar to this:
https://www.advancedhmi.com/forum/index.php?topic=1823.msg10155#msg10155

What is the "DINTTag" or "dateTime[0]" Mentioned in your Link? Looks like some sort of Connection status strategy to me...

2. You subscribed to multiple Tags with same Callback and the you are sorting data using PLCAddress. I guess thats the catch. I was subscribing to diff tags with individual CallBackHandler. (like CallbackHandlerforB18& CallbackHandlerforF20) etc. which is why None of them were ever called. I'll put same callback for all tags and see what happens but the fact that I cannot have a Different callback for each subscriptionID looks strange.

Archie can we categorize this as a Bug, CallBacks should be called based on either PLCAddress or SubscriptionID. Let me know.
Title: Re: EthernetIPforSLCMicroCom
Post by: bachphi on May 19, 2018, 07:19:57 AM
Quote
What is the "DINTTag" or "dateTime[0]" Mentioned in your Link? Looks like some sort of Connection status strategy to me...
DINTTag translates loosely to N7:0 (INT) in RSLogix500 and dateTime[0] is element 0 of an array integer/ dint/string