Using The NET Component
Using The NET Component
iFIX 2022
Using the .NET Component
No part of this publication may be reproduced in any form, or stored in a database or retrieval system, or transmitted or distributed in any
form by any means, electronic, mechanical photocopying, recording or otherwise, without the prior written permission of General Electric
Company. Information contained herein is subject to change without notice.
Trademark Notices
GE, the GE Monogram, and Predix are either registered trademarks or trademarks of General Electric Company.
Microsoft® is a registered trademark of Microsoft Corporation, in the United States and/or other countries.
We want to hear from you. If you have any comments, questions, or suggestions about our documentation, send them to the following email
address:
[email protected]
Table of Contents
Introduction 3
Browse Tree 6
Add Components 6
Add Group 6
Delete Node 6
Help 6
Example 8
To access font properties for Windows Forms components from the iFIX WorkSpace: 9
Example 9
To access font properties for Windows Presentation Framework components from the iFIX
WorkSpace: 11
Example 11
Scripting in VBA 12
Using Intellisense® 13
Example 1 17
Example 2 19
Example 21
Advanced Features 25
Example 26
To add a new component to a single system using the Component Browser dialog box: 29
Events 32
Error Logging 34
Index 37
The .NET Component feature for iFIX allows you to host .NET components within your iFIX pictures.
These .NET Components include pre-selected ones from the .NET Framework, samples from GE, or cus-
tom ones that you develop or buy.
Creating custom components requires proficiency in Microsoft® Visual Studio® 2010 and the .NET Frame-
work. In addition, to develop your own .NET components, you must be proficient in programming with the
.NET Framework. For iFIX scripting, you must have a working knowledge of the Visual Basic programming
language.
To help you use the .NET Component feature, this Help file includes the following sections:
l Introduction
l General Overview of Component Hosting
l Advanced Features
The .NET Component feature allows you to host .NET components within your iFIX pictures. All hosted
.NET components will look and function as OLE objects (ActiveX controls) within your iFIX pictures. Just
as other iFIX controls allow you to access the Property Window and Basic Animations dialog box, so do
hosted .NET components. Screen editing actions, such as Select, Move, Resize, Delete, Undo, Copy, and
Paste are all supported for .NET components as well.
The Component Hosting feature is installed by default when you install iFIX.
NOTES:
l The Backup and Restore Utility does not support backing up .NET Component files.
l .NET Component is not supported on the XP Embedded OS.
l Upgrading or in any way re-installing iFIX will result in replacing any .NET Component files that are supplied
with the product install. This includes sample files such as Visual Studio solutions and projects in the Sample
Components folder which you may have modified. If you have modified these files, they will lose their changes
on an upgrade or re-install of iFIX. If you make any changes to these Visual Studio files, they should be backed
up prior to upgrade/re-install.
l If a user is a member of the Power Users group in Windows security, that user will be unable to open pictures
with .NET components in them unless an Administrator has previously opened that picture on that PC. When an
Administrator opens the picture they register the .NET assemblies for the contained controls on that machine,
which allows Power Users to later open that same picture. Standard Windows Users do not encounter this same
problem. This note applies to Power Users in Windows Vista and later.
You can access the .NET Component on the Insert menu in the iFIX WorkSpace, as shown in the following
figure.
You can access the .NET Component on the Insert tab in the iFIX WorkSpace by selecting Objects/Links,
and then clicking .NET Component. The .NET Component Browser dialog box appears, as shown in the fol-
lowing figure.
l Exposes the public properties, methods, and events of the underlying .NET control.
l Provides type descriptions to support property editing and binding, method invocation, and event
handling with the iFIX user interface and scripting.
The .NET Component Browser dialog box allows you to manage .NET components for use within your iFIX
pictures. After selecting it from Objects/Links on the Insert tab in the iFIX WorkSpace, the .NET Com-
ponent Browser dialog box appears as shown in the following figure.
Browse Tree
The tree allows you to browse the .NET components installed on your computer and in the sample pro-
jects folder.
Add Components
Click to add a new set of components from a .NET assembly to the list of components in the browser.
Add Group
Click to add a new group in the browser.
Delete Node
Select an Assembly node or an empty Group node and click Delete to remove it from the browse tree.
Help
Click to display this Help file.
The components initially listed in the .NET Component Browser dialog box are built-in components that
can be used immediately. These supported .NET control types describe the kinds of .NET classes (types)
Component hosting in iFIX supports both Windows Forms (WinForms) and Windows Presentation Frame-
work control types in the Microsoft .NET Framework. You can find these built-in controls in the .NET Com-
ponent Browser dialog box. One group is labeled "Windows Forms," and the other group is named
"Windows Presentation Framework." The Windows Forms group contains the Sys-
tem.Windows.Forms.DataVisualization and System.Windows.Forms assemblies. The Windows Present-
ation Framework group contains the PresentationFramework assemblies. The following figure illustrates
these groups and assemblies.
The individual controls contained in each of these subfolders cover the majority of .NET controls used for
non-web-based applications.
You can access the .NET Component feature on the Insert menu in the iFIX WorkSpace. This menu option
opens the .NET Component Browser dialog box, allowing you to select a .NET component to insert into
your picture. After you insert the component into your picture, you can modify the properties and then
bind the component to a data source to any of these properties.
1. In the iFIX picture, select the .NET Component for which you want to view the properties.
2. Right-click the component and select Property Window. The Property Window appears, if it is not
already displaying.
3. Scroll through the Alphabetic list to locate the property that you want to view or modify.
1. In the iFIX WorkSpace, right-click the .NET component and select Animations. The Basic Anim-
ations Dialog appears.
2. Under Advanced Animations, click the Configure button. The .NET Component Animations dialog
box appears.
3. On any of the tabs, locate the property that you want to bind to a data source, and then click the
Animate check box next to the property. The Data Source area appears below the list of prop-
erties (if it is not already displaying).
4. Next to the Data Source field, click the Browse (...) button. The Expression Builder dialog box
appears.
5. Select a data source and click OK.
6. Enter the Animation or Historical Properties and click OK. For more information on creating data
sources, refer to the Creating Pictures e-book.
Example
The following example shows how to set the Reading property of the LinearGauge sample object to a
Float data type that has a value range from 0 to 100, and a data source of the current value. This
example assumes that you already have a RAMP block created within the iFIX database.
For information on working with font and enumeration properties of .NET Components, refer to the fol-
lowing sections:
Windows forms-based controls use the Font class (System.Drawing.Font) to access the font element in
painting their graphics. The Font class is converted to an interface that is compatible to the VBA
IFontDisp interface. As a result, any font properties of Windows forms-based controls may be configured
the same way ActiveX controls are configured in the iFIX WorkSpace.
To access font properties for Windows Forms components from the iFIX WorkSpace:
1. In the iFIX picture, select the .NET Component for which you want to access the font properties.
2. Right-click the component and select Property Window. The Properties window appears, if it is not
already displaying.
3. Scroll through the Alphabetic list to locate the font property that you want to view or modify.
4. Click the ellipsis (...) button next to the font property. The Font dialog box appears.
5. Enter your changes and click OK.
Example
The following figure shows a Windows Forms CheckBox control (in the .NET Component Browser dialog
box: .NET Components > .NET Framework > Windows Forms > System.Windows.Forms > CheckBox) and
its Font property highlighted on the Property Window dialog box of the iFIX WorkSpace.
Windows Presentation Framework controls follow a different convention for font properties from Win-
dows Forms (WinForms) controls. For Windows Presentation Framework controls, the FontFamily class
only includes information for a font type. Other font structures, such as FontStretch, FontStyle, and
FontWeight, handle the various font styles and effects. For these controls, the size of a font is accessed
through a separate property usually called FontSize. As the Font dialog box is still the best way to select
from all available fonts, the FontFamily data type is converted to the IFontDisp compatible interface.
1. In the iFIX picture, select the .NET Component for which you want to access the font properties.
2. Right-click the component and select Property Window. The Property Window appears, if it is not
already displaying.
3. Scroll through the Alphabetic list to locate the font property that you want to view or modify.
4. Click the ellipsis (...) button next to the font property. The Font dialog box appears.
5. Enter your changes and click OK.
Example
The following figure shows a Windows Presentation Framework TextBlock control (in the .NET Com-
ponent Browser dialog box: .NET Components > .NET Framework > Windows Presentation Framework >
PresentationFramework > TextBlock) and its Font property highlighted on the Property Window dialog
box.
Click the ellipsis (...) button, and the Font dialog box appears. Be aware that unlike the Font dialog box for
the Windows Forms components, only a font type can be set within the Font dialog box for Windows
Presentation Framework controls. Other font properties can be set directly through separate font prop-
erties. For a TextBlock component, as shown in the previous figure, the properties are named: FontSize,
FontStretch, FontStyle, and FontWeight.
NOTE: Not all fonts support all FontStretch, FontStyle, and FontWeight settings.
All enumerations are internally numeric types, but enumeration types make property access easier as
they provide meaningful names for the underlying numeric values. For example, for a horizontal align-
ment property, instead of setting somewhat meaningless and error-prone numbers such as 0, 1, 2, and
so on, you can select a setting name such as Left, Center, and Right from the available setting list.
The following figure shows some enumeration properties of the Windows Presentation Framework Tex-
tBlock control in the iFIX Property Window editor.
Scripting in VBA
The Property Window editor and the Basic Animation dialog box in the iFIX WorkSpace allow for con-
figuration and binding of properties of primitive data types. Beyond these, the integrated VBA scripting
supported within iFIX allows for:
Because the hosting environment for the .NET Component exposes all the properties, methods, and
events of the underlying .NET component with appropriate data conversions, the underlying component
can be fully manipulated with VBA scripting.
The GEIP_Orion_DataConversion reference must be added to the project in the Microsoft Visual Basic
project in order to access .NET Component properties for non-primitive data types through scripting.
Optionally, you may also want to include the Microsoft ActiveX Data Objects Library (version 2.7 or
higher) or other references.
To add references in Microsoft Visual Basic:
1. In the iFIX WorkSpace, right-click the component and select Edit Script. The Microsoft Visual Basic
Editor appears.
2. On the Tools menu, click References. The References dialog box appears.
3. Scroll through the list of components and make sure check marks appear next to the references
you want to add. For instance:
l GEIP_Orion_DataConversion (for the .NET Component)
l Microsoft ActiveX Data Objects Library (version 2.7 or higher for other references)
4. Click OK.
Using Intellisense®
VBA scripting is assisted with IntelliSense because the hosting environment exposes the properties and
methods of the underlying .NET component with data types that VBA scripting supports. The following fig-
ure shows IntelliSense examples at work for the Chart object included in the Windows Forms folder.
Example
This example takes the Chart component from the Windows Forms (in the .NET Component Browser dia-
log box: .NET Components > .NET Framework > Windows Forms > Sys-
tem.Windows.Forms.DataVisualization > Chart), and adds a ChartArea object to it.
Without the ChartArea object, the Chart object appears only as a selectable area. This is because the
Chart component requires at least one ChartArea object to be added to it. As chart areas and their con-
tainer (Chart Area Collection) are complex data types, the Property Window editor in the iFIX WorkSpace
cannot handle them. The action, however, can be done with VBA scripting, as shown in the following
example.
IMPORTANT: This example assumes that you have the Microsoft Northwind sample database for SQL Server or SQL
Server Express for this example to work. If you use SQL Server, the Northwind database may already be installed. To
verify, check that Northwind is one of the databases installed on your system. If it is not installed (for either SQL Server
or SQL Server Express), you can obtain it from the Microsoft web site.
The first line defines a variable for the Chart Area object, and second line is for the component
event handlers for the examples in the Using Event Handlers section.
Chart1.Series(0).ChartType = SeriesChartType_Column
Chart1.Series(0).SetCustomProperty "DrawingStyle", "Cylinder"
conn.Close
End Sub
NOTE: You may need to modify the Provider or Data Source settings to specify different database settings. The
code above assumes you are using the Northwind database on your local computer. For instance, if you are
using SQL Server on another computer, and the computer name where the server resides is MyComputer, you
would replace .\localhost with MyComputer.
In the second code paragraph of this code snippet, the chartArea object is set to the result of call-
ing the Chart Area Collection object's method: Add(). The collection object is a property of the
Chart1 object, which has been added when the Chart component is constructed.
NOTE: For different system configurations (SQL Server, database, and tables), the code for the connection
string and record set selection and setting will require appropriate changes. The second string parameter of the
DataBindTable method must be a string column of the selected table, and the other selected columns must be
numeric. The other valid values for the second string parameter of the SetCustomProperty method are Emboss,
LightToDark, Wedge, and Default (refer to Microsoft help on System.Windows.Forms.DataVisualization).
14. Click the Save button on the toolbar to save the script.
15. Close the Microsoft Visual Basic Editor, and save the picture in the iFIX WorkSpace.
16. Select Run to view your picture. The chart should display similar to the following figure. (This
graph, however, was resized to a longer shape, after it was placed into the WorkSpace in step 5.)
When you are finished with the example, your code should look similar to this:
Dim chartArea As GEIP_Orion_DataConversion.FormsChartArea
Dim mouseDown As Boolean
Chart1.Series(0).ChartType = SeriesChartType_Column
Chart1.Series(0).SetCustomProperty "DrawingStyle", "Cylinder"
conn.Close
End Sub
As the generic wrapper exposes all the events defined by an underlying .NET component as a COM con-
nection point interface, the component events can be handled with VBA scripting.
Example 1
This first example takes the Chart component from the Windows Forms (in the .NET Component Browser
dialog box: .NET Components > .NET Framework > Windows Forms > Sys-
tem.Windows.Forms.DataVisualization > Chart), and adds the MouseDown, MouseMove, and MouseUp
event handlers.
1. Open the example iFIX picture from the Accessing Component Properties and Methods Through
Scripting section, and save it under a new name.
2. In the iFIX WorkSpace, right-click the Chart component and select Edit Script. The Microsoft Visual
Basic Editor appears.
3. Select the Chart1 object from the top-left object combo box, and then select the MouseDown
event. An empty event handler will be inserted to the current script.
4. Add a simple line to set the MouseDown variable to True. For example, the finished handler will
look similar to the following:
Private Sub Chart1_MouseDown(ByVal state As Long, ByVal x As Long, ByVal y As Long)
mouseDown = True
End Sub
5. Select the MouseMove event to add the event handler, and replace the code that was auto-
matically added with the following:
Private Sub Chart1_MouseMove(ByVal state As Long, ByVal x As Long, ByVal y As Long)
If mouseDown = True Then
chartArea.Area3DStyle.Inclination = (x Mod 90) / 2
chartArea.Area3DStyle.Rotation = (y Mod 180) / 2
End If
End Sub
6. Select the MouseUp event to add the event handler, and replace the code that was automatically
added with the following:
Private Sub Chart1_MouseUp(ByVal state As Long, ByVal x As Long, ByVal y As Long)
mouseDown = False
End Sub
NOTE: The original .NET events have been converted to Win32-like messages in this example. The X and Y val-
ues are the X and Y coordinates of the mouse pointer, respectively. The state value is the mouse button state
(not used here).
7. Click the Save button on the toolbar to save the script.
8. Go back to the iFIX WorkSpace, and switch to the Run mode.
9. Click the left mouse button on the chart graph, hold the button, and move the mouse down. The
chart will rotate and incline according the current mouse position. The following figure shows an
example of the chart at a rotated and inclined position.
When you are finished with Example 1, your code should look similar to this:
Dim chartArea As GEIP_Orion_DataConversion.FormsChartArea
Dim mouseDown As Boolean
Chart1.Series(0).ChartType = SeriesChartType_Column
Chart1.Series(0).SetCustomProperty "DrawingStyle", "Cylinder"
conn.Close
End Sub
This second example takes the same Chart component from the Windows Forms (in the .NET Component
Browser dialog box: .NET Components > .NET Framework > Windows Forms > Sys-
tem.Windows.Forms.DataVisualization > Chart), with the MouseDown, MouseMove, and MouseUp
events, and adds code for two columns. These columns come from another table in the Northwind data-
base. The code between the conn.Open and conn.Close references in the CFixPicture_Initialize() handler
from the first example is replaced with new code.
1. Open the example iFIX picture from the example above. Save it under a new name.
2. In the iFIX WorkSpace, right-click the Chart component and select Edit Script. The Microsoft Visual
Basic Editor appears.
3. Replace the code between conn.Open and conn.Close in the CFixPicture_Initialize() handler with
the following code (this code selects two numeric columns from another table in the Northwind
database):
rs.Open "select Top 50 OrderID, UnitPrice, Quantity from [Order Details]", conn
Chart1.DataBindTable rs, "OrderID"
rs.Close
Chart1.Series(0).ChartType = SeriesChartType_Column
Chart1.Series(0).SetCustomProperty "DrawingStyle", "Cylinder"
Chart1.Series(1).ChartType = SeriesChartType_Column
Chart1.Series(1).SetCustomProperty "DrawingStyle", "Cylinder"
When you are finished with Example 2, your code should look similar to this:
Dim chartArea As GEIP_Orion_DataConversion.FormsChartArea
rs.Open "select Top 50 OrderID, UnitPrice, Quantity from [Order Details]", conn
Chart1.DataBindTable rs, "OrderID"
rs.Close
Chart1.Series(0).ChartType = SeriesChartType_Column
Chart1.Series(0).SetCustomProperty "DrawingStyle", "Cylinder"
Chart1.Series(1).ChartType = SeriesChartType_Column
Chart1.Series(1).SetCustomProperty "DrawingStyle", "Cylinder"
conn.Close
End Sub
The event handlers, such as the MouseDown, MouseMove, and MouseUp event handlers described in the
Using Event Handlers section, are converted by the data conversion module from the corresponding .NET
event handlers. For component hosting in iFIX, key event handlers are converted to names similar to
their counterpart Win32 key messages.
Any non-converted parameters defined by a component are represented as Win32-like parameters, but
with two string arguments: the name of the event raiser, and the .NET argument type.
These string arguments are not very useful in these non-converted (more correctly, not fully converted)
cases. However, as the events are actually raised in the meaningful manners, these events can be
handled in a normal manner using the event raiser's properties and methods to access companion
information.
This example takes the DataGrid and ComboBox components from the Windows Presentation Frame-
work (in the .NET Component Browser dialog box: .NET Components > .NET Framework > Windows
Presentation Framework > DataGrid, and ComboBox), and adds some code to alternate the row color in
the table, and to allow you to use the ComboBox control to select a row in the DataGrid.
First, with the DataGrid object, we configure the AlternatingRowBackground component property. Then,
for the ComboBox object, we add the SelectionChanged event with two string parameters, because the
Windows Presentation Framework SelectionChangedEventArgs class contains unconverted parameters.
Both the DataGrid and ComboBox components support the SelectionIndex property, which allows you to
select a corresponding row in the DataGrid, using the ComboBox control.
IMPORTANT: This example assumes that you have the Microsoft Northwind sample database for SQL Server or SQL
Server Express for this example to work. If you use SQL Server, the Northwind database may already be installed. To
verify, check that Northwind is one of the databases installed on your system. If it is not installed (for either SQL Server
or SQL Server Express), you can obtain it from the Microsoft web site.
When you are complete, the following four properties should have these settings:
rs.MoveFirst
Do While Not rs.EOF
ComboBox1.Items.Add CStr(rs!CustomerID)
rs.MoveNext
Loop
ComboBox1.SelectedIndex = 0
rs.Close
conn.Close
End Sub
14. Click the Save button on the toolbar to save the script.
15. Go back to the iFIX WorkSpace, and switch to the Run mode. The two objects will look similar to
those in the following figure.
NOTE: These example objects were resized after they were placed in the picture. You can optionally resize your
objects too. Be aware that in the iFIX WorkSpace, you should be able to see the object handles when you click
on the grid, but the grid object will be transparent in Configure mode; this behavior is expected.
As the DataGrid component contains a method that supports scrolling of the view port, the line of
code referring to the ScrollIntoView method makes the selected row always visible in this
example. With this event scripting, the ComboBox object can now drive the DataGrid object.
19. Save the picture, and switch to run mode. Try using the drop-down list to change the row focus in
the grid.
The selection of an item in the ComboBox is reflected accordingly, as a selection of a row in the
DataGrid.
When you are finished with the example, your code should look similar to this:
Private Sub CFixPicture_Initialize()
Dim conn As New Connection
Dim rs As New Recordset
conn.ConnectionString = "Provider=SQLNCLI10.1;Data Source=localhost;" _
& "Initial Catalog=Northwind;Integrated Security=SSPI;"
conn.Open
rs.Open "Select Top 20 * from Orders", conn
Set DataGrid1.ItemsSource = rs
rs.MoveFirst
Do While Not rs.EOF
ComboBox1.Items.Add CStr(rs!CustomerID)
rs.MoveNext
Loop
ComboBox1.SelectedIndex = 0
rs.Close
conn.Close
End Sub
NOTE: The SelectionChanged event is actually converted with two parameters of Variant(SafeArray). The SafeArray
interface requires more advanced scripting and is not used here.
The hosting environment and the iFIX component container work together to combine the properties and
methods of the container with those of the underlying .NET control. This makes it possible to access the
properties of the container and the .NET control from within the iFIX Properties Window or to access the
properties and methods with a single variable inserted by the VBA scripting tool.
The following common properties of the component container are grouped under the label Misc, in the
iFIX Properties Window for the .NET Component:
l Name
l Cancel
l ContextID
l ControlOrderIndex
l Default
l Description
l EnableTooltips
l Height
l HighlightEnabled
l HorizontalPosition
l HorizontalScaleDirection
l HorizontalScalePercentage
l IsSelectable
l Layer
l UniformScale
l VerticalPosition
l VerticalScaleDirection
l VerticalScalePercentage
l Visible
l Width
For more information on the meaning and usage of these properties and additional properties and meth-
ods available with VBA scripting, refer to the iFIX Automation Reference.
The hosting environment supports hosting and interfacing with the built-in Windows Presentation Frame-
work or Windows Forms (WinForms) controls. Advanced features are provided to allow you to build com-
ponents from any .NET controls – your own or from a third party – created from these built-in controls.
The following sections provide more information on how to use this advanced functionality:
In addition to the build-in Windows Presentation Framework or Windows Forms controls, you can use
third-party controls or create your own controls based on any built-in controls. For more information on
the task you want to perform, refer to the following sections:
In addition to using a third-party control, you can also create your own custom .NET component, as the
example below describes. Any custom or third-party .DLL file should reside in the <iFIX install>\DotNet
Components folder.
Custom or third-party controls can be derived and hosted from the following pre-built controls, following
the .NET Framework 4.0 classes:
You can add the new components to your .NET Component Browser dialog box, as described in the
Adding Components to the .NET Component Browser Dialog Box section.
Additionally, you can then copy the associated .DLL files to each iFIX install where you want to display the
picture, as well as the GEIP.Orion.Components.dat file, as described in the Copying Component files to
Other Systems section.
Example
The following example shows how to create a Trend Chart within the .NET Framework 4.0.
NOTE: The TrendChart class in this above example is derived from the Framework 4.0 Chart class. In the con-
structor, a ChartArea and a Series are added to the chart control, which is then configured by setting some
ChartArea and Series properties. Two properties are defined: Title for setting a chart title, and Value for binding
to a data source. When the data value changes, the set action of the Value property adds a new data point to
the chart. If the number of data points excesses a preset limit, the oldest points are removed.
3. Save this text file as TrendChart.cs, and copy it into the My Sample Components folder created in
step 1.
4. Open a Command Prompt window, change the directory to the <iFIX install>\DotNet Com-
ponents\My Sample Components folder, and issue the following command:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc /t:library /out:ChartControls.dll /r:Sys-
tem.dll;System.Windows.Forms.dll;System.Windows.Forms.DataVisualization.dll TrendChart.cs
This command assumes that .NET Framework 4.0 is installed in the default folder. Observe that
the compiled assembly ChartControls.dll is saved into the My Sample Components folder.
NOTE: The TrendChart control from this example can also be built with Visual Studio 2010. A sample project for
this control is included in the folder <iFIX install>\DotNet Components\Sample Com-
ponents\VS2010SampleProjects folder.
5. Add your new component to the .NET component Browser dialog box, so that you can add it to
your iFIX picture. For steps, refer to the Adding Components to the .NET Component Browser Dia-
log Box section
The .NET Component Browser dialog box includes a button labeled Delete Node, to allow a user to delete
a Group or Assembly node on the browser. This feature is necessary to keep the browser clean and well
organized, but use care when deleting a component assembly node (such as the ChartControls node). An
iFIX picture will fail to load if it contains any control objects created from the components of the deleted
assembly. The deletion action is safeguarded by the following rules:
An issue could occur if a closed picture that contains components from the deleted assembly is then
opened. In this case, because the iFIX WorkSpace does not check references in the closed pictures, an
error may occur on load. This is the same behavior as that of an unregistered ActiveX control in the iFIX
WorkSpace.
The component creation process creates the following essential files for a .NET source assembly to sup-
port hosting and communicating with all the components created from the selected controls in the
source assembly:
Some of the temporary or debugging files may be created when you create a .NET component, but they
are not essential for the component to function. If the same source assembly is selected to the Add Com-
ponents process the second time, the ordinal number will increase.
NOTES:
l Do not manually delete the essential supporting files.
l Occ is short for Orion COM Component.
The original control assembly name (an example of a control assembly name is ChartControls.dll), and
any other control assembly names associated with it, must be unique among all .NET control assemblies
that are used to build iFIX hostable components. Otherwise, unexpected results may happen as the .NET
runtime will use the first loaded control assembly for all same named assemblies.
NOTE: .NET has provisions to support the loading assemblies with the same name but different versions. However, that
requires the versioned assemblies be signed and installed into the system assembly cache, which is not a supported
scenario for GE component hosting.
All original .NET control assemblies must be stored under the root component directory: <iFIX
Install>\.NET components. When an original control assembly is selected to build iFIX hostable com-
ponents, the supporting assembly and type library are saved in the same directory. When components
are copied from one system to another, the folder hierarchy must be maintained.
Network shared folders for component storage are not supported due to .NET security implementations.
After you create your new .NET components, if you want to use them on iFIX systems you need to:
1. Copy the compiled .NET Component files to each iFIX node that you want to use the new controls.
2. Add the new components to the .NET Component Browser dialog box on each iFIX node where
you want to display them.
If new .NET Components are created and inserted into iFIX pictures on one iFIX system, and the saved
pictures are opened on another iFIX system, the pictures will not load with the new components if the
corresponding component files do not exist on the new system. This is true for ActiveX controls that are
not installed (copied and registered) on a new target system.
There is no need to register the new components; you do not need to register the component assembly
or the component type library files. You only need to copy the associated files to other systems, using the
same directory hierarchy, relative to the iFIX install folder. For example, if you modified the TrendChart
control, you would copy the ChartControls.dll, Occ.ChartControls.dll, and Occ.ChartControls.tlb to the
<iFIX install>\DotNet Components\Sample Components folder of the other iFIX system (even if it is a cli-
ent with mapped drives in use). The TrendChart objects configured on the original system will then load
and function on the new system.
Any custom or third-party supporting assemblies in the iFIX install folder must also be copied to the iFIX
install folders of other systems. Some third-party common assemblies may need to be installed into the
system assembly cache or be copied to the iFIX install folder.
Basically, the <iFIX install>\DotNet Components folder should be the same on each iFIX node.
After you create a new custom .NET component, you need to add it to the tree view area in the .NET
Component Browser dialog box in order to add the control to an iFIX picture on your system. Use the
interface in the Component Browser dialog box to add a new component to an individual system.
Later, if you want to synchronize this new component across all of your iFIX system (clients and servers),
manually copy the all of the files in the DotNet Components folder, including subfolders, and the master
browser file (GEIP.Orion.Components.dat file) and any other .dll files your assemblies use, to each system
that you want to synchronize. Basically, the <iFIX install>\DotNet Components should be the same on
each iFIX node.
To add a new component to a single system using the Component Browser dialog box:
1. On the computer that contains the master copy, make a copy of the <iFIX install>\DotNet Com-
ponents folder, and the <iFIX install>\GEIP.Orion.Components.dat file.
2. On each system that you want to synchronize, follow these steps:
a. Copy the master DotNet Components folder over the original <iFIX install>\DotNet Com-
ponents folder on the system you want to synchronize. Copy over this entire folder (includ-
ing all files and subfolders).
c. Copy the master GEIP.Orion.Components.dat file, the Component Browser content file,
over the original <iFIX install>\GEIP.Orion.Components.dat file on the system you want to
synchronize.
You can simply move (copy) pictures that include .NET components from one machine to another if the
.NET components in the picture are all listed on the Component Browser and the supporting assemblies
are all in the same hierarchical folders of the current machine. Otherwise, you must copy the supporting
assemblies and add .NET controls to the browser. If the .NET components on the other machine are a
superset of those on the current machine, you may simply copy the DotNet Components folder and the
GEIP.Orion.Components.dat file.
If a custom .NET component exists on another iFIX machine and you want to re-link it to your current
machine, you can use the .NET Component Browser to add the component to the tree view area in the
.NET Component Browser dialog box. You will then be able to add the component to iFIX pictures on your
system.
To re-link a custom component from another iFIX machine:
1. On the computer that contains the custom component, make a copy of the .NET Component
Assembly folder.
2. Browse to the DotNet Components folder of the computer to which you want to re-link the com-
ponent, and move the copied folder there.
3. Start iFIX and launch WorkSpace on the computer to which you want to re-link the component.
4. On the Insert tab, select Object/Links, and then click .NET Component. The component Browser
appears.
5. Select the group for the component and then click Add Components. The Add .NET Components
dialogue appears.
6. Click the browse button (...) and browse to the .NET component folder that was copied and click
the Occ.<filename>.dll.
7. Give the component assembly a new name or leave the current name. Select the components to
be added and then click OK. Verify that the component displays in the .NET Component browser,
select it, and click OK.
The data types that iFIX understands are different from the .NET data types. The .NET Framework
provides data conversions only for primitive data types, such as integers, floats and strings. The hosting
environment in iFIX supports converting commonly used complex data types:
The property or method in the exposed COM interface will have the corresponding COM types converted
from the original .NET types.
If a property or method does not meet the above conditions, it will be ignored in the component building
process and thus not be available in the component COM interface.
l If all the parameter types of a .NET event delegate are convertible according to the conditions lis-
ted in the Properties and Methods section above, the .NET event delegate will be converted to a
COM event handler with the same number of parameters of the corresponding COM types.
l Some common .NET delegate types are converted to specifically defined COM event handlers.
These include the mouse events:
l For Windows Presentation Framework: MouseEventHandler, MouseButtonEventHandler,
and MouseWheelEventHandler.
l For Windows Forms: MouseEventHandler delegates.
The key events:
l For Windows Presentation Framework: KeyEventHandler, and KeyboardEventHandler.
l For Windows Forms: KeyEventHandler, and KeyPressEventHandler delegates.
The selection events:
l SelectionChangedEventHandler and EventHandler<SelectionChangedEventArgs> del-
egates.
l The converted COM mouse event handlers are defined to have three parameters: the mouse but-
ton state, and the X and Y positions. The key COM event handlers are defined to have two para-
meters: the key state and the key code. For more information on the mouse button state and the
key state, refer to the Microsoft Win32 API help.
l The converted COM selection event handler has two parameters of the COM Variant type with an
array subtype: addedItems for items newly added to, and removedItems for items newly removed
from the selected items collection. To avoid array indexing problems (the items arrays might be
empty), check array bounds with the UBound VBA function.
l All other delegates that follow the .NET convention (two parameters: sender of the Object type
and of an EventArgs derived type) are converted to a COM handler of two parameters of the
String type.
The .NET Component hosting environment supports passing complex data types such as arrays (lists) and
data tables. The supported .NET types are exposed as common COM types or specific interfaces and
types implemented by the conversion module. The supported COM types may be passed to or returned
from the methods and properties of .NET controls. As a result of data conversion, these COM data types
appear as the corresponding .NET types to the NET controls.
These data types appear as ADODB Recordsets and are used to pass data tables with columns and rows.
IEnumerable is converted to Recordset because many .NET controls use the IEnumerable interface to
pass DataTable objects. Be sure to add the Microsoft ActiveX Data Objects Library (2.7 or higher)
These data types appear as ShortList, IntList, FloatList, DoubleList, and StringList implemented in the
data conversion module. Be sure to add the GEIP_Orion_Dataconversion reference when scripting with
these date types. For example, the ShortList list implements the following interface:
interface IShortList : IDispatch
{
[id(0x60020000), propget]
HRESULT Count([out, retval] long* pRetVal);
[id(0x60020001)]
HRESULT Add([in] short item);
[id(0x60020002)]
HRESULT Clear();
[id(00000000), propget]
HRESULT item(
[in] long index,
[out, retval] short* pRetVal);
[id(00000000), propput]
HRESULT item(
[in] long index,
[in] short pRetVal);
[id(0x60020005)]
HRESULT Insert(
[in] long index,
[in] short item);
[id(0x60020006)]
HRESULT RemoveAt([in] long index);
};
The other lists implement basically the same interface, but with different data types (long for IntList, and
so on) for the item parameter.
This data type appears as ObjectList, which implements the following interface:
interface IObjectList : IDispatch
{
[id(0x60020000), propget]
HRESULT Count([out, retval] long* pRetVal);
[id(0x60020001)]
HRESULT Add(
[in] VARIANT item,
[out, retval] long* pRetVal);
[id(0x60020002)]
HRESULT Clear();
[id(00000000), propget]
HRESULT item(
[in] long index,
[out, retval] VARIANT* pRetVal);
[id(00000000), propputref]
HRESULT item(
[in] long index,
[in] VARIANT pRetVal);
[id(0x60020005)]
HRESULT Insert(
[in] long index,
[in] VARIANT item);
As the item type listed above is VARIANT, this list can pass any convertible types supported by the data
conversion module. For example, list objects can be added to an ObjectList as list items, resulting in a
multi- dimensional array. Add the GEIP_Orion_Dataconversion reference when scripting with this data
type.
iFIX pictures can not only host, but also communicate with the .NET controls through primitive data types
and converted parameter types. The most commonly used parameter types are converted; however,
there are parameter types, such as those with custom .NET controls, that cannot be converted. These
unconverted parameter types are ignored.
In order to avoid the essential properties, methods, and events of a .NET control from being ignored (not
exposed), you can do any of the following.
l Rewrite a desired property using the convertible types listed in the Data Conversion Rules sec-
tion.
l Separate a desired property into multiple properties of the convertible types listed in the Data
Conversion Rules section.
l Rewrite a method with the convertible types or with more parameters, so that each parameter
can be converted.
l Define a new event type (delegate) with all convertible parameters, and reroute the original event
with the new delegate.
Error Logging
The error logging module for the .NET Component is designed to log information and error messages to a
file named ComponentsLogger.log. From this file, error causes can be analyzed. For instance, major
errors such as a missing .dll file are logged to file. A error logged to this file might look similar to this:
2011-07-01 13:22:12,919 [1] ERROR GEIP.Orion.DotNetComAdapters.DotNetComAdapter
Failed to load the source assembly: C:\Program Files (x86)\GE\iFIX\DotNet Components\Sample Components\GaugeContr
By default, the ComponentsLogger.log file is saved to the following location: <iFIX install>\DotNet Com-
ponents, on the computer where you are viewing the pictures. For instance, if you are viewing your pic-
tures on an iClient (view node), the log file is saved on the iClient machine.
The items that can be most easily changed are the logging file path and the logging level. The default set-
tings, as shown above, set the path to <iFIX install>\DotNet Components\ComponentsLogger.log and the
logging level to WARN.
The logging levels are: DEBUG, INFO, WARN, ERROR, and FATAL. The level DEBUG logs everything, and
the other levels: INFO, WARN, ERROR, and FATAL, log successively fewer messages. Be aware that the
logging actions are mostly performed at the configuration mode, and there are no significant per-
formance penalties in run mode even if the logging level is set to DEBUG.
3. Restart iFIX.
iFIX installs the following Microsoft® Visual Studio® 2010 sample projects for the .NET Component:
l ChartControlsV2
l GaugeControlsV2
These samples are pure .NET controls targeted to a common .NET environment. The V2 suffix was added
to avoid conflict with any code that you may have generated with previous code examples in this e-book.
The trend chart control, ChartControlsV2, is a Windows Forms (or WinForms) chart control. There are a
few properties and a simple mouse event included.
The linear gauge control, GaugeControlsV2, is a Windows® Presentation Framework user control. There
are a lot of properties added to make its overall look configurable, including title font and color, scale font
and color, range limits and colors, scale mark sizes and colors, and so on. In run mode, the range color will
blink if the needle enters a scaled region. There are also multiple events raised when the gauge needle
The control names and any other control assembly names must be unique among all .NET control assem-
blies that are used to build iFIX hostable components. Otherwise, unexpected results may occur as the
.NET runtime will use the first loaded control assembly for all same named assemblies.
IMPORTANT: The full name (namespace and class name) of any .NET control must be unique.
The examples depend on only system assemblies (as listed for the /r command option, they are Sys-
tem.dll, System.Windows.Forms.dll and System.Windows.Forms.DataVisualization.dll). Third-party con-
trols, however, usually reference their own supporting assemblies. When a control assembly is compiled,
the compiler copies all non-system reference assemblies to the output folder.
The control assembly and its supporting reference assemblies should be copied to a specific folder under
the <iFIX install>\DotNet Components folder. However, some third-party common assemblies may need
to be installed into the system assembly cache or be copied to the iFIX install folder.
A DataTable 31
DataView 31
Add Components 6, 29
DataVisualization 14
Add Group 29
DEBUG 34
ADODB Recordsets 32
Delete Node 6, 27
advanced features 25
DotNet Components folder 29
AlternatingRowBackground 21
argument type 20
E
B enumerations 11
ERROR 34
Basic Animation dialog box 12
error logging 34
binding .NET component 7
event handlers 16, 20
Brush property 9
F
C
FATAL 35
calling methods 12
Font class 9
Chart 17
Font dialog box 9-10
ChartControlsV2 35
font type 10
CheckBox 9
FontFamily 10
ComboBox 21
FontSize 10
complex data types 32
FontStretch 10
component hosting 5
FontStyle 10
Component Hosting check box 2
FontWeight 10
ComponentsLogger.log 34
copying components 29
G
creating a .NET component 25
GaugeControlsV2 35
custom .NET component 25
GEIP.Orion.Components.dat file 29
Custom iFIX product install 2
H O
iFIX properties 24 P
K R
L S
SetCustomProperty 15
M
steps to create new components 25
Microsoft ActiveX Data Objects Library 13, 32
supported control types 6
Misc iFIX properties 24
supporting files for .NET components 27
mouse events 32
System.Drwing.Font 9
MouseDown 17
MouseMove 17
MouseUp 17
TextBlock 11-12
TrendChart 7
uniqueness 28
usage 1
VARIANT 33
versioned 28
Visual Studio 35
WARN 35
Win32-like parameters 20
WinForms 7
WPF 6