示例#1
0
        //internal bool Monitor()
        //{
        //    if (TryConnectMonitor())
        //    {
        //        // Establish a MotionCursor on `Control`
        //        this._parentDriver.parentControl.InitializeMotionCursor();
        //        this._motionCursor = this._parentDriver.parentControl.MotionCursor;

        //        return true;
        //    }

        //    return false;
        //}

        private bool TryConnectMonitor()
        {
            try
            {
                _monitorClientSocket = new TcpClient();
                _monitorClientSocket.Connect(this._monitorIP, this._monitorPort);
                _monitorStatus = TCPConnectionStatus.Connected;
                _monitorClientSocket.ReceiveBufferSize = 1024;
                _monitorClientSocket.SendBufferSize    = 1024;

                _monitoringThread = new Thread(MonitoringMethod);
                _monitoringThread.IsBackground = true;
                _monitoringThread.Start();

                _isMonitored = true;

                return(_monitorClientSocket.Connected);
            }
            catch (Exception ex)
            {
                logger.Info("Real-time monitoring not available on this device");
                DisconnectMonitor();
            }

            return(false);
        }
示例#2
0
 public override bool ConnectToDevice(int deviceId)
 {
     logger.Info("Cannot connect to a device in Offline mode");
     return(false);
 }
示例#3
0
        /// <summary>
        /// Performs all necessary steps to successfuly connect to the device using the RobotStudio API.
        /// </summary>
        /// <param name="deviceId"></param>
        /// <returns></returns>
        public bool Connect(int deviceId)
        {
            _deviceId = deviceId;

            // In general, the Disconnect() + return false pattern instead of throwing errors
            // avoids the controller getting hung with an undisposed mastership or log from the client,
            // making failures a little more robust (and less annoying...)

            // Connect to the ABB real/virtual controller
            if (!LoadController(deviceId))
            {
                logger.Warning("Could not connect to controller, found no device on the network");
                Disconnect();
                return(false);
            }

            // Load the controller's IP
            if (!LoadIP())
            {
                logger.Warning("Could not connect to controller, failed to find the controller's IP");
                Disconnect();
                return(false);
            }

            // Log on to the controller
            if (!LogOn())
            {
                logger.Warning("Could not connect to controller, failed to log on to the controller");
                Disconnect();
                return(false);
            }

            if (!LoadRobotWareOptions())
            {
                logger.Warning("Could not connect to controller, failed to retrieve RobotWare options from the controller");
                Disconnect();
                return(false);
            }

            // Is controller in Automatic mode with motors on?
            if (!IsControllerInAutoMode())
            {
                logger.Warning("Could not connect to controller, please set up controller to AUTOMATIC MODE and try again.");
                Disconnect();
                return(false);
            }

            if (!IsControllerMotorsOn())
            {
                logger.Warning("Could not connect to controller, please set up Motors On mode in controller");
                Disconnect();
                return(false);
            }

            // Test if Rapid Mastership is available
            if (!TestMastershipRapid())
            {
                logger.Warning("Could not connect to controller, mastership not available");
                Disconnect();
                return(false);
            }

            // Load main task from the controller
            if (!LoadMainTask())
            {
                logger.Warning("Could not connect to controller, failed to load main task");
                Disconnect();
                return(false);
            }

            if (this._hasMultiTasking)
            {
                if (!LoadMonitorTask())
                {
                    logger.Info("Your device has the capacity to be monitored in real time, but could not be set up automatically; please refer to the documentation on how to set Machina monitoring on ABB robots.");
                }
            }

            if (!SetRunMode(CycleType.Once))
            {
                logger.Warning("Could not connect to controller, failed to set runmode to once");
                Disconnect();
                return(false);
            }

            // Subscribe to relevant events to keep track of robot execution
            if (!SubscribeToEvents())
            {
                logger.Warning("Could not connect to controller, failed to subscribe to robot controller events");
                Disconnect();
                return(false);
            }

            _isConnected = true;

            return(_isConnected);
        }