Last time we ended up creating a data point type (DPT Flap) and three data point instances (DPs Flap1, Flap2, Flap3). It's time to move on to the visual component of the operator interface. Open the gedi module. In gedi we see the name of our project in the tree and its components. We are now interested in "panels", so we expand them.
, . , «Add new panel».
— Flap.pnl, .
«» — , : pnl xml. Xml ( , WinCC OA ), . gedi, . «save as» ( — , ). Flap.pnl:
, ,
gedi , .
, , . , «Background color».
.
, , RGB. , , . , RGB, More, () , . blue.
- «»
-. ( — ).
(, ). . .. « » (reference point). ( , ). «Rotation» 90, .
, ( , ). Rotation . reference point , .
Rotation. «», «».
Save Save and run, .
— DPE Position DP Flap. «», ( ) Initialize «Open property wizard» .
Rotate object
DPE Flap1.Inputs.Position, «» «», Next, «Finish»
Save and run . DPE Flap1.Inputs.Position 11, .
para Flap1.Inputs.Position._original 90, «»
«Initialize» «». Open script editor:
// SimpleCtrlScriptStart {valid}
main()
{
EP_setRotation();
}
void EP_setRotation()
{
dyn_errClass err;
if( !dpExists( "System1:Flap1.Inputs.Position:_online.._value") )
{
setValue("", "color", "_dpdoesnotexist");
return;
}
dpConnect("EP_setRotationCB",
"System1:Flap1.Inputs.Position:_online.._value");
err = getLastError();
if (dynlen(err) > 0)
setValue("", "color", "_dpdoesnotexist");
}
void EP_setRotationCB(string dp1, int iNewValue)
{
float MIN_VALUE = 0;
float MAX_VALUE = 90;
float MIN_ROTATION = 0;
float MAX_ROTATION = 90;
float fRotation;
fRotation = ( 1.0 * (MAX_ROTATION - MIN_ROTATION) / (MAX_VALUE - MIN_VALUE)) *
(iNewValue - MIN_VALUE) + MIN_ROTATION;
if (fRotation > MAX_ROTATION) fRotation = MAX_ROTATION;
else if (fRotation < MIN_ROTATION) fRotation = MIN_ROTATION;
setValue("", "rotation", fRotation);
}
// SimpleCtrlScript {EP_setRotation}
// DP {System1:Flap1.Inputs.Position}
// DPConfig {:_online.._value}
// DPType {int}
// PVSSRange {0}
// Min {0}
// Max {90}
// MinRotation {0}
// MaxRotation {90}
// SimpleCtrlScriptEnd {EP_setRotation}
, — . , Wizard. , WinCC OA, — , «», . , C. WinCC OA Control.
. , main(), « » , .
main()
{
EP_setRotation();
}
main() — EP_SetRotation(). .
void EP_setRotation()
{
dyn_errClass err;
if( !dpExists( "System1:Flap1.Inputs.Position:_online.._value") )
{
setValue("", "color", "_dpdoesnotexist");
return;
}
dpConnect("EP_setRotationCB",
"System1:Flap1.Inputs.Position:_online.._value");
err = getLastError();
if (dynlen(err) > 0)
setValue("", "color", "_dpdoesnotexist");
}
, . (, DPE) , «». dpConnect. , …
dpConnect!!!
. dpConnect «» — WinCC OA. , . , , , , , . WinCC OA, - . , !
dpConnect ?
dpConnect("EP_setRotationCB", "System1:Flap1.Inputs.Position:_online.._value");
-, Callback- EP_setRotationCB ( ). -, - EP_setRotationCB System1:Flap1.Inputs.Position:_online.._value, , . , , (EV). , , DPE Position Flap1 . , , .
MQTT, S7-1200. . . — . . UI ( dpConnect). , callback-. , , . , , , .. (), dpConnect .
, . main EP_SetRotation. main . EP_SetRotation, , DPE , . — - ? — dpConnect () , , -. , , , . , WinCC OA — , . , , , .
callback-
void EP_setRotationCB(string dp1, int iNewValue)
{
float MIN_VALUE = 0;
float MAX_VALUE = 90;
float MIN_ROTATION = 0;
float MAX_ROTATION = 90;
float fRotation;
fRotation = ( 1.0 * (MAX_ROTATION - MIN_ROTATION) / (MAX_VALUE - MIN_VALUE)) *
(iNewValue - MIN_VALUE) + MIN_ROTATION;
if (fRotation > MAX_ROTATION) fRotation = MAX_ROTATION;
else if (fRotation < MIN_ROTATION) fRotation = MIN_ROTATION;
setValue("", "rotation", fRotation);
}
— ( ), . — . DPE, .
setValue. :
( ) — , . ( );
(rotation) — , , , … «» «» ( WinCC );
(fRotation) — .
- , Shape, (GetShape) . .
, , , , .
— . WinCC OA, . Push Button «Button label»
Open. Clicked Script Editor. dpSet, , :
— DPE, DPE. Tools→Datapoint Selector .
Flap1.Inputs.Position. , , . «» — 90 ( ). . . , — . ? . , , , , dpExists.
Close. — DPE Position 90, 0. Save and run .
dpSet. , , .
dpSet("System1:Flap1.Inputs.Position", 90);
… ( )
System1:Flap1.Inputs.Position:= 90;
. ui. DPE EV. ui EV TCP/IP. dpSet — , ui EV. ( ) — . ? , ? (", " () ). ? ? ? ui EV , . . . . , , WinCC OA , .
What is the right thing to do? It is correct to send multiple assignments with a single call to the dpSet function. For example, instead of three calls:
dpSet ("System1: Flap 1 .Inputs.Position", 90);
dpSet ("System1: Flap 2 .Inputs.Position", 90);
dpSet ("System1: Flap 3 .Inputs.Position", 90);
make one call
dpSet ("System1: Flap 1 .Inputs.Position", 90, "System1: Flap 2 .Inputs.Position", 90, "System1: Flap 3 .Inputs.Position", 90);