Пример #1
0
 public static void CloseHardWork()
 {
     CameraMgr.GetInstance().Close();
     TcpMgr.GetInstance().CloseAllEth();
     MotionMgr.GetInstace().Close();
     IOMgr.GetInstace().Close();
 }
Пример #2
0
        private void roundButton_ReadImg_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < comboBox_SelCam.Items.Count; i++)
            {
                CameraMgr.GetInstance().SetTriggerSoftMode(comboBox_SelCam.Items[i].ToString());
            }
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                // openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;//注意这里写路径时要用c:\\而不是c:\
                openFileDialog.Filter           = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp";
                openFileDialog.RestoreDirectory = true;
                openFileDialog.FilterIndex      = 1;
                openFileDialog.Multiselect      = false;
                openFileDialog.Title            = "打开图片";

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //string  fName = openFileDialog.FileName;
                    string  strPath = openFileDialog.FileName;
                    HObject img     = null;
                    HOperatorSet.ReadImage(out img, strPath);
                    visionControl1.DispImageFull(img);
                }
            }
        }
Пример #3
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     #region 读图
     //HObject img;
     //HOperatorSet.ReadImage(out img, "d:\\1.jpg");
     ////hWindowControl1.SetFullImagePart((HImage)(object)img);
     //HOperatorSet.DispObj(img, hWindowControl1.HalconID);
     #endregion
     #region 软触发
     //CameraMgr.GetInstance().GetCamera("CHP").SetTriggerMode("SoftWare");
     //uint nFrameNum =CameraMgr.GetInstance().GetCamera("CHP").FrameCount;
     //CameraMgr.GetInstance().GetCamera("CHP").GarbBySoftTrigger();
     //CameraMgr.GetInstance().GetCamera("CHP");
     //Task s = new Task((icount) =>
     //{
     //    uint frameCount =CameraMgr.GetInstance().GetCamera("CHP").FrameCount;
     //    while (frameCount <= nFrameNum)
     //    {
     //        frameCount = CameraMgr.GetInstance().GetCamera("CHP").FrameCount;
     //        Thread.Sleep(1);
     //    }
     //    HObject img = CameraMgr.GetInstance().GetCamera("CHP").GetImage();
     //    HOperatorSet.DispObj(img, (HTuple)CameraMgr.GetInstance().GetCamera("CHP").wnd);
     //},nFrameNum) ;
     //s.Start();
     #endregion
     string PagesItemName = this.Parent.Name;
     //  CameraMgr.GetInstance().GetCamera(PagesItemName).wnd = hWindowControl1.HalconID;
     CameraMgr.GetInstance().GetCamera(PagesItemName).StartGrab();
 }
Пример #4
0
        private void roundButton_VisionPrTest_Click(object sender, EventArgs e)
        {
            if (comboBox_SelVisionPR.SelectedIndex == -1)
            {
                return;
            }
            string strVisionPrName = comboBox_SelVisionPR.Items[comboBox_SelVisionPR.SelectedIndex].ToString();

            roundButton_VisionPrTest.Enabled = false;
            Action action = new Action(() =>
            {
                string camname = VisionMgr.GetInstance().GetCamName(strVisionPrName);
                double?Expouse = VisionMgr.GetInstance().GetExpourseTime(strVisionPrName);
                double?Gain    = VisionMgr.GetInstance().GetGain(strVisionPrName);

                CameraMgr.GetInstance().SetCamExposure(camname, (double)Expouse);
                CameraMgr.GetInstance().SetCamGain(camname, (double)Gain);
                CameraMgr.GetInstance().BindWindow(camname, visionControl1);
                CameraMgr.GetInstance().ClaerPr(camname);
                CameraMgr.GetInstance().GetCamera(camname).SetTriggerMode(CameraModeType.Software);
            }
                                       );

            action.BeginInvoke((ar) =>
            {
                roundButton_VisionPrTest.Invoke((MethodInvoker)(() => { roundButton_VisionPrTest.Enabled = true; }), null);
            }, null);
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.A))
        {
            Debug.Log("bind camera input event");
            CameraMgr.GetIns().BindInputEvent();
        }

        if (null == PCInputMgr.GetIns())
        {
            Debug.Log("pcinput = null");
            return;
        }

        if (null == TouchMgr.GetIns())
        {
            Debug.Log("touch input = null");
            return;
        }

        //Debug.Log("update");

        PCInputMgr.GetIns().tUpdate();

        TouchMgr.GetIns().tUpdate();
    }
Пример #6
0
        private void roundButton_AddItem_Click(object sender, EventArgs e)
        {
            ItemAdd itemAdd = null;

            if (CameraMgr.GetInstance().GetCameraNameArr() != null && CameraMgr.GetInstance().GetCameraNameArr().Count > 0)
            {
                itemAdd = new ItemAdd(CameraMgr.GetInstance().GetCameraNameArr().ToArray());
            }
            else
            {
                itemAdd = new ItemAdd(null);
            }
            DialogResult dialogResult = itemAdd.ShowDialog();

            if (dialogResult == DialogResult.Yes)
            {
                if (VisionMgr.GetInstance().GetItemNamesAndTypes().ContainsKey(itemAdd.ItemName))
                {
                    MessageBox.Show("视觉处理:名称重复", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    int index = dataGridViewProcessItem.Rows.Count;
                    CreateAndSaveItem(itemAdd.ItemName, itemAdd.VisionProcssName, itemAdd.CamName,
                                      itemAdd.Exposure, itemAdd.Gain);
                }
                dataGridViewProcessItem.Rows.Add("False", itemAdd.ItemName,
                                                 itemAdd.VisionProcssName, itemAdd.CamName,
                                                 itemAdd.Exposure.ToString(), itemAdd.Gain.ToString());
            }
        }
Пример #7
0
        private void Form_Manual_Load(object sender, EventArgs e)
        {
            visionControl1.InitWindow();
            Thread.Sleep(10);
            List <string> camname = CameraMgr.GetInstance().GetCameraNameArr();

            foreach (var temp in camname)
            {
                comboBox_SelCamera.Items.Add(temp.ToString());
            }
            if (camname != null && camname.Count > 0)
            {
                comboBox_SelCamera.Visible       = true;
                comboBox_SelCamera.SelectedIndex = 0;
            }
            else
            {
                visionControl1.Visible        = false;
                button_ContinuousSnap.Visible = false;
                button2.Visible = false;
                comboBox_SelVisionPR.Visible     = false;
                roundButton_VisionPrTest.Visible = false;
            }
            VisionMgr.GetInstance().PrItemChangedEvent += ChagedPrItem;
            ChagedPrItem("");
        }
Пример #8
0
        private void Form_CameraDebug_Load(object sender, EventArgs e)
        {
            visionControl1.InitWindow();
            HOperatorSet.SetDraw(visionControl1.GetHalconWindow(), "margin");
            Thread.Sleep(10);
            List <string> camname = CameraMgr.GetInstance().GetCameraNameArr();

            foreach (var temp in camname)
            {
                this.Sel.Items.Add(temp.ToString());
                comboBox_SelCam.Items.Add(temp.ToString());
                CameraMgr.GetInstance().ClaerPr(temp.ToString());
            }
            if (camname.Count > 0)
            {
                comboBox_SelCam.SelectedIndex = 0;
            }

            textBox_exposureTimeVal.Text = CameraMgr.GetInstance().GetCamExposure(comboBox_SelCam.Text).ToString();
            textBox_GainVal.Text         = CameraMgr.GetInstance().GetCamGain(comboBox_SelCam.Text).ToString();
            CameraMgr.GetInstance().BindWindow(comboBox_SelCam.Text, visionControl1);
            CameraMgr.GetInstance().SetAcquisitionMode(comboBox_SelCam.Text);
            UpdataVisionItems();
            ParamSetMgr.GetInstance().m_eventLoadProductFileUpadata += UpdataVisionItems;
        }
Пример #9
0
 // Start is called before the first frame update
 void Start()
 {
     player      = GetComponent <PlayerStatus>();
     animator    = GetComponent <Animator>();
     CMgr        = GameObject.Find("Players").GetComponent <CameraMgr>();
     new_anitype = player.anitype;
 }
Пример #10
0
        protected virtual IEnumerator <float> OnInPostEndTurn(T unit)
        {
            var data = GetMoveableUnits(unit);

            foreach (var item in data)
            {
                if (!item.MoveMgr.IsCanAutoExcuteMoveTarget())
                {
                    continue;
                }
                yield return(Timing.WaitForOneFrame);

                if (item.MoveMgr.ExcuteMoveTarget(false))
                {
                    if (item.IsPlayer())
                    {
                        CameraMgr.Jump(item);
                    }
                    //当单位正在移动或者暂停的时候,直接等待
                    while (
                        item.MoveMgr.IsMoving ||
                        IsPause
                        )
                    {
                        yield return(Timing.WaitForOneFrame);
                    }
                }
            }
        }
Пример #11
0
        private void OnShowChanged(object sender, EventArgs e)
        {
            List <string> camname = CameraMgr.GetInstance().GetCameraNameArr();

            foreach (var tem in camname)
            {
                CameraMgr.GetInstance().ClaerPr(tem);
            }
        }
Пример #12
0
    private void LateUpdate()
    {
        if (null == CameraMgr.GetIns())
        {
            return;
        }

        CameraMgr.GetIns().tLateUpdate();
    }
Пример #13
0
    //public Camera CamT;

    void Start()
    {
        string a = "Player(" + Game.Network.NetWork.Client_id.ToString() + ")";

        playerObj = GameObject.Find("Players").transform.Find(a).gameObject;
        player    = playerObj.GetComponent <PlayerStatus>();
        rigid     = GetComponent <Rigidbody>();
        CMgr      = GameObject.Find("Players").GetComponent <CameraMgr>();
    }
Пример #14
0
 private void OnMouseUp()
 {
     _isDraged = false;
     CameraMgr.Unlock();
     if (OnLeftUp != null)
     {
         OnLeftUp(this);
     }
 }
Пример #15
0
 private void comboBox_SelCamera_SelectedIndexChanged(object sender, EventArgs e)
 {
     for (int i = 0; i < comboBox_SelCamera.Items.Count; i++)
     {
         CameraMgr.GetInstance().SetTriggerSoftMode(comboBox_SelCamera.Items[i].ToString());
     }
     CameraMgr.GetInstance().BindWindow(comboBox_SelCamera.Text, visionControl1);
     CameraMgr.GetInstance().SetAcquisitionMode(comboBox_SelCamera.Text);
 }
Пример #16
0
    static int FocusMainCameraToPlayer(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        CameraMgr obj  = (CameraMgr)LuaScriptMgr.GetNetObjectSelf(L, 1, "CameraMgr");
        Transform arg0 = (Transform)LuaScriptMgr.GetUnityObject(L, 2, typeof(Transform));

        obj.FocusMainCameraToPlayer(arg0);
        return(0);
    }
Пример #17
0
    // Start is called before the first frame update
    void Start()
    {
        CMgr = GameObject.Find("Players").GetComponent <CameraMgr>();
        string a = "Player(" + Game.Network.NetWork.Client_id.ToString() + ")";

        player       = GameObject.Find("Players").transform.Find(a).gameObject.GetComponent <PlayerStatus>();
        is_collision = false;
        UI_conversation.SetActive(false);
        ani_type = 0;
    }
Пример #18
0
        private void BtnSanp_Click(object sender, EventArgs e)
        {
            string     strCamName = "Top";
            CameraBase cameraBase = CameraMgr.GetInstance().GetCamera(strCamName);

            cameraBase.StopGrap();
            cameraBase.BindWindow(visionControl1);
            cameraBase.SetTriggerMode(CameraModeType.Software);
            CameraMgr.GetInstance().GetCamera(strCamName).StartGrab();
            CameraMgr.GetInstance().GetCamera(strCamName).GarbBySoftTrigger();
        }
Пример #19
0
 private static void JSCleanSkybox(string _activity, string _params)
 {
     try
     {
         CameraMgr.CleanSkybox();
     }
     catch (System.Exception e)
     {
         onNotify("Parse json has error: " + e.Message);
     }
 }
Пример #20
0
 private void comboBox_SelCam_SelectedIndexChanged(object sender, EventArgs e)
 {
     for (int i = 0; i < comboBox_SelCam.Items.Count; i++)
     {
         CameraMgr.GetInstance().SetTriggerSoftMode(comboBox_SelCam.Items[i].ToString());
     }
     textBox_exposureTimeVal.Text = CameraMgr.GetInstance().GetCamExposure(comboBox_SelCam.Text).ToString();
     textBox_GainVal.Text         = CameraMgr.GetInstance().GetCamGain(comboBox_SelCam.Text).ToString();
     CameraMgr.GetInstance().BindWindow(comboBox_SelCam.Text, visionControl1);
     CameraMgr.GetInstance().SetAcquisitionMode(comboBox_SelCam.Text);
 }
Пример #21
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (main == null)
     {
         main = Camera.main;
     }
 }
Пример #22
0
 void Awake()
 {
     CMgr = GameObject.Find("Players").GetComponent <CameraMgr>();
     //string a = "Player(" + Game.Network.NetWork.Client_id.ToString() + ")";
     //player = GameObject.Find("Players").transform.Find(a).gameObject.GetComponent<PlayerStatus>();
     is_collision = false;
     UI_conversation.SetActive(false);
     ani_type  = 0;
     animator  = GetComponent <Animator>();
     coroutine = HPControl();
     StartCoroutine(coroutine);
 }
Пример #23
0
 public override void OnExit()
 {
     base.OnExit();
     cameraPosition = CameraMgr.position;
     cameraRotation = CameraMgr.rotation;
     ResourceMgr.ToggleAllGameObjects(false);
     CameraMgr.UseDefaultSkybox();
     foreach (string cloneUUID in triggers)
     {
         TriggerMgr.ToggleTrigger(cloneUUID, false);
     }
 }
Пример #24
0
 private void OnMouseDown()
 {
     MouseStartPos = Input.mousePosition;
     _isDraged     = true;
     CameraMgr.Lock();
     if (OnLeftDown != null)
     {
         OnLeftDown(this);
     }
     if (OnLeftClick != null)
     {
         OnLeftClick(this);
     }
 }
Пример #25
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        if (instance != this)
        {
            Destroy(instance);
        }

        DontDestroyOnLoad(instance);
    }
Пример #26
0
        private void button_ContinuousSnap_Click(object sender, EventArgs e)
        {
            if (comboBox_SelCamera.SelectedItem == null)
            {
                return;
            }
            CameraMgr.GetInstance().BindWindow(comboBox_SelCamera.Text, visionControl1);
            CameraBase pCamer = CameraMgr.GetInstance().GetCamera(comboBox_SelCamera.SelectedItem.ToString());

            pCamer.SetTriggerMode(CameraModeType.Software);
            Thread.Sleep(100);
            CameraMgr.GetInstance().GetCamera(comboBox_SelCamera.SelectedItem.ToString()).SetAcquisitionMode();
            // CameraMgr.GetInstance().GetCamera(comboBox_SelCamera.SelectedItem.ToString()).wnd = hWindowControl1.HalconID;
            CameraMgr.GetInstance().GetCamera(comboBox_SelCamera.SelectedItem.ToString()).StartGrab();
        }
Пример #27
0
//
//        private static void charaBones2()
//        {
//            foreach (var objectCtrlInfo in Context.Studio().dicInfo.Values)
//            {
//                if (objectCtrlInfo.kind == 0)
//                {
//                    Logger.Log("has kind = 0");
//                    OCIChar ocichar = objectCtrlInfo as OCIChar;
//                    if (ocichar == null)
//                    {
//                        Logger.Log("ocichar is null");
//                    }
//                    else if (ocichar.charInfo == null)
//                    {
//                        Logger.Log("ocichar info is null");
//                    }
//                    else
//                    {
//                        var character = ocichar.charInfo;
//                        string prefix = character is CharFemale ? "cf_" : "cm_";
//                        List<GameObject> normalTargets = new List<GameObject>();
//                        var list = new List<GameObject>();
//                        character.chaBody.objBone.transform.FindLoopAll(list);
//                        list.ForEach(item => { Logger.Log(Kit.GetGameObjectPathAndPos(item)); });
//                        Logger.Log(list.Count + "");
////                            foreach(string targetName in FileManager.GetNormalTargetNames())
////                            {
////                                GameObject bone = character.chaBody.objBone.transform.FindLoop(prefix + targetName);
////                                if(bone) normalTargets.Add(bone);
////                            }
////                            return normalTargets;
//                    }
//                    GuideObjectManager instance = Singleton<GuideObjectManager>.Instance;
//                    foreach (GuideObject guideObject in instance.selectObjects)
//                    {
//                        //                    if (guideObject.enableRot)
//                        //                    {
//                        var p0 = guideObject.transform.position;
//                        var p1 = guideObject.transformTarget.position;
//                        var g0 = guideObject.gameObject;
//                        var g1 = guideObject.transformTarget.gameObject;
//                        Logger.Log(Kit.VecStr(p0));
//                        Logger.Log(Kit.GetGameObjectPathAndPos(g0));
//                        Logger.Log(Kit.VecStr(p1));
//                        Logger.Log(Kit.GetGameObjectPathAndPos(g1));
//                        guideObject.transformTarget.gameObject.transform.Rotate(10, 0, 0);
//                        //                    }
//                    }
//                }
//            }
//        }

        #endregion

        public static Vector3 MapScreenVecToWorld(Vector3 screenVec, Vector3 pos)
        {
            var screenZ     = CameraMgr.MainCamera().WorldToScreenPoint(pos).z;
            var screenStart = Vector3.zero;

            screenStart.z = screenZ;
            var screenEnd = screenVec;

            screenEnd.z = screenZ;
            var worldStart = CameraMgr.MainCamera().ScreenToWorldPoint(screenStart);
            var worldEnd   = CameraMgr.MainCamera().ScreenToWorldPoint(screenEnd);
            var end        = pos + (worldEnd - worldStart);

            return(end);
        }
Пример #28
0
        private void ContinuousSnap_Click(object sender, EventArgs e)
        {
            string     strCamName = "Top";
            CameraBase cameraBase = CameraMgr.GetInstance().GetCamera(strCamName);

            cameraBase.StopGrap();
            cameraBase.SetTriggerMode(CameraModeType.Software);

            double valexposure = cameraBase.GetExposureTime();
            double valgain     = cameraBase.GetGain();

            cameraBase.BindWindow(visionControl1);
            cameraBase.SetAcquisitionMode();
            cameraBase.StartGrab();
        }
Пример #29
0
        private void roundButton_ContinuousSnap_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < comboBox_SelCam.Items.Count; i++)
            {
                CameraMgr.GetInstance().SetTriggerSoftMode(comboBox_SelCam.Items[i].ToString());
            }

            CameraMgr.GetInstance().BindWindow(comboBox_SelCam.Text, visionControl1);
            CameraMgr.GetInstance().SetAcquisitionMode(comboBox_SelCam.Text);
            CameraMgr.GetInstance().GetCamera(comboBox_SelCam.Text).StartGrab();
            // textBox_exposureTimeVal.Text = CameraMgr.GetInstance().GetCamExposure(comboBox_SelCam.Text).ToString();
            //  textBox_GainVal.Text = CameraMgr.GetInstance().GetCamGain(comboBox_SelCam.Text).ToString();
            CameraMgr.GetInstance().SetCamExposure(comboBox_SelCam.Text, textBox_exposureTimeVal.Text.ToDouble());
            CameraMgr.GetInstance().SetCamGain(comboBox_SelCam.Text, textBox_GainVal.Text.ToDouble());
        }
Пример #30
0
    void Start()
    {
        speedR = 3;

        CMgr      = GetComponent <CameraMgr>();
        hp        = 100;
        coroutine = HPControl();
        StartCoroutine(coroutine);

        if (ID == Game.Network.NetWork.Client_id)
        {
            SetLayersRecursively(this.gameObject.transform, "myPlayer");
            transform.GetChild(2).gameObject.layer = LayerMask.NameToLayer("PlayerMarker");
        }
    }
Пример #31
0
 void Awake()
 {
     Instance = this;
 }
Пример #32
0
 public void Awake()
 {
     _instance = this;
     //TargetComponent = Camera.main.gameObject.AddComponent<BaseObject>();
 }
Пример #33
0
	// Awake
	void Awake()
	{
		ms_kIstance = this;
		InitCameraData();
		//m_fZoomData = CameraMgr.MaxZoomInDistance - ( CameraMgr.MaxZoomInDistance * 0.8f);
		m_fZoomData = 0;
	}