private void msubClearVars()
        {
            mobjCore.Disconnect();

            mobjCore                 = null;
            mobjDataTable            = null;
            mobjDataTable2           = null;
            mobjAlarm                = null;
            mobjAlarmCurrent         = null;
            mobjCurPos               = null;
            mobjCurPos2              = null;
            mobjTask                 = null;
            mobjTaskIgnoreMacro      = null;
            mobjTaskIgnoreKarel      = null;
            mobjTaskIgnoreMacroKarel = null;
            mobjPosReg               = null;
            mobjPosReg2              = null;
            mobjSysVarInt            = null;
            mobjSysVarReal           = null;
            mobjSysVarReal2          = null;
            mobjSysVarString         = null;
            mobjSysVarPos            = null;
            mobjNumReg               = null;
            mobjNumReg2              = null;
            mobjNumReg3              = null;
            mobjVarString            = null;
            mobjStrReg               = null;
            mobjStrRegComment        = null;
            for (int ii = mobjSysVarIntArray.GetLowerBound(0); ii <= mobjSysVarIntArray.GetUpperBound(0); ii++)
            {
                mobjSysVarIntArray[ii] = null;
            }
        }
        private void msubInit(string strHost)
        {
            mobjCore = new FRRJIf.Core();

            // You need to set data table before connecting.
            mobjDataTable = mobjCore.DataTable;

            {
                mobjAlarm                = mobjDataTable.AddAlarm(FRRJIf.FRIF_DATA_TYPE.ALARM_LIST, 5, 0);
                mobjAlarmCurrent         = mobjDataTable.AddAlarm(FRRJIf.FRIF_DATA_TYPE.ALARM_CURRENT, 1, 0);
                mobjCurPos               = mobjDataTable.AddCurPos(FRRJIf.FRIF_DATA_TYPE.CURPOS, 1);
                mobjCurPosUF             = mobjDataTable.AddCurPosUF(FRRJIf.FRIF_DATA_TYPE.CURPOS, 1, 15);
                mobjCurPos2              = mobjDataTable.AddCurPos(FRRJIf.FRIF_DATA_TYPE.CURPOS, 2);
                mobjTask                 = mobjDataTable.AddTask(FRRJIf.FRIF_DATA_TYPE.TASK, 1);
                mobjTaskIgnoreMacro      = mobjDataTable.AddTask(FRRJIf.FRIF_DATA_TYPE.TASK_IGNORE_MACRO, 1);
                mobjTaskIgnoreKarel      = mobjDataTable.AddTask(FRRJIf.FRIF_DATA_TYPE.TASK_IGNORE_KAREL, 1);
                mobjTaskIgnoreMacroKarel = mobjDataTable.AddTask(FRRJIf.FRIF_DATA_TYPE.TASK_IGNORE_MACRO_KAREL, 1);
                mobjPosReg               = mobjDataTable.AddPosReg(FRRJIf.FRIF_DATA_TYPE.POSREG, 1, 1, 10);
                mobjPosReg2              = mobjDataTable.AddPosReg(FRRJIf.FRIF_DATA_TYPE.POSREG, 2, 1, 4);
                mobjSysVarInt            = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$FAST_CLOCK");
                mobjSysVarInt2           = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[10].$TIMER_VAL");
                mobjSysVarReal           = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_REAL, "$MOR_GRP[1].$CURRENT_ANG[1]");
                mobjSysVarReal2          = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_REAL, "$DUTY_TEMP");
                mobjSysVarString         = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_STRING, "$TIMER[10].$COMMENT");
                mobjSysVarPos            = mobjDataTable.AddSysVarPos(FRRJIf.FRIF_DATA_TYPE.SYSVAR_POS, "$MNUTOOL[1,1]");
                mobjVarString            = mobjDataTable.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_STRING, "$[HTTPKCL]CMDS[1]");
                mobjNumReg               = mobjDataTable.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, 1, 5);
                mobjNumReg2              = mobjDataTable.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_REAL, 6, 10);
                mobjPosRegXyzwpr         = mobjDataTable.AddPosRegXyzwpr(FRRJIf.FRIF_DATA_TYPE.POSREG_XYZWPR, 1, 1, 10);
                mobjPosRegMG             = mobjDataTable.AddPosRegMG(FRRJIf.FRIF_DATA_TYPE.POSREGMG, "C,J6", 1, 10);
                mobjStrReg               = mobjDataTable.AddString(FRRJIf.FRIF_DATA_TYPE.STRREG, 1, 3);
                mobjStrRegComment        = mobjDataTable.AddString(FRRJIf.FRIF_DATA_TYPE.STRREG_COMMENT, 1, 3);
            }

            // 2nd data table.
            // You must not set the first data table.
            mobjDataTable2        = mobjCore.DataTable2;
            mobjNumReg3           = mobjDataTable2.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, 1, 5);
            mobjSysVarIntArray    = new FRRJIf.DataSysVar[10];
            mobjSysVarIntArray[0] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[1].$TIMER_VAL");
            mobjSysVarIntArray[1] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[2].$TIMER_VAL");
            mobjSysVarIntArray[2] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[3].$TIMER_VAL");
            mobjSysVarIntArray[3] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[4].$TIMER_VAL");
            mobjSysVarIntArray[4] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[5].$TIMER_VAL");
            mobjSysVarIntArray[5] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[6].$TIMER_VAL");
            mobjSysVarIntArray[6] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[7].$TIMER_VAL");
            mobjSysVarIntArray[7] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[8].$TIMER_VAL");
            mobjSysVarIntArray[8] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[9].$TIMER_VAL");
            mobjSysVarIntArray[9] = mobjDataTable2.AddSysVar(FRRJIf.FRIF_DATA_TYPE.SYSVAR_INT, "$TIMER[10].$TIMER_VAL");



            mobjCore.Connect(strHost);
        }
示例#3
0
文件: Robot.cs 项目: lefoz/InroTech
        //INITIALIZE, CONNECT, CONSTRUCT DATATABLES
        public void subInit(string[] selectedReg)
        {
            //Set core
            try
            {
                objCore = new FRRJIf.Core();

                objSelectedReg = new FRRJIf.DataNumReg[selectedReg.Length];

                //parse string[] to int[]
                selectedRegArr = Array.ConvertAll(selectedReg, int.Parse);

                //tasklist return object
                taskArr = new string[10];

                //init datatable return objects
                dt_Selected = new System.Data.DataTable();
                dt_Selected.Clear();
                dt_Selected.Columns.Add("id", typeof(int));
                dt_Selected.Columns.Add("Registry", typeof(int));
                dt_Selected.Columns.Add("Value", typeof(double));
                dt_Selected.Columns.Add("Selected", typeof(bool));

                //welding params
                voltage = 0;
                amp     = 0;

                try
                {
                    //Set FANUC datatable1
                    objDataTable1 = objCore.get_DataTable();

                    //robotinfo
                    numRegJob    = objDataTable1.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, 2, 2);
                    numRegofJob  = objDataTable1.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, 3, 3);
                    objRobotName = objDataTable1.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, 5, 5);

                    //selected numregs
                    for (int i = 0; i < objSelectedReg.Length; i++)
                    {
                        objSelectedReg[i] = objDataTable1.AddNumReg(FRRJIf.FRIF_DATA_TYPE.NUMREG_INT, selectedRegArr[i], selectedRegArr[i]);
                    }

                    //10 data tasks
                    objTaskList = new FRRJIf.DataTask[10];
                    for (int i = 0; i < objTaskList.Length; i++)
                    {
                        objTaskList[i] = objDataTable1.AddTask(FRRJIf.FRIF_DATA_TYPE.TASK, i + 1);
                    }
                    isInit = true;
                    return;
                }
                catch (Exception ex)
                {
                    //handle ex
                    Console.WriteLine(ex.ToString());
                }
            }
            catch
            {
                Console.WriteLine("error..");
            }
        }