Beispiel #1
0
        private bool WaitForMoved(int timeOut = 5000)
        {
            object vntValue = null;

            Alarm[]   alarms;
            float[]   previousPos = GetCurrentPos();
            Stopwatch sw          = null;

            do
            {
                RefreshDataTable();
                _NumReg.GetValue(_NumReg.StartIndex, ref vntValue);
                alarms = CurrentAlarms(1);
                if (alarms[0].IsAlert)
                {
                    return(false);
                }
                var curentPos = GetCurrentPos();
                if (Enumerable.SequenceEqual(previousPos, curentPos))
                {
                    if (sw == null)
                    {
                        sw = new Stopwatch();
                        sw.Start();
                    }

                    if (sw.ElapsedMilliseconds > timeOut)
                    {
                        return(false);
                    }
                }
                else
                {
                    sw = null;
                }
            } while ((int)vntValue == 1);
            return(true);
        }
Beispiel #2
0
        //refresh datatable1
        private void refresh_dt1()
        {
            //init
            short  intLine = 0, intState = 0;
            object vntValue = null, jobValue = null, nameValue = null;
            string strProg = "", strParentProg = "";
            Array  lngAI        = new int[2];
            bool   validRefresh = false;

            var dtTemp = dt_Selected.Clone();

            //datatable gets refreshed
            validRefresh = objDataTable1.Refresh();

            //if refresh failed, disconnect
            if (validRefresh == false)
            {
                objCore.Disconnect();
                Console.WriteLine("Disconnecting - refresh failed");
                return;
            }

            //DATA FORMATTING
            //NUMERIC REGISTERS
            for (int i = 0; i <= objSelectedReg.Length - 1; i++)
            {
                if (objSelectedReg[i].GetValue(selectedRegArr[i], ref vntValue) == true)
                {
                    //add data to return-datatable  {id,regnr,value,bool}
                    dtTemp.Rows.Add(new object[] { selectedRegArr[i], selectedRegArr[i], vntValue, false });
                }
                else
                {
                    dtTemp.Rows.Add(new object[] { selectedRegArr[i], selectedRegArr[i], null, false });
                }
            }
            dt_Selected = dtTemp;


            //TASKS
            for (int i = objTaskList.GetLowerBound(0); i <= objTaskList.GetUpperBound(0); i++)
            {
                if (objTaskList[i].GetValue(ref strProg, ref intLine, ref intState, ref strParentProg))
                {
                    //if empty, exit to outer loop
                    if (strProg == "")
                    {
                        break;
                    }
                    taskArr[i] = "TASK " + objTaskList[i].Index + "  -  Program: " + strProg + "  -  Line: " + intLine + "  -  State: " + intState + "  -  Parent: " + strParentProg;
                }
                else
                {
                    taskArr[i] = "TASK " + objTaskList[i].Index + "  -  ERROR";
                }
            }

            //ANALOG IO
            //read AnalogOut - offset 1000 to get AO as in FANUC documentation
            {
                //read AnalogIn - offset 1000 to get AI as in FANUC documentation
                if (objCore.ReadGI(1000 + 1, ref lngAI, 2) == false)
                {
                    Console.WriteLine("Disconnected - read AI fail");
                    objCore.Disconnect();
                    return;
                }
                voltage = (int)lngAI.GetValue(1);
                amp     = (int)lngAI.GetValue(0);
            }

            //TASKNR of total tasks & NAME
            if (numRegJob.GetValue(0, ref jobValue) == true)
            {
                job = "" + jobValue;
            }
            if (numRegofJob.GetValue(0, ref jobValue) == true)
            {
                ofJob = "" + jobValue;
            }
            if (objRobotName.GetValue(0, ref nameValue) == true)
            {
                robotName = "" + nameValue;
            }
        }