Esempio n. 1
0
        /// <summary>
        /// 获得进给速度
        /// </summary>
        public string GetFeedingSpeed(ushort Flibhndl)
        {
            Focas1.ODBACT odbaxis = new Focas1.ODBACT();
            short         ret     = Focas1.cnc_actf(Flibhndl, odbaxis);

            return(odbaxis.data.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// Read Machine Spindle RPM Data (MachineSpindle)
        /// </summary>
        private void CallActS()
        {
            try
            {
                Focas1.ODBACT odbAct = new Focas1.ODBACT();

                focasReturn = Focas1.cnc_acts(fanucHandle, odbAct);

                if (focasReturn == EW_OK)
                {
                    base.SetDictionary(base.SPINDLE, 0, odbAct.data);

                    LogHandler.WriteLog(base.division, string.Format("{0} :: CallActS() Success :: STATUS = {1}", this.ToString(), base.SPINDLE[0]));
                }
                else if (focasReturn == EW_SOCKET)
                {
                    base.isConnect = false;
                    LogHandler.WriteLog(base.division, string.Format("{0} :: CallActS() Fail :: SocketError", this.ToString()));
                }
                else
                {
                    LogHandler.WriteLog(base.division, string.Format("{0} :: CallActS() Fail :: ReturnCode = {1}", this.ToString(), focasReturn));
                }
            }
            catch (Exception ex)
            {
                LogHandler.WriteLog(base.division, string.Format("{0} :: CallActS() Exception :: Message = {1}", this.ToString(), ex.Message));
            }
        }
Esempio n. 3
0
        //读CNC伺服轴的实际进给倍率
        #region cnc_actf
        short IMachineFanuc.GetActFeedrate(out long actFeedrate)
        {
            Focas1.ODBACT odbact_ActF = new Focas1.ODBACT();
            short         ret         = Focas1.cnc_actf(mFlibhndl, odbact_ActF);

            actFeedrate = odbact_ActF.data;
            return(ret);
        }
Esempio n. 4
0
        //进给速度
        private int GetFeedRateValue(ushort handle, out string error)
        {
            error = "";
            //进给速度
            Focas1.ODBACT actf = new Focas1.ODBACT();
            short         nRet = Focas1.cnc_actf(handle, actf);

            if (nRet == Focas1.EW_OK)
            {
                return(actf.data);
            }

            error = $"读取错误!错误代号[{nRet}]";
            return(0);
        }
Esempio n. 5
0
        //主轴转速
        private string GetSPSpeed(ushort handle, out string error)
        {
            error = "";
            //主轴转速
            Focas1.ODBACT odbspeed = new Focas1.ODBACT();

            short nRet = Focas1.cnc_acts(handle, odbspeed);

            if (nRet == Focas1.EW_OK)
            {
                return(odbspeed.data.ToString());
            }

            error = $"读取错误!错误代号[{nRet}]";
            return("");
        }
Esempio n. 6
0
        public Tuple <short, string> ReadFeedrate(ushort flib, ref ReadFeedrateResultModel data)
        {
            Focas1.ODBACT buf = new Focas1.ODBACT();
            var           ret = Focas1.cnc_actf(flib, buf);

            if (ret == 0)
            {
                data.Value = buf.data;


                return(new Tuple <short, string>(0, null));
            }
            else
            {
                return(new Tuple <short, string>(ret, $"读取进给F信息错误,返回:{ret}"));
            }
        }
Esempio n. 7
0
        //进给速度
        private static int GetFeedRateValue(string deviceAddress, out string error)
        {
            error = "";
            //进给速度
            ushort m_handle;

            Focas1.ODBACT actf = new Focas1.ODBACT();
            short         nRet = Focas1.cnc_allclibhndl3(deviceAddress, 8193, 2, out m_handle);

            if (nRet == Focas1.EW_OK)
            {
                nRet = Focas1.cnc_actf(m_handle, actf);
            }

            if (nRet == Focas1.EW_OK)
            {
                Focas1.cnc_freelibhndl(m_handle); //释放连接
                return(actf.data);
            }

            error = "连接失败";
            return(0);
        }
Esempio n. 8
0
        public string read()
        {
            if (!isOpened)
            {
                throw new Exception("Must open cnc connection first!");
            }
            // logger.Info("Target ip: " + host + "; port: " + port);
            JObject resp = new JObject();

            resp["systemtime"]               = DateTime.Now.ToString() + "." + DateTime.Now.Millisecond.ToString();
            resp["centername"]               = "加工中心";
            resp["txtip"]                    = host;
            resp["machinename"]              = "FANUC Series 32i";
            resp["spec"]                     = "5505";
            resp["x_relative"]               = null;
            resp["z_relative"]               = null;
            resp["c_relative"]               = null;
            resp["v_relative"]               = null;
            resp["x_absolute"]               = null;
            resp["z_absolute"]               = null;
            resp["c_absolute"]               = null;
            resp["v_absolute"]               = null;
            resp["x_machine"]                = null;
            resp["z_machine"]                = null;
            resp["c_machine"]                = null;
            resp["v_machine"]                = null;
            resp["x_distancetogo"]           = null;
            resp["z_distancetogo"]           = null;
            resp["c_distancetogo"]           = null;
            resp["v_distancetogo"]           = null;
            resp["spindle_name"]             = null;
            resp["spindlenumber"]            = 1;
            resp["spindleload"]              = null;
            resp["spindlespeed"]             = null;
            resp["sv1_load"]                 = null;
            resp["sv2_load"]                 = null;
            resp["sv3_load"]                 = null;
            resp["sv4_load"]                 = null;
            resp["cnc_status"]               = null;
            resp["runningmode"]              = null;
            resp["currentrunningprogramnum"] = null;
            resp["mainprogramnumber"]        = null;
            resp["currentrunningncprogram"]  = null;
            resp["currenttoolgroupnum"]      = null;
            resp["currenttoolnum"]           = null;
            resp["svnum"]                    = null;
            resp["cnc_versionnum"]           = "3C7B5D01";
            resp["relfeedrate"]              = null;
            resp["alarm_status"]             = null;
            resp["alarmnum"]                 = null;
            resp["alarmtype"]                = null;
            resp["alarmmessage"]             = null;
            resp["operatingtime"]            = null;
            resp["circlingtime"]             = null;
            resp["cuttingtime"]              = null;
            resp["powerontime"]              = null;
            resp["totalparts"]               = null;
            resp["cnc_turn_on"]              = "开机";
            short code;

            {
                short         number = Focas1.MAX_AXIS;
                Focas1.ODBPOS pos    = new Focas1.ODBPOS();
                code = Focas1.cnc_rdposition(pHdl, -1, ref number, pos);
                if (code == 0)
                {
                    resp["x_relative"]     = pos.p1.rel.data * Math.Pow(10, -pos.p1.rel.dec);
                    resp["z_relative"]     = pos.p2.rel.data * Math.Pow(10, -pos.p2.rel.dec);
                    resp["c_relative"]     = pos.p4.rel.data * Math.Pow(10, -pos.p4.rel.dec);
                    resp["v_relative"]     = pos.p5.rel.data * Math.Pow(10, -pos.p5.rel.dec);
                    resp["x_absolute"]     = pos.p1.abs.data * Math.Pow(10, -pos.p1.abs.dec);
                    resp["z_absolute"]     = pos.p2.abs.data * Math.Pow(10, -pos.p2.abs.dec);
                    resp["c_absolute"]     = pos.p4.abs.data * Math.Pow(10, -pos.p4.abs.dec);
                    resp["v_absolute"]     = pos.p5.abs.data * Math.Pow(10, -pos.p5.abs.dec);
                    resp["x_machine"]      = pos.p1.mach.data * Math.Pow(10, -pos.p1.mach.dec);
                    resp["z_machine"]      = pos.p2.mach.data * Math.Pow(10, -pos.p2.mach.dec);
                    resp["c_machine"]      = pos.p4.mach.data * Math.Pow(10, -pos.p4.mach.dec);
                    resp["v_machine"]      = pos.p5.mach.data * Math.Pow(10, -pos.p5.mach.dec);
                    resp["x_distancetogo"] = pos.p1.dist.data * Math.Pow(10, -pos.p1.dist.dec);
                    resp["z_distancetogo"] = pos.p2.dist.data * Math.Pow(10, -pos.p2.dist.dec);
                    resp["c_distancetogo"] = pos.p4.dist.data * Math.Pow(10, -pos.p4.dist.dec);
                    resp["v_distancetogo"] = pos.p5.dist.data * Math.Pow(10, -pos.p5.dist.dec);
                }
            }
            {
                short number = 32;
                Focas1.ODBEXAXISNAME spindleName = new Focas1.ODBEXAXISNAME();
                code = Focas1.cnc_exaxisname(pHdl, 1, ref number, spindleName);
                if (code == 0)
                {
                    resp["spindle_name"] = spindleName.axname1;
                }
            }
            {
                Focas1.ODBSVLOAD sv    = new Focas1.ODBSVLOAD();
                Focas1.ODBSPLOAD sp    = new Focas1.ODBSPLOAD();
                short            a     = 6;
                short            code0 = Focas1.cnc_rdsvmeter(pHdl, ref a, sv);
                short            code1 = Focas1.cnc_rdspmeter(pHdl, 1, ref a, sp);
                if (code0 == 0)
                {
                    resp["sv1_load"] = sv.svload1.data;
                    resp["sv2_load"] = sv.svload2.data;
                    resp["sv3_load"] = sv.svload3.data;
                    resp["sv4_load"] = sv.svload4.data;
                }
                if (code1 == 0)
                {
                    resp["spindleload"] = sp.spload1.spload.data;
                }
            }
            {
                Focas1.ODBACT pindle = new Focas1.ODBACT();
                code = Focas1.cnc_acts(pHdl, pindle);
                if (code == 0)
                {
                    resp["spindlespeed"] = pindle.data;
                }
            }
            {
                Focas1.ODBST obst = new Focas1.ODBST();
                code = Focas1.cnc_statinfo(pHdl, obst);
                if (code == 0)
                {
                    resp["cnc_status"]   = obst.run;
                    resp["runningmode"]  = obst.tmmode;
                    resp["alarm_status"] = obst.alarm;
                }
            }
            {
                Focas1.ODBDY2_1 dynadata = new Focas1.ODBDY2_1();
                Focas1.ODBPRO   pro      = new Focas1.ODBPRO();
                Focas1.ODBSEQ   seqnum   = new Focas1.ODBSEQ();
                code = Focas1.cnc_rdprgnum(pHdl, pro);
                if (code == 0)
                {
                    resp["currentrunningprogramnum"] = pro.data;
                    resp["mainprogramnumber"]        = pro.mdata;
                }
                code = Focas1.cnc_rdseqnum(pHdl, seqnum);
                if (code == 0)
                {
                    resp["currentrunningncprogram"] = seqnum.data;
                }
            }
            {
                Focas1.ODBTG     btg = new Focas1.ODBTG();
                Focas1.ODBUSEGRP grp = new Focas1.ODBUSEGRP();
                code = Focas1.cnc_rdtlusegrp(pHdl, grp);
                short a = Convert.ToInt16(grp.use);
                code = Focas1.cnc_rdtoolgrp(pHdl, a, 20 + 20 * 1, btg);
                resp["currenttoolgroupnum"] = a;
                resp["currenttoolnum"]      = btg.data.data1.tool_num;
            }
            {
                Focas1.ODBSYS odbsys = new Focas1.ODBSYS();
                code = Focas1.cnc_sysinfo(pHdl, odbsys);
                if (code == 0)
                {
                    resp["svnum"] = odbsys.axes[1];
                }
            }
            {
                Focas1.ODBACT odbact = new Focas1.ODBACT();
                code = Focas1.cnc_actf(pHdl, odbact);
                if (code == 0)
                {
                    resp["relfeedrate"] = odbact.data;
                }
            }
            {
                short             b   = 8;
                Focas1.ODBALMMSG2 msg = new Focas1.ODBALMMSG2();
                code = Focas1.cnc_rdalmmsg2(pHdl, -1, ref b, msg);
                if (code == 0)
                {
                    resp["alarmnum"]     = msg.msg2.alm_no;
                    resp["alarmmessage"] = msg.msg2.alm_msg;
                }
            }
            {
                int alarm = 0;
                code = Focas1.cnc_alarm2(pHdl, out alarm);
                if (code == 0)
                {
                    resp["alarmtype"] = alarmTypeMapper.ContainsKey(alarm) ? alarmTypeMapper[alarm] : null;
                }
            }
            {
                Focas1.IODBPSD_1 param6751 = new Focas1.IODBPSD_1();
                Focas1.IODBPSD_1 param6752 = new Focas1.IODBPSD_1();
                code = Focas1.cnc_rdparam(pHdl, 6751, 0, 8, param6751);
                if (code == 0)
                {
                    int workingTimeSec = param6751.ldata / 1000;
                    code = Focas1.cnc_rdparam(pHdl, 6752, 0, 8, param6752);
                    if (code == 0)
                    {
                        int workingTimeMin = param6752.ldata;
                        int workingTime    = workingTimeMin * 60 + workingTimeSec;
                        resp["operatingtime"] = workingTime;
                    }
                }
            }
            {
                Focas1.IODBPSD_1 param6757 = new Focas1.IODBPSD_1();
                Focas1.IODBPSD_1 param6758 = new Focas1.IODBPSD_1();
                code = Focas1.cnc_rdparam(pHdl, 6757, 0, 8, param6757);
                if (code == 0)
                {
                    int circlingTimeSec = param6757.ldata / 1000;
                    code = Focas1.cnc_rdparam(pHdl, 6758, 0, 8, param6758);
                    if (code == 0)
                    {
                        int circlingTimeMin = param6758.ldata;
                        int workingTime     = circlingTimeMin * 60 + circlingTimeSec;
                        resp["circlingtime"] = workingTime;
                    }
                }
            }
            {
                Focas1.IODBPSD_1 param6753 = new Focas1.IODBPSD_1();
                Focas1.IODBPSD_1 param6754 = new Focas1.IODBPSD_1();
                code = Focas1.cnc_rdparam(pHdl, 6753, 0, 8 + 32, param6753);
                if (code == 0)
                {
                    int cuttingTimeSec = param6753.ldata / 1000;
                    code = Focas1.cnc_rdparam(pHdl, 6754, 0, 8 + 32, param6754);
                    if (code == 0)
                    {
                        int cuttingTimeMin = param6754.ldata;
                        int workingTime    = cuttingTimeMin * 60 + cuttingTimeSec;
                        resp["cuttingtime"] = workingTime;
                    }
                }
            }
            {
                Focas1.IODBPSD_1 param6750 = new Focas1.IODBPSD_1();
                code = Focas1.cnc_rdparam(pHdl, 6750, 0, 8 + 32, param6750);
                if (code == 0)
                {
                    int powerOnTime = param6750.ldata * 60;
                    resp["powerontime"] = powerOnTime;
                }
            }
            {
                Focas1.IODBPSD_1 param6712 = new Focas1.IODBPSD_1();
                code = Focas1.cnc_rdparam(pHdl, 6712, 0, 8, param6712);
                if (code == 0)
                {
                    resp["totalparts"] = param6712.ldata;
                }
            }
            return(resp.ToString());
        }
Esempio n. 9
0
        //------------------------------------------------------------------------------------------------------------------//
        //---------------------------------- Get  Changed Values -----------------------------------------------------------//
        //------------------------------------------------------------------------------------------------------------------//

        public void getChangedValues(MachineTool machineTool)
        {
            mAdapter.Begin();

            // Display if machine is available
            if (machineTool.connected)
            {
                mAvail.Value = "AVAILABLE";

                // Display Active Process
                Focas1.cnc_getpath(machineTool.hFanucMonitor, out path, out maxPath);
                if (path == 1)
                {
                    mSelProc.Value = "1";
                }
                else if (path == 2)
                {
                    mSelProc.Value = "2";
                }

//--------------------------------------------------------------------------------------------------------------
                // Display Active Part Program & Sub-Program
                short ret2 = Focas1.cnc_rdexecprog(machineTool.hFanucMonitor, ref length, out blkNum, lineData);
                mBlkNum.Value = blkNum.ToString();
                mActiveLine.Value = GetProgramName(lineData, "\n");

//--------------------------------------------------------------------------------------------------------------
                Focas1.cnc_rdprgnum(machineTool.hFanucMonitor, subProgram);
                mSubProgram.Value = subProgram.data.ToString();

//--------------------------------------------------------------------------------------------------------------
                int ret = Focas1.cnc_exeprgname(machineTool.hFanucMonitor, mainProgram);
                //string progName = mainProgram.name.ToString();
                mProgram.Value = GetProgramName(mainProgram.name, "\0");

//--------------------------------------------------------------------------------------------------------------
                /*uint lineToReadFrom = 1;
                string progData = string.Empty;
                uint linesToRead = 5;
                uint charToRead = 100;

                Focas1.cnc_rdprogline2(machineTool.hFanucMonitor, mainProgram.o_num, lineToReadFrom, progData, ref linesToRead, ref charToRead);*/

//--------------------------------------------------------------------------------------------------------------
                // Display the current selected mode
                switch (machineTool.fanucStatus.aut)
                {
                    case 0:
                        {
                            mMode.Value = "MDI";
                            break;
                        }
                    case 1:
                        {
                            mMode.Value = "AUTO";
                            break;
                        }
                    case 3:
                        {
                            mMode.Value = "EDIT";
                            break;
                        }
                    case 4:
                        {
                            mMode.Value = "HAND WHEEL";
                            break;
                        }
                    case 5:
                        {
                            mMode.Value = "JOG";
                            break;
                        }
                    case 6:
                        {
                            mMode.Value = "TEACH JOG";
                            break;
                        }
                    case 7:
                        {
                            mMode.Value = "TEACH HANDLE";
                            break;
                        }
                    case 8:
                        {
                            mMode.Value = "INC FEED";
                            break;
                        }
                    case 9:
                        {
                            mMode.Value = "REFERENCE";
                            break;
                        }
                    case 10:
                        {
                            mMode.Value = "REMOTE";
                            break;
                        }
                }

//--------------------------------------------------------------------------------------------------------------
                // Currently Selected Table
                mSelTable.Value = 0;

//--------------------------------------------------------------------------------------------------------------
                // Current Active Tool
                if (machineTool.gifuChanger == false)
                {
                    Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, addrType, dataType, toolData, toolData, dataLength,
                        pmcData);
                    mActiveTool.Value = pmcData.cdata[0].ToString();
                }
                else
                {
                    Focas1.ODBM macroInfo = new Focas1.ODBM();
                    Focas1.cnc_rdmacro(machineTool.hFanucMonitor, 276, 10, macroInfo);
                    float toolNum = macroInfo.mcr_val / (10 ^ macroInfo.dec_val);
                    mActiveTool.Value = toolNum.ToString();
                }


//--------------------------------------------------------------------------------------------------------------
                // Display Alarms
                alarmNum = 10;
                ret = Focas1.cnc_rdalmmsg2(machineTool.hFanucMonitor, -1, ref alarmNum, alarmMsg);
                alarm[0] = alarmMsg.msg1.alm_msg;
                alarm[1] = alarmMsg.msg2.alm_msg;
                alarm[2] = alarmMsg.msg3.alm_msg;
                alarm[3] = alarmMsg.msg4.alm_msg;
                alarm[4] = alarmMsg.msg5.alm_msg;
                alarm[5] = alarmMsg.msg6.alm_msg;
                alarm[6] = alarmMsg.msg7.alm_msg;
                alarm[7] = alarmMsg.msg8.alm_msg;
                alarm[8] = alarmMsg.msg9.alm_msg;
                alarm[9] = alarmMsg.msg10.alm_msg;

                alarm[0] = alarm[0].Substring(0, alarmMsg.msg1.msg_len);
                alarm[1] = alarm[1].Substring(0, alarmMsg.msg2.msg_len);
                alarm[2] = alarm[2].Substring(0, alarmMsg.msg3.msg_len);
                alarm[3] = alarm[3].Substring(0, alarmMsg.msg4.msg_len);
                alarm[4] = alarm[4].Substring(0, alarmMsg.msg5.msg_len);
                alarm[5] = alarm[5].Substring(0, alarmMsg.msg6.msg_len);
                alarm[6] = alarm[6].Substring(0, alarmMsg.msg7.msg_len);
                alarm[7] = alarm[7].Substring(0, alarmMsg.msg8.msg_len);
                alarm[8] = alarm[8].Substring(0, alarmMsg.msg9.msg_len);
                alarm[9] = alarm[9].Substring(0, alarmMsg.msg10.msg_len);

                alarmType[0] = almType(alarmMsg.msg1.type);
                alarmType[1] = almType(alarmMsg.msg2.type);
                alarmType[2] = almType(alarmMsg.msg3.type);
                alarmType[3] = almType(alarmMsg.msg4.type);
                alarmType[4] = almType(alarmMsg.msg5.type);
                alarmType[5] = almType(alarmMsg.msg6.type);
                alarmType[6] = almType(alarmMsg.msg7.type);
                alarmType[7] = almType(alarmMsg.msg8.type);
                alarmType[8] = almType(alarmMsg.msg9.type);
                alarmType[9] = almType(alarmMsg.msg10.type);

                alarmNumber[0] = alarmMsg.msg1.alm_no.ToString() + ": ";
                alarmNumber[1] = alarmMsg.msg2.alm_no.ToString() + ": ";
                alarmNumber[2] = alarmMsg.msg3.alm_no.ToString() + ": ";
                alarmNumber[3] = alarmMsg.msg4.alm_no.ToString() + ": ";
                alarmNumber[4] = alarmMsg.msg5.alm_no.ToString() + ": ";
                alarmNumber[5] = alarmMsg.msg6.alm_no.ToString() + ": ";
                alarmNumber[6] = alarmMsg.msg7.alm_no.ToString() + ": ";
                alarmNumber[7] = alarmMsg.msg8.alm_no.ToString() + ": ";
                alarmNumber[8] = alarmMsg.msg9.alm_no.ToString() + ": ";
                alarmNumber[9] = alarmMsg.msg10.alm_no.ToString() + ": ";

                for (short i = 0; i < alarmType.Length; i++)
                {
                    if (alarmType[i] == "SW" && alarm[i].ToString() == string.Empty)
                    {
                        alarmType[i] = string.Empty;
                        alarm[i] = string.Empty;
                        alarmNumber[i] = string.Empty;
                    }
                }
                mAlarm1.Value = alarmType[0].ToString() + alarmNumber[0] + alarm[0].ToString();
                mAlarm2.Value = alarmType[1].ToString() + alarmNumber[1] + alarm[1].ToString();
                mAlarm3.Value = alarmType[2].ToString() + alarmNumber[2] + alarm[2].ToString();
                mAlarm4.Value = alarmType[3].ToString() + alarmNumber[3] + alarm[3].ToString();
                mAlarm5.Value = alarmType[4].ToString() + alarmNumber[4] + alarm[4].ToString();
                mAlarm6.Value = alarmType[5].ToString() + alarmNumber[5] + alarm[5].ToString();
                mAlarm7.Value = alarmType[6].ToString() + alarmNumber[6] + alarm[6].ToString();
                mAlarm8.Value = alarmType[7].ToString() + alarmNumber[7] + alarm[7].ToString();
                mAlarm9.Value = alarmType[8].ToString() + alarmNumber[8] + alarm[8].ToString();
                mAlarm10.Value = alarmType[9].ToString() + alarmNumber[9] + alarm[9].ToString();

//--------------------------------------------------------------------------------------------------------------
                // Clocks
                Focas1.cnc_rdparam(machineTool.hFanucMonitor, 6758, 0, 8, cycTimeMin);
                Focas1.cnc_rdparam(machineTool.hFanucMonitor, 6757, 0, 8, cycTimeSec);
                mCycleTime.Value = cycTimeMin.cdata.ToString() + "." + (cycTimeSec.ldata / 1000).ToString();

                //Focas1.cnc_rdtimer(machineTool.hFanucLib, 1, cycleTime);
                // mOpTime.Value = cycleTime.minute.ToString() + "." + cycleTime.msec.ToString();

//--------------------------------------------------------------------------------------------------------------
                // Display Feed, Speed overrides
                ret = Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, 0, 0, 96, 96, 16, pmcOverrides);
                mFeedOv.Value = (255-pmcOverrides.cdata[0]).ToString();
                ret = Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, 0, 0, 30, 30, 16, pmcOverrides);
                mSpeedOv.Value = pmcOverrides.cdata[0].ToString();

//--------------------------------------------------------------------------------------------------------------
                // Display Programmed Feed & Speed
                mPrgFeed.Value = "0";
                mPrgSpeed.Value = "0";

//--------------------------------------------------------------------------------------------------------------
                // Check the current feed rates
                Focas1.ODBACT feedRate = new Focas1.ODBACT();
                Focas1.cnc_actf(machineTool.hFanucMonitor, feedRate);
                mRealFeed.Value = (feedRate.data / 10000).ToString();

//--------------------------------------------------------------------------------------------------------------
                // Check Spindle Speed
                Focas1.ODBACT2 spindleSpeed = new Focas1.ODBACT2();
                Focas1.cnc_acts2(machineTool.hFanucMonitor, 1, spindleSpeed);
                mRealSpeed.Value = (spindleSpeed.data[0] / 10000).ToString();

//--------------------------------------------------------------------------------------------------------------
                // Get Drives Ready
                int ret3 = Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, 1, 0, 1, 1, 16, pmcDrivesOn);
                driveReady = GetBit(pmcDrivesOn.cdata[0], 7, true);
                mDrivesReady.Value = driveReady ? "Ready" : "Not Ready";

//--------------------------------------------------------------------------------------------------------------
                // Get Messages
                Focas1.OPMSG3 opmsg = new Focas1.OPMSG3();
                short msgSize = 5;
                Focas1.cnc_rdopmsg3(machineTool.hFanucMonitor, -1, ref msgSize, opmsg);

                // Op Message 1
                if (opmsg.msg1.datano != 0 && opmsg.msg1.datano != -1)
                {
                    mOpMsg1.Value = opmsg.msg1.data.ToString();
                }
                else
                {
                    mOpMsg1.Value = string.Empty;
                }

                // Op Message 2
                if (opmsg.msg2.datano != 0 && opmsg.msg2.datano != -1)
                {
                    mOpMsg2.Value = opmsg.msg2.data.ToString();
                }
                else
                {
                    mOpMsg2.Value = string.Empty;
                }

                // Op Message 3
                if (opmsg.msg3.datano != 0 && opmsg.msg3.datano != -1)
                {
                    mOpMsg3.Value = opmsg.msg3.data.ToString();
                }
                else
                {
                    mOpMsg3.Value = string.Empty;
                }

                // Op Message 4
                if (opmsg.msg4.datano != 0 && opmsg.msg4.datano != -1)
                {
                    mOpMsg4.Value = opmsg.msg4.data.ToString();
                }
                else
                {
                    mOpMsg4.Value = string.Empty;
                }

//--------------------------------------------------------------------------------------------------------------
                // Get Drives On
                ret3 = Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, 1, 0, 0, 0, 16, pmcDrivesOn);
                drivesOn = GetBit(pmcDrivesOn.cdata[0], 2);
                mDrivesOn.Value = drivesOn ? "Drives On" : "Drives Off";

//--------------------------------------------------------------------------------------------------------------
                // If Drives are not on and we have a reason set already, figure out how long we have been in estop
                if (!drivesOn && reasonSet)
                {
                    mDownTimeDuration.Value = dt.GetElapsedDownTime(ref totalElapsedDT);
                }

                // If the drives are not on and we do not have a reason set, show the reason popup box
                // And start our downtime counter. Also set reason to true. 
                if (!drivesOn && !reasonSet)
                {
                    machineTool.Invoke((MethodInvoker)delegate() { dt.Show(); });
                    startTime = dt.startDownTimeCounter();
                    reasonSet = true;
                }

                // If the drives are on (We have cleared all the errors), and we have a reason set (We just came out of estop)
                // So we will get the duration of the downtime, the reason for the downtime and record it.
                if (drivesOn && reasonSet)
                {
                    duration = dt.GetElapsedDownTime(ref totalElapsedDT);
                    endTime = dt.stopDownTimeCounter();
                    mDTReason.Value = dt.reason;

                    // Log the Downtime here
                    dtBuffer = true;
                    BufferDataItems();
                    dtBuffer = false;

                    reasonSet = false;
                }

                if (mDTReason.Value != string.Empty)
                {
                    // Now that we are back in our normal loop, the reason is no longer needed
                    // So now we set it to an empty string and set it to the reason for the last
                    // Downtime period that we had.
                    mDTLastReason.Value = dt.reason;
                    mDTReason.Value = string.Empty;
                    mDownTimeDuration.Value = string.Empty;
                    mLastDownTimeDuration.Value = duration;
                }

//---------------------------------------------------------------------------------------------------------------



                

                // Get Feed Hold


                // Vac On / Off
                Focas1.IODBPMC0 vacSensors = new Focas1.IODBPMC0();
                ret3 = Focas1.pmc_rdpmcrng(machineTool.hFanucMonitor, 5, 0, 46,46, 16, vacSensors);
                bool vac1 = GetBit(vacSensors.cdata[0], 1, false);
                bool vac2 = GetBit(vacSensors.cdata[0], 2, false);
                bool vac3 = GetBit(vacSensors.cdata[0], 3, false);
                bool vac4 = GetBit(vacSensors.cdata[0], 4, false);
                bool vac5 = GetBit(vacSensors.cdata[0], 5, false);
                bool vac6 = GetBit(vacSensors.cdata[0], 6, false);
                bool vac7 = GetBit(vacSensors.cdata[0], 7, false);
                bool vac8 = GetBit(vacSensors.cdata[0], 8, false);

            }
            else
            {
                mAvail.Value = "UNAVAILABLE";
            }
        }