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
scrollbar

Table of contents

Table of Contents
Include Page
OPENMI:1 IntroductionOPENMI:
1 Introduction
Include Page
OPENMI:2 Planning the migrationOPENMI:
2 Planning the migration
Include Page
OPENMI:3 WrappingOPENMI:
3 Wrapping

4. Migration - step by step

The best strategy when migrating a model is to split the process into a number of steps; at the end of each step you can compile your code and run a small test.

The steps needed for migration are described in this chapter.

Include Page
OPENMI:4.1 Step 1 - Changing your engine coreOPENMI:
4.1 Step 1 - Changing your engine core
Include Page
OPENMI:4.2 Step 2 - Creating the .Net assembliesOPENMI:
4.2 Step 2 - Creating the .Net assemblies
Include Page
OPENMI:4.3 Step 3 - Accessing the functions in the engine coreOPENMI:
4.3 Step 3 - Accessing the functions in the engine core
Include Page
OPENMI:4.4 Step 4 - Implementing the MyEngineDotNetAccessOPENMI:
4.4 Step 4 - Implementing the MyEngineDotNetAccess
Include Page
OPENMI:4.5 Step 5 - Implementing the MyEngineWrapper classOPENMI:
4.5 Step 5 - Implementing the MyEngineWrapper class
Include Page
OPENMI:4.6 Step 6 - Implementing the MyModelLinkablComponentOPENMI:
4.6 Step 6 - Implementing the MyModelLinkablComponent
Include Page
OPENMI:4.7 Step 7 - Implementation of the remaining IEngine methodsOPENMI:
4.7 Step 7 - Implementation of the remaining IEngine methods

5. Migration of the Simple River

The previous chapter described the steps involved in migrating a model to the OpenMI.

This

...

chapter shows how the migrated code is developed for the Simple River example.

5.1 The Simple River Wrapper

The Simple River model uses the migration pattern shown in Figure 4-912. Figure 4-21 13 gives a detailed explanation of how the Simple River wrapper works in terms of the wrapper classes.

...

Fig. 13 Simple River wrapper classes

Include Page
OPENMI: 5.2 Implementation of the Initialize methodOPENMI:
5.2 Implementation of the Initialize method
Include Page
OPENMI: 5.3 Implementing the SetValues methodOPENMI:
5.3 Implementing the SetValues method
Include Page
OPENMI: 5.4 Implementing the GetValues methodOPENMI:
5.4 Implementing the GetValues method
Include Page
OPENMI: 5.5 Implementation of the remaining methodsOPENMI:
5.5 Implementation of the remaining methods

6. Testing the component

It is important to test the component to check that it is working correctly. Traditionally, the procedure has been to complete implementation and then run the engine to see if it produces the correct results. However, in recent years new methodologies have been developed for testing. The dominant testing method for object oriented programs is unit testing. Unit testing is done in parallel with the implementation. This means that you will be able to find errors earlier and thus save time on debugging your code later.

This chapter discusses the testing of migrated components.

Include Page
OPENMI: 6.1 Unit testingOPENMI:
6.1 Unit testing
Include Page
OPENMI: 7. Implementing IManageStateOPENMI:
7. Implementing IManageState

7. Implementing IManageState

Implementation of the IManageState interface is not required in order to claim OpenMI compliance. However, if you want to use your model in configurations where iterations are needed or you want to use calibration or optimization controllers, the implementation of the IManageState interface is required. Normally, you should put the bulk of the implementation into the engine core and save the data required in order to restore a state in memory.

7.1 The IManageState interface

Implementation of the IManageState interface is shown in Figure 20.

...

  1. In MyLinkableEngine, specify that it implements the IManageState interface.
  2. In MyEngineWrapper, specify that it implements the IManageState interface.
  3. Implement the IManageState methods in all wrapper classes. The implementation will typically be very simple code that redirects the call to the next wrapper class and finally to the engine core, where the bulk of the implementation is located.

Image Removed
Fig. 20. IManageState implementation

8. The OMI file

The OMI file defines the entry point to a LinkableComponent. It contains information on the software unit to instantiate and the arguments to provide at initialization. This file makes it possible for a user interface to deploy your model.

...

8.1 Structure of the OMI file

The structure of the OMI file is defined in OpenMI.Standared.LinkableComponent.XSD. (http://www.openmi.org/schemas/LinkableComponent.xsd) Figure 21 provides a visual representation of the schema definition; The XML listing below provides an example of an OMI file.

Image Removed
Fig. 21. Visual representation of the LinkableComponent XML schema definition.

OMI file Example:

Code Block

<?XML version='1.0'?> <LinkableComponent Type='org.OpenMI.Examples.MC.SimpleRain' Assembly='org.OpenMI.Examples.MC, Version=1.4.0.0, Culture=neutral, PublicKeyToken= 8384b9b46466c568' XMLns='http://www.openmi.org/LinkableComponent.xsd'> <Arguments>    <Argument Key='Data' ReadOnly='true' Value='c:\OpenMI\Examples\Data\SimpleRain.txt' /> </Arguments> </LinkableComponent>

9. The OpenMICompliancyInfo file

OpenMI compliant components must be associated with an OpenMI compliance info file. This file useful information for people that are planning to use the component in an OpenMI configuration. The OpenMI compliance info file must comply to the schema OpenMICompliancyInfo.xsd ((http://www.openmi.org/schemas/OpenMICompliancyInfo.xsd)).

...

Include Page
8. The OMI file
8. The OMI file
Include Page
9. The OpenMICompliancyInfo file
9. The OpenMICompliancyInfo file

...