搬家第42天-citect2018使用精灵操控设备

前面练习过在citect2018中使用精灵显示设备状态信息,这对同类设备在HMI上状态显示的制作非常方便。工艺中往往有很多同类型的运转设备需要在中控室控制,如果一个一个的制作操控面板非常麻烦费时,利用精灵先制作出通用的控制面板会非常方便。citect中使用asswin可以弹出面板,可以传递最多8个函数,超出这个数量就需要使用别的方法了。
先做一个传递7个函数的练习。在unity中新建一个项目,建立以下变量
2. 新建一个citect2018项目,配置IO设备
3. 通讯板和端口参数如下
由于使用模拟器,所以IP是127.0.0.1
5.citect2018建立变量,与unity变量对应
6. 新建一个精灵,使用阀门形状的符号,精灵的外观使用多状态,关联三个变量,分别是开到位,关到位和热继电器信号,使用了通配符。
这个精灵的鼠标点击事件写以下代码:
asswin("!阀门控制1",300,400,1+8,"%name%_remote","%name%_OpenLimit","%name%_CloseLimit","%name%_fault","%name%_automode","%name%_manOpen","%name%_manclose");
asswin函数是用于弹出窗口的,表达式为AssWin(sPageXYModesTag1, [sTag2..8] )
第一个参数spage表示要弹出的窗口的名称,这里是“!阀门控制1”,目前没有,这个后面在制作。第2、3各参数表示弹窗出现的x,y坐标值。
第三个参数是弹出窗口的模式,我从帮助文件粘贴过来了具体含义,英文比较简单就没有翻译,可以综合几种模式,只需要把相应数值相加就是了,这里用了1+8,表示子窗体、没有图标。

0 - Normal page.

1 - Page child window. The window is closed when a new page is displayed, for example, when the PageDisplay() or PageGoto() function is called. The parent is the current active window.

2 - Window child window. The window is closed automatically when the parent window is freed with the WinFree() function. The parent is the current active window.

4 - No re-size. The window is displayed with thin borders and no maximize/minimize icons. The window cannot be re-sized.

8 - No icons. The window is displayed with thin borders and no maximize/minimize or system menu icons. The window cannot be re-sized.

16 - No caption. The window is displayed with thin borders, no caption, and no maximize/minimize or system menu icons. The window cannot be re-sized.

32 - Echo enabled. When enabled, keyboard echo, prompts, and error messages are displayed on the parent window. This mode should only be used with child windows (for example, Mode 1 and 2).

64 - Always on top.

128 - Open a unique window. This mode stops this window from being opened more then once.

256 - Display the entire window. This mode commands that no parts of the window will appear off the screen

512 - Open a unique Super Genie. This mode stops a Super Genie from being opened more than once (at the same time). However, the same Super Genie with different associations can be opened.

1024 - Disables dynamic resizing of the new window, overriding the setting of the [Page]DynamicSizing parameter.

后面是需要传递的参数名字,这里依然使用了通配符,把重要的参数传递过去。本次传递了7各参数。

7.新建一个页面,命名为!阀门控制1。

远程控制旁边的红圈使用动态填充,?1?是通配符,表示第一个参数,与前面的asswin函数传递的第一个参数相匹配,这里相当于接收%name%_remote,实际精灵应用后,把%name%具体定义后,就能关联到具体设备信号了。

开到位旁边的红圈动态填充,表达式?2?,关到位旁边的红圈动态填充,表达式?3?,故障旁边的红圈动态填充,表达式?4?,中央自动模式旁边的红圈动态填充,表达式?5?,打开阀门按钮鼠标点击事件写脚本?6?=1,关闭阀门按钮鼠标点击事件写脚本?7?=1,退出按钮鼠标点击事件写脚本winfree()
8. 工艺画面上粘贴“阀门控制精灵”,配置name参数为V101,保存编译,运行后根据开到位、关到位和热继电器信号的格子状态,阀门会显示不同的颜色,点击阀门会弹出对话框,上面显示了详细状态信息,还有操作按钮,点击操作按钮,在unity程序在线观察,可以看到相应的变量数值改变。
使用精灵传递小于等于8个参数的练习就是这样子,后面再做多于8各参数传递数值的练习。
 
 
弹出窗口也可以使用assPopup函数,这个函数也只能传递最多8个变量数值,和ASSWIN不同的是,这个函数不能定义弹出窗口的位置,也不能定义窗口模式。
posted @ 2021-03-11 10:35  来自金沙江的小鱼  阅读(671)  评论(0编辑  收藏  举报