IEnumerator Move(gcLine moveTo)
    {
        float         distanceThreshold = 0.1f;
        CncCartDouble position          = new CncCartDouble();

        position.x = (double)moveTo.X;
        position.y = (double)moveTo.Y;
        position.z = (double)moveTo.Z;
        CncCartBool Cncbool = new CncCartBool();

        Cncbool.x = 1;
        Cncbool.y = 1;
        Cncbool.z = 1;
        Cncbool.a = 1;
        Cncbool.b = 1;
        Cncbool.c = 1;
        while (Vector3.Distance(HeadPosition, new Vector3((float)moveTo.X, (float)moveTo.Y, (float)moveTo.Z)) < distanceThreshold)
        {
            g_JoggingFunctions.MoveTo(position, Cncbool, (double)moveTo.F);
            yield return(null);
        }
        DoneWithLine = true;
        Moving       = false;
        movee        = false;
        yield return(null);
    }
 // Update is called once per frame
 void Update()
 {
     if (_Connected)
     {
         CncCartDouble machinePos = G_StatusItemsposition.GetMachinePosition();//do not use the static CncGetMachinePosition() !!!
         if (machinePos != null)
         {
             HeadPosition = new Vector3((float)machinePos.x, (float)machinePos.y, (float)machinePos.z);
         }
         else
         {
             _Connected = false;
         }
     }
 }
예제 #3
0
        private void  ConnectCncServer_Click(object sender, EventArgs e)
        {
            Cnc_Rc Rc = G_GetCncServer.ConnectServer("");

            if (Rc == Cnc_Rc.CNC_RC_OK || Rc == Cnc_Rc.CNC_RC_ALREADY_RUNS || Rc == Cnc_Rc.CNC_RC_ALREADY_CONNECTED)
            {
                if (BindingIsset == false)
                {
                    BindingIsset = true;

                    //Configuration for workposition:
                    DataSource_WorkPostion = G_StatusItemsposition.GetWorkPosition();
                    MethodInfo Method_GetWorkPosition = typeof(G_StatusItemsposition).GetMethod(nameof(G_StatusItemsposition.GetWorkPosition));           //method to invoke every time when check on value changes
                    NotifyPropertyChanged_WorkPosition = new NotifyCncApiPropertyChanged <CncCartDouble>(DataSource_WorkPostion, Method_GetWorkPosition); //extra method is required because G_StatusItemsposition.GetWorkPosition(); contains not a pointer to the CncServer
                    CancelToken = new CancellationTokenSource();


                    AxisX.DataBindings.Add(nameof(TextBox.Text), DataSource_WorkPostion, nameof(CncCartDouble.x));
                    AxisY.DataBindings.Add(nameof(TextBox.Text), DataSource_WorkPostion, nameof(CncCartDouble.y), true, DataSourceUpdateMode.OnPropertyChanged, "0", "0.00");
                    AxisZ.DataBindings.Add(nameof(TextBox.Text), DataSource_WorkPostion, nameof(CncCartDouble.z), true, DataSourceUpdateMode.OnPropertyChanged, "0", "0.000");



                    //Configuration items JointConfig
                    DataSource_JointConfig            = G_GetConfigItems.GetAllJointConfig();
                    NotifyPropertyChanged_JointConfig = new NotifyCncApiPropertyChanged <CncJointCfg> [DataSource_JointConfig.Length];
                    for (int i = 0; i < DataSource_JointConfig.Length; i++)
                    {
                        NotifyPropertyChanged_JointConfig[i] = new NotifyCncApiPropertyChanged <CncJointCfg>(DataSource_JointConfig[i]);//Note: no methodinfo parameter used. G_GetConfigItems.GetAllJointConfig(); method contains a pointer to the CncServer. this is not the case by G_StatusItemsposition.GetWorkPosition();
                    }
                    PosLimit_X.DataBindings.Add(nameof(TextBox.Text), DataSource_JointConfig[0], nameof(CncJointCfg.positiveLimit), false, DataSourceUpdateMode.OnPropertyChanged);
                    PosLimit_Y.DataBindings.Add(nameof(TextBox.Text), DataSource_JointConfig[1], nameof(CncJointCfg.positiveLimit), false, DataSourceUpdateMode.OnPropertyChanged);
                    PosLimit_Z.DataBindings.Add(nameof(TextBox.Text), DataSource_JointConfig[2], nameof(CncJointCfg.positiveLimit), false, DataSourceUpdateMode.OnPropertyChanged);

                    //Check the CncServer values. Interval time can be changed in the UI
                    CncServerVars();
                }

                MessageBox.Show("CncRc State:" + Rc.ToString(), "CncServer is connected ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("CncRc State:" + Rc.ToString(), "CncServer ConnectServer Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                G_GetCncServer.DisConnectServer();
            }
        }