//初始化监视器的方法 public void InitialMoniter(string UR_IP) { //初始化这个Socket502_TCP端口 Socket502_TCP.RemoteIP = UR_IP; Socket502_TCP.RemotePort = 502; Socket502_TCP.SocketTimeOut = 1000; Socket502_TCP.initialServer(); //初始化这个Socket502_Angle端口 Socket502_Angle.RemoteIP = UR_IP; Socket502_Angle.RemotePort = 502; Socket502_Angle.SocketTimeOut = 1000; Socket502_Angle.initialServer(); //初始化这个Socket502_URState端口 Socket502_URState.RemoteIP = UR_IP; Socket502_URState.RemotePort = 502; Socket502_URState.SocketTimeOut = 1000; Socket502_URState.initialServer(); //初始化这个Socket502_URSpeedState端口 Socket502_URSpeedState.RemoteIP = UR_IP; Socket502_URSpeedState.RemotePort = 502; Socket502_URSpeedState.SocketTimeOut = 1000; Socket502_URSpeedState.initialServer(); //调用定时器,在线程中定时执行任务 GetRobotInformationTimer = new System.Timers.Timer(ScanRate); GetRobotInformationTimer.Elapsed += new System.Timers.ElapsedEventHandler(GetRobotInformation); GetRobotInformationTimer.AutoReset = true; //设置是执行一次(false)还是一直执行(true); GetRobotInformationTimer.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件; }