Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. // myfanuc.cpp : Defines the exported functions for the DLL application.
  2.  
  3. #include "stdafx.h"
  4. #include "myfanuc.h"
  5. #include <stdlib.h>
  6.  
  7. short Cdevice::DeviceReadExt(unsigned short hFanuc, int iPass) // Handle + Number of function
  8. {
  9.     m_stat.cReturn[0] = 0x00; // Empty previous result
  10.     short ret = -18; // Result of function (Initial: Unknown Error)
  11.    
  12.     ODBST odbst; // Machine State structure
  13.     IODBPMC iodbpmc; // PMC (PLC) structure
  14.     IODBPSD iodbpsd; // Parameter structure
  15.  
  16.     switch (iPass)
  17.     {
  18.     case 2: // Begin at 2!
  19.         // See: https://www.inventcom.net/fanuc-focas-library/misc/cnc_statinfo
  20.         ret = cnc_statinfo(hFanuc, &odbst);
  21.         if (!ret) // If it worked
  22.             sprintf(m_stat.cReturn, "%d", odbst.aut); // Automatic mode number, also available: odbst.run; odbst.emergency; dbst.alarm; odbst.edit;
  23.         break;
  24.     case 3:
  25.         // See; https://www.inventcom.net/fanuc-focas-library/ncdata/cnc_rdparam
  26.         ret = cnc_rdparam(hFanuc, 6711, 0, 8, &iodbpsd); // 6711 = Part counter
  27.         if (!ret)
  28.             sprintf(m_stat.cReturn, "%d", (int)iodbpsd.u.idata); // Parameter value
  29.         break;
  30.     case 4:
  31.         // See: https://www.inventcom.net/fanuc-focas-library/pmc/pmc_rdpmcrng
  32.         ret = pmc_rdpmcrng(hFanuc, 9, 0, 4200, 4200, 9, &iodbpmc); // 4200 = PMC address 9 = User data
  33.         if (!ret)
  34.             sprintf(m_stat.cReturn, "%d", (int)iodbpmc.u.cdata[0]); // Parameter value
  35.         break;
  36.     default:
  37.         break;
  38.     }
  39.  
  40.     return ret; // Returns 0 if successfull
  41. }
  42.  
  43. char *Cdevice::DeviceDataStringExt() // Return data (string)
  44. {
  45.     return(m_stat.cReturn);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement