Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3.  
  4. import xml.etree.ElementTree as oXML
  5.  
  6. class xmlBiesse(object):
  7.  
  8. def __init__(self):
  9. #self.oXMLtree = oXML.parse('/home/bob/linuxcnc/nc_files/gcode/BiesseRover346.xml')
  10. #self.oXMLtree = oXML.parse('/home/mike/....../BiesseRover346.xml')
  11. self.oXMLtree = oXML.parse('BiesseRover346.xml')
  12. #self.oXMLtree = oXML.parse('/home/bob/linuxcnc/configs/python/BiesseRover346.xml')
  13. self.oXMLroot = self.oXMLtree.getroot()
  14. machineType = self.oXMLroot.get('type')
  15. print("Machine type is : %s" % machineType)
  16.  
  17. #--------------------------------------------------------------------------
  18. # for Signals/Signal name= returns index, dir, isPulse, mesanet in a tuple
  19. #--------------------------------------------------------------------------
  20. def getSignalInfos(self, sSignalName):
  21. oXML = self.oXMLroot.find('Signals/Signal[@name="%s"]' % sSignalName)
  22. index = oXML.get('index')
  23. #print("index = %s" % index)
  24. #direc = oXML.get('dir')
  25. #desc = oXML.get('desc')
  26. #mesaIN = oXML.get('mesaIN')
  27. #mesaOUT = oXML.get('mesaOUT')
  28. return int(index) #, direc, desc, mesaIN, mesaOUT
  29.  
  30. #--------------------------------------------------------------------------
  31. # for Pulse Delay, time to wait to lower what we just put high
  32. #--------------------------------------------------------------------------
  33. def getPulseDelay(self):
  34. oXML = self.oXMLroot.find('Pulse')
  35. pulseDelay = oXML.get('delay')
  36. return float("%s" % pulseDelay)
  37.  
  38. #--------------------------------------------------------------------------
  39. # Delay to wait after opening the Casket/Cover
  40. #--------------------------------------------------------------------------
  41. def getCoverDelay(self):
  42. oXML = self.oXMLroot.find('Pulse')
  43. pulseDelay = oXML.get('coverDelay')
  44. return float("%s" % pulseDelay)
  45.  
  46. #--------------------------------------------------------------------------
  47. # for testing if spindle stopped and wait for it, multiple times
  48. #--------------------------------------------------------------------------
  49. def getSpindleStopDelay(self):
  50. oXML = self.oXMLroot.find('Pulse')
  51. spindleStopDelay = oXML.get("spindleStop")
  52. maxTrials = oXML.get("maxSpindleTrialsToStop")
  53. return float(spindleStopDelay), int(maxTrials)
  54.  
  55. def getActuationDelay(self):
  56. oXML = self.oXMLroot.find('Pulse')
  57. actuationDelay = oXML.get("actuationDelay")
  58. return float(actuationDelay)
  59.  
  60.  
  61. #--------------------------------------------------------------------------
  62. # for First Index of Drills ... patch
  63. #--------------------------------------------------------------------------
  64. def getFirstIndex(self, sWhat):
  65. oXML = self.oXMLroot.find('FirstIndex')
  66. pulseDelay = oXML.get(sWhat)
  67. return int("%s" % pulseDelay)
  68. #--------------------------------------------------------------------------
  69. # For Feed speed
  70. #--------------------------------------------------------------------------
  71. def getFeedSpeed(self):
  72. oXML = self.oXMLroot.find('Feed')
  73. feedSpeed = oXML.get('speed')
  74. return int("%s" % feedSpeed)
  75.  
  76. #--------------------------------------------------------------------------
  77. # get the position of the pocket ... 1,2,3 and Top or Front
  78. #--------------------------------------------------------------------------
  79. def getPocketPos(self, sWhichPocket, sWhichPosition):
  80. #print("%s-%s" % (sWhichPocket, sWhichPosition))
  81. oXML = self.oXMLroot.find('Pockets/Pocket[@id="%s"]' % sWhichPocket)
  82. oXML2 = oXML.find('%s' % sWhichPosition)
  83. posX = oXML2.get("x")
  84. posY = oXML2.get("y")
  85. posZ = oXML2.get("z")
  86. return float(posX), float(posY), float(posZ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement