ContentsPage
Background Processing (Global Script)............................................................................................1
Objectives........................................................................................................................................2
Global Script......................................................................................................................................3
Example of a Project Function and/or a Standard Function............................................................4
Internal Functions: Example of Graphics 1/3.....................................................................................5
Internal Functions: Example of Graphics 2/3.....................................................................................6
Internal Functions: Example of Graphics 3/3.....................................................................................7
Background Processing (Actions) with Global Script........................................................................8
Example with Functions from DLLs.................................................................................................9
General InformationGlobal Script is the general term for C functions and actions. There is a series of C functions available for programming extensive actions in WinCC. These C functions are divided into groups and can be used both in the Graphics Designer as well as to a certain extent in Global Script.
Project FunctionsAll project-specific functions are combined under this header. The functions are applicable within the project (function library).
Standard FunctionsThis is where functions are located that can be used for more than one project. Pre-defined functions are present that can be expanded by your functions.
Internal FunctionsThe system provides the functions listed here. The user can not change the internal functions. These functions contain all basic functions necessary for processing WinCC objects. These functions also include all the functions in the C standard library.
There is a subdivision into:- alarmFunctions for receiving and processing individual messages.
- allocateFunctions for dynamic memory management (required if the returnvalue is a character string, for example)- c_bibStandard C library functions
- graphicsFunctions for reading and manipulating object propertiesof individual WinCC objects
- tagFunctions for reading and writing tags from the data manager
- winccFunctions for influencing the individual WinCC Runtimecomponents
ActionsActions are available only in the Global Script. This is where actions are defined that run in the background and are not connected directly with the selected WinCC object (screen, screen window, graphic object, etc.).
TaskA bit is to be reset in a data word. This function is to be stored centrally, because it is a function that is frequently used. This central storage can be either project-specific (project functions) or for more than one project (standard functions).
ProcedureThe function is created in Global Script after the method of functioning and the parameters to be transferred have been clarified. After the function has been saved in the project functions or standard functions, it can be used in the Graphics Designer at various locations and with various parameters. (Functions you write yourself can not be used in Global Script.)The advantage of central storage is how easy it is to make changes and to maintain the function. Changes only have to be carried out at one location and are immediately available at all call-up locations (as long as the transfer parameters do not change). Parameters are transferred in the C syntax.
Function CallThe call of the function named above has the following appearance in the Graphics Designer.For example, Setting Bit 2 in a word:
Events/ mouse/ left mouse button/ C function...BitSet ( 1, "MotorStatus", 2);This sets Bit 2 in the "MotorStatus" tag. To reset the bit, you have to call the same function with the paramaters:
BitSet ( 0, "MotorStatus", 2);
GeneralYou can find functions for reading (Get) and manipulating (Set) object
Information properties of individual WinCC objects under the internal Graphics functions. The functions are divided according to the object properties groups. Some functions can be used only with certain objects.- StyleStyles (for example, line end and line weight)- FlashFlash (for example, background flashing color and flashing
frequency)- FillFill (yes/no and fill level)- FontFont (for example, font, orientation, and writing style)- AxesAxes (only for bar graphs: axis labeling and axis division)- ColorColors (for example, foreground color and border color)- I_OInput/output (only for I/O fields: output values and input values)- GeometryGeometry (for example, polygon corners and X-Y coordinates)- LimitsLimits (only for bar graphs and I/O fields: various limit values, etc.)- MiscMiscellaneous (for example, border adaptation, screen name, and visibility)
ExampleA dialog box from which various buttons can be operated is to be called in one screen. Example 1 shows the basic function for positioning and outputting the dialog box.The function is expanded somewhat in Example 2, so that the box can always be output at the lower right corner of the button to permit easier assignment to the operated element.
ProcedureThe geometry functions help to determine the button position. Then there is a check to determine whether the box fits to the right of and below the button. If this is not the case, then the box is output to the left of the button and above the lower screen edge. SetPictureName and SetVisible functions carry out theoutput.
ExampleHere you see the functions necessary for outputting the dialog box at a certain location on the screen. The function contains four transfer parameters.- lpszPictureNameScreen name for the current screen- lpszObjectNameName of the operated object- lpszBScreenNameName of the configured screen window- lpszBoxNameName of the screen to be output in the specified screen
windowThe value for the left, upper corner of the dialog box must first be permanently specified in the present example.
Function Definitionvoid Box_with_Pos1(char* lpszPictureName, char* lpszObjectName, char* lpszBScreenName, char* lpszBoxName){
Tag Declarationint BScreenXPos, BScreenYPos;
BScreenXPos = 20;BScreenYPos = 20;
Outputting the BoxSetLeft( lpszPictureName, lpszBScreenName, BScreenXPos);SetTop( lpszPictureName, lpszBScreenName, BScreenYPos);SetPictureName( lpszPictureName, lpszBScreenName, lpszBoxName);SetVisible( lpszPictureName, lpszBScreenName, 1);}
NoteThere is a function that determines the position of the operated object and outputs the dialog box on the lower, right corner of the operated object on the next page
GeneralYou have a Project-wide ActionSystem (PAS) available in WinCC for actions
Informationindependent of the screen. These actions run in the background and can be started cyclically (time trigger), acyclically (at a certain time), or even dependent on an event (tag). These actions serve to implement actions for an entire project. The individual actions are created in the Global Script Editor.
ExampleAn operating hours counter is to be implemented as an example. If a certain drive or even system component is working, an internal counter is incremented, which records the minutes and hours. A minute trigger starts the action. A start bit makes it possible to record the operating hours separately from the WinCC Runtime and store it in assigned tags.
Procedure1. Create internal tags in the data manager.2. Create an action in the Global Script Editor (for example, operating
hours.PAS).3. Select Global Script Runtime in the startup list.
4. Activate the Runtime.
GeneralAction programming from WinCC offers a multitude of generation possibilities.
Information It is also possible to access external functions stored in DLLs, for example, within the C action. These DLLs can be both standard DLLs as well as function libraries you create yourself. Using a function from a DLL is especially recommended where extensive calculations must be carried out. Because the code is already stored in an executable way in the DLL and does not have to be interpreted at runtime, there is a significantly faster processing speed for extensive calculations.
ExampleIn the example above, nothing more is done for the DLL function than processing a loop from a start value to an end value. The intermediate results are output in a diagnostics window. In a direct comparison, you do not see a significant time advantage in using DLL functions until there are very many operations.
NoteTo create the DLL, you can use the Application Wizard from Visual C++, for example (MFC-AppWizard (dll)). All functions to be used are entered in this DLL and are declared as external "C." In addition, each function must also be entered in the export table.
FAQ solutionFAQ 830 1801 Question: How can I implement a selfmade DLL in WinCC in the correct way?