WinCC Stuff

Download WinCC Stuff

Post on 24-Oct-2014

98 views

Category:

Documents

5 download

Embed Size (px)

TRANSCRIPT

<p>09.99</p> <p>WinCC C-Course</p> <p>4 WinCC C-CourseTo make objects dynamic, various options are available in WinCC. Among others, these are tag connections, dynamic dialogs and direct connections. With these aids, the implementation of complex dynamics is possible. Nevertheless, they reach their limits with growing demands. A much broader range of possibilities is available to users through the configuration of C-Actions, project functions or actions. They are created in the WinCC script language C. For many applications it is not necessary to have a very comprehensive knowledge of C. It is sufficient to supply existing functions with parameters. However, to use all capabilities of C as the WinCC script language, a basic knowledge of this programming language is needed. This course can provide you with this knowledge.</p> <p>Target GroupThis course is intended to provide basic knowledge about the general application of the programming language C to everybody who is not familiar with it. Experienced C programmers can learn the special features of C when applied to WinCC. The sample project for this course can be copied directly from the online document to your hard drive. By default, it will be stored to the C:\Configuration_Manual folder.</p> <p>P roject_C_Course</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>4-1</p> <p>WinCC C-Course</p> <p>09.99</p> <p>Sam pl Proj e ect</p> <p>The interface of the sample project is divided into several sections. They are listed below: Navigation Bar (1) The navigation bar allows the selection of the pictures pertaining to : the various chapters. Chapter Window (2) The chapter window displays the pictures assigned to the : individual chapters. These pictures contain all samples described in the particular chapter. Most of these samples are created at buttons. S cript Window (3 : The script window displays the code of the sample currently ) selected in the chapter window. The currently selected sample is marked red in the chapter window. Diagnostics Window (4 : The diagnostics window displays all outputs of the various ) samples initiated by the printf()function.</p> <p>4-2</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>09.99</p> <p>WinCC C-Course</p> <p>4. Dev opm ent Env 1 el ironm ent f C-Scripts orFor the creation of C-S cripts, WinCC provides two different editors. On is the action editor in the Graphics Designer for the creation of C-Actions at objects, the other is the Global S cript editor for the creation of project functions and global actions. The syntax of the script language corresponds to S tandard C following ANS I. Another area of application for the programming language C in WinCC pertains to the creation of Dynamic Wiz ards. For this, a separate editor is available. The usage of this editor is explained in the sample pertaining to the Dynamic Wiz and will not be treated ard in the general overview.</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>4-3</p> <p>WinCC C-Course</p> <p>09.99</p> <p>4. 1 Action Editor ofthe Graphics Designer 1.In the Graphics Designer, object properties can be made dynamic via C-Actions. In the same way, C-Actions can be used to react to object events.</p> <p>Action EditorFor the configuration of a C-Action, the action editor is available. This editor is opened from the Object Properties dialog box via a R on the desired property or ev and then selecting C-Action from the displayed pop-up ent menu. Already existing C-Actions are marked by a green arrow at the property or ev ent.</p> <p>In the action editor, the C-Action can be programmed. For C-Actions at properties, a trigger must be defined. For C-Actions at events, this is not necessary since the event itself is the trigger. The completed C-Action must be compiled. If no errors are detected by the compiler, the action editor can be exited by clicking on OK.</p> <p>4-4</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>09.99</p> <p>WinCC C-Course</p> <p>Structure ofa C-ActionIn general, a C-Action corresponds to a function in C. There are two different types of CActions: Actions that are created at Properties and actions that are created at Ev ents. Generally, a C-Action at a property is used to control the value of this property with respect to different environmental conditions (e.g. the value of a tag) For this type of C-Action, a . trigger must be defined which controls its execution. A C-Action at an ev is used to react ent to this ev ent.</p> <p>C-Action at a Property</p> <p>The sample code above represents a typical C-Action at a property. The meaning of the individual sections is described below. Header (gray): The first three lines shaded gray form the header of the C-Action. This header is generated automatically and cannot be changed. Except for the return value type (l in the sample code) the function header is identical for all properties. Three ong , parameters are transferred to the C-Action. These are the P icture Name (l Pictu psz reNa , the Object Name (l ObjectNa and the P me) psz me) roperty Name (l PropertyNa . psz me) Variable Declaration (1): In this first code section that can be edited, the variables used are declared. In the sample code this is one variable of the l type. ong Value Computation (2): In this section, the computation of the property value is performed. In the sample code, only the value of one WinCC tag is read in. Value Return (3): The computed property value is assigned to the property. This is done via the retu command. rn</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>4-5</p> <p>WinCC C-Course</p> <p>09.99</p> <p>C-Action at an Ev ent</p> <p>The sample code above represents a typical C-Action at an event. The meaning of the individual sections is described below. Header (gray): The first three lines shaded gray form the header of the C-Action. This header is generated automatically and cannot be changed. The function header differs for the various types of events. The parameters l Pictu psz reNa (P me icture Name) , l ObjectNa (Object Name)and l PropertyNa (P psz me psz me roperty Name)are transferred to the C-Action. The l PropertyNa parameter only contains relevant information psz me for events that react to the change of a property. Additional event-specific parameters can be transferred. Variable Declaration (1): In this first code section that can be edited, the variables used are declared. In the sample code this is one variable of the l type. ong Ev Procesing (2): In this section, the actions reacting to the corresponding event ent s are performed. In the sample code, the value of one WinCC tag is read in. This value is assigned as position X to the own object. The return value of a C-Action at an event is of the v type, i.e. no return value is expected. oid</p> <p>4-6</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>09.99</p> <p>WinCC C-Course</p> <p>Creation ofa C-ActionThe following table describes the individual steps req uired to create a C-Action. S tep 1 Procedure:Creation of Ca Action Open the Gra ics Desig editor. ph ner Open the desired WinCC picture. Open the Object Properties dialog box of the desired object. The Ed Action editor is opened by it R on the desired property or event and then selecting C-Action from the pop-up menu.</p> <p>2</p> <p>3</p> <p>The Ed Action editor will be displayed. it In it, the basic framework of a function will be displayed. Among other things, the header of the C-Action has been automatically generated. This header cannot be changed. In the first line of the C-Action header, the file a efp. is integrated. Through s pd a h this file, all project fnctions, sta a fnctions as well as interna fnctions are u nd rd u lu announced to the C-Action. The second part of the C-Action header is the function header. The function s header provides information about the return value of the C-Action and transferred parameters which can be used within the C-Action. The third part of the C-Action header is the open bracket. This bracket cannot s be deleted. Between this open bracket and the closing bracket, the actual code of the C-Action is programmed.</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>4-7</p> <p>WinCC C-Course</p> <p>09.99</p> <p>S tep 4</p> <p>Procedure:Creation of Ca Action Another automatically generated code section consists of two comment blocks. These blocks are necessary to give the CrossRef erence editor access to the internal information of a C-Action. They are also needed to enable the rewiring within a C-Action. If both of these options are not going to be utiliz these ed, comments can also be deleted. The first comment block is used for the definition of the WinCC tags used in the C-Action. In the program code, the defined name of the variables instead of the real variable names must be used. The second comment block is used for the definition of the WinCC pictures used in the CAction. Here as well the defined name of the picture must be used in the program code instead of the real picture name. A sample code pertaining to this topic can be found following this table. It includes the definitions of a WinCC tag and a WinCC picture as well as the subseq uent application of these definitions. P rogramming the function body, which executes the desired calculations, actions and so forth. S everal programming aids are available. One of these aids is the tag selection dialog. This dialog is opened via the toolbar button displayed below. In the displayed S ect T gdialog, a WinCC tag is selected and then confirmed by el a clicking on OK. The name of the selected WinCC tag will then be inserted at the current cursor position in the C-Action.</p> <p>5</p> <p>6</p> <p>Another aid is the function selection in the left window of the action editor. Using the function selection, all available project fnctions, sta a fnctions u nd rd u and interna fnctions can be inserted automatically at the current cursor position lu in the C-Action.</p> <p>For this, the desired function is selected via a D. This will display the Assig ningPa meters dialog, which contains a list of all parameters that must be ra fed and their data types. The function can be parameteriz in the Vau column. ed le In addition to the plain text input, the options S ect T g Gra ic Objects and el a , ph Pictu are available. To insert the function at the current cursor position in the res C-Action, confirm the dialog by clicking on OK.</p> <p>4-8</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>09.99</p> <p>WinCC C-Course</p> <p>S tep 7</p> <p>Procedure:Creation of Ca Action The completed function must now be compiled. This is done via the toolbar button displayed below.</p> <p>The result of the compiling process is displayed in the lower left corner of the action editor. This includes the number of errors found and the number of warnings. Errors always cause a C-Action to be not executable. Warnings on the other hand are notes pointing out possible errors that can occur during the execution of the C-Action. Good programming style precludes the creation of CActions with the output result other than 0 Error( , Wa s) 0 rning s) (. If errors occur during the compiling process, they will be displayed in the output D on an error message in the output window, you can jump window. Via a directly to the corresponding code line.</p> <p>8</p> <p>For C-Actions that have been created at an object property, a trigger must be defined. For C-Actions at events, this is not necessary since the event itself form the trigger. The definition of the trigger is carried out via the toolbar button displayed below. You have the option to use time or tag triggers.</p> <p>9</p> <p>By clicking on the OK button of the action editor, the programmed C-Action will be placed at the desired property or event. A property or event made dynamic through a C-Action will be marked by a green arrow.</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>4-9</p> <p>WinCC C-Course</p> <p>09.99</p> <p>Def ining WinCC Tags and WinCC Pictures</p> <p>If a new C-Action is created, the automatically generated code will include two comment blocks. These comment blocks are necessary to give the CrossRef erence editor access to the internal information of a C-Action. They are also needed to enable the rewiring within a C-Action. Variable Def inition: The first comment block is used for the definition of the WinCC tags used in the C-Action. This comment block begins with the line /WI / NCC: T AGNAME_ ECT ON_ T S I S ART and ends with the line /WI / NCC: T AGNAME_ ECT ON_ S I END. In between these two lines, the names of all WinCC tags used in the C-Action are defined. A definition takes place through the preprocessor command # ef followed by the defined name (in the sample code this is d ine S 2_ 3 I COURS T T 1)followed by the name of the WinCC tag (in the sample code E_ ES _ this is S 2 cou test_ . 3 i_ rse_ 1) Picture Def inition: The second comment block is used for the definition of the WinCC pictures used in the C-Action. This comment block begins with the line /WI / NCC: PI CNAME_ ECT ON_ T S I S ART and ends with the line /WI / NCC: PI CNAME_ ECT ON_ S I END. In between these two lines, the names of all WinCC pictures used in the C-Action are defined. This follows the same convention as described above for the definition of tag names. Application: In the actual program code, the defined values must be used instead of the real tag and picture names. Before compiling the C-Action, the preprocessor will replace all defined names with the real names.</p> <p>4-10</p> <p>WinCC Conf iguration Manual C79000-G8276-C157-01</p> <p>09.99</p> <p>WinCC C-Course</p> <p>4. 2 The Gl 1. obal Script EditorThe Global S cript editor is used for the creation of project functions, standard functions and actions.</p> <p>Proj Functions ectIf the same functionality is freq uently req uired in C-Actions, this functionality can be formulated in a project function. P roject functions can be called in all C-Actions of a WinCC project, in the same manner as all other functions. The following lists the advantages of using project functions as opposed to creating the entire program code in CActions: Central place f editing: A change of a project function affects all C-Actions in which or this function is being used. If no project functions are used, all concerned C-Actions must be changed manually. This not only simplifies the configuration, but also maintenance and troubleshooting. Reus ability: Once a project fnction has been programmed and extensively tested, it u can be used again at any time without req uiring additional configurations or new tests. Reduced Picture Volume: If not the entire program code is placed directly in the CAction at the object, the picture volume is reduced. This results in faster picture opening times and a higher performance in runtime. Pasword Protection: Project fnctions can be protected against changes by assigning s u a password. This protects the configuration data as well as your know-how. P roject functions are only available project-internal. They are stored in the WinCCP rojectFolder\LIBRARY folder and defined in the ap_pbib.h file l...</p>

Recommended

View more >