You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

How to port the OpenMI environment from Windows to Linux

Table of contents

1. Introduction

The document describes how to generate and run Linux dlls and executables from the original Windows C# sources. This is done by using Mono, a .NET Open Source project on different platforms. Only few adjustments are necessary in order to port the complete OpenMI functionality:

  • the standard OpenMI.Standard
  • the source development kit Oatc.OpenMI.Sdk.*
  • the dlls and executables Oatc.OpenMI.Gui.* for running OpenMI in the configuration editor with GUIs or from command line. 

2. Technical prerequisites

2.1. Machine and OS of the test system

  • workstation with an Intel Xeon processor
  • 64bit openSUSE 11.0

    2.2. Mono

  • Mono v. 1.9.1. for openSUSE 11.0 in 64 bit mode. V. 1.9.1. is also referred to as Mono 2.0.
  • The standard and the sdk sources should be compilable with previous versions. But the GUIs require Windows.Forms, which has been shipped with v. 1.9.1. in Oct. 2009.

2. How to compile and execute a Mono application

Command for generating a dll:

gmcs -target:library -out:<target>.dll -r<linkedLib_1>.dll,<linkedLib_k>.dll -pkg:<package_1>.pc;...;<package_m>.pc <source_1>.cs <source_n>.cs

-r:<linkedLib_?>.dll : reference to linked shared libraries (path and name)

-pkg:<package_?>.pc : ASCII files (path and name), that refer to linked shared libraries <linkedlib_?>.dll. They contain the path and the version of the dll. Example for the Windows.Forms:

prefix=/usr/lib/mono/2.0
exec_prefix=${prefix}
libdir=${exec_prefix}
Name: WindowsForms
Description: Windows Forms
Version: 2.0
Libs: -r:${libdir}/System.Windows.Forms.dll

Command for generating an exe file:

gmcs -out:<target>.exe -r<linkedLib_1>.dll,<linkedLib_k>.dll -pkg:<package_1>.pc;...;<package_m>.pc <source_1>.cs <source_n>.cs

Further compile information for resources is given in section 3.3..
Applications compiled with Mono do not run directly on the linux system, they are interpreted on a runtime engine, comparable to the virtual machine in java. Thus, the command in the terminal window command line has to start with mono, e.g.:

mono Oatc.OpenMI.GUI.ConfigurationEditor.exe

3. How to port C# sources of ...
3.1. ... the standard OpenMI.Standard.dll 1.4.0
The original source code can be compiled without any changes.
3.2. ... the sdk Oatc.OpenMI.Sdk.*.dll 1.4.1
The original source code can be compiled without any changes.
3.3. ... the GUIs Oatc.OpenMI.Gui.*.dll 1.4.1
The GUI sources use Windows.Forms, that works with resource files in order to design the graphical elements. The Windows resource files (*.resx) are generated automatically in the Microsoft Visual Studio IDE. Linux applications do not process them and create a "resource not found" exception during runtime. Thus, the resources have to be converted with the Mono tool resgen / resgen2. The following command generates a Linux readable resource <name>.resource:
resgen <name>.resx generates a Linux readable resource <name>.resource .
Visual Studio assigns a resource file to a C# file occurs automatically. On a linux machine naming conventions guarantee the correct assignment. On linux systems C# and resource file must have the same prefix. This first part of the prefix must be the namespace. Example for ElementSetViewer in the namespace Oatc.OpenMI.Gui.Controls:
• Oatc.OpenMI.Gui.Controls.ElementSetViewer.cs
• Oatc.OpenMI.Gui.Controls.ElementSetViewer.resources
Not all resources can be processed by Mono. Mono 2.0 has nearly the full functionality of Windows.Forms. It does not support the WindowsPresentationFoundation WPF, shipped since .NET 3.0, which generates resources in XAML style or logical resources. Thus, it is highly recommended to leave out any WPF elements in future OpenMI GUIs.
Mono uses the same error message as Windows. You look them up on the MSDN homepage.
Resources: The original Windows resources contained *.bmp graphics with a 24bit colour depth. Linux could not process them. The solution was to convert the BMPs externally to 8bit GIFs, before adding them to the resource in the Visual Studio IDE.

3.3.1. CommandLine
no changes
3.3.2. ConfigurationEditor
• Individual cursors (Source, Target) can't be displayed, but connecting models works
• ConnectionDialog:
todo:
"Apply" a connection
-> runtime error
listLinks.SelectedIndex = selectedIndex; // = -2;
3.3.3. Control
• ExchangeItemSelector
Filters for ElementSet and Dimension
Collapse of treeViews
3.3.4. Core
no changes

5.1 The Simple River Wrapper

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

Fig. 13 Simple River wrapper classes

  • No labels