EcoStruxure Machine Expert Twin provides an infrastructure for sending messages between objects.
The basic steps are.
1. Register an object as a listener
Core.Communication.Internal.AddListener(object listener, RecieveMessage method)
For example
Core.Communication.Internal.AddListener(this, ReceiveMethod);
Where a method like this should be provided.
void ReceiveMethod(object sender, object reciever, object message, bool broadcast)
2. Send a message to a known receiver
Core.Communication.Internal.SendMessage(object sender, object reciever, object message)
Broadcast a message to all listeners.
Core.Communication.Internal.BroadcastMessage(object sender, object message)
Broadcast a message to all listeners of a specific type.
Core.Communication.Internal.BroadcastMessage(object sender, Type recieverType, object message)
Broadcast a message to all listeners of a specific type (FullName).
Core.Communication.Internal.BroadcastMessage(object sender, string recieverTypeFullName, object message)
3. When an object should stop listen or is disposed it should be removed.
Core.Communication.Internal.RemoveListener(object listener)
Note: The specified delegate of the reciever is executed synchronously.