コード例 #1
0
ファイル: MachineFanuc.cs プロジェクト: hhhush/middle-layer
        //读主轴转速 actual rotational speed (可一次读所有主轴) (使用这一个)
        #region cnc_acts2
        short IMachineFanuc.GetSpindleSpeed(out long SpindleSpeed)
        {
            Focas1.ODBACT2 odbact_RotationSpeed = new Focas1.ODBACT2();
            short          ret = Focas1.cnc_acts2(mFlibhndl, 1, odbact_RotationSpeed);

            SpindleSpeed = odbact_RotationSpeed.data[0];
            return(ret);
        }
コード例 #2
0
ファイル: Report.cs プロジェクト: onsruddev/O-Sync
        //------------------------------------------------------------------------------------------------------------------//
        //---------------------------------- 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";
            }
        }