COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the...

82
Programming _____________________________________ _________________________________________________________________________ ___________________ ___________________ ___________________ ___________________ COMOS Platform Programming Operating Manual 04/2012 A5E03853259-01 Trademarks 1 .NET components for COMOS 2 Development with Visual Basic 6 in COMOS 3 Side-by-side configuration with manifests 4 WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 Other components 10

Transcript of COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the...

Page 1: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

� �Programming

___________________

___________________

___________________

___________________

___________________

___________________

___________________

___________________

___________________

___________________

COMOS

Platform Programming

Operating Manual

04/2012 A5E03853259-01

Trademarks 1

.NET components for COMOS

2

Development with Visual Basic 6 in COMOS

3

Side-by-side configuration with manifests

4

WinCC 5

ControlProperties 6

Creating and incorporating 3D symbols

7

Using the SearchManager 8

Icon specifications 9

Other components 10

Page 2: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Legal information

Legal information Warning notice system

This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are graded according to the degree of danger.

DANGER indicates that death or severe personal injury will result if proper precautions are not taken.

WARNING indicates that death or severe personal injury may result if proper precautions are not taken.

CAUTION with a safety alert symbol, indicates that minor personal injury can result if proper precautions are not taken.

CAUTION without a safety alert symbol, indicates that property damage can result if proper precautions are not taken.

NOTICE indicates that an unintended result or situation can occur if the relevant information is not taken into account.

If more than one degree of danger is present, the warning notice representing the highest degree of danger will be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property damage.

Qualified Personnel The product/system described in this documentation may be operated only by personnel qualified for the specific task in accordance with the relevant documentation, in particular its warning notices and safety instructions. Qualified personnel are those who, based on their training and experience, are capable of identifying risks and avoiding potential hazards when working with these products/systems.

Proper use of Siemens products Note the following:

WARNING Siemens products may only be used for the applications described in the catalog and in the relevant technical documentation. If products and components from other manufacturers are used, these must be recommended or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and maintenance are required to ensure that the products operate safely and without any problems. The permissible ambient conditions must be complied with. The information in the relevant documentation must be observed.

Trademarks All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.

Disclaimer of Liability We have reviewed the contents of this publication to ensure consistency with the hardware and software described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in this publication is reviewed regularly and any necessary corrections are included in subsequent editions.

Siemens AG Industry Sector Postfach 48 48 90026 NÜRNBERG GERMANY

A5E03853259-01 Ⓟ 05/2012 Technical data subject to change

Copyright © Siemens AG 2012. All rights reserved

Page 3: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 3

Table of contents

1 Trademarks ............................................................................................................................................... 7

2 .NET components for COMOS .................................................................................................................. 9

2.1 Building a .Net control for COMOS................................................................................................9 2.1.1 Basics for a .NET control in COMOS.............................................................................................9 2.1.2 Building a .NET control for COMOS ............................................................................................11

2.2 Integrating a .NET control in COMOS .........................................................................................13 2.2.1 Storage location of the assembly.................................................................................................13 2.2.2 Making the control of the application known................................................................................13 2.2.3 Adapting the manifest ..................................................................................................................14 2.2.4 Creating and updating manifests for .NET assemblies ...............................................................15 2.2.5 Embedding the manifest in a .NET assembly..............................................................................15 2.2.6 Using existing controls in the code ..............................................................................................16

2.3 Using controls for documents ......................................................................................................19 2.3.1 Basics...........................................................................................................................................19 2.3.2 Creating a document type............................................................................................................19 2.3.3 Runtime context ...........................................................................................................................20

2.4 Control as a tab in the device properties screen .........................................................................20 2.4.1 Configuration on the CDevice......................................................................................................20 2.4.2 Runtime context ...........................................................................................................................21 2.4.3 EditFormsAdapter as an alternative solution ...............................................................................21

2.5 Control as a properties screen.....................................................................................................22 2.5.1 Basics...........................................................................................................................................22 2.5.2 Configuration on the CDevice......................................................................................................22 2.5.3 Runtime context ...........................................................................................................................22

2.6 Debugging....................................................................................................................................23 2.6.1 Basics...........................................................................................................................................23 2.6.2 .NET Framework 3.5....................................................................................................................23 2.6.3 .NET Framework 4.0....................................................................................................................24

3 Development with Visual Basic 6 in COMOS........................................................................................... 25

3.1 Recommendation.........................................................................................................................25

3.2 Technical requirements................................................................................................................25 3.2.1 Registering COM components.....................................................................................................26 3.2.2 Registering type libraries .............................................................................................................26 3.2.3 Copying Visual Basic files into the "Bin" directory .......................................................................27

3.3 Debugging Visual Basic components ..........................................................................................29

3.4 Testing Visual Basic components................................................................................................29

4 Side-by-side configuration with manifests................................................................................................ 31

4.1 Manifests......................................................................................................................................31

4.2 External programs (EXE) .............................................................................................................32

Page 4: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Table of contents

Programming 4 Operating Manual, 04/2012, A5E03853259-01

4.3 Creating and updating manifests for COM components............................................................. 33

5 WinCC ..................................................................................................................................................... 37

6 ControlProperties..................................................................................................................................... 39

6.1 Access to Property CtrlProperty via Lib.Sui ................................................................................ 39

6.2 Bulk processing of ControlProperties via object queries ............................................................ 39

6.3 List of the ControlProperties........................................................................................................ 40

6.4 Allocation of ControlProperties to SuiControls............................................................................ 42

7 Creating and incorporating 3D symbols ................................................................................................... 45

7.1 Introduction ................................................................................................................................. 45

7.2 Creating a VB project .................................................................................................................. 45

7.3 Creating a COMOS 3D base object............................................................................................ 46

7.4 Creating the drawing procedures................................................................................................ 47

7.5 Predefined drawing functions...................................................................................................... 49 7.5.1 Introduction ................................................................................................................................. 49 7.5.2 Cuboid ......................................................................................................................................... 49 7.5.3 Cylinder on a rectangular surface ............................................................................................... 50 7.5.4 Cylinder 1 (optional ground)........................................................................................................ 51 7.5.5 Cylinder 2 (optional top and bottom)........................................................................................... 52 7.5.6 Cylinder segment ........................................................................................................................ 53 7.5.7 Cylinder wall ................................................................................................................................ 54 7.5.8 Circular disk ................................................................................................................................ 55 7.5.9 Polygon1 ..................................................................................................................................... 55 7.5.10 Polygon2 ..................................................................................................................................... 56 7.5.11 Rotation body .............................................................................................................................. 56 7.5.12 Eccentric cylinder ........................................................................................................................ 57 7.5.13 Torispherical head....................................................................................................................... 58 7.5.14 Pyramid ....................................................................................................................................... 58 7.5.15 Cylinder ....................................................................................................................................... 59 7.5.16 Sphere......................................................................................................................................... 60 7.5.17 Sphere segment.......................................................................................................................... 61 7.5.18 Text ............................................................................................................................................. 61 7.5.19 Torus ........................................................................................................................................... 62 7.5.20 Torus segment ............................................................................................................................ 63 7.5.21 Wire box ...................................................................................................................................... 64 7.5.22 Cylinder intersection.................................................................................................................... 65 7.5.23 Eccentric pyramid........................................................................................................................ 66 7.5.24 Torus arc (reduction possible) .................................................................................................... 67 7.5.25 OpenGL functions ....................................................................................................................... 67 7.5.26 Creating connectors .................................................................................................................... 68 7.5.26.1 Examples..................................................................................................................................... 70 7.5.27 Dimensionings (grabs) ................................................................................................................ 72 7.5.28 Snap points ................................................................................................................................. 72 7.5.29 Expert functions .......................................................................................................................... 72

8 Using the SearchManager ....................................................................................................................... 73

8.1 Basic information on the SearchManager................................................................................... 73

Page 5: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Table of contents

Programming Operating Manual, 04/2012, A5E03853259-01 5

8.2 Integrating the SearchManager by script.....................................................................................73

8.3 SearchManager application example ..........................................................................................76

9 Icon specifications ................................................................................................................................... 77

10 Other components ................................................................................................................................... 79

10.1 Report.ocx....................................................................................................................................79

10.2 UseSpecs.dll ................................................................................................................................80

10.3 ComosTGeneratorJobs................................................................................................................81 10.3.1 Class NextString and Class RunValues ......................................................................................81

Page 6: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Table of contents

Programming 6 Operating Manual, 04/2012, A5E03853259-01

Page 7: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 7

Trademarks 1Trademarks

Registered trademark: COMOS®

Page 8: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Trademarks

Programming 8 Operating Manual, 04/2012, A5E03853259-01

Page 9: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 9

.NET components for COMOS 22.1 Building a .Net control for COMOS

2.1.1 Basics for a .NET control in COMOS

Minimum requirements We recommend that the control inherits from System.Windows.Controls.UserControl. Inheritance from System.Windows.FrameworkElement is sufficient, however.

Alternatively, you can use System.Windows.Forms.UserControl. However, this is not recommended, because a Forms control is embedded in a WindowsFormsHost. Therefore, the direct use of System.Windows.Controls.UserControl is faster, more logical and more stable.

Note Version of .NET Framework

If you implement the IComosControl interface, use .NET Framework 3.5. Otherwise, use .NET Framework 4.0.

Communication between .NET controls and COMOS In order to communicate better with COMOS, you should implement the IComosControl interface.

The original control is then moved to a container which contains the OkAbort control and handles the Undostate management. Via the container, you have access to the buttons and can enable or disable the Undostate management:

Page 10: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.1 Building a .Net control for COMOS

Programming 10 Operating Manual, 04/2012, A5E03853259-01

Executing the commands COMOS offers a variety of commands to which the control can react. The commands offered may differ, depending on where the control is integrated in COMOS. This document describes the commands that are available when the control is used as a stand-alone plug-in.

Other uses are possible. See also chapters Using controls for documents (Page 19), Control as a tab in the device properties screen (Page 20) and Control as a properties screen (Page 22).

The control can react to button actions as well as to commands from COMOS and provide feedback by means of the three methods OnCanExecute, OnPreviewExecuted and OnExecuted. The execution of the commands is based on the RoutedCommands from WPF. In contrast to WPF, however, Executed and PreviewExecuted can be processed. Usually with WPF RoutedCommands, when PreviewExecuted is processed, no Executed is triggered, regardless of e.Handled.

In other words, when the container executes a command, OnCanExecute is first called. If the control permits execution of this command, OnPreviewExecuted is called. If the command is not set to Handled within OnPreviewExecuted, OnExecuted is called for this command.

The following commands are offered as standard:

Command Description ButtonAction Occurs for every action of a standard button. (e.g. for "Click")

Within OnCanExecute, the CanExecute property of the EventArgs can be used to determine whether or not the corresponding button is enabled. You can query which button is affected by this button action using the OriginalSource property of the EventArgs. This returns the button in question. The button is identified by the name.

CloseUIForm Occurs when the current UIForm is closed. The control is therefore notified when it is closed and can also prevent this from happening.

ProjectOrWOChange Occurs when the current COMOS project or the current working layer is changed. By default, this is following by CloseUIForm Command and the Form is closed. If the control should be maintained after the change of the project/working layer, this must be specified in the tool entry. This is done in the Window Tag of the tool by setting the autoClose attribute to "true". (For more on this, see the heading "Exception when executing ProjectOrWOChange.

The command involved at this moment can be queried as follows using the name of the command: if (e.Command is RoutedCommand) { RoutedCommand routedCommand = e.Command as RoutedCommand; if (routedCommand.Name == Commands.CloseUIForm) { } else if (routedCommand.Name == Commands.DataBaseChange) { } }

Page 11: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 11

Exception when executing ProjectOrWOChange OnExecuted is called regardless of e.Handled when executing ProjectOrWOChange. Compared to the other commands, ProjectOrWOChange does not necessarily refer to a single control, but possibly to multiple controls. That is why the started action may not be aborted by a control.

With OnCanExecute, in contrast, the action has not yet occurred. You can therefore still stop the execution.

ProjectOrWOChange is basically only interesting for controls that are expected to still be available even after a project change. By default, all controls are closed when the project is changed. If a control is still to be available after a project change, the following entry is also required: <Tool> <... autoClose="false">.

Example: <Tool id="@NET.UIFormsList" type="Button"> <Caption> <Text itx="~03416 Fensterliste"/> </Caption> <Class type="NET" assembly="Comos.UIF" progid="Comos.UIF.UIControls.UIFormsList"/> <Picture key="std_windowList"/> <Window type="Tab" area="Navigator" subarea="Detail" autoClose="false" /> </Tool>

Alternatively, by means of Reflection Alternatively, the control can make two public properties available: public IComosDWorkset Workset { get; set; } // here ItemObjects of the type: IComosDCollection, // IComosBaseObject or VBA.Collection public object ItemObjects { get; set; }

They are recognized via Reflection by the system during runtime and are set accordingly.

2.1.2 Building a .NET control for COMOS The example project contains an example of a .NET Control implementation. This example is referenced below.

Requirement You use Microsoft Visual Studio 2010 to integrate the .NET Control. The operation of the English user interface is described.

Page 12: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.1 Building a .Net control for COMOS

Programming 12 Operating Manual, 04/2012, A5E03853259-01

Procedure 1. Start Visual Studio 2010.

2. Create a new "WPF User Control Library" type C# project and assign an appropriate name.

In the example: Comos.Samples.CustomControl

3. Open the properties of the new project and set the "Target Framework" to ".NET Framework 3.5" in the "Application" tab.

4. Add the following references to the new project:

– <ComosDir>\Bin\Comos.Global.dll

– <ComosDir>\Bin\Comos.Controls.dll

– <ComosDir>\Bin\interop.Plt.dll

5. In the new project, create a new User Control type element and assign an appropriate name.

In the example: MyCustomControl

6. Open the Code Behind file of the Control.

In the example: MyCustomControl.xaml.cs

7. Integrate the Namespace Comos.Controls and implement the IComosControl interface.

8. Implement the logic of your Control.

In the example: A TextBox for the name and description of the current object.

9. Compile the project and make sure that the compilation was completed successfully.

Page 13: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 13

2.2 Integrating a .NET control in COMOS

Procedure 1. Locate the Assembly containing your Control.

2. Copy the Assembly into the Custom directory within the Bin folder in the COMOS installation directory.

3. Locate your customer-specific menu file in the COMOS installation directory in the menu directory within the config folder.

If there is no custom menu file, you should rename the ExampleMain.xml file to Main.xml and use that.

4. Create a least one <Tool> entry for your control in this file. See also chapter Making the control of the application known (Page 13).

5. If needed, create another reference entry to reach your Tool via the COMOS menu as well.

6. Adapt the Manifest as needed for COM Visible components.

See also chapter Adapting the manifest (Page 14).

7. Start COMOS.

Result You can now use your Control.

2.2.1 Storage location of the assembly Customer-specific Assemblies are stored in a directory of the "Bin\Custom" folder. This directory and the associated ComosCustomize.manifest are taken into account by the COMOS Update Center and are restored following an update.

2.2.2 Making the control of the application known The customer-specific Control must be made known to the application. This is achieved by means of an entry in the customer-specific menu file.

You can find more information on this topic in the "Starting COMOS" manual, keyword "Main.xml".

At least one <Tool> entry must exist there for each Control to be used.

Page 14: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming 14 Operating Manual, 04/2012, A5E03853259-01

<Tool> entry of the example: <ComosMainMenu> <Lib> <Tools> . . . <Tool id="@NET.MyComosControl" type="Button"> <Caption> <Text itx="My Comos Control"/> </Caption> <Class type="NET" assembly="Comos.Samples.CustomControl" progid="Comos.Samples.CustomControl.MyComosControl"/> <Picture key="std_actionWarning"/> </Tool> . . . </Tools> </Lib> </ComosMainMenu>

Control in the COMOS menu To reach your Control via the COMOS menu as well, specify this using a reference entry: <ComosMainMenu> . . . <Menu> <Toolbars> . . . <Tool idref="@NET.MyComosControl " /> . . . </Toolbars> </Menu> </ComosMainMenu>

Result The result in the example appears as follows:

2.2.3 Adapting the manifest In general, the Manifest only has to be created or adapted for Assemblies if they are also visible for COM (technically: COM Visible) or have to be visible for COM (see MSDN).

See also Creating and updating manifests for .NET assemblies (Page 15)

Embedding the manifest in a .NET assembly (Page 15)

Page 15: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 15

2.2.4 Creating and updating manifests for .NET assemblies

Procedure 1. Use the "Comos.ManifestMaker.exe" tool from the command line.

2. Open a command line.

3. Enter the following command:

"<COMOS-Installationsverzeichnis>\PTV001_Vega\Bin\COMOS.ManifestMaker.exe" -type:DOTNET -filename:C:\Custom\ComosCustom.dll -output:C:\Custom

4. Run the command.

Result The generated manifest file is stored in the "Custom" directory.

Note

The manifest file must be in the same directory as the created component.

Recommendation Embed the manifest into the final binary file for a .NET assembly (library or application).

2.2.5 Embedding the manifest in a .NET assembly

Requirement To embed manifest files in .NET assemblies, you need the "mt.exe" program from Microsoft. This program is part of Windows SDK as of Windows Vista or Visual Studio .NET SDK as of Visual Studio .NET 2005. You can download the SDKs from the Microsoft website free of charge.

Procedure In order to embed a manifest in a .NET assembly, use the autoembed and mtpath parameters.

1. Open a command prompt with access to the directory in which the "mt.exe" file is stored.

2. Execute the following command for the Assembly:

"C:\Comos\PTV001_Vega\Bin\Comos.ManifestMaker.exe" -type:DOTNET

-filename:C:\Custom\ComosCustom.dll –autoembed -mtpath:C:\Tools

Page 16: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming 16 Operating Manual, 04/2012, A5E03853259-01

Result An "RT_MANIFEST" type manifest with the ID "1" is embedded as a resource in the Assembly.

2.2.6 Using existing controls in the code

Use in COM (VB 6, scripts) Controls can only be started, not created or edited, under COM or in VB 6 and in scripts. In the code, controls can be started as follows (for example, in the Object Debugger): Set WS = a.Workset ToolID = "@NETWPFControl" ' Start as 'PlugIn' Set AppComd = WS.Globals.AppCommand AppComd.Execute "ExecuteMenuByID", ToolID ' Start as 'Properties': Set App = WS.Globals.Application App.ShowPropertiesOnMdiChild a, false, "", "CONTROLTYPE", ToolID

Use in .NET Under .NET, the more powerful IAppControls interface is available. The Namespace Comos.Global.AppControls is within the Assembly Comos.Global. To manage controls in COMOS, Members offer the following functions in this Namespace:

● Creating .NET Controls and displaying them embedded in COMOS.

– Through parameter assignment, you can determine, for example, whether the created Control is displayed in a window or in a tab, in the document area or in the Navigator area, whether the Control is reusable or not (in the COMOS sense), etc.

– The control can be created by specifying a Tool-ID from the menu file (e.g. Main.xml), and also simply by specifying class and Assembly name of the control, i.e. without requiring an entry in the menu file.

● Executing the controls currently displayed in COMOS.

● Closing controls.

The starting point for the functionality is the static Property Comos.Global.AppGlobal.AppControls, which returns an IAppControls instance. The following interfaces can be used:

● IAppControls: creating, closing and executing controls

● IAppControl: represents a control shown in COMOS angezeigtes Control

● IAppControlOptions: options for configuring a control for COMOS

Page 17: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 17

● IAppControlAppearance: advanced options for displaying the control in COMOS

● IAppControlHeader: title and icon of the control

Creating controls Controls can be created using the IAppControls.Create method. An IAppControlOptions instance has to be created beforehand by means of CreateOptions. This can be used for parameter assignment of the control and finally passed on to the Create method. A new IAppControlOptions instance must be created for each new control.

A Tool-ID can be specified from the menu file (e.g. Main.xml) during parameter assignment. Then, all parameters from the matching Tool entry of the menu file are first read. Parameters set at the IAppControlOptions - i.e. those that are no longer initial – subsequently overwrite the parameters from the tool entry. If the corresponding parameter is not set at the IAppControlOptions, the value from the Tool entry is retained.

However, controls can also be created without a Tool ID or entry in the menu file. To do this, you need to set at least the Class and Assembly parameters, whereby Class is the fully qualified name of the Control to be created and Assembly is the name of the included Assembly (without file extension).

The Create method does not immediately show the new control. It returns an IAppControl instance from which the compressed control is obtained via the control property and can then be configured. The IAppControl.Show method must then be called. The Create method returns zero if invalid options were transferred or if the control type is set for reuse in the options and a control of the corresponding type is already displayed in COMOS.

After a control has been created, the Options can only be queried but no longer be changed. You can still change the Header information, however, namely the icon and text of the tab or window.

Page 18: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.2 Integrating a .NET control in COMOS

Programming 18 Operating Manual, 04/2012, A5E03853259-01

Example: Creating controls IAppControls appControls = Comos.Global.AppGlobal.AppControls; IAppControlOptions options = appControls.CreateOptions(); options.Assembly = "Comos.Samples.CustomControl"; options.Class = "Comos.Samples.CustomControl.MyComosControl"; // or: // options.ToolId = "@NET.MyComosControl"; IAppControlAppearance appearance = options.Appearance; appearance.Area = Area.Navigator; appearance.SubArea = SubArea.Detail; IAppControl appControl = appControls.Create(options); if (appControl != null) { IAppControlHeader header = appControl.Header; header.Title = "MyTitle"; header.Image = Comos.PicturesLibrary.Pictures.Instance.PictureByKey("std_actionWarning"); appControl.Show(); }

Executing controls Using IAppControls, you can execute all IAppControl instances with the controls currently displayed in COMOS. To obtain an IAppControl instance, transfer either the corresponding index or the corresponding control to the Indexers property of IAppControls.

The IAppControls.TryClose method attempts to close a control. The method can, in turn, transfer the index or the control or even the corresponding IAppControl.

Example: Executing and closing controls IAppControls appControls = Comos.Global.AppGlobal.AppControls; IAppControl appControl = null; for (int i = 0; i < appControls.Count; i++) { if (appControls[i].Control is MyComosControl) { appControl = appControls[i]; break; } } if (appControl != null) appControls.TryClose(appControl);

Page 19: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.3 Using controls for documents

Programming Operating Manual, 04/2012, A5E03853259-01 19

2.3 Using controls for documents

2.3.1 Basics .NET Controls can also be used for documents. The .NET Controls are then specified as programs in the document types. The component is opened by double-clicking on the respective document. An editor can be integrated for custom document types.

Currently, due to technical reasons, only one document can be opened at a time. Printing, revisioning, etc. is not yet possible.

2.3.2 Creating a document type Create a document type which contains the corresponding Tool-ID as the program name:

For the old COM components, the Prog-ID was entered here. For the .NET components, the Tool-ID is required since the Prog-ID is not sufficient.

As well as the Prog-ID, you need additional information, at least the Assembly name. This additional information is taken from the Tool entry.

Page 20: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.4 Control as a tab in the device properties screen

Programming 20 Operating Manual, 04/2012, A5E03853259-01

2.3.3 Runtime context

Container A Container is set for the Control, similar to when it is used as a Plug-In.

Commands The same Commands are available as when it is used as a normal Plug-In.

Objects/ItemObjects The Objects property (when the IComosControl interface is used) or the ItemObjects property (when the alternative method with Reflection is used) is set as the value for the document to be opened.

2.4 Control as a tab in the device properties screen .NET Controls can also be displayed as tabs in the Device properties screen. For this, the respective Control must be specified as a tab in the CDevice properties in the configuration tab.

The Control is then integrated as a tab when the respective Device properties are opened.

2.4.1 Configuration on the CDevice Specify the Tool-ID of the .NET Control as a Prog-ID in the properties of the corresponding CDevice in the "Configuration" tab:

Page 21: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.4 Control as a tab in the device properties screen

Programming Operating Manual, 04/2012, A5E03853259-01 21

For the old COM components, the Prog-ID was entered here. For the .NET components, the Tool-ID is required since the Prog-ID is not sufficient. As well as the Prog-ID, you need additional information, at least the Assembly name. This additional information is taken from the Tool entry.

2.4.2 Runtime context In general, the .NET Control is subordinate to the Device properties screen when a .NET control is used as a tab in the Device properties screen. The Device properties screen is the Master in this case.

Since the old Device properties screen is unfamiliar with the new .NET world, the .NET Control can merely be displayed here.

No complex communication can take place. You can perform this in another way. See also chapter EditFormsAdapter as an alternative solution (Page 21).

Container No Container is generated.

Commands The .NET Control receives no Commands.

Objects/ItemObjects The Objects property (when the IComosControl interface is used) or the ItemObjects property (when the alternative method with Reflection is used) is set as the value for the opened Device.

2.4.3 EditFormsAdapter as an alternative solution

Basics EditFormsAdapter represents an interface between DevEdit and .NET/WPF.

WPF Controls that are routed to DevEdit with this technique must meet the following conditions:

● The Control must implement the Comos.Controls.IEditForms interface.

● The Control must inherit at least from System.Windows.Control or from System.Windows.Forms.UserControl.

● Optionally, the Control can implement the IDisposable interface.

● Optionally, the Control can implement the IEditFormsEventHandler interface.

Page 22: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.5 Control as a properties screen

Programming 22 Operating Manual, 04/2012, A5E03853259-01

Procedure After developing a .NET/WPF Control, enter it in the "Main.xml" file as a Tool.

You can see the ID of this tool in the properties of a CDevice in the "Configuration" tab. A tab is created with the user-defined components in the properties of the respective object.

2.5 Control as a properties screen

2.5.1 Basics You can also use your .NET Control as a stand-alone properties screen for certain objects. For this purpose, the respective Control is specified as a properties screen in the CDevice properties in the "System" tab.

The Control is then displayed as a properties screen when the respective Device properties are opened.

2.5.2 Configuration on the CDevice The Tool-ID of the .NET Control must be specified in the "System" tab as a properties screen in the properties of the corresponding CDevice:

2.5.3 Runtime context

Container A Container is created and set.

Commands The same Commands are available as when it is used as a normal plug-in.

Page 23: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.6 Debugging

Programming Operating Manual, 04/2012, A5E03853259-01 23

Objects/ItemObjects The Objects property (when the IComosControl interface is used) or the ItemObjects property (when the alternative method with Reflection is used) is set as the value for the Device to be opened.

2.6 Debugging

2.6.1 Basics .NET Framework 4.0 is always loaded when COMOS starts. COMOS therefore always runs in a .NET Framework 4.0 environment.

When a .NET Control is debugged, however, you need to be able to determine which .NET Framework version was used in the development and for which .NET Framework version the .NET component was compiled.

2.6.2 .NET Framework 3.5

Procedure If the .NET component being debugged was compiled for the .NET Framework 3.5, proceed as follows:

1. Start COMOS.

2. Open the component being debugged in Visual Studio 2010.

3. Make sure that the component being debugged corresponds to the version that is currently integrated in your COMOS installation; otherwise, no Debug icons can be found.

4. In the Visual Studio 2010 menu, navigate to the "Debug" menu item and click "Attach to Process…". The "Attach to Process" dialog opens.

5. In the list of processes, find the COMOS process that you want to debug and select it.

6. Above the list of all the processes, click on the "Select…" button and select the code types to be debugged. Check the box for "Managed (v4.0)".

7. Click the "Attach" button.

Result Visual Studio 2010 is now attached to the COMOS process. You can now perform the debugging.

Page 24: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

.NET components for COMOS 2.6 Debugging

Programming 24 Operating Manual, 04/2012, A5E03853259-01

2.6.3 .NET Framework 4.0

Procedure If the .NET component being debugged was compiled for the .NET Framework 4.0, proceed as follows:

1. In the properties of your C# project, you will see the "Start Action" area in the "Debug" tab.

2. Select the "Start external program" option.

3. Click the "…" button.

4. Find the COMOS installation directory and navigate to the Bin directory.

5. Select the Comos.exe file.

Result You can now perform the debugging as usual.

Page 25: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 25

Development with Visual Basic 6 in COMOS 33.1 Recommendation

Components in Visual Basic 6 are only supported in COMOS due to compatibility reasons. Use the .NET technology for new developments.

See also .NET components for COMOS (Page 9)

3.2 Technical requirements When you install COMOS, COMOS usually runs without registration of the COM components and instead uses the Windows side-by-side technology. Since Visual Basic does not support side-by-side technology, your development in Visual Basic under COMOS 9.0 will require that the COMOS 9.0 version is registered.

Requirements The following requirements are necessary for the Visual Basic development:

● The COM components of COMOS must be registered.

● The type libraries of COMOS must be registered.

● The Visual Basic files must be located in the COMOS "Bin" directory.

See also Registering COM components (Page 26)

Registering type libraries (Page 26)

Copying Visual Basic files into the "Bin" directory (Page 27)

Page 26: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Development with Visual Basic 6 in COMOS 3.2 Technical requirements

Programming 26 Operating Manual, 04/2012, A5E03853259-01

3.2.1 Registering COM components

Requirement To ensure a successful registration, use the "ComosRegister.dll" file in version 1.0.0.1 and register it. You find the file in the following directory:

"<COMOS installation directory>\updatecenter"

Procedure To register the COM components, proceed as follows:

1. Open the "Bin" folder in the COMOS installation directory.

2. Run "ComosReg.exe" to register all COM components in the "OCX" and "ComosX.ocx" directories.

Result The COM components are registered.

3.2.2 Registering type libraries

Requirement The script file "RegTLB.bat" you use to register the COMOS type libraries requires drive R to be mapped. You find the script file in the following directory:

"<COMOS installation directory>\Current\Bin\DeveloperReg"

Procedure To map drive R, proceed as follows:

1. Open a command line.

2. Run the following command:

Subst R: <COMOS installation directory>

Result Drive R is mapped.

Page 27: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Development with Visual Basic 6 in COMOS 3.2 Technical requirements

Programming Operating Manual, 04/2012, A5E03853259-01 27

Alternative procedure To map another drive, proceed as follows:

1. Open the script file "RegTLB.bat".

2. Change all references in this file to match the COMOS installation directory.

Procedure To register the COMOS type libraries, proceed as follows:

1. Open the following directory. "<COMOS installation directory>\Current\Bin\DeveloperReg"

2. To register the TypeLibs, run the script file "RegTLB.bat" in this directory.

Result The COMOS type libraries are registered.

3.2.3 Copying Visual Basic files into the "Bin" directory

Requirement You are using Visual Basic 6.0 SP6.

Page 28: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Development with Visual Basic 6 in COMOS 3.2 Technical requirements

Programming 28 Operating Manual, 04/2012, A5E03853259-01

Procedure To copy Visual Basic files into the "Bin" directory, proceed as follows:

1. Open the Visual Basic installation directory.

2. Copy the following files into the "<COMOS installation directory>\Current\Bin" directory:

– "C2.exe"

– "CVPACK.exe"

– "LINK.exe"

– "MSDIS110.dll"

– "MSPDB60.dll"

– "VB6.exe"

– "VB6.olb"

– "VB6DEBUG.dll"

– "VB6EXT.olb"

– "VB6IDE.dll"

– "VBA6.dll"

– "VBAEXE6.lib"

The "VB6.exe.config" and "VB6.exe.Manifest" files must also be available. These two files are usually installed during the COMOS installation.

Note

Do not open the VBP file by double-clicking on it in the Explorer. This results in the use of the wrong "VB6.exe" file or it changes the function that is defined per double-click.

Page 29: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Development with Visual Basic 6 in COMOS 3.3 Debugging Visual Basic components

Programming Operating Manual, 04/2012, A5E03853259-01 29

3.3 Debugging Visual Basic components

Requirement All components are as of COMOS version 9.0.

Recommendation Develop on a local computer to avoid access problems.

Procedure To debug the Visual Basic components, proceed as follows:

1. Execute "VB6.exe" in the "<COMOS installation directory>\Current\Bin" directory.

2. Open the "ComosDebug" project which is located in the following directory:

"<COMOS installation directory>\Current\Bin\ComosDebug"

3. Add the converted VB6 project.

4. Start the project.

Result COMOS opens and you have the option to debug in Visual Basic.

Note Debug mode

Not all events of .NET components are processed in the Debug mode and others are sometimes not considered.

3.4 Testing Visual Basic components You can test newly compiled components by copying the compiled file into the COMOS installation directory.

Page 30: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Development with Visual Basic 6 in COMOS 3.4 Testing Visual Basic components

Programming 30 Operating Manual, 04/2012, A5E03853259-01

Page 31: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 31

Side-by-side configuration with manifests 4

If you use a COMOS version older than 9.0, the conventional method of registering COM components is required, using "RegSvr32" for example.

Alternative as of Windows XP SP2 Beginning with Windows XP SP2, you have the alternative of copying a COM component with side-by-side configuration and using the COM component without registration. Copy the COM component into the same directory in which the .exe file is located.

4.1 Manifests You add a manifest to the EXE file for the side-by-side configuration.

Definition The manifest is an XML file that contains information concerning preconditions an .exe application requires to be executed. This file contains information concerning the COM registration. This is usually the information that is in the Windows registry. This is why the application can be executed even when the COM components are not registered.

Saving manifests You can save manifests in EXE files as external files with the following file name:

<name of EXE application>.manifest

As an alternative, you can embed the manifests in the program resources as a resource.

COM assemblies In COMOS, manifests are saved as external files for COM assemblies. The "Bin" folder contains a manifest file with COM types for the respective EXE file.

Page 32: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Side-by-side configuration with manifests 4.2 External programs (EXE)

Programming 32 Operating Manual, 04/2012, A5E03853259-01

Restrictions The following restrictions apply to side-by-side configuration:

● Since COM programs are no longer registered in the Windows registry in COMOS 9.0, the programs are assigned a manifest file through which the COM types are only introduced via the respective EXE. Therefore, there is an exe.manifest file in the "Bin" folder for each .exe file.

● All shipped COM assemblies from COMOS (OCXs and DLL files) are no longer registered by default through "RegSvr32" in the Windows registry. Instead, all information concerning the assemblies are stored in the "ComosOcx.manifest" file.

● Access to references and underlying directories is only provided via a manifest from the appropriate directory level. The appropriate directory level is usually the "Bin" directory.

The "OCX" directory is located in the "Bin" folder.

● The side-by-side method is not suitable for development machines; it should only be utilized on the computers of users. Registration is still required on the development computers.

4.2 External programs (EXE) The following rules apply for external programs that access COMOS via COM using the side-by-side method:

● All external programs, both COM and .NET, must be stored in the "BIN" folder of the local COMOS installation. For example, copy the "CustomComosExtension.exe" program to the following directory: "<COMOS installation path >\Current\BIN"

● All .NET DLL files visible from COM (technically speaking: COM Visible), must be saved in the "BIN" folder.

● Create a suitable manifest file to make COMOS objects accessible from the external file "CustomComosExtension.exe" via COM interop.

Page 33: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Side-by-side configuration with manifests 4.3 Creating and updating manifests for COM components

Programming Operating Manual, 04/2012, A5E03853259-01 33

4.3 Creating and updating manifests for COM components

Introduction If you want to include a COM component in a manifest file or want to adapt a manifest file when changing an interface, we recommend you refer to the following Internet address for instructions:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa375632(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/aa375632(v=vs.85).aspx)

Manifests in COMOS ● The "Comos.exe" file from the BIN directory of the COMOS installation used to start

COMOS also evaluates the "Comos.exe.Manifest" file.

● The file "Comos.exe.Manifest", which may not be changed, includes a reference to the file "ComosCommon.manifest".

● The file "ComosCommon.manifest" in turn includes a reference to the file "Comos.Customize.Manifest" among diverse settings.

● You usually make your changes in the "Comos.Customize.Manifest" file.

Example procedure 1. If there is no folder with the name "Custom" below the "<COMOS installation

directory>\BIN", create one with this name.

2. Run "Comos.ManifestMaker.exe" with the necessary parameters. This file is located in the directory "<COMOS installation directory>\BIN". See also the example below.

A manifest file with the name of the component is created.

3. Copy the section "file" (from "<file name" to </file>) from the manifest file you have just created.

4. Insert the copied section in the "Comos.Customize.Manifest" file behind the comment block.

5. Make sure that the file "MyCustomComosExtension.dll" and other files you may need are located in the directory "<COMOS installation directory>\BIN\Custom".

6. If necessary, change the relative path of the component.

Default: <file name="Custom\MyCustomComosExtension.dll">

Example You use a COM DLL file, for example, a DLL file in Visual Basic, named "CustomComosExtension.dll". In the command line or in a script file, add the following line and execute it:

""<COMOS installation directory>\BIN\Comos.ManifestMaker.exe" type:COM -filename: "<COMOS installation directory>\BIN\Custom\MyCustomComosExtension.dll output: "<COMOS installation directory>\BIN\Custom

Page 34: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Side-by-side configuration with manifests 4.3 Creating and updating manifests for COM components

Programming 34 Operating Manual, 04/2012, A5E03853259-01

● The first parameter is the assembly type of (COM or DOTNET).

● The second parameter is the name of the assembly.

● The third parameter is optional and determines where the generated manifest file is saved and what name the manifest file is gets.

Once a manifest file is created, the result may appear as follows: <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <file name="MyCustomComosExtension.dll"> <typelib tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" version="1.8" helpdir="" /> <comClass description="MyCustomComosExtension" progid="CustomComosExtension.HelperClass1" clsid="{69DAA847-D481-446E-967B-2DE3EFBBB672}" tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" /> <comClass description="MyCustomComosExtension" progid="CustomComosExtension.HelperClass2" clsid="{9F40C2F3-96D4-40cf-83B9-6D85DDE8E0E9}" tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" /> </file> </assembly>

The File node provides information about the component. You insert this node in the "ComosCustomize.manifest" file as follows: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity name="ComosCustomize" version="1.0.0.0" type="win32" /> <!-- *********************************************************** --> <!-- ** ComosCustomize.manifest ** --> <!-- ** ** --> <!-- ** References to additional Assemblies or OCX Components ** --> <!-- ** ** --> <!-- ** please insert here manifest information for own ** --> <!-- ** components, that exist only at specific customer ** --> <!-- ** installation ** -->

Page 35: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Side-by-side configuration with manifests 4.3 Creating and updating manifests for COM components

Programming Operating Manual, 04/2012, A5E03853259-01 35

<!-- *********************************************************** --> <file name="Custom\MyCustomComosExtension.dll"> <typelib tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" version="1.8" helpdir="" /> <comClass description="MyCustomComosExtension" progid="CustomComosExtension.HelperClass1" clsid="{69DAA847-D481-446E-967B-2DE3EFBBB672}" tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" /> <comClass description="MyCustomComosExtension" progid="CustomComosExtension.HelperClass2" clsid="{9F40C2F3-96D4-40cf-83B9-6D85DDE8E0E9}" tlbid="{B7FFF897-DA01-4b88-AD41-F75CF213FE9C}" /> </file> </assembly>

In this example, the "MyCustomComosExtension.dll" file is saved in the "Custom" subdirectory of the "BIN" folder. This is why the Name attribute of the File node is adapted accordingly.

Page 36: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Side-by-side configuration with manifests 4.3 Creating and updating manifests for COM components

Programming 36 Operating Manual, 04/2012, A5E03853259-01

Page 37: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 37

WinCC 5Example

In the following example, first the string is dimensioned (char ASString[250]) and then a variable is prepared, within which the COMOS SystemUIDs can be deposited (char SystemUID[20]).

WinCC-specific settings WinCC-specific settings follow: The if-else block is used to track down errors.

Note

The UIDs are only examples. There are other UIDs in your database.

In the if line, there is a UID different from those in the following else lines (otherwise the entire if-else block would be not make sense). With real data you will certainly manage thousands, if not tens of thousands, of objects (such as signals), if-else loops make no sense anymore in such a case and need to be replaced by a suitably advanced form of error trapping.

After that the string that was dimensioned in the first line ("strcpy") is set up.

Allowed parameters and switches See the "Starting COMOS" manual, keyword "Parameters".

The buttons that are described there can each be added to the string ("strcat").

Page 38: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

WinCC

Programming 38 Operating Manual, 04/2012, A5E03853259-01

Program example The string stored in "ASString" is then passed to the "ProgramExecute" command. ProgramExecute first finds the XIF call in the string and executes it with the following parameters. { char ASString[250] ; char SystemUID[20]; if (GetTagBit("U2") == 1) strcpy( SystemUID, "/ID: C1D45BO8U7 " ); else if (GetTagBit("Error") == 1) strcpy( SystemUID, "/ID: A1D9VBO5U7 " ); else strcpy( SystemUID, "/ID: A1D9VBO5U7 " ); strcpy( ASString, "C:\\Program Files\\COMOS\\Bin\\XIF.exe " ); strcat( ASString, "/DB: ACCESS "); strcat( ASString, "/DN: C:\\COMOS_DB\\COMOSPT.MDB " ); strcat( ASString, "/PR: CeBIT " ); strcat( ASString, SystemUID ); strcat( ASString, "/PA: DETAIL" ); ProgramExecute( ASString ); }

Page 39: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 39

ControlProperties 66.1 Access to Property CtrlProperty via Lib.Sui

ControlProperties can be set per script by means of a constant. As an alternative, the ControlProperty string can be deconstructed and assembled again.

Example for write access a.workset.lib.sui.CtrlProperty (27,a) = 0...'27 = Left a.workset.lib.sui.CtrlProperty (28,a) = 0...'28 = Top a.workset.lib.sui.CtrlProperty (29,a) = 20...'29 = Right a.workset.lib.sui.CtrlProperty (30,a) = 5...'30 = Bottom

Example for read access cp=0...'0 = LabelSize Output a.workset.lib.sui.CtrlProperty (cp,a)

6.2 Bulk processing of ControlProperties via object queries

Procedure 1. To create a standard query for attributes, select the menu command "Extra > Query >

Queries for attributes > Query: Attributes".

2. To add more columns to the query or make changes, select the "Options" command in the context menu of the table header of the open query.

3. Switch to the "Edit column" tab in the "Options" dialog.

– In the left-hand table ("No.", "Name", "Description"), you can copy, paste, etc. a selected column using the context menu.

– In the right-hand table, you can configure the column and set it as "numeric", for example.

– Via the "Properties" context menu command, in a dialog of the same name, you can change the cp constant for the property to the desired value in the "Value calculation" tab and "Object by value" tab in each case. See chapter List of the ControlProperties (Page 40).

– The columns for ControlProperties are editable.

Page 40: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

ControlProperties 6.3 List of the ControlProperties

Programming 40 Operating Manual, 04/2012, A5E03853259-01

Changing cp constants in the "'Action block' script" 1. In order to pass ControlProperties from CSpecification to BackPointer, select the entry

"Display" from the "Scriptblock 'Action' ..." list in the toolbar of the query.

2. Change the cp<Nummer> constants for the Properties in the script of the action block.

See chapter List of the ControlProperties (Page 40).

6.3 List of the ControlProperties

ControlProperties Constant Name Description Data type Possible values 0 LabelSize Width of the

description Double

1 NameSize Width of name Double 2 UnitControlSize Width of unit Double 3 ShowLabelNameDescr Show description /

name Integer 0 = only description

1 = Name and description 4 ControlType Type of edit field Integer 1 = Text field

2 = Editable combobox 3 = Combobox

5 UnitControlType Unit fix Integer 2 = Combobox 3 = Unit fix

6 ProductRequestLbSize Width of product data

Double

7 ScrollBarActiv Scrollbar active Integer 0= No 1= Yes

8 ButtonVisible Button visible Integer 0= No 1= Yes

9 LabelAlignment Text alignment Double 0 = Left 1 = Right

10 LabelFontName Font name String 11 LabelFontSize Font size Double 12 LabelFontBold Font bold Boolean 13 LabelFontItalic Font italics Boolean 14 LabelFontUnderLine Font underlined Boolean 15 LabelForeColor Font color Long 16 ProductRequestKeyInput Local editability of

product data Integer 0 = Not editable

1 = Always 2 = If engineering object is “request”

17 SpecNames (read-only!)

Name prefixes of the attribute

String Can only be edited in GUI

Page 41: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

ControlProperties 6.3 List of the ControlProperties

Programming Operating Manual, 04/2012, A5E03853259-01 41

Constant Name Description Data type Possible values 18 MaxCount

(read-only!) Maximum sentence count

Integer Can only be edited in GUI

19 Cannot be used (Turned-off) 20 Cannot be used (Turned off) 21 ShowLinkObjectName Display Integer 0 = Description of the linked

object 1 = Name of the linked object 2 = FullName of the linked object 3 = DisplayValue of the attribute

22 KeyInput Display: Not editable

Integer 0 = Editable 1 = Not editable

23 QueryFullName System-FullName of object query

String

24 FilterStdTable Filter standard table

Integer 0 = Off 1 = On base data side 2 = Always

25 BtnClickAllowed Button executable Long 0 = <normal rights management >1 = Always (independent of authorization)

26 BorderType Frame type Integer Frame type: 1 = Normal 2 = Simple 3 = Outward 4 = Inward

27 Left 28 Top 29 Right 30 Bottom 31 CaptionVisible Frame caption

visible Boolean

32 Mode Buttons Variant As binary sum: 1 = File selection 2 = Edit Excel sheet 4 = Calculate Excel sheet 8 = Allocation

33 ExecuteValue Immediately execute query

Integer 0= No 1= Yes

34 LabelFontStrikethrough Strike-through font Boolean 35 ButtonStyle Display: Compact Integer 0= All buttons

1= Compact

Page 42: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

ControlProperties 6.4 Allocation of ControlProperties to SuiControls

Programming 42 Operating Manual, 04/2012, A5E03853259-01

6.4 Allocation of ControlProperties to SuiControls

Legend for allocation list (columns) A = Edit E = Excel I = Repeater M = Query B = Border F = Check J = Memo N = FOpen C = Button G = Image K = Memo_rtf O = Link D = Label H = Signature L = Date P = List

Allocation list Name A B C C E F G H I J K L M N O P 0 LabelSize + + + + + + + 1 NameSize + + + 2 UnitControlSize + 3 ShowLabelNameDescr + + + 4 ControlType + 5 UnitControlType + 6 ProductRequestLbSize + 7 ScrollBarActiv + 8 ButtonVisible + 9 LabelAlignment + 10 LabelFontName + + + + + + + + + + 11 LabelFontSize + + + + + + + + + + 12 LabelFontBold + + + + + + + + + + 13 LabelFontItalic + + + + + + + + + + 14 LabelFontUnderLine + + + + + + + + + + 15 LabelForeColor + + + + + + + + + 16 ProductRequestKeyInput + 17 SpecNames (read only) + 18 MaxCount (read only) + 19 (Turned-off) 20 (Turned-off) 21 ShowLinkObjectName + 22 KeyInput + 23 QueryFullName + 24 FilterStdTable + 25 BtnClickAllowed + 26 BorderType + 27 Left + + + + + + + + + + + + + + + 28 Top + + + + + + + + + + + + + + +

Page 43: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

ControlProperties 6.4 Allocation of ControlProperties to SuiControls

Programming Operating Manual, 04/2012, A5E03853259-01 43

Name A B C C E F G H I J K L M N O P 29 Right + + + + + + + + + + + + + + + 30 Bottom + + + + + + + + + + + + + + + 31 CaptionVisible + 32 Mode + 33 ExecuteValue + 34 LabelFontStrikethrough + + + + + + + + + + 35 ButtonStyle +

Page 44: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

ControlProperties 6.4 Allocation of ControlProperties to SuiControls

Programming 44 Operating Manual, 04/2012, A5E03853259-01

Page 45: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 45

Creating and incorporating 3D symbols 77.1 Introduction

This section describes how you create 3D symbols by means of VisualBasic, store them in a DLL, and make them available in COMOS for Viper.

7.2 Creating a VB project

Preparation First, a new VB project is created.

Declaring the module and interface

The 3D drawing procedures and the corresponding COMOS base objects can now be created.

After having completed this process, you create the dll file for the project and save it in the COMOS installation directory "\<COMOS>\OCX\GL". At the end the new file is registered in this directory (open it with WINNT\system32\regsvr32.exe).

Page 46: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.3 Creating a COMOS 3D base object

Programming 46 Operating Manual, 04/2012, A5E03853259-01

7.3 Creating a COMOS 3D base object

Introduction Each base object that is placed in COMOS Viper must have a tab named "GD". All attributes that are important for the 3D view are listed on this tab.

The following applies for all attributes that are relevant for 3D: "Link" tab. "3D Mode": On.

Existing attributes are found in the shipped database, under path "@Viper > @Y > @3D > @PP > 01 GD tab". Attributes that already exist here should be reused in new objects. Attributes whose name is "VC" + a number must be taken from this directory. These attributes describe connectors that are accessed directly from out of COMOS.

Attributes for each 3D component ● "VGEO geo type":

Contains the drawing procedure call in form of: (Filename of the cls file without “Objects”) + "." + name of drawing function

● Essential attributes especially for each pipe component:

– "VPCL pipe spec": Defines the PipeSpec of an object.

– "VFCD function code": Assigns the object to a group of similar objects. Is used for PipeSpec mapping and identification of an object type in the code.

Optional attributes ● "LAYER layer":

Defines a group of objects that are hidden or unhidden together.

● "VCOL color": Defines the color of the object.

● "VR01 AR code": Determines the status of an object during routing. If this attribute does not exist, the component is taken into consideration by the router.

● "VSUI editable attributes": Contains the names of all attributes separated by commas that are displayed in the 3D interface when the corresponding object is selected. It is not necessary to set the D3 mode here, since this attribute can also be used outside the Viper module.

Page 47: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.4 Creating the drawing procedures

Programming Operating Manual, 04/2012, A5E03853259-01 47

7.4 Creating the drawing procedures Definition of a procedure with a name (for example, Box as the procedure name for a box). Each drawing function should additionally be provided with an ErrorHandler:

Declaration of the variables and import of the attribute values from the GD tab with the command Geo.Value ("Attribute name").

Page 48: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.4 Creating the drawing procedures

Programming 48 Operating Manual, 04/2012, A5E03853259-01

The drawing function is called multiple times in COMOS, and each time one or more parts of the symbol are drawn or refreshed. For that reason, Geo.GeometrieMode is used to distinguish the status of the current procedure call. As you can see below, there are 7 different statuses that can be defined in an If statement. Geometry modes that are not required do not need to be defined in the procedure.

Now you draw the form of the symbol in the If-loop with the Geo.GeometrieMode.GenerateGeometry expression.

Page 49: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 49

7.5 Predefined drawing functions

7.5.1 Introduction The coordinate axes specify the point of origin and the orientation of the component (green: x-axis, yellow: y-axis, blue: z-axis).

7.5.2 Cuboid

Function Geo.Box SX As Double, SY As Double, SZ As Double

Page 50: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 50 Operating Manual, 04/2012, A5E03853259-01

7.5.3 Cylinder on a rectangular surface

Function Geo.BoxCylinder BaseRadius As Double, TopRadius As Double, Height As Double, [Top As Boolean=True], [Bottom As Boolean=True]

Page 51: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 51

7.5.4 Cylinder 1 (optional ground)

Function Geo.BoxCylinder BaseRadius As Double, TopRadius As Double, Height As Double, [Top As Boolean=True], [Bottom As Boolean=True]

Page 52: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 52 Operating Manual, 04/2012, A5E03853259-01

7.5.5 Cylinder 2 (optional top and bottom)

Function Geo.Cylinder BaseRadius As Double, TopRadius As Double, Height As Double, [Top As Boolean=True], [Bottom As Boolean=True]

Top and Bottom determine the display of the top and bottom.

Page 53: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 53

7.5.6 Cylinder segment

Function Geo.CylinderSegment BigRadius As Double, SmallRadius As Double, Height As Double, StartAngle As Double, Angle As Double

Page 54: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 54 Operating Manual, 04/2012, A5E03853259-01

7.5.7 Cylinder wall

Function Geo.CylinderSide Outside As Boolean, Radius As Double, Height As Double

Outside determines the visibility of the outer surface

Page 55: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 55

7.5.8 Circular disk

Function Geo.CylinderSide Outside As Boolean, Radius As Double, Height As Double

Outside determines the visibility of the outer surface

7.5.9 Polygon1

Function Geo.Extrusion NumPoints As Long, Contur() As POINT3D, Height As Double, [Side_Lines As Boolean=True]

Polygon extended by Height in z direction.

Page 56: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 56 Operating Manual, 04/2012, A5E03853259-01

7.5.10 Polygon2

Function Geo.Polygon NumPoints As Long, Contur() As POINT3D, XNormal As Double, YNormal As Double, ZNormal As Double, [Reverse As Boolean]

XNormal, YNormal, ZNormal determine which is to be displayed. Definition of the normal vector.

7.5.11 Rotation body

Function Geo.Rotation NumPoints As Long, Contur() As POINT3D, Angle As Double

Page 57: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 57

7.5.12 Eccentric cylinder

Function Geo.ExzCylinder BaseRadius As Double, TopRadius As Double, Height As Double, Offset As Double, [Top As Boolean=True], [Bottom As Boolean=True]

Page 58: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 58 Operating Manual, 04/2012, A5E03853259-01

7.5.13 Torispherical head

Function Geo.KPBoden Diameter As Double

7.5.14 Pyramid

Function Geo.Pyramid SX As Double, SY As Double, SZ As Double

Page 59: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 59

7.5.15 Cylinder

Function Geo.SheetWithRoundedCorner Depth as Double, Width As Double, Height As Double

Page 60: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 60 Operating Manual, 04/2012, A5E03853259-01

7.5.16 Sphere

Function Geo.Sphere Radius As Double

Page 61: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 61

7.5.17 Sphere segment

Function Geo.SphereSegment Radius As Double, StartAngle As Double, Angle As Double

(-90 < StartAngle < 90; Angle + StartAngle <=180)

7.5.18 Text

Function Geo.Text sText As String, Height As Double

Page 62: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 62 Operating Manual, 04/2012, A5E03853259-01

7.5.19 Torus

Function Geo.TorusArc SmallRadius As Double, BigRadius As Double, [StartAngle As Double], [Angle As Double=360]

Page 63: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 63

7.5.20 Torus segment

Function Geo.TorusArcSegment SmallRadius As Double, BigRadius As Double, [StartAngleForBigRadius As Double], [AngleForBigRadius As Double], [StartAngleForSmallRadius As Double], [AngleForSmallRadius As Double=360]

The drawn outer surface is controlled with StartAngleForBigRadius and AngleForBigRadius:

Page 64: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 64 Operating Manual, 04/2012, A5E03853259-01

7.5.21 Wire box

Function Geo.WireBox SX As Double, SY As Double, SZ As Double

Page 65: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 65

7.5.22 Cylinder intersection

Function Geo.CylinderCylinderIntersection r3top As Double, r3bot As Double, r As Double, I As Double, [DW As Double], [e As Double], [PHI As Double]

r3top and PHI are currently not in use.

Page 66: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 66 Operating Manual, 04/2012, A5E03853259-01

7.5.23 Eccentric pyramid

Function Geo.ExzPyramide Width As Double, Depth As Double, Height AS Double, [TopWidth As Double], [TopDepth As Double], [OffsetX As Double], [OffsetY As Double]

OffsetX and OffsetY describe the offset of the area of the top area with respect to the bottom area along the x and y axes.

Page 67: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 67

7.5.24 Torus arc (reduction possible)

Function Geo.TorusArc1 SmallRadius As Double, BigRadius As Double, [StartAngle As Double], [Angle As Double = 360], [ReducedSmallRadius As Double = -1], [NumberOfSegments As Long = -1]

7.5.25 OpenGL functions

Navigating in 3D space In addition, functions derived from OpenGL are available to navigate in the 3D space:

● Rotation around a desired axis Geo.Rotate

AngleDegree As Double,

X AS Double,

Y As Double,

Z As Double

● Rotation about a specific object axis

– Geo.RotateX

AngleDegree As Double

– Geo.RotateY

AngleDegree As Double

– Geo.RotateZ

AngleDegree As Double

Page 68: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 68 Operating Manual, 04/2012, A5E03853259-01

● Move relative to the current position Geo.Move

X As Double,

Y As Double,

Z As Double

● Saves the current position Geo.PushMatrix

● Return to the saved position Geo.PopMatrix

● Return to the absolute point of origin Geo.LoadIdentity

● The position of the specified matrix is taken Geo.LoadMatrix m As MATRIX3D

7.5.26 Creating connectors

Connecting symbols with connectors (general) To be able to connect the symbol that has just been created with other symbols, it must be provided with connectors. This functions analog to drawing the basic shape in the above mentioned if loop. Move in space to the position where the connector is placed at the symbol, align it (see above for commands) and draw the connector with the function call: Geo.GeoConnector (Index As Long, [ConnectorClass As eConnectorClass=ConnectorClass_General] As I3Dconnector)

The index of the connector must be >0. In this context, a distinction is made between six connector classes, which each have different properties:

● ConnectorClass_Elo (for electrical engineering objects)

● ConnectorClass_General (default setting)

● ConnectorClass_Pipe (for pipe parts, valves, etc.)

● ConnectorClass_Steel (for steel structure objects)

● ConnectorClass_Undef

● ConnectorClass_VesselNozzle (for vessels and columns)

Page 69: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 69

Special details for ConnectorClass_Pipe Please note: If you create connectors of type ConnectorClass_Pipe, you must make sure that these connectors contain information about the nominal diameter, nominal pressure and connector type:

● The "GD" tab of objects with connectors of type ConnectorClass_Pipe must have the attributes VC11, VC12, and VC13.

Additionally you can (optionally) create the following attributes in order to define the new connector:

● "VC" + connector index + "1" for nominal diameter

● "VC" + connector index + "2" for nominal pressure

● "VC" + connector index + "3" for the connector type

If one of these attributes is missing, the software tries to access attributes with a smaller connector index (by decrementing the index number).

If a connector of this type has the connection type "“flanged", the flange area will be drawn automatically. This only works if a nominal pressure was selected for this connector.

Example:

Attribute "VC11" exists on the "GD" tab. Following happens if you now create a connector of type ConnectorClass_Pipe with index 4:

Since "VC41" is not existent, it is attempted to first access "VC31" and then "VC21". Since both these attributes do not exist either, the value is ultimately read from attribute "VC11".

Page 70: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 70 Operating Manual, 04/2012, A5E03853259-01

7.5.26.1 Examples

Example 1 The symbol description of a box with unaligned connectors at each corner could look like the following:

Page 71: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming Operating Manual, 04/2012, A5E03853259-01 71

Example 2 The symbol description of a box with aligned connectors at each corner could look like the following:

Page 72: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Creating and incorporating 3D symbols 7.5 Predefined drawing functions

Programming 72 Operating Manual, 04/2012, A5E03853259-01

7.5.27 Dimensionings (grabs) You can subsequently define dimensions assigned to a particular attribute in the Geo.GeometryMode.GenerateGrabs mode. It is thus possible to modify an object online in the 3D drawing.

7.5.28 Snap points Mode Geo.GeometrieMode.GenerateSnapPoints defines additional snap points.

7.5.29 Expert functions Following expert functions are available:

● Geo.GeometrieMode.GenerateOutlines

● Geo.GeometrieMode.GenerateCenterLines

Geo.GeometrieMode.GenerateCenterLines The Geo.GeometrieMode.GenerateOutlines mode defines additional outer lines. It is best to avoid implementation in this mode, since this can cause basic errors.

Geo.GeometrieMode.GenerateCenterLines The Geo.GeometrieMode.GenerateCenterLines mode defines additional lines. It is best to avoid implementation in this mode, since this can cause basic errors.

Page 73: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 73

Using the SearchManager 88.1 Basic information on the SearchManager

The SearchManager is a tool to search for objects with specific properties in the database.

The SearchManager directly accesses the database contents, which makes the search results available almost immediately. The SearchManager is already in use for database searches as part of queries.

You can find more information on this topic in the "Queries" manual, keyword "Database search".

You can open the SearchManager from the Object Debugger and integrate it in a script or in a user-defined component.

See also Integrating the SearchManager by script (Page 73)

8.2 Integrating the SearchManager by script The shown script excerpts can include sample values.

Procedure 1. Create an instance of the SearchManager.

Set searchManager = a.Workset.GetSearchManager

2. Set the root objects.

Set rootObjects = searchManager.RootObjects

rootObjects.add a

3. Set the system type. The following can be selected:

– 8 = Object

– 13 = Base object

– 29 = Document

– 10 = Attribute

searchManager.SystemType = 8

Page 74: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Using the SearchManager 8.2 Integrating the SearchManager by script

Programming 74 Operating Manual, 04/2012, A5E03853259-01

4. If you want to make the entire search case-dependent, you can specify this for the search.

By default, there is no distinction made between upper and lower case text (false).

searchManager.IsSearchCaseSensitive = true

5. Specify whether the user can cancel the search.

By default, the user is not permitted to cancel the search (false).

searchManager.IsUserAbortAllowed = true

6. Define one or more search conditions.

Note the setting options for search conditions below.

searchmanager.AppendSearchCondition "", "PROPERTY", "NAME", "=", "CaSeTESt"

searchmanager.AppendSearchCondition "OR", "PROPERTY", "DESCRIPTION", "LIKE",

"Test*"

7. Set the case-sensitive search for search conditions, if necessary.

searchmanager.searchconditions.item(1).IsSearchCaseSensitive = false

8. Begin the search by starting the SearchManager. All search conditions are validated in the process.

Set resultSet = searchManager.Start

9. Retrieve the results.

Here, you have the chance to specify the number of results, for example, 10. All results are retrieved if you do not set a limit.

searchManager.RetrieveData(10)

10. Execute the processing of the results. Some properties are output in this example.

For i = 1 To resultSet.count Output resultSet.Item(i).SystemUid + " " +

resultSet.Item(i).Name + " " + resultSet.Item(i).Description + " " +

resultSet.Item(i).SystemFullName()

Next

11. Exit the SearchManager.

searchManager.Stop()

Page 75: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Using the SearchManager 8.2 Integrating the SearchManager by script

Programming Operating Manual, 04/2012, A5E03853259-01 75

Setting options for search conditions (step 6) Parameter Value Logical operator The first condition is not permitted to transfer an operator. All

following conditions must transfer an operator: AND OR empty

Attribute type Specify one of the listed attribute types for each search condition: PROPERTY CLASSIFICATION INDEXSPECIFICATION ATTRIBUTE FREEPROPERTY

Attribute Permitted values for PROPERTY: NAME DESCRIPTION LABEL VALUE Permitted values for CLASSIFICATION: 1 2 3 All entries are permitted for the following attribute types: INDEXSPECIFICATION ATTRIBUTE FREEPROPERTY

Comparison operator LIKE NOT LIKE = <> < > <= >=

Value Each string "*" as placeholder for any number of characters "?" as placeholder for any character

Page 76: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Using the SearchManager 8.3 SearchManager application example

Programming 76 Operating Manual, 04/2012, A5E03853259-01

See also SearchManager application example (Page 76)

8.3 SearchManager application example Set searchManager = a.Workset.GetSearchManager Set rootObjects = searchManager.RootObjects rootObjects.add a searchManager.SystemType = 8 searchManager.IsSearchCaseSensitive = true searchManager.IsUserAbortAllowed = true searchmanager.AppendSearchCondition "", "PROPERTY", "NAME", "=", "CaSeTESt" searchmanager.AppendSearchCondition "OR", "PROPERTY", "DESCRIPTION", "LIKE", "Test*" searchmanager.searchconditions.item(1).IsSearchCaseSensitive = false Set resultSet = searchManager.Start searchManager.RetrieveData(10) For i = 1 To resultSet.count Output resultSet.Item(i).SystemUid + " " + resultSet.Item(i).Name + " " + resultSet.Item(i).Description + " " + resultSet.Item(i).SystemFullName() Next searchManager.Stop()

Page 77: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 77

Icon specifications 9Technical specifications for icons

● 72 dpi

● RGB 8 bits

● 16x16 Only icons with the size 16x16 are officially supported. Other formats are not correctly displayed in all parts of COMOS.

● Scaling: As of COMOS 8.2, the following applies: Aspect ratios are not automatically retained. Instead, the location in COMOS decides how the image is displayed.

● Background: Transparent For reasons of interoperability (due to VB), when converting between the two worlds (COM and .NET), the PicturesLibrary has to mark one color as transparent. Here, the PicturesLibrary conforms with the Microsoft standard and takes the color of the lower left pixel of the image (unless it is black). If you create an image or find one in the database that has only one color and if this is set for the lower left pixel, do not be surprised if you no longer see the image or if this color is missing in the image.

Page 78: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Icon specifications

Programming 78 Operating Manual, 04/2012, A5E03853259-01

Page 79: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Programming Operating Manual, 04/2012, A5E03853259-01 79

Other components 1010.1 Report.ocx

Document: Function CreateDWG ( x1 as Double, y1 as Double, x2 as Double, y2 as Double ) as Object

CreateDWG generates a placeholder (= rectangle) for a DWG/DXF file on the report. The parameters are the coordinates of the placeholder. An object of the class ReportDWG is supplied as return value. At this object, the to be displayed AutoCAD file is specified with the FileName property.

You can use CreateDWG anywhere where you have access to ComosReportDocument (hence to the document class of Report.ocx). In report templates this is the case with all placed objects that have a script tab in their properties.

Script Set MyDwg = ReportDocument.CreateDWG(x1, y1, x2, y2) MyDWG.FileName = "xyz.dwg"

VisualBasic Embedding Report.ocx.

Dim MyDwg as ReportLIB.ReportDWG

Set MyDwg = ReportDocument.CreateDWG(x1, y1, x2, y2)

MyDWG.FileName = "xyz.dwg"

Page 80: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Other components 10.2 UseSpecs.dll

Programming 80 Operating Manual, 04/2012, A5E03853259-01

10.2 UseSpecs.dll Returns all usages through the GetUseSpecifications function. Thus, this function is the script counterpart to the "Usage" tab.

GetUseSpecifications Function GetUseSpecifications(ByVal Spec As IComosDSpecification, ByVal ObjType As ObjectType, ByVal DocType As DocumentType, ByVal ProjType As ProjectType, ByVal Inherit As Boolean) As IComosDCollection Spec: ObjType: DocType: ProjType: Inherit:

Option ObjectType (“"Evaluation of") 0: None

1: Base objects

2: Engineering objects

3: All

Option DocumentType ("Considers documents") 0: None

1: Templates

2: Planning

3: All

Option ProjectType (“Project”) 0: Current

1: All

Example 1 The following example returns all usages of the "CurrentSpec" attribute, only considering base objects and report templates of the current project.

In addition, inherited objects are evaluated (True parameter). Set UseSpesDLL = CreateObject("ComosUseSpecs.UseSpecs") If Not UseSpesDLL Is Nothing Then Set SpecCol = UseSpesDLL.GetUseSpecifications (CurrentSpec, 1, 1, 0, True) End If

Page 81: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Other components 10.3 ComosTGeneratorJobs

Programming Operating Manual, 04/2012, A5E03853259-01 81

Example 2 Outputting an attribute in the ObjectDebugger. 'CurrentSpec is the object that was dragged into edit field "A" => UseSpesDLL.GetUseSpecifications (A, 1, 1, .... Output "SpecCol.Count = " + cstr(SpecCol.Count) For i = 1 To SpecCol.Count Output SpecCol.item(i).systemfullname Next

10.3 ComosTGeneratorJobs

10.3.1 Class NextString and Class RunValues CObject contains either the mask or @MASK:SentenceNameInTable.

Class NextString Function

● AddItem AddItem ( ByVal ItemStr as String ) as Integer Adds a string item.

● MaskValid MaskValid ( ) as Boolean

Tests if the mask itself is valid.

● Test Test ( ByVal CurrentValue as String ) as Boolean

Tests the passed string for the current mask and returns if the string is valid.

● GetNext GetNext ( ) as String

Returns the next calculated string. Does not add another item.

● RegExpPattern RegExpPattern ( ByVal ComosMask as String ) as String

● TestPrefix TestPrefix ( ByVal CurValue as String ) as Boolean

Property

● DefaultValue DefaultValue ( ) as String

● Mask Mask ( ) as String

COMOS text mask, therefore a template for a new string.

● ScreenMessages ScreenMassages ( ) as Boolean

Page 82: COMOS 4 - Siemens · WinCC 5 ControlProperties 6 Creating and incorporating 3D symbols 7 Using the SearchManager 8 Icon specifications 9 ... 2.1 Building a .Net control for COMOS

Other components 10.3 ComosTGeneratorJobs

Programming 82 Operating Manual, 04/2012, A5E03853259-01

Sub

● Clear Clear ( )

Deletes all string items.

Class RunValues Function

● Mask Mask ( ByVal TextGenerator as IComosDTextGenerator ) as String

● DefaultValue DefaultValue ( ByVal TextGenerator as IComosDTextGenerator ) as String

Property

● ScreenMessages ScreenMassages ( ) as Boolean