Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // myfanuc.cpp : Defines the exported functions for the DLL application.
- #include "stdafx.h"
- #include "myfanuc.h"
- #include <stdlib.h>
- short Cdevice::DeviceReadExt(unsigned short hFanuc, int iPass) // Handle + Number of function
- {
- m_stat.cReturn[0] = 0x00; // Empty previous result
- short ret = -18; // Result of function (Initial: Unknown Error)
- ODBST odbst; // Machine State structure
- IODBPMC iodbpmc; // PMC (PLC) structure
- IODBPSD iodbpsd; // Parameter structure
- switch (iPass)
- {
- case 2: // Begin at 2!
- // See: https://www.inventcom.net/fanuc-focas-library/misc/cnc_statinfo
- ret = cnc_statinfo(hFanuc, &odbst);
- if (!ret) // If it worked
- sprintf(m_stat.cReturn, "%d", odbst.aut); // Automatic mode number, also available: odbst.run; odbst.emergency; dbst.alarm; odbst.edit;
- break;
- case 3:
- // See; https://www.inventcom.net/fanuc-focas-library/ncdata/cnc_rdparam
- ret = cnc_rdparam(hFanuc, 6711, 0, 8, &iodbpsd); // 6711 = Part counter
- if (!ret)
- sprintf(m_stat.cReturn, "%d", (int)iodbpsd.u.idata); // Parameter value
- break;
- case 4:
- // See: https://www.inventcom.net/fanuc-focas-library/pmc/pmc_rdpmcrng
- ret = pmc_rdpmcrng(hFanuc, 9, 0, 4200, 4200, 9, &iodbpmc); // 4200 = PMC address 9 = User data
- if (!ret)
- sprintf(m_stat.cReturn, "%d", (int)iodbpmc.u.cdata[0]); // Parameter value
- break;
- default:
- break;
- }
- return ret; // Returns 0 if successfull
- }
- char *Cdevice::DeviceDataStringExt() // Return data (string)
- {
- return(m_stat.cReturn);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement