SinumerikOperate CPP
SinumerikOperate CPP
Manufacturer Documentation
Introduction 1
Getting started 2
Infrastructure services 7
Valid for
Archive service 8
Software version 4.93
Drive machine data 9
service
TraceDataRecorder 10
service
ToolManagement 11
service
Display Manager 13
11/2019 Index I
SINUMERIK® documentation
Edition history
Brief details of this edition and previous editions are listed below.
The status of each edition is shown by the code in the ”Remarks" columns.
Trademarks
All names identified by the trademark symbol ® are registered trademarks of Siemens AG. Other product
names used in this documentation may be trademarks which, if used by third parties, could infringe the
rights of their owners.
Disclaimer of liability
We have checked that the contents of this document correspond to the hardware and software
described. Nonetheless, differences might exist and therefore we cannot guarantee that they are
completely identical. Nevertheless, the information contained in this document is reviewed regularly and
any necessary changes will be included in subsequent editions.
Siemens AG 2019.
Subject to change without prior notice
11/2019 Content
Content
1
1 Introduction
! Important
Machine-critical OA functions must be secured using suitable
real-time applications. Under no circumstances should
machine-critical functions be implemented based on HMI
functions alone. In particular, the "hotlink mechanism" (notification on a value
change) cannot be used as the sole basis for implementing machine-critical
functions.
2 Getting started
2
2.1 New project
2.1.1 Creating a new project
Overview
Use of the C++ interface (C++ API) is explained using basic Win32 application
examples. The intention is to focus on using the interface, not on Windows
programming. However, it will help if the user is familiar with the 32-bit Windows
API.
The following steps must be performed before the interfaces of the C++ interface
can be used.
Create a project
Operate must have a window to be able to link the application later. For this
reason, a "Win32 Project" is created, for example, under "C++ / Win32". If the
application requires multiple windows, it should be designed as an MDI application
(Multiple Document Interface application). You will find more detailed information
on MDI in the Microsoft documentation.
Include
All classes of the C++ interface are defined in the following header file:
sloperatecppapi.h
The following Include entry must be present to be able to use the functions:
#include "sloperatecppapi.h"
if (error != 0)
{
// Error evaluation
}
The error evaluation is shown precisely in the source code of the individual
examples.
Information about error numbers
More detailed information about error numbers can be found using the
"errorLookup" application.
case WM_CREATE:
CreateWindow(L"static", L"Item:", WS_VISIBLE | WS_CHILD,
10, 20, 100, 20, hWnd, 0, GetModuleHandle(0), 0);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case 1: // read
ReadControlData();
break;
}
• Auxiliary functions are usually declared at the beginning of the file (with the
exception of asynchronous functionalities).
The sections of the systemconfiguration.ini file that are relevant for linking
OEMFrame applications are described below.
Section [processes]
This section specifies the processes to be managed by the System Manager. The
applications to be linked as OEMFrame applications must be specified here. The
following entries are relevant for OEMFrame applications:
Table 4-1: Entries in the [processes] section that are relevant for OEMFrame applications
Value Meaning
process Symbolic name of the OEMFrame application. This is required for the
operating area configuration.
cmdline Command line, passed to the oemframe.exe process on starting. "\\" must
be used as path separator.
(the path does not have to be specified if the OEMFrame application is in
the directory "\oem\sinumerik\hmi\appl")
oemframe Should always be set to "true" for OEMFrame applications.
windowname Window name of the OEMFrame application - determined using the
supplied Findwindow tool
(Start Programs Siemens Automation Sinumerik SINUMERIK
Integrate Create MyHMI -3GL Tools Find Window)
Value Meaning
startupTime The linked process starts as follows:
immediately (default)
afterServices After all services have started.
afterGuis After all GUI components have started.
The Gimmekey bit mask for an OEMFrame application is set to 0xF by default. This
means that all key combinations of F1 through F8 are available to the OEMFrame
application. The OEMFrame application itself can handle a specific key (or key
combination) by setting additional bits. Otherwise, the system configuration will
evaluate the key (or key combination) and it will not even reach the OEMFrame
application.
The Gimmekeys bit mask, the Disablekeys bit mask and the ProcessAffinityMask
bit mask can be specified with a decimal code (e.g. 31) or a hexadecimal code
(e.g. 0x1F).
Example 1:
[processes]
PROC500=process:=notepadOEM, cmdline:="C:\\WINDOWS\\system32\\notepad.exe",
oemframe:=true, deferred:=true, windowname:="Untitled - Notepad",
classname:="Notepad"
PROC501=process:=calcOEM, cmdline:="C:\\WINDOWS\\system32\\calc.exe",
oemframe:=true, deferred:=true, windowname:="Calculator",
classname:="SciCalc"
[areas]
AREA500=name:=AreaNote, process:=notepadOEM
AREA501=name:=AreaCalc, process:=calcOEM
In this example, the two Windows applications "notepad.exe" and "calc.exe" are
configured as OEMFrame applications.
Example 2:
[processes]
PROC600= process:=keycatcherOEM, cmdline:="keycatcher.exe", oemframe:=true,
deferred:=true, windowname:="keycatcher", classname:="QWidget",
gimmekeys:=0x1F, disablekeys:=0x300FF
[areas]
AREA500=name:=AreaKeyCatcher, process:= keycatcherOEM
Example 3:
[processes]
PROC600= process:=keycatcherOEM, cmdline:="keycatcher.exe", oemframe:=true,
deferred:=true, windowname:="keycatcher", classname:="QWidget",
gimmekeys:=0x4F, disablekeys:=0x300FF, menuselectkey:=Key_Control|0x7B
[areas]
AREA500=name:=AreaKeyCatcher, process:= keycatcherOEM
The Windows "keycatcher.exe" application is linked in this example. In this case, all
four softkey bars and the F10 key will reach the Windows application. Press
Ctrl+F12 to show the operating area menu when a Windows application is
displaying (the system configuration no longer evaluates F10).
Example 4:
[processes]
PROC600= process:=keycatcherOEM, cmdline:="keycatcher.exe", oemframe:=true,
deferred:=true, windowname:="keycatcher", classname:="QWidget",
gimmekeys:=0xF, disablekeys:=0x300FF
[areas]
AREA500=name:=AreaKeyCatcher, process:= keycatcherOEM
The Windows "keycatcher.exe" application is linked in this example. In this case, all
four softkey bars are fed to the Windows application. Key sequences Ctrl-F1 to
Ctrl-F8 can be mapped onto key sequences Ctrl-F13 to Ctrl-F20.
Section [areas]
The HMI operating areas are configured in this section. The following entries are
relevant for OEMFrame applications:
Table 4-5: Entries of the [areas] section that are relevant for OEMFrame applications
Value Meaning
name Symbolic name for the operating area
process Name of the OEMFrame application as set in the [processes] section.
panel Name of the panel (header) to be used. Only "SlHdStdHeaderPanel" is
currently available for OEM applications.
plcid ID to identify the operating area using the Operate HMI monitor
(only values in the range of 150-199 are permitted)
Example:
[areas]
AREA600= name:=AreaOEM, process:=notepadOEM
AREA601= name:=AreaCalc, process:=calcOEM, panel:=SlHdStdHeaderPanel
! Important
In the "processes" and "areas" sections, the number range
500-999 is reserved for OEM customers. If numbers less than 500 are used,
basic Siemens components may be overwritten.
! Important
OEMFrame applications that use the programming interfaces of HMI Advanced
are not supported.
! Important
In order to avoid write errors, the entries under "Section [processes]" and
"Section [areas]" should only be determined using the "Find Window" tool
provided (Start Programs Siemens Automation Sinumerik
SINUMERIK Integrate Create MyHMI -3GL Tools Find Window).
Section [miscellaneous]
Various settings can be made in this section. However, only the Start operating
area is usually changed here.
Example:
[miscellaneous]
startuparea = AreaOEM
The operating area displays the configured names of the operating areas from
"systemconfiguration.ini" as the text on the operating area softkeys. The menu
automatically searches for a free softkey on the horizontal softkey bar for each
operating area. If the operating area is to be assigned a certain softkey in the
operating area menu, or if a foreign language text or an icon for the operating area
should be displayed on the softkey, additional configuration is possible and is also
necessary.
A section can be created for each operating area that has been configured in
systemconfiguration.ini. The section must have the name configured for the
operating area in question, e.g. AreaOEM.
Example:
[AreaOEM]
; Text-ID of a language dependent text
TextId = MY_AREA
; File name of the text file which contains the Text-ID
TextFile = mytextfile
; Context in the text file to which the Text-ID is assigned to
TextContext = mycontext
; File name of an icon shown on the area softkey
Picture = mypicture.png
; Position of the area softkey on area menu,
; If no position is specified, an empty position is searched
SoftkeyPosition = 7
; Access level of the area softkey
AccessLevel = 5
The area softkey for the "AreaOEM" operating area is configured in this example.
The softkey is at position 7 in the operating area menu and is displayed with
access level "Keyswitch position 2" and higher. This softkey displays the text
stored in the mytextfile_xxx.ts text file in the context "mycontext" with the Text-ID
"MY_AREA". The mypicture.png icon is also displayed.
! Important
Operating area position 7 is reserved for OEM customers.
Note
If an OEMFrame application comprises several forms, then these should be
combined under one MDI frame. Only then can it be guaranteed that the System
Manager correctly executes the area switchover.
Parameter overview
Table 2-8: "oemframe.ini" parameters
Entry Meaning Default
WindowStyle_On Defines properties to be assigned to the 0
window.
WindowStyte_Off Defines properties that the window must not 0
have.
x Horizontal starting coordinate of the 0
OEMFrame application
(Unit: pixels)
y Vertical starting coordinate of the OEMFrame 0
application
(Unit: pixels)
Width Width of the Width of the desktop
OEMFrame application
(Unit: pixels)
Height Height of the Height of the desktop
OEMFrame application
(Unit: pixels)
nDelayInitComplete Delays feedback to the System Manager. 0
fSearchOnlyForTask- States whether the window specified in the 1
Window "systemconfiguration.ini" belongs to the task
also specified in that file.
fRestoreTaskWindow Defines the behavior when exiting an 0
application that was started from the
OEMFrame application.
fKeepPlacement Deactivates the size adaptation. 0
fForceTaskFocus Define which window of the OEMFrame 0
fSearchForPopUps application will be displayed when starting. 1
nInitShowMode State in which the window of the OEMFrame SW_SHOWMIN-
application is displayed when the application NOACTIVE
is started.
nShowMode State in which the window of the OEMFrame SW_SHOW-
application is displayed when it is shown. NORMAL
nUnShowMode State into which the window of the SW_SHOWMIN-
OEMFrame application is put when it is NOACTIVE
hidden.
fWinForms Must be set if the application is a "Windows 0
Forms Application".
nSwitchToTaskAfter- Controls the behavior when the OEMFrame -1
Termination application is exited.
fFindWindowWithWil Should be set when using "wildcards" (?,*) for 0
dcards the window name.
nPlacementMode Behavior when using with SideScreen or 0
DisplayManager
WindowStyle_On / WindowStyle_Off
The appearance of a Windows application is defined in part using the
SetWindowLong Windows API functions. When the SetWindowLong function is
called, the appearance of the application is controlled using an 8-byte word. Two
bytes of this word can be changed using the WindowStyle_On and
WindowStyle_Off attributes. These are explained in the following table:
The values shown in binary notation here are assigned to the WindowStyle
attributes as a decimal number. You can use the pocket calculator of Windows to
convert from binary to decimal, and vice versa. The calculator is usually found in
the Accessories program group.
Example:
The properties of the system menu as well as the horizontal and vertical scroll bar
should be defined. According to the table, these are:
0000 0000 0011 1000 0000 0000 0000 0000 binary or 0038 0000 Hex.
Now, call the pocket calculator and
- Click the Hex button
- Enter the string of digits 380000 (leading zeros can be omitted)
- Click the Dec selection button
- Copy result 3670016, using the Edit menu
- Insert the result at Attribute
Example 1:
For the Notepad editor, the system menu as well as the horizontal and vertical
scroll bar should be activated:
[notepad]
WindowStyle_On = 3670016
Example 2:
No minimize box and no maximize box should be displayed for the Notepad editor:
[notepad]
WindowStyle_Off = 196608
X/Y
The X and Y attributes define the starting coordinates of the window of the
Windows application to be linked, measured from an origin in the upper left corner
of the screen.
Height
This attribute defines the height of the window for the Windows application,
measured in pixels from the window origin according to attribute Y.
nDelayInitComplete
As soon as the window of the Windows application has been found, a message
indicating this is sent to the System Manager. The Windows application can then
be selected using the System Manager. This message can be delayed using the
"nDelayInitComplete" parameter. This is necessary if the Windows application still
has to execute actions that will take a long time after its window has been created,
which could result in the window being incorrectly displayed if it were activated too
early by the System Manager.
.
(Unit: milliseconds, default value: 0)
Example:
After creating its window, a Windows application "app.exe" reads additional status
data from a database that is absolutely necessary for the Windows application to
run correctly. The window of the Windows application may only be displayed after
all status data has been read. On the average, this read operation should take
approx. 1 sec. The following parameter assignment is required:
[app]
;worst case
nDelayInitComplete = 2000
fSearchOnlyForTaskWindow
This parameter specifies whether or not the window specified in the file
"systemconfiguration.ini" using ClassName/WindowName belongs to the task that
is also specified there. If the window belongs to the specified task, the parameter
"fSearchOnlyForTaskWindow" is assigned the value 1. If the window does not
belong to the specified task, "fSearchOnlyForTaskWindow" should be set to 0. In
this case, not just the windows of the task configured in "systemconfiguration.ini"
are considered in the search for the specified window, but all of the windows that
exist in the system at the time of the search.
(Flag, default value: 1)
Example:
The Windows application comprises more than one process, e.g. a "startup.exe"
and a "user.exe". In the "systemconfiguration.ini" file (only) "startup.exe" is entered,
from which "user.exe" is then started. The application window belongs to
"user.exe" and is therefore not found when searching is restricted to the windows
of "startup.exe". The following parameter assignment is required:
[startup]
fSearchOnlyForTaskWindow = 0
fRestoreTaskWindow
This parameter defines the behavior when exiting a Windows application that was
started from the OEMFrame application (second task level).
Note
This situation cannot be completely controlled and should therefore be avoided if
at all possible!
When the OEMFrame application is selected, the last window that was active
(ForegroundWindow) is saved by default. This window is reactivated when the
OEMFrame application is reselected. If another application has been started from
the OEMFrame application, the active window will usually belong to this Windows
application.
Basic window
Restrictions:
If a modal window (dialog box) is active in the OEMFrame application when the
second application is started, this modal window will lose the input focus when the
second application is ended. In this case, the operator must explicitly set the focus
in the dialog box (e.g. using the mouse).
fForceTaskFocus / fSearchForPopUps
These two parameters define which window the OEMFrame application will
activate after it has been deselected and reselected again. On switching from one
operating area to another, the default setting is that the last active window of the
OEMFrame application is saved. When the application is selected again, this
window is activated again. In the Windows API, this window is called the
ForegroundWindow.
fForceTaskFocus=0
Basic window fSearchForPopUps: irrelevant
This (default) behavior makes sense for the majority of applications. However,
there are exceptions for which this behavior can be changed. If the two parameters
"fForceTaskFocus" and "fSearchForPopUps" are set to the value 1, when the
OEMFrame application is deselected, a search is not made for the
ForegroundWindow but rather for an active popup window that belongs to the basic
window of the application. If a popup window is found, it will be displayed when the
OEMFrame application is selected again. If there is no popup window, the basic
window of the application will be displayed when the application is reselected.
fForceTaskFocus=1
Basic window fSearchForPopUps=1
fKeepPlacement
This function deactivates the resizing (zooming) for the basic window of the OEM
application. The application is normally zoomed to the screen size before it is
displayed. In the case of applications that do not allow their windows to be
zoomed, the resizing can result in display problems. In such cases, the zoom
function must be deactivated.
Example:
An application "fixres.exe" should be displayed in its programmed window size.
size. The following parameter assignment is required:
[fixres]
fKeepPlacement = 1
10: The application window is displayed in the same way as when the
application was started (SW_SHOWDEFAULT).
Note
The default settings are suitable for most applications. However, in some cases,
display problems can occur (window not maximized, etc.). This can be remedied
by setting parameter nShowMode=3.
fWinForms
If the OEMFRAME application is a "Windows Forms Application" with the name
"myApp.exe", then the following parameterization is required:
[myApp]
fWinForms = 1
Note
If the parameter is not set, the OEMFrame application will not be started as a
maximized window and any sizing (X, Y, Width, Height) will have no effect.
nSwitchToTaskAfterTermination
This parameter controls the behavior when the OEMFrame application is exited.
The System Manager normally displays the area switch menu in this situation and
the user must explicitly
switch to another area. This parameter can be used to initiate an automatic switch
to the previously active area.
Example:
When the "closeapp.exe" Windows application is exited, a switch should be made
to the previous area. The following parameter assignment is required:
[closeapp]
nSwitchToTaskAfterTermination = -2
fFindWindowWithWildcards
This parameter activates the wildcard search for the window name. ? (an arbitrary
character) and * (arbitrary number of characters) can be used. In this way it is
possible to identify applications that do not have the same window name at every
start (e.g. access level, time in the window name, etc.).
Example:
An application is to be integrated that contains the start time in the
window name.
oemframe.ini:
[MyQtTest]
fFindWindowWithWildcards=1
systemconfiguration.ini:
[processes]
PROC500=process:=ProcessOEM, cmdline:="C:\\Program Files
(x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\appl\\MyQtTest.exe",
oemframe:=true, windowname:="MyQtTest - ??:??:??", classname:="QWidget",
deferred:=true
[areas]
AREA500=name:=Test, process:=ProcessOEM
nPlacementMode
This parameter influences the behavior in conjunction with the Siemens Sidescreen
and the Display Manager
OEM subdirectories
If multiple OEM applications (Operate dialog boxes or OEMFrame applications) are
to be linked, these can be distributed across the OEM's own subdirectories. The
advantage is the clear assignment of the files to a particular OEM application. This
is especially true for the "systemconfiguration.ini" as there is a risk of it being
accidentally overwritten when copying, which may hide other OEM applications.
Example:
[oem_dirs]
OEM_1=oem_example
OEM_2=oem_new
When required, the appl, cfg, lng, hlp, etc. directories can be created again below
these two OEM subdirectories ("/oem/sinumerik/hmi/oem_example" and
"/oem/sinumerik/hmi/oem_new").
A version file must have the name "versions.xml" and is generated in a format
similar to XML. As a minimum, a name and a version are required:
Example (minimum):
<info>
<Name>OEM1</Name>
<Version>1.1</Version>
</info>
Example (path):
<info>
<Name>OEM1</Name>
<Version>1.1</Version>
<Component>
<Name>OEM1 componentX</Name>
<Version>6.1</Version>
<Path>appl</Path>
</Component>
</info>
During startup, the OEM directory as well as possibly existing OEM subdirectories
are scanned and a higher-level version file is created in the "/oem" directory.
Note
The higher-level version file is only created if such a version file does not exist
under "/oem". This means that it must be deleted when a new OEM application is
installed.
References to the OEM applications from the OEM directory or the OEM
subdirectories are entered into this higher-level version file. If OEM subdirectories
and the OEM directory are used simultaneously, it should be ensured that the
entries of the version files do not overwrite one another.
Note
The description of the versioning applies to the PCU50/IPC and LinuxEmbedded
target systems. The associated required infrastructure is missing on the
development PC.
<info defaultFileType="*.exe"
defaultFileVersion="01.01.00.00"
LinkName="appl">
<Name>OEM6 component</Name>
<Version>16.16</Version>
Example :
;VERSION: 06.02.08 ;DATE: 2002-01-07
;CHANGE: 06.02.04 ;DATE: 2001-07-23
In addition, a "versions.xml" with the following contents should be saved in the cfg
directory of the corresponding INI file.
By specifying the "defaultFileType", the version information is directly read out from
all INI files and displayed. The "defaultFileVersion" specifies the target version. If
the reference and actual version do not match, this is clearly indicated in the
version display by a red attention sign.
Note
The version file in the "cfg" directory is not automatically considered. Therefore, a
link to it must be created in the higher-level OEM directory (or OEM subdirectory)
by specifying "Path":
<Component>
<Name>OEM1 componentX</Name>
<Version>6.1</Version>
<Path>cfg</Path>
</Component>
2.3.3 Debugging
Visual Studio must be started as described above. SINUMERIK Operate must then
be started. As soon as a connection has been made to the control, the application
can be started in Visual Studio under debugger control.
Table 2-10:
SlString ()
Table 2-11:
SlString (const char*)
Parameter Meaning
const char* Pointer to a 0-terminated C string
Table 2-12:
SlString (SlString&)
Parameter Meaning
SlString& Reference to SlString object
~SlString
Destructor of the SlString class.
Table 2-13:
~SlString ()
clear
Deletes the string (length = 0).
Table 2-14:
void clear ()
length
Reads the length of the string.
Table 2-15:
long length ()
Parameter Meaning
Return Number of characters in the string
at
Returns a character from the string.
Table 2-16:
char at (long)
Parameter Meaning
long Index in the string
Return Characters in the string
append
Appends further characters to the string.
Table 2-17:
void append (const char*)
Parameter Meaning
const char* Character string to be appended
Table 2-18:
void append (const SlString&)
Parameter Meaning
const SlString Character string to be appended
c_str
Returns the string as a 0-terminated C string.
Table 2-19:
char* c_str ()
Parameter Meaning
Return 0-terminated C string
equals
String comparison operation.
Table 2-20:
bool equals (SlString&)
Parameter Meaning
SlString& String to be compared
Return true/false
==
String comparison operation.
Table 2-21:
bool operator== (SlString&)
Parameter Meaning
SlString& String to be compared
Return true/false
=
Assignment operator.
Table 2-22:
SlString& operator= (const char*)
Parameter Meaning
const char* 0-terminated C string to be assigned
Return Reference to SlString
Table 2-23:
SlString& operator= (SlString&)
Parameter Meaning
SlString& SlString to be assigned
Return Reference to SlString
Table 2-24:
SlVector ()
Table 2-25:
SlVector (const SlVector&)
Parameter Meaning
SlVector& Reference to vector class
~SlVector
Destructor of the SlVector class.
Table 2-26:
~SlVector ()
clear
Deletes the vector (length = 0).
Table 2-27:
clear ()
size
Returns the length of the vector (number of elements in the vector).
Table 2-28:
size ()
at
Reads an element at position (index).
Table 2-29:
T& at (long)
Parameter Meaning
long Index of a vector element
Return Reference to vector element
remove
Deletes an element at position (index).
Table 2-30:
long remove (long)
Parameter Meaning
long Index of a vector element
Return New size of the vector
push_back
Includes an element at the end of the list (in the vector).
Table 2-31:
void push_back (T&)
Parameter Meaning
T& Reference to new element
pop_back
Removes an element from the end of the list (in the vector).
Table 2-32:
void pop_back ()
=
Assignment operator.
Table 2-33:
SlVector& = (SlVector&)
enum type
{
Invalid,
Boolean,
Char,
UChar,
Int,
UInt,
Long,
ULong,
LongLong, // 64 bit
ULongLong, // 64 bit
Double,
String,
SlValueArray
};
SlValue
Default constructor.
Table 2-34:
SlValue ()
Table 2-35:
SlValue (const bool)
SlValue (const char)
SlValue (const unsigned char)
SlValue (const int)
SlValue (const unsigned int)
SlValue (const long)
SlValue (const unsigned long)
SlValue (const long long)
SlValue (const unsigned long long)
SlValue (const double)
SlValue (const SlString&)
SlValue (const SlValue&)
SlValue (const SlVector<SlValue>&)
Parameter Meaning
(…) Initialization parameters
~SlValue
Destructor.
Table 2-36:
~SlValue ()
=
Assignment operators.
Table 2-37:
SlValue& operator= (const bool)
SlValue& operator= (const char)
SlValue& operator= (const unsigned char)
SlValue& operator= (const int)
SlValue& operator= (const unsigned int)
SlValue& operator= (const long)
SlValue& operator= (const unsigned long)
SlValue& operator= (const long long)
SlValue& operator= (const unsigned long long)
SlValue& operator= (const double)
SlValue& operator= (const SlString&)
SlValue& operator= (const SlValue&)
SlValue& operator= (const SlVector<SlValue>&)
Parameter Meaning
(..) Value to be assigned
Return Reference to SlValue
GetType
Gets the type of a value.
Table 2-38:
type GetType ()
Parameter Meaning
Return enum type
toBool
Converts to Boolean.
Table 2-39:
bool toBool ()
Parameter Meaning
Return Boolean value
toChar
Converts to Character.
Table 2-40:
char toChar ()
Parameter Meaning
Return char value
toUChar
Converts to Character (byte) unsigned.
Table 2-41:
unsigned char toUChar ()
Parameter Meaning
Return char value unsigned
toInt
Converts to Integer.
Table 2-42:
int toInt ()
Parameter Meaning
Return Integer value
toUInt
Converts to Integer unsigned.
Table 2-43:
int toUInt ()
Parameter Meaning
Return Integer value unsigned
toLong
Converts to Long.
Table 2-44:
int toLong()
Parameter Meaning
Return Long value
toULong
Converts to Long unsigned.
Table 2-45:
int toULong()
Parameter Meaning
Return Long value unsigned
toLongLong
Converts to LongLong.
Table 2-46:
int toLongLong()
Parameter Meaning
Return LongLong value
toULongLong
Converts to LongLong unsigned.
Table 2-47:
int toULongLong()
Parameter Meaning
Return LongLong value unsigned
toDouble
Converts to Double.
Table 2-48:
double toDouble()
Parameter Meaning
Return Double value
toSlString
Converts to SlString.
Table 2-49:
SlString toString()
Parameter Meaning
Return SlString value
toSlValueArray
Converts to SlValue Vector.
Table 2-50:
SlVector<SlValue>& toSlValueArray()
Parameter Meaning
Return Vector of SlValue values
2.5 FAQs
Cause
Visual Studio was not started via the link provided.
Remedy
Start Visual Studio via the link provided (see Chapter 2.3).
Note
The communication time is not guaranteed. Real-time tasks therefore
cannot be performed with the C++ interface.
3.1 Introduction
3.1.1 Class model
Overview
The class model of the DataService essentially comprises the following classes:
• SlDataSvc
• SlDataSvcItem
• SlDataSvcStatus
#include "sloperatecppapi.h"
Class SlDataSvc
Data accesses to the NC and PLC are implemented using SlDataSvc objects.
In particular, variables can be read and written, and you can
be notified if the value of a variable changes.
Class SlDataSvcItem
The SlDataSvcItem object is used for the individual calls of the SlDataSvcItem
object to identify variables. The value to be written or read is also included in this
object.
Class SlDataSvcStatus
Additional information on the SlDataSvc request currently being executed can be
queried using the SlDataSvcStatus object. These include, for example, the time
stamp or the status of the current hotlink connection.
Synchronous calls
Synchronous calls only return after the request has been executed, i.e.
the calling thread is blocked during execution. This can interfere with
event processing. For example, operator inputs and displays may be
withheld during a synchronous call. This is the reason why calls that
could take a long time should be executed asynchronously.
Asynchronous calls
Asynchronous calls and hotlinks return as soon as the request has been sent
to the DataService. The returned error code cannot therefore indicate
whether the request has been completed successfully;
it can only indicate whether the request has been sent
successfully. For example, an error occurs if call parameters are not correctly
assigned. The actual request status is provided in the callbacks of the DataService.
Single call
Single calls access a variable with read or write access.
The following single calls are available:
Multi-variable call
In a multi-variable call, multiple variables are read or
written. In this case, the variables of a request can address completely different
data. The following multi-variable calls are available:
Note
The function names of the multi-variable calls do not differ from those of the
single calls. Only their call parameters are different.
Hotlink
A hotlink is a notification that one or more variables have changed. After
notification, a callback function is invoked in the implementation of the interface
class ISlDataSvcCb (see sloperatecppapi.h):
The first notification provides the value at the time the hotlink was set up.
With notifications, intermediate values are always lost if the client is unable to
process all value changes.
Array access
For some variables, multiple consecutive variables can be specified
in the variable name. This is known as an
array access.
For example, an array access to three consecutive R parameters (R7, R8, R9)
would be
"/channel/parameter/r[u1,7,#3]"
Connection monitoring
The following variables should be used to monitor the connection. The returned
value 30 indicates that a connection exists.
Note
Previously, the variable "/bag/state/opmode" or
"/Nck/Configuration/maxNumChannels" was used to monitor the connection to
the NCK and variable "ib0" to the PLC. However, this is no longer recommended
as under certain circumstances this procedure is no longer sufficient.
These and all other examples are shown in the following overview of examples.
Only the items relevant for the DataService are explained or described on each
example. The comments for the sources contain more detailed
information (e.g. screen layout, outputs, etc.).
3.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
3.2.2 Reading/writing a variable
Overview
This example shows how data can be read from and written to a control using the
SlDataService interface.
In this example, you can enter an item and then read it using the "read data" button
or write it using the "write data" button. The status bar indicates whether the calls
have been successful.
Step 1
Create the member variable of type SlDataSvc:
// create a reader
SlDataSvc reader;
// create a writer
SlDataSvc writer;
To read and write, it is not absolutely necessary to create the SlDataSvc object as
a member variable. It can also be created locally in the specific function.
Step 2
Read the control value. A SlDataSvcItem-type object is first created. The
variable name to be read is passed during creation. (In the example, the content of
the text field is passed; here, the path is specified directly.)
The read() function of the SlDataSvc object is used to read the item. The value
read is located in the value property of the SlDataSvcItem object.
Step 3
Write the control value. The value property of the SlDataSvcItem object is
assigned the value to be written. The value is written to the control using the
write() function of the SlDataSvc object.
// value to write
item.Value = 1.2345;
Overview
The following step-by-step example shows how to set up a hotlink to a variable.
In the example, you can enter an item and then, using the "start refresh" button, set
up a hotlink that can then be ended again using "stop refresh". The status bar
indicates whether the calls have been successful.
Step 1
Create the required member variables. For the hotlink, an ISlDataSvcCb is
required to identify the hotlink in addition to the SlDataSvc object:
SlDataSvc m_RefreshDataSvc;
ISlDataSvcCb* m_ pCb;
Step 2
Create the hotlink. A SlDataSvcItem-type object is first created. The variable
name to be read is passed during creation. (In the example, the content of the text
field is passed; here, the path is specified directly.)
The hotlink is set up using the subscribe() function of the SlDataSvc object.
Here, both the pointer to the callback function and the SlDataSvcItem object are
transferred.
Step 3
Implement the callback function. The SlDataSvcItemChanged() function is
already defined as virtual void. The user must implement the desired function
to evaluate the value of value. The GetType() function determines whether the
access is a single value or multiple values (e.g. an array, i.e.
SlValue::SlValueArray).
// global variables
double dRefreshValue = 0.0;
// window to inform
HWND msgWindow;
// here you can call main window to show new value dRefreshValue
…
}
}
…
}
Step 4
Unsubscribe the running hotlink. This is done using the unSubscribe() function.
Overview
The following step-by-step example shows you how to read and write multiple data
items simultaneously. In this case, the data must be located contiguously in the
control, for example, a consecutive number of R parameters or PLC bytes.
In this example, you can enter an item and then read it using the "read data" button
or write it using the "write data" button. The status bar indicates whether the calls
have been successful.
Step 1
Create the member variable of type SlDataSvc:
// create a reader
SlDataSvc reader;
// create a writer
SlDataSvc writer;
To read and write, it is not absolutely necessary to create the SlDataSvc object as
a member variable. It can also be created locally in the specific function.
Step 2
Read the control values. An SlDataSvcItem-type object is first created. The
variable name to be read is passed during creation. (In the example, the content of
the text field is passed; here, the path is specified directly.)
The values are read using the read() function of the SlDataSvc object. The value
read is located in the value property of the SlDataSvcItem object.
Step 3
Process the data that has been read. To start, a check is made to see whether the
value property of the SlDataSvcItem object contains an array. If it does, the
content of the property can be converted to an array. value1, value2,
value3, value4 are the returned values that the user can display.
if (item.value.GetType() == SlValue::SlValueArray)
{
SlValue values = item.value;
for (long i = 0; i < values.toSlValueArray().size(); i++)
{
if (i == 0) value1 = values.toSlValueArray().at(0).toDouble();
if (i == 1) value2 = values.toSlValueArray().at(1).toDouble();
if (i == 2) value3 = values.toSlValueArray().at(2).toDouble();
if (i == 3) value4 = values.toSlValueArray().at(3).toDouble();
}
}
Step 4
Write multiple control values. Assuming: value1, value2, value3, value4
are assigned new values and written back into the same SlDataSvcItem object
"/channel/parameter/r[u1,10,#4]".
// array of values
SlVector<SlValue> values;
values.push_back(value1);
values.push_back(value2);
values.push_back(value3);
values.push_back(value4);
The values are written to the control using the write() function of the SlDataSvc
object.
Overview
The following step-by-step example shows you how to read and write multiple data
items simultaneously. In this case, any data can be used, even mixed NC and PLC
data.
In this example, you can enter two different items and then read them using the
"read data" button or write them using the "write data" button. The status bar
indicates whether the calls have been successful.
Step 1
Create the member variable of type SlDataSvc:
// create a reader
SlDataSvc reader;
// create a writer
SlDataSvc writer;
To read and write, it is not absolutely necessary to create the SlDataSvc object as
a member variable. It can also be created locally in the specific function.
Step 2
Read the control values.
SlVector<SlDataSvcItem> items;
items.push_back(item1);
items.push_back(item2);
The values read are in the value property of the SlDataSvcItem object as an array
of items.
items.at[0].value.ToDouble()
items.at[1].value.ToDouble()
Step 3
Write multiple control values. Assuming: The value property of the SlDataSvcItem
object is assigned a new value and written back to the same address (as during
reading) "/channel/parameter/r[u1,10,10]" and
"/channel/parameter/r[u1,10,15]".
// set values
item1.value = 1.234;
item2.value = 2.468;
SlVector<SlDataSvcItem> items;
items.push_back(item1);
items.push_back(item2);
The values are written into the control using the write() function of the
SlDataSvc object.
Overview
Data accesses to the NC and PLC are implemented using SlDataSvc objects.
Variables can be read and written, or notification is possible when the value of a
variable changes.
Synchronous calls block the calling item until the request has been completed.
Notification of the change in value is performed using callback functions.
Mapping of variables
Variables are mapped as SlDataSvcItem-type objects. This SlDataSvcItem
object includes both the variable name and the value.
Array access
If access to multiple consecutive variables is specified in the variable name (array
access), SlDataSvc will return an array in the SlDataSvcItem object.
if (item.value.GetType() == SlValue::SlValueArray)
read
Synchronous reading of variables.
write
Synchronous writing of variables.
writeAsync
Asynchronous writing of variables.
subscribe
Sets up a notification when one or more variable values change. The call returns
as soon as the setup request has been forwarded to the server. The notification is
performed by calling the implemented callback function. The first notification
returns the value at the time the hotlink was set up.
Intermediate values can be lost, but not the final value (see also
Chapter 3.1.2 "Definitions", completeness of signaled value changes).
Parameter Meaning
item Specifies the variable and its new value
(value property).
status Status of the running hotlink. See chapter
3.5 SlDataSvcStatus reference
Return -
Parameter Meaning
items Vector of variables and their new values
(value property).
status Status of the running hotlink. See chapter
3.5 SlDataSvcStatus reference
Return -
unSubscribe
Unsubscribes a hotlink
getDeadBand / setDeadBand
Gets or sets a range within which notifications are suppressed when a value does
not differ sufficiently from the preceding value. This is only active for numerical
values and hotlinks.
If the value is greater than 0, no changes will be forwarded if the value does not
differ from the preceding value by at least the magnitude of the dead band (i.e.
value ± dead band).
A value that is less than 0 produces a series of fixed steps. Values are forwarded
only if the new value is within a different step.
getPriorityFlags / setPriorityFlags
Gets or sets the processing priority of the DataService accesses.
SlPriorityFlags.lowPriority
Low processing priority. This value should be used for cyclic activities and activities
running in the background. By default, the DataService uses this priority for
Subscribe requests once the first value has arrived.
SlPriorityFlags.highPriority
High processing priority. This value is reserved for exclusive use by the machine
manufacturer to achieve productivity goals (e.g. tool change).
SlPriorityFlags.defaultPriority
Default processing priority. By default, DataService executes all read and write
requests in this priority. This priority is also used when accessing the first value for
subscribe requests.
2. The processing priorities are active only within the DataService. Low-
priority requests that have already started will no longer be overtaken by
higher-priority requests.
Note
The flag defaultPriority (value = 0) does not have to be explicitly set. This
value is automatically set after an SlDataSvc object has been created.
getTimeOut / setTimeOut
Gets or sets the timeout for access control.
setSynchronizedMultivarAccess
Occasionally, multiple individual data refer to each other and have to be read or
written simultaneously. However, the DataService does not guarantee that the
variables of a multi-variable call will be sent in one request. In particular, if there is
a high communication load, it attempts to optimize the throughput instead.
Table 3-26:setSynchronizedMultivarAccess
public void setSynchronizedMultivarAccess (bool flag)
Parameter Meaning
flag true/false
Return -
SynchronizedMultivarAccess = true;
For a multi-variable call, setting this flag in the SlDataSvc object will force the
variables to be sent in one request and also the result to be returned in one
request.
Note that there are a number of additional constraints to be complied when setting
this flag. Failure to do so will cause the entire request to be rejected. Possible
causes could be:
1. The variables must be located on the same unit (PLC, NC, or drive).
2. In the case of NCK variables, channel-specific data may only address one
channel and drive-specific data only one drive.
3. Request and result must not exceed the size of one PDU.
Note
The space available in a PDU (protocol data unit) depends on several parameters
of the terminal device (NC, PLC, drive) and cannot be specified generally.
getSynchronizedMultivarAccess
Gets the flag for "congruence access" for multivar access.
Table 3-27:getSynchronizedMultivarAccess
public bool getSynchronizedMultivarAccess (bool flag)
Parameter Meaning
Return true/false
getUpdaterate / setUpdaterate
Gets or sets the maximum notification rate for hotlinks (subscribe calls).
Example:
SlDataSvc data;
data.standardUpdateRate()
Default value. This value is used for variables that change relatively infrequently,
but that affect the display when they do change. Examples include machine data,
operating modes, etc. (200 milliseconds).
data.highUpdateRate()
This value is used for variables whose change is tracked directly by the operator
and that change frequently. Examples include axis positions (50 milliseconds).
data.lowUpdateRate()
This value is used for variables whose acquisition is not time-critical (1000
milliseconds).
data.veryLowUpdateRate()
This value is used for variables whose acquisition is not time-critical (10000
milliseconds).
Overview
An instance of an SlDataSvcItem class represents a variable in the control (NC,
PLC, machine or drive data). This object includes both the variable name and the
value.
GUD arrays are 1-indexed for access, and from the perspective of the SlDataSvc
are always one-dimensional. This means, the index must be calculated for multi-
dimensional arrays.
UGUD.DEF file
DEF NCK INT ARRAY[2]
M17
UGUD.DEF file
DEF CHAN INT ABC[3,3]
M17
2. The underscored data type is the default data type in each case and does
not have to be specified when addressing. In addition, the specifications
DB2.DBB5:BYTE and DB2.DBB5 are equivalent, for example.
3. Square brackets are used to access arrays, e.g. DB5.DBW2:[10] (word
array of length 10).
Examples
If this is activated, then the corresponding symbolic addressing can be used in the
SlDataSvc:
The following data types from the TIA Portal are supported:
• Bool • SInt
• Byte • USInt
• Char • Int
• WChar • UInt
• String • DInt
• WString • UDInt
• Time • LInt
• Time_Of_Day • ULInt
• LTime (read only) • Word
• LTime_Of_Day • DWord
• Date • LWord
• Date_And_Time • Real
• LReal
All data types, with the exception of "String" and "WString", can also be used as
array. For arrays, it is only possible to access an individual element.
Note
NCU names are listed in MMC.INI (see also Fig. 3.5).
Entry:
[GLOBAL]
NcddeMachineNames=NCU1,NCU2
In order that the variable paths are active, the configuration file "slctrl_energy.ini"
should be created in the directory "<Installation path>/oem/sinumerik/hmi/cfg" with
the following content:
[Misc]
EnableOAInterface=true
/Hmi/TMHMICurData
In order that this variable path is active, the configuration file "sltmlistconfig.xml"
(milling machine) or "sltmturninglistconfig.xml" (turning machine) should be created
in the directory "<Installation path>/oem/sinumerik/hmi/cfg" with the following
content:
Fig. 3-9: Standard tool management of the "DRILL" tool selected with the cursor
In the variable, the data of the currently selected tool is listed as a string. Access to
the variable path can be as read access or as notification (hotlink).
The string has the following format (sample string for above figure):
-adaptNo 0 -containerNo 1 -datetime 2014-09-04T14:55:57 -dlNo 0 -edgeNo 1 -
magNo 1 -mtNo 0 -mtPlaceNo 0 -ncuName @ncu1.local -placeNo 2 -toaNo 1 -
toolDuplo 1 -toolIdent DRILL -toolNo 3 -toolType 200
ID Description
-magNo Magazine number
("0" if the current tool is not on a magazine location)
-placeNo Magazine location number
("0" if the current tool is not on a magazine location)
-mtNo Multitool number
("0" if the current tool is not on a multitool location)
-mtPlaceNo Multitool location number
("0" if the current tool is not on a multitool location)
-adaptNo Magazine location adapter number
("0" if the current tool is not on a location or an adapter number has not
been assigned to the location)
Note
The variable is always updated when one of the list screens of the standard tool
management of HMI Operate is exited. This means that the content of the
variable is empty after the startup of HMI Operate.
The order in which the tool data is stored in the variable is not specified.
Parameter Meaning
name Variable name
name
Variable name of the required data item. The name is stored as a string. The
formatting can be seen in Chapter "Variable names".
getName / setName
Gets and sets the variable names.
Note
You can also read out and manipulate the name property directly without using
setName() and getName(), for example:
SlDataSvcItem item;
item.name = “/channel/parameter/r[u1, 1]“;
SlString name = item.name;
value
Value of the variable. The type of these properties is SlValue::type, and can have
different contents depending on the specified variable (number, text). On an array
access, the value property contains an array of SlDataSvcItem objects.
Table 3-39:value
public SlValue SlDataSvcItem.value;
There are two further functions for setting/reading value: setValue() and
getValue().
getValue / setValue
Table 3-40: getValue / setValue
public SlValue getValue ();
Parameter Meaning
Return Value
Note
You can also read out and manipulate the value property directly without using
setValue() and getValue(), for example:
SlDataSvcItem item;
item.value = 1.234;
double value = item.value;
Overview
Information that is evaluated infrequently when reading, writing, or for notifications
is combined in the class described below.
3.5.6 Properties
error
Error number
Table 3-41:error
public SlDataSvcError error;
timestamp
Time at which the read data was last received in the DataService.
Table 3-42:timeStamp
public time_t timestamp;
readInfo
Information about servers and sequence numbers.
Table 3-43:readInfo
public SupplementReadInfo readInfo;
3.6 FAQs
3.6.1 FAQs regarding hotlink
Example:
Definition of GUD: DEF NCK REAL _MYVAR[99,11]
We intend to read variable _MYVAR[2,3].
The index of the access path is calculated as follows: 2*11 + 3 + 1 => 26
It is assumed that this variable is an SGUD, resulting in the following access path:
/NC/_N_CH_GD1_ACX/_MYVAR [26]
Note
A PI service call returns immediately. However, it is not guaranteed that the PI
service has been completely executed when it returns. Some PI services return
their status via OPI variables.
4.1 Introduction
4.1.1 Class model
Overview
The class model of the PiService consists primarily of the SlPiSvc class.
class SlPiSvc
This class is defined in "sloperatecppapi.h". It provides functions for
executing PI services.
These and all other examples are shown in the following overview of examples.
Only the items relevant for the PiService are explained or described in each
example. The comments for the sources contain more detailed
information (e.g. screen layout, outputs, etc.).
4.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
The following example shows how a general PI service is sent. The required
parameters can be entered on the user interface. The PI service is then sent using
the "execute" button. In this example, part program "MYMPF.MPF" in channel 1
(201) is selected for processing (_N_SELECT). To enable the example to be
executed, a part program with the name "MYMPF.MPF" must be created in the NC.
Step 1
Prepare the arguments. First an array of four strings args is created to receive the
entry from the user interface. This array of arguments includes the parameter
assignment for the PI service.
// read arguments
SlVector<SlString> args;
// Arg1
GetWindowText(hwndEditArg1, uiArg, MAX_LOADSTRING);
UnicodeToAnsi(uiArg, (LPSTR) sArg, MAX_LOADSTRING);
args.push_back(SlString(sArg));
// Arg2
GetWindowText(hwndEditArg2, uiArg, MAX_LOADSTRING);
UnicodeToAnsi(uiArg, (LPSTR) sArg, MAX_LOADSTRING);
args.push_back(SlString(sArg));
// Arg3
GetWindowText(hwndEditArg3, uiArg, MAX_LOADSTRING);
UnicodeToAnsi(uiArg, (LPSTR) sArg, MAX_LOADSTRING);
args.push_back(SlString(sArg));
// Arg4
GetWindowText(hwndEditArg4, uiArg, MAX_LOADSTRING);
UnicodeToAnsi(uiArg, (LPSTR) sArg, MAX_LOADSTRING);
args.push_back(SlString(sArg));
Step 2
Create the SlPiSvc object. When you create the object, the array of the arguments
for the PI service is passed in the constructor.
Step 3
Send the PI command. Execution of the PI service is initiated using the start()
function.
// execute PI Cmd
SlPiSvcError err = piSvc840Dsl.start(status);
Overview
The SlPiSvc object is used to send program instance services (PI services).
Parameter Meaning
args Array of parameters required to execute a
general PI service in the NCK.
Return -
start
Triggers a PI service.
cancel
Cancels a PI service.
stop
Triggers a PI STOP command.
plcMemoryReset
Triggers a PLC memory reset.
getTimeout / setTimeout
getArgs / setArgs
Gets or sets PI service parameters (string array).
getPriorityFlags / setPriorityFlags
Gets or sets flags for access control.
SlPriorityFlags.lowPriority
Low processing priority. This value should be used for cyclic activities and activities
running in the background.
SlPriorityFlags.highPriority
High processing priority. This value is reserved for exclusive use by the machine
manufacturer to achieve productivity goals (e.g. tool change).
SlPriorityFlags.defaultPriority
Default processing priority.
The processing priorities are active only within the PiService. Low-priority
requests that have already started will no longer be overtaken by higher-priority
requests.
Note
The flag defaultPriority (value = 0) does not have to be explicitly set. This
value is automatically set after creating an SlPiSvc object.
5
5 Access to alarms and events
All applications wishing to acquire alarms and events, for example, for display
purposes or for further processing and forwarding to MES, are referred to as clients
in the following.
Note
The communication time is not guaranteed. Real-time tasks therefore
cannot be performed with the C++ interface.
5.1 Overview
5.1.1 Introduction and explanation of terms
The following subchapters describe the signal flow between client, service, and
source as a function of the various alarm types.
Alarm source
The alarm service supplies alarms from various alarm sources of an NC. The alarm
service makes a distinction between the following standard sources:
Table 5-1: Specified alarm source identifiers (source URL) of the alarm service
Source Source URL
HMI /HMI
NCK /NCK
NCK channels /NCK/Channel#<Channel No>/Partprogram
(only for part program messages
PLC diagnostic buffer /PLC/DiagBuffer
PLC PMC alarms /PLC/PMC
(Alarm_S(Q): PDiag, S7-Graph, and
HiGraph)
Alarm attributes
With every alarm, the client is provided not only with the alarm number identifying
the alarm but also with additional data such as the alarm state, a timestamp, or
associated process values. This data is referred to as attributes. There are
standard attributes and additional attributes. The standard attributes are identical
for all alarm categories (see alarm category), while the additional attributes can
vary from category to category.
In addition, the attributes differ according to their source: They can originate
directly from the alarm source (e.g. timestamp, associated process values) or,
alternately, they can come from a configuration (e.g. priority).
The alarm service provides a fixed number of attributes via the alarm object.
Alarm category
Not all alarms support the same set of attributes: For example, part program
messages have no associated process values. To be able to differentiate alarms
with regard to their attributes, they are assigned to different categories. All alarms
of one category support the same set of attributes.
HMI alarms
HMI alarms are alarms that originate in the HMI itself. In this case, the HMI
applications are the alarm source.
Synchronous calls
Synchronous calls return only after the request has been performed, i.e. the calling
thread is blocked. This can interfere with event processing since control inputs and
displays are withheld during a synchronous call. For this reason, calls that may
take a long time should be performed asynchronously.
Overview
The class model of the alarm service consists primarily of the following classes:
• SlAlarmSvc
• SlAlarm
• SlAlarmSource
#include "sloperatecppapi.h"
Class SlAlarmSvc
The SlAlarmSvc class provides functions to monitor alarms. Further, via this class,
the existing alarm sources can be read out.
Class SlAlarm
This class represents an individual alarm. The class contains only functions that
reflect the various attributes of an alarm.
Class SlAlarmSource
The SlAlarmSource class represents an alarm source. The class only comprises
functions that are required to define an alarm source.
These and all other examples are shown in the following overview of examples.
Only the items relevant for the AlarmService are explained or described in each
example. The comments for the sources contain more detailed information (e.g.
screen layout, outputs, etc.).
5.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
In this example, a notification is activated about the change to the alarm list after
"Subscribe" is clicked. All currently pending alarms are displayed in the list box. If
the alarm list changes, then it is output again with current data.
Step 1
Create the required member variables (an object of type SlAlarmSvc and a
variable of type IslAlarmSvcCb, that is, a pointer that points to the callback
method):
// Object alarm
SlAlarmSvc m_Alarm;
Step 2
Create a subscription. Here, the pointer of the implemented callback method in
which the change to the alarm list is to be communicated is passed.
Step 3
Implement the callback method. Here, the alarms that are currently pending are
now displayed.
// window to inform
HWND msgWindow;
Step 4
Unsubscribe the subscription.
Overview
In this example, an alarm is triggered with "set alarm". The alarm is displayed in the
list box. It is reset with "reset alarm".
! Important
Configuration and language files (error message texts) must first be copied from
the example project to the OEM configuration (cfg) or language file directory (lng).
• slCppApiEventSource_alarmtext_deu.ts
• slCppApiEventSource_alarmtext_eng.ts
• slaesvcadapconf.xml
• slaesvcconf.xml
• slCppApiEventSource_db.xml
Step 1
Create the necessary variables (an object of type SlAlarmSvc):
// Object alarm
SlAlarmSvc m_Alarm;
Step 2
Trigger (or reset) an alarm.
// Set alarm
SlAlarmSvcError err = m_Alarm.SetAlarm (alarmNo);
...
// … or reset alarm
SlAlarmSvcError err = m_Alarm.ResetAlarm (alarmNo);
Overview
The SlAlarmSvc object can be used to access alarms that are currently active. This
is achieved using a subscription. The notification that the current alarm list has
changed is effected by calling the implemented callback method.
Subscription
The client-side access to alarms (e.g. for an alarm display) is implemented using
subscriptions and the alarm service manages a dedicated subscription for each
client. If the state of an alarm changes, the client is notified via the subscription
assigned to it by calling the implemented callback method.
Note
No provision is made for sharing of one subscription by multiple clients.
subscribeAlarms
Creates a notification about a change in the current alarm list. The call returns as
soon as the setup request has been forwarded to the server. Notification is
Return -
unsubscribeAlarms
Unsubscribes a running subscription.
subscribeEventList
Creates a notification about a change to the content of the alarm-event ring buffer;
this notification contains the state changes (coming, going, acknowledgment) of the
alarms. The call returns as soon as the setup request has been forwarded to the
server. Notification is performed by implementing the callback method
SlAlarmEventlistChanged().The first notification returns the content of the
event ring buffer at the time of creation. Subsequently, the complete content of the
ring buffer is returned when new events occur. Because the size of the list cannot
be infinite, the oldest elements are deleted when new events are generated (FIFO
principle).
unSubscribeEventList
Unsubscribes a running subscription.
subscribeEvents
Creates a notification for new alarm events, i.e. state changes (coming, going,
acknowledgment) of the alarms. The call returns as soon as the setup request has
been forwarded to the server. Notification is performed by implementing the
callback method SlAlarmNewEvent().The first notification returns the content of
the event ring buffer at the time of creation. Subsequently, newly occurred alarm
events are returned individually.
Parameter Meaning
SlAlarmNewEvent Pointer to the callback method
implementation for reporting the state
change. That is, this pointer points to the
ISlAlarmSvcEventsCb class where the
callback method SlAlarmNewEvent() to be
implemented is located.
Return SlAlarmSvcError
unSubscribeEvents
Unsubscribes a running subscription.
Table 5-12:unSubscribeEvents
Public SlAlarmSvcError unSubscribeEvents(
ISlAlarmSvcEventsCb* SlAlarmNewEvent)
Parameter Meaning
SlAlarmNewEvent Pointer to the callback method
implementation for reporting the state
change. That is, this pointer points to the
ISlAlarmSvcEventsCb class where the
callback method SlAlarmNewEvent() to be
implemented is located.
Return SlAlarmSvcError
getSources
Provides an array of AlarmSource objects.
(see Chapter 5.5 "Reference SlAlarmSource")
setAlarm
Sets an alarm.
resetAlarm
Resets an alarm.
Overview
An instance of the alarm class represents a pending alarm. The alarm class
contains only functions that provide access to all available attributes.
5.4.8 Functions
getId / setId
Gets or sets an alarm ID (alarm number) that identifies an alarm in the context of a
particular source (alarm source), i.e. the source and alarm ID determine the
appropriate alarm text.
! Important
It is possible to reuse the same alarm ID within different alarm sources (source
IDs) and to provide it with different alarm texts. That is, the alarm IDs no longer
have to be unique across all alarm sources. This means that (unique) assignment
between an alarm and alarm text is only possible with the tuple alarm ID plus
source ID.
A separate number range is reserved for each of the alarm sources. The following
table lists the number ranges:
getSource / setSource
Gets or sets an alarm source (Source) of the alarm.
getMessage / setMessage
Gets or sets an alarm text in the specified language.
getWCharMessage / setWCharMessage
Gets or sets an alarm text in the specified language. The alarm text is of type
wchar_t.
To use the function, the following project setting must be checked and corrected if
necessary.
getInstance / setInstance
Gets or sets the alarm instance ID. Several alarms can occur at the same time
within one alarm source. The alarm instance ID is used to differentiate between
these alarm instances.
getParameters / setParameters
Gets or sets the dynamic parameters (associated values, process values) of an
alarm.
getTimeStamp
Gets the timestamp.
getComment / setComment
Gets or sets a comment on the alarm.
getHelpFileUrl / setHelpFileUrl
Gets or sets the URL address of an HTML file locally or on a server in the network.
getCancelGroup / setCancelGroup
Alarms with the same CancelGroup for a collective cancellation group. When one
alarm is canceled, all alarms of the same group are automatically also canceled.
Possible values:
SlAlarmCancelGroup.NONE
Value not assigned.
SlAlarmCancelGroup.HMI
Cancels all HMI alarms.
SlAlarmCancelGroup.HMI_AND_NCU
Cancels all NCU and HMI alarms.
getCategory / setCategory
Gets or sets the category of the alarm.
Possible values:
SlAlarmCategory.NONE
Value not assigned.
SlAlarmCategory.SINUMERIK
Alarm is a general SINUMERIK alarm.
SlAlarmCategory.PARTPROG_MESSAGE
Alarm is a part program message (MSG() call in the part program).
getClearInfo / setClearInfo
The ClearInfo (clear criterion) identifies a group of alarms. The value provides
information about the action (e.g. "NC Reset") that can cancel an alarm (and
therefore all of the alarms of this group). Unlike SlAlarmCancelGroup, the clear
operation for these alarms is not performed by the alarm service. It is performed
directly in the alarm source (e.g. NC kernel). This means that the NC kernel sends
a going event as an alarm source for every alarm.
The following table contains all predefined values for SlAlarmClearInfo. At present,
the SlAlarmClearInfo structure has not yet been assigned and the numerical values
are saved.
getPriority
Gets the priority of an alarm. The priority is assigned when configuring the alarm
attributes.
getDisplayLocation / setDisplayLocation
Gets or sets the display location at which an alarm is displayed. This is, for
example, the alarm line in the header or a message window at the center of the
screen.
Possible values:
SlAlarmDisplayLocation.NONE
Value not assigned.
SlAlarmDisplayLocation.HEADER
Alarm is displayed in the alarm line.
SlAlarmDisplayLocation.SCREEN
Alarm is displayed as a "message box" in the center of the screen.
getQuality / setQuality
Gets or sets the quality that provides information about the reliability of an alarm.
Possible values:
SlAlarmQuality.QUALITY_BAD
The quality of the alarm received is poor, i.e. the data should not be used.
SlAlarmQuality.QUALITY_GOOD
The quality of the alarm received is good, i.e. the data can be used.
SlAlarmQuality.QUALITY_UNCERTAIN
AlarmSvc cannot ascertain whether the data received is good or poor.
getState / setState
Gets or sets the alarm state.
Possible values:
SlAlarmState.UNKNOWN
Unknown state.
SlAlarmState.ALARM_STATE_ACTIVE
Alarm is active.
SlAlarmState.ALARM_STATE_ACKED
Alarm is acknowledged.
SlAlarmState.ALARM_STATE_ENABLED
Alarm is enabled.
SlAlarmState.ALARM_CHANGE_ACTIVE
The active flag has changed.
SlAlarmState.ALARM_CHANGE_ACKED
The acknowledged flag has changed.
SlAlarmState.ALARM_CHANGE_ENABLED
The enabled flag has changed.
SlAlarmState.ALARM_ACK_REQUIRED
The alarm requires an acknowledgment.
SlAlarmState.ALARM_HMI_CANCEL_BTN
HMI alarm with automatic cancellation by the cancel key ("BigMac" key) of the HMI.
SlAlarmState.ALARM_HMI_CANCEL_TIME
HMI alarm with automatic cancellation by timeout.
SlAlarmState.ALARM_COMING
Alarm not requiring acknowledgment is coming.
(ALARM_STATE_ENABLED + ALARM_STATE_ACTIVE +
ALARM_CHANGE_ACTIVE)
SlAlarmState.ALARM_CAME_GOING
Alarm not requiring acknowledgment came and is now going.
(ALARM_STATE_ENABLED + ALARM_CHANGE_ACTIVE)
SlAlarmState.ALARM_HMI_CANCEL_BTN_COMING
An HMI alarm not requiring acknowledgment with cancellation using the cancel key
("BigMac" key) is coming.
(ALARM_HMI_CANCEL_BTN + ALARM_COMING)
SlAlarmState.ALARM_HMI_CANCEL_BTN_CAME_GOING
An HMI alarm not requiring acknowledgment with cancellation using the cancel key
("BigMac" key) is going.
(ALARM_HMI_CANCEL_BTN + ALARM_CAME_GOING)
SlAlarmState.ALARM_HMI_CANCEL_TIME_COMING
An HMI alarm not requiring acknowledgment with cancellation by timeout is
coming.
(ALARM_HMI_CANCEL_TIME + ALARM_COMING)
SlAlarmState.ALARM_HMI_CANCEL_TIME_CAME_GOING
An HMI alarm not requiring acknowledgment with cancellation by timeout is going.
(ALARM_HMI_CANCEL_TIME + ALARM_CAME_GOING)
SlAlarmState.ALARM_COMING_TOACK
Alarm requiring acknowledgment is coming and still has to be acknowledged.
(ALARM_ACK_REQUIRED + ALARM_COMING)
SlAlarmState.SLAE_ALARM_CAME_GOING_TOACK
Alarm requiring acknowledgment came and is going but still has to be
acknowledged.
(ALARM_ACK_REQUIRED + ALARM_CAME_GOING)
SlAlarmState.ALARM_CAME_GONE_ACKING
Alarm requiring acknowledgment came, went, and is being acknowledged.
(ALARM_ACK_REQUIRED + ALARM_STATE_ENABLED + ALARM_STATE_ACKED
+ ALARM_CHANGE_ACKED)
SlAlarmState.ALARM_CAME_ACKING
Alarm requiring acknowledgment came and is being acknowledged.
(ALARM_ACK_REQUIRED + ALARM_STATE_ENABLED +
ALARM_STATE_ACTIVE + ALARM_STATE_ACKED + ALARM_CHANGE_ACKED)
SlAlarmState.ALARM_CAME_ACKED_GOING
Alarm requiring acknowledgment came, was acknowledged, and is going.
(ALARM_ACK_REQUIRED + ALARM_STATE_ENABLED + ALARM_STATE_ACKED
+ ALARM_CHANGE_ACTIVE)
Overview
An instance of the SlAlarmSource class represents an alarm source. An alarm
source is defined using an identification number (ID) and a name. The class is
defined in sloperatecppapi.h.
5.5.2 Functions
getId / setId
Gets or sets an alarm ID (alarm number) of the alarm source.
getName / setName
Gets or sets the name of the alarm source.
6.1 Introduction
6.1.1 Class model
Overview
The class model of the file service consists primarily of the following classes:
• SlFileSvc
• SlNode
• SlFileSvcStatus
#include "sloperatecppapi.h"
Class SlFileSvc
File and directory operations can be implemented using SlFileSvc objects. These
are especially:
• Creating files/directories
• Copying files/directories
• Moving files/directories
• Deleting files/directories
• Renaming files/directories
• Listing files/directories
• Setting up a notification for drives
• Unsubscribing a notification for drives
• Block-by-block data transfer
Class SlNode
The SlNode class represents a file or a directory. The corresponding attributes of
the file or the directory can be accessed via the various functions of the class.
These include, for example: Access rights, timestamp of the last access or size.
Class SlAccessRights
The SlAccessRights class is used by the SlNode class for the
getAccessRights()/setAccessRights() functions and contains the data for
the access rights as required for SINUMERIK (access level for reading, writing,
displaying, executing, and deleting).
Class SlSlFileSvcStatus
The SlSlFileSvcStatus object contains information about the status of a request.
This is essentially an error number.
Synchronous calls
Synchronous calls return only after the request has been completed, i.e. the calling
thread is blocked until this is the case. This can interfere with event processing
since control inputs and displays are withheld during a synchronous call. For this
reason, calls that may take a long time should be performed asynchronously.
Asynchronous calls
Asynchronous calls return as soon as the request has been sent to the file service.
The returned error code cannot therefore indicate whether the request has been
completed successfully; it can only indicate whether or not the request has been
sent successfully. For example, an error occurs if call parameters are not correctly
assigned. The actual request status is supplied in the return calls of the file service
(call of the implemented callback method).
Table 6-2: Asynchronous calls
FileSvc call Description
copyAsync Copies directories or files
! Important
Only one asynchronous service can run on an SlFileSvc object at any one time. If
an attempt is made to set up a second asynchronous request, this is prevented
with an error return value.
Access rights
There are eight access levels for files and directories.
S0 denotes the access level with the highest rights and S7 the access level with
the most restrictive rights.
Access rights
The following rights can be assigned:
These and all other examples are shown in the following overview of examples.
Only the items relevant for the FileService are explained or described in each
example. The comments for the sources contain more detailed information (e.g.
screen layout, outputs, etc.).
6.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
The following step-by-step example shows how to read out the content of a
directory synchronously.
In the example, you can specify a path whose contents you can display by clicking
the "list folder" button. The status bar indicates whether the call has been
successful.
Step 1
Create a type SlFileSvc variable:
SlFileSvc fs;
For synchronous calls, it is not absolutely necessary to create the SlFileSvc object
as a member variable. It can also be created locally in the specific function.
Step 2
Create an SlNode object that represents the directory to be read out. The contents
of the text box are transferred as a path.
SlNode SlNode(sFolder);
Step 3
Read out the content. The result is returned as an array of SlNode objects.
SlVector<SlNode> SlNodelist;
Step 4
Process the data that has been read. In the example, the data is written to a
ListBox. The data is read from the array and written to the ListBox using a "for"
loop.
if (err == SL_FILESVC_OK)
{
SlString s;
// get items
for(int i = 0; i < SlNodelist.size(); i++)
{
s.append(nodelist.at(i).getName().c_str());
s.append("\r\n");
}
// display items
}
else
{
// display error
}
Overview
The following step-by-step example shows how to read out the content of a
directory asynchronously.
In the example, you can specify a path whose contents you can display by clicking
the "list folder" button. The status bar indicates whether the call has been
successful.
Step 1
Create the required member variables. On the one hand, a type SlFileSvc variable
is required, and on the other hand, a type ISlFileSvcCb:
SlFileSvc m_fs;
ISlFileSvcCb* m_pFsCb;
Step 2
Create an SlNode object that represents the directory to be read out. The contents
of the text box are transferred as a path.
SlNode SlNode(folder);
Step 3
Initiate asynchronous readout. Here, a pointer (m_pFsCb) is transferred to the
callback object, which is used to call the implemented callback method. The
SlFileSvcListCompleted () function is called if the request has ended. The
SlFileSvcListProgress () function cyclically provides information about
progress. In the following, only the implementation of the
SlFileSvcListCompleted () function is described.
long nRequestId;
SlFileSvcError err = m_fs.listAsync(node, m_pFsCb, nRequestId);
Step 4
Implement the callback method.
Step 5
Implement the display of the file and directory names of the directory to be listed.
void ShowList()
{
// this function shows the list of existing directories and files
}
Overview
The following example shows step-by-step how a file is created, synchronously
copied, and then synchronously deleted again.
In the example, a part program with contents can be created using the "create
source" button. The "copy source" softkey can be used to copy this file to the
specified destination path. The two files can then be deleted again using the
"remove source" or "remove destination" buttons. The status bar indicates whether
the calls have been successful.
Step 1
Create a type SlFileSvc variable:
SlFileSvc fs;
Step 2
Create a file. A SlNode object is created for this purpose. The sSource path
(source path) is taken from the text field. The file is created using the create()
function of the SlFileSvc. In this example, the "overwrite" parameter of the
create() function is set (true) so that the file is overwritten if it already exists.
Step 3
Copy file. Two SlNode objects are required for copying. One represents the file that
should be copied; the other, the destination file. The overwrite parameter of the
copy() function is set (true) so that an existing file is overwritten.
// Assume: get file names of source and destination from input fields
char sSrc[MAX_LOADSTRING];
char sDst[MAX_LOADSTRING];
Step 4
Delete a file. It will only be shown how the destination file is deleted. To start, an
SlNode object of the file to be deleted is created. Then this file is deleted.
Overview
The following step-by-step example shows how to create, asynchronously copy,
and then asynchronously delete a file again.
In the example, a part program with contents can be created using the "create
source" button. This file can be asynchronously copied to the specified destination
path using "copy source". Both files can then be asynchronously deleted again
using the "remove source" or "remove destination" buttons. The status bar
indicates whether the calls have been successful.
Step 1
Create the required member variables. On the one hand, an SlFileSvc type
variable is required, and on the other hand, various ISlFileSvcCb type
variables. ISlFileSvcCb is required to identify asynchronous calls:
SlFileSvc m_fs;
ISlFileSvcCb* m_pFsCb;
Step 2
Create and write a file in the same way as in the synchronous step-by-step
example, as there is no asynchronous function for creating a file or a directory.
Step 3
Copy file. Two SlNode objects are required for copying. One represents the file that
should be copied; the other, the destination file. The overwrite parameter of the
copyAsync() function is set (true) so that an existing file is overwritten. The
SlFileSvcCompleted () function is called if the request has ended. The
SlFileSvcListProgress () function cyclically provides information about
progress. In the following, only the implementation of the SlFileSvcCompleted
() function is described.
// Assume: get file names of source and destination from input fields
char sSrc[MAX_LOADSTRING];
char sDst[MAX_LOADSTRING];
Step 4
Implement the callback method.
Step 5
Delete a file. It will only be shown how the destination file is deleted. To start, an
SlNode object of the file to be deleted is created. Then the file is deleted.
// delete file
SlFileSvcError err = m_fs.removeAsync(nodeSrc, m_pFsCb, nRequestId, false);
Step 6
Implement the callback method. (as in step 4)
Overview
Attributes of a directory or a file are displayed in this example. The path of the
required directory or the file can be entered into a text box. The associated
attributes are read out and displayed by pressing the "get attributes" button.
Step 1
Create an SlNode object that represents the object to be read out (file or directory).
The contents of the text box are transferred as sPath path.
Step 2
"Extract" and output attributes from the SlNode object. All attributes are displayed
in text boxes.
if (node.exists())
{
...
...
}
Overview
In this example, data is written block-by-block to a part program on the NC.
logbook. In a further step, the part program is read block-by-block from the
NC.
Click the "start blocktransfer write" button to start the block transfer to the
destination
specified as "filename". Click the "write new datablock" button to make the contents
of the "content" text box available for transfer. Click the "end blocktransfer write"
button to close the data transfer to the NC.
Click the "read datablock async" button to export the data block-by-block from the
source
defined as "filename" and display it in "content". Click the "cancel running async
service" button to cancel an
active asynchronous request of the FileService.
Step 1
Create the required member variables. On the one hand, a type SlFileSvc variable
is required, and on the other hand, a type ISlFileSvcBlockTransferCb:
SlFileSvc m_fs;
ISlFileSvcBlockTransferCb* m_pFsCb;
...
m_pFsCb = new SlFileSvcCb();
Step 2
Start block-by-block data transfer. The data source is transferred as SlNode. The
created callback object is required for the callbacks.
SlNode nodeFileName(szFileName);
SlFileSvcError err = m_fs.startBlockTransferWriteAsync(nodeFileName,
m_pFsCb, m_nRequestId);
Step 3
Implement the required callback method SlFileSvcProvideBlockTransferData. If this
is called, data can be written.
Step 4
Write data. The data transfer is completed by setting the parameter eof=true.
SlFileSvcError err =
m_fs.writeBlockTransferDataAsync((char*)szContent.c_str(),
szContent.length(), false);
Step 5
Implement the required callback method SlFileSvcBlockTransferCompleted. If this
is called, the data transfer is completed.
Step 6
Start reading block-by-block. The data source is transferred as SlNode. The created
callback object is required for the callbacks.
SlNode nodeFileName(szFileName);
SlFileSvcError err = m_fs.startBlockTransferReadAsync(nodeFileName, m_pFsCb,
m_nRequestId, true);
Step 7
Implement the required callback method SlFileSvcReadBlockTransferData. The
read data is transferred in this method.
Step 8
Implement the required callback method SlFileSvcBlockTransferCompleted. If this
is called, the data transfer is completed.
Step 9
A data transfer can be canceled with the cancelAsync function. For this purpose,
the RequestID returned when starting the data transfer must be specified.
Step 10
Implement the required callback method SlFileSvcBlockTransferCanceled. If this is
called, the data transfer has been canceled successfully.
Overview
A SlNode object represents a file or a directory. The SlNode class contains
attributes that describe the particular directory or the particular file in more detail.
These attributes are provided as functions. This class is defined in
sloperatecppapi.h.
Path structure
The following examples show the structure of the logical paths to be used for the
functions of the SlNode class.
Note
When using a network drive or a USB drive, a corresponding drive must first be
set up from the commissioning/HMI/Log.drive operating area.
Note
Only the logical paths can be used to call the interface FileSvc. Real paths (e.g.
"/_N_MPF_DIR/_N_TEST_MPF") cannot be used.
6.3.3 Functions
getAccessRights / setAccessRights
Gets and sets the access rights as required for the SINUMERIK protection level
concept for reading, writing, deleting, executing, and listing.
exists
Defines whether the file or the directory exists.
IsDirNode
Defines whether the object is a directory or a file.
IsNcNode
Defines whether the object is located in the NC.
getPath / setPath
Gets and sets the logical path of the object.
getName
Gets the name of the file or the directory (without path).
getRealPath
Gets the real (NC) path of the object.
size
Gets the size of the object.
lastAccess
Gets the timestamp of last change.
Overview
File and directory operations can be implemented using SlFileSvc objects. These
are especially:
• Creating files/directories
• Copying files/directories
• Moving files/directories
• Deleting files/directories
• Renaming files/directories
• Setting up a notification which is issued when a new device is connected or
a device is removed
list / listAsync
These functions list the content of a directory. The results are returned as an array
of the SlNode class. A SlNode object describes a file or a directory.
With large directories, the call can take a long time. In such cases, the
asynchronous version (listAsync) should be used to avoid blocking the thread in
which the call is made.
In the asynchronous version, a request ID is received after the call to identify the
call later.
create
Creates a file. The file can be created either in the NCU or on the hard disk of the
PCU. You can decide whether to overwrite the file if it already exists.
createFolder
Creates a directory. The directory can be created either in the NCU or on the PCU.
rename / renameAsync
Renames a file or directory.
In the asynchronous version, a request ID is received after the call to identify the
call later.
copy / copyAsync
Copies a file. You can decide whether to overwrite the file if it already exists.
In the asynchronous version, a request ID is received after the call to identify the
call later.
move / moveAsync
Moves a file. You can decide whether to overwrite the file if it already exists.
In the asynchronous version, a request ID is received after the call to identify the
call later.
In the asynchronous version, a request ID is received after the call to identify the
call later.
select
The function selects a program saved on the NC for the addressed channel for
processing. This is only possible if the file is an executable file (e.g. a part
program).
selectExtern
The function selects an externally saved program (e.g. hard disk) for the addressed
channel for execution. This is only possible if the file is an executable file (e.g. a
part program).
cancel / cancelAsync
Cancels an asynchronous operation.
startBlockTransferReadAsync
This function starts the block-by-block data transfer from a specified NC source.
startBlockTransferWriteAsync
This function starts the block-by-block data transfer to a specified NC destination.
writeBlockTransferDataAsync
This function provides a data block for the transfer to a specified
NC destination.
Subscribe
Setting up a notification if drives are inserted/connected or
removed. The call returns as soon as the setup request
has been forwarded to the server.
SlFileSvcCompleted
Table 6-39: SlFileSvcCompleted – specification for the callback implementation
public void SlFileSvcCompleted(long nID, SlFileSvcStatus& status);
Parameter Meaning
nID Request ID to identify the asynchronous call
status Success status of the call
SlFileSvcProgress
Table 6-40: SlFileSvcProgress – specification for the callback implementation
public void SlFileSvcProgress(long nID, int percentage);
Parameter Meaning
nID Request ID to identify the asynchronous call
percentage Percentage value of how far the request has progressed.
SlFileSvcCanceled
Table 6-41: SlFileSvcCanceled – specification for the callback implementation
Public void SlFileSvcCanceled(long nID);
Parameter Meaning
nID Request ID to identify the asynchronous call
SlFileSvcListCompleted
Table 6-42: SlFileSvcListCompleted – specification for the callback implementation
public void SlFileSvcListCompleted(long nID, SlVector<SlNode>& nodes,
SlFileSvcStatus& status);
Parameter Meaning
nID Request ID to identify the asynchronous call
nodes List of the files and directories
status Success status of the call
SlFileSvcListProgress
Table 6-43: SlFileSvcListProgress – specification for the callback implementation
public void SlFileSvcListProgress(long nID, int percentage);
Parameter Meaning
nID Request ID to identify the asynchronous call
percentage Percentage value of how far the request has progressed.
SlFileSvcListCanceled
Table 6-44: SlFileSvcListCanceled – specification for the callback implementation
public void SlFileSvcListCanceled(long nID);
Parameter Meaning
nID Request ID to identify the asynchronous call
SlFileSvcBlockTransferCompleted
This callback is called if a block-by-block data transfer has been completed.
SlFileSvcBlockTransferCanceled
This callback is called if the requested cancellation of a block-by-block data
transfer has been completed.
SlFileSvcBlockTransferProgress
This callback returns the progress of the request for a block-by-block data transfer
from a specified NC source.
SlFileSvcReadBlockTransferData
This function is called when the data that was requested with the
startBlockTransferReadAsync function has been provided.
SlFileSvcProvideBlockTransferData
This callback is called as request for the provision of data after a block-by-block
data transfer has been initiated with the startBlockTransferWriteAsync function.
SlFileSvcDeviceMounted
This callback is called if a new drive was connected/attached.
SlFileSvcDeviceUnmounted
This callback is called if the previously attached/connected drive was removed.
Examples:
Part program path in NCU2 - //NCU/NCU2/NC/MPF.DIR
Note
NCU names are listed in MMC.INI (see also Fig. 6.6).
Entry:
[GLOBAL]
NcddeMachineNames=NCU1,NCU2
Overview
A SlAccessRights object contains the access authorizations in the sense of the
SINUMERIK protection level concept of a file or a directory.
These authorizations are available for:
• Read
• Write
• Delete
• List
• Execute
The class only contains functions for these 5 access rights and is defined in
sloperatecppapi.h.
6.5.2 Functions
Enumerator SlAccessLevel
All of the functions described in the following supply an enumerator value of type
SlAccessLevel. The possible values are described in the following table:
getRead / setRead
Gets or sets the access level required to read a file or a directory.
getWrite / setWrite
Gets or sets the access level required to write a file or a directory.
getDelete / setDelete
Gets or sets the access level required to delete a file.
getShow / setShow
Gets or sets the access level required to list a file.
getExecute / setExecute
Gets or sets the access level required to execute a file (execute refers to executing
a part program in the NC).
Overview
A SlFileSvcStatus object contains the result of a completed asynchronous request.
The object contains an error number:
• SL_FILESVC_OK: No error
Example:
// delete file
SlFileSvcError err = m_fs.removeAsync(.. .);
7 Infrastructure services
7
Objective of the chapter
This chapter describes the interface of the InfrastructureService. This can be used
in order to access global data - such as the current resolution, current language,
current channel or current access level. It is also possible to obtain a notification if
one of these values has changed.
7.1 Introduction
7.1.1 Class model
Overview
The class model of the InfrastructureService consists primarily of the
SlInfraStructSvc class.
class SlInfraStructSvc
This class is defined in sloperatecppapi.h:
#include "sloperatecppapi.h"
You can also switch the current NCU to change to a different operating area and
shutdown Operate.
1. The values are read cyclically by the NCK. Value changes continue to be
signaled if the read value differs from the previously signaled value. Value
changes are not detected by this mechanism if a value changes and then
changes back to the starting value between two consecutive sampling
points.
These and all other examples are shown in the following overview of examples.
Only the items relevant for the InfrastructureService are explained or described in
each example. The comments for the sources contain more detailed information
(e.g. screen layout, outputs, etc.).
7.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
7.2.2 Current language - read, switchover, notify for change
Overview
The "SlInfrastructureSvc" example contains almost all functions of the
InfrastructureService. However, only the part of the current language is shown
step-by-step.
The "start subscription" button sets up an automatic notification for changes to the
current language. Click "stop subscription" to end this mechanism. The current
language is explicitly read-out using the "get actual values" button. "set language
deu" and "set language eng" toggle the current display language to German or to
English.
Step 1
Create the member variable of type SlInfraStructSvc.
SlInfraStructSvc m_InfraStructureSvc;
Step 3
Set the current language. In this case, the display language changes to German.
Step 4
The subscribeLanguage function creates the notification when the current language
is changed. A pointer of type ISlInfraStructSvcCb* that points to the required
callback function is transferred.
ISlInfraStructSvcCb* m_pCb;
// subscribe language
SlInfraStructSvcError err = m_InfraStructureSvc.subscribeLanguage(m_pCb);
if ( SL_INFRASTRUCTSVC_OK == err )
{
// successful
}
else
{
// error
}
Step 5
Implement the callback function. The SlInfraStructSvcLanguageChanged function is
already defined as virtual void. The
user must implement the desired function to evaluate the language
value.
SlString m_sLanguage;
Step 6
Unsubscribe the notification regarding the change to the current language.
// unSubscribe language
SlInfraStructSvcError err = m_InfraStructureSvc.unSubscribeLanguage(m_pCb);
if ( SL_INFRASTRUCTSVC_OK == err )
{
// successful
}
else
{
// error
}
Overview
SlInfraStructSvc objects can be used to monitor the following data:
• Current resolution
• Current channel number
• Current language
• Current access level
You can also switch the current NCU to change to a different operating area and
shutdown Operate.
S0 denotes the access level with the highest rights and S7 the access level with
the most restrictive rights. The keyswitch position is enabled by the current
keyswitch position or by entry of a password.
8 Archive service
8
Objective of the chapter
This chapter describes the interface of the archive service. The archive service
allows different archive types to be generated and read-in. The following types are
supported:
Note
The archive service can only be used for SINUMERIK 840. This interface cannot
be used for SINUMERIK One and SINUMERIK 828D.
8.1 Introduction
8.1.1 Class model
Overview
The class model of the DrivesService consists primarily of the following classes
and enums:
• SlArchivingSvc
• SlArchivingSvcStatus
• SlArchiveType_Enum
• SlSetupArchivingComponent_Enum
• SlArchivingSvcRequest_Enum
• ISlArchivingSvcCb
#include "sloperatecppapi.h"
Class SlArchiveSvc
SlArchiveSvc objects are used to:
• Create and fetch archives
struct SlArchivingSvcStatus
struct SlArchivingSvcStatus
{
SlString ArchiveItem;
SlVector<StatusError> Errors;
bool OK;
long Percentage;
SlArchivingSvcRequest_Enum Request;
};
SlArchiveType_Enum
Enum values identifying the archive types:
enum SlArchiveType_Enum
{
AT_UNDEFINED = 0,
AT_SETUP = 1,
AT_PLCUPGRADE = 2,
AT_PAPERTAPE = 3,
AT_USER = 4,
AT_OTHER = 5
};
SlSetupArchivingComponent_Enum
enum SlSetupArchivingComponent_Enum
{
AC_NOTSPECIFIED = 0,
AC_NCU = 1,
AC_NCUANDCOMPENSATIONDATA = 2,
AC_PLC = 3,
AC_COMPILECYCLES = 4,
AC_DRIVESBINARY = 5,
AC_DRIVESASCII = 6,
AC_HMI = 7
};
SlArchivingSvcRequest_Enum
enum SlArchivingSvcRequest_Enum
{
A_RQ_NOREQUEST = 0,
A_RQ_LISTCOMPLETED = 1,
A_RQ_PROGRESS = 2,
A_RQ_CANCELED = 3,
A_RQ_INFO = 4,
A_RQ_ERROR = 5,
A_RQ_CONFIRMOVERWRITE = 6,
A_RQ_CONFIRMREADARCHIVE = 7,
A_RQ_CONFIRM = 8,
A_RQ_CONFIRMNCUVERSION = 9,
A_RQ_NEWFILENAME = 10
};
ISlArchivingSvcCb
SlArchiveSvcError
Long value for error feedback signals.
Only the points relevant to ArchiveService are described. The comments for the
sources contain more detailed information.
8.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
The following example shows the individual steps required to create archives.
In the example, the "create setup archive" button creates a setup archive with the
above settings.
The "create user archive" button creates a user archive with the
above read out part programs.
"archive path" and "archive name" are used to specify the storage path and the
name of the archive file, respectively.
These specifications apply to each of the two buttons. The currently edited item is
displayed in the lower box and the current progress is displayed as percentage in
the status line.
Step 1
Create the required variables of type SlArchivingSvc, ISlArchivingSvcCb and
SlSetupArchivingComponent_Enum.
Step 2
Group components.
Step 3
Generate setup archive.
m_ArchiveSvc.createSetupArchiveAsync(filepath,types,addFiles,
SlString("Creator"),SlString("Comment"),m_pCb,true);
Step 4
Implement the callback method.
void SlArchivingSvcCb::ArchivingSvcActionCompleted(SlArchivingSvcStatus
status)
{
SlArchivingSvcStatus mystatus = status;
Overview
The following example shows the individual steps required to read-in archives and
read-out supplementary information for the archives.
Clicking the "read info" button displays the supplementary information for the
marked archive in the left-hand text box.
Clicking the "read-in archive file" button imports the marked archive; the status and
the current imported percentage value are displayed in the right-hand text box and
in the status line, respectively.
Step 1
Create the required variables of type SlArchivingSvc and ISlArchivingSvcCb.
Step 2
Read-in archives.
Transfer the path and the callback.
Step 3
Implement the callback method.
void SlArchivingSvcCb::ArchivingSvcActionCompleted(SlArchivingSvcStatus
status)
{
SlArchivingSvcStatus mystatus = status;
Step 4
Read-out the archive information.
SlString value;
SlArchiveType_Enum archivetype;
time_t timestamp;
SlArchivingSvcError err;
Overview
SlArchivingSvc objects can be used to create and read-in existing archives.
8.3.3 Functions
createSetupArchiveAsync
Creates a series commissioning archive.
createPlcUpgradeArchiveAsync
Creates a PLC upgrade archive.
createUserArchiveAsync
Creates a user archive.
createPaperTapeArchiveAsync
Creates a paper-tape archive.
readArchiveAsync
Reads-in an archive.
cancelAsync
Cancels a running asynchronous request.
getType
Reads-out the archive type.
Parameter Meaning
Archives Absolute file name of the archive
Type Returned archive type.
SlArchiveType_Enum
Return Error number
getEntries
Reads-out the entries of an archive.
If the reading of the entries takes longer than 60 seconds, it will be canceled with
the following error number:
SL_ARCHIVING_GET_ENTRIES_TIMEOUT = 160000
Parameter Meaning
Archives Absolute file name of the archive
entries Returned entries of the archive.
Return Error number
getComment
Reads-out the comment of an archive.
Parameter Meaning
Archives Absolute file name of the archive
Comment The returned comment
Return Error number
getCreator
Reads-out the creator of an archive.
Parameter Meaning
Archives Absolute file name of the archive
creator The returned comment
Return Error number
getTimeStampInternal
Reads-out the time of creating an archive.
Parameter Meaning
Archives Absolute file name of the archive
timestamp The returned time when the archive was created
Return Error number
getNcuSystemSoftwareVersion
Reads-out the NCU version of an archive.
Parameter Meaning
Archives Absolute file name of the archive
creator The returned comment
Return Error number
Note
Do not read drive parameters faster than in a 1 second cycle, slower is better.
Otherwise, an excessively high communication load is created - that can result in
blocking communication between the HMI and realtime system, and can therefore
block the HMI itself.
9.1 Introduction
9.1.1 Class model
Overview
The class model of the DrivesService consists primarily of the following classes
and enums:
• SlDrivesSvc
• SlDrive
• SlDriveType
#include "sloperatecppapi.h"
Class SlDrivesSvc
SlDrivesSvc objects are used to:
• Query the list of all drive objects.
Class SlDrive
The Drive class is a separate Drive object which represents one of the following
SINAMICS components:
• Control Unit
• Com Module
• Drive
• Line Module
• I/O
The class contains attributes which describe the corresponding object in more
detail, along with functions for reading, writing, and saving drive parameters.
SlDriveType
Enum values identifying the types of drive:
enum SlDriveType
{
NotSpecified = 0,
ControlUnit = 2,
ComModule,
Drive,
LineModule,
I/O
};
SlDrivesSvcError
Long value for error feedback signals: SL_DRIVESSVC_OK == no errors
Only the points relevant to DrivesService are described. The comments for the
sources contain more detailed information.
9.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
The following example provides a step-by-step guide to listing the drive objects of a
control.
In the example, the listing of the drive objects is initialized with the "list drives"
button. The status bar indicates whether the call has been successful.
Step 1
Create the required variables: one (array) type SlDrive and a type
SlDrivesSvc.
Step 2
List the data.
// list
SlDrivesSvcError err = drvSvc.listDrives(drives);
Overview
The next example provides a step-by-step guide to reading-out drive parameters.
Sequence of operations:
Enter "Drives No" and "Param No" and confirm with the "read param" button.
Step 1
Create the required variables: one (array) type SlDrive and a type
SlDrivesSvc.
Step 2
Start by listing the drive objects. Once the list has been generated, read-out the
required parameter. Assuming: Parameter 35 (motor temperature) of drive 2 is to
be read-out:
// list
SlDrivesSvcError err = drvSvc.listDrives(drives);
// if OK
if (err == SL_DRIVESSVC_OK)
{
// get drive number and parameter number
int nDrivesNo = 2;
int nParamNo = 35;
Overview
SlDrivesSvc objects are used to list available SlDrive objects.
9.3.2 Creating an SlDrivesSvc object
9.3.3 Functions
listDrives
Returns an array with the SlDrive objects found in the NCU. The driveType
parameter is used to define the corresponding drive type for the array.
Overview
A SlDrive object represents one of the following SINAMICS components:
• Control Unit
• Com Module
• Drive
• Line Module
• I/O
The SIDrive class contains attributes which describe the corresponding object in
more detail. Attributes and actions (e.g. reading/writing parameters, etc.) can be
defined and performed by functions.
9.4.3 Functions
readParameter
Reads an individual drive parameter (parameter specified as integer).
writeParameter
Writes an individual drive parameter (parameter specified as integer).
getDriveType
Reads the drive type.
getDriveObjectId
Reads the SlDrive object ID.
getDriveObjectName
Reads the SlDrive object name.
getAxisNumber
Reads the axis number.
getAxisName
Reads the axis name.
getBusAddress
Reads the drive bus address.
getSlaveAddress
Reads the slave address.
10 TraceDataRecorder service
10
Objective of the chapter
This chapter describes the interface of the trace recorder. The Trace recorder is
used if control data needs to be recorded at high frequency. It is based on the
"sITrace" component included in SINUMERIK Operate.
10.1 Introduction
10.1.1 Class model
Overview
The class model of the recorder consists of the following classes, structures and
enums:
• class SlTraceDataRecorder
• struct SlTraceDataRecorderErrorInterval
• struct SlTraceDataRecorderDataset
• struct SlTraceDataRecorderBinData
• struct SlTraceDataRecorderErr
• enum SlTraceDataRecorderState
• enum SlTraceDataOptions
• class ISlTraceDataRecorderCb
• class ISlTraceDataRecorderDataCb
#include "sloperatecppapi.h"
Scenario 1 can be used for recording smaller data volumes. Scenario 2 is suitable
for long recording sessions.
Class SlTraceDataRecorder
Objects that permit high-frequency recording of the time characteristics of NC
variables and PLC variables can be created with class TraceDataRecorder.
struct SlTraceDataRecorderErrorInterval
struct SlTraceDataRecorderErrorInterval
{
long ErrorNo;
double TimeOffset;
};
struct SlTraceDataRecorderDataset
struct SlTraceDataRecorderDataset
{
double TimeOffset;
SlVector<int> Ids;
SlVector<SlValue> Values;
};
struct SlTraceDataRecorderBinData
struct SlTraceDataRecorderBinData
{
SlVector<SlTraceDataRecorderDataset> Data;
SlVector<SlTraceDataRecorderErrorInterval> Error;
};
struct SlTraceDataRecorderErr
struct SlTraceDataRecorderErr
{
int ErrorNo;
SlString Message;
};
enum SlTraceDataRecorderState
enum SlTraceDataRecorderState
{
Stopped = 0,
WaitingForTrigger = 1,
Recording = 2
};
enum SlTraceDataOptions
enum SlTraceDataOptions
{
None = 0,
IncludeHeader = 1,
IncludeSignalDefinition = 2,
IncludeHeaderAndSignalDefinition = 3
};
class ISlTraceDataRecorderCb
Callback interface class.
class ISlTraceDataRecorderCb
{
public:
virtual void
TraceDataRecorderStateChanged(SlTraceDataRecorderState state) = 0;
virtual void
TraceDataRecorderDataCollectionAborted(SlTraceDataRecorderErr error) = 0;
class ISlTraceDataRecorderDataCb
Callback interface class.
class ISlTraceDataRecorderDataCb
{
public:
virtual void TraceDataRecorderNewBinaryData(SlTraceDataRecorderBinData
DataBin) = 0;
Only the points relevant for the TraceService are described. The comments for the
sources contain more detailed information.
10.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
The remaining entries must be deleted. After this, the file should look like this:
! Important
In order to be able to receive data while recording, parameter "deferOffload" =
false must be set in the XML configuration.
Such an XML setup (TenSeconds_Def.xml) is included with the examples. With it,
the positions of the tool holders with axis indices 1, 2, and 3 are recorded in the
IPO cycle clock in channel 1 for ten seconds.
Note
The following points should be observed:
10.2.2 Example 1
Overview
The following example shows step-by-step how to trace and buffer control data
with the trace recorder and subsequently read out data after completing trace
operation.
In the example, you choose whether the data is to be traced as XML or binary
format via the two radio buttons. If you choose the option binary, the data will be
processed as a CSV file, for example. In two text fields, you define the setup XML
that contains the definitions for the trace operation and the destination directory for
the file containing the traced data. Using the six buttons on the left-hand side of the
form, you can execute the individual steps of the trace procedure.
The status bar at the lower edge informs you about the success of the calls.
Fig. 10-5: Data recording with the trace recorder according to scenario 1
Step 1
Create the required variables of type SlTraceDataRecorder and
ISlTraceDataRecorderCb.
Step 2
"Start session"
Create object, specify the data to be recorded in XML format and set up the status
callback.
m_pTraceDataRecorder->setReportsXml(bReportsXML);
Step 3
Read-in the setup.
// capture setup
retVal = m_pTraceDataRecorder->setup(xmlSetup);
Step 4
Start the trace.
// start trace
retVal = m_pTraceDataRecorder->start();
Step 5
Stop the trace.
// start trace
retVal = m_pTraceDataRecorder->stop();
Step 6
Start the trace.
// start trace
retVal = m_pTraceDataRecorder->start();
Step 7
Implement the status callback.
Step 8
Implement the abort callback.
Step 9
Implement the complete callback.
Step 10
Read-out the buffered data.
if ( 0 != m_pTraceDataRecorder )
{
// get binary data
SlTraceDataRecorderBinData binTracedData;
retVal = m_pTraceDataRecorder->getDataBin(binTracedData);
rsBinTracedData = convertBINtoString(binTracedData);
}
10.2.3 Example 2
Overview
The following example shows how to continuously record control data with the
trace recorder. Example 2 is structured in the same way as the previous example
1. Therefore, only the additional steps that deal with continuous recording are
described below.
In the example, you choose whether the data is to be traced as XML or binary
format via the two radio buttons. If you choose the option binary, the data will be
processed as a CSV file, for example. In two text fields, you define the setup XML
that contains the definitions for the trace operation and the destination directory for
the file containing the traced data. Using the five buttons on the left-hand side of
the form, you can execute the individual steps of the trace procedure.
The status bar at the lower edge informs you about the success of the calls.
Fig. 10-7: Data recording with the trace recorder according to scenario 2
Step 1
"Start session"
Create object, specify the data to be recorded in XML format and set up the status
and data callback.
Step 2
Implement the callback method for binary data.
// timeOffset
streamRetVal << dataSet.TimeOffset;
// IDs
for (int iCountIds = 0; iCountIds < dataSet.Ids.size();
iCountIds++)
{
streamRetVal << ";";
streamRetVal << dataSet.Ids.at(iCountIds);
}
// values
for (int iCountValues = 0; iCountValues < dataSet.Values.size();
iCountValues++)
{
streamRetVal<<";";
streamRetVal <<
dataSet.Values.at(iCountValues).toString().c_str();
}
// CRLF
streamRetVal << "\r\n";
}
Step 3
Implement the callback method for XML data.
Overview
SlTraceDataRecorder objects are used to record control data at high frequency via
the trace server.
10.3.3 Functions
Reset()
Reset the SlTraceDataRecorder.
Setup()
Setup the SlTraceDataRecoder for the data to be recorded.
Start()
Start the recording.
Stop()
Stop the recording.
Subscribe()
Setup the callback.
unSubcribe()
Unsubscribe the callback.
getDataBin()
Read-out the recorded data in binary format.
getDataXML()
Read-out the recorded data in XML format.
getReportsXML()
Determine the format in which the data is recorded.
setReportsXML()
Set the format in which the data is recorded.
getState()
Determine the current state of the SlTraceDataRecoder.
getXMLSetup()
Read-out the currently used XML data.
getTraceDataOptions()
Determine the current option settings.
setTraceDataOptions()
Set the option settings.
getLastRecordingHeaderXml()
Return the frame header, if present.
getLastRecordingSignalsXml()
Return the signal definitions, if present.
11 ToolManagement service
11
Objective of the chapter
This chapter describes the interface of the ToolManagement service. It enables
changes to be tracked with regard to tools.
11.1 Introduction
11.1.1 Class model
Overview
The class model of the ToolManagement service consists of the following classes,
structures and enums:
• class SlToolMngmntSvc
• struct SlToolInfo
• enum SlToolAction
• class ISlNewToolInfoCb
#include "sloperatecppapi.h"
class SlToolMngmntSvc
It is possible to subscribe to changes with regard to tools using SlToolMngmntSvc
objects:
• Creating/deleting tools
• Value or status changes on tools
• Loading/unloading/relocating tools
struct SlToolInfo
Structure of the checkback data:
struct SlToolInfo
{
SlToolAction action;
SlString toolIdent;
long duploNo;
long tNo;
};
enum SlToolAction
Enum values identifying the current action:
typedef enum
{
NO_ACTION = 0,
TOOL_CREATED,
TOOL_DELETED,
TOOL_DATA_CHANGED,
TOOL_MOVED
} SlToolAction;
class ISlNewToolInfoCb
Callback interface class. The following function must be overwritten:
class ISlNewToolInfoCb
{
public:
virtual void onNewToolInfo(SlVector<SlToolInfo> toolInfos) = 0;
};
SlToolMngmntSvcError
Long value for error feedback signals.
Only the points relevant for the ToolManagement service are described. The
comments for the sources contain more detailed information.
11.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
Overview
The following example shows step-by-step how changes with regard to tools can
be tracked with the ToolManagement service.
In the example, the notifications are activated after "Subscribe" has been pressed.
All changes with regard to tools are displayed in a list and updated accordingly.
Pressing "Unsubscribe" ends the subscription.
The status bar at the lower edge informs you about the success of the calls.
Step 1
Definition of a class which is derived from ISlNewToolInfoCb and serves as
callback.
Step 2
Create the following private member variables. The first one involves an object of
the actual interface class SlToolMngmntSvc. The latter, a pointer to the callback
class defined in step 1.
SlToolMngmntSvc m_ToolMngmnt;
ToolMngmntCb* m_pToolMngmntCb;
Step 3
The object of class SlToolMngmntSvc requires the TO area to be monitored as
parameter.
SinumerikToolAccessProvider::SinumerikToolAccessProvider(void)
: m_ToolMngmnt(1)
{
...
Step 4
Create an object of the callback class.
Step 5
Call the subscribe function to receive changes with regard to tools.
Step 6
All changes in TO area 1 are now signaled in the callback class in the overwritten
onNewToolInfo function.
Step 7
If the functionality is no longer required, unSubscribe is called.
Step 8
At the end, the allocated resources are released again.
delete m_pToolMngmntCb;
m_pToolMngmntCb = 0;
Overview
It is possible to subscribe to changes with regard to tools using SlToolMngmntSvc
objects:
• Creating/deleting tools
• Value or status changes on tools
• Loading/unloading/relocating tools
11.3.3 Functions
subscribe()
Subscribe to the tool events.
unSubscribe()
Unsubscribing the tool events.
11.3.4 Notification
onNewToolInfo
Notifications about changes with regard to tools are signaled in the callback object
(data type ISlNewToolInfoCb)
12.1 Introduction
12.1.1 Class model
Overview
Using the action log it is possible to log various operator sequences
in order to subsequently be able to track them. In so doing, various
events can be monitored:
The class model of the action log service consists of the following classes,
structures and enums:
• class SlTripRecorder
• enum SlTripEvent
• class ISlTripRecorderCb
• class ISlTripRecorderStateCb
#include "sloperatecppapi.h"
Class SlTripRecorder
Using TripRecorder objects, you can read-out the current action log. It is also
possible to add your own entries to the log.
enum SlTripEvent
The events that can be logged.
enum SlTripEvent
{
NoEvent = 0,
HmiStartup,
HmiShutdown,
PlcCrash,
KeyPressed,
KeyReleased,
AlarmComing,
AlarmAcknowledge,
AlarmGoing,
OpenWindowArea,
NcuChannelStatus,
NcuToolChange,
NcuToolChangeName,
NcuOverride,
WriteVariable,
NcuConnectionState,
NcuOperationMode,
PiCmd,
FileUpDownload
};
class ISlTripRecorderCb
Callback interface class for progress and completion.
class ISlTripRecorderCb
{
public:
virtual void TripLogProgress(int progress) = 0;
virtual void TripLogCompleted() = 0;
virtual void CrashLogProgress(int progress) = 0;
virtual void CrashLogCompleted() = 0;
};
class ISlTripRecorderStateCb
Callback interface class for status changes.
class ISlTripRecorderStateCb
{
public:
virtual void TripRecorderStatusChanged(bool isRecording) = 0;
};
Synchronous calls
Synchronous calls return only after the request is performed, i.e. the calling thread
is blocked in the meantime. This can interfere with event processing since control
inputs and displays are withheld during a synchronous call. For this reason, calls
that may take a long time should be performed asynchronously.
Asynchronous calls
Asynchronous calls return as soon as the request has been transferred to the
archive service. The returned error code cannot therefore indicate whether the
request has been completed successfully; it can only indicate whether or not the
request has been sent successfully. For example, an error occurs if call parameters
are not correctly assigned. The actual request status is returned in the callback of
the action log service (callback functions).
Log types
Table 12-1: Log types
Log type Description
Current log This log contains the current entries. It is implemented as ring
buffer; this means that old entries are
automatically overwritten.
Crash log For critical events, the action log saves the contents of the
current log in the so-called crash log. The entries backed up can
therefore no longer be overwritten by new entries. The crash log
can only be overwritten if an additional critical event occurs.
.
Only the points relevant for the action log service are explained or described in
each example. The comments for the sources contain more detailed information
(e.g. screen layout, outputs, etc.).
12.2.1 Preparation
Overview
Preparatory measures are described in Chapter 2.1 "New Project". All of the
items described there must be executed first.
The action log can be started and stopped in the example. You can add your own
entries to the action log using the "Make TripEntry" button. The current log is
displayed with "GetTripLog". The status bar displays the status of the action log.
Step 1
Create the required member variables.
SlTripRecorder* m_pTripRecorder;
Step 2
Create the TripRecorder object in the constructor. The user name under which own
entries are entered subsequently is specified as parameter.
Step 3
The notification for status changes is set up with the subscribe function. A pointer
of the type
ISlTripRecorderStateCb which points to the required callback function, is
transferred here.
// pointer to callback interface
ISlTripRecorderStateCb* m_pCbStatus;
// subscribe state
SlTripRecorderError retVal = m_pTripRecorder->subscribe(m_pCbStatus);
if (SL_TRIPRECORDER_OK == err)
{
// successful
}
else
{
// error
}
Step 4
Implement the callback function. Function
TripRecorderStatusChanged is already defined as virtual void. The
user must implement the desired function to evaluate the isRecording
value.
Step 5
Start the action log. The events to be logged are transferred in the form of an
SlVector. If an empty object is transferred, only your own entries are logged.
SlVector<SlTripEvent> tripIDs;
tripIDs.push_back(trip1);
tripIDs.push_back(trip2);
Step 6
Add your own entry to the action log. The user name used when creating the
TripRecorder object is taken as user name.
Step 7
Stop the action log.
Step 8
Write the current action log to a file.
SlTripRecorderError ret = m_pTripRecorder->getTripLog("C:\\tmp\\log.txt");
Note
The synchronous function "getTripLog" can take a very long time to return
depending on the size of the current action log file and therefore block the
complete SINUMERIK Operate. An alternative to this is the
asynchronous version "getTripLogAsync".
Step 9
If the notification for the status change of the action log is no longer required,
unSubscribe is called.
The action log can be started and stopped in the example. You can add your own
entries to the action log using the "Make TripEntry" button. The current log is
displayed with "GetTripLogAsync". The status bar displays the status of the action
log.
Note
With the exception of Step 8, the procedure is identical to that of example
"SlTripSvcSync", and is therefore not explained again.
Steps 1 to 7
See example "Synchronously reading out the action log" (SlTripSvcAsync)
Step 8a
Request the current action log. A pointer of the type
ISlTripRecorderCb that points to the required callback function is transferred and
informs about the completion of the request.
Step 8b
Implement the callback function. Function
TripLogCompleted is already defined as virtual void. The
user must implement the desired function in order to be informed about the
completion.
Step 9
See example "Synchronously reading out the action log" (SlTripSvcAsync)
Overview
Using TripRecorder objects, you can read-out the current action log. It is also
possible to add your own entries to the log.
A user name already set when creating the SlTripRecorder object can be queried
with the following function.
If the events to be recorded were already specified when creating the object, the
function is used without parameters. The already set events to be recorded can be
queried with the following function.
Unsubscribing
Table 12-14: Unsubscribing
SlTripRecorderError unSubscribe();
Parameter Meaning
Return value Error number
void CrashLogCompleted();
12.3.9 Events
The following events can be logged. The events to be logged are transferred in the
form of an SlVector either in the constructor or when starting a recording.
13 Display Manager
13
Objective of the chapter
You can find a description of the Display Manager in the
"SinumerikOperate_QT.pdf" document in Chapter 4.27.
13.1 Introduction
13.1.1 Class model
Overview
The class model of the Display Managers essentially comprises the
SlDisplayManager class.
SlDisplayManager class
This class is defined in sloperatecppapi.h:
#include "sloperatecppapi.h"
Overview
The following actions can be executed using SlDisplayManager objects:
• Display, change and hide application components
• Display, change and hide menu components
• Activate/deactivate the mirror mode
• Switch over displays
• Notification for the mirror mode, actual display and actual display
configuration
Application exchange:
If the application component is already visible in another frame of the display, it is moved
from there to the frame specified here. If possible, the freed frame is filled with the
application displaced from szDestFrame.
You can also attach a display name in front of a frame name (displayname.framename),
therefore changing the frame assignment into invisible displays.
Only your own HMI dialogs can be used as appname. The window to be displayed is
declared as top-level window (Qt::WindowStaysOnTopHint).
13.2.4 Notifications
Table 13-13: displayConfigurationChanged
This is callback is initiated if, after a TCU switchover, the active display configuration
changes.
void displayConfigurationChanged(const SlString& sDisplayConfig);
Parameter Meaning
sDisplayConfig Name of the display configuration
(empty, if a display configuration has not been defined for the
actual resolution)
I Index
I
I.1 Keyword index
A O
T V