2using System.Collections.Generic;
3using System.Threading.Tasks;
23 private string @
namespace;
24 private string eventId;
25 private string actorName;
26 private string eventArgs;
46 public string Name => this.name;
92 public override Task
FromXml(XmlElement Definition)
95 this.@
namespace = XML.Attribute(Definition,
"namespace");
100 return Task.CompletedTask;
108 this.actor = this.Parent as
IActor;
109 if (!(this.actor is
null))
112 throw new Exception(
"External event registered on a node that is not an actor.");
114 return base.Initialize();
123 throw new Exception(
"Event not found: " + this.eventId);
125 this.@
event.Register(
this);
136 public virtual void Trigger(
IActor Source, params KeyValuePair<string, object>[] Arguments)
140 if (!
string.IsNullOrEmpty(this.actorName))
143 if (!(Arguments is
null))
145 foreach (KeyValuePair<string, object> Argument
in Arguments)
146 Variables[Argument.Key] = Argument.Value;
149 this.@
event?.Trigger(Variables);
159 return new Parameter[] {
new Parameter(
this, this.
Model,
"e",
string.IsNullOrEmpty(this.eventArgs) ?
"e" : this.eventArgs) };
Root node of a simulation model
Variables GetEventVariables(IActor Actor)
Gets a collection of variables for a new event.
bool TryGetEvent(string Id, out IEvent Event)
Tries to get a registered event from the model.
Abstract base class for actors
Abstract base class for events
Sets a variable to the value of an event parameter.
Abstract base class for simulation nodes
ISimulationNode Parent
Parent node in the simulation model.
Abstract base class for XMPP actors.
const string XmppSchema
TAG.Simulator.XMPP.Schema.ComSimXmpp.xsd
const string XmppNamespace
http://lab.tagroot.io/Schema/ComSim/XMPP.xsd
Abstract base class for handler nodes
abstract void RegisterHandlers(IActor Actor, XmppClient Client)
Registers handlers on the XMPP Client.
string EventArgs
Variable name for the event arguments
override Task Start()
Starts the node.
string EventId
Event to trigger
IEnumerable< Parameter > Parameters
Parameters
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
HandlerNode(ISimulationNode Parent, Model Model)
Abstract base class for handler nodes
string ActorName
Variable name of the actor
string HandlerNamespace
Namespace for the handler
virtual void Trigger(IActor Source, params KeyValuePair< string, object >[] Arguments)
Method called when an external event has been received.
override string SchemaResource
Points to the embedded XML Schema resource defining the semantics of the XML namespace.
override string Namespace
XML Namespace where the element is defined.
override Task Initialize()
Initialized the node before simulation.
string Name
Local element name for the handler
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
object ActivityObject
Returns the object that will be used by the actor for actions during an activity.
Interface for external events.
Interface for nodes that can register external events.
void Register(IExternalEvent ExternalEvent)
Registers an external event on the actor.