加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

CITECT2018R2过程分析器设置趋势笔标签显示单位2

(2023-09-03 10:39:16)
标签:

施耐德

citect2018r2

过程分析器

趋势标签显示工程单位

分类: 施耐德PLC
昨天做的练习不完美,在显示趋势笔标签的时候定制效果没有做出来。今天上午试验了一下,终于做出来了。把过程简单记录一下。前面搭建unity程序和citect2018建立项目和变量、画面等不再重复叙述。在昨天练习的基础上增加一个游标拖拽事件的脚本。
Sub trend1_AN4_CursorMoved(cursor As Object, position As Integer)
Dim pa As Object
Dim hPanes As Object
Dim hPane As Object
Dim hPens As Object
Dim hPen As Object
Dim hCursors As Object
Dim hcursor As Object
Dim asLocal As Boolean
Dim cursorTime As Date
Dim milli As Integer
Dim cursorValue As String
asLocal = -1 '取本地时间 
Set pa=trend1_AN4'趋势控件
Set hCursors=pa.cursors
Set hcursor=hCursors.item(1)
Set hPanes=pa.Panes
Set hPane=hPanes.item(1)
Set hPens=hPane.Pens
Set hPen=hPens.item(1)
hcursor.GetValue hpen,asLocal, cursorTime, milli, cursorValue
hPen.SetVerticalAxisLabelValue cursorValue, cursorValue & "  m3/h"
Set hPen=hPens.item(2)
hcursor.GetValue hpen,asLocal, cursorTime, milli, cursorValue
hPen.SetVerticalAxisLabelValue cursorValue, cursorValue & "  mg/m3"
End Sub
这里面主要是取游标处的数值,然后进行字符串替换来显示定制的标签单位。.GetValue和.SetVerticalAxisLabelValue很关键。

修改一下过程分析器的初始化脚本
Sub PAIni() '趋势控件初始化,现时显示游标、数据板命名、趋势笔命名,标签位置规范排列
Dim pa As Object
Dim hPanes As Object
Dim hPane As Object
Dim hPens As Object
Dim hPen As Object
Dim hCursor As Object
Dim value1,value2
Dim asLocal As Boolean
Dim cursorTime As Date
Dim milli As Integer
Dim cursorValue As String
Dim result1
asLocal = -1 '取本地时间 
Set pa=trend1_AN4'趋势控件
Set hCursor=pa.cursors.create("游标处的数值",500)
hCursor.visible=true
Set hPanes=pa.Panes
Set hPane=hPanes.item(1)
hPane.Name="趋势笔标签自定义单位练习"
Set hPens=hPane.Pens
Set hPen=hPens.item(1)
hCursor.PenlabelX(hPen)=100
hCursor.PenlabelY(hPen)=40
hPen.Name="流量1"
hCursor.PenLabelHeight(hPen)=100  
hCursor.PenLabelWidth(hPen)=150
hPen.VerticalAxisLabelType=35
Set hPen=hPens.item(2)
hCursor.PenlabelX(hPen)=300
hCursor.PenlabelY(hPen)=40
hPen.Name="浓度1"
hCursor.PenLabelHeight(hPen)=100  
hCursor.PenLabelWidth(hPen)=150
hPen.VerticalAxisLabelType=35
End Sub
这里面趋势笔的.VerticalAxisLabelType设置为35,就是显示用户自定义趋势单位。这么一来就可以显示出1-34种单位中没有的工程单位了。缺点是需要拖拽一下游标才能有效果。
我把练习上传到了网盘,地址是
链接:https://pan.baidu.com/s/1RXD8kHY7ByRTZTEZEfcDDA 
提取码:1234
基于unity 13.1和citect2018R2做的练习

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有