private void Btn_WrPrm_Click(object sender, EventArgs e)
        {
            short  PrmAxis    = short.Parse(TB_PrmAxisW.Text);
            int    PrmNo      = int.Parse(TB_PrmNumW.Text);
            int    PrmVal     = int.Parse(TB_PrmValW.Text);
            String WPrmStatus = Itri2Fanuc.WriteParameterVal(PrmAxis, PrmNo, PrmVal);

            if (WPrmStatus.Equals("EW_OK"))
            {
                double[] PrmVals = new double[3];
                String   ret     = Itri2Fanuc.ReadParameterVal(PrmNo);
                TB_WrPrmVal.Text = ret;
            }
            else
            {
                MessageBox.Show(WPrmStatus, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #2
0
        public string FrqResponseStart(short Axis, int FrqStart, int FrqEnd, int DisAmp, int WaveNum, int PosGain)
        {
            double SmplTime = 0;

            if (FrqStart < 10)
            {
                for (double i = FrqStart; i <= 9; i++)
                {
                    SmplTime += (1 / i) * 1000 * 4 * WaveNum;
                }
                for (double i = 10; i < FrqEnd; i += 5)
                {
                    SmplTime += (1 / i) * 1000 * 4 * WaveNum;
                }
            }
            else
            {
                FrqStart = (FrqStart / 5) * 5;
                for (double i = FrqStart; i < FrqEnd; i += 5)
                {
                    SmplTime += (1 / i) * 1000 * 4 * WaveNum;
                }
            }

            sbyte[] SmplAxis = new sbyte[3] {
                (sbyte)(Axis), (sbyte)(Axis), (sbyte)(Axis)
            };
            short[] SmplType = new short[3] {
                3, 32, 31
            };
            string ret = Itri2Fanuc_func.SamplingStart(3, SmplAxis, SmplType, 512, (int)SmplTime + 4000, 0);

            if (ret != "EW_OK")
            {
                return("SamplingStart Error : " + ret);
            }
            Itri2Fanuc_func.ReadParameterVal(2326);
            Org_Value[0] = Itri2Fanuc_func.PrmContainer[Axis - 1];
            Itri2Fanuc_func.ReadParameterVal(2327);
            Org_Value[1] = Itri2Fanuc_func.PrmContainer[Axis - 1];
            Itri2Fanuc_func.ReadParameterVal(2328);
            Org_Value[2] = Itri2Fanuc_func.PrmContainer[Axis - 1];
            Itri2Fanuc_func.ReadParameterVal(2329);
            Org_Value[3] = Itri2Fanuc_func.PrmContainer[Axis - 1];
            Itri2Fanuc_func.ReadParameterVal(1825);
            Org_Value[4] = Itri2Fanuc_func.PrmContainer[Axis - 1];
            ret          = Itri2Fanuc_func.WriteParameterVal(Axis, 2326, DisAmp);
            if (ret != "EW_OK")
            {
                return("Error(No.2326) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2327, FrqStart);
            if (ret != "EW_OK")
            {
                return("Error(No.2327) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2328, FrqEnd);
            if (ret != "EW_OK")
            {
                return("Error(No.2327) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2329, WaveNum);
            if (ret != "EW_OK")
            {
                return("Error(No.2329) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 1825, PosGain);
            if (ret != "EW_OK")
            {
                return("Error(No.1825) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2270, 128);
            if (ret != "EW_OK")
            {
                return("Error(No.2270) : " + ret);
            }
            return("Start input disturbance");
        }
        public string FrqResponseStart(short Axis, int FrqStart, int FrqEnd, int DisAmp, int WaveNum, int PosGain)
        {
            Org_Value[0] = Itri2Fanuc_func.ReadParameterVal(2326);
            Org_Value[1] = Itri2Fanuc_func.ReadParameterVal(2327);
            Org_Value[2] = Itri2Fanuc_func.ReadParameterVal(2328);
            Org_Value[3] = Itri2Fanuc_func.ReadParameterVal(2329);
            Org_Value[4] = Itri2Fanuc_func.ReadParameterVal(1825);
            string ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2326, DisAmp);

            if (ret != "EW_OK")
            {
                return("Error(No.2326) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2327, FrqStart);
            if (ret != "EW_OK")
            {
                return("Error(No.2327) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2328, FrqEnd);
            if (ret != "EW_OK")
            {
                return("Error(No.2327) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2329, WaveNum);
            if (ret != "EW_OK")
            {
                return("Error(No.2329) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 1825, PosGain);
            if (ret != "EW_OK")
            {
                return("Error(No.1825) : " + ret);
            }
            ret = Itri2Fanuc_func.WriteParameterVal(Axis, 2270, 128);
            if (ret != "EW_OK")
            {
                return("Error(No.2270) : " + ret);
            }
            return("Start input disturbance");
        }