Exemplo n.º 1
0
        /// <summary>
        /// initialize /Connect sensor
        /// </summary>
        /// <returns></returns>
        public bool  Go_Init_Sensor()
        {
            bool rtn = false;

            try
            {
                KApiLib.Construct();
                GoSdkLib.Construct();
                system_main = new GoSystem();
                accelerator = new GoAccelerator();
                accelerator.Start();
                KIpAddress ipAddress = KIpAddress.Parse(SENSOR_MAIN_IP);
                sensor_main = system_main.FindSensorByIpAddress(ipAddress);
                accelerator.Attach(sensor_main);
                sensor_main.Connect();
                system_main.EnableData(true);
                system_main.SetDataHandler(AsyncReceiveData);
                system_main.Start();
            }
            catch (Exception ex)
            {
                rtn = true;
            }

            return(rtn);
        }
Exemplo n.º 2
0
        void initialApi()
        {
            KApiLib.Construct();
            GoSdkLib.Construct();
            KIpAddress addr = KIpAddress.Parse(IPAddr);

            _system = new GoSystem();

            _sensor = _system.FindSensorByIpAddress(addr);
            _system.Connect();

            if (_sensor.State == GoState.Ready)
            {
                _context.Post(delegate
                {
                    richTextBox1.AppendText("Connected" + Environment.NewLine);
                }, null);
            }
            else
            {
                _context.Post(delegate
                {
                    richTextBox1.AppendText(@"Connect failed" + Environment.NewLine);
                }, null);
            }



            _system.EnableData(true);
            _system.SetDataHandler(OnDataReceived);
        }
Exemplo n.º 3
0
 public bool InitialAcq()
 {
     mSystem = new GoSystem();
     mSensor = mSystem.FindSensorByIpAddress(KIpAddress.Parse(IPAddr));
     DeviceStatusEvent?.Invoke(this, $"Find device @ IP address {IPAddr}");
     mSystem.Connect();
     DeviceStatusEvent?.Invoke(this, $"Connect to {IPAddr}");
     mSystem.EnableData(true);
     mSystem.SetDataHandler(OnData);
     return(true);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 析构相机
 /// </summary>
 public void Dispose()
 {
     try
     {
         if (system != null)
         {
             StopListen();
             system.Dispose();
             system = null;
             sensor = null;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("DisposeCamera Error:" + ex.Message);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 使用序列号初始化相机
 /// </summary>
 /// <param name="serial"></param>
 /// <returns></returns>
 public bool InitCamera(uint serial)
 {
     try
     {
         Dispose();
         system = new GoSystem();
         sensor = system.FindSensorById(serial);
         sensor.Connect();
         Console.WriteLine("InitCamera :" + serial);
         return(true);
     }
     catch (Exception ex)
     {
         Console.WriteLine("InitCamera Error:" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 使用IP地址初始化相机
 /// </summary>
 /// <param name="ip"></param>
 /// <returns></returns>
 public bool InitCamera(string ip)
 {
     try
     {
         Dispose();
         system = new GoSystem();
         KIpAddress ipAddress = KIpAddress.Parse(ip);
         //Console.WriteLine(ipAddress.ToString());
         sensor = system.FindSensorByIpAddress(ipAddress);
         sensor.Connect();
         Console.WriteLine("InitCamera :" + ip);
         return(true);
     }
     catch (Exception ex) {
         Console.WriteLine("InitCamera Error:" + ex.Message);
         return(false);
     }
 }
Exemplo n.º 7
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //생성 :
        //수정 :
        //목적 : ConnectCamera
        //설명 :
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private bool SetCameraConnect()
        {
            bool bReturn = false;

            do
            {
                try {
                    KIpAddress ipAddress = KIpAddress.Parse(m_objInitializeParameter.str3DCameraIP);
                    GoDataSet  dataSet   = new GoDataSet();
                    m_objCamera = m_objCameraSystem.FindSensorByIpAddress(ipAddress);
                    m_objCamera.Connect();
                } catch (Exception ex) {
                    Trace.WriteLine("CAMERA GOCATOR : " + ex.ToString());
                }
            } while(false);

            return(bReturn);
        }
Exemplo n.º 8
0
        /// <summary>
        /// initial api constructor and open data channel
        /// </summary>
        /// <returns></returns>
        public bool InitialDevice()
        {
            try
            {
                KApiLib.Construct();
                GoSdkLib.Construct();
            }
            catch (KException kEx)
            {
                Trace.WriteLine(kEx.ToString());
            }

            _system = new GoSystem();
            KIpAddress kIpAddress = KIpAddress.Parse(IPAddress);

            Trace.WriteLine($"Sonsor IP {IPAddress}");
            _sensor = _system.FindSensorByIpAddress(kIpAddress);
            if (_sensor.State == GoState.Ready)
            {
                _sensor.Connect();
                Trace.WriteLine("Sonsor Connected");
            }
            else
            {
                return(false);
            }
            _system.EnableData(true);
            Trace.WriteLine("Data channel open");

            _system.SetDataHandler(onData);
            if (_sensor.State == GoState.Running)
            {
                _system.Stop();
                _system.Start();
            }
            else
            {
                _system.Start();
                Trace.WriteLine("Sysem Start");
            }


            return(true);
        }
Exemplo n.º 9
0
        public void GoSystemConstruct(string IPAddress, long profileCount)
        {
            initialApi();
            _system       = new GoSystem();
            _profileCount = profileCount;
            KIpAddress addr = KIpAddress.Parse(IPAddress);

            _sensor = _system.FindSensorByIpAddress(addr);
            _syncContext.Post(delegate { yRes.Content = profileCount.ToString(); }, null);
            _system.Connect();
            if (_sensor.IsConnected())
            {
                _system.EnableData(true);
                _system.SetDataHandler(OnDataReceived);
                _syncContext.Post(delegate { UpdateMsg("Systeme Construct successfully"); }, null);
            }
            else
            {
                _syncContext.Post(delegate { UpdateMsg("System Construct Failed"); }, null);
            }
        }
Exemplo n.º 10
0
        public clsScanner()
        {
            Callback("start connect scanner");
            KApiLib.Construct();
            GoSdkLib.Construct();
            system = new GoSystem();
            KIpAddress ipAddress = KIpAddress.Parse(ip);

            dataSet = new GoDataSet();
            try
            {
                sensor = system.FindSensorByIpAddress(ipAddress);
            }
            catch (Exception ex)
            {
                Callback("scanner connect failed");
                return;
            }

            sensor.Connect();
            Callback("scanner connected.");
        }
Exemplo n.º 11
0
        bool initialApi()
        {
            updateMsg("default ip address:" + ipAddr);
            updateMsg("Initial API construct");
            KApiLib.Construct();
            GoSdkLib.Construct();
            _system = new GoSystem();
            KIpAddress addr = KIpAddress.Parse(ipAddr);

            _sensor     = _system.FindSensorByIpAddress(addr);
            _sensorInfo = new GoSensorInfo();
            if (_sensor != null)
            {
                updateMsg("Find Device");
            }
            else
            {
                updateMsg("Device not found");
                return(false);
            }
            _sensor.Connect();
            if (_sensor.IsConnected())
            {
                updateMsg("Sensor Connected");
                string IDStr = _sensor.Id.ToString();

                updateMsg("Sensor ID:" + IDStr);
                _system.EnableData(true);
                updateMsg("Enable Data");
                _sensor.SetDataHandler(OnDataReceived);
                updateMsg("regist data handller");
                updateMsg("Waiting data....");
                string sts = _sensor.State.ToString();
                updateMsg("sensor current state:" + sts);
                return(true);
            }

            return(false);
        }
Exemplo n.º 12
0
        public void Connect()
        {
            try {
                // Gocator 초기화 및 접속 (GoSDK 예제를 참고)
                KApiLib.Construct();
                GoSdkLib.Construct();
                KIpAddress ipAddress;

                // GoSystem 필수
                m_objCameraSystem = new GoSystem();

                ipAddress = KIpAddress.Parse(m_objInitializeParameter.str3DCameraIP);

                m_objCamera = m_objCameraSystem.FindSensorByIpAddress(ipAddress);
                m_objCamera.Connect();

                m_objCameraSystem.EnableData(true);
                m_bConnect = true;
            } catch (Exception ex) {
                Trace.WriteLine("Exception Gocator : " + ex.ToString());
            }
        }
Exemplo n.º 13
0
        public bool Connect()
        {
            if (FrameworkExtenion.IsSimulate)
            {
                return(true);
            }

            try
            {
                system = new GoSystem();
                system.Stop();

                if (EnableAccelerator)
                {
                    KIpAddress ipAddress = KIpAddress.Parse(AcceleratorIp);
                    sensor = system.FindSensorByIpAddress(ipAddress);

                    //accelerator = new GoAccelerator();
                    //accelerator.Start();
                    //accelerator.Attach(sensor);
                }
                else
                {
                    KIpAddress ipAddress = KIpAddress.Parse(IpStr);
                    sensor = system.FindSensorByIpAddress(ipAddress);
                }


                sensor.Connect();
            }
            catch (Exception ex)
            {
                LastError = "ConnectError:" + ex.Message;
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
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