Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Code Block
        // event args which will be used only when we need to pass additional data there, otherwise null
        public interface ILinkableComponentEventArgs
        {
                EventType Type { get; }
		string Description { get; }
		DateTime Time { get; }
                IExchangeItem ChangedItem { get; }
                bool Stop { get; set; } // used if simulation should be stopped!
        }


        public enum EventType 
	{
		Warning,
		Informative,
		ValueOutOfRange,
		GlobalProgress,
		TimeStepProgres,
		DataChanged,
		TargetBeforeGetValuesCall,
		SourceAfterGetValuesCall,
		SourceBeforeGetValuesReturn,
		TargetAfterGetValuesReturn,
		Other
	}

    // C# way
    
    public delegate void LinkableComponentEventHandler(object source, ILinkableComponentEventArgs args);

    public interface ILinkableComponent
    {
        event LinkableComponentEventHandler Progressed;
    }





    // Java way (Observable is a class, Observer is an interface!)

    public interfaceclass LinkableComponentEventHandlerLinkableComponentObservable :extends Observable
    {
        public void setLinkableComponentEventArgsnotifyObservers(ILinkableComponentEventArgs args);
        ILinkableComponentEventArgs getLinkableComponentEventArgs();
    }}


    public interface ILinkableComponent
    {
        public LinkableComponentEventHandlerLinkableComponentObservable getProgressedEventgetObservable();
    }    

From usage point of view it will simplify a lot since:

  • User will not need to implement anything when implementing ILinkableComponent (minus 5 methods!)
  • User will need only to call event when necessary.
  • Differences between Java and C# will be really only in syntax since event in C# is almost equal to Java Observable.

Example of usage:

...

Here we are (only) replacing the OpenMI definition of the IListener and IPublisher interfaces in the Standard with the language specific classes that implement the notification/event mechanism in C# and Java. Development becomes a little bit easier (which in my opinion can also (and better) be done in the SDK), but the Standard no longer contains only interfaces and becomes more implementation language specific.

Logging in the OpenMI SDK

...