2、taAcquisition(数据采集与监视控制)。它是指一些数据采集与过程控制的专用软件,通过PLC控制,用MCGS演示来表达实现交通灯在日常生活中功能。城市主要十字路口采用PLC来控制东西红绿灯和南北红绿灯,通过装有MCGS的IPC机将交通灯控制系统与交通管理中心的信息网相连,信息网的计算机不仅能实时收集底层控制信息与参数,对底层设备实施操作,而且还能完成响应管理、统计工作,实现交通管理管控一体化。2.目的1)提高利用所学知识解决实际问题的能力2)掌握通过对图形对象在不同的数值区间内设置不同的状态属性(如颜色、大小、位置移动、可见度、闪烁效果等),用数据对象的值的变化来驱动图形对象的状态
3、改变,使系统在运行过程中,产生形象逼真的动画效果;3)培养运用组态软件和计算机设计过程控制系统的实际能力4)对复杂的工艺系统,学会编写脚本程序来实现控制流;5)拓宽和加深对已学过的理论知识的理解,培养实际应用能力,从而掌握比较全面的专业知识。6)通过熟悉MCGS软件的应用,满足实验的要求,使我们掌握组态软件的系统结构、原理、功能及技术指标、使用方法。3.设计3.1总体设计了解系统的要求,进行需求分析,确定输入与输出,建立红绿灯交通系统框架。3.2概要设计(1)、新建工程:打开MCGS软件,新建一个工程,取名zcb.MCG;(2)、界面设计:在新工程中新建两个用户窗口,其中一个用于欢迎界面(兼
6、:左边的红灯,开关型变量green_left:左边的绿灯,开关型变量yellow_left:左边的黄灯,开关型变量red_right:右边的红灯,开关型变量green_right:右边的绿灯,开关型变量yellow_right:右边的黄灯,开关型变量red_up:上边的红灯,开关型变量green_up:上边的绿灯,开关型变量yellow_up:上边的黄灯,开关型变量red_down:下边的红灯,开关型变量green_down:下边的绿灯,开关型变量yellow_down:下边的黄灯,开关型变量3)其他变量count:用来计数,来确定哪个绿灯亮,数值型变量4.4运行策略及脚本程序1)运行策
7、略主要利用红绿灯之间的切换,判断当前状态,决定车子是否走或停下来,并利用车子的显示与隐藏使车子达到转弯的效果,如当车子car_right向右走是car_right1=1,表示car_right显示,在一定范围时判断上下红绿灯状况,若上面是绿灯,则car_right1=0(car_right隐藏),car_right_up1=1(car_right_up显示),达到车子向右走然后在十字路口处向上转弯的效果2)脚本程序在循环策略中加上如下代码:count=count+2ifcount>100thencount=0endifflag=1#灯的代码#ifcount>0andco
8、unt<=50thengreen_left=1red_left=0yellow_left=0green_right=1red_right=0yellow_right=0green_up=0red_up=1yellow_up=0green_down=0red_down=1yellow_down=0endififcount>50andcount<=100thengreen_left=0red_left=1yellow_left=0green_right=0red_right=1yellow_right=0green_up=1red_up=0yellow_up=0gree
9、n_down=1red_down=0yellow_down=0endif#向右走车的代码#ifcar_right>1500thencar_right=0car_right1=1endififcar_right_up<-700thencar_right_up=0car_right_up1=0endififcar_right_down>700thencar_right_down=0car_right_down1=0endififcar_right=260andred_leftandcar_right1thenelsecar_right=car_right
10、+10endififcar_right_up1thencar_right_up=car_right_up-10endififcar_right_down1thencar_right_down=car_right_down+10endififcar_right>=390andcar_right<=410andgreen_upthencar_right1=0car_right_up1=1car_right_down1=0endififcar_right>=390andcar_right<=410andgreen_downthencar_rig
11、ht1=0car_right_up1=0car_right_down1=1endif#向左走车的代码#ifcar_left<-1500thencar_left=0car_left1=1endififcar_left_up<-700thencar_left_up=0car_left_up1=0endififcar_left_down>700thencar_left_down=0car_left_down1=0endififcar_left1andcar_left=-680andred_rightthenelsecar_left=car_left-10e
12、ndififcar_left_up1thencar_left_up=car_left_up-10endififcar_left_down1thencar_left_down=car_left_down+10endififcar_left>-800andcar_left<-770andgreen_upthencar_left1=0car_left_up1=1car_left_down1=0endififcar_left>-800andcar_left<-770andgreen_downthencar_left1=0car_left_up1=
13、0car_left_down1=1endif#向上走车的代码#ifcar_up<-700thencar_up=0car_up1=1endififcar_up_right>1000thencar_up_right=0car_up_right1=0endififcar_up_left<-1000thencar_up_left=0car_up_left1=0endififcar_up1andcar_up=-230andred_downthenelsecar_up=car_up-10endififcar_up_right1thencar_up_right
14、=car_up_right+10endififcar_up_left1thencar_up_left=car_up_left-10endififcar_up>-360andcar_up<-330andgreen_rightthencar_up1=0car_up_right1=1car_up_left1=0endififcar_up>-360andcar_up<-330andgreen_leftthencar_up1=0car_up_right1=0car_up_left1=1endif#向下走车的代码#ifcar_down>700t
15、hencar_down=0car_down1=1endififcar_down_right>1000thencar_down_right=0car_down_right1=0endififcar_down_left<-1000thencar_down_left=0car_down_left1=0endififcar_down1andcar_down=60andred_upthenelsecar_down=car_down+10endififcar_down_right1thencar_down_right=car_down_right+10endififcar_down_left1thencar_down_left=car_down_left-10endififcar_down>130andcar_down<190andgreen_rightthencar_down1=0car_down_right1=1car_down_left1=0endififcar_down>130andcar_down<190andgreen_leftthencar_down1=0car_down_right1=0car_down_left1=1endif4.5安全设置在欢迎界面的那个窗口上添加三个按钮登陆、进入