展开查看
现在我从PLC读取了一个DINT的值,0-50000的范围,到了wincc7.5,比如名字叫实际位置。然后我在画面上需要体现相对位置,但是实际移动的不是单一的X轴移动,而是分段的,比如在实际位置在0-10000时,图形是沿Y轴从下往上移动,当实际位置10000-20000时,图形从刚才停止的点沿X轴往右运动,就是这样,图形的运动轨迹是根据实际位置分段的,如何做这个图形动画,或者有相关的例子,教程都行,感谢大神,新手多包涵!
提问者:Kingdom.Yao
wincc定义xpos和ypos的内部变量,然后全局脚本中判断实际位置的变量值,
假设实际位置小于1000,y方向从20000移动到10000(像素点)
,则(ypos-20000)/(10000-20000)=(实际位置-0)/(1000-0),ypos=实际位置/1000*(-10000)*20000
否则ypos=20000
假设实际位置∈[1000,2000],xpos在[100,5000],则
(xpos-100)/(5000-100)=(实际位置-1000)/(2000-1000),xpos=(实际位置-1000)/(2000-1000)*4900+100
否则xpos=100
然后图形的坐标x连接变量xpos,坐标y连接变量ypos
补充:你不试试我说的的?图形的x,y坐标连接xpos和ypos,全局脚本计算xpos和pos的值.
根据”zhangli0 ”大佬回复,我尝试做了一下,如下:
#include "apdefap.h"
int gscAction( void )
{
if (GetTagDWord("实际位置")&"实际位置">0&"实际位置"<1000) //假设实际位置小于1000,y方向从20000移动到10000(像素点)
"Ypos1A" == "实际位置"/1000*(-10000)*20000; //Ypos==实际位置/1000*(-10000)*20000
else
"Ypos1A"==20000; //Ypos=20000
if (GetTagDWord("实际位置")&"实际位置">1000&"实际位置"<2000) //假设实际位置∈[1000,2000],xpos在[100,5000],则
"Xpos1A"==("实际位置"-1000)/(2000-1000)*4900+100;//xpos=(实际位置-1000)/(2000-1000)*4900+100
else
"Xpos1A"==100; //否则xpos=100
return 0;
}
编译后:
Compiling...
line 6 : error (0054) : operands of *, / must be arithmetic
ine 6:error (0054):operands of *,
must be arithmetic
ine 6: error (0054):operands of
must be arithmetic
line 11: error (0054):operands of
must be arithmetic
line 11: error (0054); operands of -,
must be arithmetic
该动作没有包含解释代码。
该如何修改啊,菜鸟提问,请多包涵!