SimTree - Guide
SimTree - Guide
System requirements
To use the application, STEP 7 must be installed (it was tested with Version 5.5) and you need
at least .NET Framework 4.0. You can find the application in
SimTree2010\SimTree2010\bin\Release. The code was written with Visual Studio 2010, so if
you want to open the whole Solution (what is recommended) you should use Visual Studio 2010
or newer.
The Application
Getting started
Start the application SimTree.exe
The SimTree-window is divided into two areas. On the left side there is the dynamic part of the
application. Here you can load Simatic-projects and edit them. On the right side of the window
you can see the object-structure of the command-interface. This “tree” contains links to the help
topics specified by the object. When a project is loaded, the tree highlights objects,
corresponding to the selected item on the left side. Thus you can comprehend how the
command-interface is structured.
To get familiar with the handling of SimTree, we will start with an example-project. Press the
button “Create Example-Project”. A second window pops up.
You can choose which components of the example should be created. For the beginning the
“300 Station” is enough. Uncheck all Create-options except 300 Station and click “Create”. Now
the Application creates a new project called “SimTreeExampleProject” and adds the Station
“Station300”. It also adds some modules and subnets with slaves. After the program finished,
close the window and load the project in SimTree. To do so, press FILEOpen Project on the
top-menu. The Open-Project-Dialog will appear.
Select “SimTreeExampleProject” and press “Load”. The project will load and SimTree will show
it on the left side of the window.
Now you can go through the project. The project-tree is structured like the command-interface
and the names of the objects are the texts of the nodes. You can get to the command-interface-
help by pressing “F1”. The help will open the page that belongs to the current selected object.
To see the properties of a specific object, right-click on it and choose “Properties…” in the
context-menu. Every object-type has its own properties-dialog, because the properties and
functions of an object differ, too. Here you can see the module-properties-dialog of a module.
In this dialogs you can edit the properties of an object. Some of the properties cannot be edited,
because they are read only. To edit an attribute, double-click on the attribute-name and insert a
new value. When you changed a value of an attribute or a parameter, it will be saved
immediately. Closing the Module-Dialog by pressing “Cancel” will not undo the changing! For
more detailed information about the object-parameters, press help.
As you might have already noticed, there are various items in each context-menu. They are
different for every object and they even depend on the location of the object. For example, a
module in a slave has other context-menu-items than a module in a rack. That’s because there
are some functions especially for one type of module. Not every module-function can be used
on every module!
Now you have the basic knowledge to work with SimTree. The next step is to understand, how
the program works, to enable you to work with the command-interface yourself. Please consider
that SimTree is just an example for the usage of the command-interface. It was not the demand
to give you a program with an optimized performance, but to show you how to work with the
command-interface. Therefore, the code is structured to be readable not to have an optimized
performance.
Help
You can get to the help from nearly every dialog by pressing “F1” or the “Help”-button. The help
will open on the page that belongs to the object you are currently working at. You can also get
to the help by clicking on an object-node on the right side of the application.
The Code
The Application is written in C#. To understand the code, you should have a basic knowledge of
this language.
From now on, we will stay in CreateExampleDlg. Secondly we open the project or create it, if it
doesn’t exist.
try
{
// Try to open SimTreeExampleProject
project = WrapperCls.sim.Projects["SimTreeExampleProject"];
}
catch
{
// Create SimTreeExampleProject
project = WrapperCls.sim.Projects.Add("SimTreeExampleProject");
}
S7HCOM_XLib.IS7Station5 station;
// Add station
station = (S7HCOM_XLib.IS7Station5)project.Stations.Add("Station300",
SimaticLib.S7StationType.S7300Station);
S7HCOM_XLib.IS7Rack rack;
// Add rack
rack = station.Racks.Add("UR", "6ES7 390-1???0-0AA0", "", 0);
S7HCOM_XLib.IS7Module6 cpu;
// Add power-supply
rack.Modules.Add("PS 307 10A", "6ES7 307-1KA00-0AA0", "", 1);
// Add cpu
cpu = (S7HCOM_XLib.IS7Module6)rack.Modules.Add("CPU 319-3 PN/DP", "6ES7 318-3EL01-0AB0",
"", 2);
// Add more modules
rack.Modules.Add("SIFLOW FC070", "7ME4 120-2DH20-0EA0", "", 4);
rack.Modules.Add("FM 355 C PID Control", "6ES7 355-0VH10-0AE0", "", 5);
…
S*I*M*A*T*I*C – Comment
To make it easier to find functions that deal with the command-interface, every command-
interface-function has the comment ----------*S*I*M*A*T*I*C*----------. You don’t have to
read the whole function to find the one line that is important for you.
Sometimes there is the comment “not important for Simatic” at the beginning of a function. That
means, this is a function you don’t need to understand, because there is just something
program-internal.
Regions
The two classes MainFrame and WrapperCls are separated into regions. The main regions are
structured like the SimTree-window. The region “ContextMenuStrips” has regions itself, which
are structured like the command-interface-objects.
WrapperCls
Every request to the command-interface, made in MainFrame, is stored in WrapperCls. Thus,
if you are searching for a specific command-interface-function, search for it in this class. When a
function is not in WrapperCls, look for it in the properties-dialogs. To communicate with
MainFrame, the program uses an object called TagObj.
TagObj
When a project is loaded, it is saved in a treeView-object. The COM-objects are saved as
SimObj in the tags of the nodes. To specify the type of the object, there is the enumerator
SimObjType. The numbers of this enumerator have a second meaning. They are also the IDs
for the command-interface-help (the IDs are stored in helpNumberCls). Another object called
concreteType includes more details about the object-type. All information is collected in the
class TagObj.
DialogCls
All functions in this class open extern dialogs to get input from the user. Normally the dialog
returns the input value. If the dialog was quitted with the “Cancel”-button, the function throws an
exception. The internal structure of DialogCls is not important for the usage of the command-
interface.
Example: RenameObj
When the “Rename…”-item is pressed in a context-menu, the MainFrame takes the TagObj
from the selected node and assigns it to the WrapperCls-function RenameObj. The new name
is the return value of a DialogCls-function:
MainFrame:
String newName;
try
{
// Get new name
newName = DialogCls.InputStringDlg("Insert new name", "New Name:", node.Name);
// Rename object
WrapperCls.RenameObj((TagObj)node.Tag, newName);
}
catch
{
return;
}
WrapperCls:
WaitCursor
WaitCursor turns the cursor into the Windows-wait-cursor and back to the default-cursor.
HelpNumberCls
HelpNumberCls includes all help-IDs used in the program as constant unsigned integers.
The Context-Menu-Strips
The context-menu-strips include most of the command-interface-functions. Every object-type
has its own context-menu. You can find the command-interface-functions to the menus in the
region “ContextMenuStrip” in WrapperCls. Consider that some functions are disabled in a
context-menu-strip, because they are not available for an object, but not all non-disabled-
functions are available. For example, some functions of the module-object are especially for
CPUs. You can select them from other modules than CPUs, too, but then they will throw an
error. Furthermore, you can always see online functions, but they are only operating when you
have an online-connection.
The Properties-Dialogs
Every object-type has its own properties-dialog. Every dialog consists out of properties and
functions, specific for this type. Sometimes not all properties or functions are available, because
they just exist for some objects of this type. In this case the buttons or textboxes are disabled.
Some command-interface-functions are implemented in the properties -dialogs and cannot be
found in WrapperCls! If you can’t find a function in WrapperCls look at the corresponding
properties -dialog.
module.LinkSubnet(subnet);
On the right side you can find a short guide that tells you how to use this dialog. The most part
of the dialog shows a split-container. Both panels of the container have the same structure.
Before you can create a new connection, you have to select the modules that are used for
connection the two stations. Therefore, load both, the local and the remote project. They will
appear as trees.
Now register all needed modules. You can do this by selecting the module-type in the list and
then selecting the corresponding module in the tree.
When all modules were chosen, the “Add Connection”-Button will be enabled. By pressing this
button, the add-process will start. The add-process itself happens in another method called
AddHConn2Way/AddHConn4Way.
hConn.LOCAL_INTERFACE_MODULE_WAY1 = locCp1.Name;
hConn.LOCAL_INTERFACE_ADDRESS1 = locCpI1.MACAddress;
hConn.LOCAL_INTERFACE_MODULE_WAY2 = locCp2.Name;
hConn.LOCAL_INTERFACE_ADDRESS2 = locCpI2.MACAddress;
// Create connection
S7HCOM_XLib.S7Conn s7NewConn =
conns.AddUserHConn2Way((S7HCOM_XLib.IS7Module)locCp1, hConn);
This function is called twice. One time, to create the connection in the local project and another
time, to create the connection in the remote project.