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!!!!!!!
Thanks Archie and bachphi for support.