wincc scada get and set tag value function using C script

in wincc scada get and set tag values function is used to read and modify tag value. get and set function of c script assign for a tag to read and write value. when this function execute it read tag value and process according to program. in this article we see how a get a tag value and set a tag value work on c script.

Share this article:

make a tag to get and set value

now open your wincc explorer and than open tag management and add tags input_set and Status_motor. input_set is 16 bit signed. status_motor tags are binary type using to start and stop.

img/wincccscriptfunction/make a tag to get and set value.webp

add element to screen to wincc picture

now open graphics designer and add a start button and a circle. add a input/output field to read and write tag value and a static text field to write staus of value. when a get set tag button is pressed. in input output field select tag input_set. static text field text changed as per our c script.

img/wincccscriptfunction/add element to screen to wincc picture.webp

add a c script to set a value in wincc scada tag

first script set a Boolean value to tag status of motor. when mouse is pressed. to add this c script select button event mouse click property. A c script editor open enter following c script. this script set 'TRUE'(1) value to staus_motor tag. if the status motor tag is set to 1 than color of circle is change to green. second button set false value to status_motor tag and change background color to red.

img/wincccscriptfunction/add a c script to set a value in tag.webp

add a c script to get a value of wincc tag

now this script help to get value. in this script we store a value of input output field to value1 for comparison. this script get value of input output field and store to value1 and set circle color and set static text. add this script to input output field keyboard released event property.

img/wincccscriptfunction/add a c script to get a value of wincc tag.webp

  • #include "apdefap.h"
    Includes a header file likely containing API definitions (functions/macros) used to interface with the automation or HMI application.
  • double value1 = GetTagDouble("input_set");
    Fetches a numeric tag value (likely from a PLC or a data source) named "input_set".
  • If value is between 0 and 5:
    Changes the background color of an object named "Circle1" to magenta. Sets the text of a label ("Static Text1") to say "value in Low Range".
  • lpszPictureName
    : the name of the current display/picture (UI screen).