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".
, - , , , . workshop , .
«» «».
main(mapping event)
{
dpSet("System1:Flap1.Commands.Open", 1, "System1:Flap1.Commands.Close", 0);
}
, DPE, , , . «» «», « » (, , , ).
«Close»
, Para
, , . open close .
gedi Scripts, Add New CTRL Script
, Model
. . - WinCC OA, dpConnect, . .
dpConnect . , , .
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. . , , ?
WinCC OA Append new manager, Control. (Start mode) (manual), . . 2. 2? 1 . . . , ui 1 ctrl 1, ui ( ctrl) . «-num 2». , . :
Manager Start ( ). , 2.
.
, 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.