How To Make Your Component Compliant
-
Upload
jan-gregersen -
Category
Technology
-
view
605 -
download
2
description
Transcript of How To Make Your Component Compliant
How to make your model OpenMI compliant
Jan Gregersen LicTek / DHI
Jan Gregersen
My model
Connecting things - When two and two is five
USB
• Provides freedom of choice for the users• Provides opportunities for suppliers
Standard
Introduction
Jan Gregersen
My model
How does OpenMI work : OpenMI is OO
Very short introduction to Object Oriented programming
Class Rectangle double diagonal
Class PolygonString IDdouble Areabool IsPointInside(double x, double y)double GetOverlapping Area(Polygon polygondouble GetDistanceToPoint(double x, double y)
Class PolylineString IDdouble GetDistanceToPoint(double x, double y)
Interface Geometrystring IDdouble DistanceToPoint (double x, double y)
implements implements
inherits
How does OpenMI work
Jan Gregersen
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
From outside all OpenMI compliant components look the same
OpenMI.Standard.ILinkableComponent
How does OpenMI work : ILinkableComponent
River model
RR model
How does OpenMI work
Jan Gregersen
My model
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
1. Read OMI file
2. Create component
3. Invoke (call) Initialize1. Component will read input files and
initialize
How does OpenMI work : GUI Add model
How does OpenMI work
Jan Gregersen
My model
How does OpenMI work : The OMI file
<?xml version="1.0"?><LinkableComponent Type=“RainfallRunoffModelLC" Assembly="..\bin\RainfallRunoffModel.dll"> <Arguments> <Argument Key=“Path" ReadOnly="true" Value=“..\data" /> </Arguments></LinkableComponent>
How does OpenMI work
Jan Gregersen
My model
How does OpenMI work : Model properties
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
How does OpenMI work
Jan Gregersen
My model
How does OpenMI work : Create and add link
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
1. Query and display exchange items
2. User selects output and input
3. Create a link object
4. Add the link to both components
How does OpenMI work
Jan Gregersen
My model
How does OpenMI work : ExchangeItems
Where What
How
How does OpenMI work
Jan Gregersen
My model
How does OpenMI Work : GetValues()
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
GetValues(time)
GetValues(time)
How does OpenMI work
Jan Gregersen
My model
How does OpenMI Work : GetValues()
GetValues(time)My modelGetValues(time)
ID-Based link Geo-referenced bi-directional link
How does OpenMI work
Jan Gregersen
How does OpenMI Work : The Standard
Jan Gregersen
How to migrate models
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
My model
Run
How most models are organized
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
My model
Run
OpenMI is linking models
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
My model
RunOpenMI.Standard
<<ILinkableComponent>>
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
Some model
My model
GetValues()
GetValues()
RunOpenMI.Standard
<<ILinkableComponent>>
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizonint InputExchangeItemCountIInputExchangeItem GetInputExchangeItem(int inputExchangeItemIndex)int OutputExchangeItemCountIOutputExchangeItem GetOutputExchangeItem(int outputExchangeItemIndex)
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
How do I set values ?
How to migrate models
Jan Gregersen
The OpenMI SDK• Source code C# (and
Java)• Default implementaion• Wrapper• Targeting developers
The OpenMI Standard
• The OpenMI.Standard interfaces• The OpenMI standard definition• XSD’s
• Provided by OA• Rigid release proceedure• Non frequent releases• The one and only
Standard• Makes components
linkable
How to migrate models: SDK: Balancing stability and flexibility
• Provided by OATC• Flexible release
proceedures• Frequent releases• One of many• Makes OpenMI easier• OATC.SDK targeting models• Not required• Components compliant to
same version of the standard can be linked regardless of which SDK is used.
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
Some model
My model
SDK(Wrapper)
GetValues()
GetValues()
Run
Oatc.OpenMI.Sdk<<IEngine>>
OpenMI.Standard<<ILinkableComponent>>
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
Some model
My model
SDK(Wrapper)
GetValues()
GetValues()
Run
Oatc.OpenMI.Sdk<<IEngine>>
OpenMI.Standard<<ILinkableComponent>>
// -- Execution control methods (Inherited from IRunEngine) --
void Initialize(Hashtable properties);
bool PerformTimeStep();
void Finish();
//-- Time methods (Inherited from IRunEngine) --
ITime GetCurrentTime();
ITime GetInputTime(string QuantityID, string ElementSetID);
ITimeStamp GetEarliestNeededTime();
//-- Data access methods (Inherited from IRunEngine) --
void SetValues(string QuantityID, string ElementSetID, IValueSet values);
IValueSet GetValues(string QuantityID, string ElementSetID);
//-- Component description methods (Inherited from IRunEngine) --
double GetMissingValueDefinition();
String GetComponentID();
string GetComponentDescription();
// -- Model description methods --
string GetModelID();
string GetModelDescription();
double GetTimeHorizon();
// -- Exchange items --
int GetInputExchangeItemCount();
int GetOutputExchangeItemCount();
org.OpenMI.Backbone GetInputExchangeItem(int exchangeItemIndex);
org.OpenMI.Backbone GetOutputExchangeItem(int exchangeItemIndex);
How to migrate models
Jan Gregersen
User Interface
Input file
Output file
Engine
Write
Read
Write
Some model
My model
SDK(Wrapper)
GetValues()
GetValues()
Run
Oatc.OpenMI.Sdk<<IEngine>>
OpenMI.Standard<<ILinkableComponent>>
Buffers results from the engine core
Mapping of values associated to one array of times /timespans to values represented on another array of times/timespans
t t
Mapping of values associated to one ElementSet to be represented on another ElementSet
• Link administration
• Exception handling
• Events handling
• And more..
How to migrate models
Jan GregersenHow to migrate models
void Initialize(IArgument[] properties)
string ComponentIDstring ComponentDescriptionstring ModelIDstring ModelDescriptionITimeSpan TimeHorizon
IInputExchangeItem GetInputExchangeItem(int index)IOutputExchangeItem GetOutputExchangeItem(int idex)int InputExchangeItemCountint OutputExchangeItemCount
void AddLink (ILink link)void RemoveLink(string linkID)string Validate()
void Prepare()IValueSet GetValues(ITime time, string linkID)ITimeStamp EarliestInputTime
void Finish()void Dispose()
// -- Execution control methods (Inherited from IRunEngine) --
void Initialize(Hashtable properties);
bool PerformTimeStep();
void Finish();
//-- Time methods (Inherited from IRunEngine) --
ITime GetCurrentTime();
ITime GetInputTime(string QuantityID, string ElementSetID);
ITimeStamp GetEarliestNeededTime();
//-- Data access methods (Inherited from IRunEngine) --
void SetValues(string QuantityID, string ElementSetID, IValueSet values);
IValueSet GetValues(string QuantityID, string ElementSetID);
//-- Component description methods (Inherited from IRunEngine) --
double GetMissingValueDefinition();
String GetComponentID();
string GetComponentDescription();
// -- Model description methods --
string GetModelID();
string GetModelDescription();
double GetTimeHorizon();
// -- Exchange items --
int GetInputExchangeItemCount();
int GetOutputExchangeItemCount();
org.OpenMI.Backbone GetInputExchangeItem(int exchangeItemIndex);
org.OpenMI.Backbone GetOutputExchangeItem(int exchangeItemIndex);
OpenMI.Standard.IlinkableComponent
Oatc.OpenMI.Sdk.Wrapper.IEngine
Jan GregersenHow to migrate models
<< interface >>OpenMI.Standard.ILinkableComponent
<< interface >>Oatc.OpenMI.Sdk.Wrapper.IEngine
<< abstract class >>Oatc.OpenMI.Sdk.Backbone.LinkableComponent
<< abstract class >>Oatc.OpenMI.Sdk.Wrapper.LinkableEngine
<< Class >>RiverModel.Engine
<< dll >>Fortran Engine
<< Class >>Rivermodel.EngineWrapper
<< Class >>Rivermodel.LinkableComponent
Implements
Implements
Inherits
Inherits
access
access
IEngine
access
create
Migration design pattern
Jan Gregersen
1. Make sure that your engine is a Dll not a Exe
2. Separate initialization, Perform time step, and finalization
3. Implement IEngine
4. Attach the SDK wrapper
5. Done
Five steps to a compliant model
How to migrate models
Jan Gregersen
Thank you for your attention