WinCC OA tutorial. Part 3. Global scripts (control scripts)

The valve behavior programmed in the previous section ... is illogical. In the handler for clicking the "Open" or "Close" button, we directly set the value of the element called Position. Given that in the DPT itself, we already have the commands "Open" and "Close".

Datapoint type "Flap"
Datapoint type "Flap"

, - , , , . workshop , .

«» «».

Script for pressing the "Open" button
«Open»

main(mapping event)
{
  dpSet("System1:Flap1.Commands.Open", 1, "System1:Flap1.Commands.Close", 0);
}
Modified script of the "Open" button
«Open»

, DPE, , , . «» «», « » (, , , ).

«Close»

, Para

Pressing the "Open" button
«Open»
Pressing the "Close" button
«Close»

, , . open close .

gedi Scripts, Add New CTRL Script

, Model

. . - WinCC OA, dpConnect, . .

  1. dpConnect . , , .

  2. callback .

WinCC OA. «» dpGet , , .

, dpConnect . — callback- ( OnOpen_CB), — , . , , - main Model :

main()
{
	dpConnect("OnOpen_CB", "System1:Flap1.Commands.Open");
}

callback-. — ( string) «» ( «» ). .

void OnOpen_CB(string dp1, bool bNewValue)
{
;
}

, . «» «», , 90. «», — 0.

void OnOpen_CB(string dp1, bool bNewValue)
{
	if (bNewValue) {
		dpSet("System1:Flap1.Inputs.Position", 90);
	} else {
		dpSet("System1:Flap1.Inputs.Position", 0);
	}
}

- . «» Control Manager. , (Control), . Control. . , , ?

Existing list of managers

WinCC OA Append new manager, Control. (Start mode) (manual), . . 2. 2? 1 . . . , ui 1 ctrl 1, ui ( ctrl) . «-num 2». , . :

Control manager properties for valve simulation
Control

Manager Start ( ). , 2.

Simulation script successfully launched

.

By pressing the Open button, the opening is visualized
Open
Close button renders closing
Close

, Control Manager (, main) . main() callback , , dpConnect ( ). , , control- . - .

The control manager itself creates its own separate process at startup. Its main function is executed in a separate thread (thread). The callback function (in our case OnOpen_CB) is also run in a separate thread. After execution, the main function stops working, but the callback continues to be in the PC memory (in its own thread) and is called when the "signed" variable changes.




All Articles