コード例 #1
0
        public void Scan()
        {
            NetworkScanner netscan = new NetworkScanner();

            netscan.Scan();
            controllers = netscan.Controllers;
        }
コード例 #2
0
        public ABBController()
        {
            NetworkScanner netscan = new NetworkScanner();

            netscan.Scan();
            allControllers = netscan.Controllers;// 扫描到所有控制器:
        }
コード例 #3
0
 private void InitControlUnit()
 {
     _networkScanner.Scan();
     Assert.Greater(_networkScanner.Controllers.Count, 0, "No controller found on the network.");
     _controlUnit = new ControlUnit(_networkScanner.Controllers.First());
     Assert.AreEqual(_controlUnit.TryConnect(), true, "Failed to connect to controller.");
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: DevotionZhu/RapidController
        public void AutoConnect()
        {
            scanner = new NetworkScanner();
            scanner.Scan();
            controllers = scanner.Controllers;
            string id = config.Read("ID", "RobID", "0", cfgPath);
            Guid   a  = Guid.Parse(id);

            foreach (ControllerInfo info in controllers)
            {
                if (info.SystemId == a)
                {
                    controller = Controller.Connect(info.SystemId, ConnectionType.Standalone);
                    controller.Logon(UserInfo.DefaultUser);
                    Text             = "当前已自动连接 ID:" + id + "    IP:" + info.IPAddress.ToString() + "    Port:" + info.WebServicesPort.ToString();
                    label2_INFO.Text = "已连接。";
                    setInfoColor();
                    ShowNewMessage("ヽ(✿゚▽゚)ノ 成功连接到示教器啦:" + id);
                    button_connect.Text = "     断开";
                }
            }
            if (controller == null)
            {
                MessageBox.Show("(ノへ ̄、) 未扫描到控制器或控制器ID不存在,请检查配置文件!", "自动连接错误");
            }
        }
コード例 #5
0
        public LogEditor()
        {
            NetworkScanner netScan = new NetworkScanner();

            netScan.Scan();

            ctrlInfo = netScan.GetControllers();

            foreach (var i in ctrlInfo)
            {
                if (i.SystemName.ToString() == "2600-109425") // ABB IRC5 Controller number 26-00268, 4600-800484
                {
                    aController = new Controller(i);
                }
            }
            // can be used like this, if you know which controller inside of ctrlInfo[] array.
            //aController = new Controller(ctrlInfo[0]);

            // using ControllerInfoCollection cntInfoColl -
            //cntInfoColl = netScan.Controllers;

            log = aController.EventLog;

            Console.WriteLine($"Application is running.");
            aController.EventLog.MessageWritten += _errorEventHappened;

            Console.ReadLine();
        }
コード例 #6
0
ファイル: BaseRobot.cs プロジェクト: jack06215/tmc
        public void Initialise()
        {
            var networkScanner = new NetworkScanner();

            for(int i = 0; i < 20; i++)
            {
                Thread.Sleep(100);
                networkScanner.Scan();

                foreach (ControllerInfo controller in networkScanner.Controllers)
                {
                    if (controller.IPAddress.Equals(this.RobotIPAddress))
                    {
                        this.Controller = ControllerFactory.CreateFrom(controller);
                        this.Controller.Rapid.ExecutionStatusChanged += new EventHandler<ExecutionStatusChangedEventArgs>(RapidExecutionStatusChanged);
                        this.SetSpeed(100);
                        _status = HardwareStatus.Operational;
                        return;
                    }
                }
            }

            _status = HardwareStatus.Offline;
            throw new Exception(string.Format("Robot at {0} could not be found.", this.RobotIPAddress));
        }
コード例 #7
0
        private void RefreshConnectedList()
        {
            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();
            connectedControllers = networkScanner.Controllers;

            if (connectedControllers.Count != 0)
            {
                connectButton.Enabled = true;
            }
            else
            {
                connectButton.Enabled = false;
            }

            ListViewItem item = null;

            controllerListView.Items.Clear();
            foreach (ControllerInfo controllerInfo in connectedControllers)
            {
                item = new ListViewItem(controllerInfo.IPAddress.ToString());
                item.SubItems.Add(controllerInfo.Version.ToString());
                item.SubItems.Add(controllerInfo.ControllerName);
                item.SubItems.Add(controllerInfo.Id);
                item.SubItems.Add(controllerInfo.Availability.ToString());
                item.SubItems.Add(controllerInfo.IsVirtual.ToString());
                item.SubItems.Add(controllerInfo.SystemName);
                controllerListView.Items.Add(item);
                item.Tag = controllerInfo;
            }
        }
コード例 #8
0
        public static void Main(string[] args)
        {
            Twitchbot t = new Twitchbot();

            NetworkScanner.Espipfound += OnEspFound;
            chatsw = new Stopwatch();
            execsw = new Stopwatch();

            chatsw.Start();
            execsw.Start();
            // scan for the the esp and keep scanning untill found.
            while (!NetworkScanner.espFound && !NetworkScanner.isScanning)
            {
                NetworkScanner.Scan();
                Thread.Sleep(500);
            }

            // sub to the bot message event

            TwitchClientIrc.ChatMessage += OnTwitchChat;

            // start the twitch bot

            t.Start();
        }
コード例 #9
0
ファイル: YuMi.cs プロジェクト: david0f/yumi
        public void ConnectAndDisplayData()
        {
            Console.Out.WriteLine("Scanning for controllers...");
            NetworkScanner scanner = new NetworkScanner();

            scanner.Scan();
            ControllerInfoCollection controllers = scanner.Controllers;

            if (controllers.Count == 0)
            {
                status = Status.NotFound;
            }
            Console.Out.WriteLine("Number of controllers found: {0}", controllers.Count);
            //connecting to first controller found. usually only one is present.
            if (status != Status.NotFound)
            {
                selectedController = controllers.First();
                Console.Out.WriteLine(selectedController.Name + " " + selectedController.HostName + " " + selectedController.IPAddress + " " + selectedController.Availability);
                Name = selectedController.Name + "\n" + selectedController.IPAddress;

                if (selectedController.Availability == Availability.Available)
                {
                    try
                    {
                        status     = Status.Connecting;
                        controller = ControllerFactory.CreateFrom(selectedController);
                        controller.Logon(UserInfo.DefaultUser);
                        status = Status.Connected;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Could not establish a connection to the controller" + Environment.NewLine + e.StackTrace);
                        status = Status.Disconnected;
                    }
                    finally { Console.Out.WriteLine("Connected to " + controller.IPAddress); }
                }
                else
                {
                    Console.WriteLine("The controller is not available for connections");
                    status = Status.NotAvailable;
                    status = Status.Disconnected;
                }

                controller.OperatingModeChanged += Controller_ModeChangedHandler;

                Console.Out.WriteLine(controller.OperatingMode);
                tasks = controller.Rapid.GetTasks();
                foreach (var task in tasks)
                {
                    Console.Out.WriteLine("Current task on the controller: {0} ", task.Name);
                }

                PrintRapidData(Tasks.LEFT, Modules.LEFT, "codeL");
                PrintRapidData(Tasks.RIGHT, Modules.RIGHT, "codeR");
            }
        }
コード例 #10
0
        public void createcontroler()
        {
            this.objNetworkWatcher = new NetworkScanner();
            objNetworkWatcher.Scan();

            ControllerInfoCollection objControllerInfoCollection = objNetworkWatcher.Controllers;

            objController = new Controller(objControllerInfoCollection[0]);
            objController.Logon(UserInfo.DefaultUser);
        }
コード例 #11
0
ファイル: GH_Connect.cs プロジェクト: AxisArch/Axis
        private void Scan(object sender, object e)
        {
            //Reset Controllers
            if (controllers != null)
            {
                foreach (var controller in controllers)
                {
                    controller.LogOff();
                }
                controllers = new List <Controller>();
            }

            // Find ABB robots on the network
            NetworkScanner scanner = new NetworkScanner();

            scanner.Scan();

            if (ipAddresses != null)
            {
                // Scan the network for controllers and add them to our controller array.
                foreach (string ip in ipAddresses)
                {
                    NetworkScanner.AddRemoteController(ip);
                }
            }
            ControllerInfo[] controllersID = scanner.GetControllers();
            foreach (ControllerInfo id in controllersID)
            {
                controllers.Add(new AbbIRC5Contoller(id));
            }

            // Possibility to scan for other robots

            // Allow value list to be updated
            updateVL = true;

            if (controllers != null)
            {
                if (controllers.Count > 0)
                {
                    log.Add("Controllers found:");

                    // List the controller names that were found on the network.
                    for (int i = 0; i < controllers.Count; i++)
                    {
                        log.Add(controllers[i].Name);
                    }
                }
                else
                {
                    log.Add("Scan timed out. No controllers were found.");
                }
            }
            ExpireSolution(true);
        }
コード例 #12
0
ファイル: RobotClass.cs プロジェクト: BoneMan77/FirstProject
 /// <summary>
 /// 搜索控制器返回控制器列表
 /// </summary>
 /// <returns></returns>
 public List <ControllerInfo> ScanList()
 {
     ns = new NetworkScanner();
     ns.Scan();
     foreach (ControllerInfo item in ns.Controllers)
     {
         ConList.Add(item);
     }
     JudgeLogStatus = true;
     return(ConList);
 }
コード例 #13
0
        static ControllerPresenter()
        {
            logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();

            Scanner = new NetworkScanner();
            Scanner.Scan();
            if (Scanner.Controllers.Count != 0)
            {
                CntPresent = true;
            }
        }
コード例 #14
0
        private void button_systemGuid_Click(object sender, RoutedEventArgs e)
        {
            Match m = Regex.Match(this.textBox_systemGuid.Text, @"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase);

            if (m.Success)
            {
                NetworkScanner scanner = new NetworkScanner();
                scanner.Scan();
                ControllerInfoCollection controllers = scanner.Controllers;
                foreach (ControllerInfo controllerinfo in controllers)
                {
                    if (controllerinfo.SystemId.ToString().ToUpper() == this.textBox_systemGuid.Text.ToUpper())
                    {
                        try
                        {
                            if (this.myController != null)
                            {
                                this.myController.Logoff();
                                this.myController.Dispose();
                                this.myController = null;
                            }
                            this.myController = Controller.Connect(new Guid(this.textBox_systemGuid.Text), ConnectionType.Standalone);
                            if (string.IsNullOrEmpty(this.textBox_userName.Text))
                            {
                                this.myController.Logon(UserInfo.DefaultUser);
                            }
                            else
                            {
                                UserInfo userInfo_login = new UserInfo(this.textBox_userName.Text);
                                userInfo_login.Password = this.passwordBox_password.Password;
                                this.myController.Logon(userInfo_login);
                            }

                            systemGuid = this.textBox_systemGuid.Text;
                            userName   = this.textBox_userName.Text;
                            password   = Class_Encrypt.EncryptDES(this.passwordBox_password.Password);

                            this.DialogResult = true;
                            return;
                        }catch (Exception exception)
                        {
                            MessageBox.Show(exception.Message);
                            return;
                        }
                    }
                }
                MessageBox.Show("This system guid is not valid or the controller is not connected, please check it angin.");
            }
            else
            {
                MessageBox.Show("This system guid's format is not valid, please check it angin.");
            }
        }
コード例 #15
0
        public static Dictionary <string, List <string[]> > findControllers(bool run)
        {
            List <string[]> roboCtrl = new List <string[]> {
            };
            List <string[]> virtCtrl = new List <string[]> {
            };

            if (run == true)
            {
                NetworkScanner scanner = new NetworkScanner();
                scanner.Scan();

                ControllerInfoCollection controllers = scanner.Controllers;
                foreach (ControllerInfo controller in controllers)
                {
                    if (controller.IsVirtual == false)
                    {
                        string[] eachController1 = new string[5]
                        {
                            controller.SystemName.ToString(),
                                        controller.SystemId.ToString(),
                                        controller.Availability.ToString(),
                                        controller.Version.ToString(),
                                        controller.IPAddress.ToString()
                        };
                        roboCtrl.Add(eachController1);
                    }

                    else
                    {
                        string[] eachController2 = new string[5]
                        {
                            controller.SystemName.ToString(),
                                 controller.SystemId.ToString(),
                                 controller.Availability.ToString(),
                                 controller.Version.ToString(),
                                 controller.IPAddress.ToString()
                        };
                        virtCtrl.Add(eachController2);
                    }
                }
            }
            return(new Dictionary <string, List <string[]> >
            {
                { "robotController", roboCtrl },
                { "virtualController", virtCtrl }
            });
        }
コード例 #16
0
        /// <summary>
        /// 扫描ABB控制器并连接到第一台设备
        /// </summary>
        /// <returns>
        /// 0: 连接正常
        /// -1: 未发现设备
        /// </returns>
        public int connect()
        {
            int ret = 0;

            NetworkScanner netscan = new NetworkScanner();

            netscan.Scan();
            controllers = netscan.Controllers;
            if (controllers.Count() < 1)
            {
                ret = (int)ErrorCode.err_no_controller;
                return(ret);
            }
            controller = new Controller(controllers[0]);
            controller.Logon(UserInfo.DefaultUser);
            return(ret);
        }
コード例 #17
0
        public static Dictionary<string, List<string[]>> findControllers(bool run)
        {
            List<string[]> roboCtrl = new List<string[]> { };
            List<string[]> virtCtrl = new List<string[]> { };

            if (run == true)
            {
                NetworkScanner scanner = new NetworkScanner();
                scanner.Scan();

                ControllerInfoCollection controllers = scanner.Controllers;
                foreach (ControllerInfo controller in controllers)
                {
                    if (controller.IsVirtual == false)
                    {
                        string[] eachController1 = new string[5]
                        {
                                controller.SystemName.ToString(),
                                controller.SystemId.ToString(),
                                controller.Availability.ToString(),
                                controller.Version.ToString(),
                                controller.IPAddress.ToString()
                        };
                        roboCtrl.Add(eachController1);
                    }

                    else
                    {
                        string[] eachController2 = new string[5]
                        {
                                controller.SystemName.ToString(),
                                controller.SystemId.ToString(),
                                controller.Availability.ToString(),
                                controller.Version.ToString(),
                                controller.IPAddress.ToString()
                        };
                        virtCtrl.Add(eachController2);
                    }
                }
            }
            return new Dictionary<string, List<string[]>>
            {
                {"robotController", roboCtrl},
                {"virtualController", virtCtrl}
            };
        }
コード例 #18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();
            ControllerInfoCollection controllers = networkScanner.Controllers;

            foreach (ControllerInfo controller in controllers)
            {
                ListViewItem item = new ListViewItem(controller.SystemName);
                item.SubItems.Add(controller.IPAddress.ToString());
                item.SubItems.Add(controller.Version.ToString());
                item.Tag = controller;
                this.listView1.Items.Add(item);
                item.Selected = true;
            }
        }
コード例 #19
0
ファイル: Form1.cs プロジェクト: DevotionZhu/RapidController
        /// <summary>
        /// 扫描控制器
        /// </summary>
        public void scanNetwork()
        {
            scanner = new NetworkScanner();
            scanner.Scan();
            controllers = scanner.Controllers;
            // listBox1.Items.Clear();
            ListViewItem listViewItem1;

            listView1.Items.Clear();
            foreach (ControllerInfo info in controllers)
            {
                listViewItem1 = new ListViewItem(info.SystemName);
                // INDEX: SysName/ IP / ControllerName / SysInfo  / ID / Port
                // listViewItem1.Text = (info.SystemName); // 第一列
                listViewItem1.SubItems.Add(info.IPAddress.ToString());
                listViewItem1.SubItems.Add(info.ControllerName);
                listViewItem1.SubItems.Add(info.Version.ToString());
                listViewItem1.SubItems.Add(info.SystemId.ToString());
                listViewItem1.SubItems.Add(info.WebServicesPort.ToString());
                listView1.Items.Add(listViewItem1);
            }
        }
コード例 #20
0
        // kong jian
        public void Form1_Load(object sender, EventArgs e)
        {
            // 调用 ABBCollector 进行接口扫描
            collector = new ABBCollector();

            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();
            ControllerInfoCollection controllers = networkScanner.Controllers;

            // 对于扫描到的每一个控制器执行
            foreach (ControllerInfo controller in controllers)
            {
                // listviewitem 是建立的控件中的单元 以系统SystemName为keyword 建立信息类
                ListViewItem item = new ListViewItem(controller.SystemName);
                //获取 IP version 信息
                item.SubItems.Add(controller.IPAddress.ToString()); // ip
                item.SubItems.Add(controller.Version.ToString());   // version
                item.Tag = controller;
                // 指明 item 归属的控件
                this.listControllerView.Items.Add(item);
            }
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: Gitfanlei/ABBdataacquisition
        private void Form1_Load(object sender, EventArgs e)
        {
            // 建立接口扫描类
            NetworkScanner networkScanner = new NetworkScanner();

            // 接口扫描
            networkScanner.Scan();
            // 建立控制器扫描接口变量
            ControllerInfoCollection controllers = networkScanner.Controllers;

            // 对于扫描到的每一个控制器执行
            foreach (ControllerInfo controller in controllers)
            {
                // listviewitem 是建立的控件中的单元 以系统SystemName为keyword 建立信息类
                ListViewItem item = new ListViewItem(controller.SystemName);
                //获取 IP version 信息
                item.SubItems.Add(controller.IPAddress.ToString());
                item.SubItems.Add(controller.Version.ToString());
                item.Tag = controller;
                // 指明 item 归属的控件
                this.lstControllersView.Items.Add(item);
            }
        }
コード例 #22
0
        // ABB_____________________________________________________________________________________________________________________

        public void abbScanner()
        {
            abbCollector = new ABBCollector();

            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();
            ControllerInfoCollection controllers = networkScanner.Controllers;

            foreach (ControllerInfo controller in controllers)
            {
                // 加载扫描的信息

                //// listviewitem 是建立的控件中的单元 以系统SystemName为keyword 建立信息类
                //ListViewItem item = new ListViewItem(controller.SystemName);
                ////获取 IP version 信息
                //item.SubItems.Add(controller.IPAddress.ToString());  // ip
                //item.SubItems.Add(controller.Version.ToString()); // version
                //item.Tag = controller;
                //// 指明 item 归属的控件
                //this.listControllerView.Items.Add(item);
            }
        }
コード例 #23
0
        private void ABBDiscovery()
        {
            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();

            ControllerInfo[] controllerInfos = networkScanner.GetControllers(chooseSocket ? NetworkScannerSearchCriterias.Virtual : NetworkScannerSearchCriterias.Real);

            if (controllerInfos.Length > 0)
            {
                Console.WriteLine($"当前online {controllerInfos.Length} 个ABB机器人");

                ABBControllerInfo = controllerInfos[0];

                ABBController = ControllerFactory.CreateFrom(ABBControllerInfo);  // 利用反射方式创建controller实例

                Console.WriteLine($"Found one ABB.System Name is:{abbSystemName} System ID is:{abbSystemID} System IP is:{abbSystemIP}");
            }
            else
            {
                Console.WriteLine("没有扫描到Online的机器人!");
            }
        }
コード例 #24
0
        private async void CtrlScan()
        {
            var scanner = new NetworkScanner();

            scanner.Scan();
            ControllerInfoCollection controllers = scanner.Controllers;

            var taskList = new List <Task>();

            foreach (ControllerInfo ctrl in controllers)
            {
                if (ctrl.VersionName.Contains("6."))
                {
                    var c = new IRC5Session(new Address($"{ctrl.IPAddress}{(ctrl.IsVirtual ? ":" + ctrl.WebServicesPort.ToString() : string.Empty)}"));

                    taskList.Add(GetSysInfo(c));
                }
                else if (ctrl.VersionName.Contains("7."))
                {
                    var c = new OmniCoreSession(new Address($"{ctrl.IPAddress}{(ctrl.IsVirtual ? ":" + ctrl.WebServicesPort.ToString() : string.Empty)}"));

                    taskList.Add(GetSysInfo(c));
                }
            }


            Task t = Task.WhenAll(taskList);

            try
            {
                await t;
            }
            catch
            {
                ;
            }
        }
コード例 #25
0
        private void ReloadControllers()
        {
            if (!_reloadingControllers)
            {
                _reloadingControllers = true;
                Invoke((MethodInvoker) delegate
                {
                    Button_Scan.Enabled = false;
                });
                Task.Run(() =>
                {
                    while (_networkScanner == null)
                    {
                        Thread.Sleep(10);
                    }

                    _networkScanner.Scan();
                    Invoke((MethodInvoker) delegate
                    {
                        DataGrid_Controllers.Rows.Clear();

                        foreach (ControllerInfo controllerInfo in _networkScanner.Controllers)
                        {
                            AddNewController(controllerInfo);
                        }
                        if (_networkScanner.Controllers.Count == 0)
                        {
                            Logger.InvokeLog("No controllers were found on the network.");
                        }

                        _reloadingControllers = false;
                        Button_Scan.Enabled   = true;
                    });
                });
            }
        }
コード例 #26
0
ファイル: RemoteAbb.cs プロジェクト: zimhe/Robots
        void Connect()
        {
            Disconnect();
            NetworkScanner scanner = new NetworkScanner();

            scanner.Scan();

            var controllerInfo =
                (IP != null) ?
                scanner.Controllers.FirstOrDefault(c => c.IPAddress.ToString() == IP) :
                scanner.Controllers.FirstOrDefault();

            if (controllerInfo == null)
            {
                AddLog("Controller not found.");
                return;
            }

            if (controllerInfo.Availability != Availability.Available)
            {
                AddLog("Controller not available.");
                return;
            }

            _controller = ControllerFactory.CreateFrom(controllerInfo);
            _controller.Logon(UserInfo.DefaultUser);

            // string isVirtual = controllerInfo.IsVirtual ? "Virtual" : "Real";
            // AddLog($"Connecting to {controllerInfo.Name} ({isVirtual})");

            if (!Connected)
            {
                AddLog("Couldn't connect to controller.");
                return;
            }
        }
コード例 #27
0
        /*
         * //Conbox选择项改变,进行数据显示切换
         * void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
         * {
         *
         *    RobTarget p;
         *    JointTarget J;
         *     //throw new NotImplementedException();
         *     switch (comboBox1.SelectedItem.ToString())
         *     {
         *         case "Base":
         *              p = RBTCtroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.Base);
         *         break;
         *         case "Tool":
         *              p = RBTCtroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.Tool);
         *         break;
         *         case "WorkObject":
         *              p = RBTCtroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.WorkObject);
         *         break;
         *         case "World":
         *              p = RBTCtroller.MotionSystem.ActiveMechanicalUnit.GetPosition(CoordinateSystemType.World);
         *         break;
         *         case "Undefined":
         *              J = RBTCtroller.MotionSystem.ActiveMechanicalUnit.GetPosition();
         *         break;
         *         default:break;
         *     }
         *     textBox1Num.Text = p.Trans.X.ToString();
         *     textBox2Num.Text = p.Trans.Y.ToString();
         *     textBox3Num.Text = p.Trans.Z.ToString();
         *     textBox4Num.Text = p.Rot.Q1.ToString();
         *     textBox5Num.Text = p.Rot.Q2.ToString();
         *     textBox6Num.Text = p.Rot.Q3.ToString();
         * }
         */
        //扫描函数
        private void button1_Click(object sender, EventArgs e)
        {
            NetworkScanner Netscan = new NetworkScanner();

            Netscan.Scan();
            ControllerInfoCollection ctrlerInfos = Netscan.Controllers;

            if (ctrlerInfos.Capacity != 0)
            {
                foreach (ControllerInfo ctrlerinfo in ctrlerInfos)
                {
                    ListViewItem items = new ListViewItem(ctrlerinfo.ControllerName);
                    items.SubItems.Add(ctrlerinfo.Version.ToString());
                    items.SubItems.Add(ctrlerinfo.IPAddress.ToString());
                    listView1.Items.Add(items);
                    items.Tag = ctrlerinfo;
                }
                btnConnect.Visible = true;
            }
            else
            {
                MessageBox.Show("没有可用的控制器", "提示", MessageBoxButtons.OKCancel);
            }
        }
コード例 #28
0
        private void ScanControllerToListView()
        {
            netScanner.Scan();
            ControllerInfoCollection controllers = netScanner.Controllers;

            /////////////////////////////////////////////////////////////////
            ///filling
            ////////////////////////////////////////////////////////////////
            listViewController.Items.Clear();
            ListViewItem item = null;

            foreach (ControllerInfo controllerInfo in controllers)
            {
                item = new ListViewItem(controllerInfo.IPAddress.ToString());
                item.SubItems.Add(controllerInfo.Id);
                item.SubItems.Add(controllerInfo.Availability.ToString());
                item.SubItems.Add(controllerInfo.IsVirtual.ToString());
                item.SubItems.Add(controllerInfo.SystemName);
                item.SubItems.Add(controllerInfo.Version.ToString());
                item.SubItems.Add(controllerInfo.ControllerName);
                this.listViewController.Items.Add(item);
                item.Tag = controllerInfo;
            }
        }
コード例 #29
0
        //  Additional methods
        #region additional methods
        /// <summary>
        /// Get the controller
        /// </summary>
        /// <returns> The picked controller. </returns>
        private Controller GetController()
        {
            // Initiate and clear variables
            _controllerInstance.Clear();
            ControllerInfo[] controllers;
            List <string>    controllerNames = new List <string>()
            {
            };

            // Scan for a network with controller
            NetworkScanner scanner = new NetworkScanner();

            scanner.Scan();

            // Try to get the controllers from the netwerok
            try
            {
                controllers = scanner.GetControllers();
            }
            // Else return no controllers
            catch (Exception)
            {
                controllers = null;
            }

            // Get the names of all the controllers in the scanned network
            for (int i = 0; i < controllers.Length; i++)
            {
                _controllerInstance.Add(Controller.Connect(controllers[i], ConnectionType.Standalone));
                controllerNames.Add(_controllerInstance[i].Name);
            }

            // Automatically pick the controller when one controller is available.
            if (controllerNames.Count == 1)
            {
                _pickedIndex = 0;
            }
            // Display the form and let the user pick a controller when more then one controller is available.
            else if (controllerNames.Count > 1)
            {
                // Display the form and return the index of the picked controller.
                _pickedIndex = DisplayForm(controllerNames);

                // Return a null value when the picked index is incorrect.
                if (_pickedIndex < 0)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No Station picked from menu!");
                    return(null);
                }
            }

            // Return a null value when no controller was found
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No Station found!");
                return(null);
            }

            // Select the picked controller
            return(_controllerInstance[_pickedIndex]);
        }
コード例 #30
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool   activate   = false;
            bool   scan       = false;
            bool   kill       = false;
            bool   clear      = false;
            string ip         = System.String.Empty;
            int    index      = 0;
            bool   connect    = false;
            bool   resetPP    = false;
            bool   begin      = false;
            bool   stop       = false;
            bool   monitorTCP = false;
            bool   monitorIO  = false;
            bool   stream     = false;
            Target targ       = null;

            if (!DA.GetData(0, ref activate))
            {
                ;
            }
            if (!DA.GetData(1, ref scan))
            {
                ;
            }
            if (!DA.GetData(2, ref kill))
            {
                ;
            }
            if (!DA.GetData(3, ref clear))
            {
                ;
            }
            if (!DA.GetData(4, ref ip))
            {
                ;
            }
            if (!DA.GetData(5, ref index))
            {
                ;
            }
            if (!DA.GetData(6, ref connect))
            {
                ;
            }
            if (!DA.GetData(7, ref resetPP))
            {
                ;
            }
            if (!DA.GetData(8, ref begin))
            {
                ;
            }
            if (!DA.GetData(9, ref stop))
            {
                ;
            }
            if (!DA.GetData(10, ref monitorTCP))
            {
                ;
            }
            if (!DA.GetData(11, ref monitorIO))
            {
                ;
            }
            if (!DA.GetData(12, ref stream))
            {
                ;
            }
            if (!DA.GetData(13, ref targ))
            {
                ;
            }

            this.controllerIndex = index;
            this.start           = begin;

            double cRobX = 0;
            double cRobY = 0;
            double cRobZ = 0;

            double cRobQ1 = 0;
            double cRobQ2 = 0;
            double cRobQ3 = 0;
            double cRobQ4 = 0;

            Quaternion cRobQuat = new Quaternion();


            //Check for valid licence

            /*if (bool (Core.AuthTest.loggedIn) != true)
             * {
             *  new GH_RuntimeMessage("Please sign in to confirm your licence", GH_RuntimeMessageLevel.Error);
             *  return;
             * }*/


            if (activate)
            {
                if (scan)
                {
                    // Scan the network for controllers and add them to our controller array
                    scanner.Scan();
                    controllers = scanner.GetControllers();

                    if (controllers.Length > 0)
                    {
                        log.Add("Controllers found:");

                        // List the controller names that were found on the network.
                        for (int i = 0; i < controllers.Length; i++)
                        {
                            log.Add(controllers[i].ControllerName);
                        }
                    }
                    else
                    {
                        log.Add("Scan timed out. No controllers were found.");
                    }
                }

                if (kill && controller != null)
                {
                    controller.Logoff();
                    controller.Dispose();
                    controller = null;

                    log.Add("Process killed! Abandon ship!");
                }

                if (clear)
                {
                    log.Clear();
                    log.Add("Log cleared.");
                }

                if (connect)
                {
                    if (controller == null && controllers.Length > 0)
                    {
                        string controllerID = controllers[index].ControllerName;
                        log.Add("Selected robot controller: " + controllers[index].ControllerName + ".");

                        if (controllers[index].Availability == Availability.Available)
                        {
                            log.Add("Robot controller " + controllers[index].ControllerName + " is available.");

                            if (controller != null)
                            {
                                controller.Logoff();
                                controller.Dispose();
                                controller = null;
                            }

                            controller = ControllerFactory.CreateFrom(controllers[index]);
                            controller.Logon(UserInfo.DefaultUser);
                            log.Add("Connection to robot controller " + controller.SystemName + " established.");

                            // Get T_ROB1 queue to send messages to the RAPID task.
                            if (!controller.Ipc.Exists("RMQ_T_ROB1"))
                            {
                                controller.Ipc.CreateQueue("RMQ_T_ROB1", 10, Ipc.MaxMessageSize);
                            }

                            tasks = controller.Rapid.GetTasks();
                            IpcQueue robotQueue = controller.Ipc.GetQueue("RMQ_T_ROB1");
                            int      queueID    = robotQueue.QueueId;
                            string   queueName  = robotQueue.QueueName;

                            log.Add("Established RMQ for T_ROB1 on network controller.");
                            log.Add("Rapid Message Queue ID:" + queueID.ToString() + ".");
                            log.Add("Rapid Message Queue Name:" + queueName + ".");
                            RobotQueue = robotQueue;
                        }
                        else
                        {
                            log.Add("Selected controller not available.");
                        }

                        ControllerID = controllerID;
                    }
                    else
                    {
                        if (controller != null)
                        {
                            return;
                        }
                        else
                        {
                            string exceptionMessage = "No robot controllers found on network.";
                            ControllerID = "No Controller";
                            log.Add(exceptionMessage);
                        }
                    }
                }

                if (resetPP && controller != null)
                {
                    using (Mastership m = Mastership.Request(controller.Rapid))
                    {
                        // Reset program pointer to main.
                        tasks[0].ResetProgramPointer();
                        log.Add("Program pointer set to main on the active task.");
                    }
                }

                if (begin)
                {
                    // Execute robot tasks present on controller.
                    try
                    {
                        if (controller.OperatingMode == ControllerOperatingMode.Auto)
                        {
                            using (Mastership m = Mastership.Request(controller.Rapid))
                            {
                                // Perform operation.
                                tasks[0].Start();
                                log.Add("Robot program started on robot " + controller.SystemName + ".");
                            }
                        }
                        else
                        {
                            log.Add("Automatic mode is required to start execution from a remote client.");
                        }
                    }
                    catch (System.InvalidOperationException ex)
                    {
                        log.Add("Mastership is held by another client." + ex.Message);
                    }
                    catch (System.Exception ex)
                    {
                        log.Add("Unexpected error occurred: " + ex.Message);
                    }
                }

                if (stop)
                {
                    try
                    {
                        if (controller.OperatingMode == ControllerOperatingMode.Auto)
                        {
                            using (Mastership m = Mastership.Request(controller.Rapid))
                            {
                                // Stop operation.
                                tasks[0].Stop(StopMode.Immediate);
                                log.Add("Robot program stopped on robot " + controller.SystemName + ".");
                            }
                        }
                        else
                        {
                            log.Add("Automatic mode is required to stop execution from a remote client.");
                        }
                    }
                    catch (System.InvalidOperationException ex)
                    {
                        log.Add("Mastership is held by another client." + ex.Message);
                    }
                    catch (System.Exception ex)
                    {
                        log.Add("Unexpected error occurred: " + ex.Message);
                    }
                }

                // If active, update the status of the TCP.
                if (monitorTCP)
                {
                    if (tcpMonitoringOn == 0)
                    {
                        log.Add("TCP monitoring started.");
                    }

                    cRobTarg = tasks[0].GetRobTarget();

                    cRobX = Math.Round(cRobTarg.Trans.X, 3);
                    cRobY = Math.Round(cRobTarg.Trans.Y, 3);
                    cRobZ = Math.Round(cRobTarg.Trans.Z, 3);

                    Point3d cRobPos = new Point3d(cRobX, cRobY, cRobZ);

                    cRobQ1 = Math.Round(cRobTarg.Rot.Q1, 5);
                    cRobQ2 = Math.Round(cRobTarg.Rot.Q2, 5);
                    cRobQ3 = Math.Round(cRobTarg.Rot.Q3, 5);
                    cRobQ4 = Math.Round(cRobTarg.Rot.Q4, 5);

                    cRobQuat = new Quaternion(cRobQ1, cRobQ2, cRobQ3, cRobQ4);

                    tcp = Util.QuaternionToPlane(cRobPos, cRobQuat);

                    tcpMonitoringOn += 1;
                    tcpMonitoringOff = 0;
                }
                else if (tcpMonitoringOn > 0)
                {
                    if (tcpMonitoringOff == 0)
                    {
                        log.Add("TCP monitoring stopped.");
                    }

                    tcpMonitoringOff += 1;
                    tcpMonitoringOn   = 0;
                }


                // If active, update the status of the IO system.
                if (monitorIO)
                {
                    if (ioMonitoringOn == 0)
                    {
                        log.Add("Signal monitoring started.");
                    }

                    // Filter only the digital IO system signals.
                    IOFilterTypes    dSignalFilter = IOFilterTypes.Common;
                    SignalCollection dSignals      = controller.IOSystem.GetSignals(dSignalFilter);

                    IOstatus.Clear();
                    // Iterate through the found collection and print them to the IO monitoring list.
                    foreach (Signal signal in dSignals)
                    {
                        string sigVal = signal.ToString() + ": " + signal.Value.ToString();
                        IOstatus.Add(sigVal);
                    }

                    ioMonitoringOn += 1;
                    ioMonitoringOff = 0;
                }
                else if (ioMonitoringOn > 0)
                {
                    if (ioMonitoringOff == 0)
                    {
                        log.Add("Signal monitoring stopped.");
                    }

                    ioMonitoringOff += 1;
                    ioMonitoringOn   = 0;
                }


                if (stream)
                {
                    if (targ != null)
                    {
                        IpcMessage message = new IpcMessage();

                        pos.X = (float)targ.Position.X;
                        pos.Y = (float)targ.Position.Y;
                        pos.Z = (float)targ.Position.Z;


                        ori.Q1 = targ.Quaternion.A;
                        ori.Q2 = targ.Quaternion.B;
                        ori.Q3 = targ.Quaternion.C;
                        ori.Q4 = targ.Quaternion.D;

                        pose.Trans = pos;
                        pose.Rot   = ori;

                        string content = "SD;[" +
                                         "\"Linear\"," +
                                         pos.ToString() + "," +
                                         ori.ToString() + "," +
                                         pose.ToString() +
                                         "]";

                        byte[] data = new UTF8Encoding().GetBytes(content);

                        message.SetData(data);
                        RobotQueue.Send(message);
                    }
                }


                // Output the status of the connection.
                Status = log;

                DA.SetDataList(0, log);
                DA.SetDataList(1, IOstatus);
                DA.SetData(2, new GH_Plane(tcp));

                ExpireSolution(true);
            }
        }
コード例 #31
0
ファイル: Testing_Pull.cs プロジェクト: 0000duck/Projects
 public void ScannNow()
 {
     NetScan = new NetworkScanner();
     NetScan.Scan();
     CtrlInfo = NetScan.GetControllers();
 } // end of ScannNow method
コード例 #32
0
        /// <summary>
        /// Send robot target to controller.
        /// </summary>
        /// <param name="moduleName">Name of module</param>
        /// <param name="targetName">Name of target</param>
        /// <param name="targetValue">New value for target</param>
        public static void sendRobTargetToController(string moduleName, string targetName, string targetValue)
        {
            try
            {
                var scanner = new NetworkScanner();
                scanner.Scan();

                ControllerInfoCollection controllers = scanner.Controllers;
                using (var controller = ControllerFactory.CreateFrom(controllers[0]))
                {
                    controller.Logon(UserInfo.DefaultUser);
                    using (Mastership.Request(controller.Rapid))
                    {
                        if (controller.OperatingMode == ControllerOperatingMode.Auto)
                        {
                            using (var task = controller.Rapid.GetTask("T_ROB1"))
                            {
                                var target = new RobTarget();
                                using (var rapidData = task.GetRapidData(moduleName, targetName))
                                {
                                    if (rapidData.Value is RobTarget)
                                    {
                                        target.FillFromString2(targetValue);
                                        rapidData.Value = target;
                                    }
                                }

                                var result = task.Start(true);
                                Debug.WriteLine(result.ToString());

                                task.ResetProgramPointer();
                            }
                        }
                        else
                        {
                            Debug.WriteLine("Automatic mode is required to start execution from a remote client.");
                        }
                    }
                    controller.Logoff();
                }

            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
        }
コード例 #33
0
        //////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Send RAPID to controller.
        /// </summary>
        /// <param name="filePath">File path</param>
        /// <returns></returns>
        public static bool sendRapidToController(string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new Exception("File could not be found.");
            }

            var scanner = new NetworkScanner();
            scanner.Scan();

            ControllerInfoCollection controllers = scanner.Controllers;
            using (var controller = ControllerFactory.CreateFrom(controllers[0]))
            {
                controller.Logon(UserInfo.DefaultUser);
                using (Mastership.Request(controller.Rapid))
                {
                    if (controller.OperatingMode == ControllerOperatingMode.Auto)
                    {
                        var fileName = Path.GetFileName(filePath);

                        try
                        {
                            var remoteDir = controller.FileSystem.RemoteDirectory.Replace('/', '\\');
                            var localDir = Path.GetDirectoryName(filePath);
                            controller.FileSystem.LocalDirectory = localDir;

                            //write the mod file
                            controller.FileSystem.PutFile(fileName, true);

                            //write the prf file
                            controller.FileSystem.PutFile("Dynamo.prg", true);

                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex.Message);
                            return false;
                        }

                        using (var task = controller.Rapid.GetTask("T_ROB1")) // note the task name needs to be set up like this in Robot Studio
                        {
                            // read data from file
                            task.LoadProgramFromFile("Dynamo.prg", RapidLoadMode.Replace);
                            task.LoadModuleFromFile(fileName, RapidLoadMode.Add);
                            try
                            {
                                task.ResetProgramPointer();//seems to get hung up here.
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine(ex.Message.ToString());
                                throw;
                            }

                            var result = task.Start(true);
                            Debug.WriteLine(result.ToString());
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Automatic mode is required to start execution from a remote client.");
                    }
                }
                controller.Logoff();
            }

            return true;
        }
コード例 #34
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // 主窗口大小、位置
            int Desk_width  = Screen.PrimaryScreen.WorkingArea.Width;
            int Desk_height = Screen.PrimaryScreen.WorkingArea.Height;

            Width    = Desk_width;
            Height   = Desk_height;
            Location = new Point(0, 0);

            // 尝试连接ABB
            NetworkScanner networkScanner = new NetworkScanner();

            networkScanner.Scan();
            controllers = networkScanner.Controllers;
            foreach (ControllerInfo info in controllers)
            {
                ListViewItem item = new ListViewItem("PC");
                item.SubItems.Add("ABB");
                item.SubItems.Add("Detected");
                item.Tag = info;
                listView_Log.Items.Add(item);
                ABB_Connect_OK = true;
                if_ABB_init    = true;
            }



            // 初始化内存映射
            if (If_Init_mmf == false)
            {
                try
                {
                    mmf = MemoryMappedFile.CreateNew(memo_file_name, memo_capacity);
                }
                catch (Exception Memo_e)
                {
                    Console.WriteLine("Memo File: {0} Exception caught.", Memo_e);
                    return;
                }

                try
                {
                    accessor = mmf.CreateViewAccessor();
                }
                catch (Exception Memo_e)
                {
                    Console.WriteLine("Memo File: {0} Exception caught.", Memo_e);
                    return;
                }
                If_Init_mmf = true;
            }
            // Endof-初始化内存映射

            // Gocator启动
            // 进行Gocator初始化的相关工作
            KApiLib.Construct();
            GoSdkLib.Construct();
            GC_system = new GoSystem();
            KIpAddress ipAddress = KIpAddress.Parse(SENSOR_IP);

            try
            {
                sensor = GC_system.FindSensorByIpAddress(ipAddress);
            }
            catch (Exception GC_e)
            {
                Console.WriteLine("XX Gocator Error XX : {0} Exception caught.", GC_e);
                return;
            }

            sensor.Connect();
            sensor_setup = sensor.Setup;
            GC_system.EnableData(true);
            GC_system.SetDataHandler(onData);
            if_Gocator_init = true;
            // Endof-Gocator启动
        }// - Endof - Form1Load